summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
Diffstat (limited to 'media')
-rw-r--r--media/libaah_rtp/Android.mk40
-rw-r--r--media/libaah_rtp/MODULE_LICENSE_APACHE20
-rw-r--r--media/libaah_rtp/NOTICE190
-rw-r--r--media/libaah_rtp/aah_decoder_pump.cpp519
-rw-r--r--media/libaah_rtp/aah_decoder_pump.h107
-rw-r--r--media/libaah_rtp/aah_rx_player.cpp288
-rw-r--r--media/libaah_rtp/aah_rx_player.h318
-rw-r--r--media/libaah_rtp/aah_rx_player_core.cpp809
-rw-r--r--media/libaah_rtp/aah_rx_player_ring_buffer.cpp366
-rw-r--r--media/libaah_rtp/aah_rx_player_substream.cpp677
-rw-r--r--media/libaah_rtp/aah_tx_packet.cpp344
-rw-r--r--media/libaah_rtp/aah_tx_packet.h213
-rw-r--r--media/libaah_rtp/aah_tx_player.cpp1177
-rw-r--r--media/libaah_rtp/aah_tx_player.h176
-rw-r--r--media/libaah_rtp/aah_tx_sender.cpp603
-rw-r--r--media/libaah_rtp/aah_tx_sender.h162
-rw-r--r--media/libaah_rtp/pipe_event.cpp86
-rw-r--r--media/libaah_rtp/pipe_event.h51
-rw-r--r--media/libeffects/data/audio_effects.conf39
-rw-r--r--media/libeffects/factory/EffectsFactory.c4
-rw-r--r--media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c5
-rw-r--r--media/libeffects/lvm/lib/Bundle/src/LVM_Init.c7
-rw-r--r--media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c3
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp272
-rw-r--r--media/libeffects/lvm/wrapper/Bundle/EffectBundle.h2
-rwxr-xr-xmedia/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp10
-rwxr-xr-xmedia/libeffects/preprocessing/PreProcessing.cpp10
-rw-r--r--media/libeffects/testlibs/EffectEqualizer.cpp10
-rw-r--r--media/libeffects/testlibs/EffectReverb.c8
-rw-r--r--media/libeffects/visualizer/EffectVisualizer.cpp10
-rw-r--r--media/libmedia/Android.mk3
-rw-r--r--media/libmedia/AudioEffect.cpp13
-rw-r--r--media/libmedia/AudioRecord.cpp231
-rw-r--r--media/libmedia/AudioSystem.cpp51
-rw-r--r--media/libmedia/AudioTrack.cpp37
-rw-r--r--media/libmedia/IAudioFlinger.cpp61
-rw-r--r--media/libmedia/IAudioPolicyService.cpp42
-rw-r--r--media/libmedia/IAudioRecord.cpp4
-rw-r--r--media/libmedia/IHDCP.cpp206
-rw-r--r--media/libmedia/IMediaPlayer.cpp34
-rw-r--r--media/libmedia/IMediaPlayerService.cpp41
-rw-r--r--media/libmedia/IRemoteDisplay.cpp63
-rw-r--r--media/libmedia/IRemoteDisplayClient.cpp102
-rw-r--r--media/libmedia/IStreamSource.cpp16
-rw-r--r--media/libmedia/MediaProfiles.cpp2
-rw-r--r--media/libmedia/Visualizer.cpp9
-rw-r--r--media/libmediaplayerservice/Android.mk67
-rw-r--r--media/libmediaplayerservice/HDCP.cpp127
-rw-r--r--media/libmediaplayerservice/HDCP.h54
-rw-r--r--media/libmediaplayerservice/MediaPlayerFactory.cpp340
-rw-r--r--media/libmediaplayerservice/MediaPlayerFactory.h84
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.cpp290
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.h11
-rw-r--r--media/libmediaplayerservice/MetadataRetrieverClient.cpp22
-rw-r--r--media/libmediaplayerservice/RemoteDisplay.cpp52
-rw-r--r--media/libmediaplayerservice/RemoteDisplay.h53
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.cpp29
-rw-r--r--media/libmediaplayerservice/nuplayer/Android.mk1
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp2
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.h3
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp2
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.h3
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp71
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h10
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp41
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h2
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp24
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp12
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h9
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayerSource.h4
-rw-r--r--media/libmediaplayerservice/nuplayer/RTSPSource.cpp78
-rw-r--r--media/libmediaplayerservice/nuplayer/RTSPSource.h7
-rw-r--r--media/libmediaplayerservice/nuplayer/StreamingSource.cpp24
-rw-r--r--media/libmediaplayerservice/nuplayer/StreamingSource.h3
-rw-r--r--media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp136
-rw-r--r--media/libmediaplayerservice/nuplayer/mp4/MP4Source.h52
-rw-r--r--media/libnbaio/Android.mk32
-rw-r--r--media/libnbaio/AudioBufferProviderSource.cpp145
-rw-r--r--media/libnbaio/AudioStreamInSource.cpp83
-rw-r--r--media/libnbaio/AudioStreamOutSink.cpp82
-rw-r--r--media/libnbaio/LibsndfileSink.cpp50
-rw-r--r--media/libnbaio/LibsndfileSource.cpp80
-rw-r--r--media/libnbaio/MonoPipe.cpp313
-rw-r--r--media/libnbaio/MonoPipeReader.cpp89
-rw-r--r--media/libnbaio/NBAIO.cpp190
-rw-r--r--media/libnbaio/Pipe.cpp70
-rw-r--r--media/libnbaio/PipeReader.cpp95
-rw-r--r--media/libnbaio/README.txt40
-rw-r--r--media/libnbaio/SourceAudioBufferProvider.cpp104
-rw-r--r--media/libnbaio/roundup.c32
-rw-r--r--media/libstagefright/AACWriter.cpp17
-rw-r--r--media/libstagefright/ACodec.cpp217
-rw-r--r--media/libstagefright/AMRWriter.cpp11
-rw-r--r--media/libstagefright/Android.mk15
-rw-r--r--media/libstagefright/AudioSource.cpp20
-rw-r--r--media/libstagefright/AwesomePlayer.cpp84
-rwxr-xr-xmedia/libstagefright/CameraSource.cpp32
-rw-r--r--media/libstagefright/DRMExtractor.cpp5
-rw-r--r--media/libstagefright/DataSource.cpp20
-rw-r--r--media/libstagefright/FLACExtractor.cpp63
-rw-r--r--media/libstagefright/FragmentedMP4Extractor.cpp460
-rw-r--r--media/libstagefright/HTTPBase.cpp7
-rw-r--r--media/libstagefright/MP3Extractor.cpp15
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp61
-rwxr-xr-xmedia/libstagefright/MPEG4Writer.cpp461
-rw-r--r--media/libstagefright/MediaCodec.cpp99
-rw-r--r--media/libstagefright/MediaDefs.cpp2
-rw-r--r--media/libstagefright/MediaExtractor.cpp8
-rw-r--r--media/libstagefright/MetaData.cpp8
-rw-r--r--media/libstagefright/NuCachedSource2.cpp12
-rw-r--r--media/libstagefright/NuMediaExtractor.cpp32
-rwxr-xr-xmedia/libstagefright/OMXCodec.cpp227
-rw-r--r--media/libstagefright/StagefrightMediaScanner.cpp2
-rw-r--r--media/libstagefright/StagefrightMetadataRetriever.cpp46
-rw-r--r--media/libstagefright/SurfaceMediaSource.cpp152
-rw-r--r--media/libstagefright/ThrottledSource.cpp10
-rw-r--r--media/libstagefright/TimeSource.cpp13
-rw-r--r--media/libstagefright/TimedEventQueue.cpp15
-rw-r--r--media/libstagefright/Utils.cpp191
-rw-r--r--media/libstagefright/WAVExtractor.cpp9
-rw-r--r--media/libstagefright/WVMExtractor.cpp36
-rw-r--r--media/libstagefright/avc_utils.cpp5
-rw-r--r--media/libstagefright/chromium_http/Android.mk17
-rw-r--r--media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp6
-rw-r--r--media/libstagefright/chromium_http/chromium_http_stub.cpp33
-rw-r--r--media/libstagefright/chromium_http_stub.cpp81
-rw-r--r--media/libstagefright/codecs/aacdec/Android.mk223
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC.cpp553
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC.h78
-rw-r--r--media/libstagefright/codecs/aacdec/SoftAAC2.cpp92
-rw-r--r--media/libstagefright/codecs/aacdec/aac_mem_funcs.h50
-rw-r--r--media/libstagefright/codecs/aacdec/analysis_sub_band.cpp289
-rw-r--r--media/libstagefright/codecs/aacdec/analysis_sub_band.h82
-rw-r--r--media/libstagefright/codecs/aacdec/apply_ms_synt.cpp454
-rw-r--r--media/libstagefright/codecs/aacdec/apply_ms_synt.h94
-rw-r--r--media/libstagefright/codecs/aacdec/apply_tns.cpp424
-rw-r--r--media/libstagefright/codecs/aacdec/apply_tns.h113
-rw-r--r--media/libstagefright/codecs/aacdec/bit_reversal_swap.h93
-rw-r--r--media/libstagefright/codecs/aacdec/buf_getbits.cpp167
-rw-r--r--media/libstagefright/codecs/aacdec/buf_getbits.h94
-rw-r--r--media/libstagefright/codecs/aacdec/buffer_normalization.h93
-rw-r--r--media/libstagefright/codecs/aacdec/byte_align.cpp179
-rw-r--r--media/libstagefright/codecs/aacdec/calc_auto_corr.cpp416
-rw-r--r--media/libstagefright/codecs/aacdec/calc_auto_corr.h122
-rw-r--r--media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp267
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp360
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h113
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp2203
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_envelope.h144
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp639
-rw-r--r--media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h94
-rw-r--r--media/libstagefright/codecs/aacdec/chans.h107
-rw-r--r--media/libstagefright/codecs/aacdec/check_crc.cpp144
-rw-r--r--media/libstagefright/codecs/aacdec/check_crc.h124
-rw-r--r--media/libstagefright/codecs/aacdec/dct16.cpp266
-rw-r--r--media/libstagefright/codecs/aacdec/dct16.h68
-rw-r--r--media/libstagefright/codecs/aacdec/dct64.cpp569
-rw-r--r--media/libstagefright/codecs/aacdec/dct64.h81
-rw-r--r--media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp708
-rw-r--r--media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp163
-rw-r--r--media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h92
-rw-r--r--media/libstagefright/codecs/aacdec/deinterleave.cpp287
-rw-r--r--media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp279
-rw-r--r--media/libstagefright/codecs/aacdec/digit_reversal_tables.h86
-rw-r--r--media/libstagefright/codecs/aacdec/dst16.cpp172
-rw-r--r--media/libstagefright/codecs/aacdec/dst16.h68
-rw-r--r--media/libstagefright/codecs/aacdec/dst32.cpp200
-rw-r--r--media/libstagefright/codecs/aacdec/dst32.h69
-rw-r--r--media/libstagefright/codecs/aacdec/dst8.cpp179
-rw-r--r--media/libstagefright/codecs/aacdec/dst8.h68
-rw-r--r--media/libstagefright/codecs/aacdec/e_adif_const.h97
-rw-r--r--media/libstagefright/codecs/aacdec/e_blockswitching.h112
-rw-r--r--media/libstagefright/codecs/aacdec/e_coupling_mode.h88
-rw-r--r--media/libstagefright/codecs/aacdec/e_elementid.h99
-rw-r--r--media/libstagefright/codecs/aacdec/e_huffmanconst.h119
-rw-r--r--media/libstagefright/codecs/aacdec/e_infoinitconst.h96
-rw-r--r--media/libstagefright/codecs/aacdec/e_invf_mode.h91
-rw-r--r--media/libstagefright/codecs/aacdec/e_maskstatus.h91
-rw-r--r--media/libstagefright/codecs/aacdec/e_mp4ff_const.h105
-rw-r--r--media/libstagefright/codecs/aacdec/e_progconfigconst.h110
-rw-r--r--media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h130
-rw-r--r--media/libstagefright/codecs/aacdec/e_sbr_element_id.h87
-rw-r--r--media/libstagefright/codecs/aacdec/e_sbr_error.h106
-rw-r--r--media/libstagefright/codecs/aacdec/e_sbr_header_status.h88
-rw-r--r--media/libstagefright/codecs/aacdec/e_sbr_master_status.h87
-rw-r--r--media/libstagefright/codecs/aacdec/e_sbr_sync_state.h88
-rw-r--r--media/libstagefright/codecs/aacdec/e_sr_mode.h88
-rw-r--r--media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h118
-rw-r--r--media/libstagefright/codecs/aacdec/e_tns_const.h91
-rw-r--r--media/libstagefright/codecs/aacdec/e_window_sequence.h90
-rw-r--r--media/libstagefright/codecs/aacdec/e_window_shape.h89
-rw-r--r--media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp789
-rw-r--r--media/libstagefright/codecs/aacdec/esc_iquant_scaling.h102
-rw-r--r--media/libstagefright/codecs/aacdec/extractframeinfo.cpp487
-rw-r--r--media/libstagefright/codecs/aacdec/extractframeinfo.h96
-rw-r--r--media/libstagefright/codecs/aacdec/fft_rx4.h110
-rw-r--r--media/libstagefright/codecs/aacdec/fft_rx4_long.cpp428
-rw-r--r--media/libstagefright/codecs/aacdec/fft_rx4_short.cpp468
-rw-r--r--media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp269
-rw-r--r--media/libstagefright/codecs/aacdec/find_adts_syncword.cpp305
-rw-r--r--media/libstagefright/codecs/aacdec/find_adts_syncword.h87
-rw-r--r--media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp284
-rw-r--r--media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h96
-rw-r--r--media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp261
-rw-r--r--media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h92
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32.h72
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h547
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h429
-rwxr-xr-xmedia/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h630
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h450
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h285
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h254
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h178
-rw-r--r--media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h55
-rw-r--r--media/libstagefright/codecs/aacdec/gen_rand_vector.cpp512
-rw-r--r--media/libstagefright/codecs/aacdec/gen_rand_vector.h87
-rw-r--r--media/libstagefright/codecs/aacdec/get_adif_header.cpp443
-rw-r--r--media/libstagefright/codecs/aacdec/get_adif_header.h95
-rw-r--r--media/libstagefright/codecs/aacdec/get_adts_header.cpp672
-rw-r--r--media/libstagefright/codecs/aacdec/get_adts_header.h90
-rw-r--r--media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp691
-rw-r--r--media/libstagefright/codecs/aacdec/get_audio_specific_config.h86
-rw-r--r--media/libstagefright/codecs/aacdec/get_dse.cpp215
-rw-r--r--media/libstagefright/codecs/aacdec/get_dse.h87
-rw-r--r--media/libstagefright/codecs/aacdec/get_ele_list.cpp243
-rw-r--r--media/libstagefright/codecs/aacdec/get_ele_list.h90
-rw-r--r--media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp473
-rw-r--r--media/libstagefright/codecs/aacdec/get_ga_specific_config.h94
-rw-r--r--media/libstagefright/codecs/aacdec/get_ics_info.cpp608
-rw-r--r--media/libstagefright/codecs/aacdec/get_ics_info.h111
-rw-r--r--media/libstagefright/codecs/aacdec/get_prog_config.cpp739
-rw-r--r--media/libstagefright/codecs/aacdec/get_prog_config.h89
-rw-r--r--media/libstagefright/codecs/aacdec/get_pulse_data.cpp286
-rw-r--r--media/libstagefright/codecs/aacdec/get_pulse_data.h100
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp183
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_bitstream.h126
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp183
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_startfreq.h85
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp190
-rw-r--r--media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h85
-rw-r--r--media/libstagefright/codecs/aacdec/get_sign_bits.h99
-rw-r--r--media/libstagefright/codecs/aacdec/get_tns.cpp573
-rw-r--r--media/libstagefright/codecs/aacdec/get_tns.h124
-rw-r--r--media/libstagefright/codecs/aacdec/getbits.h346
-rw-r--r--media/libstagefright/codecs/aacdec/getfill.cpp247
-rw-r--r--media/libstagefright/codecs/aacdec/getfill.h88
-rw-r--r--media/libstagefright/codecs/aacdec/getgroup.cpp255
-rw-r--r--media/libstagefright/codecs/aacdec/getics.cpp674
-rw-r--r--media/libstagefright/codecs/aacdec/getmask.cpp384
-rw-r--r--media/libstagefright/codecs/aacdec/hcbtables.h118
-rw-r--r--media/libstagefright/codecs/aacdec/hcbtables_binary.cpp1938
-rw-r--r--media/libstagefright/codecs/aacdec/huffcb.cpp381
-rw-r--r--media/libstagefright/codecs/aacdec/huffdecode.cpp528
-rw-r--r--media/libstagefright/codecs/aacdec/hufffac.cpp550
-rw-r--r--media/libstagefright/codecs/aacdec/huffman.h241
-rw-r--r--media/libstagefright/codecs/aacdec/huffspec_fxp.cpp671
-rw-r--r--media/libstagefright/codecs/aacdec/ibstream.h115
-rw-r--r--media/libstagefright/codecs/aacdec/idct16.cpp204
-rw-r--r--media/libstagefright/codecs/aacdec/idct16.h69
-rw-r--r--media/libstagefright/codecs/aacdec/idct32.cpp196
-rw-r--r--media/libstagefright/codecs/aacdec/idct32.h69
-rw-r--r--media/libstagefright/codecs/aacdec/idct8.cpp168
-rw-r--r--media/libstagefright/codecs/aacdec/idct8.h69
-rw-r--r--media/libstagefright/codecs/aacdec/imdct_fxp.cpp476
-rw-r--r--media/libstagefright/codecs/aacdec/imdct_fxp.h122
-rw-r--r--media/libstagefright/codecs/aacdec/infoinit.cpp355
-rw-r--r--media/libstagefright/codecs/aacdec/init_sbr_dec.cpp192
-rw-r--r--media/libstagefright/codecs/aacdec/init_sbr_dec.h115
-rw-r--r--media/libstagefright/codecs/aacdec/intensity_right.cpp457
-rw-r--r--media/libstagefright/codecs/aacdec/intensity_right.h97
-rw-r--r--media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp408
-rw-r--r--media/libstagefright/codecs/aacdec/inv_long_complex_rot.h99
-rw-r--r--media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp305
-rw-r--r--media/libstagefright/codecs/aacdec/inv_short_complex_rot.h88
-rw-r--r--media/libstagefright/codecs/aacdec/iquant_table.cpp1131
-rw-r--r--media/libstagefright/codecs/aacdec/iquant_table.h85
-rw-r--r--media/libstagefright/codecs/aacdec/long_term_prediction.cpp648
-rw-r--r--media/libstagefright/codecs/aacdec/long_term_prediction.h122
-rw-r--r--media/libstagefright/codecs/aacdec/long_term_synthesis.cpp1158
-rw-r--r--media/libstagefright/codecs/aacdec/long_term_synthesis.h105
-rw-r--r--media/libstagefright/codecs/aacdec/lt_decode.cpp507
-rw-r--r--media/libstagefright/codecs/aacdec/lt_decode.h96
-rw-r--r--media/libstagefright/codecs/aacdec/lt_prediction.h69
-rw-r--r--media/libstagefright/codecs/aacdec/ltp_common_internal.h115
-rw-r--r--media/libstagefright/codecs/aacdec/mdct_fxp.cpp450
-rw-r--r--media/libstagefright/codecs/aacdec/mdct_fxp.h107
-rw-r--r--media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp253
-rw-r--r--media/libstagefright/codecs/aacdec/mdst.cpp294
-rw-r--r--media/libstagefright/codecs/aacdec/mdst.h73
-rw-r--r--media/libstagefright/codecs/aacdec/mix_radix_fft.cpp319
-rw-r--r--media/libstagefright/codecs/aacdec/mix_radix_fft.h98
-rw-r--r--media/libstagefright/codecs/aacdec/ms_map_mask.h87
-rw-r--r--media/libstagefright/codecs/aacdec/ms_synt.cpp403
-rw-r--r--media/libstagefright/codecs/aacdec/ms_synt.h96
-rw-r--r--media/libstagefright/codecs/aacdec/pns_corr.cpp342
-rw-r--r--media/libstagefright/codecs/aacdec/pns_corr.h95
-rw-r--r--media/libstagefright/codecs/aacdec/pns_intensity_right.cpp653
-rw-r--r--media/libstagefright/codecs/aacdec/pns_intensity_right.h106
-rw-r--r--media/libstagefright/codecs/aacdec/pns_left.cpp431
-rw-r--r--media/libstagefright/codecs/aacdec/pns_left.h113
-rw-r--r--media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp311
-rw-r--r--media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h105
-rw-r--r--media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp391
-rw-r--r--media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h117
-rw-r--r--media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp341
-rw-r--r--media/libstagefright/codecs/aacdec/ps_allocate_decoder.h94
-rw-r--r--media/libstagefright/codecs/aacdec/ps_applied.cpp216
-rw-r--r--media/libstagefright/codecs/aacdec/ps_applied.h101
-rw-r--r--media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp304
-rw-r--r--media/libstagefright/codecs/aacdec/ps_bstr_decoding.h98
-rw-r--r--media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp281
-rw-r--r--media/libstagefright/codecs/aacdec/ps_channel_filtering.h104
-rw-r--r--media/libstagefright/codecs/aacdec/ps_constants.h89
-rw-r--r--media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp274
-rw-r--r--media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h112
-rw-r--r--media/libstagefright/codecs/aacdec/ps_decorrelate.cpp499
-rw-r--r--media/libstagefright/codecs/aacdec/ps_decorrelate.h99
-rw-r--r--media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp318
-rw-r--r--media/libstagefright/codecs/aacdec/ps_fft_rx8.h94
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp285
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h98
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp213
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h97
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp192
-rw-r--r--media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h97
-rw-r--r--media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp496
-rw-r--r--media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h97
-rw-r--r--media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp340
-rw-r--r--media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h96
-rw-r--r--media/libstagefright/codecs/aacdec/ps_read_data.cpp388
-rw-r--r--media/libstagefright/codecs/aacdec/ps_read_data.h100
-rw-r--r--media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp372
-rw-r--r--media/libstagefright/codecs/aacdec/ps_stereo_processing.h98
-rw-r--r--media/libstagefright/codecs/aacdec/pulse_nc.cpp298
-rw-r--r--media/libstagefright/codecs/aacdec/pulse_nc.h104
-rw-r--r--media/libstagefright/codecs/aacdec/pv_audio_type_defs.h183
-rw-r--r--media/libstagefright/codecs/aacdec/pv_div.cpp188
-rw-r--r--media/libstagefright/codecs/aacdec/pv_div.h74
-rw-r--r--media/libstagefright/codecs/aacdec/pv_log2.cpp168
-rw-r--r--media/libstagefright/codecs/aacdec/pv_log2.h69
-rw-r--r--media/libstagefright/codecs/aacdec/pv_normalize.cpp167
-rw-r--r--media/libstagefright/codecs/aacdec/pv_normalize.h105
-rw-r--r--media/libstagefright/codecs/aacdec/pv_pow2.cpp170
-rw-r--r--media/libstagefright/codecs/aacdec/pv_pow2.h68
-rw-r--r--media/libstagefright/codecs/aacdec/pv_sine.cpp182
-rw-r--r--media/libstagefright/codecs/aacdec/pv_sine.h68
-rw-r--r--media/libstagefright/codecs/aacdec/pv_sqrt.cpp218
-rw-r--r--media/libstagefright/codecs/aacdec/pv_sqrt.h74
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h376
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp285
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp1458
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp157
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp418
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp354
-rw-r--r--media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp368
-rw-r--r--media/libstagefright/codecs/aacdec/q_normalize.cpp388
-rw-r--r--media/libstagefright/codecs/aacdec/q_normalize.h103
-rw-r--r--media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp319
-rw-r--r--media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h99
-rw-r--r--media/libstagefright/codecs/aacdec/s_adif_header.h98
-rw-r--r--media/libstagefright/codecs/aacdec/s_bit_buffer.h93
-rw-r--r--media/libstagefright/codecs/aacdec/s_bits.h112
-rw-r--r--media/libstagefright/codecs/aacdec/s_ch_info.h103
-rw-r--r--media/libstagefright/codecs/aacdec/s_crc_buffer.h90
-rw-r--r--media/libstagefright/codecs/aacdec/s_elelist.h90
-rw-r--r--media/libstagefright/codecs/aacdec/s_frameinfo.h127
-rw-r--r--media/libstagefright/codecs/aacdec/s_hcb.h123
-rw-r--r--media/libstagefright/codecs/aacdec/s_huffman.h91
-rw-r--r--media/libstagefright/codecs/aacdec/s_hybrid.h100
-rw-r--r--media/libstagefright/codecs/aacdec/s_lt_pred_status.h174
-rw-r--r--media/libstagefright/codecs/aacdec/s_mc_info.h116
-rw-r--r--media/libstagefright/codecs/aacdec/s_mixdown.h88
-rw-r--r--media/libstagefright/codecs/aacdec/s_patch.h121
-rw-r--r--media/libstagefright/codecs/aacdec/s_progconfig.h108
-rw-r--r--media/libstagefright/codecs/aacdec/s_ps_dec.h154
-rw-r--r--media/libstagefright/codecs/aacdec/s_pulseinfo.h97
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbr_channel.h115
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbr_dec.h145
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbr_element_stream.h92
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbr_frame_data.h181
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbr_header_data.h112
-rw-r--r--media/libstagefright/codecs/aacdec/s_sbrbitstream.h91
-rw-r--r--media/libstagefright/codecs/aacdec/s_sectinfo.h91
-rw-r--r--media/libstagefright/codecs/aacdec/s_sr_info.h91
-rw-r--r--media/libstagefright/codecs/aacdec/s_tdec_int_chan.h183
-rw-r--r--media/libstagefright/codecs/aacdec/s_tdec_int_file.h277
-rw-r--r--media/libstagefright/codecs/aacdec/s_tns_frame_info.h147
-rw-r--r--media/libstagefright/codecs/aacdec/s_tnsfilt.h132
-rw-r--r--media/libstagefright/codecs/aacdec/s_wnd_shape.h89
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp366
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h92
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_applied.cpp435
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_applied.h136
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp403
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h103
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_constants.h210
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_crc_check.cpp191
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_crc_check.h98
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp253
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h95
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_dec.cpp960
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_dec.h144
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp286
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_decode_envelope.h94
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp149
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h93
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp162
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h97
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp424
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h96
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp427
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h89
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp223
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h93
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp198
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h89
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp1040
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h144
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp145
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_additional_data.h87
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp266
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_cpe.h88
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp153
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h87
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp265
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_envelope.h93
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp221
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_header_data.h89
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp218
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h94
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_sce.cpp202
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_get_sce.h102
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp214
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h91
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_open.cpp195
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_open.h116
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_read_data.cpp324
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_read_data.h127
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp183
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h83
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp269
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_reset_dec.h118
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp364
-rw-r--r--media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h104
-rw-r--r--media/libstagefright/codecs/aacdec/set_mc_info.cpp309
-rw-r--r--media/libstagefright/codecs/aacdec/set_mc_info.h98
-rw-r--r--media/libstagefright/codecs/aacdec/sfb.cpp275
-rw-r--r--media/libstagefright/codecs/aacdec/sfb.h117
-rw-r--r--media/libstagefright/codecs/aacdec/shellsort.cpp138
-rw-r--r--media/libstagefright/codecs/aacdec/shellsort.h84
-rw-r--r--media/libstagefright/codecs/aacdec/stereo_2_mono.h97
-rw-r--r--media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp483
-rw-r--r--media/libstagefright/codecs/aacdec/synthesis_sub_band.h78
-rw-r--r--media/libstagefright/codecs/aacdec/tns_ar_filter.cpp474
-rw-r--r--media/libstagefright/codecs/aacdec/tns_ar_filter.h104
-rw-r--r--media/libstagefright/codecs/aacdec/tns_decode_coef.cpp500
-rw-r--r--media/libstagefright/codecs/aacdec/tns_decode_coef.h115
-rw-r--r--media/libstagefright/codecs/aacdec/tns_inv_filter.cpp421
-rw-r--r--media/libstagefright/codecs/aacdec/tns_inv_filter.h99
-rw-r--r--media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp2604
-rw-r--r--media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp663
-rw-r--r--media/libstagefright/codecs/aacdec/unpack_idx.cpp660
-rw-r--r--media/libstagefright/codecs/aacdec/unpack_idx.h115
-rw-r--r--media/libstagefright/codecs/aacdec/window_block_fxp.h231
-rw-r--r--media/libstagefright/codecs/aacdec/window_tables_fxp.cpp730
-rw-r--r--media/libstagefright/codecs/aacdec/write_output.h138
-rw-r--r--media/libstagefright/codecs/avc/enc/Android.mk2
-rw-r--r--media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp120
-rw-r--r--media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h12
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/Android.mk2
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp117
-rw-r--r--media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h13
-rw-r--r--media/libstagefright/codecs/mp3dec/SoftMP3.cpp24
-rw-r--r--media/libstagefright/codecs/on2/dec/Android.mk7
-rw-r--r--media/libstagefright/colorconversion/SoftwareRenderer.cpp8
-rw-r--r--media/libstagefright/foundation/ALooper.cpp5
-rw-r--r--media/libstagefright/foundation/AMessage.cpp16
-rw-r--r--media/libstagefright/foundation/hexdump.cpp21
-rw-r--r--media/libstagefright/httplive/LiveSession.cpp6
-rw-r--r--media/libstagefright/id3/ID3.cpp4
-rw-r--r--media/libstagefright/include/AwesomePlayer.h1
-rw-r--r--media/libstagefright/include/FragmentedMP4Extractor.h70
-rw-r--r--media/libstagefright/include/FragmentedMP4Parser.h274
-rw-r--r--media/libstagefright/include/ID3.h2
-rw-r--r--media/libstagefright/include/WVMExtractor.h10
-rw-r--r--media/libstagefright/include/chromium_http_stub.h30
-rw-r--r--media/libstagefright/matroska/Android.mk2
-rw-r--r--media/libstagefright/mp4/FragmentedMP4Parser.cpp1985
-rw-r--r--media/libstagefright/mp4/TrackFragment.cpp364
-rw-r--r--media/libstagefright/mp4/TrackFragment.h122
-rw-r--r--media/libstagefright/mpeg2ts/ATSParser.cpp190
-rw-r--r--media/libstagefright/mpeg2ts/ATSParser.h20
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.cpp95
-rw-r--r--media/libstagefright/mpeg2ts/ESQueue.h10
-rw-r--r--media/libstagefright/omx/OMX.cpp17
-rw-r--r--media/libstagefright/omx/tests/OMXHarness.cpp29
-rw-r--r--media/libstagefright/rtsp/AAMRAssembler.cpp1
-rw-r--r--media/libstagefright/rtsp/AH263Assembler.cpp30
-rw-r--r--media/libstagefright/rtsp/AMPEG2TSAssembler.cpp119
-rw-r--r--media/libstagefright/rtsp/AMPEG2TSAssembler.h54
-rw-r--r--media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp13
-rw-r--r--media/libstagefright/rtsp/APacketSource.cpp2
-rw-r--r--media/libstagefright/rtsp/ARTPAssembler.cpp12
-rw-r--r--media/libstagefright/rtsp/ARTPSource.cpp3
-rw-r--r--media/libstagefright/rtsp/ARTSPConnection.cpp1
-rw-r--r--media/libstagefright/rtsp/Android.mk1
-rw-r--r--media/libstagefright/rtsp/MyHandler.h4
-rw-r--r--media/libstagefright/tests/Android.mk3
-rw-r--r--media/libstagefright/tests/SurfaceMediaSource_test.cpp20
-rw-r--r--media/libstagefright/timedtext/TimedTextDriver.cpp81
-rw-r--r--media/libstagefright/timedtext/TimedTextPlayer.cpp157
-rw-r--r--media/libstagefright/timedtext/TimedTextPlayer.h7
-rw-r--r--media/libstagefright/timedtext/TimedTextSRTSource.cpp54
-rw-r--r--media/libstagefright/timedtext/TimedTextSRTSource.h19
-rw-r--r--media/libstagefright/timedtext/test/Android.mk27
-rw-r--r--media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp224
-rw-r--r--media/libstagefright/wifi-display/ANetworkSession.cpp1119
-rw-r--r--media/libstagefright/wifi-display/ANetworkSession.h130
-rw-r--r--media/libstagefright/wifi-display/Android.mk84
-rw-r--r--media/libstagefright/wifi-display/Parameters.cpp90
-rw-r--r--media/libstagefright/wifi-display/Parameters.h41
-rw-r--r--media/libstagefright/wifi-display/ParsedMessage.cpp284
-rw-r--r--media/libstagefright/wifi-display/ParsedMessage.h60
-rw-r--r--media/libstagefright/wifi-display/sink/LinearRegression.cpp110
-rw-r--r--media/libstagefright/wifi-display/sink/LinearRegression.h52
-rw-r--r--media/libstagefright/wifi-display/sink/RTPSink.cpp806
-rw-r--r--media/libstagefright/wifi-display/sink/RTPSink.h98
-rw-r--r--media/libstagefright/wifi-display/sink/TunnelRenderer.cpp396
-rw-r--r--media/libstagefright/wifi-display/sink/TunnelRenderer.h84
-rw-r--r--media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp644
-rw-r--r--media/libstagefright/wifi-display/sink/WifiDisplaySink.h147
-rw-r--r--media/libstagefright/wifi-display/source/Converter.cpp606
-rw-r--r--media/libstagefright/wifi-display/source/Converter.h122
-rw-r--r--media/libstagefright/wifi-display/source/MediaPuller.cpp191
-rw-r--r--media/libstagefright/wifi-display/source/MediaPuller.h62
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.cpp964
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.h148
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.cpp196
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.h62
-rw-r--r--media/libstagefright/wifi-display/source/Sender.cpp979
-rw-r--r--media/libstagefright/wifi-display/source/Sender.h166
-rw-r--r--media/libstagefright/wifi-display/source/TSPacketizer.cpp864
-rw-r--r--media/libstagefright/wifi-display/source/TSPacketizer.h85
-rw-r--r--media/libstagefright/wifi-display/source/WifiDisplaySource.cpp1496
-rw-r--r--media/libstagefright/wifi-display/source/WifiDisplaySource.h233
-rw-r--r--media/libstagefright/wifi-display/udptest.cpp355
-rw-r--r--media/libstagefright/wifi-display/wfd.cpp123
-rw-r--r--media/mediaserver/main_mediaserver.cpp1
-rw-r--r--media/mtp/MtpDevice.cpp2
-rw-r--r--media/mtp/MtpServer.cpp2
550 files changed, 20646 insertions, 89977 deletions
diff --git a/media/libaah_rtp/Android.mk b/media/libaah_rtp/Android.mk
deleted file mode 100644
index df533ec..0000000
--- a/media/libaah_rtp/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-LOCAL_PATH:= $(call my-dir)
-#
-# libaah_rtp
-#
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := libaah_rtp
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_SRC_FILES := \
- aah_decoder_pump.cpp \
- aah_rx_player.cpp \
- aah_rx_player_core.cpp \
- aah_rx_player_ring_buffer.cpp \
- aah_rx_player_substream.cpp \
- aah_tx_packet.cpp \
- aah_tx_player.cpp \
- aah_tx_sender.cpp \
- pipe_event.cpp
-
-LOCAL_C_INCLUDES := \
- frameworks/av/include \
- frameworks/av/media \
- frameworks/av/media/libstagefright \
- frameworks/native/include/media/openmax
-
-LOCAL_SHARED_LIBRARIES := \
- libcommon_time_client \
- libbinder \
- libmedia \
- libmedia_native \
- libstagefright \
- libstagefright_foundation \
- libutils
-
-LOCAL_LDLIBS := \
- -lpthread
-
-include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libaah_rtp/MODULE_LICENSE_APACHE2 b/media/libaah_rtp/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/media/libaah_rtp/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/media/libaah_rtp/NOTICE b/media/libaah_rtp/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/media/libaah_rtp/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/media/libaah_rtp/aah_decoder_pump.cpp b/media/libaah_rtp/aah_decoder_pump.cpp
deleted file mode 100644
index bebba54..0000000
--- a/media/libaah_rtp/aah_decoder_pump.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-//#define LOG_NDEBUG 0
-#include <utils/Log.h>
-
-#include <poll.h>
-#include <pthread.h>
-
-#include <common_time/cc_helper.h>
-#include <media/AudioSystem.h>
-#include <media/AudioTrack.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXClient.h>
-#include <media/stagefright/OMXCodec.h>
-#include <media/stagefright/Utils.h>
-#include <utils/Timers.h>
-#include <utils/threads.h>
-
-#include "aah_decoder_pump.h"
-
-namespace android {
-
-static const long long kLongDecodeErrorThreshold = 1000000ll;
-static const uint32_t kMaxLongErrorsBeforeFatal = 3;
-static const uint32_t kMaxErrorsBeforeFatal = 60;
-
-AAH_DecoderPump::AAH_DecoderPump(OMXClient& omx)
- : omx_(omx)
- , thread_status_(OK)
- , renderer_(NULL)
- , last_queued_pts_valid_(false)
- , last_queued_pts_(0)
- , last_ts_transform_valid_(false)
- , last_volume_(0xFF) {
- thread_ = new ThreadWrapper(this);
-}
-
-AAH_DecoderPump::~AAH_DecoderPump() {
- shutdown();
-}
-
-status_t AAH_DecoderPump::initCheck() {
- if (thread_ == NULL) {
- ALOGE("Failed to allocate thread");
- return NO_MEMORY;
- }
-
- return OK;
-}
-
-status_t AAH_DecoderPump::queueForDecode(MediaBuffer* buf) {
- if (NULL == buf) {
- return BAD_VALUE;
- }
-
- if (OK != thread_status_) {
- return thread_status_;
- }
-
- { // Explicit scope for AutoMutex pattern.
- AutoMutex lock(&thread_lock_);
- in_queue_.push_back(buf);
- }
-
- thread_cond_.signal();
-
- return OK;
-}
-
-void AAH_DecoderPump::queueToRenderer(MediaBuffer* decoded_sample) {
- Mutex::Autolock lock(&render_lock_);
- sp<MetaData> meta;
- int64_t ts;
- status_t res;
-
- // Fetch the metadata and make sure the sample has a timestamp. We
- // cannot render samples which are missing PTSs.
- meta = decoded_sample->meta_data();
- if ((meta == NULL) || (!meta->findInt64(kKeyTime, &ts))) {
- ALOGV("Decoded sample missing timestamp, cannot render.");
- CHECK(false);
- } else {
- // If we currently are not holding on to a renderer, go ahead and
- // make one now.
- if (NULL == renderer_) {
- renderer_ = new TimedAudioTrack();
- if (NULL != renderer_) {
- int frameCount;
- AudioTrack::getMinFrameCount(&frameCount,
- AUDIO_STREAM_DEFAULT,
- static_cast<int>(format_sample_rate_));
- audio_channel_mask_t ch_format =
- audio_channel_out_mask_from_count(format_channels_);
-
- res = renderer_->set(AUDIO_STREAM_DEFAULT,
- format_sample_rate_,
- AUDIO_FORMAT_PCM_16_BIT,
- ch_format,
- frameCount);
- if (res != OK) {
- ALOGE("Failed to setup audio renderer. (res = %d)", res);
- delete renderer_;
- renderer_ = NULL;
- } else {
- CHECK(last_ts_transform_valid_);
-
- res = renderer_->setMediaTimeTransform(
- last_ts_transform_, TimedAudioTrack::COMMON_TIME);
- if (res != NO_ERROR) {
- ALOGE("Failed to set media time transform on AudioTrack"
- " (res = %d)", res);
- delete renderer_;
- renderer_ = NULL;
- } else {
- float volume = static_cast<float>(last_volume_)
- / 255.0f;
- if (renderer_->setVolume(volume, volume) != OK) {
- ALOGW("%s: setVolume failed", __FUNCTION__);
- }
-
- renderer_->start();
- }
- }
- } else {
- ALOGE("Failed to allocate AudioTrack to use as a renderer.");
- }
- }
-
- if (NULL != renderer_) {
- uint8_t* decoded_data =
- reinterpret_cast<uint8_t*>(decoded_sample->data());
- uint32_t decoded_amt = decoded_sample->range_length();
- decoded_data += decoded_sample->range_offset();
-
- sp<IMemory> pcm_payload;
- res = renderer_->allocateTimedBuffer(decoded_amt, &pcm_payload);
- if (res != OK) {
- ALOGE("Failed to allocate %d byte audio track buffer."
- " (res = %d)", decoded_amt, res);
- } else {
- memcpy(pcm_payload->pointer(), decoded_data, decoded_amt);
-
- res = renderer_->queueTimedBuffer(pcm_payload, ts);
- if (res != OK) {
- ALOGE("Failed to queue %d byte audio track buffer with"
- " media PTS %lld. (res = %d)", decoded_amt, ts, res);
- } else {
- last_queued_pts_valid_ = true;
- last_queued_pts_ = ts;
- }
- }
-
- } else {
- ALOGE("No renderer, dropping audio payload.");
- }
- }
-}
-
-void AAH_DecoderPump::stopAndCleanupRenderer() {
- if (NULL == renderer_) {
- return;
- }
-
- renderer_->stop();
- delete renderer_;
- renderer_ = NULL;
-}
-
-void AAH_DecoderPump::setRenderTSTransform(const LinearTransform& trans) {
- Mutex::Autolock lock(&render_lock_);
-
- if (last_ts_transform_valid_ && !memcmp(&trans,
- &last_ts_transform_,
- sizeof(trans))) {
- return;
- }
-
- last_ts_transform_ = trans;
- last_ts_transform_valid_ = true;
-
- if (NULL != renderer_) {
- status_t res = renderer_->setMediaTimeTransform(
- last_ts_transform_, TimedAudioTrack::COMMON_TIME);
- if (res != NO_ERROR) {
- ALOGE("Failed to set media time transform on AudioTrack"
- " (res = %d)", res);
- }
- }
-}
-
-void AAH_DecoderPump::setRenderVolume(uint8_t volume) {
- Mutex::Autolock lock(&render_lock_);
-
- if (volume == last_volume_) {
- return;
- }
-
- last_volume_ = volume;
- if (renderer_ != NULL) {
- float volume = static_cast<float>(last_volume_) / 255.0f;
- if (renderer_->setVolume(volume, volume) != OK) {
- ALOGW("%s: setVolume failed", __FUNCTION__);
- }
- }
-}
-
-// isAboutToUnderflow is something of a hack used to figure out when it might be
-// time to give up on trying to fill in a gap in the RTP sequence and simply
-// move on with a discontinuity. If we had perfect knowledge of when we were
-// going to underflow, it would not be a hack, but unfortunately we do not.
-// Right now, we just take the PTS of the last sample queued, and check to see
-// if its presentation time is within kAboutToUnderflowThreshold from now. If
-// it is, then we say that we are about to underflow. This decision is based on
-// two (possibly invalid) assumptions.
-//
-// 1) The transmitter is leading the clock by more than
-// kAboutToUnderflowThreshold.
-// 2) The delta between the PTS of the last sample queued and the next sample
-// is less than the transmitter's clock lead amount.
-//
-// Right now, the default transmitter lead time is 1 second, which is a pretty
-// large number and greater than the 50mSec that kAboutToUnderflowThreshold is
-// currently set to. This should satisfy assumption #1 for now, but changes to
-// the transmitter clock lead time could effect this.
-//
-// For non-sparse streams with a homogeneous sample rate (the vast majority of
-// streams in the world), the delta between any two adjacent PTSs will always be
-// the homogeneous sample period. It is very uncommon to see a sample period
-// greater than the 1 second clock lead we are currently using, and you
-// certainly will not see it in an MP3 file which should satisfy assumption #2.
-// Sparse audio streams (where no audio is transmitted for long periods of
-// silence) and extremely low framerate video stream (like an MPEG-2 slideshow
-// or the video stream for a pay TV audio channel) are examples of streams which
-// might violate assumption #2.
-bool AAH_DecoderPump::isAboutToUnderflow(int64_t threshold) {
- Mutex::Autolock lock(&render_lock_);
-
- // If we have never queued anything to the decoder, we really don't know if
- // we are going to underflow or not.
- if (!last_queued_pts_valid_ || !last_ts_transform_valid_) {
- return false;
- }
-
- // Don't have access to Common Time? If so, then things are Very Bad
- // elsewhere in the system; it pretty much does not matter what we do here.
- // Since we cannot really tell if we are about to underflow or not, its
- // probably best to assume that we are not and proceed accordingly.
- int64_t tt_now;
- if (OK != cc_helper_.getCommonTime(&tt_now)) {
- return false;
- }
-
- // Transform from media time to common time.
- int64_t last_queued_pts_tt;
- if (!last_ts_transform_.doForwardTransform(last_queued_pts_,
- &last_queued_pts_tt)) {
- return false;
- }
-
- // Check to see if we are underflowing.
- return ((tt_now + threshold - last_queued_pts_tt) > 0);
-}
-
-void* AAH_DecoderPump::workThread() {
- // No need to lock when accessing decoder_ from the thread. The
- // implementation of init and shutdown ensure that other threads never touch
- // decoder_ while the work thread is running.
- CHECK(decoder_ != NULL);
- CHECK(format_ != NULL);
-
- // Start the decoder and note its result code. If something goes horribly
- // wrong, callers of queueForDecode and getOutput will be able to detect
- // that the thread encountered a fatal error and shut down by examining
- // thread_status_.
- thread_status_ = decoder_->start(format_.get());
- if (OK != thread_status_) {
- ALOGE("AAH_DecoderPump's work thread failed to start decoder"
- " (res = %d)", thread_status_);
- return NULL;
- }
-
- DurationTimer decode_timer;
- uint32_t consecutive_long_errors = 0;
- uint32_t consecutive_errors = 0;
-
- while (!thread_->exitPending()) {
- status_t res;
- MediaBuffer* bufOut = NULL;
-
- decode_timer.start();
- res = decoder_->read(&bufOut);
- decode_timer.stop();
-
- if (res == INFO_FORMAT_CHANGED) {
- // Format has changed. Destroy our current renderer so that a new
- // one can be created during queueToRenderer with the proper format.
- //
- // TODO : In order to transition seamlessly, we should change this
- // to put the old renderer in a queue to play out completely before
- // we destroy it. We can still create a new renderer, the timed
- // nature of the renderer should ensure a seamless splice.
- stopAndCleanupRenderer();
- res = OK;
- }
-
- // Try to be a little nuanced in our handling of actual decode errors.
- // Errors could happen because of minor stream corruption or because of
- // transient resource limitations. In these cases, we would rather drop
- // a little bit of output and ride out the unpleasantness then throw up
- // our hands and abort everything.
- //
- // OTOH - When things are really bad (like we have a non-transient
- // resource or bookkeeping issue, or the stream being fed to us is just
- // complete and total garbage) we really want to terminate playback and
- // raise an error condition all the way up to the application level so
- // they can deal with it.
- //
- // Unfortunately, the error codes returned by the decoder can be a
- // little non-specific. For example, if an OMXCodec times out
- // attempting to obtain an output buffer, the error we get back is a
- // generic -1. Try to distinguish between this resource timeout error
- // and ES corruption error by timing how long the decode operation
- // takes. Maintain accounting for both errors and "long errors". If we
- // get more than a certain number consecutive errors of either type,
- // consider it fatal and shutdown (which will cause the error to
- // propagate all of the way up to the application level). The threshold
- // for "long errors" is deliberately much lower than that of normal
- // decode errors, both because of how long they take to happen and
- // because they generally indicate resource limitation errors which are
- // unlikely to go away in pathologically bad cases (in contrast to
- // stream corruption errors which might happen 20 times in a row and
- // then be suddenly OK again)
- if (res != OK) {
- consecutive_errors++;
- if (decode_timer.durationUsecs() >= kLongDecodeErrorThreshold)
- consecutive_long_errors++;
-
- CHECK(NULL == bufOut);
-
- ALOGW("%s: Failed to decode data (res = %d)",
- __PRETTY_FUNCTION__, res);
-
- if ((consecutive_errors >= kMaxErrorsBeforeFatal) ||
- (consecutive_long_errors >= kMaxLongErrorsBeforeFatal)) {
- ALOGE("%s: Maximum decode error threshold has been reached."
- " There have been %d consecutive decode errors, and %d"
- " consecutive decode operations which resulted in errors"
- " and took more than %lld uSec to process. The last"
- " decode operation took %lld uSec.",
- __PRETTY_FUNCTION__,
- consecutive_errors, consecutive_long_errors,
- kLongDecodeErrorThreshold, decode_timer.durationUsecs());
- thread_status_ = res;
- break;
- }
-
- continue;
- }
-
- if (NULL == bufOut) {
- ALOGW("%s: Successful decode, but no buffer produced",
- __PRETTY_FUNCTION__);
- continue;
- }
-
- // Successful decode (with actual output produced). Clear the error
- // counters.
- consecutive_errors = 0;
- consecutive_long_errors = 0;
-
- queueToRenderer(bufOut);
- bufOut->release();
- }
-
- decoder_->stop();
- stopAndCleanupRenderer();
-
- return NULL;
-}
-
-status_t AAH_DecoderPump::init(const sp<MetaData>& params) {
- Mutex::Autolock lock(&init_lock_);
-
- if (decoder_ != NULL) {
- // already inited
- return OK;
- }
-
- if (params == NULL) {
- return BAD_VALUE;
- }
-
- if (!params->findInt32(kKeyChannelCount, &format_channels_)) {
- return BAD_VALUE;
- }
-
- if (!params->findInt32(kKeySampleRate, &format_sample_rate_)) {
- return BAD_VALUE;
- }
-
- CHECK(OK == thread_status_);
- CHECK(decoder_ == NULL);
-
- status_t ret_val = UNKNOWN_ERROR;
-
- // Cache the format and attempt to create the decoder.
- format_ = params;
- decoder_ = OMXCodec::Create(
- omx_.interface(), // IOMX Handle
- format_, // Metadata for substream (indicates codec)
- false, // Make a decoder, not an encoder
- sp<MediaSource>(this)); // We will be the source for this codec.
-
- if (decoder_ == NULL) {
- ALOGE("Failed to allocate decoder in %s", __PRETTY_FUNCTION__);
- goto bailout;
- }
-
- // Fire up the pump thread. It will take care of starting and stopping the
- // decoder.
- ret_val = thread_->run("aah_decode_pump", ANDROID_PRIORITY_AUDIO);
- if (OK != ret_val) {
- ALOGE("Failed to start work thread in %s (res = %d)",
- __PRETTY_FUNCTION__, ret_val);
- goto bailout;
- }
-
-bailout:
- if (OK != ret_val) {
- decoder_ = NULL;
- format_ = NULL;
- }
-
- return OK;
-}
-
-status_t AAH_DecoderPump::shutdown() {
- Mutex::Autolock lock(&init_lock_);
- return shutdown_l();
-}
-
-status_t AAH_DecoderPump::shutdown_l() {
- thread_->requestExit();
- thread_cond_.signal();
- thread_->requestExitAndWait();
-
- for (MBQueue::iterator iter = in_queue_.begin();
- iter != in_queue_.end();
- ++iter) {
- (*iter)->release();
- }
- in_queue_.clear();
-
- last_queued_pts_valid_ = false;
- last_ts_transform_valid_ = false;
- last_volume_ = 0xFF;
- thread_status_ = OK;
-
- decoder_ = NULL;
- format_ = NULL;
-
- return OK;
-}
-
-status_t AAH_DecoderPump::read(MediaBuffer **buffer,
- const ReadOptions *options) {
- if (!buffer) {
- return BAD_VALUE;
- }
-
- *buffer = NULL;
-
- // While its not time to shut down, and we have no data to process, wait.
- AutoMutex lock(&thread_lock_);
- while (!thread_->exitPending() && in_queue_.empty())
- thread_cond_.wait(thread_lock_);
-
- // At this point, if its not time to shutdown then we must have something to
- // process. Go ahead and pop the front of the queue for processing.
- if (!thread_->exitPending()) {
- CHECK(!in_queue_.empty());
-
- *buffer = *(in_queue_.begin());
- in_queue_.erase(in_queue_.begin());
- }
-
- // If we managed to get a buffer, then everything must be OK. If not, then
- // we must be shutting down.
- return (NULL == *buffer) ? INVALID_OPERATION : OK;
-}
-
-AAH_DecoderPump::ThreadWrapper::ThreadWrapper(AAH_DecoderPump* owner)
- : Thread(false /* canCallJava*/ )
- , owner_(owner) {
-}
-
-bool AAH_DecoderPump::ThreadWrapper::threadLoop() {
- CHECK(NULL != owner_);
- owner_->workThread();
- return false;
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_decoder_pump.h b/media/libaah_rtp/aah_decoder_pump.h
deleted file mode 100644
index 4d57e49..0000000
--- a/media/libaah_rtp/aah_decoder_pump.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __DECODER_PUMP_H__
-#define __DECODER_PUMP_H__
-
-#include <pthread.h>
-
-#include <common_time/cc_helper.h>
-#include <media/stagefright/MediaSource.h>
-#include <utils/LinearTransform.h>
-#include <utils/List.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class MetaData;
-class OMXClient;
-class TimedAudioTrack;
-
-class AAH_DecoderPump : public MediaSource {
- public:
- explicit AAH_DecoderPump(OMXClient& omx);
- status_t initCheck();
-
- status_t queueForDecode(MediaBuffer* buf);
-
- status_t init(const sp<MetaData>& params);
- status_t shutdown();
-
- void setRenderTSTransform(const LinearTransform& trans);
- void setRenderVolume(uint8_t volume);
- bool isAboutToUnderflow(int64_t threshold);
- bool getStatus() const { return thread_status_; }
-
- // MediaSource methods
- virtual status_t start(MetaData *params) { return OK; }
- virtual sp<MetaData> getFormat() { return format_; }
- virtual status_t stop() { return OK; }
- virtual status_t read(MediaBuffer **buffer,
- const ReadOptions *options);
-
- protected:
- virtual ~AAH_DecoderPump();
-
- private:
- class ThreadWrapper : public Thread {
- public:
- friend class AAH_DecoderPump;
- explicit ThreadWrapper(AAH_DecoderPump* owner);
-
- private:
- virtual bool threadLoop();
- AAH_DecoderPump* owner_;
-
- DISALLOW_EVIL_CONSTRUCTORS(ThreadWrapper);
- };
-
- void* workThread();
- virtual status_t shutdown_l();
- void queueToRenderer(MediaBuffer* decoded_sample);
- void stopAndCleanupRenderer();
-
- sp<MetaData> format_;
- int32_t format_channels_; // channel count, not channel mask
- int32_t format_sample_rate_;
-
- sp<MediaSource> decoder_;
- OMXClient& omx_;
- Mutex init_lock_;
-
- sp<ThreadWrapper> thread_;
- Condition thread_cond_;
- Mutex thread_lock_;
- status_t thread_status_;
-
- Mutex render_lock_;
- TimedAudioTrack* renderer_;
- bool last_queued_pts_valid_;
- int64_t last_queued_pts_;
- bool last_ts_transform_valid_;
- LinearTransform last_ts_transform_;
- uint8_t last_volume_;
- CCHelper cc_helper_;
-
- // protected by the thread_lock_
- typedef List<MediaBuffer*> MBQueue;
- MBQueue in_queue_;
-
- DISALLOW_EVIL_CONSTRUCTORS(AAH_DecoderPump);
-};
-
-} // namespace android
-#endif // __DECODER_PUMP_H__
diff --git a/media/libaah_rtp/aah_rx_player.cpp b/media/libaah_rtp/aah_rx_player.cpp
deleted file mode 100644
index 9dd79fd..0000000
--- a/media/libaah_rtp/aah_rx_player.cpp
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-//#define LOG_NDEBUG 0
-
-#include <binder/IServiceManager.h>
-#include <media/MediaPlayerInterface.h>
-#include <utils/Log.h>
-
-#include "aah_rx_player.h"
-
-namespace android {
-
-const uint32_t AAH_RXPlayer::kRTPRingBufferSize = 1 << 10;
-
-sp<MediaPlayerBase> createAAH_RXPlayer() {
- sp<MediaPlayerBase> ret = new AAH_RXPlayer();
- return ret;
-}
-
-AAH_RXPlayer::AAH_RXPlayer()
- : ring_buffer_(kRTPRingBufferSize)
- , substreams_(NULL) {
- thread_wrapper_ = new ThreadWrapper(*this);
-
- is_playing_ = false;
- multicast_joined_ = false;
- transmitter_known_ = false;
- current_epoch_known_ = false;
- data_source_set_ = false;
- sock_fd_ = -1;
-
- substreams_.setCapacity(4);
-
- memset(&listen_addr_, 0, sizeof(listen_addr_));
- memset(&transmitter_addr_, 0, sizeof(transmitter_addr_));
-
- fetchAudioFlinger();
-}
-
-AAH_RXPlayer::~AAH_RXPlayer() {
- reset_l();
- CHECK(substreams_.size() == 0);
- omx_.disconnect();
-}
-
-status_t AAH_RXPlayer::initCheck() {
- if (thread_wrapper_ == NULL) {
- ALOGE("Failed to allocate thread wrapper!");
- return NO_MEMORY;
- }
-
- if (!ring_buffer_.initCheck()) {
- ALOGE("Failed to allocate reassembly ring buffer!");
- return NO_MEMORY;
- }
-
- // Check for the presense of the common time service by attempting to query
- // for CommonTime's frequency. If we get an error back, we cannot talk to
- // the service at all and should abort now.
- status_t res;
- uint64_t freq;
- res = cc_helper_.getCommonFreq(&freq);
- if (OK != res) {
- ALOGE("Failed to connect to common time service!");
- return res;
- }
-
- return omx_.connect();
-}
-
-status_t AAH_RXPlayer::setDataSource(
- const char *url,
- const KeyedVector<String8, String8> *headers) {
- AutoMutex api_lock(&api_lock_);
- uint32_t a, b, c, d;
- uint16_t port;
-
- if (data_source_set_) {
- return INVALID_OPERATION;
- }
-
- if (NULL == url) {
- return BAD_VALUE;
- }
-
- if (5 != sscanf(url, "%*[^:/]://%u.%u.%u.%u:%hu", &a, &b, &c, &d, &port)) {
- ALOGE("Failed to parse URL \"%s\"", url);
- return BAD_VALUE;
- }
-
- if ((a > 255) || (b > 255) || (c > 255) || (d > 255) || (port == 0)) {
- ALOGE("Bad multicast address \"%s\"", url);
- return BAD_VALUE;
- }
-
- ALOGI("setDataSource :: %u.%u.%u.%u:%hu", a, b, c, d, port);
-
- a = (a << 24) | (b << 16) | (c << 8) | d;
-
- memset(&listen_addr_, 0, sizeof(listen_addr_));
- listen_addr_.sin_family = AF_INET;
- listen_addr_.sin_port = htons(port);
- listen_addr_.sin_addr.s_addr = htonl(a);
- data_source_set_ = true;
-
- return OK;
-}
-
-status_t AAH_RXPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
- return INVALID_OPERATION;
-}
-
-status_t AAH_RXPlayer::setVideoSurface(const sp<Surface>& surface) {
- return OK;
-}
-
-status_t AAH_RXPlayer::setVideoSurfaceTexture(
- const sp<ISurfaceTexture>& surfaceTexture) {
- return OK;
-}
-
-status_t AAH_RXPlayer::prepare() {
- return OK;
-}
-
-status_t AAH_RXPlayer::prepareAsync() {
- sendEvent(MEDIA_PREPARED);
- return OK;
-}
-
-status_t AAH_RXPlayer::start() {
- AutoMutex api_lock(&api_lock_);
-
- if (is_playing_) {
- return OK;
- }
-
- status_t res = startWorkThread();
- is_playing_ = (res == OK);
- return res;
-}
-
-status_t AAH_RXPlayer::stop() {
- return pause();
-}
-
-status_t AAH_RXPlayer::pause() {
- AutoMutex api_lock(&api_lock_);
- stopWorkThread();
- CHECK(sock_fd_ < 0);
- is_playing_ = false;
- return OK;
-}
-
-bool AAH_RXPlayer::isPlaying() {
- AutoMutex api_lock(&api_lock_);
- return is_playing_;
-}
-
-status_t AAH_RXPlayer::seekTo(int msec) {
- sendEvent(MEDIA_SEEK_COMPLETE);
- return OK;
-}
-
-status_t AAH_RXPlayer::getCurrentPosition(int *msec) {
- if (NULL != msec) {
- *msec = 0;
- }
- return OK;
-}
-
-status_t AAH_RXPlayer::getDuration(int *msec) {
- if (NULL != msec) {
- *msec = 1;
- }
- return OK;
-}
-
-status_t AAH_RXPlayer::reset() {
- AutoMutex api_lock(&api_lock_);
- reset_l();
- return OK;
-}
-
-void AAH_RXPlayer::reset_l() {
- stopWorkThread();
- CHECK(sock_fd_ < 0);
- CHECK(!multicast_joined_);
- is_playing_ = false;
- data_source_set_ = false;
- transmitter_known_ = false;
- memset(&listen_addr_, 0, sizeof(listen_addr_));
-}
-
-status_t AAH_RXPlayer::setLooping(int loop) {
- return OK;
-}
-
-player_type AAH_RXPlayer::playerType() {
- return AAH_RX_PLAYER;
-}
-
-status_t AAH_RXPlayer::setParameter(int key, const Parcel &request) {
- return ERROR_UNSUPPORTED;
-}
-
-status_t AAH_RXPlayer::getParameter(int key, Parcel *reply) {
- return ERROR_UNSUPPORTED;
-}
-
-status_t AAH_RXPlayer::invoke(const Parcel& request, Parcel *reply) {
- if (!reply) {
- return BAD_VALUE;
- }
-
- int32_t magic;
- status_t err = request.readInt32(&magic);
- if (err != OK) {
- reply->writeInt32(err);
- return OK;
- }
-
- if (magic != 0x12345) {
- reply->writeInt32(BAD_VALUE);
- return OK;
- }
-
- int32_t methodID;
- err = request.readInt32(&methodID);
- if (err != OK) {
- reply->writeInt32(err);
- return OK;
- }
-
- switch (methodID) {
- // Get Volume
- case INVOKE_GET_MASTER_VOLUME: {
- if (audio_flinger_ != NULL) {
- reply->writeInt32(OK);
- reply->writeFloat(audio_flinger_->masterVolume());
- } else {
- reply->writeInt32(UNKNOWN_ERROR);
- }
- } break;
-
- // Set Volume
- case INVOKE_SET_MASTER_VOLUME: {
- float targetVol = request.readFloat();
- reply->writeInt32(audio_flinger_->setMasterVolume(targetVol));
- } break;
-
- default: return BAD_VALUE;
- }
-
- return OK;
-}
-
-void AAH_RXPlayer::fetchAudioFlinger() {
- if (audio_flinger_ == NULL) {
- sp<IServiceManager> sm = defaultServiceManager();
- sp<IBinder> binder;
- binder = sm->getService(String16("media.audio_flinger"));
-
- if (binder == NULL) {
- ALOGW("AAH_RXPlayer failed to fetch handle to audio flinger."
- " Master volume control will not be possible.");
- }
-
- audio_flinger_ = interface_cast<IAudioFlinger>(binder);
- }
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_rx_player.h b/media/libaah_rtp/aah_rx_player.h
deleted file mode 100644
index ba5617e..0000000
--- a/media/libaah_rtp/aah_rx_player.h
+++ /dev/null
@@ -1,318 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AAH_RX_PLAYER_H__
-#define __AAH_RX_PLAYER_H__
-
-#include <common_time/cc_helper.h>
-#include <media/MediaPlayerInterface.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaSource.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXClient.h>
-#include <netinet/in.h>
-#include <utils/KeyedVector.h>
-#include <utils/LinearTransform.h>
-#include <utils/threads.h>
-
-#include "aah_decoder_pump.h"
-#include "pipe_event.h"
-
-namespace android {
-
-class AAH_RXPlayer : public MediaPlayerInterface {
- public:
- AAH_RXPlayer();
-
- virtual status_t initCheck();
- virtual status_t setDataSource(const char *url,
- const KeyedVector<String8, String8>*
- headers);
- virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
- virtual status_t setVideoSurface(const sp<Surface>& surface);
- virtual status_t setVideoSurfaceTexture(const sp<ISurfaceTexture>&
- surfaceTexture);
- virtual status_t prepare();
- virtual status_t prepareAsync();
- virtual status_t start();
- virtual status_t stop();
- virtual status_t pause();
- virtual bool isPlaying();
- virtual status_t seekTo(int msec);
- virtual status_t getCurrentPosition(int *msec);
- virtual status_t getDuration(int *msec);
- virtual status_t reset();
- virtual status_t setLooping(int loop);
- virtual player_type playerType();
- virtual status_t setParameter(int key, const Parcel &request);
- virtual status_t getParameter(int key, Parcel *reply);
- virtual status_t invoke(const Parcel& request, Parcel *reply);
-
- protected:
- virtual ~AAH_RXPlayer();
-
- private:
- class ThreadWrapper : public Thread {
- public:
- friend class AAH_RXPlayer;
- explicit ThreadWrapper(AAH_RXPlayer& player)
- : Thread(false /* canCallJava */ )
- , player_(player) { }
-
- virtual bool threadLoop() { return player_.threadLoop(); }
-
- private:
- AAH_RXPlayer& player_;
-
- DISALLOW_EVIL_CONSTRUCTORS(ThreadWrapper);
- };
-
-#pragma pack(push, 1)
- // PacketBuffers are structures used by the RX ring buffer. The ring buffer
- // is a ring of pointers to PacketBuffer structures which act as variable
- // length byte arrays and hold the contents of received UDP packets. Rather
- // than make this a structure which hold a length and a pointer to another
- // allocated structure (which would require two allocations), this struct
- // uses a structure overlay pattern where allocation for the byte array
- // consists of allocating (arrayLen + sizeof(ssize_t)) bytes of data from
- // whatever pool/heap the packet buffer pulls from, and then overlaying the
- // packed PacketBuffer structure on top of the allocation. The one-byte
- // array at the end of the structure serves as an offset to the the data
- // portion of the allocation; packet buffers are never allocated on the
- // stack or using the new operator. Instead, the static allocate-byte-array
- // and destroy methods handle the allocate and overlay pattern. They also
- // allow for a potential future optimization where instead of just
- // allocating blocks from the process global heap and overlaying, the
- // allocator is replaced with a different implementation (private heap,
- // free-list, circular buffer, etc) which reduces potential heap
- // fragmentation issues which might arise from the frequent allocation and
- // destruction of the received UDP traffic.
- struct PacketBuffer {
- ssize_t length_;
- uint8_t data_[1];
-
- // TODO : consider changing this to be some form of ring buffer or free
- // pool system instead of just using the heap in order to avoid heap
- // fragmentation.
- static PacketBuffer* allocate(ssize_t length);
- static void destroy(PacketBuffer* pb);
-
- private:
- // Force people to use allocate/destroy instead of new/delete.
- PacketBuffer() { }
- ~PacketBuffer() { }
- };
-
- struct RetransRequest {
- uint32_t magic_;
- uint32_t mcast_ip_;
- uint16_t mcast_port_;
- uint16_t start_seq_;
- uint16_t end_seq_;
- };
-#pragma pack(pop)
-
- enum GapStatus {
- kGS_NoGap = 0,
- kGS_NormalGap,
- kGS_FastStartGap,
- };
-
- struct SeqNoGap {
- uint16_t start_seq_;
- uint16_t end_seq_;
- };
-
- class RXRingBuffer {
- public:
- explicit RXRingBuffer(uint32_t capacity);
- ~RXRingBuffer();
-
- bool initCheck() const { return (ring_ != NULL); }
- void reset();
-
- // Push a packet buffer with a given sequence number into the ring
- // buffer. pushBuffer will always consume the buffer pushed to it,
- // either destroying it because it was a duplicate or overflow, or
- // holding on to it in the ring. Callers should not hold any references
- // to PacketBuffers after they have been pushed to the ring. Returns
- // false in the case of a serious error (such as ring overflow).
- // Callers should consider resetting the pipeline entirely in the event
- // of a serious error.
- bool pushBuffer(PacketBuffer* buf, uint16_t seq);
-
- // Fetch the next buffer in the RTP sequence. Returns NULL if there is
- // no buffer to fetch. If a non-NULL PacketBuffer is returned,
- // is_discon will be set to indicate whether or not this PacketBuffer is
- // discontiuous with any previously returned packet buffers. Packet
- // buffers returned by fetchBuffer are the caller's responsibility; they
- // must be certain to destroy the buffers when they are done.
- PacketBuffer* fetchBuffer(bool* is_discon);
-
- // Returns true and fills out the gap structure if the read pointer of
- // the ring buffer is currently pointing to a gap which would stall a
- // fetchBuffer operation. Returns false if the read pointer is not
- // pointing to a gap in the sequence currently.
- GapStatus fetchCurrentGap(SeqNoGap* gap);
-
- // Causes the read pointer to skip over any portion of a gap indicated
- // by nak. If nak is NULL, any gap currently blocking the read pointer
- // will be completely skipped. If any portion of a gap is skipped, the
- // next successful read from fetch buffer will indicate a discontinuity.
- void processNAK(const SeqNoGap* nak = NULL);
-
- // Compute the number of milliseconds until the inactivity timer for
- // this RTP stream. Returns -1 if there is no active timeout, or 0 if
- // the system has already timed out.
- int computeInactivityTimeout();
-
- private:
- Mutex lock_;
- PacketBuffer** ring_;
- uint32_t capacity_;
- uint32_t rd_;
- uint32_t wr_;
-
- uint16_t rd_seq_;
- bool rd_seq_known_;
- bool waiting_for_fast_start_;
- bool fetched_first_packet_;
-
- uint64_t rtp_activity_timeout_;
- bool rtp_activity_timeout_valid_;
-
- DISALLOW_EVIL_CONSTRUCTORS(RXRingBuffer);
- };
-
- class Substream : public virtual RefBase {
- public:
- Substream(uint32_t ssrc, OMXClient& omx);
-
- void cleanupBufferInProgress();
- void shutdown();
- void processPayloadStart(uint8_t* buf,
- uint32_t amt,
- int32_t ts_lower);
- void processPayloadCont (uint8_t* buf,
- uint32_t amt);
- void processTSTransform(const LinearTransform& trans);
-
- bool isAboutToUnderflow();
- uint32_t getSSRC() const { return ssrc_; }
- uint16_t getProgramID() const { return (ssrc_ >> 5) & 0x1F; }
- status_t getStatus() const { return status_; }
-
- protected:
- virtual ~Substream();
-
- private:
- void cleanupDecoder();
- bool shouldAbort(const char* log_tag);
- void processCompletedBuffer();
- bool setupSubstreamMeta();
- bool setupMP3SubstreamMeta();
- bool setupAACSubstreamMeta();
- bool setupSubstreamType(uint8_t substream_type,
- uint8_t codec_type);
-
- uint32_t ssrc_;
- bool waiting_for_rap_;
- status_t status_;
-
- bool substream_details_known_;
- uint8_t substream_type_;
- uint8_t codec_type_;
- const char* codec_mime_type_;
- sp<MetaData> substream_meta_;
-
- MediaBuffer* buffer_in_progress_;
- uint32_t expected_buffer_size_;
- uint32_t buffer_filled_;
-
- Vector<uint8_t> aux_data_in_progress_;
- uint32_t aux_data_expected_size_;
-
- sp<AAH_DecoderPump> decoder_;
-
- static int64_t kAboutToUnderflowThreshold;
-
- DISALLOW_EVIL_CONSTRUCTORS(Substream);
- };
-
- typedef DefaultKeyedVector< uint32_t, sp<Substream> > SubstreamVec;
-
- status_t startWorkThread();
- void stopWorkThread();
- virtual bool threadLoop();
- bool setupSocket();
- void cleanupSocket();
- void resetPipeline();
- void reset_l();
- bool processRX(PacketBuffer* pb);
- void processRingBuffer();
- void processCommandPacket(PacketBuffer* pb);
- bool processGaps();
- int computeNextGapRetransmitTimeout();
- void fetchAudioFlinger();
-
- PipeEvent wakeup_work_thread_evt_;
- sp<ThreadWrapper> thread_wrapper_;
- Mutex api_lock_;
- bool is_playing_;
- bool data_source_set_;
-
- struct sockaddr_in listen_addr_;
- int sock_fd_;
- bool multicast_joined_;
-
- struct sockaddr_in transmitter_addr_;
- bool transmitter_known_;
-
- uint32_t current_epoch_;
- bool current_epoch_known_;
-
- SeqNoGap current_gap_;
- GapStatus current_gap_status_;
- uint64_t next_retrans_req_time_;
-
- RXRingBuffer ring_buffer_;
- SubstreamVec substreams_;
- OMXClient omx_;
- CCHelper cc_helper_;
-
- // Connection to audio flinger used to hack a path to setMasterVolume.
- sp<IAudioFlinger> audio_flinger_;
-
- static const uint32_t kRTPRingBufferSize;
- static const uint32_t kRetransRequestMagic;
- static const uint32_t kFastStartRequestMagic;
- static const uint32_t kRetransNAKMagic;
- static const uint32_t kGapRerequestTimeoutUSec;
- static const uint32_t kFastStartTimeoutUSec;
- static const uint32_t kRTPActivityTimeoutUSec;
-
- static const uint32_t INVOKE_GET_MASTER_VOLUME = 3;
- static const uint32_t INVOKE_SET_MASTER_VOLUME = 4;
-
- static uint64_t monotonicUSecNow();
-
- DISALLOW_EVIL_CONSTRUCTORS(AAH_RXPlayer);
-};
-
-} // namespace android
-
-#endif // __AAH_RX_PLAYER_H__
diff --git a/media/libaah_rtp/aah_rx_player_core.cpp b/media/libaah_rtp/aah_rx_player_core.cpp
deleted file mode 100644
index d6b31fd..0000000
--- a/media/libaah_rtp/aah_rx_player_core.cpp
+++ /dev/null
@@ -1,809 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-//#define LOG_NDEBUG 0
-#include <utils/Log.h>
-
-#include <fcntl.h>
-#include <poll.h>
-#include <sys/socket.h>
-#include <time.h>
-#include <utils/misc.h>
-
-#include <media/stagefright/Utils.h>
-
-#include "aah_rx_player.h"
-#include "aah_tx_packet.h"
-
-namespace android {
-
-const uint32_t AAH_RXPlayer::kRetransRequestMagic =
- FOURCC('T','r','e','q');
-const uint32_t AAH_RXPlayer::kRetransNAKMagic =
- FOURCC('T','n','a','k');
-const uint32_t AAH_RXPlayer::kFastStartRequestMagic =
- FOURCC('T','f','s','t');
-const uint32_t AAH_RXPlayer::kGapRerequestTimeoutUSec = 75000;
-const uint32_t AAH_RXPlayer::kFastStartTimeoutUSec = 800000;
-const uint32_t AAH_RXPlayer::kRTPActivityTimeoutUSec = 10000000;
-
-static inline int16_t fetchInt16(uint8_t* data) {
- return static_cast<int16_t>(U16_AT(data));
-}
-
-static inline int32_t fetchInt32(uint8_t* data) {
- return static_cast<int32_t>(U32_AT(data));
-}
-
-static inline int64_t fetchInt64(uint8_t* data) {
- return static_cast<int64_t>(U64_AT(data));
-}
-
-uint64_t AAH_RXPlayer::monotonicUSecNow() {
- struct timespec now;
- int res = clock_gettime(CLOCK_MONOTONIC, &now);
- CHECK(res >= 0);
-
- uint64_t ret = static_cast<uint64_t>(now.tv_sec) * 1000000;
- ret += now.tv_nsec / 1000;
-
- return ret;
-}
-
-status_t AAH_RXPlayer::startWorkThread() {
- status_t res;
- stopWorkThread();
- res = thread_wrapper_->run("TRX_Player", PRIORITY_AUDIO);
-
- if (res != OK) {
- ALOGE("Failed to start work thread (res = %d)", res);
- }
-
- return res;
-}
-
-void AAH_RXPlayer::stopWorkThread() {
- thread_wrapper_->requestExit(); // set the exit pending flag
- wakeup_work_thread_evt_.setEvent();
-
- status_t res;
- res = thread_wrapper_->requestExitAndWait(); // block until thread exit.
- if (res != OK) {
- ALOGE("Failed to stop work thread (res = %d)", res);
- }
-
- wakeup_work_thread_evt_.clearPendingEvents();
-}
-
-void AAH_RXPlayer::cleanupSocket() {
- if (sock_fd_ >= 0) {
- if (multicast_joined_) {
- int res;
- struct ip_mreq mreq;
- mreq.imr_multiaddr = listen_addr_.sin_addr;
- mreq.imr_interface.s_addr = htonl(INADDR_ANY);
- res = setsockopt(sock_fd_,
- IPPROTO_IP,
- IP_DROP_MEMBERSHIP,
- &mreq, sizeof(mreq));
- if (res < 0) {
- ALOGW("Failed to leave multicast group. (%d, %d)", res, errno);
- }
- multicast_joined_ = false;
- }
-
- close(sock_fd_);
- sock_fd_ = -1;
- }
-
- resetPipeline();
-}
-
-void AAH_RXPlayer::resetPipeline() {
- ring_buffer_.reset();
-
- // Explicitly shudown all of the active substreams, then call clear out the
- // collection. Failure to clear out a substream can result in its decoder
- // holding a reference to itself and therefor not going away when the
- // collection is cleared.
- for (size_t i = 0; i < substreams_.size(); ++i)
- substreams_.valueAt(i)->shutdown();
-
- substreams_.clear();
-
- current_gap_status_ = kGS_NoGap;
-}
-
-bool AAH_RXPlayer::setupSocket() {
- long flags;
- int res, buf_size;
- socklen_t opt_size;
-
- cleanupSocket();
- CHECK(sock_fd_ < 0);
-
- // Make the socket
- sock_fd_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (sock_fd_ < 0) {
- ALOGE("Failed to create listen socket (errno %d)", errno);
- goto bailout;
- }
-
- // Set non-blocking operation
- flags = fcntl(sock_fd_, F_GETFL);
- res = fcntl(sock_fd_, F_SETFL, flags | O_NONBLOCK);
- if (res < 0) {
- ALOGE("Failed to set socket (%d) to non-blocking mode (errno %d)",
- sock_fd_, errno);
- goto bailout;
- }
-
- // Bind to our port
- struct sockaddr_in bind_addr;
- memset(&bind_addr, 0, sizeof(bind_addr));
- bind_addr.sin_family = AF_INET;
- bind_addr.sin_addr.s_addr = INADDR_ANY;
- bind_addr.sin_port = listen_addr_.sin_port;
- res = bind(sock_fd_,
- reinterpret_cast<const sockaddr*>(&bind_addr),
- sizeof(bind_addr));
- if (res < 0) {
- uint32_t a = ntohl(bind_addr.sin_addr.s_addr);
- uint16_t p = ntohs(bind_addr.sin_port);
- ALOGE("Failed to bind socket (%d) to %d.%d.%d.%d:%hd. (errno %d)",
- sock_fd_,
- (a >> 24) & 0xFF,
- (a >> 16) & 0xFF,
- (a >> 8) & 0xFF,
- (a ) & 0xFF,
- p,
- errno);
-
- goto bailout;
- }
-
- buf_size = 1 << 16; // 64k
- res = setsockopt(sock_fd_,
- SOL_SOCKET, SO_RCVBUF,
- &buf_size, sizeof(buf_size));
- if (res < 0) {
- ALOGW("Failed to increase socket buffer size to %d. (errno %d)",
- buf_size, errno);
- }
-
- buf_size = 0;
- opt_size = sizeof(buf_size);
- res = getsockopt(sock_fd_,
- SOL_SOCKET, SO_RCVBUF,
- &buf_size, &opt_size);
- if (res < 0) {
- ALOGW("Failed to fetch socket buffer size. (errno %d)", errno);
- } else {
- ALOGI("RX socket buffer size is now %d bytes", buf_size);
- }
-
- if (listen_addr_.sin_addr.s_addr) {
- // Join the multicast group and we should be good to go.
- struct ip_mreq mreq;
- mreq.imr_multiaddr = listen_addr_.sin_addr;
- mreq.imr_interface.s_addr = htonl(INADDR_ANY);
- res = setsockopt(sock_fd_,
- IPPROTO_IP,
- IP_ADD_MEMBERSHIP,
- &mreq, sizeof(mreq));
- if (res < 0) {
- ALOGE("Failed to join multicast group. (errno %d)", errno);
- goto bailout;
- }
- multicast_joined_ = true;
- }
-
- return true;
-
-bailout:
- cleanupSocket();
- return false;
-}
-
-bool AAH_RXPlayer::threadLoop() {
- struct pollfd poll_fds[2];
- bool process_more_right_now = false;
-
- if (!setupSocket()) {
- sendEvent(MEDIA_ERROR);
- goto bailout;
- }
-
- while (!thread_wrapper_->exitPending()) {
- // Step 1: Wait until there is something to do.
- int gap_timeout = computeNextGapRetransmitTimeout();
- int ring_timeout = ring_buffer_.computeInactivityTimeout();
- int timeout = -1;
-
- if (!ring_timeout) {
- ALOGW("RTP inactivity timeout reached, resetting pipeline.");
- resetPipeline();
- timeout = gap_timeout;
- } else {
- if (gap_timeout < 0) {
- timeout = ring_timeout;
- } else if (ring_timeout < 0) {
- timeout = gap_timeout;
- } else {
- timeout = (gap_timeout < ring_timeout) ? gap_timeout
- : ring_timeout;
- }
- }
-
- if ((0 != timeout) && (!process_more_right_now)) {
- // Set up the events to wait on. Start with the wakeup pipe.
- memset(&poll_fds, 0, sizeof(poll_fds));
- poll_fds[0].fd = wakeup_work_thread_evt_.getWakeupHandle();
- poll_fds[0].events = POLLIN;
-
- // Add the RX socket.
- poll_fds[1].fd = sock_fd_;
- poll_fds[1].events = POLLIN;
-
- // Wait for something interesing to happen.
- int poll_res = poll(poll_fds, NELEM(poll_fds), timeout);
- if (poll_res < 0) {
- ALOGE("Fatal error (%d,%d) while waiting on events",
- poll_res, errno);
- sendEvent(MEDIA_ERROR);
- goto bailout;
- }
- }
-
- if (thread_wrapper_->exitPending()) {
- break;
- }
-
- wakeup_work_thread_evt_.clearPendingEvents();
- process_more_right_now = false;
-
- // Step 2: Do we have data waiting in the socket? If so, drain the
- // socket moving valid RTP information into the ring buffer to be
- // processed.
- if (poll_fds[1].revents) {
- struct sockaddr_in from;
- socklen_t from_len;
-
- ssize_t res = 0;
- while (!thread_wrapper_->exitPending()) {
- // Check the size of any pending packet.
- res = recv(sock_fd_, NULL, 0, MSG_PEEK | MSG_TRUNC);
-
- // Error?
- if (res < 0) {
- // If the error is anything other than would block,
- // something has gone very wrong.
- if ((errno != EAGAIN) && (errno != EWOULDBLOCK)) {
- ALOGE("Fatal socket error during recvfrom (%d, %d)",
- (int)res, errno);
- goto bailout;
- }
-
- // Socket is out of data, just break out of processing and
- // wait for more.
- break;
- }
-
- // Allocate a payload.
- PacketBuffer* pb = PacketBuffer::allocate(res);
- if (NULL == pb) {
- ALOGE("Fatal error, failed to allocate packet buffer of"
- " length %u", static_cast<uint32_t>(res));
- goto bailout;
- }
-
- // Fetch the data.
- from_len = sizeof(from);
- res = recvfrom(sock_fd_, pb->data_, pb->length_, 0,
- reinterpret_cast<struct sockaddr*>(&from),
- &from_len);
- if (res != pb->length_) {
- ALOGE("Fatal error, fetched packet length (%d) does not"
- " match peeked packet length (%u). This should never"
- " happen. (errno = %d)",
- static_cast<int>(res),
- static_cast<uint32_t>(pb->length_),
- errno);
- }
-
- bool drop_packet = false;
- if (transmitter_known_) {
- if (from.sin_addr.s_addr !=
- transmitter_addr_.sin_addr.s_addr) {
- uint32_t a = ntohl(from.sin_addr.s_addr);
- uint16_t p = ntohs(from.sin_port);
- ALOGV("Dropping packet from unknown transmitter"
- " %u.%u.%u.%u:%hu",
- ((a >> 24) & 0xFF),
- ((a >> 16) & 0xFF),
- ((a >> 8) & 0xFF),
- ( a & 0xFF),
- p);
-
- drop_packet = true;
- } else {
- transmitter_addr_.sin_port = from.sin_port;
- }
- } else {
- memcpy(&transmitter_addr_, &from, sizeof(from));
- transmitter_known_ = true;
- }
-
- if (!drop_packet) {
- bool serious_error = !processRX(pb);
-
- if (serious_error) {
- // Something went "seriously wrong". Currently, the
- // only trigger for this should be a ring buffer
- // overflow. The current failsafe behavior for when
- // something goes seriously wrong is to just reset the
- // pipeline. The system should behave as if this
- // AAH_RXPlayer was just set up for the first time.
- ALOGE("Something just went seriously wrong with the"
- " pipeline. Resetting.");
- resetPipeline();
- }
- } else {
- PacketBuffer::destroy(pb);
- }
- }
- }
-
- // Step 3: Process any data we mave have accumulated in the ring buffer
- // so far.
- if (!thread_wrapper_->exitPending()) {
- processRingBuffer();
- }
-
- // Step 4: At this point in time, the ring buffer should either be
- // empty, or stalled in front of a gap caused by some dropped packets.
- // Check on the current gap situation and deal with it in an appropriate
- // fashion. If processGaps returns true, it means that it has given up
- // on a gap and that we should try to process some more data
- // immediately.
- if (!thread_wrapper_->exitPending()) {
- process_more_right_now = processGaps();
- }
-
- // Step 5: Check for fatal errors. If any of our substreams has
- // encountered a fatal, unrecoverable, error, then propagate the error
- // up to user level and shut down.
- for (size_t i = 0; i < substreams_.size(); ++i) {
- status_t status;
- CHECK(substreams_.valueAt(i) != NULL);
-
- status = substreams_.valueAt(i)->getStatus();
- if (OK != status) {
- ALOGE("Substream index %d has encountered an unrecoverable"
- " error (%d). Signalling application level and shutting"
- " down.", i, status);
- sendEvent(MEDIA_ERROR);
- goto bailout;
- }
- }
- }
-
-bailout:
- cleanupSocket();
- return false;
-}
-
-bool AAH_RXPlayer::processRX(PacketBuffer* pb) {
- CHECK(NULL != pb);
-
- uint8_t* data = pb->data_;
- ssize_t amt = pb->length_;
- uint32_t nak_magic;
- uint16_t seq_no;
- uint32_t epoch;
-
- // Every packet either starts with an RTP header which is at least 12 bytes
- // long or is a retry NAK which is 14 bytes long. If there are fewer than
- // 12 bytes here, this cannot be a proper RTP packet.
- if (amt < 12) {
- ALOGV("Dropping packet, too short to contain RTP header (%u bytes)",
- static_cast<uint32_t>(amt));
- goto drop_packet;
- }
-
- // Check to see if this is the special case of a NAK packet.
- nak_magic = ntohl(*(reinterpret_cast<uint32_t*>(data)));
- if (nak_magic == kRetransNAKMagic) {
- // Looks like a NAK packet; make sure its long enough.
-
- if (amt < static_cast<ssize_t>(sizeof(RetransRequest))) {
- ALOGV("Dropping packet, too short to contain NAK payload"
- " (%u bytes)", static_cast<uint32_t>(amt));
- goto drop_packet;
- }
-
- SeqNoGap gap;
- RetransRequest* rtr = reinterpret_cast<RetransRequest*>(data);
- gap.start_seq_ = ntohs(rtr->start_seq_);
- gap.end_seq_ = ntohs(rtr->end_seq_);
-
- ALOGV("Process NAK for gap at [%hu, %hu]",
- gap.start_seq_, gap.end_seq_);
- ring_buffer_.processNAK(&gap);
-
- return true;
- }
-
- // According to the TRTP spec, version should be 2, padding should be 0,
- // extension should be 0 and CSRCCnt should be 0. If any of these tests
- // fail, we chuck the packet.
- if (data[0] != 0x80) {
- ALOGV("Dropping packet, bad V/P/X/CSRCCnt field (0x%02x)",
- data[0]);
- goto drop_packet;
- }
-
- // Check the payload type. For TRTP, it should always be 100.
- if ((data[1] & 0x7F) != 100) {
- ALOGV("Dropping packet, bad payload type. (%u)",
- data[1] & 0x7F);
- goto drop_packet;
- }
-
- // Check whether the transmitter has begun a new epoch.
- epoch = (U32_AT(data + 8) >> 10) & 0x3FFFFF;
- if (current_epoch_known_) {
- if (epoch != current_epoch_) {
- ALOGV("%s: new epoch %u", __PRETTY_FUNCTION__, epoch);
- current_epoch_ = epoch;
- resetPipeline();
- }
- } else {
- current_epoch_ = epoch;
- current_epoch_known_ = true;
- }
-
- // Extract the sequence number and hand the packet off to the ring buffer
- // for dropped packet detection and later processing.
- seq_no = U16_AT(data + 2);
- return ring_buffer_.pushBuffer(pb, seq_no);
-
-drop_packet:
- PacketBuffer::destroy(pb);
- return true;
-}
-
-void AAH_RXPlayer::processRingBuffer() {
- PacketBuffer* pb;
- bool is_discon;
- sp<Substream> substream;
- LinearTransform trans;
- bool foundTrans = false;
-
- while (NULL != (pb = ring_buffer_.fetchBuffer(&is_discon))) {
- if (is_discon) {
- // Abort all partially assembled payloads.
- for (size_t i = 0; i < substreams_.size(); ++i) {
- CHECK(substreams_.valueAt(i) != NULL);
- substreams_.valueAt(i)->cleanupBufferInProgress();
- }
- }
-
- uint8_t* data = pb->data_;
- ssize_t amt = pb->length_;
-
- // Should not have any non-RTP packets in the ring buffer. RTP packets
- // must be at least 12 bytes long.
- CHECK(amt >= 12);
-
- // Extract the marker bit and the SSRC field.
- bool marker = (data[1] & 0x80) != 0;
- uint32_t ssrc = U32_AT(data + 8);
-
- // Is this the start of a new TRTP payload? If so, the marker bit
- // should be set and there are some things we should be checking for.
- if (marker) {
- // TRTP headers need to have at least a byte for version, a byte for
- // payload type and flags, and 4 bytes for length.
- if (amt < 18) {
- ALOGV("Dropping packet, too short to contain TRTP header"
- " (%u bytes)", static_cast<uint32_t>(amt));
- goto process_next_packet;
- }
-
- // Check the TRTP version and extract the payload type/flags.
- uint8_t trtp_version = data[12];
- uint8_t payload_type = (data[13] >> 4) & 0xF;
- uint8_t trtp_flags = data[13] & 0xF;
-
- if (1 != trtp_version) {
- ALOGV("Dropping packet, bad trtp version %hhu", trtp_version);
- goto process_next_packet;
- }
-
- // Is there a timestamp transformation present on this packet? If
- // so, extract it and pass it to the appropriate substreams.
- if (trtp_flags & 0x02) {
- ssize_t offset = 18 + ((trtp_flags & 0x01) ? 4 : 0);
- if (amt < (offset + 24)) {
- ALOGV("Dropping packet, too short to contain TRTP Timestamp"
- " Transformation (%u bytes)",
- static_cast<uint32_t>(amt));
- goto process_next_packet;
- }
-
- trans.a_zero = fetchInt64(data + offset);
- trans.b_zero = fetchInt64(data + offset + 16);
- trans.a_to_b_numer = static_cast<int32_t>(
- fetchInt32 (data + offset + 8));
- trans.a_to_b_denom = U32_AT(data + offset + 12);
- foundTrans = true;
-
- uint32_t program_id = (ssrc >> 5) & 0x1F;
- for (size_t i = 0; i < substreams_.size(); ++i) {
- sp<Substream> iter = substreams_.valueAt(i);
- CHECK(iter != NULL);
-
- if (iter->getProgramID() == program_id) {
- iter->processTSTransform(trans);
- }
- }
- }
-
- // Is this a command packet? If so, its not necessarily associate
- // with one particular substream. Just give it to the command
- // packet handler and then move on.
- if (4 == payload_type) {
- processCommandPacket(pb);
- goto process_next_packet;
- }
- }
-
- // If we got to here, then we are a normal packet. Find (or allocate)
- // the substream we belong to and send the packet off to be processed.
- substream = substreams_.valueFor(ssrc);
- if (substream == NULL) {
- substream = new Substream(ssrc, omx_);
- if (substream == NULL) {
- ALOGE("Failed to allocate substream for SSRC 0x%08x", ssrc);
- goto process_next_packet;
- }
- substreams_.add(ssrc, substream);
-
- if (foundTrans) {
- substream->processTSTransform(trans);
- }
- }
-
- CHECK(substream != NULL);
-
- if (marker) {
- // Start of a new TRTP payload for this substream. Extract the
- // lower 32 bits of the timestamp and hand the buffer to the
- // substream for processing.
- uint32_t ts_lower = U32_AT(data + 4);
- substream->processPayloadStart(data + 12, amt - 12, ts_lower);
- } else {
- // Continuation of an existing TRTP payload. Just hand it off to
- // the substream for processing.
- substream->processPayloadCont(data + 12, amt - 12);
- }
-
-process_next_packet:
- PacketBuffer::destroy(pb);
- } // end of main processing while loop.
-}
-
-void AAH_RXPlayer::processCommandPacket(PacketBuffer* pb) {
- CHECK(NULL != pb);
-
- uint8_t* data = pb->data_;
- ssize_t amt = pb->length_;
-
- // verify that this packet meets the minimum length of a command packet
- if (amt < 20) {
- return;
- }
-
- uint8_t trtp_version = data[12];
- uint8_t trtp_flags = data[13] & 0xF;
-
- if (1 != trtp_version) {
- ALOGV("Dropping packet, bad trtp version %hhu", trtp_version);
- return;
- }
-
- // calculate the start of the command payload
- ssize_t offset = 18;
- if (trtp_flags & 0x01) {
- // timestamp is present (4 bytes)
- offset += 4;
- }
- if (trtp_flags & 0x02) {
- // transform is present (24 bytes)
- offset += 24;
- }
-
- // the packet must contain 2 bytes of command payload beyond the TRTP header
- if (amt < offset + 2) {
- return;
- }
-
- uint16_t command_id = U16_AT(data + offset);
-
- switch (command_id) {
- case TRTPControlPacket::kCommandNop:
- break;
-
- case TRTPControlPacket::kCommandEOS:
- case TRTPControlPacket::kCommandFlush: {
- uint16_t program_id = (U32_AT(data + 8) >> 5) & 0x1F;
- ALOGI("*** %s flushing program_id=%d",
- __PRETTY_FUNCTION__, program_id);
-
- Vector<uint32_t> substreams_to_remove;
- for (size_t i = 0; i < substreams_.size(); ++i) {
- sp<Substream> iter = substreams_.valueAt(i);
- if (iter->getProgramID() == program_id) {
- iter->shutdown();
- substreams_to_remove.add(iter->getSSRC());
- }
- }
-
- for (size_t i = 0; i < substreams_to_remove.size(); ++i) {
- substreams_.removeItem(substreams_to_remove[i]);
- }
- } break;
- }
-}
-
-bool AAH_RXPlayer::processGaps() {
- // Deal with the current gap situation. Specifically...
- //
- // 1) If a new gap has shown up, send a retransmit request to the
- // transmitter.
- // 2) If a gap we were working on has had a packet in the middle or at
- // the end filled in, send another retransmit request for the begining
- // portion of the gap. TRTP was designed for LANs where packet
- // re-ordering is very unlikely; so see the middle or end of a gap
- // filled in before the begining is an almost certain indication that
- // a retransmission packet was also dropped.
- // 3) If we have been working on a gap for a while and it still has not
- // been filled in, send another retransmit request.
- // 4) If the are no more gaps in the ring, clear the current_gap_status_
- // flag to indicate that all is well again.
-
- // Start by fetching the active gap status.
- SeqNoGap gap;
- bool send_retransmit_request = false;
- bool ret_val = false;
- GapStatus gap_status;
- if (kGS_NoGap != (gap_status = ring_buffer_.fetchCurrentGap(&gap))) {
- // Note: checking for a change in the end sequence number should cover
- // moving on to an entirely new gap for case #1 as well as resending the
- // begining of a gap range for case #2.
- send_retransmit_request = (kGS_NoGap == current_gap_status_) ||
- (current_gap_.end_seq_ != gap.end_seq_);
-
- // If this is the same gap we have been working on, and it has timed
- // out, then check to see if our substreams are about to underflow. If
- // so, instead of sending another retransmit request, just give up on
- // this gap and move on.
- if (!send_retransmit_request &&
- (kGS_NoGap != current_gap_status_) &&
- (0 == computeNextGapRetransmitTimeout())) {
-
- // If out current gap is the fast-start gap, don't bother to skip it
- // because substreams look like the are about to underflow.
- if ((kGS_FastStartGap != gap_status) ||
- (current_gap_.end_seq_ != gap.end_seq_)) {
- for (size_t i = 0; i < substreams_.size(); ++i) {
- if (substreams_.valueAt(i)->isAboutToUnderflow()) {
- ALOGV("About to underflow, giving up on gap [%hu, %hu]",
- gap.start_seq_, gap.end_seq_);
- ring_buffer_.processNAK();
- current_gap_status_ = kGS_NoGap;
- return true;
- }
- }
- }
-
- // Looks like no one is about to underflow. Just go ahead and send
- // the request.
- send_retransmit_request = true;
- }
- } else {
- current_gap_status_ = kGS_NoGap;
- }
-
- if (send_retransmit_request) {
- // If we have been working on a fast start, and it is still not filled
- // in, even after the extended retransmit time out, give up and skip it.
- // The system should fall back into its normal slow-start behavior.
- if ((kGS_FastStartGap == current_gap_status_) &&
- (current_gap_.end_seq_ == gap.end_seq_)) {
- ALOGV("Fast start is taking forever; giving up.");
- ring_buffer_.processNAK();
- current_gap_status_ = kGS_NoGap;
- return true;
- }
-
- // Send the request.
- RetransRequest req;
- uint32_t magic = (kGS_FastStartGap == gap_status)
- ? kFastStartRequestMagic
- : kRetransRequestMagic;
- req.magic_ = htonl(magic);
- req.mcast_ip_ = listen_addr_.sin_addr.s_addr;
- req.mcast_port_ = listen_addr_.sin_port;
- req.start_seq_ = htons(gap.start_seq_);
- req.end_seq_ = htons(gap.end_seq_);
-
- {
- uint32_t a = ntohl(transmitter_addr_.sin_addr.s_addr);
- uint16_t p = ntohs(transmitter_addr_.sin_port);
- ALOGV("Sending to transmitter %u.%u.%u.%u:%hu",
- ((a >> 24) & 0xFF),
- ((a >> 16) & 0xFF),
- ((a >> 8) & 0xFF),
- ( a & 0xFF),
- p);
- }
-
- int res = sendto(sock_fd_, &req, sizeof(req), 0,
- reinterpret_cast<struct sockaddr*>(&transmitter_addr_),
- sizeof(transmitter_addr_));
- if (res < 0) {
- ALOGE("Error when sending retransmit request (%d)", errno);
- } else {
- ALOGV("%s request for range [%hu, %hu] sent",
- (kGS_FastStartGap == gap_status) ? "Fast Start"
- : "Retransmit",
- gap.start_seq_, gap.end_seq_);
- }
-
- // Update the current gap info.
- current_gap_ = gap;
- current_gap_status_ = gap_status;
- next_retrans_req_time_ = monotonicUSecNow() +
- ((kGS_FastStartGap == current_gap_status_)
- ? kFastStartTimeoutUSec
- : kGapRerequestTimeoutUSec);
- }
-
- return false;
-}
-
-// Compute when its time to send the next gap retransmission in milliseconds.
-// Returns < 0 for an infinite timeout (no gap) and 0 if its time to retransmit
-// right now.
-int AAH_RXPlayer::computeNextGapRetransmitTimeout() {
- if (kGS_NoGap == current_gap_status_) {
- return -1;
- }
-
- int64_t timeout_delta = next_retrans_req_time_ - monotonicUSecNow();
-
- timeout_delta /= 1000;
- if (timeout_delta <= 0) {
- return 0;
- }
-
- return static_cast<uint32_t>(timeout_delta);
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_rx_player_ring_buffer.cpp b/media/libaah_rtp/aah_rx_player_ring_buffer.cpp
deleted file mode 100644
index 779405e..0000000
--- a/media/libaah_rtp/aah_rx_player_ring_buffer.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-//#define LOG_NDEBUG 0
-#include <utils/Log.h>
-
-#include "aah_rx_player.h"
-
-namespace android {
-
-AAH_RXPlayer::RXRingBuffer::RXRingBuffer(uint32_t capacity) {
- capacity_ = capacity;
- rd_ = wr_ = 0;
- ring_ = new PacketBuffer*[capacity];
- memset(ring_, 0, sizeof(PacketBuffer*) * capacity);
- reset();
-}
-
-AAH_RXPlayer::RXRingBuffer::~RXRingBuffer() {
- reset();
- delete[] ring_;
-}
-
-void AAH_RXPlayer::RXRingBuffer::reset() {
- AutoMutex lock(&lock_);
-
- if (NULL != ring_) {
- while (rd_ != wr_) {
- CHECK(rd_ < capacity_);
- if (NULL != ring_[rd_]) {
- PacketBuffer::destroy(ring_[rd_]);
- ring_[rd_] = NULL;
- }
- rd_ = (rd_ + 1) % capacity_;
- }
- }
-
- rd_ = wr_ = 0;
- rd_seq_known_ = false;
- waiting_for_fast_start_ = true;
- fetched_first_packet_ = false;
- rtp_activity_timeout_valid_ = false;
-}
-
-bool AAH_RXPlayer::RXRingBuffer::pushBuffer(PacketBuffer* buf,
- uint16_t seq) {
- AutoMutex lock(&lock_);
- CHECK(NULL != ring_);
- CHECK(NULL != buf);
-
- rtp_activity_timeout_valid_ = true;
- rtp_activity_timeout_ = monotonicUSecNow() + kRTPActivityTimeoutUSec;
-
- // If the ring buffer is totally reset (we have never received a single
- // payload) then we don't know the rd sequence number and this should be
- // simple. We just store the payload, advance the wr pointer and record the
- // initial sequence number.
- if (!rd_seq_known_) {
- CHECK(rd_ == wr_);
- CHECK(NULL == ring_[wr_]);
- CHECK(wr_ < capacity_);
-
- ring_[wr_] = buf;
- wr_ = (wr_ + 1) % capacity_;
- rd_seq_ = seq;
- rd_seq_known_ = true;
- return true;
- }
-
- // Compute the seqence number of this payload and of the write pointer,
- // normalized around the read pointer. IOW - transform the payload seq no
- // and the wr pointer seq no into a space where the rd pointer seq no is
- // zero. This will define 4 cases we can consider...
- //
- // 1) norm_seq == norm_wr_seq
- // This payload is contiguous with the last. All is good.
- //
- // 2) ((norm_seq < norm_wr_seq) && (norm_seq >= norm_rd_seq)
- // aka ((norm_seq < norm_wr_seq) && (norm_seq >= 0)
- // This payload is in the past, in the unprocessed region of the ring
- // buffer. It is probably a retransmit intended to fill in a dropped
- // payload; it may be a duplicate.
- //
- // 3) ((norm_seq - norm_wr_seq) & 0x8000) != 0
- // This payload is in the past compared to the write pointer (or so very
- // far in the future that it has wrapped the seq no space), but not in
- // the unprocessed region of the ring buffer. This could be a duplicate
- // retransmit; we just drop these payloads unless we are waiting for our
- // first fast start packet. If we are waiting for fast start, than this
- // packet is probably the first packet of the fast start retransmission.
- // If it will fit in the buffer, back up the read pointer to its position
- // and clear the fast start flag, otherwise just drop it.
- //
- // 4) ((norm_seq - norm_wr_seq) & 0x8000) == 0
- // This payload which is ahead of the next write pointer. This indicates
- // that we have missed some payloads and need to request a retransmit.
- // If norm_seq >= (capacity - 1), then the gap is so large that it would
- // overflow the ring buffer and we should probably start to panic.
-
- uint16_t norm_wr_seq = ((wr_ + capacity_ - rd_) % capacity_);
- uint16_t norm_seq = seq - rd_seq_;
-
- // Check for overflow first.
- if ((!(norm_seq & 0x8000)) && (norm_seq >= (capacity_ - 1))) {
- ALOGW("Ring buffer overflow; cap = %u, [rd, wr] = [%hu, %hu],"
- " seq = %hu", capacity_, rd_seq_, norm_wr_seq + rd_seq_, seq);
- PacketBuffer::destroy(buf);
- return false;
- }
-
- // Check for case #1
- if (norm_seq == norm_wr_seq) {
- CHECK(wr_ < capacity_);
- CHECK(NULL == ring_[wr_]);
-
- ring_[wr_] = buf;
- wr_ = (wr_ + 1) % capacity_;
-
- CHECK(wr_ != rd_);
- return true;
- }
-
- // Check case #2
- uint32_t ring_pos = (rd_ + norm_seq) % capacity_;
- if ((norm_seq < norm_wr_seq) && (!(norm_seq & 0x8000))) {
- // Do we already have a payload for this slot? If so, then this looks
- // like a duplicate retransmit. Just ignore it.
- if (NULL != ring_[ring_pos]) {
- ALOGD("RXed duplicate retransmit, seq = %hu", seq);
- PacketBuffer::destroy(buf);
- } else {
- // Looks like we were missing this payload. Go ahead and store it.
- ring_[ring_pos] = buf;
- }
-
- return true;
- }
-
- // Check case #3
- if ((norm_seq - norm_wr_seq) & 0x8000) {
- if (!waiting_for_fast_start_) {
- ALOGD("RXed duplicate retransmit from before rd pointer, seq = %hu",
- seq);
- PacketBuffer::destroy(buf);
- } else {
- // Looks like a fast start fill-in. Go ahead and store it, assuming
- // that we can fit it in the buffer.
- uint32_t implied_ring_size = static_cast<uint32_t>(norm_wr_seq)
- + (rd_seq_ - seq);
-
- if (implied_ring_size >= (capacity_ - 1)) {
- ALOGD("RXed what looks like a fast start packet (seq = %hu),"
- " but packet is too far in the past to fit into the ring"
- " buffer. Dropping.", seq);
- PacketBuffer::destroy(buf);
- } else {
- ring_pos = (rd_ + capacity_ + seq - rd_seq_) % capacity_;
- rd_seq_ = seq;
- rd_ = ring_pos;
- waiting_for_fast_start_ = false;
-
- CHECK(ring_pos < capacity_);
- CHECK(NULL == ring_[ring_pos]);
- ring_[ring_pos] = buf;
- }
-
- }
- return true;
- }
-
- // Must be in case #4 with no overflow. This packet fits in the current
- // ring buffer, but is discontiuguous. Advance the write pointer leaving a
- // gap behind.
- uint32_t gap_len = (ring_pos + capacity_ - wr_) % capacity_;
- ALOGD("Drop detected; %u packets, seq_range [%hu, %hu]",
- gap_len,
- rd_seq_ + norm_wr_seq,
- rd_seq_ + norm_wr_seq + gap_len - 1);
-
- CHECK(NULL == ring_[ring_pos]);
- ring_[ring_pos] = buf;
- wr_ = (ring_pos + 1) % capacity_;
- CHECK(wr_ != rd_);
-
- return true;
-}
-
-AAH_RXPlayer::PacketBuffer*
-AAH_RXPlayer::RXRingBuffer::fetchBuffer(bool* is_discon) {
- AutoMutex lock(&lock_);
- CHECK(NULL != ring_);
- CHECK(NULL != is_discon);
-
- // If the read seqence number is not known, then this ring buffer has not
- // received a packet since being reset and there cannot be any packets to
- // return. If we are still waiting for the first fast start packet to show
- // up, we don't want to let any buffer be consumed yet because we expect to
- // see a packet before the initial read sequence number show up shortly.
- if (!rd_seq_known_ || waiting_for_fast_start_) {
- *is_discon = false;
- return NULL;
- }
-
- PacketBuffer* ret = NULL;
- *is_discon = !fetched_first_packet_;
-
- while ((rd_ != wr_) && (NULL == ret)) {
- CHECK(rd_ < capacity_);
-
- // If we hit a gap, stall and do not advance the read pointer. Let the
- // higher level code deal with requesting retries and/or deciding to
- // skip the current gap.
- ret = ring_[rd_];
- if (NULL == ret) {
- break;
- }
-
- ring_[rd_] = NULL;
- rd_ = (rd_ + 1) % capacity_;
- ++rd_seq_;
- }
-
- if (NULL != ret) {
- fetched_first_packet_ = true;
- }
-
- return ret;
-}
-
-AAH_RXPlayer::GapStatus
-AAH_RXPlayer::RXRingBuffer::fetchCurrentGap(SeqNoGap* gap) {
- AutoMutex lock(&lock_);
- CHECK(NULL != ring_);
- CHECK(NULL != gap);
-
- // If the read seqence number is not known, then this ring buffer has not
- // received a packet since being reset and there cannot be any gaps.
- if (!rd_seq_known_) {
- return kGS_NoGap;
- }
-
- // If we are waiting for fast start, then the current gap is a fast start
- // gap and it includes all packets before the read sequence number.
- if (waiting_for_fast_start_) {
- gap->start_seq_ =
- gap->end_seq_ = rd_seq_ - 1;
- return kGS_FastStartGap;
- }
-
- // If rd == wr, then the buffer is empty and there cannot be any gaps.
- if (rd_ == wr_) {
- return kGS_NoGap;
- }
-
- // If rd_ is currently pointing at an unprocessed packet, then there is no
- // current gap.
- CHECK(rd_ < capacity_);
- if (NULL != ring_[rd_]) {
- return kGS_NoGap;
- }
-
- // Looks like there must be a gap here. The start of the gap is the current
- // rd sequence number, all we need to do now is determine its length in
- // order to compute the end sequence number.
- gap->start_seq_ = rd_seq_;
- uint16_t end = rd_seq_;
- uint32_t tmp = (rd_ + 1) % capacity_;
- while ((tmp != wr_) && (NULL == ring_[tmp])) {
- ++end;
- tmp = (tmp + 1) % capacity_;
- }
- gap->end_seq_ = end;
-
- return kGS_NormalGap;
-}
-
-void AAH_RXPlayer::RXRingBuffer::processNAK(const SeqNoGap* nak) {
- AutoMutex lock(&lock_);
- CHECK(NULL != ring_);
-
- // If we were waiting for our first fast start fill-in packet, and we
- // received a NAK, then apparantly we are not getting our fast start. Just
- // clear the waiting flag and go back to normal behavior.
- if (waiting_for_fast_start_) {
- waiting_for_fast_start_ = false;
- }
-
- // If we have not received a packet since last reset, or there is no data in
- // the ring, then there is nothing to skip.
- if ((!rd_seq_known_) || (rd_ == wr_)) {
- return;
- }
-
- // If rd_ is currently pointing at an unprocessed packet, then there is no
- // gap to skip.
- CHECK(rd_ < capacity_);
- if (NULL != ring_[rd_]) {
- return;
- }
-
- // Looks like there must be a gap here. Advance rd until we have passed
- // over the portion of it indicated by nak (or all of the gap if nak is
- // NULL). Then reset fetched_first_packet_ so that the next read will show
- // up as being discontiguous.
- uint16_t seq_after_gap = (NULL == nak) ? 0 : nak->end_seq_ + 1;
- while ((rd_ != wr_) &&
- (NULL == ring_[rd_]) &&
- ((NULL == nak) || (seq_after_gap != rd_seq_))) {
- rd_ = (rd_ + 1) % capacity_;
- ++rd_seq_;
- }
- fetched_first_packet_ = false;
-}
-
-int AAH_RXPlayer::RXRingBuffer::computeInactivityTimeout() {
- AutoMutex lock(&lock_);
-
- if (!rtp_activity_timeout_valid_) {
- return -1;
- }
-
- uint64_t now = monotonicUSecNow();
- if (rtp_activity_timeout_ <= now) {
- return 0;
- }
-
- return (rtp_activity_timeout_ - now) / 1000;
-}
-
-AAH_RXPlayer::PacketBuffer*
-AAH_RXPlayer::PacketBuffer::allocate(ssize_t length) {
- if (length <= 0) {
- return NULL;
- }
-
- uint32_t alloc_len = sizeof(PacketBuffer) + length;
- PacketBuffer* ret = reinterpret_cast<PacketBuffer*>(
- new uint8_t[alloc_len]);
-
- if (NULL != ret) {
- ret->length_ = length;
- }
-
- return ret;
-}
-
-void AAH_RXPlayer::PacketBuffer::destroy(PacketBuffer* pb) {
- uint8_t* kill_me = reinterpret_cast<uint8_t*>(pb);
- delete[] kill_me;
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_rx_player_substream.cpp b/media/libaah_rtp/aah_rx_player_substream.cpp
deleted file mode 100644
index 18b0e2b..0000000
--- a/media/libaah_rtp/aah_rx_player_substream.cpp
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-//#define LOG_NDEBUG 0
-
-#include <utils/Log.h>
-
-#include <include/avc_utils.h>
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/OMXCodec.h>
-#include <media/stagefright/Utils.h>
-
-#include "aah_rx_player.h"
-#include "aah_tx_packet.h"
-
-inline uint32_t min(uint32_t a, uint32_t b) {
- return (a < b ? a : b);
-}
-
-namespace android {
-
-int64_t AAH_RXPlayer::Substream::kAboutToUnderflowThreshold =
- 50ull * 1000;
-
-AAH_RXPlayer::Substream::Substream(uint32_t ssrc, OMXClient& omx) {
- ssrc_ = ssrc;
- substream_details_known_ = false;
- buffer_in_progress_ = NULL;
- status_ = OK;
- codec_mime_type_ = "";
-
- decoder_ = new AAH_DecoderPump(omx);
- if (decoder_ == NULL) {
- ALOGE("%s failed to allocate decoder pump!", __PRETTY_FUNCTION__);
- }
- if (OK != decoder_->initCheck()) {
- ALOGE("%s failed to initialize decoder pump!", __PRETTY_FUNCTION__);
- }
-
- // cleanupBufferInProgress will reset most of the internal state variables.
- // Just need to make sure that buffer_in_progress_ is NULL before calling.
- cleanupBufferInProgress();
-}
-
-AAH_RXPlayer::Substream::~Substream() {
- shutdown();
-}
-
-void AAH_RXPlayer::Substream::shutdown() {
- substream_meta_ = NULL;
- status_ = OK;
- cleanupBufferInProgress();
- cleanupDecoder();
-}
-
-void AAH_RXPlayer::Substream::cleanupBufferInProgress() {
- if (NULL != buffer_in_progress_) {
- buffer_in_progress_->release();
- buffer_in_progress_ = NULL;
- }
-
- expected_buffer_size_ = 0;
- buffer_filled_ = 0;
- waiting_for_rap_ = true;
-
- aux_data_in_progress_.clear();
- aux_data_expected_size_ = 0;
-}
-
-void AAH_RXPlayer::Substream::cleanupDecoder() {
- if (decoder_ != NULL) {
- decoder_->shutdown();
- }
-}
-
-bool AAH_RXPlayer::Substream::shouldAbort(const char* log_tag) {
- // If we have already encountered a fatal error, do nothing. We are just
- // waiting for our owner to shut us down now.
- if (OK != status_) {
- ALOGV("Skipping %s, substream has encountered fatal error (%d).",
- log_tag, status_);
- return true;
- }
-
- return false;
-}
-
-void AAH_RXPlayer::Substream::processPayloadStart(uint8_t* buf,
- uint32_t amt,
- int32_t ts_lower) {
- uint32_t min_length = 6;
-
- if (shouldAbort(__PRETTY_FUNCTION__)) {
- return;
- }
-
- // Do we have a buffer in progress already? If so, abort the buffer. In
- // theory, this should never happen. If there were a discontinutity in the
- // stream, the discon in the seq_nos at the RTP level should have already
- // triggered a cleanup of the buffer in progress. To see a problem at this
- // level is an indication either of a bug in the transmitter, or some form
- // of terrible corruption/tampering on the wire.
- if (NULL != buffer_in_progress_) {
- ALOGE("processPayloadStart is aborting payload already in progress.");
- cleanupBufferInProgress();
- }
-
- // Parse enough of the header to know where we stand. Since this is a
- // payload start, it should begin with a TRTP header which has to be at
- // least 6 bytes long.
- if (amt < min_length) {
- ALOGV("Discarding payload too short to contain TRTP header (len = %u)",
- amt);
- return;
- }
-
- // Check the TRTP version number.
- if (0x01 != buf[0]) {
- ALOGV("Unexpected TRTP version (%u) in header. Expected %u.",
- buf[0], 1);
- return;
- }
-
- // Extract the substream type field and make sure its one we understand (and
- // one that does not conflict with any previously received substream type.
- uint8_t header_type = (buf[1] >> 4) & 0xF;
- switch (header_type) {
- case TRTPPacket::kHeaderTypeAudio:
- // Audio, yay! Just break. We understand audio payloads.
- break;
- case TRTPPacket::kHeaderTypeVideo:
- ALOGV("RXed packet with unhandled TRTP header type (Video).");
- return;
- case TRTPPacket::kHeaderTypeSubpicture:
- ALOGV("RXed packet with unhandled TRTP header type (Subpicture).");
- return;
- case TRTPPacket::kHeaderTypeControl:
- ALOGV("RXed packet with unhandled TRTP header type (Control).");
- return;
- default:
- ALOGV("RXed packet with unhandled TRTP header type (%u).",
- header_type);
- return;
- }
-
- if (substream_details_known_ && (header_type != substream_type_)) {
- ALOGV("RXed TRTP Payload for SSRC=0x%08x where header type (%u) does"
- " not match previously received header type (%u)",
- ssrc_, header_type, substream_type_);
- return;
- }
-
- // Check the flags to see if there is another 32 bits of timestamp present.
- uint32_t trtp_header_len = 6;
- bool ts_valid = buf[1] & TRTPPacket::kFlag_TSValid;
- if (ts_valid) {
- min_length += 4;
- trtp_header_len += 4;
- if (amt < min_length) {
- ALOGV("Discarding payload too short to contain TRTP timestamp"
- " (len = %u)", amt);
- return;
- }
- }
-
- // Extract the TRTP length field and sanity check it.
- uint32_t trtp_len = U32_AT(buf + 2);
- if (trtp_len < min_length) {
- ALOGV("TRTP length (%u) is too short to be valid. Must be at least %u"
- " bytes.", trtp_len, min_length);
- return;
- }
-
- // Extract the rest of the timestamp field if valid.
- int64_t ts = 0;
- uint32_t parse_offset = 6;
- if (ts_valid) {
- uint32_t ts_upper = U32_AT(buf + parse_offset);
- parse_offset += 4;
- ts = (static_cast<int64_t>(ts_upper) << 32) | ts_lower;
- }
-
- // Check the flags to see if there is another 24 bytes of timestamp
- // transformation present.
- if (buf[1] & TRTPPacket::kFlag_TSTransformPresent) {
- min_length += 24;
- parse_offset += 24;
- trtp_header_len += 24;
- if (amt < min_length) {
- ALOGV("Discarding payload too short to contain TRTP timestamp"
- " transformation (len = %u)", amt);
- return;
- }
- }
-
- // TODO : break the parsing into individual parsers for the different
- // payload types (audio, video, etc).
- //
- // At this point in time, we know that this is audio. Go ahead and parse
- // the basic header, check the codec type, and find the payload portion of
- // the packet.
- min_length += 3;
- if (trtp_len < min_length) {
- ALOGV("TRTP length (%u) is too short to be a valid audio payload. Must"
- " be at least %u bytes.", trtp_len, min_length);
- return;
- }
-
- if (amt < min_length) {
- ALOGV("TRTP porttion of RTP payload (%u bytes) too small to contain"
- " entire TRTP header. TRTP does not currently support"
- " fragmenting TRTP headers across RTP payloads", amt);
- return;
- }
-
- uint8_t codec_type = buf[parse_offset ];
- uint8_t flags = buf[parse_offset + 1];
- uint8_t volume = buf[parse_offset + 2];
- parse_offset += 3;
- trtp_header_len += 3;
-
- if (!setupSubstreamType(header_type, codec_type)) {
- return;
- }
-
- if (decoder_ != NULL) {
- decoder_->setRenderVolume(volume);
- }
-
- if (waiting_for_rap_ && !(flags & TRTPAudioPacket::kFlag_RandomAccessPoint)) {
- ALOGV("Dropping non-RAP TRTP Audio Payload while waiting for RAP.");
- return;
- }
-
- // Check for the presence of codec aux data.
- if (flags & TRTPAudioPacket::kFlag_AuxLengthPresent) {
- min_length += 4;
- trtp_header_len += 4;
-
- if (trtp_len < min_length) {
- ALOGV("TRTP length (%u) is too short to be a valid audio payload. "
- "Must be at least %u bytes.", trtp_len, min_length);
- return;
- }
-
- if (amt < min_length) {
- ALOGV("TRTP porttion of RTP payload (%u bytes) too small to contain"
- " entire TRTP header. TRTP does not currently support"
- " fragmenting TRTP headers across RTP payloads", amt);
- return;
- }
-
- aux_data_expected_size_ = U32_AT(buf + parse_offset);
- aux_data_in_progress_.clear();
- if (aux_data_in_progress_.capacity() < aux_data_expected_size_) {
- aux_data_in_progress_.setCapacity(aux_data_expected_size_);
- }
- } else {
- aux_data_expected_size_ = 0;
- }
-
- if ((aux_data_expected_size_ + trtp_header_len) > trtp_len) {
- ALOGV("Expected codec aux data length (%u) and TRTP header overhead"
- " (%u) too large for total TRTP payload length (%u).",
- aux_data_expected_size_, trtp_header_len, trtp_len);
- return;
- }
-
- // OK - everything left is just payload. Compute the payload size, start
- // the buffer in progress and pack as much payload as we can into it. If
- // the payload is finished once we are done, go ahead and send the payload
- // to the decoder.
- expected_buffer_size_ = trtp_len
- - trtp_header_len
- - aux_data_expected_size_;
- if (!expected_buffer_size_) {
- ALOGV("Dropping TRTP Audio Payload with 0 Access Unit length");
- return;
- }
-
- CHECK(amt >= trtp_header_len);
- uint32_t todo = amt - trtp_header_len;
- if ((expected_buffer_size_ + aux_data_expected_size_) < todo) {
- ALOGV("Extra data (%u > %u) present in initial TRTP Audio Payload;"
- " dropping payload.", todo,
- expected_buffer_size_ + aux_data_expected_size_);
- return;
- }
-
- buffer_filled_ = 0;
- buffer_in_progress_ = new MediaBuffer(expected_buffer_size_);
- if ((NULL == buffer_in_progress_) ||
- (NULL == buffer_in_progress_->data())) {
- ALOGV("Failed to allocate MediaBuffer of length %u",
- expected_buffer_size_);
- cleanupBufferInProgress();
- return;
- }
-
- sp<MetaData> meta = buffer_in_progress_->meta_data();
- if (meta == NULL) {
- ALOGV("Missing metadata structure in allocated MediaBuffer; dropping"
- " payload");
- cleanupBufferInProgress();
- return;
- }
-
- meta->setCString(kKeyMIMEType, codec_mime_type_);
- if (ts_valid) {
- meta->setInt64(kKeyTime, ts);
- }
-
- // Skip over the header we have already extracted.
- amt -= trtp_header_len;
- buf += trtp_header_len;
-
- // Extract as much of the expected aux data as we can.
- todo = min(aux_data_expected_size_, amt);
- if (todo) {
- aux_data_in_progress_.appendArray(buf, todo);
- buf += todo;
- amt -= todo;
- }
-
- // Extract as much of the expected payload as we can.
- todo = min(expected_buffer_size_, amt);
- if (todo > 0) {
- uint8_t* tgt =
- reinterpret_cast<uint8_t*>(buffer_in_progress_->data());
- memcpy(tgt, buf, todo);
- buffer_filled_ = amt;
- buf += todo;
- amt -= todo;
- }
-
- if (buffer_filled_ >= expected_buffer_size_) {
- processCompletedBuffer();
- }
-}
-
-void AAH_RXPlayer::Substream::processPayloadCont(uint8_t* buf,
- uint32_t amt) {
- if (shouldAbort(__PRETTY_FUNCTION__)) {
- return;
- }
-
- if (NULL == buffer_in_progress_) {
- ALOGV("TRTP Receiver skipping payload continuation; no buffer currently"
- " in progress.");
- return;
- }
-
- CHECK(aux_data_in_progress_.size() <= aux_data_expected_size_);
- uint32_t aux_left = aux_data_expected_size_ - aux_data_in_progress_.size();
- if (aux_left) {
- uint32_t todo = min(aux_left, amt);
- aux_data_in_progress_.appendArray(buf, todo);
- amt -= todo;
- buf += todo;
-
- if (!amt)
- return;
- }
-
- CHECK(buffer_filled_ < expected_buffer_size_);
- uint32_t buffer_left = expected_buffer_size_ - buffer_filled_;
- if (amt > buffer_left) {
- ALOGV("Extra data (%u > %u) present in continued TRTP Audio Payload;"
- " dropping payload.", amt, buffer_left);
- cleanupBufferInProgress();
- return;
- }
-
- if (amt > 0) {
- uint8_t* tgt =
- reinterpret_cast<uint8_t*>(buffer_in_progress_->data());
- memcpy(tgt + buffer_filled_, buf, amt);
- buffer_filled_ += amt;
- }
-
- if (buffer_filled_ >= expected_buffer_size_) {
- processCompletedBuffer();
- }
-}
-
-void AAH_RXPlayer::Substream::processCompletedBuffer() {
- status_t res;
-
- CHECK(NULL != buffer_in_progress_);
-
- if (decoder_ == NULL) {
- ALOGV("Dropping complete buffer, no decoder pump allocated");
- goto bailout;
- }
-
- // Make sure our metadata used to initialize the decoder has been properly
- // set up.
- if (!setupSubstreamMeta())
- goto bailout;
-
- // If our decoder has not be set up, do so now.
- res = decoder_->init(substream_meta_);
- if (OK != res) {
- ALOGE("Failed to init decoder (res = %d)", res);
- cleanupDecoder();
- substream_meta_ = NULL;
- goto bailout;
- }
-
- // Queue the payload for decode.
- res = decoder_->queueForDecode(buffer_in_progress_);
-
- if (res != OK) {
- ALOGD("Failed to queue payload for decode, resetting decoder pump!"
- " (res = %d)", res);
- status_ = res;
- cleanupDecoder();
- cleanupBufferInProgress();
- }
-
- // NULL out buffer_in_progress before calling the cleanup helper.
- //
- // MediaBuffers use something of a hybrid ref-counting pattern which prevent
- // the AAH_DecoderPump's input queue from adding their own reference to the
- // MediaBuffer. MediaBuffers start life with a reference count of 0, as
- // well as an observer which starts as NULL. Before being given an
- // observer, the ref count cannot be allowed to become non-zero as it will
- // cause calls to release() to assert. Basically, before a MediaBuffer has
- // an observer, they behave like non-ref counted obects where release()
- // serves the roll of delete. After a MediaBuffer has an observer, they
- // become more like ref counted objects where add ref and release can be
- // used, and when the ref count hits zero, the MediaBuffer is handed off to
- // the observer.
- //
- // Given all of this, when we give the buffer to the decoder pump to wait in
- // the to-be-processed queue, the decoder cannot add a ref to the buffer as
- // it would in a traditional ref counting system. Instead it needs to
- // "steal" the non-existent ref. In the case of queue failure, we need to
- // make certain to release this non-existent reference so that the buffer is
- // cleaned up during the cleanupBufferInProgress helper. In the case of a
- // successful queue operation, we need to make certain that the
- // cleanupBufferInProgress helper does not release the buffer since it needs
- // to remain alive in the queue. We acomplish this by NULLing out the
- // buffer pointer before calling the cleanup helper.
- buffer_in_progress_ = NULL;
-
-bailout:
- cleanupBufferInProgress();
-}
-
-bool AAH_RXPlayer::Substream::setupSubstreamMeta() {
- switch (codec_type_) {
- case TRTPAudioPacket::kCodecMPEG1Audio:
- codec_mime_type_ = MEDIA_MIMETYPE_AUDIO_MPEG;
- return setupMP3SubstreamMeta();
-
- case TRTPAudioPacket::kCodecAACAudio:
- codec_mime_type_ = MEDIA_MIMETYPE_AUDIO_AAC;
- return setupAACSubstreamMeta();
-
- default:
- ALOGV("Failed to setup substream metadata for unsupported codec"
- " type (%u)", codec_type_);
- break;
- }
-
- return false;
-}
-
-bool AAH_RXPlayer::Substream::setupMP3SubstreamMeta() {
- const uint8_t* buffer_data = NULL;
- int sample_rate;
- int channel_count;
- size_t frame_size;
- status_t res;
-
- buffer_data = reinterpret_cast<const uint8_t*>(buffer_in_progress_->data());
- if (buffer_in_progress_->size() < 4) {
- ALOGV("MP3 payload too short to contain header, dropping payload.");
- return false;
- }
-
- // Extract the channel count and the sample rate from the MP3 header. The
- // stagefright MP3 requires that these be delivered before decoing can
- // begin.
- if (!GetMPEGAudioFrameSize(U32_AT(buffer_data),
- &frame_size,
- &sample_rate,
- &channel_count,
- NULL,
- NULL)) {
- ALOGV("Failed to parse MP3 header in payload, droping payload.");
- return false;
- }
-
-
- // Make sure that our substream metadata is set up properly. If there has
- // been a format change, be sure to reset the underlying decoder. In
- // stagefright, it seems like the only way to do this is to destroy and
- // recreate the decoder.
- if (substream_meta_ == NULL) {
- substream_meta_ = new MetaData();
-
- if (substream_meta_ == NULL) {
- ALOGE("Failed to allocate MetaData structure for MP3 substream");
- return false;
- }
-
- substream_meta_->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_MPEG);
- substream_meta_->setInt32 (kKeyChannelCount, channel_count);
- substream_meta_->setInt32 (kKeySampleRate, sample_rate);
- } else {
- int32_t prev_sample_rate;
- int32_t prev_channel_count;
- substream_meta_->findInt32(kKeySampleRate, &prev_sample_rate);
- substream_meta_->findInt32(kKeyChannelCount, &prev_channel_count);
-
- if ((prev_channel_count != channel_count) ||
- (prev_sample_rate != sample_rate)) {
- ALOGW("MP3 format change detected, forcing decoder reset.");
- cleanupDecoder();
-
- substream_meta_->setInt32(kKeyChannelCount, channel_count);
- substream_meta_->setInt32(kKeySampleRate, sample_rate);
- }
- }
-
- return true;
-}
-
-bool AAH_RXPlayer::Substream::setupAACSubstreamMeta() {
- int32_t sample_rate, channel_cnt;
- static const size_t overhead = sizeof(sample_rate)
- + sizeof(channel_cnt);
-
- if (aux_data_in_progress_.size() < overhead) {
- ALOGE("Not enough aux data (%u) to initialize AAC substream decoder",
- aux_data_in_progress_.size());
- return false;
- }
-
- const uint8_t* aux_data = aux_data_in_progress_.array();
- size_t aux_data_size = aux_data_in_progress_.size();
- sample_rate = U32_AT(aux_data);
- channel_cnt = U32_AT(aux_data + sizeof(sample_rate));
-
- const uint8_t* esds_data = NULL;
- size_t esds_data_size = 0;
- if (aux_data_size > overhead) {
- esds_data = aux_data + overhead;
- esds_data_size = aux_data_size - overhead;
- }
-
- // Do we already have metadata? If so, has it changed at all? If not, then
- // there should be nothing else to do. Otherwise, release our old stream
- // metadata and make new metadata.
- if (substream_meta_ != NULL) {
- uint32_t type;
- const void* data;
- size_t size;
- int32_t prev_sample_rate;
- int32_t prev_channel_count;
- bool res;
-
- res = substream_meta_->findInt32(kKeySampleRate, &prev_sample_rate);
- CHECK(res);
- res = substream_meta_->findInt32(kKeyChannelCount, &prev_channel_count);
- CHECK(res);
-
- // If nothing has changed about the codec aux data (esds, sample rate,
- // channel count), then we can just do nothing and get out. Otherwise,
- // we will need to reset the decoder and make a new metadata object to
- // deal with the format change.
- bool hasData = (esds_data != NULL);
- bool hadData = substream_meta_->findData(kKeyESDS, &type, &data, &size);
- bool esds_change = (hadData != hasData);
-
- if (!esds_change && hasData)
- esds_change = ((size != esds_data_size) ||
- memcmp(data, esds_data, size));
-
- if (!esds_change &&
- (prev_sample_rate == sample_rate) &&
- (prev_channel_count == channel_cnt)) {
- return true; // no change, just get out.
- }
-
- ALOGW("AAC format change detected, forcing decoder reset.");
- cleanupDecoder();
- substream_meta_ = NULL;
- }
-
- CHECK(substream_meta_ == NULL);
-
- substream_meta_ = new MetaData();
- if (substream_meta_ == NULL) {
- ALOGE("Failed to allocate MetaData structure for AAC substream");
- return false;
- }
-
- substream_meta_->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_AAC);
- substream_meta_->setInt32 (kKeySampleRate, sample_rate);
- substream_meta_->setInt32 (kKeyChannelCount, channel_cnt);
-
- if (esds_data) {
- substream_meta_->setData(kKeyESDS, kTypeESDS,
- esds_data, esds_data_size);
- }
-
- return true;
-}
-
-void AAH_RXPlayer::Substream::processTSTransform(const LinearTransform& trans) {
- if (decoder_ != NULL) {
- decoder_->setRenderTSTransform(trans);
- }
-}
-
-bool AAH_RXPlayer::Substream::isAboutToUnderflow() {
- if (decoder_ == NULL) {
- return false;
- }
-
- return decoder_->isAboutToUnderflow(kAboutToUnderflowThreshold);
-}
-
-bool AAH_RXPlayer::Substream::setupSubstreamType(uint8_t substream_type,
- uint8_t codec_type) {
- // Sanity check the codec type. Right now we only support MP3 and AAC.
- // Also check for conflicts with previously delivered codec types.
- if (substream_details_known_) {
- if (codec_type != codec_type_) {
- ALOGV("RXed TRTP Payload for SSRC=0x%08x where codec type (%u) does"
- " not match previously received codec type (%u)",
- ssrc_, codec_type, codec_type_);
- return false;
- }
-
- return true;
- }
-
- switch (codec_type) {
- // MP3 and AAC are all we support right now.
- case TRTPAudioPacket::kCodecMPEG1Audio:
- case TRTPAudioPacket::kCodecAACAudio:
- break;
-
- default:
- ALOGV("RXed TRTP Audio Payload for SSRC=0x%08x with unsupported"
- " codec type (%u)", ssrc_, codec_type);
- return false;
- }
-
- substream_type_ = substream_type;
- codec_type_ = codec_type;
- substream_details_known_ = true;
-
- return true;
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_tx_packet.cpp b/media/libaah_rtp/aah_tx_packet.cpp
deleted file mode 100644
index 4cd6e47..0000000
--- a/media/libaah_rtp/aah_tx_packet.cpp
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-#include <utils/Log.h>
-
-#include <arpa/inet.h>
-#include <string.h>
-
-#include <media/stagefright/foundation/ADebug.h>
-
-#include "aah_tx_packet.h"
-
-namespace android {
-
-const int TRTPPacket::kRTPHeaderLen;
-const uint32_t TRTPPacket::kTRTPEpochMask;
-
-TRTPPacket::~TRTPPacket() {
- delete mPacket;
-}
-
-/*** TRTP packet properties ***/
-
-void TRTPPacket::setSeqNumber(uint16_t val) {
- mSeqNumber = val;
-
- if (mIsPacked) {
- const int kTRTPSeqNumberOffset = 2;
- uint16_t* buf = reinterpret_cast<uint16_t*>(
- mPacket + kTRTPSeqNumberOffset);
- *buf = htons(mSeqNumber);
- }
-}
-
-uint16_t TRTPPacket::getSeqNumber() const {
- return mSeqNumber;
-}
-
-void TRTPPacket::setPTS(int64_t val) {
- CHECK(!mIsPacked);
- mPTS = val;
- mPTSValid = true;
-}
-
-int64_t TRTPPacket::getPTS() const {
- return mPTS;
-}
-
-void TRTPPacket::setEpoch(uint32_t val) {
- mEpoch = val;
-
- if (mIsPacked) {
- const int kTRTPEpochOffset = 8;
- uint32_t* buf = reinterpret_cast<uint32_t*>(
- mPacket + kTRTPEpochOffset);
- uint32_t val = ntohl(*buf);
- val &= ~(kTRTPEpochMask << kTRTPEpochShift);
- val |= (mEpoch & kTRTPEpochMask) << kTRTPEpochShift;
- *buf = htonl(val);
- }
-}
-
-void TRTPPacket::setProgramID(uint16_t val) {
- CHECK(!mIsPacked);
- mProgramID = val;
-}
-
-void TRTPPacket::setSubstreamID(uint16_t val) {
- CHECK(!mIsPacked);
- mSubstreamID = val;
-}
-
-
-void TRTPPacket::setClockTransform(const LinearTransform& trans) {
- CHECK(!mIsPacked);
- mClockTranform = trans;
- mClockTranformValid = true;
-}
-
-uint8_t* TRTPPacket::getPacket() const {
- CHECK(mIsPacked);
- return mPacket;
-}
-
-int TRTPPacket::getPacketLen() const {
- CHECK(mIsPacked);
- return mPacketLen;
-}
-
-void TRTPPacket::setExpireTime(nsecs_t val) {
- CHECK(!mIsPacked);
- mExpireTime = val;
-}
-
-nsecs_t TRTPPacket::getExpireTime() const {
- return mExpireTime;
-}
-
-/*** TRTP audio packet properties ***/
-
-void TRTPAudioPacket::setCodecType(TRTPAudioCodecType val) {
- CHECK(!mIsPacked);
- mCodecType = val;
-}
-
-void TRTPAudioPacket::setRandomAccessPoint(bool val) {
- CHECK(!mIsPacked);
- mRandomAccessPoint = val;
-}
-
-void TRTPAudioPacket::setDropable(bool val) {
- CHECK(!mIsPacked);
- mDropable = val;
-}
-
-void TRTPAudioPacket::setDiscontinuity(bool val) {
- CHECK(!mIsPacked);
- mDiscontinuity = val;
-}
-
-void TRTPAudioPacket::setEndOfStream(bool val) {
- CHECK(!mIsPacked);
- mEndOfStream = val;
-}
-
-void TRTPAudioPacket::setVolume(uint8_t val) {
- CHECK(!mIsPacked);
- mVolume = val;
-}
-
-void TRTPAudioPacket::setAccessUnitData(const void* data, size_t len) {
- CHECK(!mIsPacked);
- mAccessUnitData = data;
- mAccessUnitLen = len;
-}
-
-void TRTPAudioPacket::setAuxData(const void* data, size_t len) {
- CHECK(!mIsPacked);
- mAuxData = data;
- mAuxDataLen = len;
-}
-
-/*** TRTP control packet properties ***/
-
-void TRTPControlPacket::setCommandID(TRTPCommandID val) {
- CHECK(!mIsPacked);
- mCommandID = val;
-}
-
-/*** TRTP packet serializers ***/
-
-void TRTPPacket::writeU8(uint8_t*& buf, uint8_t val) {
- *buf = val;
- buf++;
-}
-
-void TRTPPacket::writeU16(uint8_t*& buf, uint16_t val) {
- *reinterpret_cast<uint16_t*>(buf) = htons(val);
- buf += 2;
-}
-
-void TRTPPacket::writeU32(uint8_t*& buf, uint32_t val) {
- *reinterpret_cast<uint32_t*>(buf) = htonl(val);
- buf += 4;
-}
-
-void TRTPPacket::writeU64(uint8_t*& buf, uint64_t val) {
- buf[0] = static_cast<uint8_t>(val >> 56);
- buf[1] = static_cast<uint8_t>(val >> 48);
- buf[2] = static_cast<uint8_t>(val >> 40);
- buf[3] = static_cast<uint8_t>(val >> 32);
- buf[4] = static_cast<uint8_t>(val >> 24);
- buf[5] = static_cast<uint8_t>(val >> 16);
- buf[6] = static_cast<uint8_t>(val >> 8);
- buf[7] = static_cast<uint8_t>(val);
- buf += 8;
-}
-
-void TRTPPacket::writeTRTPHeader(uint8_t*& buf,
- bool isFirstFragment,
- int totalPacketLen) {
- // RTP header
- writeU8(buf,
- ((mVersion & 0x03) << 6) |
- (static_cast<int>(mPadding) << 5) |
- (static_cast<int>(mExtension) << 4) |
- (mCsrcCount & 0x0F));
- writeU8(buf,
- (static_cast<int>(isFirstFragment) << 7) |
- (mPayloadType & 0x7F));
- writeU16(buf, mSeqNumber);
- if (isFirstFragment && mPTSValid) {
- writeU32(buf, mPTS & 0xFFFFFFFF);
- } else {
- writeU32(buf, 0);
- }
- writeU32(buf,
- ((mEpoch & kTRTPEpochMask) << kTRTPEpochShift) |
- ((mProgramID & 0x1F) << 5) |
- (mSubstreamID & 0x1F));
-
- // TRTP header
- writeU8(buf, mTRTPVersion);
- writeU8(buf,
- ((mTRTPHeaderType & 0x0F) << 4) |
- (mClockTranformValid ? 0x02 : 0x00) |
- (mPTSValid ? 0x01 : 0x00));
- writeU32(buf, totalPacketLen - kRTPHeaderLen);
- if (mPTSValid) {
- writeU32(buf, mPTS >> 32);
- }
-
- if (mClockTranformValid) {
- writeU64(buf, mClockTranform.a_zero);
- writeU32(buf, mClockTranform.a_to_b_numer);
- writeU32(buf, mClockTranform.a_to_b_denom);
- writeU64(buf, mClockTranform.b_zero);
- }
-}
-
-bool TRTPAudioPacket::pack() {
- if (mIsPacked) {
- return false;
- }
-
- int packetLen = kRTPHeaderLen +
- mAuxDataLen +
- mAccessUnitLen +
- TRTPHeaderLen();
-
- // TODO : support multiple fragments
- const int kMaxUDPPayloadLen = 65507;
- if (packetLen > kMaxUDPPayloadLen) {
- return false;
- }
-
- mPacket = new uint8_t[packetLen];
- if (!mPacket) {
- return false;
- }
-
- mPacketLen = packetLen;
-
- uint8_t* cur = mPacket;
- bool hasAux = mAuxData && mAuxDataLen;
- uint8_t flags = (static_cast<int>(hasAux) << 4) |
- (static_cast<int>(mRandomAccessPoint) << 3) |
- (static_cast<int>(mDropable) << 2) |
- (static_cast<int>(mDiscontinuity) << 1) |
- (static_cast<int>(mEndOfStream));
-
- writeTRTPHeader(cur, true, packetLen);
- writeU8(cur, mCodecType);
- writeU8(cur, flags);
- writeU8(cur, mVolume);
-
- if (hasAux) {
- writeU32(cur, mAuxDataLen);
- memcpy(cur, mAuxData, mAuxDataLen);
- cur += mAuxDataLen;
- }
-
- memcpy(cur, mAccessUnitData, mAccessUnitLen);
-
- mIsPacked = true;
- return true;
-}
-
-int TRTPPacket::TRTPHeaderLen() const {
- // 6 bytes for version, payload type, flags and length. An additional 4 if
- // there are upper timestamp bits present and another 24 if there is a clock
- // transformation present.
- return 6 +
- (mClockTranformValid ? 24 : 0) +
- (mPTSValid ? 4 : 0);
-}
-
-int TRTPAudioPacket::TRTPHeaderLen() const {
- // TRTPPacket::TRTPHeaderLen() for the base TRTPHeader. 3 bytes for audio's
- // codec type, flags and volume field. Another 5 bytes if the codec type is
- // PCM and we are sending sample rate/channel count. as well as however long
- // the aux data (if present) is.
-
- int pcmParamLength;
- switch(mCodecType) {
- case kCodecPCMBigEndian:
- case kCodecPCMLittleEndian:
- pcmParamLength = 5;
- break;
-
- default:
- pcmParamLength = 0;
- break;
- }
-
-
- int auxDataLenField = (NULL != mAuxData) ? sizeof(uint32_t) : 0;
- return TRTPPacket::TRTPHeaderLen() +
- 3 +
- auxDataLenField +
- pcmParamLength;
-}
-
-bool TRTPControlPacket::pack() {
- if (mIsPacked) {
- return false;
- }
-
- // command packets contain a 2-byte command ID
- int packetLen = kRTPHeaderLen +
- TRTPHeaderLen() +
- 2;
-
- mPacket = new uint8_t[packetLen];
- if (!mPacket) {
- return false;
- }
-
- mPacketLen = packetLen;
-
- uint8_t* cur = mPacket;
-
- writeTRTPHeader(cur, true, packetLen);
- writeU16(cur, mCommandID);
-
- mIsPacked = true;
- return true;
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_tx_packet.h b/media/libaah_rtp/aah_tx_packet.h
deleted file mode 100644
index 7f78ea0..0000000
--- a/media/libaah_rtp/aah_tx_packet.h
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AAH_TX_PACKET_H__
-#define __AAH_TX_PACKET_H__
-
-#include <media/stagefright/foundation/ABase.h>
-#include <utils/LinearTransform.h>
-#include <utils/RefBase.h>
-#include <utils/Timers.h>
-
-namespace android {
-
-class TRTPPacket : public RefBase {
- public:
- enum TRTPHeaderType {
- kHeaderTypeAudio = 1,
- kHeaderTypeVideo = 2,
- kHeaderTypeSubpicture = 3,
- kHeaderTypeControl = 4,
- };
-
- enum TRTPPayloadFlags {
- kFlag_TSTransformPresent = 0x02,
- kFlag_TSValid = 0x01,
- };
-
- protected:
- TRTPPacket(TRTPHeaderType headerType)
- : mIsPacked(false)
- , mVersion(2)
- , mPadding(false)
- , mExtension(false)
- , mCsrcCount(0)
- , mPayloadType(100)
- , mSeqNumber(0)
- , mPTSValid(false)
- , mPTS(0)
- , mEpoch(0)
- , mProgramID(0)
- , mSubstreamID(0)
- , mClockTranformValid(false)
- , mTRTPVersion(1)
- , mTRTPLength(0)
- , mTRTPHeaderType(headerType)
- , mPacket(NULL)
- , mPacketLen(0) { }
-
- public:
- virtual ~TRTPPacket();
-
- void setSeqNumber(uint16_t val);
- uint16_t getSeqNumber() const;
-
- void setPTS(int64_t val);
- int64_t getPTS() const;
-
- void setEpoch(uint32_t val);
- void setProgramID(uint16_t val);
- void setSubstreamID(uint16_t val);
- void setClockTransform(const LinearTransform& trans);
-
- uint8_t* getPacket() const;
- int getPacketLen() const;
-
- void setExpireTime(nsecs_t val);
- nsecs_t getExpireTime() const;
-
- virtual bool pack() = 0;
-
- // mask for the number of bits in a TRTP epoch
- static const uint32_t kTRTPEpochMask = (1 << 22) - 1;
- static const int kTRTPEpochShift = 10;
-
- protected:
- static const int kRTPHeaderLen = 12;
- virtual int TRTPHeaderLen() const;
-
- void writeTRTPHeader(uint8_t*& buf,
- bool isFirstFragment,
- int totalPacketLen);
-
- void writeU8(uint8_t*& buf, uint8_t val);
- void writeU16(uint8_t*& buf, uint16_t val);
- void writeU32(uint8_t*& buf, uint32_t val);
- void writeU64(uint8_t*& buf, uint64_t val);
-
- bool mIsPacked;
-
- uint8_t mVersion;
- bool mPadding;
- bool mExtension;
- uint8_t mCsrcCount;
- uint8_t mPayloadType;
- uint16_t mSeqNumber;
- bool mPTSValid;
- int64_t mPTS;
- uint32_t mEpoch;
- uint16_t mProgramID;
- uint16_t mSubstreamID;
- LinearTransform mClockTranform;
- bool mClockTranformValid;
- uint8_t mTRTPVersion;
- uint32_t mTRTPLength;
- TRTPHeaderType mTRTPHeaderType;
-
- uint8_t* mPacket;
- int mPacketLen;
-
- nsecs_t mExpireTime;
-
- DISALLOW_EVIL_CONSTRUCTORS(TRTPPacket);
-};
-
-class TRTPAudioPacket : public TRTPPacket {
- public:
- enum AudioPayloadFlags {
- kFlag_AuxLengthPresent = 0x10,
- kFlag_RandomAccessPoint = 0x08,
- kFlag_Dropable = 0x04,
- kFlag_Discontinuity = 0x02,
- kFlag_EndOfStream = 0x01,
- };
-
- TRTPAudioPacket()
- : TRTPPacket(kHeaderTypeAudio)
- , mCodecType(kCodecInvalid)
- , mRandomAccessPoint(false)
- , mDropable(false)
- , mDiscontinuity(false)
- , mEndOfStream(false)
- , mVolume(0)
- , mAccessUnitData(NULL)
- , mAccessUnitLen(0)
- , mAuxData(NULL)
- , mAuxDataLen(0) { }
-
- enum TRTPAudioCodecType {
- kCodecInvalid = 0,
- kCodecPCMBigEndian = 1,
- kCodecPCMLittleEndian = 2,
- kCodecMPEG1Audio = 3,
- kCodecAACAudio = 4,
- };
-
- void setCodecType(TRTPAudioCodecType val);
- void setRandomAccessPoint(bool val);
- void setDropable(bool val);
- void setDiscontinuity(bool val);
- void setEndOfStream(bool val);
- void setVolume(uint8_t val);
- void setAccessUnitData(const void* data, size_t len);
- void setAuxData(const void* data, size_t len);
-
- virtual bool pack();
-
- protected:
- virtual int TRTPHeaderLen() const;
-
- private:
- TRTPAudioCodecType mCodecType;
- bool mRandomAccessPoint;
- bool mDropable;
- bool mDiscontinuity;
- bool mEndOfStream;
- uint8_t mVolume;
-
- const void* mAccessUnitData;
- size_t mAccessUnitLen;
- const void* mAuxData;
- size_t mAuxDataLen;
-
- DISALLOW_EVIL_CONSTRUCTORS(TRTPAudioPacket);
-};
-
-class TRTPControlPacket : public TRTPPacket {
- public:
- TRTPControlPacket()
- : TRTPPacket(kHeaderTypeControl)
- , mCommandID(kCommandNop) {}
-
- enum TRTPCommandID {
- kCommandNop = 1,
- kCommandFlush = 2,
- kCommandEOS = 3,
- };
-
- void setCommandID(TRTPCommandID val);
-
- virtual bool pack();
-
- private:
- TRTPCommandID mCommandID;
-
- DISALLOW_EVIL_CONSTRUCTORS(TRTPControlPacket);
-};
-
-} // namespace android
-
-#endif // __AAH_TX_PLAYER_H__
diff --git a/media/libaah_rtp/aah_tx_player.cpp b/media/libaah_rtp/aah_tx_player.cpp
deleted file mode 100644
index 974805b..0000000
--- a/media/libaah_rtp/aah_tx_player.cpp
+++ /dev/null
@@ -1,1177 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-#include <utils/Log.h>
-
-#define __STDC_FORMAT_MACROS
-#include <inttypes.h>
-#include <netdb.h>
-#include <netinet/ip.h>
-
-#include <common_time/cc_helper.h>
-#include <media/IMediaPlayer.h>
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/AMessage.h>
-#include <media/stagefright/FileSource.h>
-#include <media/stagefright/MediaBuffer.h>
-#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-#include <utils/Timers.h>
-
-#include "aah_tx_packet.h"
-#include "aah_tx_player.h"
-
-namespace android {
-
-static int64_t kLowWaterMarkUs = 2000000ll; // 2secs
-static int64_t kHighWaterMarkUs = 10000000ll; // 10secs
-static const size_t kLowWaterMarkBytes = 40000;
-static const size_t kHighWaterMarkBytes = 200000;
-
-// When we start up, how much lead time should we put on the first access unit?
-static const int64_t kAAHStartupLeadTimeUs = 300000LL;
-
-// How much time do we attempt to lead the clock by in steady state?
-static const int64_t kAAHBufferTimeUs = 1000000LL;
-
-// how long do we keep data in our retransmit buffer after sending it.
-const int64_t AAH_TXPlayer::kAAHRetryKeepAroundTimeNs =
- kAAHBufferTimeUs * 1100;
-
-sp<MediaPlayerBase> createAAH_TXPlayer() {
- sp<MediaPlayerBase> ret = new AAH_TXPlayer();
- return ret;
-}
-
-template <typename T> static T clamp(T val, T min, T max) {
- if (val < min) {
- return min;
- } else if (val > max) {
- return max;
- } else {
- return val;
- }
-}
-
-struct AAH_TXEvent : public TimedEventQueue::Event {
- AAH_TXEvent(AAH_TXPlayer *player,
- void (AAH_TXPlayer::*method)()) : mPlayer(player)
- , mMethod(method) {}
-
- protected:
- virtual ~AAH_TXEvent() {}
-
- virtual void fire(TimedEventQueue *queue, int64_t /* now_us */) {
- (mPlayer->*mMethod)();
- }
-
- private:
- AAH_TXPlayer *mPlayer;
- void (AAH_TXPlayer::*mMethod)();
-
- AAH_TXEvent(const AAH_TXEvent &);
- AAH_TXEvent& operator=(const AAH_TXEvent &);
-};
-
-AAH_TXPlayer::AAH_TXPlayer()
- : mQueueStarted(false)
- , mFlags(0)
- , mExtractorFlags(0) {
- DataSource::RegisterDefaultSniffers();
-
- mBufferingEvent = new AAH_TXEvent(this, &AAH_TXPlayer::onBufferingUpdate);
- mBufferingEventPending = false;
-
- mPumpAudioEvent = new AAH_TXEvent(this, &AAH_TXPlayer::onPumpAudio);
- mPumpAudioEventPending = false;
-
- mAudioCodecData = NULL;
-
- reset_l();
-}
-
-AAH_TXPlayer::~AAH_TXPlayer() {
- if (mQueueStarted) {
- mQueue.stop();
- }
-
- reset_l();
-}
-
-void AAH_TXPlayer::cancelPlayerEvents(bool keepBufferingGoing) {
- if (!keepBufferingGoing) {
- mQueue.cancelEvent(mBufferingEvent->eventID());
- mBufferingEventPending = false;
-
- mQueue.cancelEvent(mPumpAudioEvent->eventID());
- mPumpAudioEventPending = false;
- }
-}
-
-status_t AAH_TXPlayer::initCheck() {
- // Check for the presense of the common time service by attempting to query
- // for CommonTime's frequency. If we get an error back, we cannot talk to
- // the service at all and should abort now.
- status_t res;
- uint64_t freq;
- res = mCCHelper.getCommonFreq(&freq);
- if (OK != res) {
- ALOGE("Failed to connect to common time service! (res %d)", res);
- return res;
- }
-
- return OK;
-}
-
-status_t AAH_TXPlayer::setDataSource(
- const char *url,
- const KeyedVector<String8, String8> *headers) {
- Mutex::Autolock autoLock(mLock);
- return setDataSource_l(url, headers);
-}
-
-status_t AAH_TXPlayer::setDataSource_l(
- const char *url,
- const KeyedVector<String8, String8> *headers) {
- reset_l();
-
- mUri.setTo(url);
-
- if (headers) {
- mUriHeaders = *headers;
-
- ssize_t index = mUriHeaders.indexOfKey(String8("x-hide-urls-from-log"));
- if (index >= 0) {
- // Browser is in "incognito" mode, suppress logging URLs.
-
- // This isn't something that should be passed to the server.
- mUriHeaders.removeItemsAt(index);
-
- mFlags |= INCOGNITO;
- }
- }
-
- // The URL may optionally contain a "#" character followed by a Skyjam
- // cookie. Ideally the cookie header should just be passed in the headers
- // argument, but the Java API for supplying headers is apparently not yet
- // exposed in the SDK used by application developers.
- const char kSkyjamCookieDelimiter = '#';
- char* skyjamCookie = strrchr(mUri.string(), kSkyjamCookieDelimiter);
- if (skyjamCookie) {
- skyjamCookie++;
- mUriHeaders.add(String8("Cookie"), String8(skyjamCookie));
- mUri = String8(mUri.string(), skyjamCookie - mUri.string());
- }
-
- return OK;
-}
-
-status_t AAH_TXPlayer::setDataSource(int fd, int64_t offset, int64_t length) {
- Mutex::Autolock autoLock(mLock);
-
- reset_l();
-
- sp<DataSource> dataSource = new FileSource(dup(fd), offset, length);
-
- status_t err = dataSource->initCheck();
-
- if (err != OK) {
- return err;
- }
-
- mFileSource = dataSource;
-
- sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
-
- if (extractor == NULL) {
- return UNKNOWN_ERROR;
- }
-
- return setDataSource_l(extractor);
-}
-
-status_t AAH_TXPlayer::setVideoSurface(const sp<Surface>& surface) {
- return OK;
-}
-
-status_t AAH_TXPlayer::setVideoSurfaceTexture(
- const sp<ISurfaceTexture>& surfaceTexture) {
- return OK;
-}
-
-status_t AAH_TXPlayer::prepare() {
- return INVALID_OPERATION;
-}
-
-status_t AAH_TXPlayer::prepareAsync() {
- Mutex::Autolock autoLock(mLock);
-
- return prepareAsync_l();
-}
-
-status_t AAH_TXPlayer::prepareAsync_l() {
- if (mFlags & PREPARING) {
- return UNKNOWN_ERROR; // async prepare already pending
- }
-
- mAAH_Sender = AAH_TXSender::GetInstance();
- if (mAAH_Sender == NULL) {
- return NO_MEMORY;
- }
-
- if (!mQueueStarted) {
- mQueue.start();
- mQueueStarted = true;
- }
-
- mFlags |= PREPARING;
- mAsyncPrepareEvent = new AAH_TXEvent(
- this, &AAH_TXPlayer::onPrepareAsyncEvent);
-
- mQueue.postEvent(mAsyncPrepareEvent);
-
- return OK;
-}
-
-status_t AAH_TXPlayer::finishSetDataSource_l() {
- sp<DataSource> dataSource;
-
- if (!strncasecmp("http://", mUri.string(), 7) ||
- !strncasecmp("https://", mUri.string(), 8)) {
-
- mConnectingDataSource = HTTPBase::Create(
- (mFlags & INCOGNITO)
- ? HTTPBase::kFlagIncognito
- : 0);
-
- mLock.unlock();
- status_t err = mConnectingDataSource->connect(mUri, &mUriHeaders);
- mLock.lock();
-
- if (err != OK) {
- mConnectingDataSource.clear();
-
- ALOGI("mConnectingDataSource->connect() returned %d", err);
- return err;
- }
-
- mCachedSource = new NuCachedSource2(mConnectingDataSource);
- mConnectingDataSource.clear();
-
- dataSource = mCachedSource;
-
- // We're going to prefill the cache before trying to instantiate
- // the extractor below, as the latter is an operation that otherwise
- // could block on the datasource for a significant amount of time.
- // During that time we'd be unable to abort the preparation phase
- // without this prefill.
-
- mLock.unlock();
-
- for (;;) {
- status_t finalStatus;
- size_t cachedDataRemaining =
- mCachedSource->approxDataRemaining(&finalStatus);
-
- if (finalStatus != OK ||
- cachedDataRemaining >= kHighWaterMarkBytes ||
- (mFlags & PREPARE_CANCELLED)) {
- break;
- }
-
- usleep(200000);
- }
-
- mLock.lock();
-
- if (mFlags & PREPARE_CANCELLED) {
- ALOGI("Prepare cancelled while waiting for initial cache fill.");
- return UNKNOWN_ERROR;
- }
- } else {
- dataSource = DataSource::CreateFromURI(mUri.string(), &mUriHeaders);
- }
-
- if (dataSource == NULL) {
- return UNKNOWN_ERROR;
- }
-
- sp<MediaExtractor> extractor = MediaExtractor::Create(dataSource);
-
- if (extractor == NULL) {
- return UNKNOWN_ERROR;
- }
-
- return setDataSource_l(extractor);
-}
-
-status_t AAH_TXPlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
- // Attempt to approximate overall stream bitrate by summing all
- // tracks' individual bitrates, if not all of them advertise bitrate,
- // we have to fail.
-
- int64_t totalBitRate = 0;
-
- for (size_t i = 0; i < extractor->countTracks(); ++i) {
- sp<MetaData> meta = extractor->getTrackMetaData(i);
-
- int32_t bitrate;
- if (!meta->findInt32(kKeyBitRate, &bitrate)) {
- totalBitRate = -1;
- break;
- }
-
- totalBitRate += bitrate;
- }
-
- mBitrate = totalBitRate;
-
- ALOGV("mBitrate = %lld bits/sec", mBitrate);
-
- bool haveAudio = false;
- for (size_t i = 0; i < extractor->countTracks(); ++i) {
- sp<MetaData> meta = extractor->getTrackMetaData(i);
-
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
-
- if (!strncasecmp(mime, "audio/", 6)) {
- mAudioSource = extractor->getTrack(i);
- CHECK(mAudioSource != NULL);
- haveAudio = true;
- break;
- }
- }
-
- if (!haveAudio) {
- return UNKNOWN_ERROR;
- }
-
- mExtractorFlags = extractor->flags();
-
- return OK;
-}
-
-void AAH_TXPlayer::abortPrepare(status_t err) {
- CHECK(err != OK);
-
- notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, err);
-
- mPrepareResult = err;
- mFlags &= ~(PREPARING|PREPARE_CANCELLED|PREPARING_CONNECTED);
- mPreparedCondition.broadcast();
-}
-
-void AAH_TXPlayer::onPrepareAsyncEvent() {
- Mutex::Autolock autoLock(mLock);
-
- if (mFlags & PREPARE_CANCELLED) {
- ALOGI("prepare was cancelled before doing anything");
- abortPrepare(UNKNOWN_ERROR);
- return;
- }
-
- if (mUri.size() > 0) {
- status_t err = finishSetDataSource_l();
-
- if (err != OK) {
- abortPrepare(err);
- return;
- }
- }
-
- mAudioFormat = mAudioSource->getFormat();
- if (!mAudioFormat->findInt64(kKeyDuration, &mDurationUs))
- mDurationUs = 1;
-
- const char* mime_type = NULL;
- if (!mAudioFormat->findCString(kKeyMIMEType, &mime_type)) {
- ALOGE("Failed to find audio substream MIME type during prepare.");
- abortPrepare(BAD_VALUE);
- return;
- }
-
- if (!strcmp(mime_type, MEDIA_MIMETYPE_AUDIO_MPEG)) {
- mAudioCodec = TRTPAudioPacket::kCodecMPEG1Audio;
- } else
- if (!strcmp(mime_type, MEDIA_MIMETYPE_AUDIO_AAC)) {
- mAudioCodec = TRTPAudioPacket::kCodecAACAudio;
-
- uint32_t type;
- int32_t sample_rate;
- int32_t channel_count;
- const void* esds_data;
- size_t esds_len;
-
- if (!mAudioFormat->findInt32(kKeySampleRate, &sample_rate)) {
- ALOGE("Failed to find sample rate for AAC substream.");
- abortPrepare(BAD_VALUE);
- return;
- }
-
- if (!mAudioFormat->findInt32(kKeyChannelCount, &channel_count)) {
- ALOGE("Failed to find channel count for AAC substream.");
- abortPrepare(BAD_VALUE);
- return;
- }
-
- if (!mAudioFormat->findData(kKeyESDS, &type, &esds_data, &esds_len)) {
- ALOGE("Failed to find codec init data for AAC substream.");
- abortPrepare(BAD_VALUE);
- return;
- }
-
- CHECK(NULL == mAudioCodecData);
- mAudioCodecDataSize = esds_len
- + sizeof(sample_rate)
- + sizeof(channel_count);
- mAudioCodecData = new uint8_t[mAudioCodecDataSize];
- if (NULL == mAudioCodecData) {
- ALOGE("Failed to allocate %u bytes for AAC substream codec aux"
- " data.", mAudioCodecDataSize);
- mAudioCodecDataSize = 0;
- abortPrepare(BAD_VALUE);
- return;
- }
-
- uint8_t* tmp = mAudioCodecData;
- tmp[0] = static_cast<uint8_t>((sample_rate >> 24) & 0xFF);
- tmp[1] = static_cast<uint8_t>((sample_rate >> 16) & 0xFF);
- tmp[2] = static_cast<uint8_t>((sample_rate >> 8) & 0xFF);
- tmp[3] = static_cast<uint8_t>((sample_rate ) & 0xFF);
- tmp[4] = static_cast<uint8_t>((channel_count >> 24) & 0xFF);
- tmp[5] = static_cast<uint8_t>((channel_count >> 16) & 0xFF);
- tmp[6] = static_cast<uint8_t>((channel_count >> 8) & 0xFF);
- tmp[7] = static_cast<uint8_t>((channel_count ) & 0xFF);
-
- memcpy(tmp + 8, esds_data, esds_len);
- } else {
- ALOGE("Unsupported MIME type \"%s\" in audio substream", mime_type);
- abortPrepare(BAD_VALUE);
- return;
- }
-
- status_t err = mAudioSource->start();
- if (err != OK) {
- ALOGI("failed to start audio source, err=%d", err);
- abortPrepare(err);
- return;
- }
-
- mFlags |= PREPARING_CONNECTED;
-
- if (mCachedSource != NULL) {
- postBufferingEvent_l();
- } else {
- finishAsyncPrepare_l();
- }
-}
-
-void AAH_TXPlayer::finishAsyncPrepare_l() {
- notifyListener_l(MEDIA_PREPARED);
-
- mPrepareResult = OK;
- mFlags &= ~(PREPARING|PREPARE_CANCELLED|PREPARING_CONNECTED);
- mFlags |= PREPARED;
- mPreparedCondition.broadcast();
-}
-
-status_t AAH_TXPlayer::start() {
- Mutex::Autolock autoLock(mLock);
-
- mFlags &= ~CACHE_UNDERRUN;
-
- return play_l();
-}
-
-status_t AAH_TXPlayer::play_l() {
- if (mFlags & PLAYING) {
- return OK;
- }
-
- if (!(mFlags & PREPARED)) {
- return INVALID_OPERATION;
- }
-
- {
- Mutex::Autolock lock(mEndpointLock);
- if (!mEndpointValid) {
- return INVALID_OPERATION;
- }
- if (!mEndpointRegistered) {
- mProgramID = mAAH_Sender->registerEndpoint(mEndpoint);
- mEndpointRegistered = true;
- }
- }
-
- mFlags |= PLAYING;
-
- updateClockTransform_l(false);
-
- postPumpAudioEvent_l(-1);
-
- return OK;
-}
-
-status_t AAH_TXPlayer::stop() {
- status_t ret = pause();
- sendEOS_l();
- return ret;
-}
-
-status_t AAH_TXPlayer::pause() {
- Mutex::Autolock autoLock(mLock);
-
- mFlags &= ~CACHE_UNDERRUN;
-
- return pause_l();
-}
-
-status_t AAH_TXPlayer::pause_l(bool doClockUpdate) {
- if (!(mFlags & PLAYING)) {
- return OK;
- }
-
- cancelPlayerEvents(true /* keepBufferingGoing */);
-
- mFlags &= ~PLAYING;
-
- if (doClockUpdate) {
- updateClockTransform_l(true);
- }
-
- return OK;
-}
-
-void AAH_TXPlayer::updateClockTransform_l(bool pause) {
- // record the new pause status so that onPumpAudio knows what rate to apply
- // when it initializes the transform
- mPlayRateIsPaused = pause;
-
- // if we haven't yet established a valid clock transform, then we can't
- // do anything here
- if (!mCurrentClockTransformValid) {
- return;
- }
-
- // sample the current common time
- int64_t commonTimeNow;
- if (OK != mCCHelper.getCommonTime(&commonTimeNow)) {
- ALOGE("updateClockTransform_l get common time failed");
- mCurrentClockTransformValid = false;
- return;
- }
-
- // convert the current common time to media time using the old
- // transform
- int64_t mediaTimeNow;
- if (!mCurrentClockTransform.doReverseTransform(
- commonTimeNow, &mediaTimeNow)) {
- ALOGE("updateClockTransform_l reverse transform failed");
- mCurrentClockTransformValid = false;
- return;
- }
-
- // calculate a new transform that preserves the old transform's
- // result for the current time
- mCurrentClockTransform.a_zero = mediaTimeNow;
- mCurrentClockTransform.b_zero = commonTimeNow;
- mCurrentClockTransform.a_to_b_numer = 1;
- mCurrentClockTransform.a_to_b_denom = pause ? 0 : 1;
-
- // send a packet announcing the new transform
- sp<TRTPControlPacket> packet = new TRTPControlPacket();
- packet->setClockTransform(mCurrentClockTransform);
- packet->setCommandID(TRTPControlPacket::kCommandNop);
- queuePacketToSender_l(packet);
-}
-
-void AAH_TXPlayer::sendEOS_l() {
- sp<TRTPControlPacket> packet = new TRTPControlPacket();
- packet->setCommandID(TRTPControlPacket::kCommandEOS);
- queuePacketToSender_l(packet);
-}
-
-bool AAH_TXPlayer::isPlaying() {
- return (mFlags & PLAYING) || (mFlags & CACHE_UNDERRUN);
-}
-
-status_t AAH_TXPlayer::seekTo(int msec) {
- if (mExtractorFlags & MediaExtractor::CAN_SEEK) {
- Mutex::Autolock autoLock(mLock);
- return seekTo_l(static_cast<int64_t>(msec) * 1000);
- }
-
- notifyListener_l(MEDIA_SEEK_COMPLETE);
- return OK;
-}
-
-status_t AAH_TXPlayer::seekTo_l(int64_t timeUs) {
- mIsSeeking = true;
- mSeekTimeUs = timeUs;
-
- mCurrentClockTransformValid = false;
- mLastQueuedMediaTimePTSValid = false;
-
- // send a flush command packet
- sp<TRTPControlPacket> packet = new TRTPControlPacket();
- packet->setCommandID(TRTPControlPacket::kCommandFlush);
- queuePacketToSender_l(packet);
-
- return OK;
-}
-
-status_t AAH_TXPlayer::getCurrentPosition(int *msec) {
- if (!msec) {
- return BAD_VALUE;
- }
-
- Mutex::Autolock lock(mLock);
-
- int position;
-
- if (mIsSeeking) {
- position = mSeekTimeUs / 1000;
- } else if (mCurrentClockTransformValid) {
- // sample the current common time
- int64_t commonTimeNow;
- if (OK != mCCHelper.getCommonTime(&commonTimeNow)) {
- ALOGE("getCurrentPosition get common time failed");
- return INVALID_OPERATION;
- }
-
- int64_t mediaTimeNow;
- if (!mCurrentClockTransform.doReverseTransform(commonTimeNow,
- &mediaTimeNow)) {
- ALOGE("getCurrentPosition reverse transform failed");
- return INVALID_OPERATION;
- }
-
- position = static_cast<int>(mediaTimeNow / 1000);
- } else {
- position = 0;
- }
-
- int duration;
- if (getDuration_l(&duration) == OK) {
- *msec = clamp(position, 0, duration);
- } else {
- *msec = (position >= 0) ? position : 0;
- }
-
- return OK;
-}
-
-status_t AAH_TXPlayer::getDuration(int* msec) {
- if (!msec) {
- return BAD_VALUE;
- }
-
- Mutex::Autolock lock(mLock);
-
- return getDuration_l(msec);
-}
-
-status_t AAH_TXPlayer::getDuration_l(int* msec) {
- if (mDurationUs < 0) {
- return UNKNOWN_ERROR;
- }
-
- *msec = (mDurationUs + 500) / 1000;
-
- return OK;
-}
-
-status_t AAH_TXPlayer::reset() {
- Mutex::Autolock autoLock(mLock);
- reset_l();
- return OK;
-}
-
-void AAH_TXPlayer::reset_l() {
- if (mFlags & PREPARING) {
- mFlags |= PREPARE_CANCELLED;
- if (mConnectingDataSource != NULL) {
- ALOGI("interrupting the connection process");
- mConnectingDataSource->disconnect();
- }
-
- if (mFlags & PREPARING_CONNECTED) {
- // We are basically done preparing, we're just buffering
- // enough data to start playback, we can safely interrupt that.
- finishAsyncPrepare_l();
- }
- }
-
- while (mFlags & PREPARING) {
- mPreparedCondition.wait(mLock);
- }
-
- cancelPlayerEvents();
-
- sendEOS_l();
-
- mCachedSource.clear();
-
- if (mAudioSource != NULL) {
- mAudioSource->stop();
- }
- mAudioSource.clear();
- mAudioCodec = TRTPAudioPacket::kCodecInvalid;
- mAudioFormat = NULL;
- delete[] mAudioCodecData;
- mAudioCodecData = NULL;
- mAudioCodecDataSize = 0;
-
- mFlags = 0;
- mExtractorFlags = 0;
-
- mDurationUs = -1;
- mIsSeeking = false;
- mSeekTimeUs = 0;
-
- mUri.setTo("");
- mUriHeaders.clear();
-
- mFileSource.clear();
-
- mBitrate = -1;
-
- {
- Mutex::Autolock lock(mEndpointLock);
- if (mAAH_Sender != NULL && mEndpointRegistered) {
- mAAH_Sender->unregisterEndpoint(mEndpoint);
- }
- mEndpointRegistered = false;
- mEndpointValid = false;
- }
-
- mProgramID = 0;
-
- mAAH_Sender.clear();
- mLastQueuedMediaTimePTSValid = false;
- mCurrentClockTransformValid = false;
- mPlayRateIsPaused = false;
-
- mTRTPVolume = 255;
-}
-
-status_t AAH_TXPlayer::setLooping(int loop) {
- return OK;
-}
-
-player_type AAH_TXPlayer::playerType() {
- return AAH_TX_PLAYER;
-}
-
-status_t AAH_TXPlayer::setParameter(int key, const Parcel &request) {
- return ERROR_UNSUPPORTED;
-}
-
-status_t AAH_TXPlayer::getParameter(int key, Parcel *reply) {
- return ERROR_UNSUPPORTED;
-}
-
-status_t AAH_TXPlayer::invoke(const Parcel& request, Parcel *reply) {
- return INVALID_OPERATION;
-}
-
-status_t AAH_TXPlayer::getMetadata(const media::Metadata::Filter& ids,
- Parcel* records) {
- using media::Metadata;
-
- Metadata metadata(records);
-
- metadata.appendBool(Metadata::kPauseAvailable, true);
- metadata.appendBool(Metadata::kSeekBackwardAvailable, false);
- metadata.appendBool(Metadata::kSeekForwardAvailable, false);
- metadata.appendBool(Metadata::kSeekAvailable, false);
-
- return OK;
-}
-
-status_t AAH_TXPlayer::setVolume(float leftVolume, float rightVolume) {
- if (leftVolume != rightVolume) {
- ALOGE("%s does not support per channel volume: %f, %f",
- __PRETTY_FUNCTION__, leftVolume, rightVolume);
- }
-
- float volume = clamp(leftVolume, 0.0f, 1.0f);
-
- Mutex::Autolock lock(mLock);
- mTRTPVolume = static_cast<uint8_t>((leftVolume * 255.0) + 0.5);
-
- return OK;
-}
-
-status_t AAH_TXPlayer::setAudioStreamType(audio_stream_type_t streamType) {
- return OK;
-}
-
-status_t AAH_TXPlayer::setRetransmitEndpoint(
- const struct sockaddr_in* endpoint) {
- Mutex::Autolock lock(mLock);
-
- if (NULL == endpoint)
- return BAD_VALUE;
-
- // Once the endpoint has been registered, it may not be changed.
- if (mEndpointRegistered)
- return INVALID_OPERATION;
-
- mEndpoint.addr = endpoint->sin_addr.s_addr;
- mEndpoint.port = endpoint->sin_port;
- mEndpointValid = true;
-
- return OK;
-}
-
-void AAH_TXPlayer::notifyListener_l(int msg, int ext1, int ext2) {
- sendEvent(msg, ext1, ext2);
-}
-
-bool AAH_TXPlayer::getBitrate_l(int64_t *bitrate) {
- off64_t size;
- if (mDurationUs >= 0 &&
- mCachedSource != NULL &&
- mCachedSource->getSize(&size) == OK) {
- *bitrate = size * 8000000ll / mDurationUs; // in bits/sec
- return true;
- }
-
- if (mBitrate >= 0) {
- *bitrate = mBitrate;
- return true;
- }
-
- *bitrate = 0;
-
- return false;
-}
-
-// Returns true iff cached duration is available/applicable.
-bool AAH_TXPlayer::getCachedDuration_l(int64_t *durationUs, bool *eos) {
- int64_t bitrate;
-
- if (mCachedSource != NULL && getBitrate_l(&bitrate)) {
- status_t finalStatus;
- size_t cachedDataRemaining = mCachedSource->approxDataRemaining(
- &finalStatus);
- *durationUs = cachedDataRemaining * 8000000ll / bitrate;
- *eos = (finalStatus != OK);
- return true;
- }
-
- return false;
-}
-
-void AAH_TXPlayer::ensureCacheIsFetching_l() {
- if (mCachedSource != NULL) {
- mCachedSource->resumeFetchingIfNecessary();
- }
-}
-
-void AAH_TXPlayer::postBufferingEvent_l() {
- if (mBufferingEventPending) {
- return;
- }
- mBufferingEventPending = true;
- mQueue.postEventWithDelay(mBufferingEvent, 1000000ll);
-}
-
-void AAH_TXPlayer::postPumpAudioEvent_l(int64_t delayUs) {
- if (mPumpAudioEventPending) {
- return;
- }
- mPumpAudioEventPending = true;
- mQueue.postEventWithDelay(mPumpAudioEvent, delayUs < 0 ? 10000 : delayUs);
-}
-
-void AAH_TXPlayer::onBufferingUpdate() {
- Mutex::Autolock autoLock(mLock);
- if (!mBufferingEventPending) {
- return;
- }
- mBufferingEventPending = false;
-
- if (mCachedSource != NULL) {
- status_t finalStatus;
- size_t cachedDataRemaining = mCachedSource->approxDataRemaining(
- &finalStatus);
- bool eos = (finalStatus != OK);
-
- if (eos) {
- if (finalStatus == ERROR_END_OF_STREAM) {
- notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
- }
- if (mFlags & PREPARING) {
- ALOGV("cache has reached EOS, prepare is done.");
- finishAsyncPrepare_l();
- }
- } else {
- int64_t bitrate;
- if (getBitrate_l(&bitrate)) {
- size_t cachedSize = mCachedSource->cachedSize();
- int64_t cachedDurationUs = cachedSize * 8000000ll / bitrate;
-
- int percentage = (100.0 * (double) cachedDurationUs)
- / mDurationUs;
- if (percentage > 100) {
- percentage = 100;
- }
-
- notifyListener_l(MEDIA_BUFFERING_UPDATE, percentage);
- } else {
- // We don't know the bitrate of the stream, use absolute size
- // limits to maintain the cache.
-
- if ((mFlags & PLAYING) &&
- !eos &&
- (cachedDataRemaining < kLowWaterMarkBytes)) {
- ALOGI("cache is running low (< %d) , pausing.",
- kLowWaterMarkBytes);
- mFlags |= CACHE_UNDERRUN;
- pause_l();
- ensureCacheIsFetching_l();
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
- } else if (eos || cachedDataRemaining > kHighWaterMarkBytes) {
- if (mFlags & CACHE_UNDERRUN) {
- ALOGI("cache has filled up (> %d), resuming.",
- kHighWaterMarkBytes);
- mFlags &= ~CACHE_UNDERRUN;
- play_l();
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
- } else if (mFlags & PREPARING) {
- ALOGV("cache has filled up (> %d), prepare is done",
- kHighWaterMarkBytes);
- finishAsyncPrepare_l();
- }
- }
- }
- }
- }
-
- int64_t cachedDurationUs;
- bool eos;
- if (getCachedDuration_l(&cachedDurationUs, &eos)) {
- ALOGV("cachedDurationUs = %.2f secs, eos=%d",
- cachedDurationUs / 1E6, eos);
-
- if ((mFlags & PLAYING) &&
- !eos &&
- (cachedDurationUs < kLowWaterMarkUs)) {
- ALOGI("cache is running low (%.2f secs) , pausing.",
- cachedDurationUs / 1E6);
- mFlags |= CACHE_UNDERRUN;
- pause_l();
- ensureCacheIsFetching_l();
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
- } else if (eos || cachedDurationUs > kHighWaterMarkUs) {
- if (mFlags & CACHE_UNDERRUN) {
- ALOGI("cache has filled up (%.2f secs), resuming.",
- cachedDurationUs / 1E6);
- mFlags &= ~CACHE_UNDERRUN;
- play_l();
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
- } else if (mFlags & PREPARING) {
- ALOGV("cache has filled up (%.2f secs), prepare is done",
- cachedDurationUs / 1E6);
- finishAsyncPrepare_l();
- }
- }
- }
-
- postBufferingEvent_l();
-}
-
-void AAH_TXPlayer::onPumpAudio() {
- while (true) {
- Mutex::Autolock autoLock(mLock);
- // If this flag is clear, its because someone has externally canceled
- // this pump operation (probably because we a resetting/shutting down).
- // Get out immediately, do not reschedule ourselves.
- if (!mPumpAudioEventPending) {
- return;
- }
-
- // Start by checking if there is still work to be doing. If we have
- // never queued a payload (so we don't know what the last queued PTS is)
- // or we have never established a MediaTime->CommonTime transformation,
- // then we have work to do (one time through this loop should establish
- // both). Otherwise, we want to keep a fixed amt of presentation time
- // worth of data buffered. If we cannot get common time (service is
- // unavailable, or common time is undefined)) then we don't have a lot
- // of good options here. For now, signal an error up to the app level
- // and shut down the transmission pump.
- int64_t commonTimeNow;
- if (OK != mCCHelper.getCommonTime(&commonTimeNow)) {
- // Failed to get common time; either the service is down or common
- // time is not synced. Raise an error and shutdown the player.
- ALOGE("*** Cannot pump audio, unable to fetch common time."
- " Shutting down.");
- notifyListener_l(MEDIA_ERROR, MEDIA_ERROR_UNKNOWN, UNKNOWN_ERROR);
- mPumpAudioEventPending = false;
- break;
- }
-
- if (mCurrentClockTransformValid && mLastQueuedMediaTimePTSValid) {
- int64_t mediaTimeNow;
- bool conversionResult = mCurrentClockTransform.doReverseTransform(
- commonTimeNow,
- &mediaTimeNow);
- CHECK(conversionResult);
-
- if ((mediaTimeNow +
- kAAHBufferTimeUs -
- mLastQueuedMediaTimePTS) <= 0) {
- break;
- }
- }
-
- MediaSource::ReadOptions options;
- if (mIsSeeking) {
- options.setSeekTo(mSeekTimeUs);
- }
-
- MediaBuffer* mediaBuffer;
- status_t err = mAudioSource->read(&mediaBuffer, &options);
- if (err != NO_ERROR) {
- if (err == ERROR_END_OF_STREAM) {
- ALOGI("*** %s reached end of stream", __PRETTY_FUNCTION__);
- notifyListener_l(MEDIA_BUFFERING_UPDATE, 100);
- notifyListener_l(MEDIA_PLAYBACK_COMPLETE);
- pause_l(false);
- sendEOS_l();
- } else {
- ALOGE("*** %s read failed err=%d", __PRETTY_FUNCTION__, err);
- }
- return;
- }
-
- if (mIsSeeking) {
- mIsSeeking = false;
- notifyListener_l(MEDIA_SEEK_COMPLETE);
- }
-
- uint8_t* data = (static_cast<uint8_t*>(mediaBuffer->data()) +
- mediaBuffer->range_offset());
- ALOGV("*** %s got media buffer data=[%02hhx %02hhx %02hhx %02hhx]"
- " offset=%d length=%d", __PRETTY_FUNCTION__,
- data[0], data[1], data[2], data[3],
- mediaBuffer->range_offset(), mediaBuffer->range_length());
-
- int64_t mediaTimeUs;
- CHECK(mediaBuffer->meta_data()->findInt64(kKeyTime, &mediaTimeUs));
- ALOGV("*** timeUs=%lld", mediaTimeUs);
-
- if (!mCurrentClockTransformValid) {
- if (OK == mCCHelper.getCommonTime(&commonTimeNow)) {
- mCurrentClockTransform.a_zero = mediaTimeUs;
- mCurrentClockTransform.b_zero = commonTimeNow +
- kAAHStartupLeadTimeUs;
- mCurrentClockTransform.a_to_b_numer = 1;
- mCurrentClockTransform.a_to_b_denom = mPlayRateIsPaused ? 0 : 1;
- mCurrentClockTransformValid = true;
- } else {
- // Failed to get common time; either the service is down or
- // common time is not synced. Raise an error and shutdown the
- // player.
- ALOGE("*** Cannot begin transmission, unable to fetch common"
- " time. Dropping sample with pts=%lld", mediaTimeUs);
- notifyListener_l(MEDIA_ERROR,
- MEDIA_ERROR_UNKNOWN,
- UNKNOWN_ERROR);
- mPumpAudioEventPending = false;
- break;
- }
- }
-
- ALOGV("*** transmitting packet with pts=%lld", mediaTimeUs);
-
- sp<TRTPAudioPacket> packet = new TRTPAudioPacket();
- packet->setPTS(mediaTimeUs);
- packet->setSubstreamID(1);
-
- packet->setCodecType(mAudioCodec);
- packet->setVolume(mTRTPVolume);
- // TODO : introduce a throttle for this so we can control the
- // frequency with which transforms get sent.
- packet->setClockTransform(mCurrentClockTransform);
- packet->setAccessUnitData(data, mediaBuffer->range_length());
-
- // TODO : while its pretty much universally true that audio ES payloads
- // are all RAPs across all codecs, it might be a good idea to throttle
- // the frequency with which we send codec out of band data to the RXers.
- // If/when we do, we need to flag only those payloads which have
- // required out of band data attached to them as RAPs.
- packet->setRandomAccessPoint(true);
-
- if (mAudioCodecData && mAudioCodecDataSize) {
- packet->setAuxData(mAudioCodecData, mAudioCodecDataSize);
- }
-
- queuePacketToSender_l(packet);
- mediaBuffer->release();
-
- mLastQueuedMediaTimePTSValid = true;
- mLastQueuedMediaTimePTS = mediaTimeUs;
- }
-
- { // Explicit scope for the autolock pattern.
- Mutex::Autolock autoLock(mLock);
-
- // If someone externally has cleared this flag, its because we should be
- // shutting down. Do not reschedule ourselves.
- if (!mPumpAudioEventPending) {
- return;
- }
-
- // Looks like no one canceled us explicitly. Clear our flag and post a
- // new event to ourselves.
- mPumpAudioEventPending = false;
- postPumpAudioEvent_l(10000);
- }
-}
-
-void AAH_TXPlayer::queuePacketToSender_l(const sp<TRTPPacket>& packet) {
- if (mAAH_Sender == NULL) {
- return;
- }
-
- sp<AMessage> message = new AMessage(AAH_TXSender::kWhatSendPacket,
- mAAH_Sender->handlerID());
-
- {
- Mutex::Autolock lock(mEndpointLock);
- if (!mEndpointValid) {
- return;
- }
-
- message->setInt32(AAH_TXSender::kSendPacketIPAddr, mEndpoint.addr);
- message->setInt32(AAH_TXSender::kSendPacketPort, mEndpoint.port);
- }
-
- packet->setProgramID(mProgramID);
- packet->setExpireTime(systemTime() + kAAHRetryKeepAroundTimeNs);
- packet->pack();
-
- message->setObject(AAH_TXSender::kSendPacketTRTPPacket, packet);
-
- message->post();
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_tx_player.h b/media/libaah_rtp/aah_tx_player.h
deleted file mode 100644
index 2e4b1f7..0000000
--- a/media/libaah_rtp/aah_tx_player.h
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AAH_TX_PLAYER_H__
-#define __AAH_TX_PLAYER_H__
-
-#include <common_time/cc_helper.h>
-#include <libstagefright/include/HTTPBase.h>
-#include <libstagefright/include/NuCachedSource2.h>
-#include <libstagefright/include/TimedEventQueue.h>
-#include <media/MediaPlayerInterface.h>
-#include <media/stagefright/MediaExtractor.h>
-#include <media/stagefright/MediaSource.h>
-#include <utils/LinearTransform.h>
-#include <utils/String8.h>
-#include <utils/threads.h>
-
-#include "aah_tx_sender.h"
-
-namespace android {
-
-class AAH_TXPlayer : public MediaPlayerHWInterface {
- public:
- AAH_TXPlayer();
-
- virtual status_t initCheck();
- virtual status_t setDataSource(const char *url,
- const KeyedVector<String8, String8>*
- headers);
- virtual status_t setDataSource(int fd, int64_t offset, int64_t length);
- virtual status_t setVideoSurface(const sp<Surface>& surface);
- virtual status_t setVideoSurfaceTexture(const sp<ISurfaceTexture>&
- surfaceTexture);
- virtual status_t prepare();
- virtual status_t prepareAsync();
- virtual status_t start();
- virtual status_t stop();
- virtual status_t pause();
- virtual bool isPlaying();
- virtual status_t seekTo(int msec);
- virtual status_t getCurrentPosition(int *msec);
- virtual status_t getDuration(int *msec);
- virtual status_t reset();
- virtual status_t setLooping(int loop);
- virtual player_type playerType();
- virtual status_t setParameter(int key, const Parcel &request);
- virtual status_t getParameter(int key, Parcel *reply);
- virtual status_t invoke(const Parcel& request, Parcel *reply);
- virtual status_t getMetadata(const media::Metadata::Filter& ids,
- Parcel* records);
- virtual status_t setVolume(float leftVolume, float rightVolume);
- virtual status_t setAudioStreamType(audio_stream_type_t streamType);
- virtual status_t setRetransmitEndpoint(
- const struct sockaddr_in* endpoint);
-
- static const int64_t kAAHRetryKeepAroundTimeNs;
-
- protected:
- virtual ~AAH_TXPlayer();
-
- private:
- friend struct AwesomeEvent;
-
- enum {
- PLAYING = 1,
- PREPARING = 8,
- PREPARED = 16,
- PREPARE_CANCELLED = 64,
- CACHE_UNDERRUN = 128,
-
- // We are basically done preparing but are currently buffering
- // sufficient data to begin playback and finish the preparation
- // phase for good.
- PREPARING_CONNECTED = 2048,
-
- INCOGNITO = 32768,
- };
-
- status_t setDataSource_l(const char *url,
- const KeyedVector<String8, String8> *headers);
- status_t setDataSource_l(const sp<MediaExtractor>& extractor);
- status_t finishSetDataSource_l();
- status_t prepareAsync_l();
- void onPrepareAsyncEvent();
- void finishAsyncPrepare_l();
- void abortPrepare(status_t err);
- status_t play_l();
- status_t pause_l(bool doClockUpdate = true);
- status_t seekTo_l(int64_t timeUs);
- void updateClockTransform_l(bool pause);
- void sendEOS_l();
- void cancelPlayerEvents(bool keepBufferingGoing = false);
- void reset_l();
- void notifyListener_l(int msg, int ext1 = 0, int ext2 = 0);
- bool getBitrate_l(int64_t* bitrate);
- status_t getDuration_l(int* msec);
- bool getCachedDuration_l(int64_t* durationUs, bool* eos);
- void ensureCacheIsFetching_l();
- void postBufferingEvent_l();
- void postPumpAudioEvent_l(int64_t delayUs);
- void onBufferingUpdate();
- void onPumpAudio();
- void queuePacketToSender_l(const sp<TRTPPacket>& packet);
-
- Mutex mLock;
-
- TimedEventQueue mQueue;
- bool mQueueStarted;
-
- sp<TimedEventQueue::Event> mBufferingEvent;
- bool mBufferingEventPending;
-
- uint32_t mFlags;
- uint32_t mExtractorFlags;
-
- String8 mUri;
- KeyedVector<String8, String8> mUriHeaders;
-
- sp<DataSource> mFileSource;
-
- sp<TimedEventQueue::Event> mAsyncPrepareEvent;
- Condition mPreparedCondition;
- status_t mPrepareResult;
-
- bool mIsSeeking;
- int64_t mSeekTimeUs;
-
- sp<TimedEventQueue::Event> mPumpAudioEvent;
- bool mPumpAudioEventPending;
-
- sp<HTTPBase> mConnectingDataSource;
- sp<NuCachedSource2> mCachedSource;
-
- sp<MediaSource> mAudioSource;
- TRTPAudioPacket::TRTPAudioCodecType mAudioCodec;
- sp<MetaData> mAudioFormat;
- uint8_t* mAudioCodecData;
- size_t mAudioCodecDataSize;
-
- int64_t mDurationUs;
- int64_t mBitrate;
-
- sp<AAH_TXSender> mAAH_Sender;
- LinearTransform mCurrentClockTransform;
- bool mCurrentClockTransformValid;
- int64_t mLastQueuedMediaTimePTS;
- bool mLastQueuedMediaTimePTSValid;
- bool mPlayRateIsPaused;
- CCHelper mCCHelper;
-
- Mutex mEndpointLock;
- AAH_TXSender::Endpoint mEndpoint;
- bool mEndpointValid;
- bool mEndpointRegistered;
- uint16_t mProgramID;
- uint8_t mTRTPVolume;
-
- DISALLOW_EVIL_CONSTRUCTORS(AAH_TXPlayer);
-};
-
-} // namespace android
-
-#endif // __AAH_TX_PLAYER_H__
diff --git a/media/libaah_rtp/aah_tx_sender.cpp b/media/libaah_rtp/aah_tx_sender.cpp
deleted file mode 100644
index 08e32d2..0000000
--- a/media/libaah_rtp/aah_tx_sender.cpp
+++ /dev/null
@@ -1,603 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-#include <media/stagefright/foundation/ADebug.h>
-
-#include <netinet/in.h>
-#include <poll.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <unistd.h>
-
-#include <media/stagefright/foundation/AMessage.h>
-#include <utils/misc.h>
-
-#include "aah_tx_player.h"
-#include "aah_tx_sender.h"
-
-namespace android {
-
-const char* AAH_TXSender::kSendPacketIPAddr = "ipaddr";
-const char* AAH_TXSender::kSendPacketPort = "port";
-const char* AAH_TXSender::kSendPacketTRTPPacket = "trtp";
-
-const int AAH_TXSender::kRetryTrimIntervalUs = 100000;
-const int AAH_TXSender::kHeartbeatIntervalUs = 1000000;
-const int AAH_TXSender::kRetryBufferCapacity = 100;
-const nsecs_t AAH_TXSender::kHeartbeatTimeout = 600ull * 1000000000ull;
-
-Mutex AAH_TXSender::sLock;
-wp<AAH_TXSender> AAH_TXSender::sInstance;
-uint32_t AAH_TXSender::sNextEpoch;
-bool AAH_TXSender::sNextEpochValid = false;
-
-AAH_TXSender::AAH_TXSender() : mSocket(-1) {
- mLastSentPacketTime = systemTime();
-}
-
-sp<AAH_TXSender> AAH_TXSender::GetInstance() {
- Mutex::Autolock autoLock(sLock);
-
- sp<AAH_TXSender> sender = sInstance.promote();
-
- if (sender == NULL) {
- sender = new AAH_TXSender();
- if (sender == NULL) {
- return NULL;
- }
-
- sender->mLooper = new ALooper();
- if (sender->mLooper == NULL) {
- return NULL;
- }
-
- sender->mReflector = new AHandlerReflector<AAH_TXSender>(sender.get());
- if (sender->mReflector == NULL) {
- return NULL;
- }
-
- sender->mSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (sender->mSocket == -1) {
- ALOGW("%s unable to create socket", __PRETTY_FUNCTION__);
- return NULL;
- }
-
- struct sockaddr_in bind_addr;
- memset(&bind_addr, 0, sizeof(bind_addr));
- bind_addr.sin_family = AF_INET;
- if (bind(sender->mSocket,
- reinterpret_cast<const sockaddr*>(&bind_addr),
- sizeof(bind_addr)) < 0) {
- ALOGW("%s unable to bind socket (errno %d)",
- __PRETTY_FUNCTION__, errno);
- return NULL;
- }
-
- sender->mRetryReceiver = new RetryReceiver(sender.get());
- if (sender->mRetryReceiver == NULL) {
- return NULL;
- }
-
- sender->mLooper->setName("AAH_TXSender");
- sender->mLooper->registerHandler(sender->mReflector);
- sender->mLooper->start(false, false, PRIORITY_AUDIO);
-
- if (sender->mRetryReceiver->run("AAH_TXSenderRetry", PRIORITY_AUDIO)
- != OK) {
- ALOGW("%s unable to start retry thread", __PRETTY_FUNCTION__);
- return NULL;
- }
-
- sInstance = sender;
- }
-
- return sender;
-}
-
-AAH_TXSender::~AAH_TXSender() {
- mLooper->stop();
- mLooper->unregisterHandler(mReflector->id());
-
- if (mRetryReceiver != NULL) {
- mRetryReceiver->requestExit();
- mRetryReceiver->mWakeupEvent.setEvent();
- if (mRetryReceiver->requestExitAndWait() != OK) {
- ALOGW("%s shutdown of retry receiver failed", __PRETTY_FUNCTION__);
- }
- mRetryReceiver->mSender = NULL;
- mRetryReceiver.clear();
- }
-
- if (mSocket != -1) {
- close(mSocket);
- }
-}
-
-// Return the next epoch number usable for a newly instantiated endpoint.
-uint32_t AAH_TXSender::getNextEpoch() {
- Mutex::Autolock autoLock(sLock);
-
- if (sNextEpochValid) {
- sNextEpoch = (sNextEpoch + 1) & TRTPPacket::kTRTPEpochMask;
- } else {
- sNextEpoch = ns2ms(systemTime()) & TRTPPacket::kTRTPEpochMask;
- sNextEpochValid = true;
- }
-
- return sNextEpoch;
-}
-
-// Notify the sender that a player has started sending to this endpoint.
-// Returns a program ID for use by the calling player.
-uint16_t AAH_TXSender::registerEndpoint(const Endpoint& endpoint) {
- Mutex::Autolock lock(mEndpointLock);
-
- EndpointState* eps = mEndpointMap.valueFor(endpoint);
- if (eps) {
- eps->playerRefCount++;
- } else {
- eps = new EndpointState(getNextEpoch());
- mEndpointMap.add(endpoint, eps);
- }
-
- // if this is the first registered endpoint, then send a message to start
- // trimming retry buffers and a message to start sending heartbeats.
- if (mEndpointMap.size() == 1) {
- sp<AMessage> trimMessage = new AMessage(kWhatTrimRetryBuffers,
- handlerID());
- trimMessage->post(kRetryTrimIntervalUs);
-
- sp<AMessage> heartbeatMessage = new AMessage(kWhatSendHeartbeats,
- handlerID());
- heartbeatMessage->post(kHeartbeatIntervalUs);
- }
-
- eps->nextProgramID++;
- return eps->nextProgramID;
-}
-
-// Notify the sender that a player has ceased sending to this endpoint.
-// An endpoint's state can not be deleted until all of the endpoint's
-// registered players have called unregisterEndpoint.
-void AAH_TXSender::unregisterEndpoint(const Endpoint& endpoint) {
- Mutex::Autolock lock(mEndpointLock);
-
- EndpointState* eps = mEndpointMap.valueFor(endpoint);
- if (eps) {
- eps->playerRefCount--;
- CHECK(eps->playerRefCount >= 0);
- }
-}
-
-void AAH_TXSender::onMessageReceived(const sp<AMessage>& msg) {
- switch (msg->what()) {
- case kWhatSendPacket:
- onSendPacket(msg);
- break;
-
- case kWhatTrimRetryBuffers:
- trimRetryBuffers();
- break;
-
- case kWhatSendHeartbeats:
- sendHeartbeats();
- break;
-
- default:
- TRESPASS();
- break;
- }
-}
-
-void AAH_TXSender::onSendPacket(const sp<AMessage>& msg) {
- sp<RefBase> obj;
- CHECK(msg->findObject(kSendPacketTRTPPacket, &obj));
- sp<TRTPPacket> packet = static_cast<TRTPPacket*>(obj.get());
-
- uint32_t ipAddr;
- CHECK(msg->findInt32(kSendPacketIPAddr,
- reinterpret_cast<int32_t*>(&ipAddr)));
-
- int32_t port32;
- CHECK(msg->findInt32(kSendPacketPort, &port32));
- uint16_t port = port32;
-
- Mutex::Autolock lock(mEndpointLock);
- doSendPacket_l(packet, Endpoint(ipAddr, port));
- mLastSentPacketTime = systemTime();
-}
-
-void AAH_TXSender::doSendPacket_l(const sp<TRTPPacket>& packet,
- const Endpoint& endpoint) {
- EndpointState* eps = mEndpointMap.valueFor(endpoint);
- if (!eps) {
- // the endpoint state has disappeared, so the player that sent this
- // packet must be dead.
- return;
- }
-
- // assign the packet's sequence number
- packet->setEpoch(eps->epoch);
- packet->setSeqNumber(eps->trtpSeqNumber++);
-
- // add the packet to the retry buffer
- RetryBuffer& retry = eps->retry;
- retry.push_back(packet);
-
- // send the packet
- struct sockaddr_in addr;
- memset(&addr, 0, sizeof(addr));
- addr.sin_family = AF_INET;
- addr.sin_addr.s_addr = endpoint.addr;
- addr.sin_port = endpoint.port;
-
- ssize_t result = sendto(mSocket,
- packet->getPacket(),
- packet->getPacketLen(),
- 0,
- (const struct sockaddr *) &addr,
- sizeof(addr));
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
-}
-
-void AAH_TXSender::trimRetryBuffers() {
- Mutex::Autolock lock(mEndpointLock);
-
- nsecs_t localTimeNow = systemTime();
-
- Vector<Endpoint> endpointsToRemove;
-
- for (size_t i = 0; i < mEndpointMap.size(); i++) {
- EndpointState* eps = mEndpointMap.editValueAt(i);
- RetryBuffer& retry = eps->retry;
-
- while (!retry.isEmpty()) {
- if (retry[0]->getExpireTime() < localTimeNow) {
- retry.pop_front();
- } else {
- break;
- }
- }
-
- if (retry.isEmpty() && eps->playerRefCount == 0) {
- endpointsToRemove.add(mEndpointMap.keyAt(i));
- }
- }
-
- // remove the state for any endpoints that are no longer in use
- for (size_t i = 0; i < endpointsToRemove.size(); i++) {
- Endpoint& e = endpointsToRemove.editItemAt(i);
- ALOGD("*** %s removing endpoint addr=%08x",
- __PRETTY_FUNCTION__, e.addr);
- size_t index = mEndpointMap.indexOfKey(e);
- delete mEndpointMap.valueAt(index);
- mEndpointMap.removeItemsAt(index);
- }
-
- // schedule the next trim
- if (mEndpointMap.size()) {
- sp<AMessage> trimMessage = new AMessage(kWhatTrimRetryBuffers,
- handlerID());
- trimMessage->post(kRetryTrimIntervalUs);
- }
-}
-
-void AAH_TXSender::sendHeartbeats() {
- Mutex::Autolock lock(mEndpointLock);
-
- if (shouldSendHeartbeats_l()) {
- for (size_t i = 0; i < mEndpointMap.size(); i++) {
- EndpointState* eps = mEndpointMap.editValueAt(i);
- const Endpoint& ep = mEndpointMap.keyAt(i);
-
- sp<TRTPControlPacket> packet = new TRTPControlPacket();
- packet->setCommandID(TRTPControlPacket::kCommandNop);
-
- packet->setExpireTime(systemTime() +
- AAH_TXPlayer::kAAHRetryKeepAroundTimeNs);
- packet->pack();
-
- doSendPacket_l(packet, ep);
- }
- }
-
- // schedule the next heartbeat
- if (mEndpointMap.size()) {
- sp<AMessage> heartbeatMessage = new AMessage(kWhatSendHeartbeats,
- handlerID());
- heartbeatMessage->post(kHeartbeatIntervalUs);
- }
-}
-
-bool AAH_TXSender::shouldSendHeartbeats_l() {
- // assert(holding endpoint lock)
- return (systemTime() < (mLastSentPacketTime + kHeartbeatTimeout));
-}
-
-// Receiver
-
-// initial 4-byte ID of a retry request packet
-const uint32_t AAH_TXSender::RetryReceiver::kRetryRequestID = 'Treq';
-
-// initial 4-byte ID of a retry NAK packet
-const uint32_t AAH_TXSender::RetryReceiver::kRetryNakID = 'Tnak';
-
-// initial 4-byte ID of a fast start request packet
-const uint32_t AAH_TXSender::RetryReceiver::kFastStartRequestID = 'Tfst';
-
-AAH_TXSender::RetryReceiver::RetryReceiver(AAH_TXSender* sender)
- : Thread(false),
- mSender(sender) {}
-
- AAH_TXSender::RetryReceiver::~RetryReceiver() {
- mWakeupEvent.clearPendingEvents();
- }
-
-// Returns true if val is within the interval bounded inclusively by
-// start and end. Also handles the case where there is a rollover of the
-// range between start and end.
-template <typename T>
-static inline bool withinIntervalWithRollover(T val, T start, T end) {
- return ((start <= end && val >= start && val <= end) ||
- (start > end && (val >= start || val <= end)));
-}
-
-bool AAH_TXSender::RetryReceiver::threadLoop() {
- struct pollfd pollFds[2];
- pollFds[0].fd = mSender->mSocket;
- pollFds[0].events = POLLIN;
- pollFds[0].revents = 0;
- pollFds[1].fd = mWakeupEvent.getWakeupHandle();
- pollFds[1].events = POLLIN;
- pollFds[1].revents = 0;
-
- int pollResult = poll(pollFds, NELEM(pollFds), -1);
- if (pollResult == -1) {
- ALOGE("%s poll failed", __PRETTY_FUNCTION__);
- return false;
- }
-
- if (exitPending()) {
- ALOGI("*** %s exiting", __PRETTY_FUNCTION__);
- return false;
- }
-
- if (pollFds[0].revents) {
- handleRetryRequest();
- }
-
- return true;
-}
-
-void AAH_TXSender::RetryReceiver::handleRetryRequest() {
- ALOGV("*** RX %s start", __PRETTY_FUNCTION__);
-
- RetryPacket request;
- struct sockaddr requestSrcAddr;
- socklen_t requestSrcAddrLen = sizeof(requestSrcAddr);
-
- ssize_t result = recvfrom(mSender->mSocket, &request, sizeof(request), 0,
- &requestSrcAddr, &requestSrcAddrLen);
- if (result == -1) {
- ALOGE("%s recvfrom failed, errno=%d", __PRETTY_FUNCTION__, errno);
- return;
- }
-
- if (static_cast<size_t>(result) < sizeof(RetryPacket)) {
- ALOGW("%s short packet received", __PRETTY_FUNCTION__);
- return;
- }
-
- uint32_t host_request_id = ntohl(request.id);
- if ((host_request_id != kRetryRequestID) &&
- (host_request_id != kFastStartRequestID)) {
- ALOGW("%s received retry request with bogus ID (%08x)",
- __PRETTY_FUNCTION__, host_request_id);
- return;
- }
-
- Endpoint endpoint(request.endpointIP, request.endpointPort);
-
- Mutex::Autolock lock(mSender->mEndpointLock);
-
- EndpointState* eps = mSender->mEndpointMap.valueFor(endpoint);
-
- if (eps == NULL || eps->retry.isEmpty()) {
- // we have no retry buffer or an empty retry buffer for this endpoint,
- // so NAK the entire request
- RetryPacket nak = request;
- nak.id = htonl(kRetryNakID);
- result = sendto(mSender->mSocket, &nak, sizeof(nak), 0,
- &requestSrcAddr, requestSrcAddrLen);
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
- return;
- }
-
- RetryBuffer& retry = eps->retry;
-
- uint16_t startSeq = ntohs(request.seqStart);
- uint16_t endSeq = ntohs(request.seqEnd);
-
- uint16_t retryFirstSeq = retry[0]->getSeqNumber();
- uint16_t retryLastSeq = retry[retry.size() - 1]->getSeqNumber();
-
- // If this is a fast start, then force the start of the retry to match the
- // start of the retransmit ring buffer (unless the end of the retransmit
- // ring buffer is already past the point of fast start)
- if ((host_request_id == kFastStartRequestID) &&
- !((startSeq - retryFirstSeq) & 0x8000)) {
- startSeq = retryFirstSeq;
- }
-
- int startIndex;
- if (withinIntervalWithRollover(startSeq, retryFirstSeq, retryLastSeq)) {
- startIndex = static_cast<uint16_t>(startSeq - retryFirstSeq);
- } else {
- startIndex = -1;
- }
-
- int endIndex;
- if (withinIntervalWithRollover(endSeq, retryFirstSeq, retryLastSeq)) {
- endIndex = static_cast<uint16_t>(endSeq - retryFirstSeq);
- } else {
- endIndex = -1;
- }
-
- if (startIndex == -1 && endIndex == -1) {
- // no part of the request range is found in the retry buffer
- RetryPacket nak = request;
- nak.id = htonl(kRetryNakID);
- result = sendto(mSender->mSocket, &nak, sizeof(nak), 0,
- &requestSrcAddr, requestSrcAddrLen);
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
- return;
- }
-
- if (startIndex == -1) {
- // NAK a subrange at the front of the request range
- RetryPacket nak = request;
- nak.id = htonl(kRetryNakID);
- nak.seqEnd = htons(retryFirstSeq - 1);
- result = sendto(mSender->mSocket, &nak, sizeof(nak), 0,
- &requestSrcAddr, requestSrcAddrLen);
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
-
- startIndex = 0;
- } else if (endIndex == -1) {
- // NAK a subrange at the back of the request range
- RetryPacket nak = request;
- nak.id = htonl(kRetryNakID);
- nak.seqStart = htons(retryLastSeq + 1);
- result = sendto(mSender->mSocket, &nak, sizeof(nak), 0,
- &requestSrcAddr, requestSrcAddrLen);
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
-
- endIndex = retry.size() - 1;
- }
-
- // send the retry packets
- for (int i = startIndex; i <= endIndex; i++) {
- const sp<TRTPPacket>& replyPacket = retry[i];
-
- result = sendto(mSender->mSocket,
- replyPacket->getPacket(),
- replyPacket->getPacketLen(),
- 0,
- &requestSrcAddr,
- requestSrcAddrLen);
-
- if (result == -1) {
- ALOGW("%s sendto failed", __PRETTY_FUNCTION__);
- }
- }
-}
-
-// Endpoint
-
-AAH_TXSender::Endpoint::Endpoint()
- : addr(0)
- , port(0) { }
-
-AAH_TXSender::Endpoint::Endpoint(uint32_t a, uint16_t p)
- : addr(a)
- , port(p) {}
-
-bool AAH_TXSender::Endpoint::operator<(const Endpoint& other) const {
- return ((addr < other.addr) ||
- (addr == other.addr && port < other.port));
-}
-
-// EndpointState
-
-AAH_TXSender::EndpointState::EndpointState(uint32_t _epoch)
- : retry(kRetryBufferCapacity)
- , playerRefCount(1)
- , trtpSeqNumber(0)
- , nextProgramID(0)
- , epoch(_epoch) { }
-
-// CircularBuffer
-
-template <typename T>
-CircularBuffer<T>::CircularBuffer(size_t capacity)
- : mCapacity(capacity)
- , mHead(0)
- , mTail(0)
- , mFillCount(0) {
- mBuffer = new T[capacity];
-}
-
-template <typename T>
-CircularBuffer<T>::~CircularBuffer() {
- delete [] mBuffer;
-}
-
-template <typename T>
-void CircularBuffer<T>::push_back(const T& item) {
- if (this->isFull()) {
- this->pop_front();
- }
- mBuffer[mHead] = item;
- mHead = (mHead + 1) % mCapacity;
- mFillCount++;
-}
-
-template <typename T>
-void CircularBuffer<T>::pop_front() {
- CHECK(!isEmpty());
- mBuffer[mTail] = T();
- mTail = (mTail + 1) % mCapacity;
- mFillCount--;
-}
-
-template <typename T>
-size_t CircularBuffer<T>::size() const {
- return mFillCount;
-}
-
-template <typename T>
-bool CircularBuffer<T>::isFull() const {
- return (mFillCount == mCapacity);
-}
-
-template <typename T>
-bool CircularBuffer<T>::isEmpty() const {
- return (mFillCount == 0);
-}
-
-template <typename T>
-const T& CircularBuffer<T>::itemAt(size_t index) const {
- CHECK(index < mFillCount);
- return mBuffer[(mTail + index) % mCapacity];
-}
-
-template <typename T>
-const T& CircularBuffer<T>::operator[](size_t index) const {
- return itemAt(index);
-}
-
-} // namespace android
diff --git a/media/libaah_rtp/aah_tx_sender.h b/media/libaah_rtp/aah_tx_sender.h
deleted file mode 100644
index 74206c4..0000000
--- a/media/libaah_rtp/aah_tx_sender.h
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __AAH_TX_SENDER_H__
-#define __AAH_TX_SENDER_H__
-
-#include <media/stagefright/foundation/ALooper.h>
-#include <media/stagefright/foundation/AHandlerReflector.h>
-#include <utils/RefBase.h>
-#include <utils/threads.h>
-
-#include "aah_tx_packet.h"
-#include "pipe_event.h"
-
-namespace android {
-
-template <typename T> class CircularBuffer {
- public:
- CircularBuffer(size_t capacity);
- ~CircularBuffer();
- void push_back(const T& item);;
- void pop_front();
- size_t size() const;
- bool isFull() const;
- bool isEmpty() const;
- const T& itemAt(size_t index) const;
- const T& operator[](size_t index) const;
-
- private:
- T* mBuffer;
- size_t mCapacity;
- size_t mHead;
- size_t mTail;
- size_t mFillCount;
-
- DISALLOW_EVIL_CONSTRUCTORS(CircularBuffer);
-};
-
-class AAH_TXSender : public virtual RefBase {
- public:
- ~AAH_TXSender();
-
- static sp<AAH_TXSender> GetInstance();
-
- ALooper::handler_id handlerID() { return mReflector->id(); }
-
- // an IP address and port
- struct Endpoint {
- Endpoint();
- Endpoint(uint32_t a, uint16_t p);
- bool operator<(const Endpoint& other) const;
-
- uint32_t addr;
- uint16_t port;
- };
-
- uint16_t registerEndpoint(const Endpoint& endpoint);
- void unregisterEndpoint(const Endpoint& endpoint);
-
- enum {
- kWhatSendPacket,
- kWhatTrimRetryBuffers,
- kWhatSendHeartbeats,
- };
-
- // fields for SendPacket messages
- static const char* kSendPacketIPAddr;
- static const char* kSendPacketPort;
- static const char* kSendPacketTRTPPacket;
-
- private:
- AAH_TXSender();
-
- static Mutex sLock;
- static wp<AAH_TXSender> sInstance;
- static uint32_t sNextEpoch;
- static bool sNextEpochValid;
-
- static uint32_t getNextEpoch();
-
- typedef CircularBuffer<sp<TRTPPacket> > RetryBuffer;
-
- // state maintained on a per-endpoint basis
- struct EndpointState {
- EndpointState(uint32_t epoch);
- RetryBuffer retry;
- int playerRefCount;
- uint16_t trtpSeqNumber;
- uint16_t nextProgramID;
- uint32_t epoch;
- };
-
- friend class AHandlerReflector<AAH_TXSender>;
- void onMessageReceived(const sp<AMessage>& msg);
- void onSendPacket(const sp<AMessage>& msg);
- void doSendPacket_l(const sp<TRTPPacket>& packet,
- const Endpoint& endpoint);
- void trimRetryBuffers();
- void sendHeartbeats();
- bool shouldSendHeartbeats_l();
-
- sp<ALooper> mLooper;
- sp<AHandlerReflector<AAH_TXSender> > mReflector;
-
- int mSocket;
- nsecs_t mLastSentPacketTime;
-
- DefaultKeyedVector<Endpoint, EndpointState*> mEndpointMap;
- Mutex mEndpointLock;
-
- static const int kRetryTrimIntervalUs;
- static const int kHeartbeatIntervalUs;
- static const int kRetryBufferCapacity;
- static const nsecs_t kHeartbeatTimeout;
-
- class RetryReceiver : public Thread {
- private:
- friend class AAH_TXSender;
-
- RetryReceiver(AAH_TXSender* sender);
- virtual ~RetryReceiver();
- virtual bool threadLoop();
- void handleRetryRequest();
-
- static const int kMaxReceiverPacketLen;
- static const uint32_t kRetryRequestID;
- static const uint32_t kFastStartRequestID;
- static const uint32_t kRetryNakID;
-
- AAH_TXSender* mSender;
- PipeEvent mWakeupEvent;
- };
-
- sp<RetryReceiver> mRetryReceiver;
-
- DISALLOW_EVIL_CONSTRUCTORS(AAH_TXSender);
-};
-
-struct RetryPacket {
- uint32_t id;
- uint32_t endpointIP;
- uint16_t endpointPort;
- uint16_t seqStart;
- uint16_t seqEnd;
-} __attribute__((packed));
-
-} // namespace android
-
-#endif // __AAH_TX_SENDER_H__
diff --git a/media/libaah_rtp/pipe_event.cpp b/media/libaah_rtp/pipe_event.cpp
deleted file mode 100644
index b8e6960..0000000
--- a/media/libaah_rtp/pipe_event.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_TAG "LibAAH_RTP"
-#include <utils/Log.h>
-
-#include <errno.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <unistd.h>
-
-#include "pipe_event.h"
-
-namespace android {
-
-PipeEvent::PipeEvent() {
- pipe_[0] = -1;
- pipe_[1] = -1;
-
- // Create the pipe.
- if (pipe(pipe_) >= 0) {
- // Set non-blocking mode on the read side of the pipe so we can
- // easily drain it whenever we wakeup.
- fcntl(pipe_[0], F_SETFL, O_NONBLOCK);
- } else {
- ALOGE("Failed to create pipe event %d %d %d",
- pipe_[0], pipe_[1], errno);
- pipe_[0] = -1;
- pipe_[1] = -1;
- }
-}
-
-PipeEvent::~PipeEvent() {
- if (pipe_[0] >= 0) {
- close(pipe_[0]);
- }
-
- if (pipe_[1] >= 0) {
- close(pipe_[1]);
- }
-}
-
-void PipeEvent::clearPendingEvents() {
- char drain_buffer[16];
- while (read(pipe_[0], drain_buffer, sizeof(drain_buffer)) > 0) {
- // No body.
- }
-}
-
-bool PipeEvent::wait(int timeout) {
- struct pollfd wait_fd;
-
- wait_fd.fd = getWakeupHandle();
- wait_fd.events = POLLIN;
- wait_fd.revents = 0;
-
- int res = poll(&wait_fd, 1, timeout);
-
- if (res < 0) {
- ALOGE("Wait error in PipeEvent; sleeping to prevent overload!");
- usleep(1000);
- }
-
- return (res > 0);
-}
-
-void PipeEvent::setEvent() {
- char foo = 'q';
- write(pipe_[1], &foo, 1);
-}
-
-} // namespace android
-
diff --git a/media/libaah_rtp/pipe_event.h b/media/libaah_rtp/pipe_event.h
deleted file mode 100644
index e53b0fd..0000000
--- a/media/libaah_rtp/pipe_event.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef __PIPE_EVENT_H__
-#define __PIPE_EVENT_H__
-
-#include <media/stagefright/foundation/ABase.h>
-
-namespace android {
-
-class PipeEvent {
- public:
- PipeEvent();
- ~PipeEvent();
-
- bool initCheck() const {
- return ((pipe_[0] >= 0) && (pipe_[1] >= 0));
- }
-
- int getWakeupHandle() const { return pipe_[0]; }
-
- // block until the event fires; returns true if the event fired and false if
- // the wait timed out. Timeout is expressed in milliseconds; negative
- // values mean wait forever.
- bool wait(int timeout = -1);
-
- void clearPendingEvents();
- void setEvent();
-
- private:
- int pipe_[2];
-
- DISALLOW_EVIL_CONSTRUCTORS(PipeEvent);
-};
-
-} // namespace android
-
-#endif // __PIPE_EVENT_H__
diff --git a/media/libeffects/data/audio_effects.conf b/media/libeffects/data/audio_effects.conf
index d681c69..93f27cb 100644
--- a/media/libeffects/data/audio_effects.conf
+++ b/media/libeffects/data/audio_effects.conf
@@ -15,14 +15,18 @@ libraries {
visualizer {
path /system/lib/soundfx/libvisualizer.so
}
- pre_processing {
- path /system/lib/soundfx/libaudiopreprocessing.so
- }
downmix {
path /system/lib/soundfx/libdownmix.so
}
}
+# Default pre-processing library. Add to audio_effect.conf "libraries" section if
+# audio HAL implements support for default software audio pre-processing effects
+#
+# pre_processing {
+# path /system/lib/soundfx/libaudiopreprocessing.so
+# }
+
# list of effects to load. Each effect element must contain a "library" and a "uuid" element.
# The value of the "library" element must correspond to the name of one library element in the
# "libraries" element.
@@ -79,19 +83,24 @@ effects {
library downmix
uuid 93f04452-e4fe-41cc-91f9-e475b6d1d69f
}
- agc {
- library pre_processing
- uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b
- }
- aec {
- library pre_processing
- uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b
- }
- ns {
- library pre_processing
- uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b
- }
}
+
+# Default pre-processing effects. Add to audio_effect.conf "effects" section if
+# audio HAL implements support for them.
+#
+# agc {
+# library pre_processing
+# uuid aa8130e0-66fc-11e0-bad0-0002a5d5c51b
+# }
+# aec {
+# library pre_processing
+# uuid bb392ec0-8d4d-11e0-a896-0002a5d5c51b
+# }
+# ns {
+# library pre_processing
+# uuid c06c8400-8e06-11e0-9cb6-0002a5d5c51b
+# }
+
# Audio preprocessor configurations.
# The pre processor configuration consists in a list of elements each describing
# pre processor settings for a given input source. Valid input source names are:
diff --git a/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index 59cd9e3..f158929 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -214,7 +214,7 @@ int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescriptor)
while (gCurLib) {
if (gCurEffect) {
if (index == gCurEffectIdx) {
- memcpy(pDescriptor, gCurEffect->object, sizeof(effect_descriptor_t));
+ *pDescriptor = *(effect_descriptor_t *)gCurEffect->object;
ret = 0;
break;
} else {
@@ -251,7 +251,7 @@ int EffectGetDescriptor(const effect_uuid_t *uuid, effect_descriptor_t *pDescrip
pthread_mutex_lock(&gLibLock);
ret = findEffect(NULL, uuid, &l, &d);
if (ret == 0) {
- memcpy(pDescriptor, d, sizeof(effect_descriptor_t));
+ *pDescriptor = *d;
}
pthread_mutex_unlock(&gLibLock);
return ret;
diff --git a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
index 3b3c07c..32c4ce0 100644
--- a/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
+++ b/media/libeffects/lvm/lib/Bass/src/LVDBE_Init.c
@@ -232,6 +232,10 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
pInstance->pData->AGCInstance.AGC_Gain = pInstance->pData->AGCInstance.AGC_MaxGain;
/* Default to the bass boost setting */
+ // initialize the mixer with some fixes values since otherwise LVDBE_SetVolume ends up
+ // reading uninitialized data
+ pMixer_Instance = &pInstance->pData->BypassVolume;
+ LVC_Mixer_Init(&pMixer_Instance->MixerStream[0],0x00007FFF,0x00007FFF);
/*
* Initialise the volume
@@ -242,7 +246,6 @@ LVDBE_ReturnStatus_en LVDBE_Init(LVDBE_Handle_t *phInstance,
pInstance->pData->AGCInstance.Volume = pInstance->pData->AGCInstance.Target;
/* Initialise as the target */
- pMixer_Instance = &pInstance->pData->BypassVolume;
MixGain = LVC_Mixer_GetTarget(&pMixer_Instance->MixerStream[0]);
LVC_Mixer_Init(&pMixer_Instance->MixerStream[0],MixGain,MixGain);
diff --git a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
index 20370b7..542c3c8 100644
--- a/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
+++ b/media/libeffects/lvm/lib/Bundle/src/LVM_Init.c
@@ -961,6 +961,7 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance)
LVM_InstParams_t InstParams; /* Instance parameters */
LVM_ControlParams_t Params; /* Control Parameters */
LVM_Instance_t *pInstance = (LVM_Instance_t *)hInstance; /* Pointer to Instance */
+ LVM_HeadroomParams_t HeadroomParams;
if(hInstance == LVM_NULL){
@@ -970,6 +971,9 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance)
/* Save the control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
LVM_GetControlParameters(hInstance, &Params);
+ /*Save the headroom parameters*/
+ LVM_GetHeadroomParams(hInstance, &HeadroomParams);
+
/* Retrieve allocated buffers in memtab */
LVM_GetMemoryTable(hInstance, &MemTab, LVM_NULL);
@@ -984,6 +988,9 @@ LVM_ReturnStatus_en LVM_ClearAudioBuffers(LVM_Handle_t hInstance)
/* Restore control parameters */ /* coverity[unchecked_value] */ /* Do not check return value internal function calls */
LVM_SetControlParameters(hInstance, &Params);
+ /*Restore the headroom parameters*/
+ LVM_SetHeadroomParams(hInstance, &HeadroomParams);
+
/* DC removal filter */
DC_2I_D16_TRC_WRA_01_Init(&pInstance->DC_RemovalInstance);
diff --git a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c
index e83e515..c4767a8 100644
--- a/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c
+++ b/media/libeffects/lvm/lib/Eq/src/LVEQNB_Init.c
@@ -264,6 +264,9 @@ LVEQNB_ReturnStatus_en LVEQNB_Init(LVEQNB_Handle_t *phInstance,
MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BandDef_t));
pInstance->pBandDefinitions = (LVEQNB_BandDef_t *)InstAlloc_AddMember(&AllocMem,
MemSize);
+ // clear all the bands, setting their gain to 0, otherwise when applying new params,
+ // it will compare against uninitialized values
+ memset(pInstance->pBandDefinitions, 0, MemSize);
MemSize = (pCapabilities->MaxBands * sizeof(LVEQNB_BiquadType_en));
pInstance->pBiquadType = (LVEQNB_BiquadType_en *)InstAlloc_AddMember(&AllocMem,
MemSize);
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 40dffd4..d706c2d 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -180,16 +180,16 @@ extern "C" int EffectQueryEffect(uint32_t index, effect_descriptor_t *pDescripto
}
if(index == LVM_BASS_BOOST){
ALOGV("\tEffectQueryEffect processing LVM_BASS_BOOST");
- memcpy(pDescriptor, &gBassBoostDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gBassBoostDescriptor;
}else if(index == LVM_VIRTUALIZER){
ALOGV("\tEffectQueryEffect processing LVM_VIRTUALIZER");
- memcpy(pDescriptor, &gVirtualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gVirtualizerDescriptor;
} else if(index == LVM_EQUALIZER){
ALOGV("\tEffectQueryEffect processing LVM_EQUALIZER");
- memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gEqualizerDescriptor;
} else if(index == LVM_VOLUME){
ALOGV("\tEffectQueryEffect processing LVM_VOLUME");
- memcpy(pDescriptor, &gVolumeDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gVolumeDescriptor;
}
ALOGV("\tEffectQueryEffect end\n");
return 0;
@@ -299,6 +299,10 @@ extern "C" int EffectCreate(const effect_uuid_t *uuid,
pContext->pBundledContext->SamplesToExitCountBb = 0;
pContext->pBundledContext->SamplesToExitCountEq = 0;
+ for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
+ pContext->pBundledContext->bandGaindB[i] = EQNB_5BandSoftPresets[i];
+ }
+
ALOGV("\tEffectCreate - Calling LvmBundle_init");
ret = LvmBundle_init(pContext);
@@ -494,7 +498,7 @@ extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
return -EINVAL;
}
- memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+ *pDescriptor = *desc;
return 0;
} /* end EffectGetDescriptor */
@@ -698,10 +702,10 @@ int LvmBundle_init(EffectContext *pContext){
/* Set the headroom parameters */
HeadroomBandDef[0].Limit_Low = 20;
HeadroomBandDef[0].Limit_High = 4999;
- HeadroomBandDef[0].Headroom_Offset = 3;
+ HeadroomBandDef[0].Headroom_Offset = 0;
HeadroomBandDef[1].Limit_Low = 5000;
HeadroomBandDef[1].Limit_High = 24000;
- HeadroomBandDef[1].Headroom_Offset = 4;
+ HeadroomBandDef[1].Headroom_Offset = 0;
HeadroomParams.pHeadroomDefinition = &HeadroomBandDef[0];
HeadroomParams.Headroom_OperatingMode = LVM_HEADROOM_ON;
HeadroomParams.NHeadroomBands = 2;
@@ -965,7 +969,7 @@ int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
|| pConfig->outputCfg.accessMode == EFFECT_BUFFER_ACCESS_ACCUMULATE);
CHECK_ARG(pConfig->inputCfg.format == AUDIO_FORMAT_PCM_16_BIT);
- memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+ pContext->config = *pConfig;
switch (pConfig->inputCfg.samplingRate) {
case 8000:
@@ -1011,6 +1015,8 @@ int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "Effect_setConfig")
if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ ActiveParams.SampleRate = SampleRate;
+
LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "Effect_setConfig")
@@ -1041,7 +1047,7 @@ int Effect_setConfig(EffectContext *pContext, effect_config_t *pConfig){
void Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig)
{
- memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+ *pConfig = pContext->config;
} /* end Effect_getConfig */
//----------------------------------------------------------------------------
@@ -1192,36 +1198,120 @@ void VirtualizerSetStrength(EffectContext *pContext, uint32_t strength){
//ALOGV("\tVirtualizerSetStrength Succesfully called LVM_SetControlParameters\n\n");
} /* end setStrength */
+
//----------------------------------------------------------------------------
-// EqualizerGetBandLevel()
+// EqualizerLimitBandLevels()
//----------------------------------------------------------------------------
-// Purpose: Retrieve the gain currently being used for the band passed in
+// Purpose: limit all EQ band gains to a value less than 0 dB while
+// preserving the relative band levels.
//
// Inputs:
-// band: band number
// pContext: effect engine context
//
// Outputs:
//
//----------------------------------------------------------------------------
-int32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){
+void EqualizerLimitBandLevels(EffectContext *pContext) {
+ LVM_ControlParams_t ActiveParams; /* Current control Parameters */
+ LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
- int32_t Gain =0;
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
- LVM_EQNB_BandDef_t *BandDef;
/* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance,
- &ActiveParams);
+ LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerLimitBandLevels")
+ //ALOGV("\tEqualizerLimitBandLevels Succesfully returned from LVM_GetControlParameters\n");
+ //ALOGV("\tEqualizerLimitBandLevels just Got -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
+
+ // Apply a volume correction to avoid clipping in the EQ based on 2 factors:
+ // - the maximum EQ band gain: the volume correction is such that the total of volume + max
+ // band gain is <= 0 dB
+ // - the average gain in all bands weighted by their proximity to max gain band.
+ int maxGain = 0;
+ int avgGain = 0;
+ int avgCount = 0;
+ for (int i = 0; i < FIVEBAND_NUMBANDS; i++) {
+ if (pContext->pBundledContext->bandGaindB[i] >= maxGain) {
+ int tmpMaxGain = pContext->pBundledContext->bandGaindB[i];
+ int tmpAvgGain = 0;
+ int tmpAvgCount = 0;
+ for (int j = 0; j < FIVEBAND_NUMBANDS; j++) {
+ int gain = pContext->pBundledContext->bandGaindB[j];
+ // skip current band and gains < 0 dB
+ if (j == i || gain < 0)
+ continue;
+ // no need to continue if one band not processed yet has a higher gain than current
+ // max
+ if (gain > tmpMaxGain) {
+ // force skipping "if (tmpAvgGain >= avgGain)" below as tmpAvgGain is not
+ // meaningful in this case
+ tmpAvgGain = -1;
+ break;
+ }
+
+ int weight = 1;
+ if (j < (i + 2) && j > (i - 2))
+ weight = 4;
+ tmpAvgGain += weight * gain;
+ tmpAvgCount += weight;
+ }
+ if (tmpAvgGain >= avgGain) {
+ maxGain = tmpMaxGain;
+ avgGain = tmpAvgGain;
+ avgCount = tmpAvgCount;
+ }
+ }
+ ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i];
+ ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i];
+ ActiveParams.pEQNB_BandDefinition[i].Gain = pContext->pBundledContext->bandGaindB[i];
+ }
+
+ int gainCorrection = 0;
+ if (maxGain + pContext->pBundledContext->volume > 0) {
+ gainCorrection = maxGain + pContext->pBundledContext->volume;
+ }
+ if (avgCount) {
+ gainCorrection += avgGain/avgCount;
+ }
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerGetBandLevel")
+ ALOGV("EqualizerLimitBandLevels() gainCorrection %d maxGain %d avgGain %d avgCount %d",
+ gainCorrection, maxGain, avgGain, avgCount);
- BandDef = ActiveParams.pEQNB_BandDefinition;
- Gain = (int32_t)BandDef[band].Gain*100; // Convert to millibels
+ ActiveParams.VC_EffectLevel = pContext->pBundledContext->volume - gainCorrection;
+ if (ActiveParams.VC_EffectLevel < -96) {
+ ActiveParams.VC_EffectLevel = -96;
+ }
+
+ /* Activate the initial settings */
+ LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerLimitBandLevels")
+ //ALOGV("\tEqualizerLimitBandLevels just Set -> %d\n",
+ // ActiveParams.pEQNB_BandDefinition[band].Gain);
- //ALOGV("\tEqualizerGetBandLevel -> %d\n", Gain );
- //ALOGV("\tEqualizerGetBandLevel Succesfully returned from LVM_GetControlParameters\n");
- return Gain;
+ //ALOGV("\tEqualizerLimitBandLevels just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel );
+ if(pContext->pBundledContext->firstVolume == LVM_TRUE){
+ LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
+ LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process")
+ ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
+ pContext->pBundledContext->firstVolume = LVM_FALSE;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+// EqualizerGetBandLevel()
+//----------------------------------------------------------------------------
+// Purpose: Retrieve the gain currently being used for the band passed in
+//
+// Inputs:
+// band: band number
+// pContext: effect engine context
+//
+// Outputs:
+//
+//----------------------------------------------------------------------------
+int32_t EqualizerGetBandLevel(EffectContext *pContext, int32_t band){
+ //ALOGV("\tEqualizerGetBandLevel -> %d\n", pContext->pBundledContext->bandGaindB[band] );
+ return pContext->pBundledContext->bandGaindB[band] * 100;
}
//----------------------------------------------------------------------------
@@ -1246,30 +1336,12 @@ void EqualizerSetBandLevel(EffectContext *pContext, int band, short Gain){
gainRounded = (int)((Gain-50)/100);
}
//ALOGV("\tEqualizerSetBandLevel(%d)->(%d)", Gain, gainRounded);
-
-
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
- LVM_EQNB_BandDef_t *BandDef;
-
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetBandLevel")
- //ALOGV("\tEqualizerSetBandLevel Succesfully returned from LVM_GetControlParameters\n");
- //ALOGV("\tEqualizerSetBandLevel just Got -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
-
- /* Set local EQ parameters */
- BandDef = ActiveParams.pEQNB_BandDefinition;
- ActiveParams.pEQNB_BandDefinition[band].Gain = gainRounded;
-
- /* Activate the initial settings */
- LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetBandLevel")
- //ALOGV("\tEqualizerSetBandLevel just Set -> %d\n",ActiveParams.pEQNB_BandDefinition[band].Gain);
-
+ pContext->pBundledContext->bandGaindB[band] = gainRounded;
pContext->pBundledContext->CurPreset = PRESET_CUSTOM;
- return;
+
+ EqualizerLimitBandLevels(pContext);
}
+
//----------------------------------------------------------------------------
// EqualizerGetCentreFrequency()
//----------------------------------------------------------------------------
@@ -1395,25 +1467,14 @@ void EqualizerSetPreset(EffectContext *pContext, int preset){
//ALOGV("\tEqualizerSetPreset(%d)", preset);
pContext->pBundledContext->CurPreset = preset;
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
-
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "EqualizerSetPreset")
- //ALOGV("\tEqualizerSetPreset Succesfully returned from LVM_GetControlParameters\n");
-
//ActiveParams.pEQNB_BandDefinition = &BandDefs[0];
for (int i=0; i<FIVEBAND_NUMBANDS; i++)
{
- ActiveParams.pEQNB_BandDefinition[i].Frequency = EQNB_5BandPresetsFrequencies[i];
- ActiveParams.pEQNB_BandDefinition[i].QFactor = EQNB_5BandPresetsQFactors[i];
- ActiveParams.pEQNB_BandDefinition[i].Gain
- = EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS];
+ pContext->pBundledContext->bandGaindB[i] =
+ EQNB_5BandSoftPresets[i + preset * FIVEBAND_NUMBANDS];
}
- /* Activate the new settings */
- LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "EqualizerSetPreset")
+
+ EqualizerLimitBandLevels(pContext);
//ALOGV("\tEqualizerSetPreset Succesfully called LVM_SetControlParameters\n");
return;
@@ -1458,40 +1519,18 @@ const char * EqualizerGetPresetName(int32_t preset){
int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
-
- //ALOGV("\tVolumeSetVolumeLevel Level to be set is %d %d\n", level, (LVM_INT16)(level/100));
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
- //ALOGV("\tVolumeSetVolumeLevel Succesfully returned from LVM_GetControlParameters got: %d\n",
- //ActiveParams.VC_EffectLevel);
-
- /* Volume parameters */
- ActiveParams.VC_EffectLevel = (LVM_INT16)(level/100);
- //ALOGV("\tVolumeSetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
+ if (level > 0 || level < -9600) {
+ return -EINVAL;
+ }
- /* Activate the initial settings */
- LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetVolumeLevel")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) {
+ pContext->pBundledContext->levelSaved = level / 100;
+ } else {
+ pContext->pBundledContext->volume = level / 100;
+ }
- //ALOGV("\tVolumeSetVolumeLevel Succesfully called LVM_SetControlParameters\n");
+ EqualizerLimitBandLevels(pContext);
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetVolumeLevel")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-
- //ALOGV("\tVolumeSetVolumeLevel just set (-96dB -> 0dB) -> %d\n",ActiveParams.VC_EffectLevel );
- if(pContext->pBundledContext->firstVolume == LVM_TRUE){
- LvmStatus = LVM_SetVolumeNoSmoothing(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetVolumeNoSmoothing", "LvmBundle_process")
- ALOGV("\tLVM_VOLUME: Disabling Smoothing for first volume change to remove spikes/clicks");
- pContext->pBundledContext->firstVolume = LVM_FALSE;
- }
return 0;
} /* end VolumeSetVolumeLevel */
@@ -1507,20 +1546,11 @@ int VolumeSetVolumeLevel(EffectContext *pContext, int16_t level){
int VolumeGetVolumeLevel(EffectContext *pContext, int16_t *level){
- //ALOGV("\tVolumeGetVolumeLevel start");
-
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus = LVM_SUCCESS; /* Function call status */
-
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeGetVolumeLevel")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-
- //ALOGV("\tVolumeGetVolumeLevel() (-96dB -> 0dB) -> %d\n", ActiveParams.VC_EffectLevel );
- //ALOGV("\tVolumeGetVolumeLevel Succesfully returned from LVM_GetControlParameters\n");
-
- *level = ActiveParams.VC_EffectLevel*100; // Convert dB to millibels
- //ALOGV("\tVolumeGetVolumeLevel end");
+ if (pContext->pBundledContext->bMuteEnabled == LVM_TRUE) {
+ *level = pContext->pBundledContext->levelSaved * 100;
+ } else {
+ *level = pContext->pBundledContext->volume * 100;
+ }
return 0;
} /* end VolumeGetVolumeLevel */
@@ -1540,32 +1570,16 @@ int32_t VolumeSetMute(EffectContext *pContext, uint32_t mute){
pContext->pBundledContext->bMuteEnabled = mute;
- LVM_ControlParams_t ActiveParams; /* Current control Parameters */
- LVM_ReturnStatus_en LvmStatus=LVM_SUCCESS; /* Function call status */
-
- /* Get the current settings */
- LvmStatus = LVM_GetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_GetControlParameters", "VolumeSetMute")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
-
- //ALOGV("\tVolumeSetMute Succesfully returned from LVM_GetControlParameters\n");
- //ALOGV("\tVolumeSetMute to %d, level was %d\n", mute, ActiveParams.VC_EffectLevel );
-
/* Set appropriate volume level */
if(pContext->pBundledContext->bMuteEnabled == LVM_TRUE){
- pContext->pBundledContext->levelSaved = ActiveParams.VC_EffectLevel;
- ActiveParams.VC_EffectLevel = -96;
+ pContext->pBundledContext->levelSaved = pContext->pBundledContext->volume;
+ pContext->pBundledContext->volume = -96;
}else{
- ActiveParams.VC_EffectLevel = pContext->pBundledContext->levelSaved;
+ pContext->pBundledContext->volume = pContext->pBundledContext->levelSaved;
}
- /* Activate the initial settings */
- LvmStatus = LVM_SetControlParameters(pContext->pBundledContext->hInstance, &ActiveParams);
- LVM_ERROR_CHECK(LvmStatus, "LVM_SetControlParameters", "VolumeSetMute")
- if(LvmStatus != LVM_SUCCESS) return -EINVAL;
+ EqualizerLimitBandLevels(pContext);
- //ALOGV("\tVolumeSetMute Succesfully called LVM_SetControlParameters\n");
- //ALOGV("\tVolumeSetMute end");
return 0;
} /* end setMute */
@@ -2723,7 +2737,7 @@ int Effect_process(effect_handle_t self,
outBuffer->s16[i] =
clamp16((LVM_INT32)outBuffer->s16[i] + (LVM_INT32)inBuffer->s16[i]);
}
- } else {
+ } else if (outBuffer->raw != inBuffer->raw) {
memcpy(outBuffer->raw, inBuffer->raw, outBuffer->frameCount*sizeof(LVM_INT16)*2);
}
}
@@ -3272,7 +3286,7 @@ int Effect_getDescriptor(effect_handle_t self,
return -EINVAL;
}
- memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+ *pDescriptor = *desc;
return 0;
} /* end Effect_getDescriptor */
diff --git a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
index 5634ca1..330bb32 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.h
@@ -95,6 +95,8 @@ struct BundledEffectContext{
int SamplesToExitCountVirt;
LVM_INT16 *workBuffer;
int frameCount;
+ int32_t bandGaindB[FIVEBAND_NUMBANDS];
+ int volume;
#ifdef LVM_PCM
FILE *PcmInPtr;
FILE *PcmOutPtr;
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 9599dcc..941d651 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -206,7 +206,7 @@ extern "C" int EffectQueryEffect(uint32_t index,
ALOGV("\tLVM_ERROR : EffectQueryEffect index out of range %d", index);
return -ENOENT;
}
- memcpy(pDescriptor, gDescriptors[index], sizeof(effect_descriptor_t));
+ *pDescriptor = *gDescriptors[index];
ALOGV("\tEffectQueryEffect end\n");
return 0;
} /* end EffectQueryEffect */
@@ -330,7 +330,7 @@ extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
for (i = 0; i < length; i++) {
if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
- memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
+ *pDescriptor = *gDescriptors[i];
ALOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
i, gDescriptors[i]->uuid.timeLow);
return 0;
@@ -645,7 +645,7 @@ int Reverb_setConfig(ReverbContext *pContext, effect_config_t *pConfig){
}
//ALOGV("\tReverb_setConfig calling memcpy");
- memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+ pContext->config = *pConfig;
switch (pConfig->inputCfg.samplingRate) {
@@ -715,7 +715,7 @@ int Reverb_setConfig(ReverbContext *pContext, effect_config_t *pConfig){
void Reverb_getConfig(ReverbContext *pContext, effect_config_t *pConfig)
{
- memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+ *pConfig = pContext->config;
} /* end Reverb_getConfig */
//----------------------------------------------------------------------------
@@ -2157,7 +2157,7 @@ int Reverb_getDescriptor(effect_handle_t self,
}
}
- memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+ *pDescriptor = *desc;
return 0;
} /* end Reverb_getDescriptor */
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index cfa7f51..597866a 100755
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -517,6 +517,10 @@ int AecSetDevice(preproc_effect_t *effect, uint32_t device)
webrtc::EchoControlMobile *aec = static_cast<webrtc::EchoControlMobile *>(effect->engine);
webrtc::EchoControlMobile::RoutingMode mode = webrtc::EchoControlMobile::kQuietEarpieceOrHeadset;
+ if (audio_is_input_device(device)) {
+ return 0;
+ }
+
switch(device) {
case AUDIO_DEVICE_OUT_EARPIECE:
mode = webrtc::EchoControlMobile::kEarpiece;
@@ -1700,7 +1704,7 @@ int PreProcessingFx_GetDescriptor(effect_handle_t self,
return -EINVAL;
}
- memcpy(pDescriptor, sDescriptors[effect->procId], sizeof(effect_descriptor_t));
+ *pDescriptor = *sDescriptors[effect->procId];
return 0;
}
@@ -1834,7 +1838,7 @@ int PreProcessingLib_QueryEffect(uint32_t index, effect_descriptor_t *pDescripto
if (index >= PREPROC_NUM_EFFECTS) {
return -EINVAL;
}
- memcpy(pDescriptor, sDescriptors[index], sizeof(effect_descriptor_t));
+ *pDescriptor = *sDescriptors[index];
return 0;
}
@@ -1905,7 +1909,7 @@ int PreProcessingLib_GetDescriptor(const effect_uuid_t *uuid,
ALOGV("PreProcessingLib_GetDescriptor() got fx %s", desc->name);
- memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+ *pDescriptor = *desc;
return 0;
}
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 35a4a61..90ebe1f 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -136,7 +136,7 @@ extern "C" int EffectQueryEffect(uint32_t index,
if (index > 0) {
return -EINVAL;
}
- memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gEqualizerDescriptor;
return 0;
} /* end EffectQueryNext */
@@ -204,7 +204,7 @@ extern "C" int EffectGetDescriptor(const effect_uuid_t *uuid,
}
if (memcmp(uuid, &gEqualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
- memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gEqualizerDescriptor;
return 0;
}
@@ -262,7 +262,7 @@ int Equalizer_setConfig(EqualizerContext *pContext, effect_config_t *pConfig)
}
CHECK_ARG(channelCount <= AudioBiquadFilter::MAX_CHANNELS);
- memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+ pContext->config = *pConfig;
pContext->pEqualizer->configure(channelCount,
pConfig->inputCfg.samplingRate);
@@ -290,7 +290,7 @@ int Equalizer_setConfig(EqualizerContext *pContext, effect_config_t *pConfig)
void Equalizer_getConfig(EqualizerContext *pContext, effect_config_t *pConfig)
{
- memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+ *pConfig = pContext->config;
} // end Equalizer_getConfig
@@ -752,7 +752,7 @@ extern "C" int Equalizer_getDescriptor(effect_handle_t self,
return -EINVAL;
}
- memcpy(pDescriptor, &android::gEqualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = android::gEqualizerDescriptor;
return 0;
}
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index 8351712..a87a834 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -194,7 +194,7 @@ int EffectGetDescriptor(const effect_uuid_t *uuid,
for (i = 0; i < length; i++) {
if (memcmp(uuid, &gDescriptors[i]->uuid, sizeof(effect_uuid_t)) == 0) {
- memcpy(pDescriptor, gDescriptors[i], sizeof(effect_descriptor_t));
+ *pDescriptor = *gDescriptors[i];
ALOGV("EffectGetDescriptor - UUID matched Reverb type %d, UUID = %x",
i, gDescriptors[i]->uuid.timeLow);
return 0;
@@ -440,7 +440,7 @@ int Reverb_GetDescriptor(effect_handle_t self,
}
}
- memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+ *pDescriptor = *desc;
return 0;
} /* end Reverb_getDescriptor */
@@ -546,7 +546,7 @@ int Reverb_setConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig,
return -EINVAL;
}
- memcpy(&pRvbModule->config, pConfig, sizeof(effect_config_t));
+ pRvbModule->config = *pConfig;
pReverb->m_nSamplingRate = pRvbModule->config.outputCfg.samplingRate;
@@ -644,7 +644,7 @@ int Reverb_setConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig,
void Reverb_getConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig)
{
- memcpy(pConfig, &pRvbModule->config, sizeof(effect_config_t));
+ *pConfig = pRvbModule->config;
}
/*----------------------------------------------------------------------------
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index d3c69f4..44baf93 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -106,7 +106,7 @@ int Visualizer_setConfig(VisualizerContext *pContext, effect_config_t *pConfig)
pConfig->outputCfg.accessMode != EFFECT_BUFFER_ACCESS_ACCUMULATE) return -EINVAL;
if (pConfig->inputCfg.format != AUDIO_FORMAT_PCM_16_BIT) return -EINVAL;
- memcpy(&pContext->mConfig, pConfig, sizeof(effect_config_t));
+ pContext->mConfig = *pConfig;
Visualizer_reset(pContext);
@@ -130,7 +130,7 @@ int Visualizer_setConfig(VisualizerContext *pContext, effect_config_t *pConfig)
void Visualizer_getConfig(VisualizerContext *pContext, effect_config_t *pConfig)
{
- memcpy(pConfig, &pContext->mConfig, sizeof(effect_config_t));
+ *pConfig = pContext->mConfig;
}
@@ -190,7 +190,7 @@ int VisualizerLib_QueryEffect(uint32_t index,
if (index > 0) {
return -EINVAL;
}
- memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gVisualizerDescriptor;
return 0;
}
@@ -253,7 +253,7 @@ int VisualizerLib_GetDescriptor(const effect_uuid_t *uuid,
}
if (memcmp(uuid, &gVisualizerDescriptor.uuid, sizeof(effect_uuid_t)) == 0) {
- memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gVisualizerDescriptor;
return 0;
}
@@ -561,7 +561,7 @@ int Visualizer_getDescriptor(effect_handle_t self,
return -EINVAL;
}
- memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+ *pDescriptor = gVisualizerDescriptor;
return 0;
} /* end Visualizer_getDescriptor */
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 6afc505..54666fb 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -18,6 +18,7 @@ LOCAL_SRC_FILES:= \
IAudioTrack.cpp \
IAudioRecord.cpp \
ICrypto.cpp \
+ IHDCP.cpp \
AudioRecord.cpp \
AudioSystem.cpp \
mediaplayer.cpp \
@@ -26,6 +27,8 @@ LOCAL_SRC_FILES:= \
IMediaRecorderClient.cpp \
IMediaPlayer.cpp \
IMediaRecorder.cpp \
+ IRemoteDisplay.cpp \
+ IRemoteDisplayClient.cpp \
IStreamSource.cpp \
Metadata.cpp \
mediarecorder.cpp \
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 34451ca..680604b 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -122,19 +122,12 @@ status_t AudioEffect::set(const effect_uuid_t *type,
mSessionId = sessionId;
memset(&mDescriptor, 0, sizeof(effect_descriptor_t));
- memcpy(&mDescriptor.type, EFFECT_UUID_NULL, sizeof(effect_uuid_t));
- memcpy(&mDescriptor.uuid, EFFECT_UUID_NULL, sizeof(effect_uuid_t));
-
- if (type != NULL) {
- memcpy(&mDescriptor.type, type, sizeof(effect_uuid_t));
- }
- if (uuid != NULL) {
- memcpy(&mDescriptor.uuid, uuid, sizeof(effect_uuid_t));
- }
+ mDescriptor.type = *(type != NULL ? type : EFFECT_UUID_NULL);
+ mDescriptor.uuid = *(uuid != NULL ? uuid : EFFECT_UUID_NULL);
mIEffectClient = new EffectClient(this);
- iEffect = audioFlinger->createEffect(getpid(), (effect_descriptor_t *)&mDescriptor,
+ iEffect = audioFlinger->createEffect(getpid(), &mDescriptor,
mIEffectClient, priority, io, mSessionId, &mStatus, &mId, &enabled);
if (iEffect == 0 || (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS)) {
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 0562f8e..8ea6306 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -18,28 +18,18 @@
//#define LOG_NDEBUG 0
#define LOG_TAG "AudioRecord"
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <sched.h>
#include <sys/resource.h>
+#include <sys/types.h>
-#include <private/media/AudioTrackShared.h>
-
-#include <media/AudioSystem.h>
+#include <binder/IPCThreadState.h>
+#include <cutils/atomic.h>
+#include <cutils/compiler.h>
#include <media/AudioRecord.h>
-#include <media/mediarecorder.h>
-
-#include <binder/IServiceManager.h>
+#include <media/AudioSystem.h>
+#include <system/audio.h>
#include <utils/Log.h>
-#include <binder/Parcel.h>
-#include <binder/IPCThreadState.h>
-#include <utils/Timers.h>
-#include <utils/Atomic.h>
-#include <system/audio.h>
-#include <cutils/bitops.h>
-#include <cutils/compiler.h>
+#include <private/media/AudioTrackShared.h>
namespace android {
// ---------------------------------------------------------------------------
@@ -49,18 +39,23 @@ status_t AudioRecord::getMinFrameCount(
int* frameCount,
uint32_t sampleRate,
audio_format_t format,
- int channelCount)
+ audio_channel_mask_t channelMask)
{
+ if (frameCount == NULL) return BAD_VALUE;
+
+ // default to 0 in case of error
+ *frameCount = 0;
+
size_t size = 0;
- if (AudioSystem::getInputBufferSize(sampleRate, format, channelCount, &size)
+ if (AudioSystem::getInputBufferSize(sampleRate, format, channelMask, &size)
!= NO_ERROR) {
ALOGE("AudioSystem could not query the input buffer size.");
return NO_INIT;
}
if (size == 0) {
- ALOGE("Unsupported configuration: sampleRate %d, format %d, channelCount %d",
- sampleRate, format, channelCount);
+ ALOGE("Unsupported configuration: sampleRate %d, format %d, channelMask %#x",
+ sampleRate, format, channelMask);
return BAD_VALUE;
}
@@ -68,6 +63,7 @@ status_t AudioRecord::getMinFrameCount(
size <<= 1;
if (audio_is_linear_pcm(format)) {
+ int channelCount = popcount(channelMask);
size /= channelCount * audio_bytes_per_sample(format);
}
@@ -87,9 +83,8 @@ AudioRecord::AudioRecord(
audio_source_t inputSource,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
- record_flags flags,
callback_t cbf,
void* user,
int notificationFrames,
@@ -98,7 +93,7 @@ AudioRecord::AudioRecord(
mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(SP_DEFAULT)
{
mStatus = set(inputSource, sampleRate, format, channelMask,
- frameCount, flags, cbf, user, notificationFrames, sessionId);
+ frameCount, cbf, user, notificationFrames, sessionId);
}
AudioRecord::~AudioRecord()
@@ -108,9 +103,10 @@ AudioRecord::~AudioRecord()
// it is looping on buffer empty condition in obtainBuffer().
// Otherwise the callback thread will never exit.
stop();
- if (mClientRecordThread != 0) {
- mClientRecordThread->requestExitAndWait();
- mClientRecordThread.clear();
+ if (mAudioRecordThread != 0) {
+ mAudioRecordThread->requestExit(); // see comment in AudioRecord.h
+ mAudioRecordThread->requestExitAndWait();
+ mAudioRecordThread.clear();
}
mAudioRecord.clear();
IPCThreadState::self()->flushCommands();
@@ -122,9 +118,8 @@ status_t AudioRecord::set(
audio_source_t inputSource,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
- record_flags flags,
callback_t cbf,
void* user,
int notificationFrames,
@@ -132,7 +127,7 @@ status_t AudioRecord::set(
int sessionId)
{
- ALOGV("set(): sampleRate %d, channelMask %d, frameCount %d",sampleRate, channelMask, frameCount);
+ ALOGV("set(): sampleRate %d, channelMask %#x, frameCount %d",sampleRate, channelMask, frameCount);
AutoMutex lock(mLock);
@@ -174,7 +169,6 @@ status_t AudioRecord::set(
sampleRate,
format,
channelMask,
- (audio_in_acoustics_t)flags,
mSessionId);
if (input == 0) {
ALOGE("Could not get audio input for record source %d", inputSource);
@@ -183,7 +177,7 @@ status_t AudioRecord::set(
// validate framecount
int minFrameCount = 0;
- status_t status = getMinFrameCount(&minFrameCount, sampleRate, format, channelCount);
+ status_t status = getMinFrameCount(&minFrameCount, sampleRate, format, channelMask);
if (status != NO_ERROR) {
return status;
}
@@ -207,7 +201,8 @@ status_t AudioRecord::set(
}
if (cbf != NULL) {
- mClientRecordThread = new ClientRecordThread(*this, threadCanCallJava);
+ mAudioRecordThread = new AudioRecordThread(*this, threadCanCallJava);
+ mAudioRecordThread->run("AudioRecord", ANDROID_PRIORITY_AUDIO);
}
mStatus = NO_ERROR;
@@ -217,7 +212,7 @@ status_t AudioRecord::set(
mFrameCount = mCblk->frameCount;
mChannelCount = (uint8_t)channelCount;
mChannelMask = channelMask;
- mActive = 0;
+ mActive = false;
mCbf = cbf;
mNotificationFrames = notificationFrames;
mRemainingFrames = notificationFrames;
@@ -229,7 +224,6 @@ status_t AudioRecord::set(
mNewPosition = 0;
mUpdatePeriod = 0;
mInputSource = inputSource;
- mFlags = flags;
mInput = input;
AudioSystem::acquireAudioSessionId(mSessionId);
@@ -282,41 +276,19 @@ audio_source_t AudioRecord::inputSource() const
status_t AudioRecord::start(AudioSystem::sync_event_t event, int triggerSession)
{
status_t ret = NO_ERROR;
- sp<ClientRecordThread> t = mClientRecordThread;
+ sp<AudioRecordThread> t = mAudioRecordThread;
ALOGV("start, sync event %d trigger session %d", event, triggerSession);
- if (t != 0) {
- if (t->exitPending()) {
- if (t->requestExitAndWait() == WOULD_BLOCK) {
- ALOGE("AudioRecord::start called from thread");
- return WOULD_BLOCK;
- }
- }
- }
-
AutoMutex lock(mLock);
// acquire a strong reference on the IAudioRecord and IMemory so that they cannot be destroyed
// while we are accessing the cblk
sp<IAudioRecord> audioRecord = mAudioRecord;
sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
- if (mActive == 0) {
- mActive = 1;
- pid_t tid;
- if (t != 0) {
- mReadyToRun = WOULD_BLOCK;
- t->run("AudioRecord", ANDROID_PRIORITY_AUDIO);
- tid = t->getTid(); // pid_t is unknown until run()
- ALOGV("getTid=%d", tid);
- if (tid == -1) {
- tid = 0;
- }
- // thread blocks in readyToRun()
- } else {
- tid = 0; // not gettid()
- }
+ if (!mActive) {
+ mActive = true;
cblk->lock.lock();
if (!(cblk->flags & CBLK_INVALID_MSK)) {
@@ -338,58 +310,51 @@ status_t AudioRecord::start(AudioSystem::sync_event_t event, int triggerSession)
AudioSystem::kSyncRecordStartTimeOutMs;
cblk->waitTimeMs = 0;
if (t != 0) {
- // thread unblocks in readyToRun() and returns NO_ERROR
- mReadyToRun = NO_ERROR;
- mCondition.signal();
+ t->resume();
} else {
mPreviousPriority = getpriority(PRIO_PROCESS, 0);
get_sched_policy(0, &mPreviousSchedulingGroup);
androidSetThreadPriority(0, ANDROID_PRIORITY_AUDIO);
}
} else {
- mActive = 0;
- // thread unblocks in readyToRun() and returns NO_INIT
- mReadyToRun = NO_INIT;
- mCondition.signal();
+ mActive = false;
}
}
return ret;
}
-status_t AudioRecord::stop()
+void AudioRecord::stop()
{
- sp<ClientRecordThread> t = mClientRecordThread;
+ sp<AudioRecordThread> t = mAudioRecordThread;
ALOGV("stop");
AutoMutex lock(mLock);
- if (mActive == 1) {
- mActive = 0;
+ if (mActive) {
+ mActive = false;
mCblk->cv.signal();
mAudioRecord->stop();
// the record head position will reset to 0, so if a marker is set, we need
// to activate it again
mMarkerReached = false;
if (t != 0) {
- t->requestExit();
+ t->pause();
} else {
setpriority(PRIO_PROCESS, 0, mPreviousPriority);
set_sched_policy(0, mPreviousSchedulingGroup);
}
}
-
- return NO_ERROR;
}
bool AudioRecord::stopped() const
{
+ AutoMutex lock(mLock);
return !mActive;
}
uint32_t AudioRecord::getSampleRate() const
{
- AutoMutex lock(mLock);
return mCblk->sampleRate;
}
@@ -397,6 +362,7 @@ status_t AudioRecord::setMarkerPosition(uint32_t marker)
{
if (mCbf == NULL) return INVALID_OPERATION;
+ AutoMutex lock(mLock);
mMarkerPosition = marker;
mMarkerReached = false;
@@ -407,6 +373,7 @@ status_t AudioRecord::getMarkerPosition(uint32_t *marker) const
{
if (marker == NULL) return BAD_VALUE;
+ AutoMutex lock(mLock);
*marker = mMarkerPosition;
return NO_ERROR;
@@ -418,6 +385,8 @@ status_t AudioRecord::setPositionUpdatePeriod(uint32_t updatePeriod)
uint32_t curPosition;
getPosition(&curPosition);
+
+ AutoMutex lock(mLock);
mNewPosition = curPosition + updatePeriod;
mUpdatePeriod = updatePeriod;
@@ -428,6 +397,7 @@ status_t AudioRecord::getPositionUpdatePeriod(uint32_t *updatePeriod) const
{
if (updatePeriod == NULL) return BAD_VALUE;
+ AutoMutex lock(mLock);
*updatePeriod = mUpdatePeriod;
return NO_ERROR;
@@ -445,10 +415,8 @@ status_t AudioRecord::getPosition(uint32_t *position) const
unsigned int AudioRecord::getInputFramesLost() const
{
- if (mActive)
- return AudioSystem::getInputFramesLost(mInput);
- else
- return 0;
+ // no need to check mActive, because if inactive this will return 0, which is what we want
+ return AudioSystem::getInputFramesLost(mInput);
}
// -------------------------------------------------------------------------
@@ -457,7 +425,7 @@ unsigned int AudioRecord::getInputFramesLost() const
status_t AudioRecord::openRecord_l(
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
audio_io_handle_t input)
{
@@ -467,13 +435,20 @@ status_t AudioRecord::openRecord_l(
return NO_INIT;
}
+ pid_t tid = -1;
+ // FIXME see similar logic at AudioTrack
+
+ int originalSessionId = mSessionId;
sp<IAudioRecord> record = audioFlinger->openRecord(getpid(), input,
sampleRate, format,
channelMask,
frameCount,
IAudioFlinger::TRACK_DEFAULT,
+ tid,
&mSessionId,
&status);
+ ALOGE_IF(originalSessionId != 0 && mSessionId != originalSessionId,
+ "session ID changed from %d to %d", originalSessionId, mSessionId);
if (record == 0) {
ALOGE("AudioFlinger could not create record track, status: %d", status);
@@ -499,7 +474,7 @@ status_t AudioRecord::openRecord_l(
status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
{
AutoMutex lock(mLock);
- int active;
+ bool active;
status_t result = NO_ERROR;
audio_track_cblk_t* cblk = mCblk;
uint32_t framesReq = audioBuffer->frameCount;
@@ -528,7 +503,7 @@ status_t AudioRecord::obtainBuffer(Buffer* audioBuffer, int32_t waitCount)
result = cblk->cv.waitRelative(cblk->lock, milliseconds(waitTimeMs));
cblk->lock.unlock();
mLock.lock();
- if (mActive == 0) {
+ if (!mActive) {
return status_t(STOPPED);
}
cblk->lock.lock();
@@ -613,13 +588,13 @@ audio_io_handle_t AudioRecord::getInput_l()
mCblk->sampleRate,
mFormat,
mChannelMask,
- (audio_in_acoustics_t)mFlags,
mSessionId);
return mInput;
}
int AudioRecord::getSessionId() const
{
+ // no lock needed because session ID doesn't change after first set()
return mSessionId;
}
@@ -678,7 +653,7 @@ ssize_t AudioRecord::read(void* buffer, size_t userSize)
// -------------------------------------------------------------------------
-bool AudioRecord::processAudioBuffer(const sp<ClientRecordThread>& thread)
+bool AudioRecord::processAudioBuffer(const sp<AudioRecordThread>& thread)
{
Buffer audioBuffer;
uint32_t frames = mRemainingFrames;
@@ -690,22 +665,32 @@ bool AudioRecord::processAudioBuffer(const sp<ClientRecordThread>& thread)
sp<IAudioRecord> audioRecord = mAudioRecord;
sp<IMemory> iMem = mCblkMemory;
audio_track_cblk_t* cblk = mCblk;
+ bool active = mActive;
+ uint32_t markerPosition = mMarkerPosition;
+ uint32_t newPosition = mNewPosition;
+ uint32_t user = cblk->user;
+ // determine whether a marker callback will be needed, while locked
+ bool needMarker = !mMarkerReached && (mMarkerPosition > 0) && (user >= mMarkerPosition);
+ if (needMarker) {
+ mMarkerReached = true;
+ }
+ // determine the number of new position callback(s) that will be needed, while locked
+ uint32_t updatePeriod = mUpdatePeriod;
+ uint32_t needNewPos = updatePeriod > 0 && user >= newPosition ?
+ ((user - newPosition) / updatePeriod) + 1 : 0;
+ mNewPosition = newPosition + updatePeriod * needNewPos;
mLock.unlock();
- // Manage marker callback
- if (!mMarkerReached && (mMarkerPosition > 0)) {
- if (cblk->user >= mMarkerPosition) {
- mCbf(EVENT_MARKER, mUserData, (void *)&mMarkerPosition);
- mMarkerReached = true;
- }
+ // perform marker callback, while unlocked
+ if (needMarker) {
+ mCbf(EVENT_MARKER, mUserData, &markerPosition);
}
- // Manage new position callback
- if (mUpdatePeriod > 0) {
- while (cblk->user >= mNewPosition) {
- mCbf(EVENT_NEW_POS, mUserData, (void *)&mNewPosition);
- mNewPosition += mUpdatePeriod;
- }
+ // perform new position callback(s), while unlocked
+ for (; needNewPos > 0; --needNewPos) {
+ uint32_t temp = newPosition;
+ mCbf(EVENT_NEW_POS, mUserData, &temp);
+ newPosition += updatePeriod;
}
do {
@@ -748,10 +733,12 @@ bool AudioRecord::processAudioBuffer(const sp<ClientRecordThread>& thread)
// Manage overrun callback
- if (mActive && (cblk->framesAvailable() == 0)) {
+ if (active && (cblk->framesAvailable() == 0)) {
+ // The value of active is stale, but we are almost sure to be active here because
+ // otherwise we would have exited when obtainBuffer returned STOPPED earlier.
ALOGV("Overrun user: %x, server: %x, flags %04x", cblk->user, cblk->server, cblk->flags);
if (!(android_atomic_or(CBLK_UNDERRUN_ON, &cblk->flags) & CBLK_UNDERRUN_MSK)) {
- mCbf(EVENT_OVERRUN, mUserData, 0);
+ mCbf(EVENT_OVERRUN, mUserData, NULL);
}
}
@@ -805,7 +792,7 @@ status_t AudioRecord::restoreRecord_l(audio_track_cblk_t*& cblk)
result = NO_ERROR;
cblk->lock.unlock();
}
- if (result != NO_ERROR || mActive == 0) {
+ if (result != NO_ERROR || !mActive) {
result = status_t(STOPPED);
}
}
@@ -825,23 +812,51 @@ status_t AudioRecord::restoreRecord_l(audio_track_cblk_t*& cblk)
// =========================================================================
-AudioRecord::ClientRecordThread::ClientRecordThread(AudioRecord& receiver, bool bCanCallJava)
- : Thread(bCanCallJava), mReceiver(receiver)
+AudioRecord::AudioRecordThread::AudioRecordThread(AudioRecord& receiver, bool bCanCallJava)
+ : Thread(bCanCallJava), mReceiver(receiver), mPaused(true)
+{
+}
+
+AudioRecord::AudioRecordThread::~AudioRecordThread()
+{
+}
+
+bool AudioRecord::AudioRecordThread::threadLoop()
+{
+ {
+ AutoMutex _l(mMyLock);
+ if (mPaused) {
+ mMyCond.wait(mMyLock);
+ // caller will check for exitPending()
+ return true;
+ }
+ }
+ if (!mReceiver.processAudioBuffer(this)) {
+ pause();
+ }
+ return true;
+}
+
+void AudioRecord::AudioRecordThread::requestExit()
{
+ // must be in this order to avoid a race condition
+ Thread::requestExit();
+ resume();
}
-bool AudioRecord::ClientRecordThread::threadLoop()
+void AudioRecord::AudioRecordThread::pause()
{
- return mReceiver.processAudioBuffer(this);
+ AutoMutex _l(mMyLock);
+ mPaused = true;
}
-status_t AudioRecord::ClientRecordThread::readyToRun()
+void AudioRecord::AudioRecordThread::resume()
{
- AutoMutex(mReceiver.mLock);
- while (mReceiver.mReadyToRun == WOULD_BLOCK) {
- mReceiver.mCondition.wait(mReceiver.mLock);
+ AutoMutex _l(mMyLock);
+ if (mPaused) {
+ mPaused = false;
+ mMyCond.signal();
}
- return mReceiver.mReadyToRun;
}
// -------------------------------------------------------------------------
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 4c41ba5..207f96f 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -41,7 +41,7 @@ DefaultKeyedVector<audio_io_handle_t, AudioSystem::OutputDescriptor *> AudioSyst
// Cached values for recording queries, all protected by gLock
uint32_t AudioSystem::gPrevInSamplingRate = 16000;
audio_format_t AudioSystem::gPrevInFormat = AUDIO_FORMAT_PCM_16_BIT;
-int AudioSystem::gPrevInChannelCount = 1;
+audio_channel_mask_t AudioSystem::gPrevInChannelMask = AUDIO_CHANNEL_IN_MONO;
size_t AudioSystem::gInBuffSize = 0;
@@ -334,25 +334,25 @@ status_t AudioSystem::getLatency(audio_io_handle_t output,
return NO_ERROR;
}
-status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount,
- size_t* buffSize)
+status_t AudioSystem::getInputBufferSize(uint32_t sampleRate, audio_format_t format,
+ audio_channel_mask_t channelMask, size_t* buffSize)
{
gLock.lock();
// Do we have a stale gInBufferSize or are we requesting the input buffer size for new values
size_t inBuffSize = gInBuffSize;
if ((inBuffSize == 0) || (sampleRate != gPrevInSamplingRate) || (format != gPrevInFormat)
- || (channelCount != gPrevInChannelCount)) {
+ || (channelMask != gPrevInChannelMask)) {
gLock.unlock();
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) {
return PERMISSION_DENIED;
}
- inBuffSize = af->getInputBufferSize(sampleRate, format, channelCount);
+ inBuffSize = af->getInputBufferSize(sampleRate, format, channelMask);
gLock.lock();
// save the request params
gPrevInSamplingRate = sampleRate;
gPrevInFormat = format;
- gPrevInChannelCount = channelCount;
+ gPrevInChannelMask = channelMask;
gInBuffSize = inBuffSize;
}
@@ -449,7 +449,7 @@ void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, audio_io_handle
OutputDescriptor *outputDesc = new OutputDescriptor(*desc);
gOutputs.add(ioHandle, outputDesc);
- ALOGV("ioConfigChanged() new output samplingRate %d, format %d channels %d frameCount %d latency %d",
+ ALOGV("ioConfigChanged() new output samplingRate %d, format %d channels %#x frameCount %d latency %d",
outputDesc->samplingRate, outputDesc->format, outputDesc->channels, outputDesc->frameCount, outputDesc->latency);
} break;
case OUTPUT_CLOSED: {
@@ -471,7 +471,7 @@ void AudioSystem::AudioFlingerClient::ioConfigChanged(int event, audio_io_handle
if (param2 == NULL) break;
desc = (const OutputDescriptor *)param2;
- ALOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %d frameCount %d latency %d",
+ ALOGV("ioConfigChanged() new config for output %d samplingRate %d, format %d channels %#x frameCount %d latency %d",
ioHandle, desc->samplingRate, desc->format,
desc->channels, desc->frameCount, desc->latency);
OutputDescriptor *outputDesc = gOutputs.valueAt(index);
@@ -588,12 +588,12 @@ audio_policy_forced_cfg_t AudioSystem::getForceUse(audio_policy_force_use_t usag
audio_io_handle_t AudioSystem::getOutput(audio_stream_type_t stream,
uint32_t samplingRate,
audio_format_t format,
- uint32_t channels,
+ audio_channel_mask_t channelMask,
audio_output_flags_t flags)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return 0;
- return aps->getOutput(stream, samplingRate, format, channels, flags);
+ return aps->getOutput(stream, samplingRate, format, channelMask, flags);
}
status_t AudioSystem::startOutput(audio_io_handle_t output,
@@ -624,13 +624,12 @@ void AudioSystem::releaseOutput(audio_io_handle_t output)
audio_io_handle_t AudioSystem::getInput(audio_source_t inputSource,
uint32_t samplingRate,
audio_format_t format,
- uint32_t channels,
- audio_in_acoustics_t acoustics,
+ audio_channel_mask_t channelMask,
int sessionId)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return 0;
- return aps->getInput(inputSource, samplingRate, format, channels, acoustics, sessionId);
+ return aps->getInput(inputSource, samplingRate, format, channelMask, sessionId);
}
status_t AudioSystem::startInput(audio_io_handle_t input)
@@ -695,14 +694,14 @@ audio_devices_t AudioSystem::getDevicesForStream(audio_stream_type_t stream)
return aps->getDevicesForStream(stream);
}
-audio_io_handle_t AudioSystem::getOutputForEffect(effect_descriptor_t *desc)
+audio_io_handle_t AudioSystem::getOutputForEffect(const effect_descriptor_t *desc)
{
const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
if (aps == 0) return PERMISSION_DENIED;
return aps->getOutputForEffect(desc);
}
-status_t AudioSystem::registerEffect(effect_descriptor_t *desc,
+status_t AudioSystem::registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -736,6 +735,28 @@ status_t AudioSystem::isStreamActive(audio_stream_type_t stream, bool* state, ui
return NO_ERROR;
}
+status_t AudioSystem::isSourceActive(audio_source_t stream, bool* state)
+{
+ const sp<IAudioPolicyService>& aps = AudioSystem::get_audio_policy_service();
+ if (aps == 0) return PERMISSION_DENIED;
+ if (state == NULL) return BAD_VALUE;
+ *state = aps->isSourceActive(stream);
+ return NO_ERROR;
+}
+
+int32_t AudioSystem::getPrimaryOutputSamplingRate()
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return 0;
+ return af->getPrimaryOutputSamplingRate();
+}
+
+int32_t AudioSystem::getPrimaryOutputFrameCount()
+{
+ const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+ if (af == 0) return 0;
+ return af->getPrimaryOutputFrameCount();
+}
void AudioSystem::clearAudioConfigCache()
{
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index e5a60f5..aec8c4a 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -54,6 +54,11 @@ status_t AudioTrack::getMinFrameCount(
audio_stream_type_t streamType,
uint32_t sampleRate)
{
+ if (frameCount == NULL) return BAD_VALUE;
+
+ // default to 0 in case of error
+ *frameCount = 0;
+
// FIXME merge with similar code in createTrack_l(), except we're missing
// some information here that is available in createTrack_l():
// audio_io_handle_t output
@@ -98,7 +103,7 @@ AudioTrack::AudioTrack(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- int channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
audio_output_flags_t flags,
callback_t cbf,
@@ -131,7 +136,8 @@ AudioTrack::AudioTrack(
mIsTimed(false),
mPreviousPriority(ANDROID_PRIORITY_NORMAL), mPreviousSchedulingGroup(SP_DEFAULT)
{
- mStatus = set((audio_stream_type_t)streamType, sampleRate, (audio_format_t)format, channelMask,
+ mStatus = set((audio_stream_type_t)streamType, sampleRate, (audio_format_t)format,
+ (audio_channel_mask_t) channelMask,
frameCount, (audio_output_flags_t)flags, cbf, user, notificationFrames,
0 /*sharedBuffer*/, false /*threadCanCallJava*/, sessionId);
}
@@ -140,7 +146,7 @@ AudioTrack::AudioTrack(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- int channelMask,
+ audio_channel_mask_t channelMask,
const sp<IMemory>& sharedBuffer,
audio_output_flags_t flags,
callback_t cbf,
@@ -181,7 +187,7 @@ status_t AudioTrack::set(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- int channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
audio_output_flags_t flags,
callback_t cbf,
@@ -247,7 +253,7 @@ status_t AudioTrack::set(
}
if (!audio_is_output_channel(channelMask)) {
- ALOGE("Invalid channel mask");
+ ALOGE("Invalid channel mask %#x", channelMask);
return BAD_VALUE;
}
uint32_t channelCount = popcount(channelMask);
@@ -281,7 +287,7 @@ status_t AudioTrack::set(
status_t status = createTrack_l(streamType,
sampleRate,
format,
- (uint32_t)channelMask,
+ channelMask,
frameCount,
flags,
sharedBuffer,
@@ -299,7 +305,7 @@ status_t AudioTrack::set(
mStreamType = streamType;
mFormat = format;
- mChannelMask = (uint32_t)channelMask;
+ mChannelMask = channelMask;
mChannelCount = channelCount;
mSharedBuffer = sharedBuffer;
mMuted = false;
@@ -367,7 +373,6 @@ sp<IMemory>& AudioTrack::sharedBuffer()
void AudioTrack::start()
{
sp<AudioTrackThread> t = mAudioTrackThread;
- status_t status = NO_ERROR;
ALOGV("start %p", this);
@@ -395,6 +400,7 @@ void AudioTrack::start()
}
ALOGV("start %p before lock cblk %p", this, mCblk);
+ status_t status = NO_ERROR;
if (!(cblk->flags & CBLK_INVALID_MSK)) {
cblk->lock.unlock();
ALOGV("mAudioTrack->start()");
@@ -744,7 +750,7 @@ status_t AudioTrack::createTrack_l(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
audio_output_flags_t flags,
const sp<IMemory>& sharedBuffer,
@@ -1138,7 +1144,7 @@ status_t TimedAudioTrack::allocateTimedBuffer(size_t size, sp<IMemory>* buffer)
// If the track is not invalid already, try to allocate a buffer. alloc
// fails indicating that the server is dead, flag the track as invalid so
- // we can attempt to restore in in just a bit.
+ // we can attempt to restore in just a bit.
if (!(mCblk->flags & CBLK_INVALID_MSK)) {
result = mAudioTrack->allocateTimedBuffer(size, buffer);
if (result == DEAD_OBJECT) {
@@ -1435,7 +1441,7 @@ status_t AudioTrack::dump(int fd, const Vector<String16>& args) const
result.append(" AudioTrack::dump\n");
snprintf(buffer, 255, " stream type(%d), left - right volume(%f, %f)\n", mStreamType, mVolume[0], mVolume[1]);
result.append(buffer);
- snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, mCblk->frameCount);
+ snprintf(buffer, 255, " format(%d), channel count(%d), frame count(%d)\n", mFormat, mChannelCount, (mCblk == 0) ? 0 : mCblk->frameCount);
result.append(buffer);
snprintf(buffer, 255, " sample rate(%d), status(%d), muted(%d)\n", (mCblk == 0) ? 0 : mCblk->sampleRate, mStatus, mMuted);
result.append(buffer);
@@ -1472,15 +1478,6 @@ bool AudioTrack::AudioTrackThread::threadLoop()
return true;
}
-status_t AudioTrack::AudioTrackThread::readyToRun()
-{
- return NO_ERROR;
-}
-
-void AudioTrack::AudioTrackThread::onFirstRef()
-{
-}
-
void AudioTrack::AudioTrackThread::requestExit()
{
// must be in this order to avoid a race condition
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index e8dd438..ce8ffc4 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -32,7 +32,7 @@ enum {
CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION,
OPEN_RECORD,
SAMPLE_RATE,
- CHANNEL_COUNT,
+ CHANNEL_COUNT, // obsolete
FORMAT,
FRAME_COUNT,
LATENCY,
@@ -70,7 +70,9 @@ enum {
GET_EFFECT_DESCRIPTOR,
CREATE_EFFECT,
MOVE_EFFECTS,
- LOAD_HW_MODULE
+ LOAD_HW_MODULE,
+ GET_PRIMARY_OUTPUT_SAMPLING_RATE,
+ GET_PRIMARY_OUTPUT_FRAME_COUNT,
};
class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -86,7 +88,7 @@ public:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
track_flags_t flags,
const sp<IMemory>& sharedBuffer,
@@ -135,9 +137,10 @@ public:
audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
track_flags_t flags,
+ pid_t tid,
int *sessionId,
status_t *status)
{
@@ -151,6 +154,7 @@ public:
data.writeInt32(channelMask);
data.writeInt32(frameCount);
data.writeInt32(flags);
+ data.writeInt32((int32_t) tid);
int lSessionId = 0;
if (sessionId != NULL) {
lSessionId = *sessionId;
@@ -182,6 +186,7 @@ public:
return reply.readInt32();
}
+#if 0
virtual int channelCount(audio_io_handle_t output) const
{
Parcel data, reply;
@@ -190,6 +195,7 @@ public:
remote()->transact(CHANNEL_COUNT, data, &reply);
return reply.readInt32();
}
+#endif
virtual audio_format_t format(audio_io_handle_t output) const
{
@@ -347,13 +353,14 @@ public:
remote()->transact(REGISTER_CLIENT, data, &reply);
}
- virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const
+ virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
+ audio_channel_mask_t channelMask) const
{
Parcel data, reply;
data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
data.writeInt32(sampleRate);
data.writeInt32(format);
- data.writeInt32(channelCount);
+ data.writeInt32(channelMask);
remote()->transact(GET_INPUTBUFFERSIZE, data, &reply);
return reply.readInt32();
}
@@ -682,6 +689,23 @@ public:
remote()->transact(LOAD_HW_MODULE, data, &reply);
return (audio_module_handle_t) reply.readInt32();
}
+
+ virtual int32_t getPrimaryOutputSamplingRate()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ remote()->transact(GET_PRIMARY_OUTPUT_SAMPLING_RATE, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual int32_t getPrimaryOutputFrameCount()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioFlinger::getInterfaceDescriptor());
+ remote()->transact(GET_PRIMARY_OUTPUT_FRAME_COUNT, data, &reply);
+ return reply.readInt32();
+ }
+
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -698,7 +722,7 @@ status_t BnAudioFlinger::onTransact(
int streamType = data.readInt32();
uint32_t sampleRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
- int channelCount = data.readInt32();
+ audio_channel_mask_t channelMask = data.readInt32();
size_t bufferCount = data.readInt32();
track_flags_t flags = (track_flags_t) data.readInt32();
sp<IMemory> buffer = interface_cast<IMemory>(data.readStrongBinder());
@@ -708,7 +732,7 @@ status_t BnAudioFlinger::onTransact(
status_t status;
sp<IAudioTrack> track = createTrack(pid,
(audio_stream_type_t) streamType, sampleRate, format,
- channelCount, bufferCount, flags, buffer, output, tid, &sessionId, &status);
+ channelMask, bufferCount, flags, buffer, output, tid, &sessionId, &status);
reply->writeInt32(sessionId);
reply->writeInt32(status);
reply->writeStrongBinder(track->asBinder());
@@ -720,13 +744,14 @@ status_t BnAudioFlinger::onTransact(
audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
uint32_t sampleRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
- int channelCount = data.readInt32();
+ audio_channel_mask_t channelMask = data.readInt32();
size_t bufferCount = data.readInt32();
track_flags_t flags = (track_flags_t) data.readInt32();
+ pid_t tid = (pid_t) data.readInt32();
int sessionId = data.readInt32();
status_t status;
sp<IAudioRecord> record = openRecord(pid, input,
- sampleRate, format, channelCount, bufferCount, flags, &sessionId, &status);
+ sampleRate, format, channelMask, bufferCount, flags, tid, &sessionId, &status);
reply->writeInt32(sessionId);
reply->writeInt32(status);
reply->writeStrongBinder(record->asBinder());
@@ -737,11 +762,13 @@ status_t BnAudioFlinger::onTransact(
reply->writeInt32( sampleRate((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
+#if 0
case CHANNEL_COUNT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
reply->writeInt32( channelCount((audio_io_handle_t) data.readInt32()) );
return NO_ERROR;
} break;
+#endif
case FORMAT: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
reply->writeInt32( format((audio_io_handle_t) data.readInt32()) );
@@ -846,8 +873,8 @@ status_t BnAudioFlinger::onTransact(
CHECK_INTERFACE(IAudioFlinger, data, reply);
uint32_t sampleRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
- int channelCount = data.readInt32();
- reply->writeInt32( getInputBufferSize(sampleRate, format, channelCount) );
+ audio_channel_mask_t channelMask = data.readInt32();
+ reply->writeInt32( getInputBufferSize(sampleRate, format, channelMask) );
return NO_ERROR;
} break;
case OPEN_OUTPUT: {
@@ -1037,6 +1064,16 @@ status_t BnAudioFlinger::onTransact(
reply->writeInt32(loadHwModule(data.readCString()));
return NO_ERROR;
} break;
+ case GET_PRIMARY_OUTPUT_SAMPLING_RATE: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt32(getPrimaryOutputSamplingRate());
+ return NO_ERROR;
+ } break;
+ case GET_PRIMARY_OUTPUT_FRAME_COUNT: {
+ CHECK_INTERFACE(IAudioFlinger, data, reply);
+ reply->writeInt32(getPrimaryOutputFrameCount());
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp
index 7aab8d6..401437c 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libmedia/IAudioPolicyService.cpp
@@ -52,6 +52,7 @@ enum {
REGISTER_EFFECT,
UNREGISTER_EFFECT,
IS_STREAM_ACTIVE,
+ IS_SOURCE_ACTIVE,
GET_DEVICES_FOR_STREAM,
QUERY_DEFAULT_PRE_PROCESSING,
SET_EFFECT_ENABLED
@@ -123,7 +124,7 @@ public:
audio_stream_type_t stream,
uint32_t samplingRate,
audio_format_t format,
- uint32_t channels,
+ audio_channel_mask_t channelMask,
audio_output_flags_t flags)
{
Parcel data, reply;
@@ -131,7 +132,7 @@ public:
data.writeInt32(static_cast <uint32_t>(stream));
data.writeInt32(samplingRate);
data.writeInt32(static_cast <uint32_t>(format));
- data.writeInt32(channels);
+ data.writeInt32(channelMask);
data.writeInt32(static_cast <uint32_t>(flags));
remote()->transact(GET_OUTPUT, data, &reply);
return static_cast <audio_io_handle_t> (reply.readInt32());
@@ -175,8 +176,7 @@ public:
audio_source_t inputSource,
uint32_t samplingRate,
audio_format_t format,
- uint32_t channels,
- audio_in_acoustics_t acoustics,
+ audio_channel_mask_t channelMask,
int audioSession)
{
Parcel data, reply;
@@ -184,8 +184,7 @@ public:
data.writeInt32((int32_t) inputSource);
data.writeInt32(samplingRate);
data.writeInt32(static_cast <uint32_t>(format));
- data.writeInt32(channels);
- data.writeInt32(static_cast <uint32_t>(acoustics));
+ data.writeInt32(channelMask);
data.writeInt32(audioSession);
remote()->transact(GET_INPUT, data, &reply);
return static_cast <audio_io_handle_t> (reply.readInt32());
@@ -276,7 +275,7 @@ public:
return (audio_devices_t) reply.readInt32();
}
- virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc)
+ virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
@@ -285,7 +284,7 @@ public:
return static_cast <audio_io_handle_t> (reply.readInt32());
}
- virtual status_t registerEffect(effect_descriptor_t *desc,
+ virtual status_t registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -331,6 +330,15 @@ public:
return reply.readInt32();
}
+ virtual bool isSourceActive(audio_source_t source) const
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IAudioPolicyService::getInterfaceDescriptor());
+ data.writeInt32((int32_t) source);
+ remote()->transact(IS_SOURCE_ACTIVE, data, &reply);
+ return reply.readInt32();
+ }
+
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count)
@@ -417,14 +425,14 @@ status_t BnAudioPolicyService::onTransact(
static_cast <audio_stream_type_t>(data.readInt32());
uint32_t samplingRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
- uint32_t channels = data.readInt32();
+ audio_channel_mask_t channelMask = data.readInt32();
audio_output_flags_t flags =
static_cast <audio_output_flags_t>(data.readInt32());
audio_io_handle_t output = getOutput(stream,
samplingRate,
format,
- channels,
+ channelMask,
flags);
reply->writeInt32(static_cast <int>(output));
return NO_ERROR;
@@ -464,15 +472,12 @@ status_t BnAudioPolicyService::onTransact(
audio_source_t inputSource = (audio_source_t) data.readInt32();
uint32_t samplingRate = data.readInt32();
audio_format_t format = (audio_format_t) data.readInt32();
- uint32_t channels = data.readInt32();
- audio_in_acoustics_t acoustics =
- static_cast <audio_in_acoustics_t>(data.readInt32());
+ audio_channel_mask_t channelMask = data.readInt32();
int audioSession = data.readInt32();
audio_io_handle_t input = getInput(inputSource,
samplingRate,
format,
- channels,
- acoustics,
+ channelMask,
audioSession);
reply->writeInt32(static_cast <int>(input));
return NO_ERROR;
@@ -597,6 +602,13 @@ status_t BnAudioPolicyService::onTransact(
return NO_ERROR;
} break;
+ case IS_SOURCE_ACTIVE: {
+ CHECK_INTERFACE(IAudioPolicyService, data, reply);
+ audio_source_t source = (audio_source_t) data.readInt32();
+ reply->writeInt32( isSourceActive(source));
+ return NO_ERROR;
+ }
+
case QUERY_DEFAULT_PRE_PROCESSING: {
CHECK_INTERFACE(IAudioPolicyService, data, reply);
int audioSession = data.readInt32();
diff --git a/media/libmedia/IAudioRecord.cpp b/media/libmedia/IAudioRecord.cpp
index 57a80a9..0d06e98 100644
--- a/media/libmedia/IAudioRecord.cpp
+++ b/media/libmedia/IAudioRecord.cpp
@@ -42,7 +42,7 @@ public:
{
}
- virtual status_t start(int event, int triggerSession)
+ virtual status_t start(int /*AudioSystem::sync_event_t*/ event, int triggerSession)
{
Parcel data, reply;
data.writeInterfaceToken(IAudioRecord::getInterfaceDescriptor());
@@ -92,7 +92,7 @@ status_t BnAudioRecord::onTransact(
} break;
case START: {
CHECK_INTERFACE(IAudioRecord, data, reply);
- int event = data.readInt32();
+ int /*AudioSystem::sync_event_t*/ event = data.readInt32();
int triggerSession = data.readInt32();
reply->writeInt32(start(event, triggerSession));
return NO_ERROR;
diff --git a/media/libmedia/IHDCP.cpp b/media/libmedia/IHDCP.cpp
new file mode 100644
index 0000000..493f5a4
--- /dev/null
+++ b/media/libmedia/IHDCP.cpp
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "IHDCP"
+#include <utils/Log.h>
+
+#include <binder/Parcel.h>
+#include <media/IHDCP.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+namespace android {
+
+enum {
+ OBSERVER_NOTIFY = IBinder::FIRST_CALL_TRANSACTION,
+ HDCP_SET_OBSERVER,
+ HDCP_INIT_ASYNC,
+ HDCP_SHUTDOWN_ASYNC,
+ HDCP_ENCRYPT,
+};
+
+struct BpHDCPObserver : public BpInterface<IHDCPObserver> {
+ BpHDCPObserver(const sp<IBinder> &impl)
+ : BpInterface<IHDCPObserver>(impl) {
+ }
+
+ virtual void notify(
+ int msg, int ext1, int ext2, const Parcel *obj) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IHDCPObserver::getInterfaceDescriptor());
+ data.writeInt32(msg);
+ data.writeInt32(ext1);
+ data.writeInt32(ext2);
+ if (obj && obj->dataSize() > 0) {
+ data.appendFrom(const_cast<Parcel *>(obj), 0, obj->dataSize());
+ }
+ remote()->transact(OBSERVER_NOTIFY, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+};
+
+IMPLEMENT_META_INTERFACE(HDCPObserver, "android.hardware.IHDCPObserver");
+
+struct BpHDCP : public BpInterface<IHDCP> {
+ BpHDCP(const sp<IBinder> &impl)
+ : BpInterface<IHDCP>(impl) {
+ }
+
+ virtual status_t setObserver(const sp<IHDCPObserver> &observer) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
+ data.writeStrongBinder(observer->asBinder());
+ remote()->transact(HDCP_SET_OBSERVER, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual status_t initAsync(const char *host, unsigned port) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
+ data.writeCString(host);
+ data.writeInt32(port);
+ remote()->transact(HDCP_INIT_ASYNC, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual status_t shutdownAsync() {
+ Parcel data, reply;
+ data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
+ remote()->transact(HDCP_SHUTDOWN_ASYNC, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual status_t encrypt(
+ const void *inData, size_t size, uint32_t streamCTR,
+ uint64_t *outInputCTR, void *outData) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
+ data.writeInt32(size);
+ data.write(inData, size);
+ data.writeInt32(streamCTR);
+ remote()->transact(HDCP_ENCRYPT, data, &reply);
+
+ status_t err = reply.readInt32();
+
+ if (err != OK) {
+ *outInputCTR = 0;
+
+ return err;
+ }
+
+ *outInputCTR = reply.readInt64();
+ reply.read(outData, size);
+
+ return err;
+ }
+};
+
+IMPLEMENT_META_INTERFACE(HDCP, "android.hardware.IHDCP");
+
+status_t BnHDCPObserver::onTransact(
+ uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
+ switch (code) {
+ case OBSERVER_NOTIFY:
+ {
+ CHECK_INTERFACE(IHDCPObserver, data, reply);
+
+ int msg = data.readInt32();
+ int ext1 = data.readInt32();
+ int ext2 = data.readInt32();
+
+ Parcel obj;
+ if (data.dataAvail() > 0) {
+ obj.appendFrom(
+ const_cast<Parcel *>(&data),
+ data.dataPosition(),
+ data.dataAvail());
+ }
+
+ notify(msg, ext1, ext2, &obj);
+
+ return OK;
+ }
+
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+status_t BnHDCP::onTransact(
+ uint32_t code, const Parcel &data, Parcel *reply, uint32_t flags) {
+ switch (code) {
+ case HDCP_SET_OBSERVER:
+ {
+ CHECK_INTERFACE(IHDCP, data, reply);
+
+ sp<IHDCPObserver> observer =
+ interface_cast<IHDCPObserver>(data.readStrongBinder());
+
+ reply->writeInt32(setObserver(observer));
+ return OK;
+ }
+
+ case HDCP_INIT_ASYNC:
+ {
+ CHECK_INTERFACE(IHDCP, data, reply);
+
+ const char *host = data.readCString();
+ unsigned port = data.readInt32();
+
+ reply->writeInt32(initAsync(host, port));
+ return OK;
+ }
+
+ case HDCP_SHUTDOWN_ASYNC:
+ {
+ CHECK_INTERFACE(IHDCP, data, reply);
+
+ reply->writeInt32(shutdownAsync());
+ return OK;
+ }
+
+ case HDCP_ENCRYPT:
+ {
+ size_t size = data.readInt32();
+
+ void *inData = malloc(2 * size);
+ void *outData = (uint8_t *)inData + size;
+
+ data.read(inData, size);
+
+ uint32_t streamCTR = data.readInt32();
+ uint64_t inputCTR;
+ status_t err = encrypt(inData, size, streamCTR, &inputCTR, outData);
+
+ reply->writeInt32(err);
+
+ if (err == OK) {
+ reply->writeInt64(inputCTR);
+ reply->write(outData, size);
+ }
+
+ free(inData);
+ inData = outData = NULL;
+
+ return OK;
+ }
+
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+} // namespace android
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index 0bb237d..cb07766 100644
--- a/media/libmedia/IMediaPlayer.cpp
+++ b/media/libmedia/IMediaPlayer.cpp
@@ -55,6 +55,7 @@ enum {
SET_PARAMETER,
GET_PARAMETER,
SET_RETRANSMIT_ENDPOINT,
+ GET_RETRANSMIT_ENDPOINT,
SET_NEXT_PLAYER,
};
@@ -292,7 +293,8 @@ public:
return remote()->transact(GET_PARAMETER, data, reply);
}
- status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) {
+ status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint)
+ {
Parcel data, reply;
status_t err;
@@ -319,6 +321,23 @@ public:
remote()->transact(SET_NEXT_PLAYER, data, &reply);
return reply.readInt32();
}
+
+ status_t getRetransmitEndpoint(struct sockaddr_in* endpoint)
+ {
+ Parcel data, reply;
+ status_t err;
+
+ data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
+ err = remote()->transact(GET_RETRANSMIT_ENDPOINT, data, &reply);
+
+ if ((OK != err) || (OK != (err = reply.readInt32()))) {
+ return err;
+ }
+
+ data.read(endpoint, sizeof(*endpoint));
+
+ return err;
+ }
};
IMPLEMENT_META_INTERFACE(MediaPlayer, "android.media.IMediaPlayer");
@@ -498,11 +517,24 @@ status_t BnMediaPlayer::onTransact(
} else {
reply->writeInt32(setRetransmitEndpoint(NULL));
}
+
+ return NO_ERROR;
+ } break;
+ case GET_RETRANSMIT_ENDPOINT: {
+ CHECK_INTERFACE(IMediaPlayer, data, reply);
+
+ struct sockaddr_in endpoint;
+ status_t res = getRetransmitEndpoint(&endpoint);
+
+ reply->writeInt32(res);
+ reply->write(&endpoint, sizeof(endpoint));
+
return NO_ERROR;
} break;
case SET_NEXT_PLAYER: {
CHECK_INTERFACE(IMediaPlayer, data, reply);
reply->writeInt32(setNextPlayer(interface_cast<IMediaPlayer>(data.readStrongBinder())));
+
return NO_ERROR;
} break;
default:
diff --git a/media/libmedia/IMediaPlayerService.cpp b/media/libmedia/IMediaPlayerService.cpp
index 9120617..c0a0260 100644
--- a/media/libmedia/IMediaPlayerService.cpp
+++ b/media/libmedia/IMediaPlayerService.cpp
@@ -21,12 +21,16 @@
#include <binder/Parcel.h>
#include <binder/IMemory.h>
#include <media/ICrypto.h>
+#include <media/IHDCP.h>
#include <media/IMediaPlayerService.h>
#include <media/IMediaRecorder.h>
#include <media/IOMX.h>
+#include <media/IRemoteDisplay.h>
+#include <media/IRemoteDisplayClient.h>
#include <media/IStreamSource.h>
#include <utils/Errors.h> // for status_t
+#include <utils/String8.h>
namespace android {
@@ -38,8 +42,10 @@ enum {
CREATE_METADATA_RETRIEVER,
GET_OMX,
MAKE_CRYPTO,
+ MAKE_HDCP,
ADD_BATTERY_DATA,
- PULL_BATTERY_DATA
+ PULL_BATTERY_DATA,
+ LISTEN_FOR_REMOTE_DISPLAY,
};
class BpMediaPlayerService: public BpInterface<IMediaPlayerService>
@@ -120,6 +126,13 @@ public:
return interface_cast<ICrypto>(reply.readStrongBinder());
}
+ virtual sp<IHDCP> makeHDCP() {
+ Parcel data, reply;
+ data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
+ remote()->transact(MAKE_HDCP, data, &reply);
+ return interface_cast<IHDCP>(reply.readStrongBinder());
+ }
+
virtual void addBatteryData(uint32_t params) {
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
@@ -132,6 +145,17 @@ public:
data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
return remote()->transact(PULL_BATTERY_DATA, data, reply);
}
+
+ virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
+ const String8& iface)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IMediaPlayerService::getInterfaceDescriptor());
+ data.writeStrongBinder(client->asBinder());
+ data.writeString8(iface);
+ remote()->transact(LISTEN_FOR_REMOTE_DISPLAY, data, &reply);
+ return interface_cast<IRemoteDisplay>(reply.readStrongBinder());
+ }
};
IMPLEMENT_META_INTERFACE(MediaPlayerService, "android.media.IMediaPlayerService");
@@ -206,6 +230,12 @@ status_t BnMediaPlayerService::onTransact(
reply->writeStrongBinder(crypto->asBinder());
return NO_ERROR;
} break;
+ case MAKE_HDCP: {
+ CHECK_INTERFACE(IMediaPlayerService, data, reply);
+ sp<IHDCP> hdcp = makeHDCP();
+ reply->writeStrongBinder(hdcp->asBinder());
+ return NO_ERROR;
+ } break;
case ADD_BATTERY_DATA: {
CHECK_INTERFACE(IMediaPlayerService, data, reply);
uint32_t params = data.readInt32();
@@ -217,6 +247,15 @@ status_t BnMediaPlayerService::onTransact(
pullBatteryData(reply);
return NO_ERROR;
} break;
+ case LISTEN_FOR_REMOTE_DISPLAY: {
+ CHECK_INTERFACE(IMediaPlayerService, data, reply);
+ sp<IRemoteDisplayClient> client(
+ interface_cast<IRemoteDisplayClient>(data.readStrongBinder()));
+ String8 iface(data.readString8());
+ sp<IRemoteDisplay> display(listenForRemoteDisplay(client, iface));
+ reply->writeStrongBinder(display->asBinder());
+ return NO_ERROR;
+ } break;
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/IRemoteDisplay.cpp b/media/libmedia/IRemoteDisplay.cpp
new file mode 100644
index 0000000..da25a15
--- /dev/null
+++ b/media/libmedia/IRemoteDisplay.cpp
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <media/IRemoteDisplay.h>
+
+namespace android {
+
+enum {
+ DISPOSE = IBinder::FIRST_CALL_TRANSACTION,
+};
+
+class BpRemoteDisplay: public BpInterface<IRemoteDisplay>
+{
+public:
+ BpRemoteDisplay(const sp<IBinder>& impl)
+ : BpInterface<IRemoteDisplay>(impl)
+ {
+ }
+
+ status_t dispose()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
+ remote()->transact(DISPOSE, data, &reply);
+ return reply.readInt32();
+ }
+};
+
+IMPLEMENT_META_INTERFACE(RemoteDisplay, "android.media.IRemoteDisplay");
+
+// ----------------------------------------------------------------------
+
+status_t BnRemoteDisplay::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+ switch (code) {
+ case DISPOSE: {
+ CHECK_INTERFACE(IRemoteDisplay, data, reply);
+ reply->writeInt32(dispose());
+ return NO_ERROR;
+ }
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+}; // namespace android
diff --git a/media/libmedia/IRemoteDisplayClient.cpp b/media/libmedia/IRemoteDisplayClient.cpp
new file mode 100644
index 0000000..4a1b570
--- /dev/null
+++ b/media/libmedia/IRemoteDisplayClient.cpp
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <media/IRemoteDisplayClient.h>
+#include <gui/ISurfaceTexture.h>
+#include <utils/String8.h>
+
+namespace android {
+
+enum {
+ ON_DISPLAY_CONNECTED = IBinder::FIRST_CALL_TRANSACTION,
+ ON_DISPLAY_DISCONNECTED,
+ ON_DISPLAY_ERROR,
+};
+
+class BpRemoteDisplayClient: public BpInterface<IRemoteDisplayClient>
+{
+public:
+ BpRemoteDisplayClient(const sp<IBinder>& impl)
+ : BpInterface<IRemoteDisplayClient>(impl)
+ {
+ }
+
+ void onDisplayConnected(const sp<ISurfaceTexture>& surfaceTexture,
+ uint32_t width, uint32_t height, uint32_t flags)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
+ data.writeStrongBinder(surfaceTexture->asBinder());
+ data.writeInt32(width);
+ data.writeInt32(height);
+ data.writeInt32(flags);
+ remote()->transact(ON_DISPLAY_CONNECTED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ void onDisplayDisconnected()
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
+ remote()->transact(ON_DISPLAY_DISCONNECTED, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+
+ void onDisplayError(int32_t error)
+ {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplayClient::getInterfaceDescriptor());
+ data.writeInt32(error);
+ remote()->transact(ON_DISPLAY_ERROR, data, &reply, IBinder::FLAG_ONEWAY);
+ }
+};
+
+IMPLEMENT_META_INTERFACE(RemoteDisplayClient, "android.media.IRemoteDisplayClient");
+
+// ----------------------------------------------------------------------
+
+status_t BnRemoteDisplayClient::onTransact(
+ uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags)
+{
+ switch (code) {
+ case ON_DISPLAY_CONNECTED: {
+ CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
+ sp<ISurfaceTexture> surfaceTexture(
+ interface_cast<ISurfaceTexture>(data.readStrongBinder()));
+ uint32_t width = data.readInt32();
+ uint32_t height = data.readInt32();
+ uint32_t flags = data.readInt32();
+ onDisplayConnected(surfaceTexture, width, height, flags);
+ return NO_ERROR;
+ }
+ case ON_DISPLAY_DISCONNECTED: {
+ CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
+ onDisplayDisconnected();
+ return NO_ERROR;
+ }
+ case ON_DISPLAY_ERROR: {
+ CHECK_INTERFACE(IRemoteDisplayClient, data, reply);
+ int32_t error = data.readInt32();
+ onDisplayError(error);
+ return NO_ERROR;
+ }
+ default:
+ return BBinder::onTransact(code, data, reply, flags);
+ }
+}
+
+}; // namespace android
diff --git a/media/libmedia/IStreamSource.cpp b/media/libmedia/IStreamSource.cpp
index 078be94..78d810d 100644
--- a/media/libmedia/IStreamSource.cpp
+++ b/media/libmedia/IStreamSource.cpp
@@ -37,6 +37,7 @@ enum {
SET_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
SET_BUFFERS,
ON_BUFFER_AVAILABLE,
+ FLAGS,
// IStreamListener
QUEUE_BUFFER,
@@ -72,6 +73,14 @@ struct BpStreamSource : public BpInterface<IStreamSource> {
remote()->transact(
ON_BUFFER_AVAILABLE, data, &reply, IBinder::FLAG_ONEWAY);
}
+
+ virtual uint32_t flags() const {
+ Parcel data, reply;
+ data.writeInterfaceToken(IStreamSource::getInterfaceDescriptor());
+ remote()->transact(FLAGS, data, &reply);
+
+ return reply.readInt32();
+ }
};
IMPLEMENT_META_INTERFACE(StreamSource, "android.hardware.IStreamSource");
@@ -109,6 +118,13 @@ status_t BnStreamSource::onTransact(
break;
}
+ case FLAGS:
+ {
+ CHECK_INTERFACE(IStreamSource, data, reply);
+ reply->writeInt32(this->flags());
+ break;
+ }
+
default:
return BBinder::onTransact(code, data, reply, flags);
}
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index 48bbf8f..8319cd7 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -373,7 +373,7 @@ MediaProfiles::getCameraId(const char** atts)
void MediaProfiles::addStartTimeOffset(int cameraId, const char** atts)
{
- int offsetTimeMs = 700;
+ int offsetTimeMs = 1000;
if (atts[2]) {
CHECK(!strcmp("startOffsetMs", atts[2]));
offsetTimeMs = atoi(atts[3]);
diff --git a/media/libmedia/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index de0bf7d..8196e10 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -353,13 +353,4 @@ bool Visualizer::CaptureThread::threadLoop()
return false;
}
-status_t Visualizer::CaptureThread::readyToRun()
-{
- return NO_ERROR;
-}
-
-void Visualizer::CaptureThread::onFirstRef()
-{
-}
-
}; // namespace android
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
index f173e2e..5b5ed71 100644
--- a/media/libmediaplayerservice/Android.mk
+++ b/media/libmediaplayerservice/Android.mk
@@ -9,45 +9,48 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
ActivityManager.cpp \
Crypto.cpp \
- MediaRecorderClient.cpp \
+ HDCP.cpp \
+ MediaPlayerFactory.cpp \
MediaPlayerService.cpp \
+ MediaRecorderClient.cpp \
MetadataRetrieverClient.cpp \
- TestPlayerStub.cpp \
- MidiMetadataRetriever.cpp \
MidiFile.cpp \
+ MidiMetadataRetriever.cpp \
+ RemoteDisplay.cpp \
StagefrightPlayer.cpp \
- StagefrightRecorder.cpp
-
-LOCAL_SHARED_LIBRARIES := \
- libcutils \
- libutils \
- libbinder \
- libvorbisidec \
- libsonivox \
- libmedia \
- libmedia_native \
- libcamera_client \
- libstagefright \
- libstagefright_omx \
- libstagefright_foundation \
- libgui \
- libdl \
- libaah_rtp
-
-LOCAL_STATIC_LIBRARIES := \
- libstagefright_nuplayer \
- libstagefright_rtsp \
-
-LOCAL_C_INCLUDES := \
- $(call include-path-for, graphics corecg) \
- $(TOP)/frameworks/av/media/libstagefright/include \
- $(TOP)/frameworks/av/media/libstagefright/rtsp \
- $(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/external/tremolo/Tremolo \
+ StagefrightRecorder.cpp \
+ TestPlayerStub.cpp \
+
+LOCAL_SHARED_LIBRARIES := \
+ libbinder \
+ libcamera_client \
+ libcutils \
+ libdl \
+ libgui \
+ libmedia \
+ libmedia_native \
+ libsonivox \
+ libstagefright \
+ libstagefright_foundation \
+ libstagefright_omx \
+ libstagefright_wfd \
+ libutils \
+ libvorbisidec \
+
+LOCAL_STATIC_LIBRARIES := \
+ libstagefright_nuplayer \
+ libstagefright_rtsp \
+
+LOCAL_C_INCLUDES := \
+ $(call include-path-for, graphics corecg) \
+ $(TOP)/frameworks/av/media/libstagefright/include \
+ $(TOP)/frameworks/av/media/libstagefright/rtsp \
+ $(TOP)/frameworks/av/media/libstagefright/wifi-display \
+ $(TOP)/frameworks/native/include/media/openmax \
+ $(TOP)/external/tremolo/Tremolo \
LOCAL_MODULE:= libmediaplayerservice
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/media/libmediaplayerservice/HDCP.cpp b/media/libmediaplayerservice/HDCP.cpp
new file mode 100644
index 0000000..09b9719
--- /dev/null
+++ b/media/libmediaplayerservice/HDCP.cpp
@@ -0,0 +1,127 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "HDCP"
+#include <utils/Log.h>
+
+#include "HDCP.h"
+
+#include <media/stagefright/foundation/ADebug.h>
+
+#include <dlfcn.h>
+
+namespace android {
+
+HDCP::HDCP()
+ : mLibHandle(NULL),
+ mHDCPModule(NULL) {
+ mLibHandle = dlopen("libstagefright_hdcp.so", RTLD_NOW);
+
+ if (mLibHandle == NULL) {
+ ALOGE("Unable to locate libstagefright_hdcp.so");
+ return;
+ }
+
+ typedef HDCPModule *(*CreateHDCPModuleFunc)(
+ void *, HDCPModule::ObserverFunc);
+
+ CreateHDCPModuleFunc createHDCPModule =
+ (CreateHDCPModuleFunc)dlsym(mLibHandle, "createHDCPModule");
+
+ if (createHDCPModule == NULL) {
+ ALOGE("Unable to find symbol 'createHDCPModule'.");
+ } else if ((mHDCPModule = createHDCPModule(
+ this, &HDCP::ObserveWrapper)) == NULL) {
+ ALOGE("createHDCPModule failed.");
+ }
+}
+
+HDCP::~HDCP() {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mHDCPModule != NULL) {
+ delete mHDCPModule;
+ mHDCPModule = NULL;
+ }
+
+ if (mLibHandle != NULL) {
+ dlclose(mLibHandle);
+ mLibHandle = NULL;
+ }
+}
+
+status_t HDCP::setObserver(const sp<IHDCPObserver> &observer) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mHDCPModule == NULL) {
+ return NO_INIT;
+ }
+
+ mObserver = observer;
+
+ return OK;
+}
+
+status_t HDCP::initAsync(const char *host, unsigned port) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mHDCPModule == NULL) {
+ return NO_INIT;
+ }
+
+ return mHDCPModule->initAsync(host, port);
+}
+
+status_t HDCP::shutdownAsync() {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mHDCPModule == NULL) {
+ return NO_INIT;
+ }
+
+ return mHDCPModule->shutdownAsync();
+}
+
+status_t HDCP::encrypt(
+ const void *inData, size_t size, uint32_t streamCTR,
+ uint64_t *outInputCTR, void *outData) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mHDCPModule == NULL) {
+ *outInputCTR = 0;
+
+ return NO_INIT;
+ }
+
+ return mHDCPModule->encrypt(inData, size, streamCTR, outInputCTR, outData);
+}
+
+// static
+void HDCP::ObserveWrapper(void *me, int msg, int ext1, int ext2) {
+ static_cast<HDCP *>(me)->observe(msg, ext1, ext2);
+}
+
+void HDCP::observe(int msg, int ext1, int ext2) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mObserver != NULL) {
+ mObserver->notify(msg, ext1, ext2, NULL /* obj */);
+ }
+}
+
+} // namespace android
+
diff --git a/media/libmediaplayerservice/HDCP.h b/media/libmediaplayerservice/HDCP.h
new file mode 100644
index 0000000..b2fc457
--- /dev/null
+++ b/media/libmediaplayerservice/HDCP.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef HDCP_H_
+
+#define HDCP_H_
+
+#include <media/IHDCP.h>
+#include <utils/Mutex.h>
+
+namespace android {
+
+struct HDCP : public BnHDCP {
+ HDCP();
+ virtual ~HDCP();
+
+ virtual status_t setObserver(const sp<IHDCPObserver> &observer);
+ virtual status_t initAsync(const char *host, unsigned port);
+ virtual status_t shutdownAsync();
+
+ virtual status_t encrypt(
+ const void *inData, size_t size, uint32_t streamCTR,
+ uint64_t *outInputCTR, void *outData);
+
+private:
+ Mutex mLock;
+
+ void *mLibHandle;
+ HDCPModule *mHDCPModule;
+ sp<IHDCPObserver> mObserver;
+
+ static void ObserveWrapper(void *me, int msg, int ext1, int ext2);
+ void observe(int msg, int ext1, int ext2);
+
+ DISALLOW_EVIL_CONSTRUCTORS(HDCP);
+};
+
+} // namespace android
+
+#endif // HDCP_H_
+
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.cpp b/media/libmediaplayerservice/MediaPlayerFactory.cpp
new file mode 100644
index 0000000..3f69c11
--- /dev/null
+++ b/media/libmediaplayerservice/MediaPlayerFactory.cpp
@@ -0,0 +1,340 @@
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#define LOG_TAG "MediaPlayerFactory"
+#include <utils/Log.h>
+
+#include <cutils/properties.h>
+#include <media/IMediaPlayer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <utils/Errors.h>
+#include <utils/misc.h>
+
+#include "MediaPlayerFactory.h"
+
+#include "MidiFile.h"
+#include "TestPlayerStub.h"
+#include "StagefrightPlayer.h"
+#include "nuplayer/NuPlayerDriver.h"
+
+namespace android {
+
+Mutex MediaPlayerFactory::sLock;
+MediaPlayerFactory::tFactoryMap MediaPlayerFactory::sFactoryMap;
+bool MediaPlayerFactory::sInitComplete = false;
+
+status_t MediaPlayerFactory::registerFactory_l(IFactory* factory,
+ player_type type) {
+ if (NULL == factory) {
+ ALOGE("Failed to register MediaPlayerFactory of type %d, factory is"
+ " NULL.", type);
+ return BAD_VALUE;
+ }
+
+ if (sFactoryMap.indexOfKey(type) >= 0) {
+ ALOGE("Failed to register MediaPlayerFactory of type %d, type is"
+ " already registered.", type);
+ return ALREADY_EXISTS;
+ }
+
+ if (sFactoryMap.add(type, factory) < 0) {
+ ALOGE("Failed to register MediaPlayerFactory of type %d, failed to add"
+ " to map.", type);
+ return UNKNOWN_ERROR;
+ }
+
+ return OK;
+}
+
+player_type MediaPlayerFactory::getDefaultPlayerType() {
+ char value[PROPERTY_VALUE_MAX];
+ if (property_get("media.stagefright.use-nuplayer", value, NULL)
+ && (!strcmp("1", value) || !strcasecmp("true", value))) {
+ return NU_PLAYER;
+ }
+
+ return STAGEFRIGHT_PLAYER;
+}
+
+status_t MediaPlayerFactory::registerFactory(IFactory* factory,
+ player_type type) {
+ Mutex::Autolock lock_(&sLock);
+ return registerFactory_l(factory, type);
+}
+
+void MediaPlayerFactory::unregisterFactory(player_type type) {
+ Mutex::Autolock lock_(&sLock);
+ sFactoryMap.removeItem(type);
+}
+
+#define GET_PLAYER_TYPE_IMPL(a...) \
+ Mutex::Autolock lock_(&sLock); \
+ \
+ player_type ret = STAGEFRIGHT_PLAYER; \
+ float bestScore = 0.0; \
+ \
+ for (size_t i = 0; i < sFactoryMap.size(); ++i) { \
+ \
+ IFactory* v = sFactoryMap.valueAt(i); \
+ float thisScore; \
+ CHECK(v != NULL); \
+ thisScore = v->scoreFactory(a, bestScore); \
+ if (thisScore > bestScore) { \
+ ret = sFactoryMap.keyAt(i); \
+ bestScore = thisScore; \
+ } \
+ } \
+ \
+ if (0.0 == bestScore) { \
+ bestScore = getDefaultPlayerType(); \
+ } \
+ \
+ return ret;
+
+player_type MediaPlayerFactory::getPlayerType(const sp<IMediaPlayer>& client,
+ const char* url) {
+ GET_PLAYER_TYPE_IMPL(client, url);
+}
+
+player_type MediaPlayerFactory::getPlayerType(const sp<IMediaPlayer>& client,
+ int fd,
+ int64_t offset,
+ int64_t length) {
+ GET_PLAYER_TYPE_IMPL(client, fd, offset, length);
+}
+
+player_type MediaPlayerFactory::getPlayerType(const sp<IMediaPlayer>& client,
+ const sp<IStreamSource> &source) {
+ GET_PLAYER_TYPE_IMPL(client, source);
+}
+
+#undef GET_PLAYER_TYPE_IMPL
+
+sp<MediaPlayerBase> MediaPlayerFactory::createPlayer(
+ player_type playerType,
+ void* cookie,
+ notify_callback_f notifyFunc) {
+ sp<MediaPlayerBase> p;
+ IFactory* factory;
+ status_t init_result;
+ Mutex::Autolock lock_(&sLock);
+
+ if (sFactoryMap.indexOfKey(playerType) < 0) {
+ ALOGE("Failed to create player object of type %d, no registered"
+ " factory", playerType);
+ return p;
+ }
+
+ factory = sFactoryMap.valueFor(playerType);
+ CHECK(NULL != factory);
+ p = factory->createPlayer();
+
+ if (p == NULL) {
+ ALOGE("Failed to create player object of type %d, create failed",
+ playerType);
+ return p;
+ }
+
+ init_result = p->initCheck();
+ if (init_result == NO_ERROR) {
+ p->setNotifyCallback(cookie, notifyFunc);
+ } else {
+ ALOGE("Failed to create player object of type %d, initCheck failed"
+ " (res = %d)", playerType, init_result);
+ p.clear();
+ }
+
+ return p;
+}
+
+/*****************************************************************************
+ * *
+ * Built-In Factory Implementations *
+ * *
+ *****************************************************************************/
+
+class StagefrightPlayerFactory :
+ public MediaPlayerFactory::IFactory {
+ public:
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ int fd,
+ int64_t offset,
+ int64_t length,
+ float curScore) {
+ char buf[20];
+ lseek(fd, offset, SEEK_SET);
+ read(fd, buf, sizeof(buf));
+ lseek(fd, offset, SEEK_SET);
+
+ long ident = *((long*)buf);
+
+ // Ogg vorbis?
+ if (ident == 0x5367674f) // 'OggS'
+ return 1.0;
+
+ return 0.0;
+ }
+
+ virtual sp<MediaPlayerBase> createPlayer() {
+ ALOGV(" create StagefrightPlayer");
+ return new StagefrightPlayer();
+ }
+};
+
+class NuPlayerFactory : public MediaPlayerFactory::IFactory {
+ public:
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const char* url,
+ float curScore) {
+ static const float kOurScore = 0.8;
+
+ if (kOurScore <= curScore)
+ return 0.0;
+
+ if (!strncasecmp("http://", url, 7)
+ || !strncasecmp("https://", url, 8)) {
+ size_t len = strlen(url);
+ if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
+ return kOurScore;
+ }
+
+ if (strstr(url,"m3u8")) {
+ return kOurScore;
+ }
+ }
+
+ if (!strncasecmp("rtsp://", url, 7)) {
+ return kOurScore;
+ }
+
+ return 0.0;
+ }
+
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const sp<IStreamSource> &source,
+ float curScore) {
+ return 1.0;
+ }
+
+ virtual sp<MediaPlayerBase> createPlayer() {
+ ALOGV(" create NuPlayer");
+ return new NuPlayerDriver;
+ }
+};
+
+class SonivoxPlayerFactory : public MediaPlayerFactory::IFactory {
+ public:
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const char* url,
+ float curScore) {
+ static const float kOurScore = 0.4;
+ static const char* const FILE_EXTS[] = { ".mid",
+ ".midi",
+ ".smf",
+ ".xmf",
+ ".mxmf",
+ ".imy",
+ ".rtttl",
+ ".rtx",
+ ".ota" };
+ if (kOurScore <= curScore)
+ return 0.0;
+
+ // use MidiFile for MIDI extensions
+ int lenURL = strlen(url);
+ for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
+ int len = strlen(FILE_EXTS[i]);
+ int start = lenURL - len;
+ if (start > 0) {
+ if (!strncasecmp(url + start, FILE_EXTS[i], len)) {
+ return kOurScore;
+ }
+ }
+ }
+
+ return 0.0;
+ }
+
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ int fd,
+ int64_t offset,
+ int64_t length,
+ float curScore) {
+ static const float kOurScore = 0.8;
+
+ if (kOurScore <= curScore)
+ return 0.0;
+
+ // Some kind of MIDI?
+ EAS_DATA_HANDLE easdata;
+ if (EAS_Init(&easdata) == EAS_SUCCESS) {
+ EAS_FILE locator;
+ locator.path = NULL;
+ locator.fd = fd;
+ locator.offset = offset;
+ locator.length = length;
+ EAS_HANDLE eashandle;
+ if (EAS_OpenFile(easdata, &locator, &eashandle) == EAS_SUCCESS) {
+ EAS_CloseFile(easdata, eashandle);
+ EAS_Shutdown(easdata);
+ return kOurScore;
+ }
+ EAS_Shutdown(easdata);
+ }
+
+ return 0.0;
+ }
+
+ virtual sp<MediaPlayerBase> createPlayer() {
+ ALOGV(" create MidiFile");
+ return new MidiFile();
+ }
+};
+
+class TestPlayerFactory : public MediaPlayerFactory::IFactory {
+ public:
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const char* url,
+ float curScore) {
+ if (TestPlayerStub::canBeUsed(url)) {
+ return 1.0;
+ }
+
+ return 0.0;
+ }
+
+ virtual sp<MediaPlayerBase> createPlayer() {
+ ALOGV("Create Test Player stub");
+ return new TestPlayerStub();
+ }
+};
+
+void MediaPlayerFactory::registerBuiltinFactories() {
+ Mutex::Autolock lock_(&sLock);
+
+ if (sInitComplete)
+ return;
+
+ registerFactory_l(new StagefrightPlayerFactory(), STAGEFRIGHT_PLAYER);
+ registerFactory_l(new NuPlayerFactory(), NU_PLAYER);
+ registerFactory_l(new SonivoxPlayerFactory(), SONIVOX_PLAYER);
+ registerFactory_l(new TestPlayerFactory(), TEST_PLAYER);
+
+ sInitComplete = true;
+}
+
+} // namespace android
diff --git a/media/libmediaplayerservice/MediaPlayerFactory.h b/media/libmediaplayerservice/MediaPlayerFactory.h
new file mode 100644
index 0000000..fe8972b
--- /dev/null
+++ b/media/libmediaplayerservice/MediaPlayerFactory.h
@@ -0,0 +1,84 @@
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+
+#ifndef ANDROID_MEDIAPLAYERFACTORY_H
+#define ANDROID_MEDIAPLAYERFACTORY_H
+
+#include <media/MediaPlayerInterface.h>
+#include <media/stagefright/foundation/ABase.h>
+
+namespace android {
+
+class MediaPlayerFactory {
+ public:
+ class IFactory {
+ public:
+ virtual ~IFactory() { }
+
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const char* url,
+ float curScore) { return 0.0; }
+
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ int fd,
+ int64_t offset,
+ int64_t length,
+ float curScore) { return 0.0; }
+
+ virtual float scoreFactory(const sp<IMediaPlayer>& client,
+ const sp<IStreamSource> &source,
+ float curScore) { return 0.0; }
+
+ virtual sp<MediaPlayerBase> createPlayer() = 0;
+ };
+
+ static status_t registerFactory(IFactory* factory,
+ player_type type);
+ static void unregisterFactory(player_type type);
+ static player_type getPlayerType(const sp<IMediaPlayer>& client,
+ const char* url);
+ static player_type getPlayerType(const sp<IMediaPlayer>& client,
+ int fd,
+ int64_t offset,
+ int64_t length);
+ static player_type getPlayerType(const sp<IMediaPlayer>& client,
+ const sp<IStreamSource> &source);
+
+ static sp<MediaPlayerBase> createPlayer(player_type playerType,
+ void* cookie,
+ notify_callback_f notifyFunc);
+
+ static void registerBuiltinFactories();
+
+ private:
+ typedef KeyedVector<player_type, IFactory*> tFactoryMap;
+
+ MediaPlayerFactory() { }
+
+ static status_t registerFactory_l(IFactory* factory,
+ player_type type);
+ static player_type getDefaultPlayerType();
+
+ static Mutex sLock;
+ static tFactoryMap sFactoryMap;
+ static bool sInitComplete;
+
+ DISALLOW_EVIL_CONSTRUCTORS(MediaPlayerFactory);
+};
+
+} // namespace android
+#endif // ANDROID_MEDIAPLAYERFACTORY_H
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index c47fbd6..9bedff1 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -43,8 +43,9 @@
#include <utils/String8.h>
#include <utils/SystemClock.h>
#include <utils/Vector.h>
-#include <cutils/properties.h>
+#include <media/IRemoteDisplay.h>
+#include <media/IRemoteDisplayClient.h>
#include <media/MediaPlayerInterface.h>
#include <media/mediarecorder.h>
#include <media/MediaMetadataRetrieverInterface.h>
@@ -61,6 +62,7 @@
#include "MediaRecorderClient.h"
#include "MediaPlayerService.h"
#include "MetadataRetrieverClient.h"
+#include "MediaPlayerFactory.h"
#include "MidiFile.h"
#include "TestPlayerStub.h"
@@ -70,11 +72,8 @@
#include <OMX.h>
#include "Crypto.h"
-
-namespace android {
-sp<MediaPlayerBase> createAAH_TXPlayer();
-sp<MediaPlayerBase> createAAH_RXPlayer();
-}
+#include "HDCP.h"
+#include "RemoteDisplay.h"
namespace {
using android::media::Metadata;
@@ -194,22 +193,6 @@ static bool checkPermission(const char* permissionString) {
return ok;
}
-// TODO: Temp hack until we can register players
-typedef struct {
- const char *extension;
- const player_type playertype;
-} extmap;
-extmap FILE_EXTS [] = {
- {".mid", SONIVOX_PLAYER},
- {".midi", SONIVOX_PLAYER},
- {".smf", SONIVOX_PLAYER},
- {".xmf", SONIVOX_PLAYER},
- {".imy", SONIVOX_PLAYER},
- {".rtttl", SONIVOX_PLAYER},
- {".rtx", SONIVOX_PLAYER},
- {".ota", SONIVOX_PLAYER},
-};
-
// TODO: Find real cause of Audio/Video delay in PV framework and remove this workaround
/* static */ int MediaPlayerService::AudioOutput::mMinBufferCount = 4;
/* static */ bool MediaPlayerService::AudioOutput::mIsOnEmulator = false;
@@ -232,6 +215,8 @@ MediaPlayerService::MediaPlayerService()
}
// speaker is on by default
mBatteryAudio.deviceOn[SPEAKER] = 1;
+
+ MediaPlayerFactory::registerBuiltinFactories();
}
MediaPlayerService::~MediaPlayerService()
@@ -297,6 +282,19 @@ sp<ICrypto> MediaPlayerService::makeCrypto() {
return new Crypto;
}
+sp<IHDCP> MediaPlayerService::makeHDCP() {
+ return new HDCP;
+}
+
+sp<IRemoteDisplay> MediaPlayerService::listenForRemoteDisplay(
+ const sp<IRemoteDisplayClient>& client, const String8& iface) {
+ if (!checkPermission("android.permission.CONTROL_WIFI_DISPLAY")) {
+ return NULL;
+ }
+
+ return new RemoteDisplay(client, iface.string());
+}
+
status_t MediaPlayerService::AudioCache::dump(int fd, const Vector<String16>& args) const
{
const size_t SIZE = 256;
@@ -545,174 +543,6 @@ void MediaPlayerService::Client::disconnect()
IPCThreadState::self()->flushCommands();
}
-static player_type getDefaultPlayerType() {
- char value[PROPERTY_VALUE_MAX];
- if (property_get("media.stagefright.use-nuplayer", value, NULL)
- && (!strcmp("1", value) || !strcasecmp("true", value))) {
- return NU_PLAYER;
- }
-
- return STAGEFRIGHT_PLAYER;
-}
-
-player_type getPlayerType(int fd, int64_t offset, int64_t length)
-{
- char buf[20];
- lseek(fd, offset, SEEK_SET);
- read(fd, buf, sizeof(buf));
- lseek(fd, offset, SEEK_SET);
-
- long ident = *((long*)buf);
-
- // Ogg vorbis?
- if (ident == 0x5367674f) // 'OggS'
- return STAGEFRIGHT_PLAYER;
-
- // Some kind of MIDI?
- EAS_DATA_HANDLE easdata;
- if (EAS_Init(&easdata) == EAS_SUCCESS) {
- EAS_FILE locator;
- locator.path = NULL;
- locator.fd = fd;
- locator.offset = offset;
- locator.length = length;
- EAS_HANDLE eashandle;
- if (EAS_OpenFile(easdata, &locator, &eashandle) == EAS_SUCCESS) {
- EAS_CloseFile(easdata, eashandle);
- EAS_Shutdown(easdata);
- return SONIVOX_PLAYER;
- }
- EAS_Shutdown(easdata);
- }
-
- return getDefaultPlayerType();
-}
-
-player_type getPlayerType(const char* url)
-{
- if (TestPlayerStub::canBeUsed(url)) {
- return TEST_PLAYER;
- }
-
- if (!strncasecmp("http://", url, 7)
- || !strncasecmp("https://", url, 8)) {
- size_t len = strlen(url);
- if (len >= 5 && !strcasecmp(".m3u8", &url[len - 5])) {
- return NU_PLAYER;
- }
-
- if (strstr(url,"m3u8")) {
- return NU_PLAYER;
- }
- }
-
- if (!strncasecmp("rtsp://", url, 7)) {
- return NU_PLAYER;
- }
-
- if (!strncasecmp("aahRX://", url, 8)) {
- return AAH_RX_PLAYER;
- }
-
- // use MidiFile for MIDI extensions
- int lenURL = strlen(url);
- for (int i = 0; i < NELEM(FILE_EXTS); ++i) {
- int len = strlen(FILE_EXTS[i].extension);
- int start = lenURL - len;
- if (start > 0) {
- if (!strncasecmp(url + start, FILE_EXTS[i].extension, len)) {
- return FILE_EXTS[i].playertype;
- }
- }
- }
-
- return getDefaultPlayerType();
-}
-
-player_type MediaPlayerService::Client::getPlayerType(int fd,
- int64_t offset,
- int64_t length)
-{
- // Until re-transmit functionality is added to the existing core android
- // players, we use the special AAH TX player whenever we were configured
- // for retransmission.
- if (mRetransmitEndpointValid) {
- return AAH_TX_PLAYER;
- }
-
- return android::getPlayerType(fd, offset, length);
-}
-
-player_type MediaPlayerService::Client::getPlayerType(const char* url)
-{
- // Until re-transmit functionality is added to the existing core android
- // players, we use the special AAH TX player whenever we were configured
- // for retransmission.
- if (mRetransmitEndpointValid) {
- return AAH_TX_PLAYER;
- }
-
- return android::getPlayerType(url);
-}
-
-player_type MediaPlayerService::Client::getPlayerType(
- const sp<IStreamSource> &source) {
- // Until re-transmit functionality is added to the existing core android
- // players, we use the special AAH TX player whenever we were configured
- // for retransmission.
- if (mRetransmitEndpointValid) {
- return AAH_TX_PLAYER;
- }
-
- return NU_PLAYER;
-}
-
-static sp<MediaPlayerBase> createPlayer(player_type playerType, void* cookie,
- notify_callback_f notifyFunc)
-{
- sp<MediaPlayerBase> p;
- switch (playerType) {
- case SONIVOX_PLAYER:
- ALOGV(" create MidiFile");
- p = new MidiFile();
- break;
- case STAGEFRIGHT_PLAYER:
- ALOGV(" create StagefrightPlayer");
- p = new StagefrightPlayer;
- break;
- case NU_PLAYER:
- ALOGV(" create NuPlayer");
- p = new NuPlayerDriver;
- break;
- case TEST_PLAYER:
- ALOGV("Create Test Player stub");
- p = new TestPlayerStub();
- break;
- case AAH_RX_PLAYER:
- ALOGV(" create A@H RX Player");
- p = createAAH_RXPlayer();
- break;
- case AAH_TX_PLAYER:
- ALOGV(" create A@H TX Player");
- p = createAAH_TXPlayer();
- break;
- default:
- ALOGE("Unknown player type: %d", playerType);
- return NULL;
- }
- if (p != NULL) {
- if (p->initCheck() == NO_ERROR) {
- p->setNotifyCallback(cookie, notifyFunc);
- } else {
- p.clear();
- }
- }
- if (p == NULL) {
- ALOGE("Failed to create player object");
- }
- return p;
-}
-
sp<MediaPlayerBase> MediaPlayerService::Client::createPlayer(player_type playerType)
{
// determine if we have the right player type
@@ -722,7 +552,7 @@ sp<MediaPlayerBase> MediaPlayerService::Client::createPlayer(player_type playerT
p.clear();
}
if (p == NULL) {
- p = android::createPlayer(playerType, this, notify);
+ p = MediaPlayerFactory::createPlayer(playerType, this, notify);
}
if (p != NULL) {
@@ -805,7 +635,7 @@ status_t MediaPlayerService::Client::setDataSource(
close(fd);
return mStatus;
} else {
- player_type playerType = getPlayerType(url);
+ player_type playerType = MediaPlayerFactory::getPlayerType(this, url);
sp<MediaPlayerBase> p = setDataSource_pre(playerType);
if (p == NULL) {
return NO_INIT;
@@ -842,10 +672,10 @@ status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64
ALOGV("calculated length = %lld", length);
}
- // Until re-transmit functionality is added to the existing core android
- // players, we use the special AAH TX player whenever we were configured for
- // retransmission.
- player_type playerType = getPlayerType(fd, offset, length);
+ player_type playerType = MediaPlayerFactory::getPlayerType(this,
+ fd,
+ offset,
+ length);
sp<MediaPlayerBase> p = setDataSource_pre(playerType);
if (p == NULL) {
return NO_INIT;
@@ -859,10 +689,7 @@ status_t MediaPlayerService::Client::setDataSource(int fd, int64_t offset, int64
status_t MediaPlayerService::Client::setDataSource(
const sp<IStreamSource> &source) {
// create the right type of player
- // Until re-transmit functionality is added to the existing core android
- // players, we use the special AAH TX player whenever we were configured for
- // retransmission.
- player_type playerType = getPlayerType(source);
+ player_type playerType = MediaPlayerFactory::getPlayerType(this, source);
sp<MediaPlayerBase> p = setDataSource_pre(playerType);
if (p == NULL) {
return NO_INIT;
@@ -1084,15 +911,22 @@ status_t MediaPlayerService::Client::setNextPlayer(const sp<IMediaPlayer>& playe
Mutex::Autolock l(mLock);
sp<Client> c = static_cast<Client*>(player.get());
mNextClient = c;
- if (mAudioOutput != NULL && c != NULL) {
- mAudioOutput->setNextOutput(c->mAudioOutput);
- } else {
- ALOGE("no current audio output");
+
+ if (c != NULL) {
+ if (mAudioOutput != NULL) {
+ mAudioOutput->setNextOutput(c->mAudioOutput);
+ } else if ((mPlayer != NULL) && !mPlayer->hardwareOutput()) {
+ ALOGE("no current audio output");
+ }
+
+ if ((mPlayer != NULL) && (mNextClient->getPlayer() != NULL)) {
+ mPlayer->setNextPlayer(mNextClient->getPlayer());
+ }
}
+
return OK;
}
-
status_t MediaPlayerService::Client::seekTo(int msec)
{
ALOGV("[%d] seekTo(%d)", mConnId, msec);
@@ -1209,15 +1043,40 @@ status_t MediaPlayerService::Client::setRetransmitEndpoint(
return NO_ERROR;
}
+status_t MediaPlayerService::Client::getRetransmitEndpoint(
+ struct sockaddr_in* endpoint)
+{
+ if (NULL == endpoint)
+ return BAD_VALUE;
+
+ sp<MediaPlayerBase> p = getPlayer();
+
+ if (p != NULL)
+ return p->getRetransmitEndpoint(endpoint);
+
+ if (!mRetransmitEndpointValid)
+ return NO_INIT;
+
+ *endpoint = mRetransmitEndpoint;
+
+ return NO_ERROR;
+}
+
void MediaPlayerService::Client::notify(
void* cookie, int msg, int ext1, int ext2, const Parcel *obj)
{
Client* client = static_cast<Client*>(cookie);
+ if (client == NULL) {
+ return;
+ }
+ sp<IMediaPlayerClient> c;
{
Mutex::Autolock l(client->mLock);
+ c = client->mClient;
if (msg == MEDIA_PLAYBACK_COMPLETE && client->mNextClient != NULL) {
- client->mAudioOutput->switchToNextOutput();
+ if (client->mAudioOutput != NULL)
+ client->mAudioOutput->switchToNextOutput();
client->mNextClient->start();
client->mNextClient->mClient->notify(MEDIA_INFO, MEDIA_INFO_STARTED_AS_NEXT, 0, obj);
}
@@ -1235,8 +1094,11 @@ void MediaPlayerService::Client::notify(
// also access mMetadataUpdated and clears it.
client->addNewMetadataUpdate(metadata_type);
}
- ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
- client->mClient->notify(msg, ext1, ext2, obj);
+
+ if (c != NULL) {
+ ALOGV("[%d] notify (%p, %d, %d, %d)", client->mConnId, cookie, msg, ext1, ext2);
+ c->notify(msg, ext1, ext2, obj);
+ }
}
@@ -1315,12 +1177,13 @@ sp<IMemory> MediaPlayerService::decode(const char* url, uint32_t *pSampleRate, i
return mem;
}
- player_type playerType = getPlayerType(url);
+ player_type playerType =
+ MediaPlayerFactory::getPlayerType(NULL /* client */, url);
ALOGV("player type = %d", playerType);
// create the right type of player
sp<AudioCache> cache = new AudioCache(url);
- player = android::createPlayer(playerType, cache.get(), cache->notify);
+ player = MediaPlayerFactory::createPlayer(playerType, cache.get(), cache->notify);
if (player == NULL) goto Exit;
if (player->hardwareOutput()) goto Exit;
@@ -1362,12 +1225,15 @@ sp<IMemory> MediaPlayerService::decode(int fd, int64_t offset, int64_t length, u
sp<MemoryBase> mem;
sp<MediaPlayerBase> player;
- player_type playerType = getPlayerType(fd, offset, length);
+ player_type playerType = MediaPlayerFactory::getPlayerType(NULL /* client */,
+ fd,
+ offset,
+ length);
ALOGV("player type = %d", playerType);
// create the right type of player
sp<AudioCache> cache = new AudioCache("decode_fd");
- player = android::createPlayer(playerType, cache.get(), cache->notify);
+ player = MediaPlayerFactory::createPlayer(playerType, cache.get(), cache->notify);
if (player == NULL) goto Exit;
if (player->hardwareOutput()) goto Exit;
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 95b1b05..fd648df 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -41,6 +41,8 @@ class AudioTrack;
class IMediaRecorder;
class IMediaMetadataRetriever;
class IOMX;
+class IRemoteDisplay;
+class IRemoteDisplayClient;
class MediaRecorderClient;
#define CALLBACK_ANTAGONIZER 0
@@ -247,7 +249,10 @@ public:
virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat);
virtual sp<IOMX> getOMX();
virtual sp<ICrypto> makeCrypto();
+ virtual sp<IHDCP> makeHDCP();
+ virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
+ const String8& iface);
virtual status_t dump(int fd, const Vector<String16>& args);
void removeClient(wp<Client> client);
@@ -299,7 +304,6 @@ public:
private:
class Client : public BnMediaPlayer {
-
// IMediaPlayer interface
virtual void disconnect();
virtual status_t setVideoSurfaceTexture(
@@ -326,6 +330,7 @@ private:
virtual status_t setParameter(int key, const Parcel &request);
virtual status_t getParameter(int key, Parcel *reply);
virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint);
+ virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint);
virtual status_t setNextPlayer(const sp<IMediaPlayer>& player);
sp<MediaPlayerBase> createPlayer(player_type playerType);
@@ -342,10 +347,6 @@ private:
void setDataSource_post(const sp<MediaPlayerBase>& p,
status_t status);
- player_type getPlayerType(int fd, int64_t offset, int64_t length);
- player_type getPlayerType(const char* url);
- player_type getPlayerType(const sp<IStreamSource> &source);
-
static void notify(void* cookie, int msg,
int ext1, int ext2, const Parcel *obj);
diff --git a/media/libmediaplayerservice/MetadataRetrieverClient.cpp b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
index e44031e..348957f 100644
--- a/media/libmediaplayerservice/MetadataRetrieverClient.cpp
+++ b/media/libmediaplayerservice/MetadataRetrieverClient.cpp
@@ -37,12 +37,10 @@
#include "MidiMetadataRetriever.h"
#include "MetadataRetrieverClient.h"
#include "StagefrightMetadataRetriever.h"
+#include "MediaPlayerFactory.h"
namespace android {
-extern player_type getPlayerType(const char* url);
-extern player_type getPlayerType(int fd, int64_t offset, int64_t length);
-
MetadataRetrieverClient::MetadataRetrieverClient(pid_t pid)
{
ALOGV("MetadataRetrieverClient constructor pid(%d)", pid);
@@ -115,7 +113,17 @@ status_t MetadataRetrieverClient::setDataSource(
if (url == NULL) {
return UNKNOWN_ERROR;
}
- player_type playerType = getPlayerType(url);
+
+ // When asking the MediaPlayerFactory subsystem to choose a media player for
+ // a given URL, a pointer to an outer IMediaPlayer can be passed to the
+ // factory system to be taken into consideration along with the URL. In the
+ // case of choosing an instance of a MediaPlayerBase for a
+ // MetadataRetrieverClient, there is no outer IMediaPlayer which will
+ // eventually encapsulate the result of this selection. In this case, just
+ // pass NULL to getPlayerType to indicate that there is no outer
+ // IMediaPlayer to consider during selection.
+ player_type playerType =
+ MediaPlayerFactory::getPlayerType(NULL /* client */, url);
ALOGV("player type = %d", playerType);
sp<MediaMetadataRetrieverBase> p = createRetriever(playerType);
if (p == NULL) return NO_INIT;
@@ -150,7 +158,11 @@ status_t MetadataRetrieverClient::setDataSource(int fd, int64_t offset, int64_t
ALOGV("calculated length = %lld", length);
}
- player_type playerType = getPlayerType(fd, offset, length);
+ player_type playerType =
+ MediaPlayerFactory::getPlayerType(NULL /* client */,
+ fd,
+ offset,
+ length);
ALOGV("player type = %d", playerType);
sp<MediaMetadataRetrieverBase> p = createRetriever(playerType);
if (p == NULL) {
diff --git a/media/libmediaplayerservice/RemoteDisplay.cpp b/media/libmediaplayerservice/RemoteDisplay.cpp
new file mode 100644
index 0000000..5baa3ad
--- /dev/null
+++ b/media/libmediaplayerservice/RemoteDisplay.cpp
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "RemoteDisplay.h"
+
+#include "ANetworkSession.h"
+#include "source/WifiDisplaySource.h"
+
+#include <media/IRemoteDisplayClient.h>
+
+namespace android {
+
+RemoteDisplay::RemoteDisplay(
+ const sp<IRemoteDisplayClient> &client, const char *iface)
+ : mLooper(new ALooper),
+ mNetSession(new ANetworkSession),
+ mSource(new WifiDisplaySource(mNetSession, client)) {
+ mLooper->setName("wfd_looper");
+ mLooper->registerHandler(mSource);
+
+ mNetSession->start();
+ mLooper->start();
+
+ mSource->start(iface);
+}
+
+RemoteDisplay::~RemoteDisplay() {
+}
+
+status_t RemoteDisplay::dispose() {
+ mSource->stop();
+
+ mLooper->stop();
+ mNetSession->stop();
+
+ return OK;
+}
+
+} // namespace android
diff --git a/media/libmediaplayerservice/RemoteDisplay.h b/media/libmediaplayerservice/RemoteDisplay.h
new file mode 100644
index 0000000..0d87250
--- /dev/null
+++ b/media/libmediaplayerservice/RemoteDisplay.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef REMOTE_DISPLAY_H_
+
+#define REMOTE_DISPLAY_H_
+
+#include <media/IRemoteDisplay.h>
+#include <media/stagefright/foundation/ABase.h>
+#include <utils/Errors.h>
+#include <utils/RefBase.h>
+
+namespace android {
+
+struct ALooper;
+struct ANetworkSession;
+struct IRemoteDisplayClient;
+struct WifiDisplaySource;
+
+struct RemoteDisplay : public BnRemoteDisplay {
+ RemoteDisplay(const sp<IRemoteDisplayClient> &client, const char *iface);
+
+ virtual status_t dispose();
+
+protected:
+ virtual ~RemoteDisplay();
+
+private:
+ sp<ALooper> mNetLooper;
+ sp<ALooper> mLooper;
+ sp<ANetworkSession> mNetSession;
+ sp<WifiDisplaySource> mSource;
+
+ DISALLOW_EVIL_CONSTRUCTORS(RemoteDisplay);
+};
+
+} // namespace android
+
+#endif // REMOTE_DISPLAY_H_
+
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 727fd0d..57b0ec2 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -1035,11 +1035,11 @@ void StagefrightRecorder::clipVideoFrameRate() {
"enc.vid.fps.min", mVideoEncoder);
int maxFrameRate = mEncoderProfiles->getVideoEncoderParamByName(
"enc.vid.fps.max", mVideoEncoder);
- if (mFrameRate < minFrameRate && mFrameRate != -1) {
+ if (mFrameRate < minFrameRate && minFrameRate != -1) {
ALOGW("Intended video encoding frame rate (%d fps) is too small"
" and will be set to (%d fps)", mFrameRate, minFrameRate);
mFrameRate = minFrameRate;
- } else if (mFrameRate > maxFrameRate) {
+ } else if (mFrameRate > maxFrameRate && maxFrameRate != -1) {
ALOGW("Intended video encoding frame rate (%d fps) is too large"
" and will be set to (%d fps)", mFrameRate, maxFrameRate);
mFrameRate = maxFrameRate;
@@ -1052,11 +1052,11 @@ void StagefrightRecorder::clipVideoBitRate() {
"enc.vid.bps.min", mVideoEncoder);
int maxBitRate = mEncoderProfiles->getVideoEncoderParamByName(
"enc.vid.bps.max", mVideoEncoder);
- if (mVideoBitRate < minBitRate) {
+ if (mVideoBitRate < minBitRate && minBitRate != -1) {
ALOGW("Intended video encoding bit rate (%d bps) is too small"
" and will be set to (%d bps)", mVideoBitRate, minBitRate);
mVideoBitRate = minBitRate;
- } else if (mVideoBitRate > maxBitRate) {
+ } else if (mVideoBitRate > maxBitRate && maxBitRate != -1) {
ALOGW("Intended video encoding bit rate (%d bps) is too large"
" and will be set to (%d bps)", mVideoBitRate, maxBitRate);
mVideoBitRate = maxBitRate;
@@ -1069,11 +1069,11 @@ void StagefrightRecorder::clipVideoFrameWidth() {
"enc.vid.width.min", mVideoEncoder);
int maxFrameWidth = mEncoderProfiles->getVideoEncoderParamByName(
"enc.vid.width.max", mVideoEncoder);
- if (mVideoWidth < minFrameWidth) {
+ if (mVideoWidth < minFrameWidth && minFrameWidth != -1) {
ALOGW("Intended video encoding frame width (%d) is too small"
" and will be set to (%d)", mVideoWidth, minFrameWidth);
mVideoWidth = minFrameWidth;
- } else if (mVideoWidth > maxFrameWidth) {
+ } else if (mVideoWidth > maxFrameWidth && maxFrameWidth != -1) {
ALOGW("Intended video encoding frame width (%d) is too large"
" and will be set to (%d)", mVideoWidth, maxFrameWidth);
mVideoWidth = maxFrameWidth;
@@ -1164,7 +1164,7 @@ void StagefrightRecorder::clipAudioBitRate() {
int minAudioBitRate =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.bps.min", mAudioEncoder);
- if (mAudioBitRate < minAudioBitRate) {
+ if (minAudioBitRate != -1 && mAudioBitRate < minAudioBitRate) {
ALOGW("Intended audio encoding bit rate (%d) is too small"
" and will be set to (%d)", mAudioBitRate, minAudioBitRate);
mAudioBitRate = minAudioBitRate;
@@ -1173,7 +1173,7 @@ void StagefrightRecorder::clipAudioBitRate() {
int maxAudioBitRate =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.bps.max", mAudioEncoder);
- if (mAudioBitRate > maxAudioBitRate) {
+ if (maxAudioBitRate != -1 && mAudioBitRate > maxAudioBitRate) {
ALOGW("Intended audio encoding bit rate (%d) is too large"
" and will be set to (%d)", mAudioBitRate, maxAudioBitRate);
mAudioBitRate = maxAudioBitRate;
@@ -1186,7 +1186,7 @@ void StagefrightRecorder::clipAudioSampleRate() {
int minSampleRate =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.hz.min", mAudioEncoder);
- if (mSampleRate < minSampleRate) {
+ if (minSampleRate != -1 && mSampleRate < minSampleRate) {
ALOGW("Intended audio sample rate (%d) is too small"
" and will be set to (%d)", mSampleRate, minSampleRate);
mSampleRate = minSampleRate;
@@ -1195,7 +1195,7 @@ void StagefrightRecorder::clipAudioSampleRate() {
int maxSampleRate =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.hz.max", mAudioEncoder);
- if (mSampleRate > maxSampleRate) {
+ if (maxSampleRate != -1 && mSampleRate > maxSampleRate) {
ALOGW("Intended audio sample rate (%d) is too large"
" and will be set to (%d)", mSampleRate, maxSampleRate);
mSampleRate = maxSampleRate;
@@ -1208,7 +1208,7 @@ void StagefrightRecorder::clipNumberOfAudioChannels() {
int minChannels =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.ch.min", mAudioEncoder);
- if (mAudioChannels < minChannels) {
+ if (minChannels != -1 && mAudioChannels < minChannels) {
ALOGW("Intended number of audio channels (%d) is too small"
" and will be set to (%d)", mAudioChannels, minChannels);
mAudioChannels = minChannels;
@@ -1217,7 +1217,7 @@ void StagefrightRecorder::clipNumberOfAudioChannels() {
int maxChannels =
mEncoderProfiles->getAudioEncoderParamByName(
"enc.aud.ch.max", mAudioEncoder);
- if (mAudioChannels > maxChannels) {
+ if (maxChannels != -1 && mAudioChannels > maxChannels) {
ALOGW("Intended number of audio channels (%d) is too large"
" and will be set to (%d)", mAudioChannels, maxChannels);
mAudioChannels = maxChannels;
@@ -1230,11 +1230,11 @@ void StagefrightRecorder::clipVideoFrameHeight() {
"enc.vid.height.min", mVideoEncoder);
int maxFrameHeight = mEncoderProfiles->getVideoEncoderParamByName(
"enc.vid.height.max", mVideoEncoder);
- if (mVideoHeight < minFrameHeight) {
+ if (minFrameHeight != -1 && mVideoHeight < minFrameHeight) {
ALOGW("Intended video encoding frame height (%d) is too small"
" and will be set to (%d)", mVideoHeight, minFrameHeight);
mVideoHeight = minFrameHeight;
- } else if (mVideoHeight > maxFrameHeight) {
+ } else if (maxFrameHeight != -1 && mVideoHeight > maxFrameHeight) {
ALOGW("Intended video encoding frame height (%d) is too large"
" and will be set to (%d)", mVideoHeight, maxFrameHeight);
mVideoHeight = maxFrameHeight;
@@ -1410,7 +1410,6 @@ status_t StagefrightRecorder::setupVideoEncoder(
uint32_t encoder_flags = 0;
if (mIsMetaDataStoredInVideoBuffers) {
- encoder_flags |= OMXCodec::kHardwareCodecsOnly;
encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
}
diff --git a/media/libmediaplayerservice/nuplayer/Android.mk b/media/libmediaplayerservice/nuplayer/Android.mk
index f97ba57..f946c1c 100644
--- a/media/libmediaplayerservice/nuplayer/Android.mk
+++ b/media/libmediaplayerservice/nuplayer/Android.mk
@@ -11,6 +11,7 @@ LOCAL_SRC_FILES:= \
NuPlayerStreamListener.cpp \
RTSPSource.cpp \
StreamingSource.cpp \
+ mp4/MP4Source.cpp \
LOCAL_C_INCLUDES := \
$(TOP)/frameworks/av/media/libstagefright/httplive \
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 99569c9..f0c3240 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -128,7 +128,7 @@ status_t NuPlayer::GenericSource::feedMoreTSData() {
return OK;
}
-sp<MetaData> NuPlayer::GenericSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::GenericSource::getFormatMeta(bool audio) {
sp<MediaSource> source = audio ? mAudioTrack.mSource : mVideoTrack.mSource;
if (source == NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index aaa5876..e50b855 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -43,7 +43,6 @@ struct NuPlayer::GenericSource : public NuPlayer::Source {
virtual status_t feedMoreTSData();
- virtual sp<MetaData> getFormat(bool audio);
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
virtual status_t getDuration(int64_t *durationUs);
@@ -53,6 +52,8 @@ struct NuPlayer::GenericSource : public NuPlayer::Source {
protected:
virtual ~GenericSource();
+ virtual sp<MetaData> getFormatMeta(bool audio);
+
private:
struct Track {
sp<MediaSource> mSource;
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index 22b8847..1e98f35 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -81,7 +81,7 @@ void NuPlayer::HTTPLiveSource::start() {
mTSParser = new ATSParser;
}
-sp<MetaData> NuPlayer::HTTPLiveSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::HTTPLiveSource::getFormatMeta(bool audio) {
ATSParser::SourceType type =
audio ? ATSParser::AUDIO : ATSParser::VIDEO;
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
index f22af5b..9950a9e 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
@@ -37,7 +37,6 @@ struct NuPlayer::HTTPLiveSource : public NuPlayer::Source {
virtual status_t feedMoreTSData();
- virtual sp<MetaData> getFormat(bool audio);
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
virtual status_t getDuration(int64_t *durationUs);
@@ -47,6 +46,8 @@ struct NuPlayer::HTTPLiveSource : public NuPlayer::Source {
protected:
virtual ~HTTPLiveSource();
+ virtual sp<MetaData> getFormatMeta(bool audio);
+
private:
enum Flags {
// Don't log any URLs.
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 86e122f..1ddf775 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -28,9 +28,11 @@
#include "RTSPSource.h"
#include "StreamingSource.h"
#include "GenericSource.h"
+#include "mp4/MP4Source.h"
#include "ATSParser.h"
+#include <cutils/properties.h> // for property_get
#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
@@ -43,6 +45,9 @@
#include "avc_utils.h"
+#include "ESDS.h"
+#include <media/stagefright/Utils.h>
+
namespace android {
////////////////////////////////////////////////////////////////////////////////
@@ -63,7 +68,8 @@ NuPlayer::NuPlayer()
mSkipRenderingVideoUntilMediaTimeUs(-1ll),
mVideoLateByUs(0ll),
mNumFramesTotal(0ll),
- mNumFramesDropped(0ll) {
+ mNumFramesDropped(0ll),
+ mVideoScalingMode(NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW) {
}
NuPlayer::~NuPlayer() {
@@ -81,7 +87,14 @@ void NuPlayer::setDriver(const wp<NuPlayerDriver> &driver) {
void NuPlayer::setDataSource(const sp<IStreamSource> &source) {
sp<AMessage> msg = new AMessage(kWhatSetDataSource, id());
- msg->setObject("source", new StreamingSource(source));
+ char prop[PROPERTY_VALUE_MAX];
+ if (property_get("media.stagefright.use-mp4source", prop, NULL)
+ && (!strcmp(prop, "1") || !strcasecmp(prop, "true"))) {
+ msg->setObject("source", new MP4Source(source));
+ } else {
+ msg->setObject("source", new StreamingSource(source));
+ }
+
msg->post();
}
@@ -205,6 +218,9 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
CHECK(msg->findObject("native-window", &obj));
mNativeWindow = static_cast<NativeWindowWrapper *>(obj.get());
+
+ // XXX - ignore error from setVideoScalingMode for now
+ setVideoScalingMode(mVideoScalingMode);
break;
}
@@ -258,7 +274,9 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
mAudioDecoder != NULL, mVideoDecoder != NULL);
- instantiateDecoder(false, &mVideoDecoder);
+ if (mNativeWindow != NULL) {
+ instantiateDecoder(false, &mVideoDecoder);
+ }
if (mAudioSink != NULL) {
instantiateDecoder(true, &mAudioDecoder);
@@ -279,7 +297,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
break;
}
- if (mAudioDecoder == NULL || mVideoDecoder == NULL) {
+ if ((mAudioDecoder == NULL && mAudioSink != NULL)
+ || (mVideoDecoder == NULL && mNativeWindow != NULL)) {
msg->post(100000ll);
mScanSourcesPending = true;
}
@@ -500,6 +519,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
CHECK(msg->findInt32("audio", &audio));
ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
+ } else if (what == Renderer::kWhatVideoRenderingStart) {
+ notifyListener(MEDIA_INFO, MEDIA_INFO_RENDERING_START, 0);
}
break;
}
@@ -674,16 +695,16 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) {
return OK;
}
- sp<MetaData> meta = mSource->getFormat(audio);
+ sp<AMessage> format = mSource->getFormat(audio);
- if (meta == NULL) {
+ if (format == NULL) {
return -EWOULDBLOCK;
}
if (!audio) {
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
- mVideoIsAVC = !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime);
+ AString mime;
+ CHECK(format->findString("mime", &mime));
+ mVideoIsAVC = !strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime.c_str());
}
sp<AMessage> notify =
@@ -694,7 +715,7 @@ status_t NuPlayer::instantiateDecoder(bool audio, sp<Decoder> *decoder) {
new Decoder(notify, mNativeWindow);
looper()->registerHandler(*decoder);
- (*decoder)->configure(meta);
+ (*decoder)->configure(format);
int64_t durationUs;
if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
@@ -925,4 +946,34 @@ void NuPlayer::flushDecoder(bool audio, bool needShutdown) {
}
}
+sp<AMessage> NuPlayer::Source::getFormat(bool audio) {
+ sp<MetaData> meta = getFormatMeta(audio);
+
+ if (meta == NULL) {
+ return NULL;
+ }
+
+ sp<AMessage> msg = new AMessage;
+
+ if(convertMetaDataToMessage(meta, &msg) == OK) {
+ return msg;
+ }
+ return NULL;
+}
+
+status_t NuPlayer::setVideoScalingMode(int32_t mode) {
+ mVideoScalingMode = mode;
+ if (mNativeWindow != NULL
+ && mNativeWindow->getNativeWindow() != NULL) {
+ status_t ret = native_window_set_scaling_mode(
+ mNativeWindow->getNativeWindow().get(), mVideoScalingMode);
+ if (ret != OK) {
+ ALOGE("Failed to set scaling mode (%d): %s",
+ -ret, strerror(-ret));
+ return ret;
+ }
+ }
+ return OK;
+}
+
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 25766e0..36d3a9c 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -55,19 +55,23 @@ struct NuPlayer : public AHandler {
// Will notify the driver through "notifySeekComplete" once finished.
void seekToAsync(int64_t seekTimeUs);
+ status_t setVideoScalingMode(int32_t mode);
+
protected:
virtual ~NuPlayer();
virtual void onMessageReceived(const sp<AMessage> &msg);
+public:
+ struct NuPlayerStreamListener;
+ struct Source;
+
private:
struct Decoder;
struct GenericSource;
struct HTTPLiveSource;
- struct NuPlayerStreamListener;
struct Renderer;
struct RTSPSource;
- struct Source;
struct StreamingSource;
enum {
@@ -128,6 +132,8 @@ private:
int64_t mVideoLateByUs;
int64_t mNumFramesTotal, mNumFramesDropped;
+ int32_t mVideoScalingMode;
+
status_t instantiateDecoder(bool audio, sp<Decoder> *decoder);
status_t feedDecoderInputData(bool audio, const sp<AMessage> &msg);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 0e53662..22f699e 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -20,15 +20,11 @@
#include "NuPlayerDecoder.h"
-#include "ESDS.h"
-
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/ACodec.h>
#include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
namespace android {
@@ -42,16 +38,24 @@ NuPlayer::Decoder::Decoder(
NuPlayer::Decoder::~Decoder() {
}
-void NuPlayer::Decoder::configure(const sp<MetaData> &meta) {
+void NuPlayer::Decoder::configure(const sp<AMessage> &format) {
CHECK(mCodec == NULL);
- const char *mime;
- CHECK(meta->findCString(kKeyMIMEType, &mime));
+ AString mime;
+ CHECK(format->findString("mime", &mime));
sp<AMessage> notifyMsg =
new AMessage(kWhatCodecNotify, id());
- sp<AMessage> format = makeFormat(meta);
+ mCSDIndex = 0;
+ for (size_t i = 0;; ++i) {
+ sp<ABuffer> csd;
+ if (!format->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
+ break;
+ }
+
+ mCSD.push(csd);
+ }
if (mNativeWindow != NULL) {
format->setObject("native-window", mNativeWindow);
@@ -61,7 +65,7 @@ void NuPlayer::Decoder::configure(const sp<MetaData> &meta) {
// quickly, violating the OpenMAX specs, until that is remedied
// we need to invest in an extra looper to free the main event
// queue.
- bool needDedicatedLooper = !strncasecmp(mime, "video/", 6);
+ bool needDedicatedLooper = !strncasecmp(mime.c_str(), "video/", 6);
mCodec = new ACodec;
@@ -100,25 +104,6 @@ void NuPlayer::Decoder::onMessageReceived(const sp<AMessage> &msg) {
}
}
-sp<AMessage> NuPlayer::Decoder::makeFormat(const sp<MetaData> &meta) {
- CHECK(mCSD.isEmpty());
-
- sp<AMessage> msg;
- CHECK_EQ(convertMetaDataToMessage(meta, &msg), (status_t)OK);
-
- mCSDIndex = 0;
- for (size_t i = 0;; ++i) {
- sp<ABuffer> csd;
- if (!msg->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
- break;
- }
-
- mCSD.push(csd);
- }
-
- return msg;
-}
-
void NuPlayer::Decoder::onFillThisBuffer(const sp<AMessage> &msg) {
sp<AMessage> reply;
CHECK(msg->findMessage("reply", &reply));
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index 3ab1fcf..a876148 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -30,7 +30,7 @@ struct NuPlayer::Decoder : public AHandler {
Decoder(const sp<AMessage> &notify,
const sp<NativeWindowWrapper> &nativeWindow = NULL);
- void configure(const sp<MetaData> &meta);
+ void configure(const sp<AMessage> &format);
void signalFlush();
void signalResume();
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
index 441cbf3..d03601f 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDriver.cpp
@@ -259,7 +259,29 @@ player_type NuPlayerDriver::playerType() {
}
status_t NuPlayerDriver::invoke(const Parcel &request, Parcel *reply) {
- return INVALID_OPERATION;
+ if (reply == NULL) {
+ ALOGE("reply is a NULL pointer");
+ return BAD_VALUE;
+ }
+
+ int32_t methodId;
+ status_t ret = request.readInt32(&methodId);
+ if (ret != OK) {
+ ALOGE("Failed to retrieve the requested method to invoke");
+ return ret;
+ }
+
+ switch (methodId) {
+ case INVOKE_ID_SET_VIDEO_SCALING_MODE:
+ {
+ int mode = request.readInt32();
+ return mPlayer->setVideoScalingMode(mode);
+ }
+ default:
+ {
+ return INVALID_OPERATION;
+ }
+ }
}
void NuPlayerDriver::setAudioSink(const sp<AudioSink> &audioSink) {
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 1f13955..8a75f83 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -47,6 +47,7 @@ NuPlayer::Renderer::Renderer(
mHasVideo(false),
mSyncQueues(false),
mPaused(false),
+ mVideoRenderingStarted(false),
mLastPositionUpdateUs(-1ll),
mVideoLateByUs(0ll) {
}
@@ -387,9 +388,20 @@ void NuPlayer::Renderer::onDrainVideoQueue() {
mVideoQueue.erase(mVideoQueue.begin());
entry = NULL;
+ if (!mVideoRenderingStarted) {
+ mVideoRenderingStarted = true;
+ notifyVideoRenderingStart();
+ }
+
notifyPosition();
}
+void NuPlayer::Renderer::notifyVideoRenderingStart() {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatVideoRenderingStart);
+ notify->post();
+}
+
void NuPlayer::Renderer::notifyEOS(bool audio, status_t finalResult) {
sp<AMessage> notify = mNotify->dup();
notify->setInt32("what", kWhatEOS);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
index 268628b..e4368c7 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
@@ -45,9 +45,10 @@ struct NuPlayer::Renderer : public AHandler {
void resume();
enum {
- kWhatEOS = 'eos ',
- kWhatFlushComplete = 'fluC',
- kWhatPosition = 'posi',
+ kWhatEOS = 'eos ',
+ kWhatFlushComplete = 'fluC',
+ kWhatPosition = 'posi',
+ kWhatVideoRenderingStart = 'vdrd',
};
protected:
@@ -99,6 +100,7 @@ private:
bool mSyncQueues;
bool mPaused;
+ bool mVideoRenderingStarted;
int64_t mLastPositionUpdateUs;
int64_t mVideoLateByUs;
@@ -120,6 +122,7 @@ private:
void notifyFlushComplete(bool audio);
void notifyPosition();
void notifyVideoLateBy(int64_t lateByUs);
+ void notifyVideoRenderingStart();
void flushQueue(List<QueueEntry> *queue);
bool dropBufferWhileFlushing(bool audio, const sp<AMessage> &msg);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
index 531b29f..66aeff3 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
@@ -34,7 +34,7 @@ struct NuPlayer::Source : public RefBase {
// an error or ERROR_END_OF_STREAM if not.
virtual status_t feedMoreTSData() = 0;
- virtual sp<MetaData> getFormat(bool audio) = 0;
+ virtual sp<AMessage> getFormat(bool audio);
virtual status_t dequeueAccessUnit(
bool audio, sp<ABuffer> *accessUnit) = 0;
@@ -54,6 +54,8 @@ struct NuPlayer::Source : public RefBase {
protected:
virtual ~Source() {}
+ virtual sp<MetaData> getFormatMeta(bool audio) { return NULL; }
+
private:
DISALLOW_EVIL_CONSTRUCTORS(Source);
};
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
index c910488..5a7a785 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
@@ -23,6 +23,7 @@
#include "AnotherPacketSource.h"
#include "MyHandler.h"
+#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
namespace android {
@@ -95,7 +96,7 @@ status_t NuPlayer::RTSPSource::feedMoreTSData() {
return mFinalResult;
}
-sp<MetaData> NuPlayer::RTSPSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::RTSPSource::getFormatMeta(bool audio) {
sp<AnotherPacketSource> source = getSource(audio);
if (source == NULL) {
@@ -159,6 +160,13 @@ status_t NuPlayer::RTSPSource::dequeueAccessUnit(
}
sp<AnotherPacketSource> NuPlayer::RTSPSource::getSource(bool audio) {
+ if (mTSParser != NULL) {
+ sp<MediaSource> source = mTSParser->getSource(
+ audio ? ATSParser::AUDIO : ATSParser::VIDEO);
+
+ return static_cast<AnotherPacketSource *>(source.get());
+ }
+
return audio ? mAudioTrack : mVideoTrack;
}
@@ -255,7 +263,12 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
{
size_t trackIndex;
CHECK(msg->findSize("trackIndex", &trackIndex));
- CHECK_LT(trackIndex, mTracks.size());
+
+ if (mTSParser == NULL) {
+ CHECK_LT(trackIndex, mTracks.size());
+ } else {
+ CHECK_EQ(trackIndex, 0u);
+ }
sp<ABuffer> accessUnit;
CHECK(msg->findBuffer("accessUnit", &accessUnit));
@@ -267,6 +280,37 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ if (mTSParser != NULL) {
+ size_t offset = 0;
+ status_t err = OK;
+ while (offset + 188 <= accessUnit->size()) {
+ err = mTSParser->feedTSPacket(
+ accessUnit->data() + offset, 188);
+ if (err != OK) {
+ break;
+ }
+
+ offset += 188;
+ }
+
+ if (offset < accessUnit->size()) {
+ err = ERROR_MALFORMED;
+ }
+
+ if (err != OK) {
+ sp<AnotherPacketSource> source = getSource(false /* audio */);
+ if (source != NULL) {
+ source->signalEOS(err);
+ }
+
+ source = getSource(true /* audio */);
+ if (source != NULL) {
+ source->signalEOS(err);
+ }
+ }
+ break;
+ }
+
TrackInfo *info = &mTracks.editItemAt(trackIndex);
sp<AnotherPacketSource> source = info->mSource;
@@ -296,14 +340,28 @@ void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
case MyHandler::kWhatEOS:
{
- size_t trackIndex;
- CHECK(msg->findSize("trackIndex", &trackIndex));
- CHECK_LT(trackIndex, mTracks.size());
-
int32_t finalResult;
CHECK(msg->findInt32("finalResult", &finalResult));
CHECK_NE(finalResult, (status_t)OK);
+ if (mTSParser != NULL) {
+ sp<AnotherPacketSource> source = getSource(false /* audio */);
+ if (source != NULL) {
+ source->signalEOS(finalResult);
+ }
+
+ source = getSource(true /* audio */);
+ if (source != NULL) {
+ source->signalEOS(finalResult);
+ }
+
+ return;
+ }
+
+ size_t trackIndex;
+ CHECK(msg->findSize("trackIndex", &trackIndex));
+ CHECK_LT(trackIndex, mTracks.size());
+
TrackInfo *info = &mTracks.editItemAt(trackIndex);
sp<AnotherPacketSource> source = info->mSource;
if (source != NULL) {
@@ -364,6 +422,14 @@ void NuPlayer::RTSPSource::onConnected() {
const char *mime;
CHECK(format->findCString(kKeyMIMEType, &mime));
+ if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG2TS)) {
+ // Very special case for MPEG2 Transport Streams.
+ CHECK_EQ(numTracks, 1u);
+
+ mTSParser = new ATSParser;
+ return;
+ }
+
bool isAudio = !strncasecmp(mime, "audio/", 6);
bool isVideo = !strncasecmp(mime, "video/", 6);
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.h b/media/libmediaplayerservice/nuplayer/RTSPSource.h
index e11e304..f07c724 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.h
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.h
@@ -20,6 +20,8 @@
#include "NuPlayerSource.h"
+#include "ATSParser.h"
+
#include <media/stagefright/foundation/AHandlerReflector.h>
namespace android {
@@ -40,7 +42,6 @@ struct NuPlayer::RTSPSource : public NuPlayer::Source {
virtual status_t feedMoreTSData();
- virtual sp<MetaData> getFormat(bool audio);
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
virtual status_t getDuration(int64_t *durationUs);
@@ -52,6 +53,8 @@ struct NuPlayer::RTSPSource : public NuPlayer::Source {
protected:
virtual ~RTSPSource();
+ virtual sp<MetaData> getFormatMeta(bool audio);
+
private:
enum {
kWhatNotify = 'noti',
@@ -98,6 +101,8 @@ private:
sp<AnotherPacketSource> mAudioTrack;
sp<AnotherPacketSource> mVideoTrack;
+ sp<ATSParser> mTSParser;
+
int32_t mSeekGeneration;
sp<AnotherPacketSource> getSource(bool audio);
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
index 7c9bc5e..a1fd2ed 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
@@ -42,7 +42,15 @@ NuPlayer::StreamingSource::~StreamingSource() {
void NuPlayer::StreamingSource::start() {
mStreamListener = new NuPlayerStreamListener(mSource, 0);
- mTSParser = new ATSParser(ATSParser::TS_TIMESTAMPS_ARE_ABSOLUTE);
+
+ uint32_t sourceFlags = mSource->flags();
+
+ uint32_t parserFlags = ATSParser::TS_TIMESTAMPS_ARE_ABSOLUTE;
+ if (sourceFlags & IStreamSource::kFlagAlignedVideoData) {
+ parserFlags |= ATSParser::ALIGNED_VIDEO_DATA;
+ }
+
+ mTSParser = new ATSParser(parserFlags);
mStreamListener->start();
}
@@ -107,7 +115,7 @@ status_t NuPlayer::StreamingSource::feedMoreTSData() {
return OK;
}
-sp<MetaData> NuPlayer::StreamingSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::StreamingSource::getFormatMeta(bool audio) {
ATSParser::SourceType type =
audio ? ATSParser::AUDIO : ATSParser::VIDEO;
@@ -138,7 +146,17 @@ status_t NuPlayer::StreamingSource::dequeueAccessUnit(
return finalResult == OK ? -EWOULDBLOCK : finalResult;
}
- return source->dequeueAccessUnit(accessUnit);
+ status_t err = source->dequeueAccessUnit(accessUnit);
+
+#if !defined(LOG_NDEBUG) || LOG_NDEBUG == 0
+ if (err == OK) {
+ int64_t timeUs;
+ CHECK((*accessUnit)->meta()->findInt64("timeUs", &timeUs));
+ ALOGV("dequeueAccessUnit timeUs=%lld us", timeUs);
+ }
+#endif
+
+ return err;
}
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.h b/media/libmediaplayerservice/nuplayer/StreamingSource.h
index ca00ef9..3971e2a 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.h
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.h
@@ -33,12 +33,13 @@ struct NuPlayer::StreamingSource : public NuPlayer::Source {
virtual status_t feedMoreTSData();
- virtual sp<MetaData> getFormat(bool audio);
virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
protected:
virtual ~StreamingSource();
+ virtual sp<MetaData> getFormatMeta(bool audio);
+
private:
sp<IStreamSource> mSource;
status_t mFinalResult;
diff --git a/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp
new file mode 100644
index 0000000..ffb3a65
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp
@@ -0,0 +1,136 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "MP4Source.h"
+
+#include "FragmentedMP4Parser.h"
+#include "../NuPlayerStreamListener.h"
+
+#include <media/IStreamSource.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/MetaData.h>
+
+namespace android {
+
+struct StreamSource : public FragmentedMP4Parser::Source {
+ StreamSource(const sp<IStreamSource> &source)
+ : mListener(new NuPlayer::NuPlayerStreamListener(source, 0)),
+ mPosition(0) {
+ mListener->start();
+ }
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+ if (offset < mPosition) {
+ return -EPIPE;
+ }
+
+ while (offset > mPosition) {
+ char buffer[1024];
+ off64_t skipBytes = offset - mPosition;
+ if (skipBytes > sizeof(buffer)) {
+ skipBytes = sizeof(buffer);
+ }
+
+ sp<AMessage> extra;
+ ssize_t n;
+ for (;;) {
+ n = mListener->read(buffer, skipBytes, &extra);
+
+ if (n == -EWOULDBLOCK) {
+ usleep(10000);
+ continue;
+ }
+
+ break;
+ }
+
+ ALOGV("skipped %ld bytes at offset %lld", n, mPosition);
+
+ if (n < 0) {
+ return n;
+ }
+
+ mPosition += n;
+ }
+
+ sp<AMessage> extra;
+ size_t total = 0;
+ while (total < size) {
+ ssize_t n = mListener->read(
+ (uint8_t *)data + total, size - total, &extra);
+
+ if (n == -EWOULDBLOCK) {
+ usleep(10000);
+ continue;
+ } else if (n == 0) {
+ break;
+ } else if (n < 0) {
+ mPosition += total;
+ return n;
+ }
+
+ total += n;
+ }
+
+ ALOGV("read %ld bytes at offset %lld", n, mPosition);
+
+ mPosition += total;
+
+ return total;
+ }
+
+ bool isSeekable() {
+ return false;
+ }
+
+private:
+ sp<NuPlayer::NuPlayerStreamListener> mListener;
+ off64_t mPosition;
+
+ DISALLOW_EVIL_CONSTRUCTORS(StreamSource);
+};
+
+MP4Source::MP4Source(const sp<IStreamSource> &source)
+ : mSource(source),
+ mLooper(new ALooper),
+ mParser(new FragmentedMP4Parser),
+ mEOS(false) {
+ mLooper->registerHandler(mParser);
+}
+
+MP4Source::~MP4Source() {
+}
+
+void MP4Source::start() {
+ mLooper->start(false /* runOnCallingThread */);
+ mParser->start(new StreamSource(mSource));
+}
+
+status_t MP4Source::feedMoreTSData() {
+ return mEOS ? ERROR_END_OF_STREAM : (status_t)OK;
+}
+
+sp<AMessage> MP4Source::getFormat(bool audio) {
+ return mParser->getFormat(audio);
+}
+
+status_t MP4Source::dequeueAccessUnit(
+ bool audio, sp<ABuffer> *accessUnit) {
+ return mParser->dequeueAccessUnit(audio, accessUnit);
+}
+
+} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h
new file mode 100644
index 0000000..4e927af
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MP4_SOURCE_H
+#define MP4_SOURCE_H
+
+#include "NuPlayerSource.h"
+
+namespace android {
+
+struct FragmentedMP4Parser;
+
+struct MP4Source : public NuPlayer::Source {
+ MP4Source(const sp<IStreamSource> &source);
+
+ virtual void start();
+
+ virtual status_t feedMoreTSData();
+
+ virtual sp<AMessage> getFormat(bool audio);
+
+ virtual status_t dequeueAccessUnit(
+ bool audio, sp<ABuffer> *accessUnit);
+
+protected:
+ virtual ~MP4Source();
+
+private:
+ sp<IStreamSource> mSource;
+ sp<ALooper> mLooper;
+ sp<FragmentedMP4Parser> mParser;
+ bool mEOS;
+
+ DISALLOW_EVIL_CONSTRUCTORS(MP4Source);
+};
+
+} // namespace android
+
+#endif // MP4_SOURCE_H
diff --git a/media/libnbaio/Android.mk b/media/libnbaio/Android.mk
new file mode 100644
index 0000000..757272f
--- /dev/null
+++ b/media/libnbaio/Android.mk
@@ -0,0 +1,32 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ AudioBufferProviderSource.cpp \
+ AudioStreamOutSink.cpp \
+ AudioStreamInSource.cpp \
+ NBAIO.cpp \
+ MonoPipe.cpp \
+ MonoPipeReader.cpp \
+ Pipe.cpp \
+ PipeReader.cpp \
+ roundup.c \
+ SourceAudioBufferProvider.cpp
+
+# libsndfile license is incompatible; uncomment to use for local debug only
+#LOCAL_SRC_FILES += LibsndfileSink.cpp LibsndfileSource.cpp
+#LOCAL_C_INCLUDES += path/to/libsndfile/src
+#LOCAL_STATIC_LIBRARIES += libsndfile
+
+# uncomment for systrace
+# LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_AUDIO
+
+LOCAL_MODULE := libnbaio
+
+LOCAL_SHARED_LIBRARIES := \
+ libcommon_time_client \
+ libcutils \
+ libutils
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libnbaio/AudioBufferProviderSource.cpp b/media/libnbaio/AudioBufferProviderSource.cpp
new file mode 100644
index 0000000..74a6fdb
--- /dev/null
+++ b/media/libnbaio/AudioBufferProviderSource.cpp
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "AudioBufferProviderSource"
+//#define LOG_NDEBUG 0
+
+#include <cutils/compiler.h>
+#include <utils/Log.h>
+#include <media/nbaio/AudioBufferProviderSource.h>
+
+namespace android {
+
+AudioBufferProviderSource::AudioBufferProviderSource(AudioBufferProvider *provider,
+ NBAIO_Format format) :
+ NBAIO_Source(format), mProvider(provider), mConsumed(0)
+{
+ ALOG_ASSERT(provider != NULL);
+ ALOG_ASSERT(format != Format_Invalid);
+}
+
+AudioBufferProviderSource::~AudioBufferProviderSource()
+{
+ if (mBuffer.raw != NULL) {
+ mProvider->releaseBuffer(&mBuffer);
+ }
+}
+
+ssize_t AudioBufferProviderSource::availableToRead()
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ return mBuffer.raw != NULL ? mBuffer.frameCount - mConsumed : 0;
+}
+
+ssize_t AudioBufferProviderSource::read(void *buffer,
+ size_t count,
+ int64_t readPTS)
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ if (CC_UNLIKELY(mBuffer.raw == NULL)) {
+ mBuffer.frameCount = count;
+ status_t status = mProvider->getNextBuffer(&mBuffer, readPTS);
+ if (status != OK) {
+ return status == NOT_ENOUGH_DATA ? (ssize_t) WOULD_BLOCK : (ssize_t) status;
+ }
+ ALOG_ASSERT(mBuffer.raw != NULL);
+ // mConsumed is 0 either from constructor or after releaseBuffer()
+ }
+ size_t available = mBuffer.frameCount - mConsumed;
+ if (CC_UNLIKELY(count > available)) {
+ count = available;
+ }
+ // count could be zero, either because count was zero on entry or
+ // available is zero, but both are unlikely so don't check for that
+ memcpy(buffer, (char *) mBuffer.raw + (mConsumed << mBitShift), count << mBitShift);
+ if (CC_UNLIKELY((mConsumed += count) >= mBuffer.frameCount)) {
+ mProvider->releaseBuffer(&mBuffer);
+ mBuffer.raw = NULL;
+ mConsumed = 0;
+ }
+ mFramesRead += count;
+ // For better responsiveness with large values of count,
+ // return a short count rather than continuing with next buffer.
+ // This gives the caller a chance to interpolate other actions.
+ return count;
+}
+
+ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *user,
+ int64_t readPTS, size_t block)
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ if (CC_UNLIKELY(block == 0)) {
+ block = ~0;
+ }
+ for (size_t accumulator = 0; ; ) {
+ ALOG_ASSERT(accumulator <= total);
+ size_t count = total - accumulator;
+ if (CC_UNLIKELY(count == 0)) {
+ return accumulator;
+ }
+ if (CC_LIKELY(count > block)) {
+ count = block;
+ }
+ // 1 <= count <= block
+ if (CC_UNLIKELY(mBuffer.raw == NULL)) {
+ mBuffer.frameCount = count;
+ status_t status = mProvider->getNextBuffer(&mBuffer, readPTS);
+ if (CC_LIKELY(status == OK)) {
+ ALOG_ASSERT(mBuffer.raw != NULL && mBuffer.frameCount <= count);
+ // mConsumed is 0 either from constructor or after releaseBuffer()
+ continue;
+ }
+ // FIXME simplify logic - does the initial count and block checks again for no reason;
+ // don't you just want to fall through to the size_t available line?
+ if (CC_LIKELY(status == NOT_ENOUGH_DATA)) {
+ status = WOULD_BLOCK;
+ }
+ return accumulator > 0 ? accumulator : (ssize_t) status;
+ }
+ size_t available = mBuffer.frameCount - mConsumed;
+ if (CC_UNLIKELY(count > available)) {
+ count = available;
+ }
+ if (CC_LIKELY(count > 0)) {
+ char* readTgt = (char *) mBuffer.raw + (mConsumed << mBitShift);
+ ssize_t ret = via(user, readTgt, count, readPTS);
+ if (CC_UNLIKELY(ret <= 0)) {
+ if (CC_LIKELY(accumulator > 0)) {
+ return accumulator;
+ }
+ return ret;
+ }
+ ALOG_ASSERT((size_t) ret <= count);
+ mFramesRead += ret;
+ accumulator += ret;
+ if (CC_LIKELY((mConsumed += ret) < mBuffer.frameCount)) {
+ continue;
+ }
+ }
+ mProvider->releaseBuffer(&mBuffer);
+ mBuffer.raw = NULL;
+ mConsumed = 0;
+ // don't get next buffer until we really need it
+ }
+}
+
+} // namespace android
diff --git a/media/libnbaio/AudioStreamInSource.cpp b/media/libnbaio/AudioStreamInSource.cpp
new file mode 100644
index 0000000..05273f6
--- /dev/null
+++ b/media/libnbaio/AudioStreamInSource.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "AudioStreamInSource"
+//#define LOG_NDEBUG 0
+
+#include <cutils/compiler.h>
+#include <utils/Log.h>
+#include <media/nbaio/AudioStreamInSource.h>
+
+namespace android {
+
+AudioStreamInSource::AudioStreamInSource(audio_stream_in *stream) :
+ NBAIO_Source(),
+ mStream(stream),
+ mStreamBufferSizeBytes(0),
+ mFramesOverrun(0),
+ mOverruns(0)
+{
+ ALOG_ASSERT(stream != NULL);
+}
+
+AudioStreamInSource::~AudioStreamInSource()
+{
+}
+
+ssize_t AudioStreamInSource::negotiate(const NBAIO_Format offers[], size_t numOffers,
+ NBAIO_Format counterOffers[], size_t& numCounterOffers)
+{
+ if (mFormat == Format_Invalid) {
+ mStreamBufferSizeBytes = mStream->common.get_buffer_size(&mStream->common);
+ audio_format_t streamFormat = mStream->common.get_format(&mStream->common);
+ if (streamFormat == AUDIO_FORMAT_PCM_16_BIT) {
+ uint32_t sampleRate = mStream->common.get_sample_rate(&mStream->common);
+ audio_channel_mask_t channelMask =
+ (audio_channel_mask_t) mStream->common.get_channels(&mStream->common);
+ mFormat = Format_from_SR_C(sampleRate, popcount(channelMask));
+ mBitShift = Format_frameBitShift(mFormat);
+ }
+ }
+ return NBAIO_Source::negotiate(offers, numOffers, counterOffers, numCounterOffers);
+}
+
+size_t AudioStreamInSource::framesOverrun()
+{
+ uint32_t framesOverrun = mStream->get_input_frames_lost(mStream);
+ if (framesOverrun > 0) {
+ mFramesOverrun += framesOverrun;
+ // FIXME only increment for contiguous ranges
+ ++mOverruns;
+ }
+ return mFramesOverrun;
+}
+
+ssize_t AudioStreamInSource::read(void *buffer, size_t count)
+{
+ if (CC_UNLIKELY(mFormat == Format_Invalid)) {
+ return NEGOTIATE;
+ }
+ ssize_t bytesRead = mStream->read(mStream, buffer, count << mBitShift);
+ if (bytesRead > 0) {
+ size_t framesRead = bytesRead >> mBitShift;
+ mFramesRead += framesRead;
+ return framesRead;
+ } else {
+ return bytesRead;
+ }
+}
+
+} // namespace android
diff --git a/media/libnbaio/AudioStreamOutSink.cpp b/media/libnbaio/AudioStreamOutSink.cpp
new file mode 100644
index 0000000..6f525e5
--- /dev/null
+++ b/media/libnbaio/AudioStreamOutSink.cpp
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "AudioStreamOutSink"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <media/nbaio/AudioStreamOutSink.h>
+
+namespace android {
+
+AudioStreamOutSink::AudioStreamOutSink(audio_stream_out *stream) :
+ NBAIO_Sink(),
+ mStream(stream),
+ mStreamBufferSizeBytes(0)
+{
+ ALOG_ASSERT(stream != NULL);
+}
+
+AudioStreamOutSink::~AudioStreamOutSink()
+{
+}
+
+ssize_t AudioStreamOutSink::negotiate(const NBAIO_Format offers[], size_t numOffers,
+ NBAIO_Format counterOffers[], size_t& numCounterOffers)
+{
+ if (mFormat == Format_Invalid) {
+ mStreamBufferSizeBytes = mStream->common.get_buffer_size(&mStream->common);
+ audio_format_t streamFormat = mStream->common.get_format(&mStream->common);
+ if (streamFormat == AUDIO_FORMAT_PCM_16_BIT) {
+ uint32_t sampleRate = mStream->common.get_sample_rate(&mStream->common);
+ audio_channel_mask_t channelMask =
+ (audio_channel_mask_t) mStream->common.get_channels(&mStream->common);
+ mFormat = Format_from_SR_C(sampleRate, popcount(channelMask));
+ mBitShift = Format_frameBitShift(mFormat);
+ }
+ }
+ return NBAIO_Sink::negotiate(offers, numOffers, counterOffers, numCounterOffers);
+}
+
+ssize_t AudioStreamOutSink::write(const void *buffer, size_t count)
+{
+ if (!mNegotiated) {
+ return NEGOTIATE;
+ }
+ ALOG_ASSERT(mFormat != Format_Invalid);
+ ssize_t ret = mStream->write(mStream, buffer, count << mBitShift);
+ if (ret > 0) {
+ ret >>= mBitShift;
+ mFramesWritten += ret;
+ } else {
+ // FIXME verify HAL implementations are returning the correct error codes e.g. WOULD_BLOCK
+ }
+ return ret;
+}
+
+status_t AudioStreamOutSink::getNextWriteTimestamp(int64_t *timestamp) {
+ ALOG_ASSERT(timestamp != NULL);
+
+ if (NULL == mStream)
+ return INVALID_OPERATION;
+
+ if (NULL == mStream->get_next_write_timestamp)
+ return INVALID_OPERATION;
+
+ return mStream->get_next_write_timestamp(mStream, timestamp);
+}
+
+} // namespace android
diff --git a/media/libnbaio/LibsndfileSink.cpp b/media/libnbaio/LibsndfileSink.cpp
new file mode 100644
index 0000000..77debc0
--- /dev/null
+++ b/media/libnbaio/LibsndfileSink.cpp
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "LibsndfileSink"
+//#define LOG_NDEBUG 0
+
+#include <utils/Errors.h>
+#include <utils/Log.h>
+#include <media/nbaio/LibsndfileSink.h>
+
+namespace android {
+
+LibsndfileSink::LibsndfileSink(SNDFILE *sndfile, const SF_INFO &sfinfo) :
+ NBAIO_Sink(Format_from_SR_C(sfinfo.samplerate, sfinfo.channels)),
+ mSndfile(sndfile)
+{
+}
+
+LibsndfileSink::~LibsndfileSink()
+{
+ // do not close mSndfile; we don't own it
+}
+
+ssize_t LibsndfileSink::write(const void *buffer, size_t count)
+{
+ if (!mNegotiated) {
+ return (ssize_t) NEGOTIATE;
+ }
+ if (mSndfile == NULL) {
+ return (ssize_t) NO_INIT;
+ }
+ sf_count_t actual = sf_writef_short(mSndfile, (short *) buffer, (sf_count_t) count);
+ mFramesWritten += actual;
+ return actual;
+}
+
+} // namespace android
diff --git a/media/libnbaio/LibsndfileSource.cpp b/media/libnbaio/LibsndfileSource.cpp
new file mode 100644
index 0000000..98610e0
--- /dev/null
+++ b/media/libnbaio/LibsndfileSource.cpp
@@ -0,0 +1,80 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "LibsndfileSource"
+//#define LOG_NDEBUG 0
+
+#include <utils/Errors.h>
+#include <utils/Log.h>
+#include <media/nbaio/LibsndfileSource.h>
+
+namespace android {
+
+LibsndfileSource::LibsndfileSource(SNDFILE *sndfile, const SF_INFO &sfinfo, bool loop) :
+ NBAIO_Source(Format_from_SR_C(sfinfo.samplerate, sfinfo.channels)),
+ mSndfile(sndfile),
+ mEstimatedFramesUntilEOF(sfinfo.frames),
+ mLooping(loop && sfinfo.seekable),
+ mReadAnyFramesThisLoopCycle(false)
+{
+}
+
+LibsndfileSource::~LibsndfileSource()
+{
+ // do not close mSndfile; we don't own it
+}
+
+ssize_t LibsndfileSource::availableToRead()
+{
+ // after we reach the presumed EOF, report infinity just in case there's actually more
+ return !mLooping && mEstimatedFramesUntilEOF > 0 ? mEstimatedFramesUntilEOF : SSIZE_MAX;
+}
+
+ssize_t LibsndfileSource::read(void *buffer, size_t count)
+{
+ if (!mNegotiated) {
+ return (ssize_t) NEGOTIATE;
+ }
+ if (mSndfile == NULL) {
+ return (ssize_t) NO_INIT;
+ }
+ sf_count_t actual = sf_readf_short(mSndfile, (short *) buffer, (sf_count_t) count);
+ // Detect EOF by zero frames read, not by mFramesUntilEOF as it could be inaccurate
+ if (actual == 0) {
+ if (mLooping) {
+ if (mReadAnyFramesThisLoopCycle) {
+ (void) sf_seek(mSndfile, (sf_count_t) 0, SEEK_SET);
+ mReadAnyFramesThisLoopCycle = false;
+ } else {
+ // We didn't read any frames during the current loop cycle, so disable
+ // further looping to prevent the caller from busy waiting at read().
+ // This is especially important when looping an empty file.
+ mLooping = false;
+ }
+ }
+ } else {
+ mFramesRead += actual;
+ if (actual >= mEstimatedFramesUntilEOF) {
+ mEstimatedFramesUntilEOF = 0;
+ } else {
+ mEstimatedFramesUntilEOF -= actual;
+ }
+ mReadAnyFramesThisLoopCycle = true;
+ }
+ return actual;
+}
+
+} // namespace android
diff --git a/media/libnbaio/MonoPipe.cpp b/media/libnbaio/MonoPipe.cpp
new file mode 100644
index 0000000..e8d3d9b
--- /dev/null
+++ b/media/libnbaio/MonoPipe.cpp
@@ -0,0 +1,313 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "MonoPipe"
+//#define LOG_NDEBUG 0
+
+#include <common_time/cc_helper.h>
+#include <cutils/atomic.h>
+#include <cutils/compiler.h>
+#include <utils/LinearTransform.h>
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <media/AudioBufferProvider.h>
+#include <media/nbaio/MonoPipe.h>
+#include <media/nbaio/roundup.h>
+
+
+namespace android {
+
+MonoPipe::MonoPipe(size_t reqFrames, NBAIO_Format format, bool writeCanBlock) :
+ NBAIO_Sink(format),
+ mUpdateSeq(0),
+ mReqFrames(reqFrames),
+ mMaxFrames(roundup(reqFrames)),
+ mBuffer(malloc(mMaxFrames * Format_frameSize(format))),
+ mFront(0),
+ mRear(0),
+ mWriteTsValid(false),
+ // mWriteTs
+ mSetpoint((reqFrames * 11) / 16),
+ mWriteCanBlock(writeCanBlock),
+ mIsShutdown(false)
+{
+ CCHelper tmpHelper;
+ status_t res;
+ uint64_t N, D;
+
+ mNextRdPTS = AudioBufferProvider::kInvalidPTS;
+
+ mSamplesToLocalTime.a_zero = 0;
+ mSamplesToLocalTime.b_zero = 0;
+ mSamplesToLocalTime.a_to_b_numer = 0;
+ mSamplesToLocalTime.a_to_b_denom = 0;
+
+ D = Format_sampleRate(format);
+ if (OK != (res = tmpHelper.getLocalFreq(&N))) {
+ ALOGE("Failed to fetch local time frequency when constructing a"
+ " MonoPipe (res = %d). getNextWriteTimestamp calls will be"
+ " non-functional", res);
+ return;
+ }
+
+ LinearTransform::reduce(&N, &D);
+ static const uint64_t kSignedHiBitsMask = ~(0x7FFFFFFFull);
+ static const uint64_t kUnsignedHiBitsMask = ~(0xFFFFFFFFull);
+ if ((N & kSignedHiBitsMask) || (D & kUnsignedHiBitsMask)) {
+ ALOGE("Cannot reduce sample rate to local clock frequency ratio to fit"
+ " in a 32/32 bit rational. (max reduction is 0x%016llx/0x%016llx"
+ "). getNextWriteTimestamp calls will be non-functional", N, D);
+ return;
+ }
+
+ mSamplesToLocalTime.a_to_b_numer = static_cast<int32_t>(N);
+ mSamplesToLocalTime.a_to_b_denom = static_cast<uint32_t>(D);
+}
+
+MonoPipe::~MonoPipe()
+{
+ free(mBuffer);
+}
+
+ssize_t MonoPipe::availableToWrite() const
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ // uses mMaxFrames not mReqFrames, so allows "over-filling" the pipe beyond requested limit
+ ssize_t ret = mMaxFrames - (mRear - android_atomic_acquire_load(&mFront));
+ ALOG_ASSERT((0 <= ret) && (ret <= mMaxFrames));
+ return ret;
+}
+
+ssize_t MonoPipe::write(const void *buffer, size_t count)
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ size_t totalFramesWritten = 0;
+ while (count > 0) {
+ // can't return a negative value, as we already checked for !mNegotiated
+ size_t avail = availableToWrite();
+ size_t written = avail;
+ if (CC_LIKELY(written > count)) {
+ written = count;
+ }
+ size_t rear = mRear & (mMaxFrames - 1);
+ size_t part1 = mMaxFrames - rear;
+ if (part1 > written) {
+ part1 = written;
+ }
+ if (CC_LIKELY(part1 > 0)) {
+ memcpy((char *) mBuffer + (rear << mBitShift), buffer, part1 << mBitShift);
+ if (CC_UNLIKELY(rear + part1 == mMaxFrames)) {
+ size_t part2 = written - part1;
+ if (CC_LIKELY(part2 > 0)) {
+ memcpy(mBuffer, (char *) buffer + (part1 << mBitShift), part2 << mBitShift);
+ }
+ }
+ android_atomic_release_store(written + mRear, &mRear);
+ totalFramesWritten += written;
+ }
+ if (!mWriteCanBlock || mIsShutdown) {
+ break;
+ }
+ count -= written;
+ buffer = (char *) buffer + (written << mBitShift);
+ // Simulate blocking I/O by sleeping at different rates, depending on a throttle.
+ // The throttle tries to keep the mean pipe depth near the setpoint, with a slight jitter.
+ uint32_t ns;
+ if (written > 0) {
+ size_t filled = (mMaxFrames - avail) + written;
+ // FIXME cache these values to avoid re-computation
+ if (filled <= mSetpoint / 2) {
+ // pipe is (nearly) empty, fill quickly
+ ns = written * ( 500000000 / Format_sampleRate(mFormat));
+ } else if (filled <= (mSetpoint * 3) / 4) {
+ // pipe is below setpoint, fill at slightly faster rate
+ ns = written * ( 750000000 / Format_sampleRate(mFormat));
+ } else if (filled <= (mSetpoint * 5) / 4) {
+ // pipe is at setpoint, fill at nominal rate
+ ns = written * (1000000000 / Format_sampleRate(mFormat));
+ } else if (filled <= (mSetpoint * 3) / 2) {
+ // pipe is above setpoint, fill at slightly slower rate
+ ns = written * (1150000000 / Format_sampleRate(mFormat));
+ } else if (filled <= (mSetpoint * 7) / 4) {
+ // pipe is overflowing, fill slowly
+ ns = written * (1350000000 / Format_sampleRate(mFormat));
+ } else {
+ // pipe is severely overflowing
+ ns = written * (1750000000 / Format_sampleRate(mFormat));
+ }
+ } else {
+ ns = count * (1350000000 / Format_sampleRate(mFormat));
+ }
+ if (ns > 999999999) {
+ ns = 999999999;
+ }
+ struct timespec nowTs;
+ bool nowTsValid = !clock_gettime(CLOCK_MONOTONIC, &nowTs);
+ // deduct the elapsed time since previous write() completed
+ if (nowTsValid && mWriteTsValid) {
+ time_t sec = nowTs.tv_sec - mWriteTs.tv_sec;
+ long nsec = nowTs.tv_nsec - mWriteTs.tv_nsec;
+ ALOGE_IF(sec < 0 || (sec == 0 && nsec < 0),
+ "clock_gettime(CLOCK_MONOTONIC) failed: was %ld.%09ld but now %ld.%09ld",
+ mWriteTs.tv_sec, mWriteTs.tv_nsec, nowTs.tv_sec, nowTs.tv_nsec);
+ if (nsec < 0) {
+ --sec;
+ nsec += 1000000000;
+ }
+ if (sec == 0) {
+ if ((long) ns > nsec) {
+ ns -= nsec;
+ } else {
+ ns = 0;
+ }
+ }
+ }
+ if (ns > 0) {
+ const struct timespec req = {0, ns};
+ nanosleep(&req, NULL);
+ }
+ // record the time that this write() completed
+ if (nowTsValid) {
+ mWriteTs = nowTs;
+ if ((mWriteTs.tv_nsec += ns) >= 1000000000) {
+ mWriteTs.tv_nsec -= 1000000000;
+ ++mWriteTs.tv_sec;
+ }
+ }
+ mWriteTsValid = nowTsValid;
+ }
+ mFramesWritten += totalFramesWritten;
+ return totalFramesWritten;
+}
+
+void MonoPipe::setAvgFrames(size_t setpoint)
+{
+ mSetpoint = setpoint;
+}
+
+status_t MonoPipe::getNextWriteTimestamp(int64_t *timestamp)
+{
+ int32_t front;
+
+ ALOG_ASSERT(NULL != timestamp);
+
+ if (0 == mSamplesToLocalTime.a_to_b_denom)
+ return UNKNOWN_ERROR;
+
+ observeFrontAndNRPTS(&front, timestamp);
+
+ if (AudioBufferProvider::kInvalidPTS != *timestamp) {
+ // If we have a valid read-pointer and next read timestamp pair, then
+ // use the current value of the write pointer to figure out how many
+ // frames are in the buffer, and offset the timestamp by that amt. Then
+ // next time we write to the MonoPipe, the data will hit the speakers at
+ // the next read timestamp plus the current amount of data in the
+ // MonoPipe.
+ size_t pendingFrames = (mRear - front) & (mMaxFrames - 1);
+ *timestamp = offsetTimestampByAudioFrames(*timestamp, pendingFrames);
+ }
+
+ return OK;
+}
+
+void MonoPipe::updateFrontAndNRPTS(int32_t newFront, int64_t newNextRdPTS)
+{
+ // Set the MSB of the update sequence number to indicate that there is a
+ // multi-variable update in progress. Use an atomic store with an "acquire"
+ // barrier to make sure that the next operations cannot be re-ordered and
+ // take place before the change to mUpdateSeq is commited..
+ int32_t tmp = mUpdateSeq | 0x80000000;
+ android_atomic_acquire_store(tmp, &mUpdateSeq);
+
+ // Update mFront and mNextRdPTS
+ mFront = newFront;
+ mNextRdPTS = newNextRdPTS;
+
+ // We are finished with the update. Compute the next sequnce number (which
+ // should be the old sequence number, plus one, and with the MSB cleared)
+ // and then store it in mUpdateSeq using an atomic store with a "release"
+ // barrier so our update operations cannot be re-ordered past the update of
+ // the sequence number.
+ tmp = (tmp + 1) & 0x7FFFFFFF;
+ android_atomic_release_store(tmp, &mUpdateSeq);
+}
+
+void MonoPipe::observeFrontAndNRPTS(int32_t *outFront, int64_t *outNextRdPTS)
+{
+ // Perform an atomic observation of mFront and mNextRdPTS. Basically,
+ // atomically observe the sequence number, then observer the variables, then
+ // atomically observe the sequence number again. If the two observations of
+ // the sequence number match, and the update-in-progress bit was not set,
+ // then we know we have a successful atomic observation. Otherwise, we loop
+ // around and try again.
+ //
+ // Note, it is very important that the observer be a lower priority thread
+ // than the updater. If the updater is lower than the observer, or they are
+ // the same priority and running with SCHED_FIFO (implying that quantum
+ // based premption is disabled) then we run the risk of deadlock.
+ int32_t seqOne, seqTwo;
+
+ do {
+ seqOne = android_atomic_acquire_load(&mUpdateSeq);
+ *outFront = mFront;
+ *outNextRdPTS = mNextRdPTS;
+ seqTwo = android_atomic_release_load(&mUpdateSeq);
+ } while ((seqOne != seqTwo) || (seqOne & 0x80000000));
+}
+
+int64_t MonoPipe::offsetTimestampByAudioFrames(int64_t ts, size_t audFrames)
+{
+ if (0 == mSamplesToLocalTime.a_to_b_denom)
+ return AudioBufferProvider::kInvalidPTS;
+
+ if (ts == AudioBufferProvider::kInvalidPTS)
+ return AudioBufferProvider::kInvalidPTS;
+
+ int64_t frame_lt_duration;
+ if (!mSamplesToLocalTime.doForwardTransform(audFrames,
+ &frame_lt_duration)) {
+ // This should never fail, but if there is a bug which is causing it
+ // to fail, this message would probably end up flooding the logs
+ // because the conversion would probably fail forever. Log the
+ // error, but then zero out the ratio in the linear transform so
+ // that we don't try to do any conversions from now on. This
+ // MonoPipe's getNextWriteTimestamp is now broken for good.
+ ALOGE("Overflow when attempting to convert %d audio frames to"
+ " duration in local time. getNextWriteTimestamp will fail from"
+ " now on.", audFrames);
+ mSamplesToLocalTime.a_to_b_numer = 0;
+ mSamplesToLocalTime.a_to_b_denom = 0;
+ return AudioBufferProvider::kInvalidPTS;
+ }
+
+ return ts + frame_lt_duration;
+}
+
+void MonoPipe::shutdown(bool newState)
+{
+ mIsShutdown = newState;
+}
+
+bool MonoPipe::isShutdown()
+{
+ return mIsShutdown;
+}
+
+} // namespace android
diff --git a/media/libnbaio/MonoPipeReader.cpp b/media/libnbaio/MonoPipeReader.cpp
new file mode 100644
index 0000000..394f6ac
--- /dev/null
+++ b/media/libnbaio/MonoPipeReader.cpp
@@ -0,0 +1,89 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "MonoPipeReader"
+//#define LOG_NDEBUG 0
+
+#include <cutils/compiler.h>
+#include <utils/Log.h>
+#include <media/nbaio/MonoPipeReader.h>
+
+namespace android {
+
+MonoPipeReader::MonoPipeReader(MonoPipe* pipe) :
+ NBAIO_Source(pipe->mFormat),
+ mPipe(pipe)
+{
+}
+
+MonoPipeReader::~MonoPipeReader()
+{
+}
+
+ssize_t MonoPipeReader::availableToRead()
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ ssize_t ret = android_atomic_acquire_load(&mPipe->mRear) - mPipe->mFront;
+ ALOG_ASSERT((0 <= ret) && (ret <= mMaxFrames));
+ return ret;
+}
+
+ssize_t MonoPipeReader::read(void *buffer, size_t count, int64_t readPTS)
+{
+ // Compute the "next read PTS" and cache it. Callers of read pass a read
+ // PTS indicating the local time for which they are requesting data along
+ // with a count (which is the number of audio frames they are going to
+ // ultimately pass to the next stage of the pipeline). Offsetting readPTS
+ // by the duration of count will give us the readPTS which will be passed to
+ // us next time, assuming they system continues to operate in steady state
+ // with no discontinuities. We stash this value so it can be used by the
+ // MonoPipe writer to imlement getNextWriteTimestamp.
+ int64_t nextReadPTS;
+ nextReadPTS = mPipe->offsetTimestampByAudioFrames(readPTS, count);
+
+ // count == 0 is unlikely and not worth checking for explicitly; will be handled automatically
+ ssize_t red = availableToRead();
+ if (CC_UNLIKELY(red <= 0)) {
+ // Uh-oh, looks like we are underflowing. Update the next read PTS and
+ // get out.
+ mPipe->updateFrontAndNRPTS(mPipe->mFront, nextReadPTS);
+ return red;
+ }
+ if (CC_LIKELY((size_t) red > count)) {
+ red = count;
+ }
+ size_t front = mPipe->mFront & (mPipe->mMaxFrames - 1);
+ size_t part1 = mPipe->mMaxFrames - front;
+ if (part1 > (size_t) red) {
+ part1 = red;
+ }
+ if (CC_LIKELY(part1 > 0)) {
+ memcpy(buffer, (char *) mPipe->mBuffer + (front << mBitShift), part1 << mBitShift);
+ if (CC_UNLIKELY(front + part1 == mPipe->mMaxFrames)) {
+ size_t part2 = red - part1;
+ if (CC_LIKELY(part2 > 0)) {
+ memcpy((char *) buffer + (part1 << mBitShift), mPipe->mBuffer, part2 << mBitShift);
+ }
+ }
+ mPipe->updateFrontAndNRPTS(red + mPipe->mFront, nextReadPTS);
+ mFramesRead += red;
+ }
+ return red;
+}
+
+} // namespace android
diff --git a/media/libnbaio/NBAIO.cpp b/media/libnbaio/NBAIO.cpp
new file mode 100644
index 0000000..00d2017
--- /dev/null
+++ b/media/libnbaio/NBAIO.cpp
@@ -0,0 +1,190 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "NBAIO"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <media/nbaio/NBAIO.h>
+
+namespace android {
+
+size_t Format_frameSize(NBAIO_Format format)
+{
+ switch (format) {
+ case Format_SR44_1_C2_I16:
+ case Format_SR48_C2_I16:
+ return 2 * sizeof(short);
+ case Format_SR44_1_C1_I16:
+ case Format_SR48_C1_I16:
+ return 1 * sizeof(short);
+ case Format_Invalid:
+ default:
+ return 0;
+ }
+}
+
+size_t Format_frameBitShift(NBAIO_Format format)
+{
+ switch (format) {
+ case Format_SR44_1_C2_I16:
+ case Format_SR48_C2_I16:
+ return 2; // 1 << 2 == 2 * sizeof(short)
+ case Format_SR44_1_C1_I16:
+ case Format_SR48_C1_I16:
+ return 1; // 1 << 1 == 1 * sizeof(short)
+ case Format_Invalid:
+ default:
+ return 0;
+ }
+}
+
+unsigned Format_sampleRate(NBAIO_Format format)
+{
+ switch (format) {
+ case Format_SR44_1_C1_I16:
+ case Format_SR44_1_C2_I16:
+ return 44100;
+ case Format_SR48_C1_I16:
+ case Format_SR48_C2_I16:
+ return 48000;
+ case Format_Invalid:
+ default:
+ return 0;
+ }
+}
+
+unsigned Format_channelCount(NBAIO_Format format)
+{
+ switch (format) {
+ case Format_SR44_1_C1_I16:
+ case Format_SR48_C1_I16:
+ return 1;
+ case Format_SR44_1_C2_I16:
+ case Format_SR48_C2_I16:
+ return 2;
+ case Format_Invalid:
+ default:
+ return 0;
+ }
+}
+
+NBAIO_Format Format_from_SR_C(unsigned sampleRate, unsigned channelCount)
+{
+ if (sampleRate == 44100 && channelCount == 2) return Format_SR44_1_C2_I16;
+ if (sampleRate == 48000 && channelCount == 2) return Format_SR48_C2_I16;
+ if (sampleRate == 44100 && channelCount == 1) return Format_SR44_1_C1_I16;
+ if (sampleRate == 48000 && channelCount == 1) return Format_SR48_C1_I16;
+ return Format_Invalid;
+}
+
+// This is a default implementation; it is expected that subclasses will optimize this.
+ssize_t NBAIO_Sink::writeVia(writeVia_t via, size_t total, void *user, size_t block)
+{
+ if (!mNegotiated) {
+ return (ssize_t) NEGOTIATE;
+ }
+ static const size_t maxBlock = 32;
+ size_t frameSize = Format_frameSize(mFormat);
+ ALOG_ASSERT(frameSize > 0 && frameSize <= 8);
+ // double guarantees alignment for stack similar to what malloc() gives for heap
+ if (block == 0 || block > maxBlock) {
+ block = maxBlock;
+ }
+ double buffer[((frameSize * block) + sizeof(double) - 1) / sizeof(double)];
+ size_t accumulator = 0;
+ while (accumulator < total) {
+ size_t count = total - accumulator;
+ if (count > block) {
+ count = block;
+ }
+ ssize_t ret = via(user, buffer, count);
+ if (ret > 0) {
+ ALOG_ASSERT((size_t) ret <= count);
+ size_t maxRet = ret;
+ ret = write(buffer, maxRet);
+ if (ret > 0) {
+ ALOG_ASSERT((size_t) ret <= maxRet);
+ accumulator += ret;
+ continue;
+ }
+ }
+ return accumulator > 0 ? accumulator : ret;
+ }
+ return accumulator;
+}
+
+// This is a default implementation; it is expected that subclasses will optimize this.
+ssize_t NBAIO_Source::readVia(readVia_t via, size_t total, void *user,
+ int64_t readPTS, size_t block)
+{
+ if (!mNegotiated) {
+ return (ssize_t) NEGOTIATE;
+ }
+ static const size_t maxBlock = 32;
+ size_t frameSize = Format_frameSize(mFormat);
+ ALOG_ASSERT(frameSize > 0 && frameSize <= 8);
+ // double guarantees alignment for stack similar to what malloc() gives for heap
+ if (block == 0 || block > maxBlock) {
+ block = maxBlock;
+ }
+ double buffer[((frameSize * block) + sizeof(double) - 1) / sizeof(double)];
+ size_t accumulator = 0;
+ while (accumulator < total) {
+ size_t count = total - accumulator;
+ if (count > block) {
+ count = block;
+ }
+ ssize_t ret = read(buffer, count, readPTS);
+ if (ret > 0) {
+ ALOG_ASSERT((size_t) ret <= count);
+ size_t maxRet = ret;
+ ret = via(user, buffer, maxRet, readPTS);
+ if (ret > 0) {
+ ALOG_ASSERT((size_t) ret <= maxRet);
+ accumulator += ret;
+ continue;
+ }
+ }
+ return accumulator > 0 ? accumulator : ret;
+ }
+ return accumulator;
+}
+
+// Default implementation that only accepts my mFormat
+ssize_t NBAIO_Port::negotiate(const NBAIO_Format offers[], size_t numOffers,
+ NBAIO_Format counterOffers[], size_t& numCounterOffers)
+{
+ ALOGV("negotiate offers=%p numOffers=%u countersOffers=%p numCounterOffers=%u",
+ offers, numOffers, counterOffers, numCounterOffers);
+ if (mFormat != Format_Invalid) {
+ for (size_t i = 0; i < numOffers; ++i) {
+ if (offers[i] == mFormat) {
+ mNegotiated = true;
+ return i;
+ }
+ }
+ if (numCounterOffers > 0) {
+ counterOffers[0] = mFormat;
+ }
+ numCounterOffers = 1;
+ } else {
+ numCounterOffers = 0;
+ }
+ return (ssize_t) NEGOTIATE;
+}
+
+} // namespace android
diff --git a/media/libnbaio/Pipe.cpp b/media/libnbaio/Pipe.cpp
new file mode 100644
index 0000000..1c21f9c
--- /dev/null
+++ b/media/libnbaio/Pipe.cpp
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "Pipe"
+//#define LOG_NDEBUG 0
+
+#include <cutils/atomic.h>
+#include <cutils/compiler.h>
+#include <utils/Log.h>
+#include <media/nbaio/Pipe.h>
+#include <media/nbaio/roundup.h>
+
+namespace android {
+
+Pipe::Pipe(size_t maxFrames, NBAIO_Format format) :
+ NBAIO_Sink(format),
+ mMaxFrames(roundup(maxFrames)),
+ mBuffer(malloc(mMaxFrames * Format_frameSize(format))),
+ mRear(0),
+ mReaders(0)
+{
+}
+
+Pipe::~Pipe()
+{
+ ALOG_ASSERT(android_atomic_acquire_load(&mReaders) == 0);
+ free(mBuffer);
+}
+
+ssize_t Pipe::write(const void *buffer, size_t count)
+{
+ // count == 0 is unlikely and not worth checking for
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ // write() is not multi-thread safe w.r.t. itself, so no mutex or atomic op needed to read mRear
+ size_t rear = mRear & (mMaxFrames - 1);
+ size_t written = mMaxFrames - rear;
+ if (CC_LIKELY(written > count)) {
+ written = count;
+ }
+ memcpy((char *) mBuffer + (rear << mBitShift), buffer, written << mBitShift);
+ if (CC_UNLIKELY(rear + written == mMaxFrames)) {
+ if (CC_UNLIKELY((count -= written) > rear)) {
+ count = rear;
+ }
+ if (CC_LIKELY(count > 0)) {
+ memcpy(mBuffer, (char *) buffer + (written << mBitShift), count << mBitShift);
+ written += count;
+ }
+ }
+ android_atomic_release_store(written + mRear, &mRear);
+ mFramesWritten += written;
+ return written;
+}
+
+} // namespace android
diff --git a/media/libnbaio/PipeReader.cpp b/media/libnbaio/PipeReader.cpp
new file mode 100644
index 0000000..d786b84
--- /dev/null
+++ b/media/libnbaio/PipeReader.cpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "PipeReader"
+//#define LOG_NDEBUG 0
+
+#include <cutils/compiler.h>
+#include <utils/Log.h>
+#include <media/nbaio/PipeReader.h>
+
+namespace android {
+
+PipeReader::PipeReader(Pipe& pipe) :
+ NBAIO_Source(pipe.mFormat),
+ mPipe(pipe),
+ // any data already in the pipe is not visible to this PipeReader
+ mFront(android_atomic_acquire_load(&pipe.mRear)),
+ mFramesOverrun(0),
+ mOverruns(0)
+{
+ android_atomic_inc(&pipe.mReaders);
+}
+
+PipeReader::~PipeReader()
+{
+ int32_t readers = android_atomic_dec(&mPipe.mReaders);
+ ALOG_ASSERT(readers > 0);
+}
+
+ssize_t PipeReader::availableToRead()
+{
+ if (CC_UNLIKELY(!mNegotiated)) {
+ return NEGOTIATE;
+ }
+ int32_t rear = android_atomic_acquire_load(&mPipe.mRear);
+ // read() is not multi-thread safe w.r.t. itself, so no mutex or atomic op needed to read mFront
+ size_t avail = rear - mFront;
+ if (CC_UNLIKELY(avail > mPipe.mMaxFrames)) {
+ // Discard 1/16 of the most recent data in pipe to avoid another overrun immediately
+ int32_t oldFront = mFront;
+ mFront = rear - mPipe.mMaxFrames + (mPipe.mMaxFrames >> 4);
+ mFramesOverrun += (size_t) (mFront - oldFront);
+ ++mOverruns;
+ return OVERRUN;
+ }
+ return avail;
+}
+
+ssize_t PipeReader::read(void *buffer, size_t count, int64_t readPTS)
+{
+ ssize_t avail = availableToRead();
+ if (CC_UNLIKELY(avail <= 0)) {
+ return avail;
+ }
+ // An overrun can occur from here on and be silently ignored,
+ // but it will be caught at next read()
+ if (CC_LIKELY(count > (size_t) avail)) {
+ count = avail;
+ }
+ size_t front = mFront & (mPipe.mMaxFrames - 1);
+ size_t red = mPipe.mMaxFrames - front;
+ if (CC_LIKELY(red > count)) {
+ red = count;
+ }
+ // In particular, an overrun during the memcpy will result in reading corrupt data
+ memcpy(buffer, (char *) mPipe.mBuffer + (front << mBitShift), red << mBitShift);
+ // We could re-read the rear pointer here to detect the corruption, but why bother?
+ if (CC_UNLIKELY(front + red == mPipe.mMaxFrames)) {
+ if (CC_UNLIKELY((count -= red) > front)) {
+ count = front;
+ }
+ if (CC_LIKELY(count > 0)) {
+ memcpy((char *) buffer + (red << mBitShift), mPipe.mBuffer, count << mBitShift);
+ red += count;
+ }
+ }
+ mFront += red;
+ mFramesRead += red;
+ return red;
+}
+
+} // namespace android
diff --git a/media/libnbaio/README.txt b/media/libnbaio/README.txt
new file mode 100644
index 0000000..8d74ab2
--- /dev/null
+++ b/media/libnbaio/README.txt
@@ -0,0 +1,40 @@
+libnbaio (for "Non-Blocking Audio I/O") was originally intended to
+be a purely non-blocking API. It has evolved to now include
+a few blocking implementations of the interface.
+
+Note: as used here, "short transfer count" means the return value for
+read() or write() that indicates the actual number of successfully
+transferred frames is less than the requested number of frames.
+
+Pipe
+----
+supports 1 writer and N readers
+
+no mutexes, so safe to use between SCHED_NORMAL and SCHED_FIFO threads
+
+writes:
+ non-blocking
+ never return a short transfer count
+ overwrite data if not consumed quickly enough
+
+reads:
+ non-blocking
+ return a short transfer count if not enough data
+ will lose data if reader doesn't keep up
+
+MonoPipe
+--------
+supports 1 writer and 1 reader
+
+no mutexes, so safe to use between SCHED_NORMAL and SCHED_FIFO threads
+
+write are optionally blocking:
+ if configured to block, then will wait until space available before returning
+ if configured to not block, then will return a short transfer count
+ and will never overwrite data
+
+reads:
+ non-blocking
+ return a short transfer count if not enough data
+ never lose data
+
diff --git a/media/libnbaio/SourceAudioBufferProvider.cpp b/media/libnbaio/SourceAudioBufferProvider.cpp
new file mode 100644
index 0000000..d11a86c
--- /dev/null
+++ b/media/libnbaio/SourceAudioBufferProvider.cpp
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "SourceAudioBufferProvider"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <media/nbaio/SourceAudioBufferProvider.h>
+
+namespace android {
+
+SourceAudioBufferProvider::SourceAudioBufferProvider(const sp<NBAIO_Source>& source) :
+ mSource(source),
+ // mFrameBitShiftFormat below
+ mAllocated(NULL), mSize(0), mOffset(0), mRemaining(0), mGetCount(0)
+{
+ ALOG_ASSERT(source != 0);
+
+ // negotiate with source
+ NBAIO_Format counterOffers[1];
+ size_t numCounterOffers = 1;
+ ssize_t index = source->negotiate(NULL, 0, counterOffers, numCounterOffers);
+ ALOG_ASSERT(index == (ssize_t) NEGOTIATE && numCounterOffers > 0);
+ numCounterOffers = 0;
+ index = source->negotiate(counterOffers, 1, NULL, numCounterOffers);
+ ALOG_ASSERT(index == 0);
+ mFrameBitShift = Format_frameBitShift(source->format());
+}
+
+SourceAudioBufferProvider::~SourceAudioBufferProvider()
+{
+ free(mAllocated);
+}
+
+status_t SourceAudioBufferProvider::getNextBuffer(Buffer *buffer, int64_t pts)
+{
+ ALOG_ASSERT(buffer != NULL && buffer->frameCount > 0 && mGetCount == 0);
+ // any leftover data available?
+ if (mRemaining > 0) {
+ ALOG_ASSERT(mOffset + mRemaining <= mSize);
+ if (mRemaining < buffer->frameCount) {
+ buffer->frameCount = mRemaining;
+ }
+ buffer->raw = (char *) mAllocated + (mOffset << mFrameBitShift);
+ mGetCount = buffer->frameCount;
+ return OK;
+ }
+ // do we need to reallocate?
+ if (buffer->frameCount > mSize) {
+ free(mAllocated);
+ mAllocated = malloc(buffer->frameCount << mFrameBitShift);
+ mSize = buffer->frameCount;
+ }
+ // read from source
+ ssize_t actual = mSource->read(mAllocated, buffer->frameCount, pts);
+ if (actual > 0) {
+ ALOG_ASSERT((size_t) actual <= buffer->frameCount);
+ mOffset = 0;
+ mRemaining = actual;
+ buffer->raw = mAllocated;
+ buffer->frameCount = actual;
+ mGetCount = actual;
+ return OK;
+ }
+ buffer->raw = NULL;
+ buffer->frameCount = 0;
+ mGetCount = 0;
+ return NOT_ENOUGH_DATA;
+}
+
+void SourceAudioBufferProvider::releaseBuffer(Buffer *buffer)
+{
+ ALOG_ASSERT((buffer != NULL) &&
+ (buffer->raw == (char *) mAllocated + (mOffset << mFrameBitShift)) &&
+ (buffer->frameCount <= mGetCount) &&
+ (mGetCount <= mRemaining) &&
+ (mOffset + mRemaining <= mSize));
+ mOffset += buffer->frameCount;
+ mRemaining -= buffer->frameCount;
+ buffer->raw = NULL;
+ buffer->frameCount = 0;
+ mGetCount = 0;
+}
+
+size_t SourceAudioBufferProvider::framesReady() const
+{
+ ssize_t avail = mSource->availableToRead();
+ return avail < 0 ? 0 : (size_t) avail;
+}
+
+} // namespace android
diff --git a/media/libnbaio/roundup.c b/media/libnbaio/roundup.c
new file mode 100644
index 0000000..1d552d1
--- /dev/null
+++ b/media/libnbaio/roundup.c
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <media/nbaio/roundup.h>
+
+unsigned roundup(unsigned v)
+{
+ // __builtin_clz is undefined for zero input
+ if (v == 0) {
+ v = 1;
+ }
+ int lz = __builtin_clz((int) v);
+ unsigned rounded = ((unsigned) 0x80000000) >> lz;
+ // 0x800000001 and higher are actually rounded _down_ to prevent overflow
+ if (v > rounded && lz > 0) {
+ rounded <<= 1;
+ }
+ return rounded;
+}
diff --git a/media/libstagefright/AACWriter.cpp b/media/libstagefright/AACWriter.cpp
index 284ba01..a6f7cfb 100644
--- a/media/libstagefright/AACWriter.cpp
+++ b/media/libstagefright/AACWriter.cpp
@@ -28,6 +28,8 @@
#include <media/stagefright/MetaData.h>
#include <media/mediarecorder.h>
#include <sys/prctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <fcntl.h>
namespace android {
@@ -44,7 +46,7 @@ AACWriter::AACWriter(const char *filename)
ALOGV("AACWriter Constructor");
- mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
+ mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
if (mFd >= 0) {
mInitCheck = OK;
}
@@ -302,6 +304,7 @@ status_t AACWriter::threadFunc() {
int64_t previousPausedDurationUs = 0;
int64_t maxTimestampUs = 0;
status_t err = OK;
+ bool stoppedPrematurely = true;
prctl(PR_SET_NAME, (unsigned long)"AACWriterThread", 0, 0, 0);
@@ -370,6 +373,18 @@ status_t AACWriter::threadFunc() {
buffer->release();
buffer = NULL;
+
+ if (err != OK) {
+ break;
+ }
+
+ if (stoppedPrematurely) {
+ stoppedPrematurely = false;
+ }
+ }
+
+ if ((err == OK || err == ERROR_END_OF_STREAM) && stoppedPrematurely) {
+ err = ERROR_MALFORMED;
}
close(mFd);
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c4743a1..0ca027b 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -32,8 +32,12 @@
#include <media/stagefright/OMXClient.h>
#include <media/stagefright/OMXCodec.h>
+#include <media/hardware/HardwareAPI.h>
+
#include <OMX_Component.h>
+#include "include/avc_utils.h"
+
namespace android {
template<class T>
@@ -401,6 +405,10 @@ void ACodec::initiateShutdown(bool keepComponentAllocated) {
msg->post();
}
+void ACodec::signalRequestIDRFrame() {
+ (new AMessage(kWhatRequestIDRFrame, id()))->post();
+}
+
status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
CHECK(portIndex == kPortIndexInput || portIndex == kPortIndexOutput);
@@ -595,7 +603,7 @@ status_t ACodec::allocateOutputBuffersFromNativeWindow() {
// Dequeue buffers and send them to OMX
for (OMX_U32 i = 0; i < def.nBufferCountActual; i++) {
ANativeWindowBuffer *buf;
- err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
+ err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf);
if (err != 0) {
ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
break;
@@ -653,7 +661,7 @@ status_t ACodec::cancelBufferToNativeWindow(BufferInfo *info) {
mComponentName.c_str(), info->mBufferID);
int err = mNativeWindow->cancelBuffer(
- mNativeWindow.get(), info->mGraphicBuffer.get());
+ mNativeWindow.get(), info->mGraphicBuffer.get(), -1);
CHECK_EQ(err, 0);
@@ -664,7 +672,8 @@ status_t ACodec::cancelBufferToNativeWindow(BufferInfo *info) {
ACodec::BufferInfo *ACodec::dequeueBufferFromNativeWindow() {
ANativeWindowBuffer *buf;
- if (mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf) != 0) {
+ int fenceFd = -1;
+ if (native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf) != 0) {
ALOGE("dequeueBuffer failed.");
return NULL;
}
@@ -860,6 +869,47 @@ status_t ACodec::configureCodec(
return INVALID_OPERATION;
}
+ int32_t storeMeta;
+ if (encoder
+ && msg->findInt32("store-metadata-in-buffers", &storeMeta)
+ && storeMeta != 0) {
+ err = mOMX->storeMetaDataInBuffers(mNode, kPortIndexInput, OMX_TRUE);
+
+ if (err != OK) {
+ ALOGE("[%s] storeMetaDataInBuffers failed w/ err %d",
+ mComponentName.c_str(), err);
+
+ return err;
+ }
+ }
+
+ int32_t prependSPSPPS;
+ if (encoder
+ && msg->findInt32("prepend-sps-pps-to-idr-frames", &prependSPSPPS)
+ && prependSPSPPS != 0) {
+ OMX_INDEXTYPE index;
+ err = mOMX->getExtensionIndex(
+ mNode,
+ "OMX.google.android.index.prependSPSPPSToIDRFrames",
+ &index);
+
+ if (err == OK) {
+ PrependSPSPPSToIDRFramesParams params;
+ InitOMXParams(&params);
+ params.bEnable = OMX_TRUE;
+
+ err = mOMX->setParameter(
+ mNode, index, &params, sizeof(params));
+ }
+
+ if (err != OK) {
+ ALOGE("Encoder could not be configured to emit SPS/PPS before "
+ "IDR frames. (err %d)", err);
+
+ return err;
+ }
+ }
+
if (!strncasecmp(mime, "video/", 6)) {
if (encoder) {
err = setupVideoEncoder(mime, msg);
@@ -1357,7 +1407,8 @@ status_t ACodec::setSupportedOutputFormat() {
|| format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar
|| format.eColorFormat == OMX_COLOR_FormatCbYCrY
|| format.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar
- || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar);
+ || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar
+ || format.eColorFormat == OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka);
return mOMX->setParameter(
mNode, OMX_IndexParamVideoPortFormat,
@@ -1585,6 +1636,15 @@ static OMX_U32 setPFramesSpacing(int32_t iFramesInterval, int32_t frameRate) {
return ret;
}
+static OMX_VIDEO_CONTROLRATETYPE getBitrateMode(const sp<AMessage> &msg) {
+ int32_t tmp;
+ if (!msg->findInt32("bitrate-mode", &tmp)) {
+ return OMX_Video_ControlRateVariable;
+ }
+
+ return static_cast<OMX_VIDEO_CONTROLRATETYPE>(tmp);
+}
+
status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) {
int32_t bitrate, iFrameInterval;
if (!msg->findInt32("bitrate", &bitrate)
@@ -1592,6 +1652,8 @@ status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) {
return INVALID_OPERATION;
}
+ OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg);
+
float frameRate;
if (!msg->findFloat("frame-rate", &frameRate)) {
int32_t tmp;
@@ -1655,7 +1717,7 @@ status_t ACodec::setupMPEG4EncoderParameters(const sp<AMessage> &msg) {
return err;
}
- err = configureBitrate(bitrate);
+ err = configureBitrate(bitrate, bitrateMode);
if (err != OK) {
return err;
@@ -1671,6 +1733,8 @@ status_t ACodec::setupH263EncoderParameters(const sp<AMessage> &msg) {
return INVALID_OPERATION;
}
+ OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg);
+
float frameRate;
if (!msg->findFloat("frame-rate", &frameRate)) {
int32_t tmp;
@@ -1729,7 +1793,7 @@ status_t ACodec::setupH263EncoderParameters(const sp<AMessage> &msg) {
return err;
}
- err = configureBitrate(bitrate);
+ err = configureBitrate(bitrate, bitrateMode);
if (err != OK) {
return err;
@@ -1745,6 +1809,8 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
return INVALID_OPERATION;
}
+ OMX_VIDEO_CONTROLRATETYPE bitrateMode = getBitrateMode(msg);
+
float frameRate;
if (!msg->findFloat("frame-rate", &frameRate)) {
int32_t tmp;
@@ -1830,7 +1896,7 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
return err;
}
- return configureBitrate(bitrate);
+ return configureBitrate(bitrate, bitrateMode);
}
status_t ACodec::verifySupportForProfileAndLevel(
@@ -1859,7 +1925,8 @@ status_t ACodec::verifySupportForProfileAndLevel(
}
}
-status_t ACodec::configureBitrate(int32_t bitrate) {
+status_t ACodec::configureBitrate(
+ int32_t bitrate, OMX_VIDEO_CONTROLRATETYPE bitrateMode) {
OMX_VIDEO_PARAM_BITRATETYPE bitrateType;
InitOMXParams(&bitrateType);
bitrateType.nPortIndex = kPortIndexOutput;
@@ -1872,7 +1939,7 @@ status_t ACodec::configureBitrate(int32_t bitrate) {
return err;
}
- bitrateType.eControlRate = OMX_Video_ControlRateVariable;
+ bitrateType.eControlRate = bitrateMode;
bitrateType.nTargetBitrate = bitrate;
return mOMX->setParameter(
@@ -2188,7 +2255,8 @@ status_t ACodec::pushBlankBuffersToNativeWindow() {
// on the screen and then been replaced, so an previous video frames are
// guaranteed NOT to be currently displayed.
for (int i = 0; i < numBufs + 1; i++) {
- err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &anb);
+ int fenceFd = -1;
+ err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &anb);
if (err != NO_ERROR) {
ALOGE("error pushing blank frames: dequeueBuffer failed: %s (%d)",
strerror(-err), -err);
@@ -2196,13 +2264,6 @@ status_t ACodec::pushBlankBuffersToNativeWindow() {
}
sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- err = mNativeWindow->lockBuffer(mNativeWindow.get(),
- buf->getNativeBuffer());
- if (err != NO_ERROR) {
- ALOGE("error pushing blank frames: lockBuffer failed: %s (%d)",
- strerror(-err), -err);
- goto error;
- }
// Fill the buffer with the a 1x1 checkerboard pattern ;)
uint32_t* img = NULL;
@@ -2223,7 +2284,7 @@ status_t ACodec::pushBlankBuffersToNativeWindow() {
}
err = mNativeWindow->queueBuffer(mNativeWindow.get(),
- buf->getNativeBuffer());
+ buf->getNativeBuffer(), -1);
if (err != NO_ERROR) {
ALOGE("error pushing blank frames: queueBuffer failed: %s (%d)",
strerror(-err), -err);
@@ -2238,7 +2299,7 @@ error:
if (err != NO_ERROR) {
// Clean up after an error.
if (anb != NULL) {
- mNativeWindow->cancelBuffer(mNativeWindow.get(), anb);
+ mNativeWindow->cancelBuffer(mNativeWindow.get(), anb, -1);
}
native_window_api_disconnect(mNativeWindow.get(),
@@ -2274,6 +2335,24 @@ error:
ACodec::PortDescription::PortDescription() {
}
+status_t ACodec::requestIDRFrame() {
+ if (!mIsEncoder) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ OMX_CONFIG_INTRAREFRESHVOPTYPE params;
+ InitOMXParams(&params);
+
+ params.nPortIndex = kPortIndexOutput;
+ params.IntraRefreshVOP = OMX_TRUE;
+
+ return mOMX->setConfig(
+ mNode,
+ OMX_IndexConfigVideoIntraVOPRefresh,
+ &params,
+ sizeof(params));
+}
+
void ACodec::PortDescription::addBuffer(
IOMX::buffer_id id, const sp<ABuffer> &buffer) {
mBufferIDs.push_back(id);
@@ -2428,6 +2507,24 @@ bool ACodec::BaseState::onOMXEmptyBufferDone(IOMX::buffer_id bufferID) {
CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_COMPONENT);
info->mStatus = BufferInfo::OWNED_BY_US;
+ const sp<AMessage> &bufferMeta = info->mData->meta();
+ void *mediaBuffer;
+ if (bufferMeta->findPointer("mediaBuffer", &mediaBuffer)
+ && mediaBuffer != NULL) {
+ // We're in "store-metadata-in-buffers" mode, the underlying
+ // OMX component had access to data that's implicitly refcounted
+ // by this "mediaBuffer" object. Now that the OMX component has
+ // told us that it's done with the input buffer, we can decrement
+ // the mediaBuffer's reference count.
+
+ ALOGV("releasing mbuf %p", mediaBuffer);
+
+ ((MediaBuffer *)mediaBuffer)->release();
+ mediaBuffer = NULL;
+
+ bufferMeta->setPointer("mediaBuffer", NULL);
+ }
+
PortMode mode = getPortMode(kPortIndexInput);
switch (mode) {
@@ -2535,10 +2632,10 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
}
if (buffer != info->mData) {
- if (0 && !(flags & OMX_BUFFERFLAG_CODECCONFIG)) {
- ALOGV("[%s] Needs to copy input data.",
- mCodec->mComponentName.c_str());
- }
+ ALOGV("[%s] Needs to copy input data for buffer %p. (%p != %p)",
+ mCodec->mComponentName.c_str(),
+ bufferID,
+ buffer.get(), info->mData.get());
CHECK_LE(buffer->size(), info->mData->capacity());
memcpy(info->mData->data(), buffer->data(), buffer->size());
@@ -2551,10 +2648,22 @@ void ACodec::BaseState::onInputBufferFilled(const sp<AMessage> &msg) {
ALOGV("[%s] calling emptyBuffer %p w/ EOS",
mCodec->mComponentName.c_str(), bufferID);
} else {
+#if TRACK_BUFFER_TIMING
+ ALOGI("[%s] calling emptyBuffer %p w/ time %lld us",
+ mCodec->mComponentName.c_str(), bufferID, timeUs);
+#else
ALOGV("[%s] calling emptyBuffer %p w/ time %lld us",
mCodec->mComponentName.c_str(), bufferID, timeUs);
+#endif
}
+#if TRACK_BUFFER_TIMING
+ ACodec::BufferStats stats;
+ stats.mEmptyBufferTimeUs = ALooper::GetNowUs();
+ stats.mFillBufferDoneTimeUs = -1ll;
+ mCodec->mBufferStats.add(timeUs, stats);
+#endif
+
CHECK_EQ(mCodec->mOMX->emptyBuffer(
mCodec->mNode,
bufferID,
@@ -2651,6 +2760,22 @@ bool ACodec::BaseState::onOMXFillBufferDone(
mCodec->mComponentName.c_str(), bufferID, timeUs, flags);
ssize_t index;
+
+#if TRACK_BUFFER_TIMING
+ index = mCodec->mBufferStats.indexOfKey(timeUs);
+ if (index >= 0) {
+ ACodec::BufferStats *stats = &mCodec->mBufferStats.editValueAt(index);
+ stats->mFillBufferDoneTimeUs = ALooper::GetNowUs();
+
+ ALOGI("frame PTS %lld: %lld",
+ timeUs,
+ stats->mFillBufferDoneTimeUs - stats->mEmptyBufferTimeUs);
+
+ mCodec->mBufferStats.removeItemsAt(index);
+ stats = NULL;
+ }
+#endif
+
BufferInfo *info =
mCodec->findBufferByID(kPortIndexOutput, bufferID, &index);
@@ -2684,6 +2809,12 @@ bool ACodec::BaseState::onOMXFillBufferDone(
if (mCodec->mNativeWindow == NULL) {
info->mData->setRange(rangeOffset, rangeLength);
+
+#if 0
+ if (IsIDR(info->mData)) {
+ ALOGI("IDR frame");
+ }
+#endif
}
if (mCodec->mSkipCutBuffer != NULL) {
@@ -2751,7 +2882,7 @@ void ACodec::BaseState::onOutputBufferDrained(const sp<AMessage> &msg) {
status_t err;
if ((err = mCodec->mNativeWindow->queueBuffer(
mCodec->mNativeWindow.get(),
- info->mGraphicBuffer.get())) == OK) {
+ info->mGraphicBuffer.get(), -1)) == OK) {
info->mStatus = BufferInfo::OWNED_BY_NATIVE_WINDOW;
} else {
mCodec->signalError(OMX_ErrorUndefined, err);
@@ -2890,20 +3021,21 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
sp<IOMX> omx = client.interface();
- Vector<String8> matchingCodecs;
- Vector<uint32_t> matchingCodecQuirks;
+ Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
AString mime;
AString componentName;
- uint32_t quirks;
+ uint32_t quirks = 0;
if (msg->findString("componentName", &componentName)) {
- matchingCodecs.push_back(String8(componentName.c_str()));
+ ssize_t index = matchingCodecs.add();
+ OMXCodec::CodecNameAndQuirks *entry = &matchingCodecs.editItemAt(index);
+ entry->mName = String8(componentName.c_str());
- if (!OMXCodec::findCodecQuirks(componentName.c_str(), &quirks)) {
- quirks = 0;
+ if (!OMXCodec::findCodecQuirks(
+ componentName.c_str(), &entry->mQuirks)) {
+ entry->mQuirks = 0;
}
- matchingCodecQuirks.push_back(quirks);
} else {
CHECK(msg->findString("mime", &mime));
@@ -2917,8 +3049,7 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
encoder, // createEncoder
NULL, // matchComponentName
0, // flags
- &matchingCodecs,
- &matchingCodecQuirks);
+ &matchingCodecs);
}
sp<CodecObserver> observer = new CodecObserver;
@@ -2926,8 +3057,8 @@ bool ACodec::UninitializedState::onAllocateComponent(const sp<AMessage> &msg) {
for (size_t matchIndex = 0; matchIndex < matchingCodecs.size();
++matchIndex) {
- componentName = matchingCodecs.itemAt(matchIndex).string();
- quirks = matchingCodecQuirks.itemAt(matchIndex);
+ componentName = matchingCodecs.itemAt(matchIndex).mName.string();
+ quirks = matchingCodecs.itemAt(matchIndex).mQuirks;
pid_t tid = androidGetTid();
int prevPriority = androidGetThreadPriority(tid);
@@ -3253,11 +3384,6 @@ void ACodec::ExecutingState::submitOutputBuffers() {
if (info->mStatus == BufferInfo::OWNED_BY_NATIVE_WINDOW) {
continue;
}
-
- status_t err = mCodec->mNativeWindow->lockBuffer(
- mCodec->mNativeWindow.get(),
- info->mGraphicBuffer.get());
- CHECK_EQ(err, (status_t)OK);
} else {
CHECK_EQ((int)info->mStatus, (int)BufferInfo::OWNED_BY_US);
}
@@ -3352,6 +3478,17 @@ bool ACodec::ExecutingState::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatRequestIDRFrame:
+ {
+ status_t err = mCodec->requestIDRFrame();
+ if (err != OK) {
+ ALOGW("Requesting an IDR frame failed.");
+ }
+
+ handled = true;
+ break;
+ }
+
default:
handled = BaseState::onMessageReceived(msg);
break;
diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp
index ca85640..8d5eec8 100644
--- a/media/libstagefright/AMRWriter.cpp
+++ b/media/libstagefright/AMRWriter.cpp
@@ -36,7 +36,7 @@ AMRWriter::AMRWriter(const char *filename)
mPaused(false),
mResumed(false) {
- mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
+ mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
if (mFd >= 0) {
mInitCheck = OK;
}
@@ -254,11 +254,14 @@ status_t AMRWriter::threadFunc() {
if (n < (ssize_t)buffer->range_length()) {
buffer->release();
buffer = NULL;
+ err = ERROR_IO;
+ break;
+ }
+ if (err != OK) {
break;
}
- // XXX: How to tell it is stopped prematurely?
if (stoppedPrematurely) {
stoppedPrematurely = false;
}
@@ -267,8 +270,8 @@ status_t AMRWriter::threadFunc() {
buffer = NULL;
}
- if (stoppedPrematurely) {
- notify(MEDIA_RECORDER_EVENT_INFO, MEDIA_RECORDER_TRACK_INFO_COMPLETION_STATUS, UNKNOWN_ERROR);
+ if ((err == OK || err == ERROR_END_OF_STREAM) && stoppedPrematurely) {
+ err = ERROR_MALFORMED;
}
close(mFd);
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index ac50470..cc0581e 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -19,6 +19,7 @@ LOCAL_SRC_FILES:= \
ESDS.cpp \
FileSource.cpp \
FLACExtractor.cpp \
+ FragmentedMP4Extractor.cpp \
HTTPBase.cpp \
JPEGSource.cpp \
MP3Extractor.cpp \
@@ -53,6 +54,8 @@ LOCAL_SRC_FILES:= \
WVMExtractor.cpp \
XINGSeeker.cpp \
avc_utils.cpp \
+ mp4/FragmentedMP4Parser.cpp \
+ mp4/TrackFragment.cpp \
LOCAL_C_INCLUDES:= \
$(TOP)/frameworks/av/include/media/stagefright/timedtext \
@@ -80,6 +83,7 @@ LOCAL_SHARED_LIBRARIES := \
libssl \
libstagefright_omx \
libstagefright_yuv \
+ libsync \
libui \
libutils \
libvorbisidec \
@@ -91,18 +95,15 @@ LOCAL_STATIC_LIBRARIES := \
libstagefright_matroska \
libstagefright_timedtext \
libvpx \
+ libwebm \
libstagefright_mpeg2ts \
libstagefright_httplive \
libstagefright_id3 \
libFLAC \
-ifneq ($(TARGET_BUILD_PDK), true)
-LOCAL_STATIC_LIBRARIES += \
- libstagefright_chromium_http
-LOCAL_SHARED_LIBRARIES += \
- libchromium_net
+LOCAL_SRC_FILES += \
+ chromium_http_stub.cpp
LOCAL_CPPFLAGS += -DCHROMIUM_AVAILABLE=1
-endif
LOCAL_SHARED_LIBRARIES += libstlport
include external/stlport/libstlport.mk
@@ -117,6 +118,8 @@ LOCAL_CFLAGS += -Wno-multichar
LOCAL_MODULE:= libstagefright
+LOCAL_MODULE_TAGS := optional
+
include $(BUILD_SHARED_LIBRARY)
include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 72d797e..861aebe 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -24,6 +24,7 @@
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
#include <cutils/properties.h>
#include <stdlib.h>
@@ -33,7 +34,7 @@ static void AudioRecordCallbackFunction(int event, void *user, void *info) {
AudioSource *source = (AudioSource *) user;
switch (event) {
case AudioRecord::EVENT_MORE_DATA: {
- source->dataCallbackTimestamp(*((AudioRecord::Buffer *) info), systemTime() / 1000);
+ source->dataCallback(*((AudioRecord::Buffer *) info));
break;
}
case AudioRecord::EVENT_OVERRUN: {
@@ -48,12 +49,12 @@ static void AudioRecordCallbackFunction(int event, void *user, void *info) {
AudioSource::AudioSource(
audio_source_t inputSource, uint32_t sampleRate, uint32_t channelCount)
- : mStarted(false),
+ : mRecord(NULL),
+ mStarted(false),
mSampleRate(sampleRate),
mPrevSampleTimeUs(0),
mNumFramesReceived(0),
mNumClientOwnedBuffers(0) {
-
ALOGV("sampleRate: %d, channelCount: %d", sampleRate, channelCount);
CHECK(channelCount == 1 || channelCount == 2);
@@ -61,7 +62,7 @@ AudioSource::AudioSource(
status_t status = AudioRecord::getMinFrameCount(&minFrameCount,
sampleRate,
AUDIO_FORMAT_PCM_16_BIT,
- channelCount);
+ audio_channel_in_mask_from_count(channelCount));
if (status == OK) {
// make sure that the AudioRecord callback never returns more than the maximum
// buffer size
@@ -73,15 +74,10 @@ AudioSource::AudioSource(
bufCount++;
}
- AudioRecord::record_flags flags = (AudioRecord::record_flags)
- (AudioRecord::RECORD_AGC_ENABLE |
- AudioRecord::RECORD_NS_ENABLE |
- AudioRecord::RECORD_IIR_ENABLE);
mRecord = new AudioRecord(
inputSource, sampleRate, AUDIO_FORMAT_PCM_16_BIT,
audio_channel_in_mask_from_count(channelCount),
bufCount * frameCount,
- flags,
AudioRecordCallbackFunction,
this,
frameCount);
@@ -275,8 +271,9 @@ void AudioSource::signalBufferReturned(MediaBuffer *buffer) {
return;
}
-status_t AudioSource::dataCallbackTimestamp(
- const AudioRecord::Buffer& audioBuffer, int64_t timeUs) {
+status_t AudioSource::dataCallback(const AudioRecord::Buffer& audioBuffer) {
+ int64_t timeUs = systemTime() / 1000ll;
+
ALOGV("dataCallbackTimestamp: %lld us", timeUs);
Mutex::Autolock autoLock(mLock);
if (!mStarted) {
@@ -300,6 +297,7 @@ status_t AudioSource::dataCallbackTimestamp(
// Assume latency is constant.
mStartTimeUs += mRecord->latency() * 1000;
}
+
mPrevSampleTimeUs = mStartTimeUs;
}
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 0f346d8..1e2625a 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -130,7 +130,7 @@ struct AwesomeNativeWindowRenderer : public AwesomeRenderer {
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
native_window_set_buffers_timestamp(mNativeWindow.get(), timeUs * 1000);
status_t err = mNativeWindow->queueBuffer(
- mNativeWindow.get(), buffer->graphicBuffer().get());
+ mNativeWindow.get(), buffer->graphicBuffer().get(), -1);
if (err != 0) {
ALOGE("queueBuffer failed with error %s (%d)", strerror(-err),
-err);
@@ -183,6 +183,7 @@ AwesomePlayer::AwesomePlayer()
: mQueueStarted(false),
mUIDValid(false),
mTimeSource(NULL),
+ mVideoRenderingStarted(false),
mVideoRendererIsPreview(false),
mAudioPlayer(NULL),
mDisplayWidth(0),
@@ -280,11 +281,7 @@ status_t AwesomePlayer::setDataSource_l(
}
}
- if (!(mFlags & INCOGNITO)) {
- ALOGI("setDataSource_l('%s')", mUri.string());
- } else {
- ALOGI("setDataSource_l(URL suppressed)");
- }
+ ALOGI("setDataSource_l(URL suppressed)");
// The actual work will be done during preparation in the call to
// ::finishSetDataSource_l to avoid blocking the calling thread in
@@ -454,7 +451,11 @@ status_t AwesomePlayer::setDataSource_l(const sp<MediaExtractor> &extractor) {
}
if (!haveAudio && !haveVideo) {
- return UNKNOWN_ERROR;
+ if (mWVMExtractor != NULL) {
+ return mWVMExtractor->getError();
+ } else {
+ return UNKNOWN_ERROR;
+ }
}
mExtractorFlags = extractor->flags();
@@ -468,6 +469,7 @@ void AwesomePlayer::reset() {
}
void AwesomePlayer::reset_l() {
+ mVideoRenderingStarted = false;
mActiveAudioTrackIndex = -1;
mDisplayWidth = 0;
mDisplayHeight = 0;
@@ -710,7 +712,6 @@ void AwesomePlayer::onBufferingUpdate() {
kHighWaterMarkBytes);
modifyFlags(CACHE_UNDERRUN, CLEAR);
play_l();
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
} else if (mFlags & PREPARING) {
ALOGV("cache has filled up (> %d), prepare is done",
kHighWaterMarkBytes);
@@ -754,23 +755,18 @@ void AwesomePlayer::onBufferingUpdate() {
if ((mFlags & PLAYING) && !eos
&& (cachedDurationUs < kLowWaterMarkUs)) {
modifyFlags(CACHE_UNDERRUN, SET);
- if (mWVMExtractor == NULL) {
- ALOGI("cache is running low (%.2f secs) , pausing.",
- cachedDurationUs / 1E6);
- pause_l();
- ensureCacheIsFetching_l();
- sendCacheStats();
- }
+ ALOGI("cache is running low (%.2f secs) , pausing.",
+ cachedDurationUs / 1E6);
+ pause_l();
+ ensureCacheIsFetching_l();
+ sendCacheStats();
notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_START);
} else if (eos || cachedDurationUs > kHighWaterMarkUs) {
if (mFlags & CACHE_UNDERRUN) {
modifyFlags(CACHE_UNDERRUN, CLEAR);
- if (mWVMExtractor == NULL) {
- ALOGI("cache has filled up (%.2f secs), resuming.",
- cachedDurationUs / 1E6);
- play_l();
- }
- notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
+ ALOGI("cache has filled up (%.2f secs), resuming.",
+ cachedDurationUs / 1E6);
+ play_l();
} else if (mFlags & PREPARING) {
ALOGV("cache has filled up (%.2f secs), prepare is done",
cachedDurationUs / 1E6);
@@ -784,9 +780,14 @@ void AwesomePlayer::onBufferingUpdate() {
void AwesomePlayer::sendCacheStats() {
sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL && mCachedSource != NULL) {
+ if (listener != NULL) {
int32_t kbps = 0;
- status_t err = mCachedSource->getEstimatedBandwidthKbps(&kbps);
+ status_t err = UNKNOWN_ERROR;
+ if (mCachedSource != NULL) {
+ err = mCachedSource->getEstimatedBandwidthKbps(&kbps);
+ } else if (mWVMExtractor != NULL) {
+ err = mWVMExtractor->getEstimatedBandwidthKbps(&kbps);
+ }
if (err == OK) {
listener->sendEvent(
MEDIA_INFO, MEDIA_INFO_NETWORK_BANDWIDTH, kbps);
@@ -1503,6 +1504,7 @@ status_t AwesomePlayer::initVideoDecoder(uint32_t flags) {
status_t err = mVideoSource->start();
if (err != OK) {
+ ALOGE("failed to start video source");
mVideoSource.clear();
return err;
}
@@ -1705,7 +1707,8 @@ void AwesomePlayer::onVideoEvent() {
}
}
- if ((mFlags & TEXTPLAYER_INITIALIZED) && !(mFlags & (TEXT_RUNNING | SEEK_PREVIEW))) {
+ if ((mFlags & TEXTPLAYER_INITIALIZED)
+ && !(mFlags & (TEXT_RUNNING | SEEK_PREVIEW))) {
mTextDriver->start();
modifyFlags(TEXT_RUNNING, SET);
}
@@ -1751,17 +1754,24 @@ void AwesomePlayer::onVideoEvent() {
&& mAudioPlayer != NULL
&& mAudioPlayer->getMediaTimeMapping(
&realTimeUs, &mediaTimeUs)) {
- ALOGI("we're much too late (%.2f secs), video skipping ahead",
- latenessUs / 1E6);
+ if (mWVMExtractor == NULL) {
+ ALOGI("we're much too late (%.2f secs), video skipping ahead",
+ latenessUs / 1E6);
- mVideoBuffer->release();
- mVideoBuffer = NULL;
+ mVideoBuffer->release();
+ mVideoBuffer = NULL;
- mSeeking = SEEK_VIDEO_ONLY;
- mSeekTimeUs = mediaTimeUs;
+ mSeeking = SEEK_VIDEO_ONLY;
+ mSeekTimeUs = mediaTimeUs;
- postVideoEvent_l();
- return;
+ postVideoEvent_l();
+ return;
+ } else {
+ // The widevine extractor doesn't deal well with seeking
+ // audio and video independently. We'll just have to wait
+ // until the decoder catches up, which won't be long at all.
+ ALOGI("we're very late (%.2f secs)", latenessUs / 1E6);
+ }
}
if (latenessUs > 40000) {
@@ -1807,6 +1817,11 @@ void AwesomePlayer::onVideoEvent() {
if (mVideoRenderer != NULL) {
mSinceLastDropped++;
mVideoRenderer->render(mVideoBuffer);
+ if (!mVideoRenderingStarted) {
+ mVideoRenderingStarted = true;
+ notifyListener_l(MEDIA_INFO, MEDIA_INFO_RENDERING_START);
+ }
+
}
mVideoBuffer->release();
@@ -2577,7 +2592,7 @@ status_t AwesomePlayer::dump(int fd, const Vector<String16> &args) const {
fprintf(out, " AwesomePlayer\n");
if (mStats.mFd < 0) {
- fprintf(out, " URI(%s)", mStats.mURI.string());
+ fprintf(out, " URI(suppressed)");
} else {
fprintf(out, " fd(%d)", mStats.mFd);
}
@@ -2626,6 +2641,9 @@ void AwesomePlayer::modifyFlags(unsigned value, FlagMode mode) {
mFlags |= value;
break;
case CLEAR:
+ if ((value & CACHE_UNDERRUN) && (mFlags & CACHE_UNDERRUN)) {
+ notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
+ }
mFlags &= ~value;
break;
case ASSIGN:
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 3ddad93..efd7af7 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -111,6 +111,10 @@ static int32_t getColorFormat(const char* colorFormat) {
return OMX_TI_COLOR_FormatYUV420PackedSemiPlanar;
}
+ if (!strcmp(colorFormat, CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE)) {
+ return OMX_COLOR_FormatAndroidOpaque;
+ }
+
ALOGE("Uknown color format (%s), please add it to "
"CameraSource::getColorFormat", colorFormat);
@@ -151,6 +155,7 @@ CameraSource::CameraSource(
const sp<Surface>& surface,
bool storeMetaDataInVideoBuffers)
: mCameraFlags(0),
+ mNumInputBuffers(0),
mVideoFrameRate(-1),
mCamera(0),
mSurface(surface),
@@ -567,6 +572,18 @@ void CameraSource::startCameraRecording() {
// camera and recording is started by the applications. The applications
// will connect to the camera in ICameraRecordingProxy::startRecording.
int64_t token = IPCThreadState::self()->clearCallingIdentity();
+ if (mNumInputBuffers > 0) {
+ status_t err = mCamera->sendCommand(
+ CAMERA_CMD_SET_VIDEO_BUFFER_COUNT, mNumInputBuffers, 0);
+
+ // This could happen for CameraHAL1 clients; thus the failure is
+ // not a fatal error
+ if (err != OK) {
+ ALOGW("Failed to set video buffer count to %d due to %d",
+ mNumInputBuffers, err);
+ }
+ }
+
if (mCameraFlags & FLAGS_HOT_CAMERA) {
mCamera->unlock();
mCamera.clear();
@@ -595,9 +612,18 @@ status_t CameraSource::start(MetaData *meta) {
}
mStartTimeUs = 0;
- int64_t startTimeUs;
- if (meta && meta->findInt64(kKeyTime, &startTimeUs)) {
- mStartTimeUs = startTimeUs;
+ mNumInputBuffers = 0;
+ if (meta) {
+ int64_t startTimeUs;
+ if (meta->findInt64(kKeyTime, &startTimeUs)) {
+ mStartTimeUs = startTimeUs;
+ }
+
+ int32_t nBuffers;
+ if (meta->findInt32(kKeyNumBuffers, &nBuffers)) {
+ CHECK_GT(nBuffers, 0);
+ mNumInputBuffers = nBuffers;
+ }
}
startCameraRecording();
diff --git a/media/libstagefright/DRMExtractor.cpp b/media/libstagefright/DRMExtractor.cpp
index 524c3aa..63cb430 100644
--- a/media/libstagefright/DRMExtractor.cpp
+++ b/media/libstagefright/DRMExtractor.cpp
@@ -15,11 +15,6 @@
*/
#include "include/DRMExtractor.h"
-#include "include/AMRExtractor.h"
-#include "include/MP3Extractor.h"
-#include "include/MPEG4Extractor.h"
-#include "include/WAVExtractor.h"
-#include "include/OggExtractor.h"
#include <arpa/inet.h>
#include <utils/String8.h>
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index c75f100..9d0eea2 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -17,20 +17,21 @@
#include "include/AMRExtractor.h"
#if CHROMIUM_AVAILABLE
-#include "include/DataUriSource.h"
+#include "include/chromium_http_stub.h"
#endif
+#include "include/AACExtractor.h"
+#include "include/DRMExtractor.h"
+#include "include/FLACExtractor.h"
+#include "include/FragmentedMP4Extractor.h"
+#include "include/HTTPBase.h"
#include "include/MP3Extractor.h"
-#include "include/MPEG4Extractor.h"
-#include "include/WAVExtractor.h"
-#include "include/OggExtractor.h"
#include "include/MPEG2PSExtractor.h"
#include "include/MPEG2TSExtractor.h"
+#include "include/MPEG4Extractor.h"
#include "include/NuCachedSource2.h"
-#include "include/HTTPBase.h"
-#include "include/DRMExtractor.h"
-#include "include/FLACExtractor.h"
-#include "include/AACExtractor.h"
+#include "include/OggExtractor.h"
+#include "include/WAVExtractor.h"
#include "include/WVMExtractor.h"
#include "matroska/MatroskaExtractor.h"
@@ -110,6 +111,7 @@ void DataSource::RegisterSniffer(SnifferFunc func) {
// static
void DataSource::RegisterDefaultSniffers() {
RegisterSniffer(SniffMPEG4);
+ RegisterSniffer(SniffFragmentedMP4);
RegisterSniffer(SniffMatroska);
RegisterSniffer(SniffOgg);
RegisterSniffer(SniffWAV);
@@ -173,7 +175,7 @@ sp<DataSource> DataSource::CreateFromURI(
# if CHROMIUM_AVAILABLE
} else if (!strncasecmp("data:", uri, 5)) {
- source = new DataUriSource(uri);
+ source = createDataUriSource(uri);
#endif
} else {
// Assume it's a filename.
diff --git a/media/libstagefright/FLACExtractor.cpp b/media/libstagefright/FLACExtractor.cpp
index 668d7f7..098fcf9 100644
--- a/media/libstagefright/FLACExtractor.cpp
+++ b/media/libstagefright/FLACExtractor.cpp
@@ -122,7 +122,7 @@ private:
// media buffers
size_t mMaxBufferSize;
MediaBufferGroup *mGroup;
- void (*mCopy)(short *dst, const int *const *src, unsigned nSamples);
+ void (*mCopy)(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels);
// handle to underlying libFLAC parser
FLAC__StreamDecoder *mDecoder;
@@ -350,7 +350,7 @@ void FLACParser::metadataCallback(const FLAC__StreamMetadata *metadata)
for (FLAC__uint32 i = 0; i < vc->num_comments; ++i) {
FLAC__StreamMetadata_VorbisComment_Entry *vce;
vce = &vc->comments[i];
- if (mFileMetadata != 0) {
+ if (mFileMetadata != 0 && vce->entry != NULL) {
parseVorbisComment(mFileMetadata, (const char *) vce->entry,
vce->length);
}
@@ -380,14 +380,14 @@ void FLACParser::errorCallback(FLAC__StreamDecoderErrorStatus status)
// Copy samples from FLAC native 32-bit non-interleaved to 16-bit interleaved.
// These are candidates for optimization if needed.
-static void copyMono8(short *dst, const int *const *src, unsigned nSamples)
+static void copyMono8(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i] << 8;
}
}
-static void copyStereo8(short *dst, const int *const *src, unsigned nSamples)
+static void copyStereo8(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i] << 8;
@@ -395,14 +395,23 @@ static void copyStereo8(short *dst, const int *const *src, unsigned nSamples)
}
}
-static void copyMono16(short *dst, const int *const *src, unsigned nSamples)
+static void copyMultiCh8(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
+{
+ for (unsigned i = 0; i < nSamples; ++i) {
+ for (unsigned c = 0; c < nChannels; ++c) {
+ *dst++ = src[c][i] << 8;
+ }
+ }
+}
+
+static void copyMono16(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i];
}
}
-static void copyStereo16(short *dst, const int *const *src, unsigned nSamples)
+static void copyStereo16(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i];
@@ -410,16 +419,25 @@ static void copyStereo16(short *dst, const int *const *src, unsigned nSamples)
}
}
+static void copyMultiCh16(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
+{
+ for (unsigned i = 0; i < nSamples; ++i) {
+ for (unsigned c = 0; c < nChannels; ++c) {
+ *dst++ = src[c][i];
+ }
+ }
+}
+
// 24-bit versions should do dithering or noise-shaping, here or in AudioFlinger
-static void copyMono24(short *dst, const int *const *src, unsigned nSamples)
+static void copyMono24(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i] >> 8;
}
}
-static void copyStereo24(short *dst, const int *const *src, unsigned nSamples)
+static void copyStereo24(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
for (unsigned i = 0; i < nSamples; ++i) {
*dst++ = src[0][i] >> 8;
@@ -427,7 +445,16 @@ static void copyStereo24(short *dst, const int *const *src, unsigned nSamples)
}
}
-static void copyTrespass(short *dst, const int *const *src, unsigned nSamples)
+static void copyMultiCh24(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
+{
+ for (unsigned i = 0; i < nSamples; ++i) {
+ for (unsigned c = 0; c < nChannels; ++c) {
+ *dst++ = src[c][i] >> 8;
+ }
+ }
+}
+
+static void copyTrespass(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels)
{
TRESPASS();
}
@@ -507,11 +534,7 @@ status_t FLACParser::init()
}
if (mStreamInfoValid) {
// check channel count
- switch (getChannels()) {
- case 1:
- case 2:
- break;
- default:
+ if (getChannels() == 0 || getChannels() > 8) {
ALOGE("unsupported channel count %u", getChannels());
return NO_INIT;
}
@@ -536,9 +559,10 @@ status_t FLACParser::init()
case 32000:
case 44100:
case 48000:
+ case 88200:
+ case 96000:
break;
default:
- // 96000 would require a proper downsampler in AudioFlinger
ALOGE("unsupported sample rate %u", getSampleRate());
return NO_INIT;
}
@@ -546,17 +570,20 @@ status_t FLACParser::init()
static const struct {
unsigned mChannels;
unsigned mBitsPerSample;
- void (*mCopy)(short *dst, const int *const *src, unsigned nSamples);
+ void (*mCopy)(short *dst, const int *const *src, unsigned nSamples, unsigned nChannels);
} table[] = {
{ 1, 8, copyMono8 },
{ 2, 8, copyStereo8 },
+ { 8, 8, copyMultiCh8 },
{ 1, 16, copyMono16 },
{ 2, 16, copyStereo16 },
+ { 8, 16, copyMultiCh16 },
{ 1, 24, copyMono24 },
{ 2, 24, copyStereo24 },
+ { 8, 24, copyMultiCh24 },
};
for (unsigned i = 0; i < sizeof(table)/sizeof(table[0]); ++i) {
- if (table[i].mChannels == getChannels() &&
+ if (table[i].mChannels >= getChannels() &&
table[i].mBitsPerSample == getBitsPerSample()) {
mCopy = table[i].mCopy;
break;
@@ -640,7 +667,7 @@ MediaBuffer *FLACParser::readBuffer(bool doSeek, FLAC__uint64 sample)
short *data = (short *) buffer->data();
buffer->set_range(0, bufferSize);
// copy PCM from FLAC write buffer to our media buffer, with interleaving
- (*mCopy)(data, mWriteBuffer, blocksize);
+ (*mCopy)(data, mWriteBuffer, blocksize, getChannels());
// fill in buffer metadata
CHECK(mWriteHeader.number_type == FLAC__FRAME_NUMBER_TYPE_SAMPLE_NUMBER);
FLAC__uint64 sampleNumber = mWriteHeader.number.sample_number;
diff --git a/media/libstagefright/FragmentedMP4Extractor.cpp b/media/libstagefright/FragmentedMP4Extractor.cpp
new file mode 100644
index 0000000..82712ef
--- /dev/null
+++ b/media/libstagefright/FragmentedMP4Extractor.cpp
@@ -0,0 +1,460 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "FragmentedMP4Extractor"
+#include <utils/Log.h>
+
+#include "include/FragmentedMP4Extractor.h"
+#include "include/SampleTable.h"
+#include "include/ESDS.h"
+
+#include <arpa/inet.h>
+
+#include <ctype.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <cutils/properties.h> // for property_get
+
+#include <media/stagefright/foundation/ABitReader.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaBufferGroup.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+#include <media/stagefright/Utils.h>
+#include <utils/String8.h>
+
+namespace android {
+
+class FragmentedMPEG4Source : public MediaSource {
+public:
+ // Caller retains ownership of the Parser
+ FragmentedMPEG4Source(bool audio,
+ const sp<MetaData> &format,
+ const sp<FragmentedMP4Parser> &parser,
+ const sp<FragmentedMP4Extractor> &extractor);
+
+ 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);
+
+protected:
+ virtual ~FragmentedMPEG4Source();
+
+private:
+ Mutex mLock;
+
+ sp<MetaData> mFormat;
+ sp<FragmentedMP4Parser> mParser;
+ sp<FragmentedMP4Extractor> mExtractor;
+ bool mIsAudioTrack;
+ uint32_t mCurrentSampleIndex;
+
+ bool mIsAVC;
+ size_t mNALLengthSize;
+
+ bool mStarted;
+
+ MediaBufferGroup *mGroup;
+
+ bool mWantsNALFragments;
+
+ uint8_t *mSrcBuffer;
+
+ FragmentedMPEG4Source(const FragmentedMPEG4Source &);
+ FragmentedMPEG4Source &operator=(const FragmentedMPEG4Source &);
+};
+
+
+FragmentedMP4Extractor::FragmentedMP4Extractor(const sp<DataSource> &source)
+ : mLooper(new ALooper),
+ mParser(new FragmentedMP4Parser()),
+ mDataSource(source),
+ mInitCheck(NO_INIT),
+ mFileMetaData(new MetaData) {
+ ALOGV("FragmentedMP4Extractor");
+ mLooper->registerHandler(mParser);
+ mLooper->start(false /* runOnCallingThread */);
+ mParser->start(mDataSource);
+
+ bool hasVideo = mParser->getFormat(false /* audio */, true /* synchronous */) != NULL;
+ bool hasAudio = mParser->getFormat(true /* audio */, true /* synchronous */) != NULL;
+
+ ALOGV("number of tracks: %d", countTracks());
+
+ if (hasVideo) {
+ mFileMetaData->setCString(
+ kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_MPEG4);
+ } else if (hasAudio) {
+ mFileMetaData->setCString(kKeyMIMEType, "audio/mp4");
+ } else {
+ ALOGE("no audio and no video, no idea what file type this is");
+ }
+ // tracks are numbered such that video track is first, audio track is second
+ if (hasAudio && hasVideo) {
+ mTrackCount = 2;
+ mAudioTrackIndex = 1;
+ } else if (hasAudio) {
+ mTrackCount = 1;
+ mAudioTrackIndex = 0;
+ } else if (hasVideo) {
+ mTrackCount = 1;
+ mAudioTrackIndex = -1;
+ } else {
+ mTrackCount = 0;
+ mAudioTrackIndex = -1;
+ }
+}
+
+FragmentedMP4Extractor::~FragmentedMP4Extractor() {
+ ALOGV("~FragmentedMP4Extractor");
+ mLooper->stop();
+}
+
+uint32_t FragmentedMP4Extractor::flags() const {
+ return CAN_PAUSE |
+ (mParser->isSeekable() ? (CAN_SEEK_BACKWARD | CAN_SEEK_FORWARD | CAN_SEEK) : 0);
+}
+
+sp<MetaData> FragmentedMP4Extractor::getMetaData() {
+ return mFileMetaData;
+}
+
+size_t FragmentedMP4Extractor::countTracks() {
+ return mTrackCount;
+}
+
+
+sp<MetaData> FragmentedMP4Extractor::getTrackMetaData(
+ size_t index, uint32_t flags) {
+ if (index >= countTracks()) {
+ return NULL;
+ }
+
+ sp<AMessage> msg = mParser->getFormat(index == mAudioTrackIndex, true /* synchronous */);
+
+ if (msg == NULL) {
+ ALOGV("got null format for track %d", index);
+ return NULL;
+ }
+
+ sp<MetaData> meta = new MetaData();
+ convertMessageToMetaData(msg, meta);
+ return meta;
+}
+
+static void MakeFourCCString(uint32_t x, char *s) {
+ s[0] = x >> 24;
+ s[1] = (x >> 16) & 0xff;
+ s[2] = (x >> 8) & 0xff;
+ s[3] = x & 0xff;
+ s[4] = '\0';
+}
+
+sp<MediaSource> FragmentedMP4Extractor::getTrack(size_t index) {
+ if (index >= countTracks()) {
+ return NULL;
+ }
+ return new FragmentedMPEG4Source(index == mAudioTrackIndex, getTrackMetaData(index, 0), mParser, this);
+}
+
+
+////////////////////////////////////////////////////////////////////////////////
+
+FragmentedMPEG4Source::FragmentedMPEG4Source(
+ bool audio,
+ const sp<MetaData> &format,
+ const sp<FragmentedMP4Parser> &parser,
+ const sp<FragmentedMP4Extractor> &extractor)
+ : mFormat(format),
+ mParser(parser),
+ mExtractor(extractor),
+ mIsAudioTrack(audio),
+ mStarted(false),
+ mGroup(NULL),
+ mWantsNALFragments(false),
+ mSrcBuffer(NULL) {
+}
+
+FragmentedMPEG4Source::~FragmentedMPEG4Source() {
+ if (mStarted) {
+ stop();
+ }
+}
+
+status_t FragmentedMPEG4Source::start(MetaData *params) {
+ Mutex::Autolock autoLock(mLock);
+
+ CHECK(!mStarted);
+
+ int32_t val;
+ if (params && params->findInt32(kKeyWantsNALFragments, &val)
+ && val != 0) {
+ mWantsNALFragments = true;
+ } else {
+ mWantsNALFragments = false;
+ }
+ ALOGV("caller wants NAL fragments: %s", mWantsNALFragments ? "yes" : "no");
+
+ mGroup = new MediaBufferGroup;
+
+ int32_t max_size = 65536;
+ // XXX CHECK(mFormat->findInt32(kKeyMaxInputSize, &max_size));
+
+ mGroup->add_buffer(new MediaBuffer(max_size));
+
+ mSrcBuffer = new uint8_t[max_size];
+
+ mStarted = true;
+
+ return OK;
+}
+
+status_t FragmentedMPEG4Source::stop() {
+ Mutex::Autolock autoLock(mLock);
+
+ CHECK(mStarted);
+
+ delete[] mSrcBuffer;
+ mSrcBuffer = NULL;
+
+ delete mGroup;
+ mGroup = NULL;
+
+ mStarted = false;
+ mCurrentSampleIndex = 0;
+
+ return OK;
+}
+
+sp<MetaData> FragmentedMPEG4Source::getFormat() {
+ Mutex::Autolock autoLock(mLock);
+
+ return mFormat;
+}
+
+
+status_t FragmentedMPEG4Source::read(
+ MediaBuffer **out, const ReadOptions *options) {
+ int64_t seekTimeUs;
+ ReadOptions::SeekMode mode;
+ if (options && options->getSeekTo(&seekTimeUs, &mode)) {
+ mParser->seekTo(mIsAudioTrack, seekTimeUs);
+ }
+ MediaBuffer *buffer = NULL;
+ mGroup->acquire_buffer(&buffer);
+ sp<ABuffer> parseBuffer;
+
+ status_t ret = mParser->dequeueAccessUnit(mIsAudioTrack, &parseBuffer, true /* synchronous */);
+ if (ret != OK) {
+ buffer->release();
+ ALOGV("returning %d", ret);
+ return ret;
+ }
+ sp<AMessage> meta = parseBuffer->meta();
+ int64_t timeUs;
+ CHECK(meta->findInt64("timeUs", &timeUs));
+ buffer->meta_data()->setInt64(kKeyTime, timeUs);
+ buffer->set_range(0, parseBuffer->size());
+ memcpy(buffer->data(), parseBuffer->data(), parseBuffer->size());
+ *out = buffer;
+ return OK;
+}
+
+
+static bool isCompatibleBrand(uint32_t fourcc) {
+ static const uint32_t kCompatibleBrands[] = {
+ FOURCC('i', 's', 'o', 'm'),
+ FOURCC('i', 's', 'o', '2'),
+ FOURCC('a', 'v', 'c', '1'),
+ FOURCC('3', 'g', 'p', '4'),
+ FOURCC('m', 'p', '4', '1'),
+ FOURCC('m', 'p', '4', '2'),
+
+ // Won't promise that the following file types can be played.
+ // Just give these file types a chance.
+ FOURCC('q', 't', ' ', ' '), // Apple's QuickTime
+ FOURCC('M', 'S', 'N', 'V'), // Sony's PSP
+
+ FOURCC('3', 'g', '2', 'a'), // 3GPP2
+ FOURCC('3', 'g', '2', 'b'),
+ };
+
+ for (size_t i = 0;
+ i < sizeof(kCompatibleBrands) / sizeof(kCompatibleBrands[0]);
+ ++i) {
+ if (kCompatibleBrands[i] == fourcc) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+// Attempt to actually parse the 'ftyp' atom and determine if a suitable
+// compatible brand is present.
+// Also try to identify where this file's metadata ends
+// (end of the 'moov' atom) and report it to the caller as part of
+// the metadata.
+static bool Sniff(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *meta) {
+ // We scan up to 128k bytes to identify this file as an MP4.
+ static const off64_t kMaxScanOffset = 128ll * 1024ll;
+
+ off64_t offset = 0ll;
+ bool foundGoodFileType = false;
+ bool isFragmented = false;
+ off64_t moovAtomEndOffset = -1ll;
+ bool done = false;
+
+ while (!done && offset < kMaxScanOffset) {
+ uint32_t hdr[2];
+ if (source->readAt(offset, hdr, 8) < 8) {
+ return false;
+ }
+
+ uint64_t chunkSize = ntohl(hdr[0]);
+ uint32_t chunkType = ntohl(hdr[1]);
+ off64_t chunkDataOffset = offset + 8;
+
+ if (chunkSize == 1) {
+ if (source->readAt(offset + 8, &chunkSize, 8) < 8) {
+ return false;
+ }
+
+ chunkSize = ntoh64(chunkSize);
+ chunkDataOffset += 8;
+
+ if (chunkSize < 16) {
+ // The smallest valid chunk is 16 bytes long in this case.
+ return false;
+ }
+ } else if (chunkSize < 8) {
+ // The smallest valid chunk is 8 bytes long.
+ return false;
+ }
+
+ off64_t chunkDataSize = offset + chunkSize - chunkDataOffset;
+
+ char chunkstring[5];
+ MakeFourCCString(chunkType, chunkstring);
+ ALOGV("saw chunk type %s, size %lld @ %lld", chunkstring, chunkSize, offset);
+ switch (chunkType) {
+ case FOURCC('f', 't', 'y', 'p'):
+ {
+ if (chunkDataSize < 8) {
+ return false;
+ }
+
+ uint32_t numCompatibleBrands = (chunkDataSize - 8) / 4;
+ for (size_t i = 0; i < numCompatibleBrands + 2; ++i) {
+ if (i == 1) {
+ // Skip this index, it refers to the minorVersion,
+ // not a brand.
+ continue;
+ }
+
+ uint32_t brand;
+ if (source->readAt(
+ chunkDataOffset + 4 * i, &brand, 4) < 4) {
+ return false;
+ }
+
+ brand = ntohl(brand);
+ char brandstring[5];
+ MakeFourCCString(brand, brandstring);
+ ALOGV("Brand: %s", brandstring);
+
+ if (isCompatibleBrand(brand)) {
+ foundGoodFileType = true;
+ break;
+ }
+ }
+
+ if (!foundGoodFileType) {
+ return false;
+ }
+
+ break;
+ }
+
+ case FOURCC('m', 'o', 'o', 'v'):
+ {
+ moovAtomEndOffset = offset + chunkSize;
+ break;
+ }
+
+ case FOURCC('m', 'o', 'o', 'f'):
+ {
+ // this is kind of broken, since we might not actually find a
+ // moof box in the first 128k.
+ isFragmented = true;
+ done = true;
+ break;
+ }
+
+ default:
+ break;
+ }
+
+ offset += chunkSize;
+ }
+
+ if (!foundGoodFileType || !isFragmented) {
+ return false;
+ }
+
+ *mimeType = MEDIA_MIMETYPE_CONTAINER_MPEG4;
+ *confidence = 0.5f; // slightly more than MPEG4Extractor
+
+ if (moovAtomEndOffset >= 0) {
+ *meta = new AMessage;
+ (*meta)->setInt64("meta-data-size", moovAtomEndOffset);
+ (*meta)->setInt32("fragmented", 1); // tell MediaExtractor what to instantiate
+
+ ALOGV("found metadata size: %lld", moovAtomEndOffset);
+ }
+
+ return true;
+}
+
+// used by DataSource::RegisterDefaultSniffers
+bool SniffFragmentedMP4(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *meta) {
+ ALOGV("SniffFragmentedMP4");
+ char prop[PROPERTY_VALUE_MAX];
+ if (property_get("media.stagefright.use-fragmp4", prop, NULL)
+ && (!strcmp(prop, "1") || !strcasecmp(prop, "true"))) {
+ return Sniff(source, mimeType, confidence, meta);
+ }
+
+ return false;
+}
+
+} // namespace android
diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp
index d7eea3f..40bfc55 100644
--- a/media/libstagefright/HTTPBase.cpp
+++ b/media/libstagefright/HTTPBase.cpp
@@ -21,7 +21,7 @@
#include "include/HTTPBase.h"
#if CHROMIUM_AVAILABLE
-#include "include/ChromiumHTTPDataSource.h"
+#include "include/chromium_http_stub.h"
#endif
#include <media/stagefright/foundation/ADebug.h>
@@ -46,7 +46,10 @@ HTTPBase::HTTPBase()
// static
sp<HTTPBase> HTTPBase::Create(uint32_t flags) {
#if CHROMIUM_AVAILABLE
- return new ChromiumHTTPDataSource(flags);
+ HTTPBase *dataSource = createChromiumHTTPDataSource(flags);
+ if (dataSource) {
+ return dataSource;
+ }
#endif
{
TRESPASS();
diff --git a/media/libstagefright/MP3Extractor.cpp b/media/libstagefright/MP3Extractor.cpp
index 6abaf23..380dab4 100644
--- a/media/libstagefright/MP3Extractor.cpp
+++ b/media/libstagefright/MP3Extractor.cpp
@@ -228,6 +228,7 @@ protected:
virtual ~MP3Source();
private:
+ static const size_t kMaxFrameSize;
sp<MetaData> mMeta;
sp<DataSource> mDataSource;
off64_t mFirstFramePos;
@@ -349,8 +350,10 @@ MP3Extractor::MP3Extractor(
mInitCheck = OK;
- // get iTunes-style gapless info if present
- ID3 id3(mDataSource);
+ // Get iTunes-style gapless info if present.
+ // When getting the id3 tag, skip the V1 tags to prevent the source cache
+ // from being iterated to the end of the file.
+ ID3 id3(mDataSource, true);
if (id3.isValid()) {
ID3::Iterator *com = new ID3::Iterator(id3, "COM");
if (com->done()) {
@@ -405,6 +408,13 @@ sp<MetaData> MP3Extractor::getTrackMetaData(size_t index, uint32_t flags) {
////////////////////////////////////////////////////////////////////////////////
+// The theoretical maximum frame size for an MPEG audio stream should occur
+// while playing a Layer 2, MPEGv2.5 audio stream at 160kbps (with padding).
+// The size of this frame should be...
+// ((1152 samples/frame * 160000 bits/sec) /
+// (8000 samples/sec * 8 bits/byte)) + 1 padding byte/frame = 2881 bytes/frame.
+// Set our max frame size to the nearest power of 2 above this size (aka, 4kB)
+const size_t MP3Source::kMaxFrameSize = (1 << 12); /* 4096 bytes */
MP3Source::MP3Source(
const sp<MetaData> &meta, const sp<DataSource> &source,
off64_t first_frame_pos, uint32_t fixed_header,
@@ -433,7 +443,6 @@ status_t MP3Source::start(MetaData *) {
mGroup = new MediaBufferGroup;
- const size_t kMaxFrameSize = 32768;
mGroup->add_buffer(new MediaBuffer(kMaxFrameSize));
mCurrentPos = mFirstFramePos;
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index a572541..1a62f9d 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
#define LOG_TAG "MPEG4Extractor"
#include <utils/Log.h>
@@ -29,6 +30,7 @@
#include <string.h>
#include <media/stagefright/foundation/ABitReader.h>
+#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/DataSource.h>
@@ -408,7 +410,7 @@ char* MPEG4Extractor::getDrmTrackInfo(size_t trackID, int *len) {
}
// Reads an encoded integer 7 bits at a time until it encounters the high bit clear.
-int32_t readSize(off64_t offset,
+static int32_t readSize(off64_t offset,
const sp<DataSource> DataSource, uint8_t *numOfBytes) {
uint32_t size = 0;
uint8_t data;
@@ -1220,18 +1222,15 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
case FOURCC('a', 'v', 'c', 'C'):
{
- char buffer[256];
- if (chunk_data_size > (off64_t)sizeof(buffer)) {
- return ERROR_BUFFER_TOO_SMALL;
- }
+ sp<ABuffer> buffer = new ABuffer(chunk_data_size);
if (mDataSource->readAt(
- data_offset, buffer, chunk_data_size) < chunk_data_size) {
+ data_offset, buffer->data(), chunk_data_size) < chunk_data_size) {
return ERROR_IO;
}
mLastTrack->meta->setData(
- kKeyAVCC, kTypeAVCC, buffer, chunk_data_size);
+ kKeyAVCC, kTypeAVCC, buffer->data(), chunk_data_size);
*offset += chunk_size;
break;
@@ -1425,18 +1424,15 @@ status_t MPEG4Extractor::parseChunk(off64_t *offset, int depth) {
if (mFileMetaData != NULL) {
ALOGV("chunk_data_size = %lld and data_offset = %lld",
chunk_data_size, data_offset);
- uint8_t *buffer = new uint8_t[chunk_data_size + 1];
+ sp<ABuffer> buffer = new ABuffer(chunk_data_size + 1);
if (mDataSource->readAt(
- data_offset, buffer, chunk_data_size) != (ssize_t)chunk_data_size) {
- delete[] buffer;
- buffer = NULL;
-
+ data_offset, buffer->data(), chunk_data_size) != (ssize_t)chunk_data_size) {
return ERROR_IO;
}
const int kSkipBytesOfDataBox = 16;
mFileMetaData->setData(
kKeyAlbumArt, MetaData::TYPE_NONE,
- buffer + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox);
+ buffer->data() + kSkipBytesOfDataBox, chunk_data_size - kSkipBytesOfDataBox);
}
*offset += chunk_size;
@@ -1632,8 +1628,9 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) {
{
if (size == 16 && flags == 0) {
char tmp[16];
- sprintf(tmp, "%d/%d",
- (int)buffer[size - 5], (int)buffer[size - 3]);
+ uint16_t* pTrack = (uint16_t*)&buffer[10];
+ uint16_t* pTotalTracks = (uint16_t*)&buffer[12];
+ sprintf(tmp, "%d/%d", ntohs(*pTrack), ntohs(*pTotalTracks));
mFileMetaData->setCString(kKeyCDTrackNumber, tmp);
}
@@ -1641,10 +1638,11 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) {
}
case FOURCC('d', 'i', 's', 'k'):
{
- if (size == 14 && flags == 0) {
+ if ((size == 14 || size == 16) && flags == 0) {
char tmp[16];
- sprintf(tmp, "%d/%d",
- (int)buffer[size - 3], (int)buffer[size - 1]);
+ uint16_t* pDisc = (uint16_t*)&buffer[10];
+ uint16_t* pTotalDiscs = (uint16_t*)&buffer[12];
+ sprintf(tmp, "%d/%d", ntohs(*pDisc), ntohs(*pTotalDiscs));
mFileMetaData->setCString(kKeyDiscNumber, tmp);
}
@@ -1664,15 +1662,26 @@ status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) {
mLastCommentData.setTo((const char *)buffer + 8);
break;
}
- if (mLastCommentMean == "com.apple.iTunes"
- && mLastCommentName == "iTunSMPB"
- && mLastCommentData.length() != 0) {
- int32_t delay, padding;
- if (sscanf(mLastCommentData,
- " %*x %x %x %*x", &delay, &padding) == 2) {
- mLastTrack->meta->setInt32(kKeyEncoderDelay, delay);
- mLastTrack->meta->setInt32(kKeyEncoderPadding, padding);
+
+ // Once we have a set of mean/name/data info, go ahead and process
+ // it to see if its something we are interested in. Whether or not
+ // were are interested in the specific tag, make sure to clear out
+ // the set so we can be ready to process another tuple should one
+ // show up later in the file.
+ if ((mLastCommentMean.length() != 0) &&
+ (mLastCommentName.length() != 0) &&
+ (mLastCommentData.length() != 0)) {
+
+ if (mLastCommentMean == "com.apple.iTunes"
+ && mLastCommentName == "iTunSMPB") {
+ int32_t delay, padding;
+ if (sscanf(mLastCommentData,
+ " %*x %x %x %*x", &delay, &padding) == 2) {
+ mLastTrack->meta->setInt32(kKeyEncoderDelay, delay);
+ mLastTrack->meta->setInt32(kKeyEncoderPadding, padding);
+ }
}
+
mLastCommentMean.clear();
mLastCommentName.clear();
mLastCommentData.clear();
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 6108298..8b52e15 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -42,6 +42,7 @@
namespace android {
+static const int64_t kMinStreamableFileSizeInBytes = 5 * 1024 * 1024;
static const int64_t kMax32BitFileSize = 0x007fffffffLL;
static const uint8_t kNalUnitTypeSeqParamSet = 0x07;
static const uint8_t kNalUnitTypePicParamSet = 0x08;
@@ -75,6 +76,128 @@ private:
kSampleArraySize = 1000,
};
+ // A helper class to handle faster write box with table entries
+ template<class TYPE>
+ struct ListTableEntries {
+ ListTableEntries(uint32_t elementCapacity, uint32_t entryCapacity)
+ : mElementCapacity(elementCapacity),
+ mEntryCapacity(entryCapacity),
+ mTotalNumTableEntries(0),
+ mNumValuesInCurrEntry(0),
+ mCurrTableEntriesElement(NULL) {
+ CHECK_GT(mElementCapacity, 0);
+ CHECK_GT(mEntryCapacity, 0);
+ }
+
+ // Free the allocated memory.
+ ~ListTableEntries() {
+ while (!mTableEntryList.empty()) {
+ typename List<TYPE *>::iterator it = mTableEntryList.begin();
+ delete[] (*it);
+ mTableEntryList.erase(it);
+ }
+ }
+
+ // Replace the value at the given position by the given value.
+ // There must be an existing value at the given position.
+ // @arg value must be in network byte order
+ // @arg pos location the value must be in.
+ void set(const TYPE& value, uint32_t pos) {
+ CHECK_LT(pos, mTotalNumTableEntries * mEntryCapacity);
+
+ typename List<TYPE *>::iterator it = mTableEntryList.begin();
+ uint32_t iterations = (pos / (mElementCapacity * mEntryCapacity));
+ while (it != mTableEntryList.end() && iterations > 0) {
+ ++it;
+ --iterations;
+ }
+ CHECK(it != mTableEntryList.end());
+ CHECK_EQ(iterations, 0);
+
+ (*it)[(pos % (mElementCapacity * mEntryCapacity))] = value;
+ }
+
+ // Get the value at the given position by the given value.
+ // @arg value the retrieved value at the position in network byte order.
+ // @arg pos location the value must be in.
+ // @return true if a value is found.
+ bool get(TYPE& value, uint32_t pos) const {
+ if (pos >= mTotalNumTableEntries * mEntryCapacity) {
+ return false;
+ }
+
+ typename List<TYPE *>::iterator it = mTableEntryList.begin();
+ uint32_t iterations = (pos / (mElementCapacity * mEntryCapacity));
+ while (it != mTableEntryList.end() && iterations > 0) {
+ ++it;
+ --iterations;
+ }
+ CHECK(it != mTableEntryList.end());
+ CHECK_EQ(iterations, 0);
+
+ value = (*it)[(pos % (mElementCapacity * mEntryCapacity))];
+ return true;
+ }
+
+ // Store a single value.
+ // @arg value must be in network byte order.
+ void add(const TYPE& value) {
+ CHECK_LT(mNumValuesInCurrEntry, mElementCapacity);
+ uint32_t nEntries = mTotalNumTableEntries % mElementCapacity;
+ uint32_t nValues = mNumValuesInCurrEntry % mEntryCapacity;
+ if (nEntries == 0 && nValues == 0) {
+ mCurrTableEntriesElement = new TYPE[mEntryCapacity * mElementCapacity];
+ CHECK(mCurrTableEntriesElement != NULL);
+ mTableEntryList.push_back(mCurrTableEntriesElement);
+ }
+
+ uint32_t pos = nEntries * mEntryCapacity + nValues;
+ mCurrTableEntriesElement[pos] = value;
+
+ ++mNumValuesInCurrEntry;
+ if ((mNumValuesInCurrEntry % mEntryCapacity) == 0) {
+ ++mTotalNumTableEntries;
+ mNumValuesInCurrEntry = 0;
+ }
+ }
+
+ // Write out the table entries:
+ // 1. the number of entries goes first
+ // 2. followed by the values in the table enties in order
+ // @arg writer the writer to actual write to the storage
+ void write(MPEG4Writer *writer) const {
+ CHECK_EQ(mNumValuesInCurrEntry % mEntryCapacity, 0);
+ uint32_t nEntries = mTotalNumTableEntries;
+ writer->writeInt32(nEntries);
+ for (typename List<TYPE *>::iterator it = mTableEntryList.begin();
+ it != mTableEntryList.end(); ++it) {
+ CHECK_GT(nEntries, 0);
+ if (nEntries >= mElementCapacity) {
+ writer->write(*it, sizeof(TYPE) * mEntryCapacity, mElementCapacity);
+ nEntries -= mElementCapacity;
+ } else {
+ writer->write(*it, sizeof(TYPE) * mEntryCapacity, nEntries);
+ break;
+ }
+ }
+ }
+
+ // Return the number of entries in the table.
+ uint32_t count() const { return mTotalNumTableEntries; }
+
+ private:
+ uint32_t mElementCapacity; // # entries in an element
+ uint32_t mEntryCapacity; // # of values in each entry
+ uint32_t mTotalNumTableEntries;
+ uint32_t mNumValuesInCurrEntry; // up to mEntryCapacity
+ TYPE *mCurrTableEntriesElement;
+ mutable List<TYPE *> mTableEntryList;
+
+ DISALLOW_EVIL_CONSTRUCTORS(ListTableEntries);
+ };
+
+
+
MPEG4Writer *mOwner;
sp<MetaData> mMeta;
sp<MediaSource> mSource;
@@ -90,67 +213,25 @@ private:
int64_t mMaxChunkDurationUs;
bool mIsRealTimeRecording;
- int64_t mMaxTimeStampUs;
int64_t mEstimatedTrackSizeBytes;
int64_t mMdatSizeBytes;
int32_t mTimeScale;
pthread_t mThread;
- /*
- * mNumSamples is used to track the total number of samples in
- * mSampleSizes List.
- *
- * A linked list of fixed sized array is used here to reduce the time
- * to write out stsz box.
- */
- uint32_t mNumSamples;
- uint32_t* mCurrentSampleSizeArr;
- List<uint32_t *> mSampleSizes;
- bool mSamplesHaveSameSize;
List<MediaBuffer *> mChunkSamples;
- size_t mNumStcoTableEntries;
- List<off64_t> mChunkOffsets;
-
- size_t mNumStscTableEntries;
- struct StscTableEntry {
-
- StscTableEntry(uint32_t chunk, uint32_t samples, uint32_t id)
- : firstChunk(chunk),
- samplesPerChunk(samples),
- sampleDescriptionId(id) {}
-
- uint32_t firstChunk;
- uint32_t samplesPerChunk;
- uint32_t sampleDescriptionId;
- };
- List<StscTableEntry> mStscTableEntries;
-
- size_t mNumStssTableEntries;
- List<int32_t> mStssTableEntries;
-
- struct SttsTableEntry {
-
- SttsTableEntry(uint32_t count, uint32_t duration)
- : sampleCount(count), sampleDuration(duration) {}
-
- uint32_t sampleCount;
- uint32_t sampleDuration; // time scale based
- };
- size_t mNumSttsTableEntries;
- List<SttsTableEntry> mSttsTableEntries;
+ bool mSamplesHaveSameSize;
+ ListTableEntries<uint32_t> *mStszTableEntries;
- struct CttsTableEntry {
- CttsTableEntry(uint32_t count, int32_t timescaledDur)
- : sampleCount(count), sampleDuration(timescaledDur) {}
+ ListTableEntries<uint32_t> *mStcoTableEntries;
+ ListTableEntries<off64_t> *mCo64TableEntries;
+ ListTableEntries<uint32_t> *mStscTableEntries;
+ ListTableEntries<uint32_t> *mStssTableEntries;
+ ListTableEntries<uint32_t> *mSttsTableEntries;
+ ListTableEntries<uint32_t> *mCttsTableEntries;
- uint32_t sampleCount;
- uint32_t sampleDuration; // time scale based
- };
- size_t mNumCttsTableEntries;
- List<CttsTableEntry> mCttsTableEntries;
int64_t mMinCttsOffsetTimeUs;
int64_t mMaxCttsOffsetTimeUs;
@@ -269,7 +350,7 @@ MPEG4Writer::MPEG4Writer(const char *filename)
mAreGeoTagsAvailable(false),
mStartTimeOffsetMs(-1) {
- mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR);
+ mFd = open(filename, O_CREAT | O_LARGEFILE | O_TRUNC | O_RDWR, S_IRUSR | S_IWUSR);
if (mFd >= 0) {
mInitCheck = OK;
}
@@ -333,6 +414,10 @@ status_t MPEG4Writer::Track::dump(
snprintf(buffer, SIZE, " reached EOS: %s\n",
mReachedEOS? "true": "false");
result.append(buffer);
+ snprintf(buffer, SIZE, " frames encoded : %d\n", mStszTableEntries->count());
+ result.append(buffer);
+ snprintf(buffer, SIZE, " duration encoded : %lld us\n", mTrackDurationUs);
+ result.append(buffer);
::write(fd, result.string(), result.size());
return OK;
}
@@ -343,7 +428,7 @@ status_t MPEG4Writer::addSource(const sp<MediaSource> &source) {
ALOGE("Attempt to add source AFTER recording is started");
return UNKNOWN_ERROR;
}
- Track *track = new Track(this, source, mTracks.size());
+ Track *track = new Track(this, source, 1 + mTracks.size());
mTracks.push_back(track);
return OK;
@@ -487,8 +572,16 @@ status_t MPEG4Writer::start(MetaData *param) {
CHECK_GT(mTimeScale, 0);
ALOGV("movie time scale: %d", mTimeScale);
- mStreamableFile = true;
- mWriteMoovBoxToMemory = false;
+ /*
+ * When the requested file size limit is small, the priority
+ * is to meet the file size limit requirement, rather than
+ * to make the file streamable.
+ */
+ mStreamableFile =
+ (mMaxFileSizeLimitBytes != 0 &&
+ mMaxFileSizeLimitBytes >= kMinStreamableFileSizeInBytes);
+
+ mWriteMoovBoxToMemory = mStreamableFile;
mMoovBoxBuffer = NULL;
mMoovBoxBufferOffset = 0;
@@ -504,11 +597,16 @@ status_t MPEG4Writer::start(MetaData *param) {
mEstimatedMoovBoxSize = estimateMoovBoxSize(bitRate);
}
CHECK_GE(mEstimatedMoovBoxSize, 8);
- lseek64(mFd, mFreeBoxOffset, SEEK_SET);
- writeInt32(mEstimatedMoovBoxSize);
- write("free", 4);
+ if (mStreamableFile) {
+ // Reserve a 'free' box only for streamable file
+ lseek64(mFd, mFreeBoxOffset, SEEK_SET);
+ writeInt32(mEstimatedMoovBoxSize);
+ write("free", 4);
+ mMdatOffset = mFreeBoxOffset + mEstimatedMoovBoxSize;
+ } else {
+ mMdatOffset = mOffset;
+ }
- mMdatOffset = mFreeBoxOffset + mEstimatedMoovBoxSize;
mOffset = mMdatOffset;
lseek64(mFd, mMdatOffset, SEEK_SET);
if (mUse32BitOffset) {
@@ -689,7 +787,7 @@ status_t MPEG4Writer::reset() {
lseek64(mFd, mOffset, SEEK_SET);
const off64_t moovOffset = mOffset;
- mWriteMoovBoxToMemory = true;
+ mWriteMoovBoxToMemory = mStreamableFile;
mMoovBoxBuffer = (uint8_t *) malloc(mEstimatedMoovBoxSize);
mMoovBoxBufferOffset = 0;
CHECK(mMoovBoxBuffer != NULL);
@@ -1071,6 +1169,10 @@ bool MPEG4Writer::exceedsFileSizeLimit() {
nTotalBytesEstimate += (*it)->getEstimatedTrackSizeBytes();
}
+ if (!mStreamableFile) {
+ // Add 1024 bytes as error tolerance
+ return nTotalBytesEstimate + 1024 >= mMaxFileSizeLimitBytes;
+ }
// Be conservative in the estimate: do not exceed 95% of
// the target file limit. For small target file size limit, though,
// this will not help.
@@ -1140,6 +1242,13 @@ MPEG4Writer::Track::Track(
mTrackDurationUs(0),
mEstimatedTrackSizeBytes(0),
mSamplesHaveSameSize(true),
+ mStszTableEntries(new ListTableEntries<uint32_t>(1000, 1)),
+ mStcoTableEntries(new ListTableEntries<uint32_t>(1000, 1)),
+ mCo64TableEntries(new ListTableEntries<off64_t>(1000, 1)),
+ mStscTableEntries(new ListTableEntries<uint32_t>(1000, 3)),
+ mStssTableEntries(new ListTableEntries<uint32_t>(1000, 1)),
+ mSttsTableEntries(new ListTableEntries<uint32_t>(1000, 2)),
+ mCttsTableEntries(new ListTableEntries<uint32_t>(1000, 2)),
mCodecSpecificData(NULL),
mCodecSpecificDataSize(0),
mGotAllCodecSpecificData(false),
@@ -1159,20 +1268,20 @@ MPEG4Writer::Track::Track(
void MPEG4Writer::Track::updateTrackSizeEstimate() {
- int64_t stcoBoxSizeBytes = mOwner->use32BitFileOffset()
- ? mNumStcoTableEntries * 4
- : mNumStcoTableEntries * 8;
-
- int64_t stszBoxSizeBytes = mSamplesHaveSameSize? 4: (mNumSamples * 4);
+ uint32_t stcoBoxCount = (mOwner->use32BitFileOffset()
+ ? mStcoTableEntries->count()
+ : mCo64TableEntries->count());
+ int64_t stcoBoxSizeBytes = stcoBoxCount * 4;
+ int64_t stszBoxSizeBytes = mSamplesHaveSameSize? 4: (mStszTableEntries->count() * 4);
mEstimatedTrackSizeBytes = mMdatSizeBytes; // media data size
if (!mOwner->isFileStreamable()) {
// Reserved free space is not large enough to hold
// all meta data and thus wasted.
- mEstimatedTrackSizeBytes += mNumStscTableEntries * 12 + // stsc box size
- mNumStssTableEntries * 4 + // stss box size
- mNumSttsTableEntries * 8 + // stts box size
- mNumCttsTableEntries * 8 + // ctts box size
+ mEstimatedTrackSizeBytes += mStscTableEntries->count() * 12 + // stsc box size
+ mStssTableEntries->count() * 4 + // stss box size
+ mSttsTableEntries->count() * 8 + // stts box size
+ mCttsTableEntries->count() * 8 + // ctts box size
stcoBoxSizeBytes + // stco box size
stszBoxSizeBytes; // stsz box size
}
@@ -1181,14 +1290,13 @@ void MPEG4Writer::Track::updateTrackSizeEstimate() {
void MPEG4Writer::Track::addOneStscTableEntry(
size_t chunkId, size_t sampleId) {
- StscTableEntry stscEntry(chunkId, sampleId, 1);
- mStscTableEntries.push_back(stscEntry);
- ++mNumStscTableEntries;
+ mStscTableEntries->add(htonl(chunkId));
+ mStscTableEntries->add(htonl(sampleId));
+ mStscTableEntries->add(htonl(1));
}
void MPEG4Writer::Track::addOneStssTableEntry(size_t sampleId) {
- mStssTableEntries.push_back(sampleId);
- ++mNumStssTableEntries;
+ mStssTableEntries->add(htonl(sampleId));
}
void MPEG4Writer::Track::addOneSttsTableEntry(
@@ -1197,9 +1305,8 @@ void MPEG4Writer::Track::addOneSttsTableEntry(
if (duration == 0) {
ALOGW("0-duration samples found: %d", sampleCount);
}
- SttsTableEntry sttsEntry(sampleCount, duration);
- mSttsTableEntries.push_back(sttsEntry);
- ++mNumSttsTableEntries;
+ mSttsTableEntries->add(htonl(sampleCount));
+ mSttsTableEntries->add(htonl(duration));
}
void MPEG4Writer::Track::addOneCttsTableEntry(
@@ -1208,14 +1315,17 @@ void MPEG4Writer::Track::addOneCttsTableEntry(
if (mIsAudio) {
return;
}
- CttsTableEntry cttsEntry(sampleCount, duration);
- mCttsTableEntries.push_back(cttsEntry);
- ++mNumCttsTableEntries;
+ mCttsTableEntries->add(htonl(sampleCount));
+ mCttsTableEntries->add(htonl(duration));
}
void MPEG4Writer::Track::addChunkOffset(off64_t offset) {
- ++mNumStcoTableEntries;
- mChunkOffsets.push_back(offset);
+ if (mOwner->use32BitFileOffset()) {
+ uint32_t value = offset;
+ mStcoTableEntries->add(htonl(value));
+ } else {
+ mCo64TableEntries->add(hton64(offset));
+ }
}
void MPEG4Writer::Track::setTimeScale() {
@@ -1274,16 +1384,26 @@ void MPEG4Writer::Track::getCodecSpecificDataFromInputFormatIfPossible() {
MPEG4Writer::Track::~Track() {
stop();
+ delete mStszTableEntries;
+ delete mStcoTableEntries;
+ delete mCo64TableEntries;
+ delete mStscTableEntries;
+ delete mSttsTableEntries;
+ delete mStssTableEntries;
+ delete mCttsTableEntries;
+
+ mStszTableEntries = NULL;
+ mStcoTableEntries = NULL;
+ mCo64TableEntries = NULL;
+ mStscTableEntries = NULL;
+ mSttsTableEntries = NULL;
+ mStssTableEntries = NULL;
+ mCttsTableEntries = NULL;
+
if (mCodecSpecificData != NULL) {
free(mCodecSpecificData);
mCodecSpecificData = NULL;
}
-
- while (!mSampleSizes.empty()) {
- List<uint32_t *>::iterator it = mSampleSizes.begin();
- delete[] (*it);
- mSampleSizes.erase(it);
- }
}
void MPEG4Writer::Track::initTrackingProgressStatus(MetaData *params) {
@@ -1526,13 +1646,7 @@ status_t MPEG4Writer::Track::start(MetaData *params) {
mTrackDurationUs = 0;
mReachedEOS = false;
mEstimatedTrackSizeBytes = 0;
- mNumStcoTableEntries = 0;
- mNumStssTableEntries = 0;
- mNumStscTableEntries = 0;
- mNumSttsTableEntries = 0;
- mNumCttsTableEntries = 0;
mMdatSizeBytes = 0;
-
mMaxChunkDurationUs = 0;
pthread_create(&mThread, &attr, ThreadWrapper, this);
@@ -1868,6 +1982,7 @@ status_t MPEG4Writer::Track::threadEntry() {
int64_t currCttsOffsetTimeTicks = 0; // Timescale based ticks
int64_t lastCttsOffsetTimeTicks = -1; // Timescale based ticks
int32_t cttsSampleCount = 0; // Sample count in the current ctts table entry
+ uint32_t lastSamplesPerChunk = 0;
if (mIsAudio) {
prctl(PR_SET_NAME, (unsigned long)"AudioTrackEncoding", 0, 0, 0);
@@ -1878,7 +1993,6 @@ status_t MPEG4Writer::Track::threadEntry() {
sp<MetaData> meta_data;
- mNumSamples = 0;
status_t err = OK;
MediaBuffer *buffer;
while (!mDone && (err = mSource->read(&buffer)) == OK) {
@@ -1967,7 +2081,7 @@ status_t MPEG4Writer::Track::threadEntry() {
CHECK(meta_data->findInt64(kKeyTime, &timestampUs));
////////////////////////////////////////////////////////////////////////////////
- if (mNumSamples == 0) {
+ if (mStszTableEntries->count() == 0) {
mFirstSampleTimeRealUs = systemTime() / 1000;
mStartTimestampUs = timestampUs;
mOwner->setStartTimestampUs(mStartTimestampUs);
@@ -2005,7 +2119,7 @@ status_t MPEG4Writer::Track::threadEntry() {
currCttsOffsetTimeTicks =
(cttsOffsetTimeUs * mTimeScale + 500000LL) / 1000000LL;
CHECK_LE(currCttsOffsetTimeTicks, 0x0FFFFFFFFLL);
- if (mNumSamples == 0) {
+ if (mStszTableEntries->count() == 0) {
// Force the first ctts table entry to have one single entry
// so that we can do adjustment for the initial track start
// time offset easily in writeCttsBox().
@@ -2023,7 +2137,7 @@ status_t MPEG4Writer::Track::threadEntry() {
}
// Update ctts time offset range
- if (mNumSamples == 0) {
+ if (mStszTableEntries->count() == 0) {
mMinCttsOffsetTimeUs = currCttsOffsetTimeTicks;
mMaxCttsOffsetTimeUs = currCttsOffsetTimeTicks;
} else {
@@ -2057,22 +2171,18 @@ status_t MPEG4Writer::Track::threadEntry() {
currDurationTicks =
((timestampUs * mTimeScale + 500000LL) / 1000000LL -
(lastTimestampUs * mTimeScale + 500000LL) / 1000000LL);
- CHECK_GE(currDurationTicks, 0ll);
-
- if ((mNumSamples % kSampleArraySize) == 0) {
- uint32_t *arr = new uint32_t[kSampleArraySize];
- CHECK(arr != NULL);
- mSampleSizes.push_back(arr);
- mCurrentSampleSizeArr = arr;
+ if (currDurationTicks < 0ll) {
+ ALOGE("timestampUs %lld < lastTimestampUs %lld for %s track",
+ timestampUs, lastTimestampUs, mIsAudio? "Audio": "Video");
+ return UNKNOWN_ERROR;
}
- mCurrentSampleSizeArr[mNumSamples % kSampleArraySize] = htonl(sampleSize);
- ++mNumSamples;
- if (mNumSamples > 2) {
+ mStszTableEntries->add(htonl(sampleSize));
+ if (mStszTableEntries->count() > 2) {
// Force the first sample to have its own stts entry so that
// we can adjust its value later to maintain the A/V sync.
- if (mNumSamples == 3 || currDurationTicks != lastDurationTicks) {
+ if (mStszTableEntries->count() == 3 || currDurationTicks != lastDurationTicks) {
addOneSttsTableEntry(sampleCount, lastDurationTicks);
sampleCount = 1;
} else {
@@ -2081,7 +2191,7 @@ status_t MPEG4Writer::Track::threadEntry() {
}
if (mSamplesHaveSameSize) {
- if (mNumSamples >= 2 && previousSampleSize != sampleSize) {
+ if (mStszTableEntries->count() >= 2 && previousSampleSize != sampleSize) {
mSamplesHaveSameSize = false;
}
previousSampleSize = sampleSize;
@@ -2093,7 +2203,7 @@ status_t MPEG4Writer::Track::threadEntry() {
lastTimestampUs = timestampUs;
if (isSync != 0) {
- addOneStssTableEntry(mNumSamples);
+ addOneStssTableEntry(mStszTableEntries->count());
}
if (mTrackingProgressStatus) {
@@ -2105,7 +2215,12 @@ status_t MPEG4Writer::Track::threadEntry() {
if (!hasMultipleTracks) {
off64_t offset = mIsAvc? mOwner->addLengthPrefixedSample_l(copy)
: mOwner->addSample_l(copy);
- if (mChunkOffsets.empty()) {
+
+ uint32_t count = (mOwner->use32BitFileOffset()
+ ? mStcoTableEntries->count()
+ : mCo64TableEntries->count());
+
+ if (count == 0) {
addChunkOffset(offset);
}
copy->release();
@@ -2128,9 +2243,9 @@ status_t MPEG4Writer::Track::threadEntry() {
}
++nChunks;
if (nChunks == 1 || // First chunk
- (--(mStscTableEntries.end()))->samplesPerChunk !=
- mChunkSamples.size()) {
- addOneStscTableEntry(nChunks, mChunkSamples.size());
+ lastSamplesPerChunk != mChunkSamples.size()) {
+ lastSamplesPerChunk = mChunkSamples.size();
+ addOneStscTableEntry(nChunks, lastSamplesPerChunk);
}
bufferChunk(timestampUs);
chunkTimestampUs = timestampUs;
@@ -2148,7 +2263,7 @@ status_t MPEG4Writer::Track::threadEntry() {
// Last chunk
if (!hasMultipleTracks) {
- addOneStscTableEntry(1, mNumSamples);
+ addOneStscTableEntry(1, mStszTableEntries->count());
} else if (!mChunkSamples.empty()) {
addOneStscTableEntry(++nChunks, mChunkSamples.size());
bufferChunk(timestampUs);
@@ -2157,14 +2272,14 @@ status_t MPEG4Writer::Track::threadEntry() {
// We don't really know how long the last frame lasts, since
// there is no frame time after it, just repeat the previous
// frame's duration.
- if (mNumSamples == 1) {
+ if (mStszTableEntries->count() == 1) {
lastDurationUs = 0; // A single sample's duration
lastDurationTicks = 0;
} else {
++sampleCount; // Count for the last sample
}
- if (mNumSamples <= 2) {
+ if (mStszTableEntries->count() <= 2) {
addOneSttsTableEntry(1, lastDurationTicks);
if (sampleCount - 1 > 0) {
addOneSttsTableEntry(sampleCount - 1, lastDurationTicks);
@@ -2187,7 +2302,7 @@ status_t MPEG4Writer::Track::threadEntry() {
sendTrackSummary(hasMultipleTracks);
ALOGI("Received total/0-length (%d/%d) buffers and encoded %d frames. - %s",
- count, nZeroLengthFrames, mNumSamples, mIsAudio? "audio": "video");
+ count, nZeroLengthFrames, mStszTableEntries->count(), mIsAudio? "audio": "video");
if (mIsAudio) {
ALOGI("Audio track drift time: %lld us", mOwner->getDriftTimeUs());
}
@@ -2199,12 +2314,12 @@ status_t MPEG4Writer::Track::threadEntry() {
}
bool MPEG4Writer::Track::isTrackMalFormed() const {
- if (mSampleSizes.empty()) { // no samples written
+ if (mStszTableEntries->count() == 0) { // no samples written
ALOGE("The number of recorded samples is 0");
return true;
}
- if (!mIsAudio && mNumStssTableEntries == 0) { // no sync frames for video
+ if (!mIsAudio && mStssTableEntries->count() == 0) { // no sync frames for video
ALOGE("There are no sync frames for video track");
return true;
}
@@ -2235,7 +2350,7 @@ void MPEG4Writer::Track::sendTrackSummary(bool hasMultipleTracks) {
mOwner->notify(MEDIA_RECORDER_TRACK_EVENT_INFO,
trackNum | MEDIA_RECORDER_TRACK_INFO_ENCODED_FRAMES,
- mNumSamples);
+ mStszTableEntries->count());
{
// The system delay time excluding the requested initial delay that
@@ -2273,6 +2388,7 @@ void MPEG4Writer::Track::sendTrackSummary(bool hasMultipleTracks) {
void MPEG4Writer::Track::trackProgressStatus(int64_t timeUs, status_t err) {
ALOGV("trackProgressStatus: %lld us", timeUs);
+
if (mTrackEveryTimeDurationUs > 0 &&
timeUs - mPreviousTrackTimeUs >= mTrackEveryTimeDurationUs) {
ALOGV("Fire time tracking progress status at %lld us", timeUs);
@@ -2586,7 +2702,7 @@ void MPEG4Writer::Track::writeTkhdBox(uint32_t now) {
mOwner->writeInt32(0x07); // version=0, flags=7
mOwner->writeInt32(now); // creation time
mOwner->writeInt32(now); // modification time
- mOwner->writeInt32(mTrackId + 1); // track id starts with 1
+ mOwner->writeInt32(mTrackId); // track id starts with 1
mOwner->writeInt32(0); // reserved
int64_t trakDurationUs = getDurationUs();
int32_t mvhdTimeScale = mOwner->getTimeScale();
@@ -2743,21 +2859,11 @@ int32_t MPEG4Writer::Track::getStartTimeOffsetScaledTime() const {
void MPEG4Writer::Track::writeSttsBox() {
mOwner->beginBox("stts");
mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(mNumSttsTableEntries);
-
- // Compensate for small start time difference from different media tracks
- List<SttsTableEntry>::iterator it = mSttsTableEntries.begin();
- CHECK(it != mSttsTableEntries.end() && it->sampleCount == 1);
- mOwner->writeInt32(it->sampleCount);
- mOwner->writeInt32(getStartTimeOffsetScaledTime() + it->sampleDuration);
-
- int64_t totalCount = 1;
- while (++it != mSttsTableEntries.end()) {
- mOwner->writeInt32(it->sampleCount);
- mOwner->writeInt32(it->sampleDuration);
- totalCount += it->sampleCount;
- }
- CHECK_EQ(totalCount, mNumSamples);
+ uint32_t duration;
+ CHECK(mSttsTableEntries->get(duration, 1));
+ duration = htonl(duration); // Back to host byte order
+ mSttsTableEntries->set(htonl(duration + getStartTimeOffsetScaledTime()), 1);
+ mSttsTableEntries->write(mOwner);
mOwner->endBox(); // stts
}
@@ -2772,101 +2878,52 @@ void MPEG4Writer::Track::writeCttsBox() {
}
// Do not write ctts box when there is no need to have it.
- if ((mNumCttsTableEntries == 1 &&
- mCttsTableEntries.begin()->sampleDuration == 0) ||
- mNumCttsTableEntries == 0) {
+ if (mCttsTableEntries->count() == 0) {
return;
}
- ALOGD("ctts box has %d entries with range [%lld, %lld]",
- mNumCttsTableEntries, mMinCttsOffsetTimeUs, mMaxCttsOffsetTimeUs);
+ ALOGV("ctts box has %d entries with range [%lld, %lld]",
+ mCttsTableEntries->count(), mMinCttsOffsetTimeUs, mMaxCttsOffsetTimeUs);
mOwner->beginBox("ctts");
- // Version 1 allows to use negative offset time value, but
- // we are sticking to version 0 for now.
mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(mNumCttsTableEntries);
-
- // Compensate for small start time difference from different media tracks
- List<CttsTableEntry>::iterator it = mCttsTableEntries.begin();
- CHECK(it != mCttsTableEntries.end() && it->sampleCount == 1);
- mOwner->writeInt32(it->sampleCount);
- mOwner->writeInt32(getStartTimeOffsetScaledTime() +
- it->sampleDuration - mMinCttsOffsetTimeUs);
-
- int64_t totalCount = 1;
- while (++it != mCttsTableEntries.end()) {
- mOwner->writeInt32(it->sampleCount);
- mOwner->writeInt32(it->sampleDuration - mMinCttsOffsetTimeUs);
- totalCount += it->sampleCount;
- }
- CHECK_EQ(totalCount, mNumSamples);
+ uint32_t duration;
+ CHECK(mCttsTableEntries->get(duration, 1));
+ duration = htonl(duration); // Back host byte order
+ mCttsTableEntries->set(htonl(duration + getStartTimeOffsetScaledTime() - mMinCttsOffsetTimeUs), 1);
+ mCttsTableEntries->write(mOwner);
mOwner->endBox(); // ctts
}
void MPEG4Writer::Track::writeStssBox() {
mOwner->beginBox("stss");
mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(mNumStssTableEntries); // number of sync frames
- for (List<int32_t>::iterator it = mStssTableEntries.begin();
- it != mStssTableEntries.end(); ++it) {
- mOwner->writeInt32(*it);
- }
+ mStssTableEntries->write(mOwner);
mOwner->endBox(); // stss
}
void MPEG4Writer::Track::writeStszBox() {
- ALOGD("writeStszBox for %s track", isAudio()? "Audio": "Video");
mOwner->beginBox("stsz");
mOwner->writeInt32(0); // version=0, flags=0
- if (mSamplesHaveSameSize) {
- CHECK(mCurrentSampleSizeArr != 0);
- mOwner->write(mCurrentSampleSizeArr, 4, 1); // default sample size
- } else {
- mOwner->writeInt32(0);
- }
- mOwner->writeInt32(mNumSamples);
- uint32_t nSamples = mNumSamples;
- if (!mSamplesHaveSameSize) {
- for (List<uint32_t *>::iterator it = mSampleSizes.begin();
- it != mSampleSizes.end(); ++it) {
- if (nSamples >= kSampleArraySize) {
- mOwner->write(*it, 4, kSampleArraySize);
- nSamples -= kSampleArraySize;
- } else {
- mOwner->write(*it, 4, nSamples);
- break;
- }
- }
- }
+ mOwner->writeInt32(0);
+ mStszTableEntries->write(mOwner);
mOwner->endBox(); // stsz
- ALOGD("writeStszBox: X");
}
void MPEG4Writer::Track::writeStscBox() {
mOwner->beginBox("stsc");
mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(mNumStscTableEntries);
- for (List<StscTableEntry>::iterator it = mStscTableEntries.begin();
- it != mStscTableEntries.end(); ++it) {
- mOwner->writeInt32(it->firstChunk);
- mOwner->writeInt32(it->samplesPerChunk);
- mOwner->writeInt32(it->sampleDescriptionId);
- }
+ mStscTableEntries->write(mOwner);
mOwner->endBox(); // stsc
}
void MPEG4Writer::Track::writeStcoBox(bool use32BitOffset) {
mOwner->beginBox(use32BitOffset? "stco": "co64");
mOwner->writeInt32(0); // version=0, flags=0
- mOwner->writeInt32(mNumStcoTableEntries);
- for (List<off64_t>::iterator it = mChunkOffsets.begin();
- it != mChunkOffsets.end(); ++it) {
- if (use32BitOffset) {
- mOwner->writeInt32(static_cast<int32_t>(*it));
- } else {
- mOwner->writeInt64((*it));
- }
+ if (use32BitOffset) {
+ mStcoTableEntries->write(mOwner);
+ } else {
+ mCo64TableEntries->write(mOwner);
}
mOwner->endBox(); // stco or co64
}
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 2060699..cb8a651 100644
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -302,6 +302,20 @@ status_t MediaCodec::getOutputFormat(sp<AMessage> *format) const {
return OK;
}
+status_t MediaCodec::getName(AString *name) const {
+ sp<AMessage> msg = new AMessage(kWhatGetName, id());
+
+ sp<AMessage> response;
+ status_t err;
+ if ((err = PostAndAwaitResponse(msg, &response)) != OK) {
+ return err;
+ }
+
+ CHECK(response->findString("name", name));
+
+ return OK;
+}
+
status_t MediaCodec::getInputBuffers(Vector<sp<ABuffer> > *buffers) const {
sp<AMessage> msg = new AMessage(kWhatGetBuffers, id());
msg->setInt32("portIndex", kPortIndexInput);
@@ -327,6 +341,18 @@ status_t MediaCodec::flush() {
return PostAndAwaitResponse(msg, &response);
}
+status_t MediaCodec::requestIDRFrame() {
+ (new AMessage(kWhatRequestIDRFrame, id()))->post();
+
+ return OK;
+}
+
+void MediaCodec::requestActivityNotification(const sp<AMessage> &notify) {
+ sp<AMessage> msg = new AMessage(kWhatRequestActivityNotification, id());
+ msg->setMessage("notify", notify);
+ msg->post();
+}
+
////////////////////////////////////////////////////////////////////////////////
void MediaCodec::cancelPendingDequeueOperations() {
@@ -492,6 +518,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
sendErrorReponse = false;
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
cancelPendingDequeueOperations();
break;
@@ -502,6 +529,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
sendErrorReponse = false;
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
break;
}
}
@@ -520,16 +548,15 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
CHECK_EQ(mState, INITIALIZING);
setState(INITIALIZED);
- AString componentName;
- CHECK(msg->findString("componentName", &componentName));
+ CHECK(msg->findString("componentName", &mComponentName));
- if (componentName.startsWith("OMX.google.")) {
+ if (mComponentName.startsWith("OMX.google.")) {
mFlags |= kFlagIsSoftwareCodec;
} else {
mFlags &= ~kFlagIsSoftwareCodec;
}
- if (componentName.endsWith(".secure")) {
+ if (mComponentName.endsWith(".secure")) {
mFlags |= kFlagIsSecure;
} else {
mFlags &= ~kFlagIsSecure;
@@ -594,6 +621,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
(new AMessage)->postReply(mReplyID);
} else {
mFlags |= kFlagOutputBuffersChanged;
+ postActivityNotificationIfPossible();
}
}
break;
@@ -632,6 +660,7 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
mOutputFormat = msg;
mFlags |= kFlagOutputFormatChanged;
+ postActivityNotificationIfPossible();
break;
}
@@ -663,6 +692,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
err);
mFlags |= kFlagStickyError;
+ postActivityNotificationIfPossible();
+
cancelPendingDequeueOperations();
}
break;
@@ -674,6 +705,8 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
++mDequeueInputTimeoutGeneration;
mFlags &= ~kFlagDequeueInputPending;
mDequeueInputReplyID = 0;
+ } else {
+ postActivityNotificationIfPossible();
}
break;
}
@@ -703,7 +736,10 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
++mDequeueOutputTimeoutGeneration;
mFlags &= ~kFlagDequeueOutputPending;
mDequeueOutputReplyID = 0;
+ } else {
+ postActivityNotificationIfPossible();
}
+
break;
}
@@ -1133,6 +1169,40 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatRequestIDRFrame:
+ {
+ mCodec->signalRequestIDRFrame();
+ break;
+ }
+
+ case kWhatRequestActivityNotification:
+ {
+ CHECK(mActivityNotify == NULL);
+ CHECK(msg->findMessage("notify", &mActivityNotify));
+
+ postActivityNotificationIfPossible();
+ break;
+ }
+
+ case kWhatGetName:
+ {
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ if (mComponentName.empty()) {
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", INVALID_OPERATION);
+
+ response->postReply(replyID);
+ break;
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setString("name", mComponentName.c_str());
+ response->postReply(replyID);
+ break;
+ }
+
default:
TRESPASS();
}
@@ -1198,6 +1268,12 @@ void MediaCodec::setState(State newState) {
mFlags &= ~kFlagOutputFormatChanged;
mFlags &= ~kFlagOutputBuffersChanged;
mFlags &= ~kFlagStickyError;
+
+ mActivityNotify.clear();
+ }
+
+ if (newState == UNINITIALIZED) {
+ mComponentName.clear();
}
mState = newState;
@@ -1465,4 +1541,19 @@ status_t MediaCodec::setNativeWindow(
return OK;
}
+void MediaCodec::postActivityNotificationIfPossible() {
+ if (mActivityNotify == NULL) {
+ return;
+ }
+
+ if ((mFlags & (kFlagStickyError
+ | kFlagOutputBuffersChanged
+ | kFlagOutputFormatChanged))
+ || !mAvailPortBuffers[kPortIndexInput].empty()
+ || !mAvailPortBuffers[kPortIndexOutput].empty()) {
+ mActivityNotify->post();
+ mActivityNotify.clear();
+ }
+}
+
} // namespace android
diff --git a/media/libstagefright/MediaDefs.cpp b/media/libstagefright/MediaDefs.cpp
index 2740d6b..e7b5903 100644
--- a/media/libstagefright/MediaDefs.cpp
+++ b/media/libstagefright/MediaDefs.cpp
@@ -42,7 +42,7 @@ const char *MEDIA_MIMETYPE_AUDIO_FLAC = "audio/flac";
const char *MEDIA_MIMETYPE_AUDIO_AAC_ADTS = "audio/aac-adts";
const char *MEDIA_MIMETYPE_CONTAINER_MPEG4 = "video/mp4";
-const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/wav";
+const char *MEDIA_MIMETYPE_CONTAINER_WAV = "audio/x-wav";
const char *MEDIA_MIMETYPE_CONTAINER_OGG = "application/ogg";
const char *MEDIA_MIMETYPE_CONTAINER_MATROSKA = "video/x-matroska";
const char *MEDIA_MIMETYPE_CONTAINER_MPEG2TS = "video/mp2ts";
diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp
index 9ab6611..b18c916 100644
--- a/media/libstagefright/MediaExtractor.cpp
+++ b/media/libstagefright/MediaExtractor.cpp
@@ -21,6 +21,7 @@
#include "include/AMRExtractor.h"
#include "include/MP3Extractor.h"
#include "include/MPEG4Extractor.h"
+#include "include/FragmentedMP4Extractor.h"
#include "include/WAVExtractor.h"
#include "include/OggExtractor.h"
#include "include/MPEG2PSExtractor.h"
@@ -93,7 +94,12 @@ sp<MediaExtractor> MediaExtractor::Create(
MediaExtractor *ret = NULL;
if (!strcasecmp(mime, MEDIA_MIMETYPE_CONTAINER_MPEG4)
|| !strcasecmp(mime, "audio/mp4")) {
- ret = new MPEG4Extractor(source);
+ int fragmented = 0;
+ if (meta != NULL && meta->findInt32("fragmented", &fragmented) && fragmented) {
+ ret = new FragmentedMP4Extractor(source);
+ } else {
+ ret = new MPEG4Extractor(source);
+ }
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
ret = new MP3Extractor(source, meta);
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)
diff --git a/media/libstagefright/MetaData.cpp b/media/libstagefright/MetaData.cpp
index 755594a..a01ec97 100644
--- a/media/libstagefright/MetaData.cpp
+++ b/media/libstagefright/MetaData.cpp
@@ -22,6 +22,8 @@
#include <string.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AString.h>
+#include <media/stagefright/foundation/hexdump.h>
#include <media/stagefright/MetaData.h>
namespace android {
@@ -318,6 +320,12 @@ String8 MetaData::typed_data::asString() const {
default:
out = String8::format("(unknown type %d, size %d)", mType, mSize);
+ if (mSize <= 48) { // if it's less than three lines of hex data, dump it
+ AString foo;
+ hexdump(data, mSize, 0, &foo);
+ out.append("\n");
+ out.append(foo.c_str());
+ }
break;
}
return out;
diff --git a/media/libstagefright/NuCachedSource2.cpp b/media/libstagefright/NuCachedSource2.cpp
index f1075b1..05e599b 100644
--- a/media/libstagefright/NuCachedSource2.cpp
+++ b/media/libstagefright/NuCachedSource2.cpp
@@ -298,7 +298,9 @@ void NuCachedSource2::fetchInternal() {
Mutex::Autolock autoLock(mLock);
- if (err == ERROR_UNSUPPORTED) {
+ if (err == ERROR_UNSUPPORTED || err == -EPIPE) {
+ // These are errors that are not likely to go away even if we
+ // retry, i.e. the server doesn't support range requests or similar.
mNumRetriesLeft = 0;
return;
} else if (err != OK) {
@@ -317,8 +319,14 @@ void NuCachedSource2::fetchInternal() {
Mutex::Autolock autoLock(mLock);
if (n < 0) {
- ALOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
mFinalStatus = n;
+ if (n == ERROR_UNSUPPORTED || n == -EPIPE) {
+ // These are errors that are not likely to go away even if we
+ // retry, i.e. the server doesn't support range requests or similar.
+ mNumRetriesLeft = 0;
+ }
+
+ ALOGE("source returned error %ld, %d retries left", n, mNumRetriesLeft);
mCache->releasePage(page);
} else if (n == 0) {
ALOGI("ERROR_END_OF_STREAM");
diff --git a/media/libstagefright/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index 29e1d21..404fa94 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -110,6 +110,12 @@ status_t NuMediaExtractor::setDataSource(
// give us data in a call to MediaSource::read(), unlike its
// default mode that we use from AwesomePlayer.
static_cast<WVMExtractor *>(mImpl.get())->setCryptoPluginMode(true);
+ } else if (mImpl->getDrmFlag()) {
+ // For all other drm content, we don't want to expose decrypted
+ // content to Java application.
+ mImpl.clear();
+ mImpl = NULL;
+ return ERROR_UNSUPPORTED;
}
mDataSource = dataSource;
@@ -120,6 +126,7 @@ status_t NuMediaExtractor::setDataSource(
}
status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
+
Mutex::Autolock autoLock(mLock);
if (mImpl != NULL) {
@@ -146,6 +153,31 @@ status_t NuMediaExtractor::setDataSource(int fd, off64_t offset, off64_t size) {
return OK;
}
+status_t NuMediaExtractor::setDataSource(const sp<DataSource> &source) {
+ Mutex::Autolock autoLock(mLock);
+
+ if (mImpl != NULL) {
+ return -EINVAL;
+ }
+
+ status_t err = source->initCheck();
+ if (err != OK) {
+ return err;
+ }
+
+ mImpl = MediaExtractor::Create(source);
+
+ if (mImpl == NULL) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ mDataSource = source;
+
+ updateDurationAndBitrate();
+
+ return OK;
+}
+
void NuMediaExtractor::updateDurationAndBitrate() {
mTotalBitrate = 0ll;
mDurationUs = -1ll;
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index a6636a1..70de174 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -147,12 +147,13 @@ static bool IsSoftwareCodec(const char *componentName) {
// A sort order in which OMX software codecs are first, followed
// by other (non-OMX) software codecs, followed by everything else.
static int CompareSoftwareCodecsFirst(
- const String8 *elem1, const String8 *elem2) {
- bool isOMX1 = !strncmp(elem1->string(), "OMX.", 4);
- bool isOMX2 = !strncmp(elem2->string(), "OMX.", 4);
+ const OMXCodec::CodecNameAndQuirks *elem1,
+ const OMXCodec::CodecNameAndQuirks *elem2) {
+ bool isOMX1 = !strncmp(elem1->mName.string(), "OMX.", 4);
+ bool isOMX2 = !strncmp(elem2->mName.string(), "OMX.", 4);
- bool isSoftwareCodec1 = IsSoftwareCodec(elem1->string());
- bool isSoftwareCodec2 = IsSoftwareCodec(elem2->string());
+ bool isSoftwareCodec1 = IsSoftwareCodec(elem1->mName.string());
+ bool isSoftwareCodec2 = IsSoftwareCodec(elem2->mName.string());
if (isSoftwareCodec1) {
if (!isSoftwareCodec2) { return -1; }
@@ -182,14 +183,9 @@ void OMXCodec::findMatchingCodecs(
const char *mime,
bool createEncoder, const char *matchComponentName,
uint32_t flags,
- Vector<String8> *matchingCodecs,
- Vector<uint32_t> *matchingCodecQuirks) {
+ Vector<CodecNameAndQuirks> *matchingCodecs) {
matchingCodecs->clear();
- if (matchingCodecQuirks) {
- matchingCodecQuirks->clear();
- }
-
const MediaCodecList *list = MediaCodecList::getInstance();
if (list == NULL) {
return;
@@ -221,11 +217,13 @@ void OMXCodec::findMatchingCodecs(
((flags & kHardwareCodecsOnly) && !IsSoftwareCodec(componentName)) ||
(!(flags & (kSoftwareCodecsOnly | kHardwareCodecsOnly)))) {
- matchingCodecs->push(String8(componentName));
+ ssize_t index = matchingCodecs->add();
+ CodecNameAndQuirks *entry = &matchingCodecs->editItemAt(index);
+ entry->mName = String8(componentName);
+ entry->mQuirks = getComponentQuirks(list, matchIndex);
- if (matchingCodecQuirks) {
- matchingCodecQuirks->push(getComponentQuirks(list, matchIndex));
- }
+ ALOGV("matching '%s' quirks 0x%08x",
+ entry->mName.string(), entry->mQuirks);
}
}
@@ -294,13 +292,14 @@ sp<MediaSource> OMXCodec::Create(
bool success = meta->findCString(kKeyMIMEType, &mime);
CHECK(success);
- Vector<String8> matchingCodecs;
- Vector<uint32_t> matchingCodecQuirks;
+ Vector<CodecNameAndQuirks> matchingCodecs;
findMatchingCodecs(
- mime, createEncoder, matchComponentName, flags,
- &matchingCodecs, &matchingCodecQuirks);
+ mime, createEncoder, matchComponentName, flags, &matchingCodecs);
if (matchingCodecs.isEmpty()) {
+ ALOGV("No matching codecs! (mime: %s, createEncoder: %s, "
+ "matchComponentName: %s, flags: 0x%x)",
+ mime, createEncoder ? "true" : "false", matchComponentName, flags);
return NULL;
}
@@ -308,8 +307,8 @@ sp<MediaSource> OMXCodec::Create(
IOMX::node_id node = 0;
for (size_t i = 0; i < matchingCodecs.size(); ++i) {
- const char *componentNameBase = matchingCodecs[i].string();
- uint32_t quirks = matchingCodecQuirks[i];
+ const char *componentNameBase = matchingCodecs[i].mName.string();
+ uint32_t quirks = matchingCodecs[i].mQuirks;
const char *componentName = componentNameBase;
AString tmp;
@@ -547,12 +546,8 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
if (mIsEncoder) {
setVideoInputFormat(mMIME, meta);
} else {
- int32_t width, height;
- bool success = meta->findInt32(kKeyWidth, &width);
- success = success && meta->findInt32(kKeyHeight, &height);
- CHECK(success);
status_t err = setVideoOutputFormat(
- mMIME, width, height);
+ mMIME, meta);
if (err != OK) {
return err;
@@ -569,6 +564,8 @@ status_t OMXCodec::configureCodec(const sp<MetaData> &meta) {
if ((mFlags & kClientNeedsFramebuffer)
&& !strncmp(mComponentName, "OMX.SEC.", 8)) {
+ // This appears to no longer be needed???
+
OMX_INDEXTYPE index;
status_t err =
@@ -893,7 +890,7 @@ static OMX_U32 setPFramesSpacing(int32_t iFramesInterval, int32_t frameRate) {
} else if (iFramesInterval == 0) {
return 0;
}
- OMX_U32 ret = frameRate * iFramesInterval;
+ OMX_U32 ret = frameRate * iFramesInterval - 1;
CHECK(ret > 1);
return ret;
}
@@ -1171,7 +1168,13 @@ status_t OMXCodec::setupAVCEncoderParameters(const sp<MetaData>& meta) {
}
status_t OMXCodec::setVideoOutputFormat(
- const char *mime, OMX_U32 width, OMX_U32 height) {
+ const char *mime, const sp<MetaData>& meta) {
+
+ int32_t width, height;
+ bool success = meta->findInt32(kKeyWidth, &width);
+ success = success && meta->findInt32(kKeyHeight, &height);
+ CHECK(success);
+
CODEC_LOGV("setVideoOutputFormat width=%ld, height=%ld", width, height);
OMX_VIDEO_CODINGTYPE compressionFormat = OMX_VIDEO_CodingUnused;
@@ -1214,7 +1217,28 @@ status_t OMXCodec::setVideoOutputFormat(
|| format.eColorFormat == OMX_COLOR_FormatYUV420SemiPlanar
|| format.eColorFormat == OMX_COLOR_FormatCbYCrY
|| format.eColorFormat == OMX_TI_COLOR_FormatYUV420PackedSemiPlanar
- || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar);
+ || format.eColorFormat == OMX_QCOM_COLOR_FormatYVU420SemiPlanar
+ || format.eColorFormat == OMX_QCOM_COLOR_FormatYUV420PackedSemiPlanar64x32Tile2m8ka);
+
+ int32_t colorFormat;
+ if (meta->findInt32(kKeyColorFormat, &colorFormat)
+ && colorFormat != OMX_COLOR_FormatUnused
+ && colorFormat != format.eColorFormat) {
+
+ while (OMX_ErrorNoMore != err) {
+ format.nIndex++;
+ err = mOMX->getParameter(
+ mNode, OMX_IndexParamVideoPortFormat,
+ &format, sizeof(format));
+ if (format.eColorFormat == colorFormat) {
+ break;
+ }
+ }
+ if (format.eColorFormat != colorFormat) {
+ CODEC_LOGE("Color format %d is not supported", colorFormat);
+ return ERROR_UNSUPPORTED;
+ }
+ }
err = mOMX->setParameter(
mNode, OMX_IndexParamVideoPortFormat,
@@ -1665,6 +1689,8 @@ status_t OMXCodec::applyRotation() {
if (transform) {
err = native_window_set_buffers_transform(
mNativeWindow.get(), transform);
+ ALOGE("native_window_set_buffers_transform failed: %s (%d)",
+ strerror(-err), -err);
}
return err;
@@ -1679,6 +1705,7 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
status_t err = mOMX->getParameter(
mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
if (err != OK) {
+ CODEC_LOGE("getParameter failed: %d", err);
return err;
}
@@ -1776,7 +1803,7 @@ status_t OMXCodec::allocateOutputBuffersFromNativeWindow() {
// Dequeue buffers and send them to OMX
for (OMX_U32 i = 0; i < def.nBufferCountActual; i++) {
ANativeWindowBuffer* buf;
- err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
+ err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf);
if (err != 0) {
ALOGE("dequeueBuffer failed: %s (%d)", strerror(-err), -err);
break;
@@ -1832,7 +1859,7 @@ status_t OMXCodec::cancelBufferToNativeWindow(BufferInfo *info) {
CHECK_EQ((int)info->mStatus, (int)OWNED_BY_US);
CODEC_LOGV("Calling cancelBuffer on buffer %p", info->mBuffer);
int err = mNativeWindow->cancelBuffer(
- mNativeWindow.get(), info->mMediaBuffer->graphicBuffer().get());
+ mNativeWindow.get(), info->mMediaBuffer->graphicBuffer().get(), -1);
if (err != 0) {
CODEC_LOGE("cancelBuffer failed w/ error 0x%08x", err);
@@ -1846,7 +1873,8 @@ status_t OMXCodec::cancelBufferToNativeWindow(BufferInfo *info) {
OMXCodec::BufferInfo* OMXCodec::dequeueBufferFromNativeWindow() {
// Dequeue the next buffer from the native window.
ANativeWindowBuffer* buf;
- int err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf);
+ int fenceFd = -1;
+ int err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &buf);
if (err != 0) {
CODEC_LOGE("dequeueBuffer failed w/ error 0x%08x", err);
@@ -1950,7 +1978,8 @@ status_t OMXCodec::pushBlankBuffersToNativeWindow() {
// on the screen and then been replaced, so an previous video frames are
// guaranteed NOT to be currently displayed.
for (int i = 0; i < numBufs + 1; i++) {
- err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &anb);
+ int fenceFd = -1;
+ err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(), &anb);
if (err != NO_ERROR) {
ALOGE("error pushing blank frames: dequeueBuffer failed: %s (%d)",
strerror(-err), -err);
@@ -1958,13 +1987,6 @@ status_t OMXCodec::pushBlankBuffersToNativeWindow() {
}
sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- err = mNativeWindow->lockBuffer(mNativeWindow.get(),
- buf->getNativeBuffer());
- if (err != NO_ERROR) {
- ALOGE("error pushing blank frames: lockBuffer failed: %s (%d)",
- strerror(-err), -err);
- goto error;
- }
// Fill the buffer with the a 1x1 checkerboard pattern ;)
uint32_t* img = NULL;
@@ -1985,7 +2007,7 @@ status_t OMXCodec::pushBlankBuffersToNativeWindow() {
}
err = mNativeWindow->queueBuffer(mNativeWindow.get(),
- buf->getNativeBuffer());
+ buf->getNativeBuffer(), -1);
if (err != NO_ERROR) {
ALOGE("error pushing blank frames: queueBuffer failed: %s (%d)",
strerror(-err), -err);
@@ -2000,7 +2022,7 @@ error:
if (err != NO_ERROR) {
// Clean up after an error.
if (anb != NULL) {
- mNativeWindow->cancelBuffer(mNativeWindow.get(), anb);
+ mNativeWindow->cancelBuffer(mNativeWindow.get(), anb, -1);
}
native_window_api_disconnect(mNativeWindow.get(),
@@ -2048,11 +2070,13 @@ int64_t OMXCodec::getDecodingTimeUs() {
}
void OMXCodec::on_message(const omx_message &msg) {
- // even in error state, we still need to process EMPTY_BUFFER_DONE
- // and FILL_BUFFER_DONE event, or we will run into mediaserver crash issue
if (mState == ERROR) {
+ /*
+ * only drop EVENT messages, EBD and FBD are still
+ * processed for bookkeeping purposes
+ */
if (msg.type == omx_message::EVENT) {
- ALOGW("Dropping OMX message - we're in ERROR state.");
+ ALOGW("Dropping OMX EVENT message - we're in ERROR state.");
return;
}
}
@@ -2090,13 +2114,6 @@ void OMXCodec::on_message(const omx_message &msg) {
// Buffer could not be released until empty buffer done is called.
if (info->mMediaBuffer != NULL) {
- if (mIsEncoder &&
- (mQuirks & kAvoidMemcopyInputRecordingFrames)) {
- // If zero-copy mode is enabled this will send the
- // input buffer back to the upstream source.
- restorePatchedDataPointer(info);
- }
-
info->mMediaBuffer->release();
info->mMediaBuffer = NULL;
}
@@ -3069,39 +3086,24 @@ bool OMXCodec::drainInputBuffer(BufferInfo *info) {
}
bool releaseBuffer = true;
- if (mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames)) {
- CHECK(mOMXLivesLocally && offset == 0);
-
- OMX_BUFFERHEADERTYPE *header =
- (OMX_BUFFERHEADERTYPE *)info->mBuffer;
-
- CHECK(header->pBuffer == info->mData);
-
- header->pBuffer =
- (OMX_U8 *)srcBuffer->data() + srcBuffer->range_offset();
-
- releaseBuffer = false;
- info->mMediaBuffer = srcBuffer;
- } else {
- if (mFlags & kStoreMetaDataInVideoBuffers) {
+ if (mFlags & kStoreMetaDataInVideoBuffers) {
releaseBuffer = false;
info->mMediaBuffer = srcBuffer;
- }
+ }
- if (mFlags & kUseSecureInputBuffers) {
+ if (mFlags & kUseSecureInputBuffers) {
// Data in "info" is already provided at this time.
releaseBuffer = false;
CHECK(info->mMediaBuffer == NULL);
info->mMediaBuffer = srcBuffer;
- } else {
- CHECK(srcBuffer->data() != NULL) ;
- memcpy((uint8_t *)info->mData + offset,
- (const uint8_t *)srcBuffer->data()
- + srcBuffer->range_offset(),
- srcBuffer->range_length());
- }
+ } else {
+ CHECK(srcBuffer->data() != NULL) ;
+ memcpy((uint8_t *)info->mData + offset,
+ (const uint8_t *)srcBuffer->data()
+ + srcBuffer->range_offset(),
+ srcBuffer->range_length());
}
int64_t lastBufferTimeUs;
@@ -3203,23 +3205,6 @@ void OMXCodec::fillOutputBuffer(BufferInfo *info) {
return;
}
- if (info->mMediaBuffer != NULL) {
- sp<GraphicBuffer> graphicBuffer = info->mMediaBuffer->graphicBuffer();
- if (graphicBuffer != 0) {
- // When using a native buffer we need to lock the buffer before
- // giving it to OMX.
- CODEC_LOGV("Calling lockBuffer on %p", info->mBuffer);
- int err = mNativeWindow->lockBuffer(mNativeWindow.get(),
- graphicBuffer.get());
- if (err != 0) {
- CODEC_LOGE("lockBuffer failed w/ error 0x%08x", err);
-
- setState(ERROR);
- return;
- }
- }
- }
-
CODEC_LOGV("Calling fillBuffer on buffer %p", info->mBuffer);
status_t err = mOMX->fillBuffer(mNode, info->mBuffer);
@@ -3624,6 +3609,7 @@ status_t OMXCodec::start(MetaData *meta) {
Mutex::Autolock autoLock(mLock);
if (mState != LOADED) {
+ CODEC_LOGE("called start in the unexpected state: %d", mState);
return UNKNOWN_ERROR;
}
@@ -3639,11 +3625,6 @@ status_t OMXCodec::start(MetaData *meta) {
}
params->setInt64(kKeyTime, startTimeUs);
}
- status_t err = mSource->start(params.get());
-
- if (err != OK) {
- return err;
- }
mCodecSpecificDataIndex = 0;
mInitialBufferSubmit = true;
@@ -3656,13 +3637,45 @@ status_t OMXCodec::start(MetaData *meta) {
mFilledBuffers.clear();
mPaused = false;
+ status_t err;
+ if (mIsEncoder) {
+ // Calling init() before starting its source so that we can configure,
+ // if supported, the source to use exactly the same number of input
+ // buffers as requested by the encoder.
+ if ((err = init()) != OK) {
+ CODEC_LOGE("init failed: %d", err);
+ return err;
+ }
+
+ params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
+ err = mSource->start(params.get());
+ if (err != OK) {
+ CODEC_LOGE("source failed to start: %d", err);
+ stopOmxComponent_l();
+ }
+ return err;
+ }
+
+ // Decoder case
+ if ((err = mSource->start(params.get())) != OK) {
+ CODEC_LOGE("source failed to start: %d", err);
+ return err;
+ }
return init();
}
status_t OMXCodec::stop() {
CODEC_LOGV("stop mState=%d", mState);
-
Mutex::Autolock autoLock(mLock);
+ status_t err = stopOmxComponent_l();
+ mSource->stop();
+
+ CODEC_LOGV("stopped in state %d", mState);
+ return err;
+}
+
+status_t OMXCodec::stopOmxComponent_l() {
+ CODEC_LOGV("stopOmxComponent_l mState=%d", mState);
while (isIntermediateState(mState)) {
mAsyncCompletion.wait(mLock);
@@ -3760,10 +3773,6 @@ status_t OMXCodec::stop() {
mLeftOverBuffer = NULL;
}
- mSource->stop();
-
- CODEC_LOGV("stopped in state %d", mState);
-
return OK;
}
@@ -4515,7 +4524,7 @@ status_t QueryCodecs(
const sp<IOMX> &omx,
const char *mime, bool queryDecoders, bool hwCodecOnly,
Vector<CodecCapabilities> *results) {
- Vector<String8> matchingCodecs;
+ Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
results->clear();
OMXCodec::findMatchingCodecs(mime,
@@ -4525,7 +4534,7 @@ status_t QueryCodecs(
&matchingCodecs);
for (size_t c = 0; c < matchingCodecs.size(); c++) {
- const char *componentName = matchingCodecs.itemAt(c).string();
+ const char *componentName = matchingCodecs.itemAt(c).mName.string();
results->push();
CodecCapabilities *caps = &results->editItemAt(results->size() - 1);
@@ -4612,14 +4621,6 @@ status_t QueryCodecs(
return QueryCodecs(omx, mimeType, queryDecoders, false /*hwCodecOnly*/, results);
}
-void OMXCodec::restorePatchedDataPointer(BufferInfo *info) {
- CHECK(mIsEncoder && (mQuirks & kAvoidMemcopyInputRecordingFrames));
- CHECK(mOMXLivesLocally);
-
- OMX_BUFFERHEADERTYPE *header = (OMX_BUFFERHEADERTYPE *)info->mBuffer;
- header->pBuffer = (OMX_U8 *)info->mData;
-}
-
// These are supposed be equivalent to the logic in
// "audio_channel_out_mask_from_count".
status_t getOMXChannelMapping(size_t numChannels, OMX_AUDIO_CHANNELTYPE map[]) {
diff --git a/media/libstagefright/StagefrightMediaScanner.cpp b/media/libstagefright/StagefrightMediaScanner.cpp
index b7cf96e..bccffd8 100644
--- a/media/libstagefright/StagefrightMediaScanner.cpp
+++ b/media/libstagefright/StagefrightMediaScanner.cpp
@@ -42,7 +42,7 @@ static bool FileHasAcceptableExtension(const char *extension) {
".mpeg", ".ogg", ".mid", ".smf", ".imy", ".wma", ".aac",
".wav", ".amr", ".midi", ".xmf", ".rtttl", ".rtx", ".ota",
".mkv", ".mka", ".webm", ".ts", ".fl", ".flac", ".mxmf",
- ".avi", ".mpeg", ".mpg"
+ ".avi", ".mpeg", ".mpg", ".mpga"
};
static const size_t kNumValidExtensions =
sizeof(kValidExtensions) / sizeof(kValidExtensions[0]);
diff --git a/media/libstagefright/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index 7951496..19af4fb 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -110,6 +110,31 @@ status_t StagefrightMetadataRetriever::setDataSource(
return OK;
}
+static bool isYUV420PlanarSupported(
+ OMXClient *client,
+ const sp<MetaData> &trackMeta) {
+
+ const char *mime;
+ CHECK(trackMeta->findCString(kKeyMIMEType, &mime));
+
+ Vector<CodecCapabilities> caps;
+ if (QueryCodecs(client->interface(), mime,
+ true, /* queryDecoders */
+ true, /* hwCodecOnly */
+ &caps) == OK) {
+
+ for (size_t j = 0; j < caps.size(); ++j) {
+ CodecCapabilities cap = caps[j];
+ for (size_t i = 0; i < cap.mColorFormats.size(); ++i) {
+ if (cap.mColorFormats[i] == OMX_COLOR_FormatYUV420Planar) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+}
+
static VideoFrame *extractVideoFrameWithCodecFlags(
OMXClient *client,
const sp<MetaData> &trackMeta,
@@ -117,9 +142,19 @@ static VideoFrame *extractVideoFrameWithCodecFlags(
uint32_t flags,
int64_t frameTimeUs,
int seekMode) {
+
+ sp<MetaData> format = source->getFormat();
+
+ // XXX:
+ // Once all vendors support OMX_COLOR_FormatYUV420Planar, we can
+ // remove this check and always set the decoder output color format
+ if (isYUV420PlanarSupported(client, trackMeta)) {
+ format->setInt32(kKeyColorFormat, OMX_COLOR_FormatYUV420Planar);
+ }
+
sp<MediaSource> decoder =
OMXCodec::Create(
- client->interface(), source->getFormat(), false, source,
+ client->interface(), format, false, source,
NULL, flags | OMXCodec::kClientNeedsFramebuffer);
if (decoder.get() == NULL) {
@@ -398,7 +433,7 @@ const char *StagefrightMetadataRetriever::extractMetadata(int keyCode) {
return NULL;
}
- return strdup(mMetaData.valueAt(index).string());
+ return mMetaData.valueAt(index).string();
}
void StagefrightMetadataRetriever::parseMetaData() {
@@ -462,6 +497,7 @@ void StagefrightMetadataRetriever::parseMetaData() {
int32_t videoWidth = -1;
int32_t videoHeight = -1;
int32_t audioBitrate = -1;
+ int32_t rotationAngle = -1;
// The overall duration is the duration of the longest track.
int64_t maxDurationUs = 0;
@@ -489,6 +525,9 @@ void StagefrightMetadataRetriever::parseMetaData() {
CHECK(trackMeta->findInt32(kKeyWidth, &videoWidth));
CHECK(trackMeta->findInt32(kKeyHeight, &videoHeight));
+ if (!trackMeta->findInt32(kKeyRotation, &rotationAngle)) {
+ rotationAngle = 0;
+ }
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_TEXT_3GPP)) {
const char *lang;
trackMeta->findCString(kKeyMediaLanguage, &lang);
@@ -521,6 +560,9 @@ void StagefrightMetadataRetriever::parseMetaData() {
sprintf(tmp, "%d", videoHeight);
mMetaData.add(METADATA_KEY_VIDEO_HEIGHT, String8(tmp));
+
+ sprintf(tmp, "%d", rotationAngle);
+ mMetaData.add(METADATA_KEY_VIDEO_ROTATION, String8(tmp));
}
if (numTracks == 1 && hasAudio && audioBitrate >= 0) {
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 300d2fc..3c002fc 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -18,8 +18,8 @@
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/SurfaceMediaSource.h>
-#include <media/stagefright/MetaData.h>
#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MetaData.h>
#include <OMX_IVCommon.h>
#include <MetadataBufferType.h>
@@ -39,20 +39,22 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig
mWidth(bufferWidth),
mHeight(bufferHeight),
mCurrentSlot(BufferQueue::INVALID_BUFFER_SLOT),
+ mNumPendingBuffers(0),
mCurrentTimestamp(0),
mFrameRate(30),
- mStopped(false),
+ mStarted(false),
mNumFramesReceived(0),
mNumFramesEncoded(0),
- mFirstFrameTimestamp(0)
-{
- ALOGV("SurfaceMediaSource::SurfaceMediaSource");
+ mFirstFrameTimestamp(0),
+ mMaxAcquiredBufferCount(4), // XXX double-check the default
+ mUseAbsoluteTimestamps(false) {
+ ALOGV("SurfaceMediaSource");
if (bufferWidth == 0 || bufferHeight == 0) {
ALOGE("Invalid dimensions %dx%d", bufferWidth, bufferHeight);
}
- mBufferQueue = new BufferQueue(true, MIN_UNDEQUEUED_BUFFERS);
+ mBufferQueue = new BufferQueue(true);
mBufferQueue->setDefaultBufferSize(bufferWidth, bufferHeight);
mBufferQueue->setSynchronousMode(true);
mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_VIDEO_ENCODER |
@@ -77,21 +79,19 @@ SurfaceMediaSource::SurfaceMediaSource(uint32_t bufferWidth, uint32_t bufferHeig
}
SurfaceMediaSource::~SurfaceMediaSource() {
- ALOGV("SurfaceMediaSource::~SurfaceMediaSource");
- if (!mStopped) {
- reset();
- }
+ ALOGV("~SurfaceMediaSource");
+ CHECK(!mStarted);
}
nsecs_t SurfaceMediaSource::getTimestamp() {
- ALOGV("SurfaceMediaSource::getTimestamp");
+ ALOGV("getTimestamp");
Mutex::Autolock lock(mMutex);
return mCurrentTimestamp;
}
void SurfaceMediaSource::setFrameAvailableListener(
const sp<FrameAvailableListener>& listener) {
- ALOGV("SurfaceMediaSource::setFrameAvailableListener");
+ ALOGV("setFrameAvailableListener");
Mutex::Autolock lock(mMutex);
mFrameAvailableListener = listener;
}
@@ -113,6 +113,7 @@ void SurfaceMediaSource::dump(String8& result, const char* prefix,
status_t SurfaceMediaSource::setFrameRate(int32_t fps)
{
+ ALOGV("setFrameRate");
Mutex::Autolock lock(mMutex);
const int MAX_FRAME_RATE = 60;
if (fps < 0 || fps > MAX_FRAME_RATE) {
@@ -128,36 +129,100 @@ bool SurfaceMediaSource::isMetaDataStoredInVideoBuffers() const {
}
int32_t SurfaceMediaSource::getFrameRate( ) const {
+ ALOGV("getFrameRate");
Mutex::Autolock lock(mMutex);
return mFrameRate;
}
status_t SurfaceMediaSource::start(MetaData *params)
{
- ALOGV("started!");
+ ALOGV("start");
+
+ Mutex::Autolock lock(mMutex);
+
+ CHECK(!mStarted);
mStartTimeNs = 0;
int64_t startTimeUs;
- if (params && params->findInt64(kKeyTime, &startTimeUs)) {
- mStartTimeNs = startTimeUs * 1000;
+ int32_t bufferCount = 0;
+ if (params) {
+ if (params->findInt64(kKeyTime, &startTimeUs)) {
+ mStartTimeNs = startTimeUs * 1000;
+ }
+
+ if (!params->findInt32(kKeyNumBuffers, &bufferCount)) {
+ ALOGE("Failed to find the advertised buffer count");
+ return UNKNOWN_ERROR;
+ }
+
+ if (bufferCount <= 1) {
+ ALOGE("bufferCount %d is too small", bufferCount);
+ return BAD_VALUE;
+ }
+
+ mMaxAcquiredBufferCount = bufferCount;
+ }
+
+ CHECK_GT(mMaxAcquiredBufferCount, 1);
+
+ status_t err =
+ mBufferQueue->setMaxAcquiredBufferCount(mMaxAcquiredBufferCount);
+
+ if (err != OK) {
+ return err;
}
+ mNumPendingBuffers = 0;
+ mStarted = true;
+
return OK;
}
+status_t SurfaceMediaSource::setMaxAcquiredBufferCount(size_t count) {
+ ALOGV("setMaxAcquiredBufferCount(%d)", count);
+ Mutex::Autolock lock(mMutex);
-status_t SurfaceMediaSource::reset()
-{
- ALOGV("Reset");
+ CHECK_GT(count, 1);
+ mMaxAcquiredBufferCount = count;
+
+ return OK;
+}
+status_t SurfaceMediaSource::setUseAbsoluteTimestamps() {
+ ALOGV("setUseAbsoluteTimestamps");
Mutex::Autolock lock(mMutex);
- // TODO: Add waiting on mFrameCompletedCondition here?
- mStopped = true;
+ mUseAbsoluteTimestamps = true;
+ return OK;
+}
+
+status_t SurfaceMediaSource::stop()
+{
+ ALOGV("stop");
+ Mutex::Autolock lock(mMutex);
+
+ if (!mStarted) {
+ return OK;
+ }
+
+ while (mNumPendingBuffers > 0) {
+ ALOGI("Still waiting for %d buffers to be returned.",
+ mNumPendingBuffers);
+
+#if DEBUG_PENDING_BUFFERS
+ for (size_t i = 0; i < mPendingBuffers.size(); ++i) {
+ ALOGI("%d: %p", i, mPendingBuffers.itemAt(i));
+ }
+#endif
+
+ mMediaBuffersAvailableCondition.wait(mMutex);
+ }
+
+ mStarted = false;
mFrameAvailableCondition.signal();
- mBufferQueue->consumerDisconnect();
+ mMediaBuffersAvailableCondition.signal();
- return OK;
+ return mBufferQueue->consumerDisconnect();
}
sp<MetaData> SurfaceMediaSource::getFormat()
@@ -193,9 +258,8 @@ sp<MetaData> SurfaceMediaSource::getFormat()
// Note: Call only when you have the lock
static void passMetadataBuffer(MediaBuffer **buffer,
buffer_handle_t bufferHandle) {
- // MediaBuffer allocates and owns this data
- MediaBuffer *tempBuffer = new MediaBuffer(4 + sizeof(buffer_handle_t));
- char *data = (char *)tempBuffer->data();
+ *buffer = new MediaBuffer(4 + sizeof(buffer_handle_t));
+ char *data = (char *)(*buffer)->data();
if (data == NULL) {
ALOGE("Cannot allocate memory for metadata buffer!");
return;
@@ -203,7 +267,6 @@ static void passMetadataBuffer(MediaBuffer **buffer,
OMX_U32 type = kMetadataBufferTypeGrallocSource;
memcpy(data, &type, 4);
memcpy(data + 4, &bufferHandle, sizeof(buffer_handle_t));
- *buffer = tempBuffer;
ALOGV("handle = %p, , offset = %d, length = %d",
bufferHandle, (*buffer)->range_length(), (*buffer)->range_offset());
@@ -217,6 +280,10 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
*buffer = NULL;
+ while (mStarted && mNumPendingBuffers == mMaxAcquiredBufferCount) {
+ mMediaBuffersAvailableCondition.wait(mMutex);
+ }
+
// Update the current buffer info
// TODO: mCurrentSlot can be made a bufferstate since there
// can be more than one "current" slots.
@@ -224,7 +291,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
BufferQueue::BufferItem item;
// If the recording has started and the queue is empty, then just
// wait here till the frames come in from the client side
- while (!mStopped) {
+ while (mStarted) {
status_t err = mBufferQueue->acquireBuffer(&item);
if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
@@ -238,13 +305,14 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
}
// check for the timing of this buffer
- if (mNumFramesReceived == 0) {
+ if (mNumFramesReceived == 0 && !mUseAbsoluteTimestamps) {
mFirstFrameTimestamp = item.mTimestamp;
// Initial delay
if (mStartTimeNs > 0) {
if (item.mTimestamp < mStartTimeNs) {
// This frame predates start of record, discard
- mBufferQueue->releaseBuffer(item.mBuf, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR);
+ mBufferQueue->releaseBuffer(item.mBuf, EGL_NO_DISPLAY,
+ EGL_NO_SYNC_KHR, Fence::NO_FENCE);
continue;
}
mStartTimeNs = item.mTimestamp - mStartTimeNs;
@@ -264,7 +332,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
// If the loop was exited as a result of stopping the recording,
// it is OK
- if (mStopped) {
+ if (!mStarted) {
ALOGV("Read: SurfaceMediaSource is stopped. Returning ERROR_END_OF_STREAM.");
return ERROR_END_OF_STREAM;
}
@@ -282,6 +350,7 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
mNumFramesEncoded++;
// Pass the data to the MediaBuffer. Pass in only the metadata
+
passMetadataBuffer(buffer, mBufferSlot[mCurrentSlot]->handle);
(*buffer)->setObserver(this);
@@ -291,6 +360,13 @@ status_t SurfaceMediaSource::read( MediaBuffer **buffer,
mNumFramesEncoded, mCurrentTimestamp / 1000,
mCurrentTimestamp / 1000 - prevTimeStamp / 1000);
+ ++mNumPendingBuffers;
+
+#if DEBUG_PENDING_BUFFERS
+ mPendingBuffers.push_back(*buffer);
+#endif
+
+ ALOGV("returning mbuf %p", *buffer);
return OK;
}
@@ -333,7 +409,8 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) {
ALOGV("Slot %d returned, matches handle = %p", id,
mBufferSlot[id]->handle);
- mBufferQueue->releaseBuffer(id, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR);
+ mBufferQueue->releaseBuffer(id, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR,
+ Fence::NO_FENCE);
buffer->setObserver(0);
buffer->release();
@@ -346,6 +423,18 @@ void SurfaceMediaSource::signalBufferReturned(MediaBuffer *buffer) {
if (!foundBuffer) {
CHECK(!"signalBufferReturned: bogus buffer");
}
+
+#if DEBUG_PENDING_BUFFERS
+ for (size_t i = 0; i < mPendingBuffers.size(); ++i) {
+ if (mPendingBuffers.itemAt(i) == buffer) {
+ mPendingBuffers.removeAt(i);
+ break;
+ }
+ }
+#endif
+
+ --mNumPendingBuffers;
+ mMediaBuffersAvailableCondition.broadcast();
}
// Part of the BufferQueue::ConsumerListener
@@ -374,7 +463,6 @@ void SurfaceMediaSource::onBuffersReleased() {
Mutex::Autolock lock(mMutex);
mFrameAvailableCondition.signal();
- mStopped = true;
for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
mBufferSlot[i] = 0;
diff --git a/media/libstagefright/ThrottledSource.cpp b/media/libstagefright/ThrottledSource.cpp
index b1fcafd..348a9d3 100644
--- a/media/libstagefright/ThrottledSource.cpp
+++ b/media/libstagefright/ThrottledSource.cpp
@@ -17,16 +17,10 @@
#include "include/ThrottledSource.h"
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
namespace android {
-static int64_t getNowUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_usec + tv.tv_sec * 1000000ll;
-}
-
ThrottledSource::ThrottledSource(
const sp<DataSource> &source,
int32_t bandwidthLimitBytesPerSecond)
@@ -52,7 +46,7 @@ ssize_t ThrottledSource::readAt(off64_t offset, void *data, size_t size) {
mTotalTransferred += n;
- int64_t nowUs = getNowUs();
+ int64_t nowUs = ALooper::GetNowUs();
if (mStartTimeUs < 0) {
mStartTimeUs = nowUs;
diff --git a/media/libstagefright/TimeSource.cpp b/media/libstagefright/TimeSource.cpp
index d987fbf..041980f 100644
--- a/media/libstagefright/TimeSource.cpp
+++ b/media/libstagefright/TimeSource.cpp
@@ -17,24 +17,17 @@
#include <stddef.h>
#include <sys/time.h>
+#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/TimeSource.h>
namespace android {
SystemTimeSource::SystemTimeSource()
- : mStartTimeUs(GetSystemTimeUs()) {
+ : mStartTimeUs(ALooper::GetNowUs()) {
}
int64_t SystemTimeSource::getRealTimeUs() {
- return GetSystemTimeUs() - mStartTimeUs;
-}
-
-// static
-int64_t SystemTimeSource::GetSystemTimeUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
+ return ALooper::GetNowUs() - mStartTimeUs;
}
} // namespace android
diff --git a/media/libstagefright/TimedEventQueue.cpp b/media/libstagefright/TimedEventQueue.cpp
index 9df15eb..7e9c4bf 100644
--- a/media/libstagefright/TimedEventQueue.cpp
+++ b/media/libstagefright/TimedEventQueue.cpp
@@ -30,6 +30,7 @@
#include <sys/time.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
namespace android {
@@ -94,7 +95,7 @@ TimedEventQueue::event_id TimedEventQueue::postEventToBack(
TimedEventQueue::event_id TimedEventQueue::postEventWithDelay(
const sp<Event> &event, int64_t delay_us) {
CHECK(delay_us >= 0);
- return postTimedEvent(event, getRealTimeUs() + delay_us);
+ return postTimedEvent(event, ALooper::GetNowUs() + delay_us);
}
TimedEventQueue::event_id TimedEventQueue::postTimedEvent(
@@ -179,14 +180,6 @@ void TimedEventQueue::cancelEvents(
}
// static
-int64_t TimedEventQueue::getRealTimeUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_sec * 1000000ll + tv.tv_usec;
-}
-
-// static
void *TimedEventQueue::ThreadWrapper(void *me) {
androidSetThreadPriority(0, ANDROID_PRIORITY_FOREGROUND);
@@ -225,7 +218,7 @@ void TimedEventQueue::threadEntry() {
List<QueueItem>::iterator it = mQueue.begin();
eventID = (*it).event->eventID();
- now_us = getRealTimeUs();
+ now_us = ALooper::GetNowUs();
int64_t when_us = (*it).realtime_us;
int64_t delay_us;
@@ -258,7 +251,7 @@ void TimedEventQueue::threadEntry() {
if (!timeoutCapped && err == -ETIMEDOUT) {
// We finally hit the time this event is supposed to
// trigger.
- now_us = getRealTimeUs();
+ now_us = ALooper::GetNowUs();
break;
}
}
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index 2a16f66..74e9222 100644
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -241,5 +241,196 @@ status_t convertMetaDataToMessage(
return OK;
}
+static size_t reassembleAVCC(const sp<ABuffer> &csd0, const sp<ABuffer> csd1, char *avcc) {
+
+ avcc[0] = 1; // version
+ avcc[1] = 0x64; // profile
+ avcc[2] = 0; // unused (?)
+ avcc[3] = 0xd; // level
+ avcc[4] = 0xff; // reserved+size
+
+ size_t i = 0;
+ int numparams = 0;
+ int lastparamoffset = 0;
+ int avccidx = 6;
+ do {
+ if (i >= csd0->size() - 4 ||
+ memcmp(csd0->data() + i, "\x00\x00\x00\x01", 4) == 0) {
+ if (i >= csd0->size() - 4) {
+ // there can't be another param here, so use all the rest
+ i = csd0->size();
+ }
+ ALOGV("block at %d, last was %d", i, lastparamoffset);
+ if (lastparamoffset > 0) {
+ int size = i - lastparamoffset;
+ avcc[avccidx++] = size >> 8;
+ avcc[avccidx++] = size & 0xff;
+ memcpy(avcc+avccidx, csd0->data() + lastparamoffset, size);
+ avccidx += size;
+ numparams++;
+ }
+ i += 4;
+ lastparamoffset = i;
+ } else {
+ i++;
+ }
+ } while(i < csd0->size());
+ ALOGV("csd0 contains %d params", numparams);
+
+ avcc[5] = 0xe0 | numparams;
+ //and now csd-1
+ i = 0;
+ numparams = 0;
+ lastparamoffset = 0;
+ int numpicparamsoffset = avccidx;
+ avccidx++;
+ do {
+ if (i >= csd1->size() - 4 ||
+ memcmp(csd1->data() + i, "\x00\x00\x00\x01", 4) == 0) {
+ if (i >= csd1->size() - 4) {
+ // there can't be another param here, so use all the rest
+ i = csd1->size();
+ }
+ ALOGV("block at %d, last was %d", i, lastparamoffset);
+ if (lastparamoffset > 0) {
+ int size = i - lastparamoffset;
+ avcc[avccidx++] = size >> 8;
+ avcc[avccidx++] = size & 0xff;
+ memcpy(avcc+avccidx, csd1->data() + lastparamoffset, size);
+ avccidx += size;
+ numparams++;
+ }
+ i += 4;
+ lastparamoffset = i;
+ } else {
+ i++;
+ }
+ } while(i < csd1->size());
+ avcc[numpicparamsoffset] = numparams;
+ return avccidx;
+}
+
+static void reassembleESDS(const sp<ABuffer> &csd0, char *esds) {
+ int csd0size = csd0->size();
+ esds[0] = 3; // kTag_ESDescriptor;
+ int esdescriptorsize = 26 + csd0size;
+ CHECK(esdescriptorsize < 268435456); // 7 bits per byte, so max is 2^28-1
+ esds[1] = 0x80 | (esdescriptorsize >> 21);
+ esds[2] = 0x80 | ((esdescriptorsize >> 14) & 0x7f);
+ esds[3] = 0x80 | ((esdescriptorsize >> 7) & 0x7f);
+ esds[4] = (esdescriptorsize & 0x7f);
+ esds[5] = esds[6] = 0; // es id
+ esds[7] = 0; // flags
+ esds[8] = 4; // kTag_DecoderConfigDescriptor
+ int configdescriptorsize = 18 + csd0size;
+ esds[9] = 0x80 | (configdescriptorsize >> 21);
+ esds[10] = 0x80 | ((configdescriptorsize >> 14) & 0x7f);
+ esds[11] = 0x80 | ((configdescriptorsize >> 7) & 0x7f);
+ esds[12] = (configdescriptorsize & 0x7f);
+ esds[13] = 0x40; // objectTypeIndication
+ esds[14] = 0x15; // not sure what 14-25 mean, they are ignored by ESDS.cpp,
+ esds[15] = 0x00; // but the actual values here were taken from a real file.
+ esds[16] = 0x18;
+ esds[17] = 0x00;
+ esds[18] = 0x00;
+ esds[19] = 0x00;
+ esds[20] = 0xfa;
+ esds[21] = 0x00;
+ esds[22] = 0x00;
+ esds[23] = 0x00;
+ esds[24] = 0xfa;
+ esds[25] = 0x00;
+ esds[26] = 5; // kTag_DecoderSpecificInfo;
+ esds[27] = 0x80 | (csd0size >> 21);
+ esds[28] = 0x80 | ((csd0size >> 14) & 0x7f);
+ esds[29] = 0x80 | ((csd0size >> 7) & 0x7f);
+ esds[30] = (csd0size & 0x7f);
+ memcpy((void*)&esds[31], csd0->data(), csd0size);
+ // data following this is ignored, so don't bother appending it
+
+}
+
+void convertMessageToMetaData(const sp<AMessage> &msg, sp<MetaData> &meta) {
+ AString mime;
+ if (msg->findString("mime", &mime)) {
+ meta->setCString(kKeyMIMEType, mime.c_str());
+ } else {
+ ALOGW("did not find mime type");
+ }
+
+ int64_t durationUs;
+ if (msg->findInt64("durationUs", &durationUs)) {
+ meta->setInt64(kKeyDuration, durationUs);
+ }
+
+ if (mime.startsWith("video/")) {
+ int32_t width;
+ int32_t height;
+ if (msg->findInt32("width", &width) && msg->findInt32("height", &height)) {
+ meta->setInt32(kKeyWidth, width);
+ meta->setInt32(kKeyHeight, height);
+ } else {
+ ALOGW("did not find width and/or height");
+ }
+ } else if (mime.startsWith("audio/")) {
+ int32_t numChannels;
+ if (msg->findInt32("channel-count", &numChannels)) {
+ meta->setInt32(kKeyChannelCount, numChannels);
+ }
+ int32_t sampleRate;
+ if (msg->findInt32("sample-rate", &sampleRate)) {
+ meta->setInt32(kKeySampleRate, sampleRate);
+ }
+ int32_t channelMask;
+ if (msg->findInt32("channel-mask", &channelMask)) {
+ meta->setInt32(kKeyChannelMask, channelMask);
+ }
+ int32_t delay = 0;
+ if (msg->findInt32("encoder-delay", &delay)) {
+ meta->setInt32(kKeyEncoderDelay, delay);
+ }
+ int32_t padding = 0;
+ if (msg->findInt32("encoder-padding", &padding)) {
+ meta->setInt32(kKeyEncoderPadding, padding);
+ }
+
+ int32_t isADTS;
+ if (msg->findInt32("is-adts", &isADTS)) {
+ meta->setInt32(kKeyIsADTS, isADTS);
+ }
+ }
+
+ int32_t maxInputSize;
+ if (msg->findInt32("max-input-size", &maxInputSize)) {
+ meta->setInt32(kKeyMaxInputSize, maxInputSize);
+ }
+
+ // reassemble the csd data into its original form
+ sp<ABuffer> csd0;
+ if (msg->findBuffer("csd-0", &csd0)) {
+ if (mime.startsWith("video/")) { // do we need to be stricter than this?
+ sp<ABuffer> csd1;
+ if (msg->findBuffer("csd-1", &csd1)) {
+ char avcc[1024]; // that oughta be enough, right?
+ size_t outsize = reassembleAVCC(csd0, csd1, avcc);
+ meta->setData(kKeyAVCC, kKeyAVCC, avcc, outsize);
+ }
+ } else if (mime.startsWith("audio/")) {
+ int csd0size = csd0->size();
+ char esds[csd0size + 31];
+ reassembleESDS(csd0, esds);
+ meta->setData(kKeyESDS, kKeyESDS, esds, sizeof(esds));
+ }
+ }
+
+ // XXX TODO add whatever other keys there are
+
+#if 0
+ ALOGI("converted %s to:", msg->debugString(0).c_str());
+ meta->dumpToLog();
+#endif
+}
+
+
} // namespace android
diff --git a/media/libstagefright/WAVExtractor.cpp b/media/libstagefright/WAVExtractor.cpp
index 851321d..2a7f628 100644
--- a/media/libstagefright/WAVExtractor.cpp
+++ b/media/libstagefright/WAVExtractor.cpp
@@ -106,7 +106,7 @@ sp<MetaData> WAVExtractor::getMetaData() {
return meta;
}
- meta->setCString(kKeyMIMEType, "audio/x-wav");
+ meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_WAV);
return meta;
}
@@ -401,8 +401,10 @@ status_t WAVSource::read(
return err;
}
+ // make sure that maxBytesToRead is multiple of 3, in 24-bit case
size_t maxBytesToRead =
- mBitsPerSample == 8 ? kMaxFrameSize / 2 : kMaxFrameSize;
+ mBitsPerSample == 8 ? kMaxFrameSize / 2 :
+ (mBitsPerSample == 24 ? 3*(kMaxFrameSize/3): kMaxFrameSize);
size_t maxBytesAvailable =
(mCurrentPos - mOffset >= (off64_t)mSize)
@@ -425,7 +427,7 @@ status_t WAVSource::read(
buffer->set_range(0, n);
- if (mWaveFormat == WAVE_FORMAT_PCM) {
+ if (mWaveFormat == WAVE_FORMAT_PCM || mWaveFormat == WAVE_FORMAT_EXTENSIBLE) {
if (mBitsPerSample == 8) {
// Convert 8-bit unsigned samples to 16-bit signed.
@@ -509,4 +511,3 @@ bool SniffWAV(
}
} // namespace android
-
diff --git a/media/libstagefright/WVMExtractor.cpp b/media/libstagefright/WVMExtractor.cpp
index 08d2ae2..5ae80cc 100644
--- a/media/libstagefright/WVMExtractor.cpp
+++ b/media/libstagefright/WVMExtractor.cpp
@@ -72,15 +72,18 @@ WVMExtractor::WVMExtractor(const sp<DataSource> &source)
}
}
-bool WVMExtractor::getVendorLibHandle()
+static void init_routine()
{
- if (gVendorLibHandle == NULL) {
- gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
- }
-
+ gVendorLibHandle = dlopen("libwvm.so", RTLD_NOW);
if (gVendorLibHandle == NULL) {
ALOGE("Failed to open libwvm.so");
}
+}
+
+bool WVMExtractor::getVendorLibHandle()
+{
+ static pthread_once_t sOnceControl = PTHREAD_ONCE_INIT;
+ pthread_once(&sOnceControl, init_routine);
return gVendorLibHandle != NULL;
}
@@ -121,6 +124,15 @@ int64_t WVMExtractor::getCachedDurationUs(status_t *finalStatus) {
return mImpl->getCachedDurationUs(finalStatus);
}
+status_t WVMExtractor::getEstimatedBandwidthKbps(int32_t *kbps) {
+ if (mImpl == NULL) {
+ return UNKNOWN_ERROR;
+ }
+
+ return mImpl->getEstimatedBandwidthKbps(kbps);
+}
+
+
void WVMExtractor::setAdaptiveStreamingMode(bool adaptive) {
if (mImpl != NULL) {
mImpl->setAdaptiveStreamingMode(adaptive);
@@ -139,6 +151,20 @@ void WVMExtractor::setUID(uid_t uid) {
}
}
+status_t WVMExtractor::getError() {
+ if (mImpl == NULL) {
+ return UNKNOWN_ERROR;
+ }
+
+ return mImpl->getError();
+}
+
+void WVMExtractor::setError(status_t err) {
+ if (mImpl != NULL) {
+ mImpl->setError(err);
+ }
+}
+
bool SniffWVM(
const sp<DataSource> &source, String8 *mimeType, float *confidence,
sp<AMessage> *) {
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp
index 65c1848..a141752 100644
--- a/media/libstagefright/avc_utils.cpp
+++ b/media/libstagefright/avc_utils.cpp
@@ -600,7 +600,7 @@ bool GetMPEGAudioFrameSize(
bitrate = kBitrateV2[bitrate_index - 1];
if (out_num_samples) {
- *out_num_samples = 576;
+ *out_num_samples = (layer == 1 /* L3 */) ? 576 : 1152;
}
}
@@ -612,7 +612,8 @@ bool GetMPEGAudioFrameSize(
*frame_size = 144000 * bitrate / sampling_rate + padding;
} else {
// V2 or V2.5
- *frame_size = 72000 * bitrate / sampling_rate + padding;
+ size_t tmp = (layer == 1 /* L3 */) ? 72000 : 144000;
+ *frame_size = tmp * bitrate / sampling_rate + padding;
}
}
diff --git a/media/libstagefright/chromium_http/Android.mk b/media/libstagefright/chromium_http/Android.mk
index 6ab2a00..2c6d84c 100644
--- a/media/libstagefright/chromium_http/Android.mk
+++ b/media/libstagefright/chromium_http/Android.mk
@@ -6,7 +6,8 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
DataUriSource.cpp \
ChromiumHTTPDataSource.cpp \
- support.cpp
+ support.cpp \
+ chromium_http_stub.cpp
LOCAL_C_INCLUDES:= \
$(TOP)/frameworks/av/media/libstagefright \
@@ -16,10 +17,20 @@ LOCAL_C_INCLUDES:= \
LOCAL_CFLAGS += -Wno-multichar
-LOCAL_SHARED_LIBRARIES += libstlport
+LOCAL_SHARED_LIBRARIES += \
+ libstlport \
+ libchromium_net \
+ libutils \
+ libcutils \
+ libstagefright_foundation \
+ libstagefright \
+ libdrmframework
+
include external/stlport/libstlport.mk
LOCAL_MODULE:= libstagefright_chromium_http
-include $(BUILD_STATIC_LIBRARY)
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_SHARED_LIBRARY)
endif
diff --git a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
index 3f0b2c2..32a0ec8 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -78,12 +78,8 @@ status_t ChromiumHTTPDataSource::connect_l(
disconnect_l();
}
- if (!(mFlags & kFlagIncognito)) {
- LOG_PRI(ANDROID_LOG_INFO, LOG_TAG, "connect to %s @%lld", uri, offset);
- } else {
- LOG_PRI(ANDROID_LOG_INFO, LOG_TAG,
+ LOG_PRI(ANDROID_LOG_INFO, LOG_TAG,
"connect to <URL suppressed> @%lld", offset);
- }
mURI = uri;
mContentType = String8("application/octet-stream");
diff --git a/media/libstagefright/chromium_http/chromium_http_stub.cpp b/media/libstagefright/chromium_http/chromium_http_stub.cpp
new file mode 100644
index 0000000..560a61f
--- /dev/null
+++ b/media/libstagefright/chromium_http/chromium_http_stub.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include <include/chromium_http_stub.h>
+#include <include/ChromiumHTTPDataSource.h>
+#include <include/DataUriSource.h>
+
+namespace android {
+
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags) {
+ return new ChromiumHTTPDataSource(flags);
+}
+
+DataSource *createDataUriSource(const char *uri) {
+ return new DataUriSource(uri);
+}
+
+}
diff --git a/media/libstagefright/chromium_http_stub.cpp b/media/libstagefright/chromium_http_stub.cpp
new file mode 100644
index 0000000..cbd8796
--- /dev/null
+++ b/media/libstagefright/chromium_http_stub.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include <media/stagefright/DataSource.h>
+
+#include "include/chromium_http_stub.h"
+#include "include/HTTPBase.h"
+
+namespace android {
+
+static bool gFirst = true;
+static void *gHandle;
+static Mutex gLibMutex;
+
+HTTPBase *(*gLib_createChromiumHTTPDataSource)(uint32_t flags);
+DataSource *(*gLib_createDataUriSource)(const char *uri);
+
+static bool load_libstagefright_chromium_http() {
+ Mutex::Autolock autoLock(gLibMutex);
+ void *sym;
+
+ if (!gFirst) {
+ return (gHandle != NULL);
+ }
+
+ gFirst = false;
+
+ gHandle = dlopen("libstagefright_chromium_http.so", RTLD_NOW);
+ if (gHandle == NULL) {
+ return false;
+ }
+
+ sym = dlsym(gHandle, "createChromiumHTTPDataSource");
+ if (sym == NULL) {
+ gHandle = NULL;
+ return false;
+ }
+ gLib_createChromiumHTTPDataSource = (HTTPBase *(*)(uint32_t))sym;
+
+ sym = dlsym(gHandle, "createDataUriSource");
+ if (sym == NULL) {
+ gHandle = NULL;
+ return false;
+ }
+ gLib_createDataUriSource = (DataSource *(*)(const char *))sym;
+
+ return true;
+}
+
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags) {
+ if (!load_libstagefright_chromium_http()) {
+ return NULL;
+ }
+
+ return gLib_createChromiumHTTPDataSource(flags);
+}
+
+DataSource *createDataUriSource(const char *uri) {
+ if (!load_libstagefright_chromium_http()) {
+ return NULL;
+ }
+
+ return gLib_createDataUriSource(uri);
+}
+
+}
diff --git a/media/libstagefright/codecs/aacdec/Android.mk b/media/libstagefright/codecs/aacdec/Android.mk
index 91457c5..4dc38a8 100644
--- a/media/libstagefright/codecs/aacdec/Android.mk
+++ b/media/libstagefright/codecs/aacdec/Android.mk
@@ -1,213 +1,28 @@
LOCAL_PATH:= $(call my-dir)
-AAC_LIBRARY = fraunhofer
+include $(CLEAR_VARS)
-ifeq ($(AAC_LIBRARY), fraunhofer)
- include $(CLEAR_VARS)
+LOCAL_SRC_FILES := \
+ SoftAAC2.cpp
- LOCAL_SRC_FILES := \
- SoftAAC2.cpp
+LOCAL_C_INCLUDES := \
+ frameworks/av/media/libstagefright/include \
+ frameworks/native/include/media/openmax \
+ external/aac/libAACdec/include \
+ external/aac/libPCMutils/include \
+ external/aac/libFDK/include \
+ external/aac/libMpegTPDec/include \
+ external/aac/libSBRdec/include \
+ external/aac/libSYS/include
- LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax \
- external/aac/libAACdec/include \
- external/aac/libPCMutils/include \
- external/aac/libFDK/include \
- external/aac/libMpegTPDec/include \
- external/aac/libSBRdec/include \
- external/aac/libSYS/include
+LOCAL_CFLAGS :=
- LOCAL_CFLAGS :=
+LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
- LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
+LOCAL_SHARED_LIBRARIES := \
+ libstagefright_omx libstagefright_foundation libutils libcutils
- LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils libcutils
+LOCAL_MODULE := libstagefright_soft_aacdec
+LOCAL_MODULE_TAGS := optional
- LOCAL_MODULE := libstagefright_soft_aacdec
- LOCAL_MODULE_TAGS := optional
-
- include $(BUILD_SHARED_LIBRARY)
-
-else # pv
-
- LOCAL_SRC_FILES := \
- analysis_sub_band.cpp \
- apply_ms_synt.cpp \
- apply_tns.cpp \
- buf_getbits.cpp \
- byte_align.cpp \
- calc_auto_corr.cpp \
- calc_gsfb_table.cpp \
- calc_sbr_anafilterbank.cpp \
- calc_sbr_envelope.cpp \
- calc_sbr_synfilterbank.cpp \
- check_crc.cpp \
- dct16.cpp \
- dct64.cpp \
- decode_huff_cw_binary.cpp \
- decode_noise_floorlevels.cpp \
- deinterleave.cpp \
- digit_reversal_tables.cpp \
- dst16.cpp \
- dst32.cpp \
- dst8.cpp \
- esc_iquant_scaling.cpp \
- extractframeinfo.cpp \
- fft_rx4_long.cpp \
- fft_rx4_short.cpp \
- fft_rx4_tables_fxp.cpp \
- find_adts_syncword.cpp \
- fwd_long_complex_rot.cpp \
- fwd_short_complex_rot.cpp \
- gen_rand_vector.cpp \
- get_adif_header.cpp \
- get_adts_header.cpp \
- get_audio_specific_config.cpp \
- get_dse.cpp \
- get_ele_list.cpp \
- get_ga_specific_config.cpp \
- get_ics_info.cpp \
- get_prog_config.cpp \
- get_pulse_data.cpp \
- get_sbr_bitstream.cpp \
- get_sbr_startfreq.cpp \
- get_sbr_stopfreq.cpp \
- get_tns.cpp \
- getfill.cpp \
- getgroup.cpp \
- getics.cpp \
- getmask.cpp \
- hcbtables_binary.cpp \
- huffcb.cpp \
- huffdecode.cpp \
- hufffac.cpp \
- huffspec_fxp.cpp \
- idct16.cpp \
- idct32.cpp \
- idct8.cpp \
- imdct_fxp.cpp \
- infoinit.cpp \
- init_sbr_dec.cpp \
- intensity_right.cpp \
- inv_long_complex_rot.cpp \
- inv_short_complex_rot.cpp \
- iquant_table.cpp \
- long_term_prediction.cpp \
- long_term_synthesis.cpp \
- lt_decode.cpp \
- mdct_fxp.cpp \
- mdct_tables_fxp.cpp \
- mdst.cpp \
- mix_radix_fft.cpp \
- ms_synt.cpp \
- pns_corr.cpp \
- pns_intensity_right.cpp \
- pns_left.cpp \
- ps_all_pass_filter_coeff.cpp \
- ps_all_pass_fract_delay_filter.cpp \
- ps_allocate_decoder.cpp \
- ps_applied.cpp \
- ps_bstr_decoding.cpp \
- ps_channel_filtering.cpp \
- ps_decode_bs_utils.cpp \
- ps_decorrelate.cpp \
- ps_fft_rx8.cpp \
- ps_hybrid_analysis.cpp \
- ps_hybrid_filter_bank_allocation.cpp \
- ps_hybrid_synthesis.cpp \
- ps_init_stereo_mixing.cpp \
- ps_pwr_transient_detection.cpp \
- ps_read_data.cpp \
- ps_stereo_processing.cpp \
- pulse_nc.cpp \
- pv_div.cpp \
- pv_log2.cpp \
- pv_normalize.cpp \
- pv_pow2.cpp \
- pv_sine.cpp \
- pv_sqrt.cpp \
- pvmp4audiodecoderconfig.cpp \
- pvmp4audiodecoderframe.cpp \
- pvmp4audiodecodergetmemrequirements.cpp \
- pvmp4audiodecoderinitlibrary.cpp \
- pvmp4audiodecoderresetbuffer.cpp \
- q_normalize.cpp \
- qmf_filterbank_coeff.cpp \
- sbr_aliasing_reduction.cpp \
- sbr_applied.cpp \
- sbr_code_book_envlevel.cpp \
- sbr_crc_check.cpp \
- sbr_create_limiter_bands.cpp \
- sbr_dec.cpp \
- sbr_decode_envelope.cpp \
- sbr_decode_huff_cw.cpp \
- sbr_downsample_lo_res.cpp \
- sbr_envelope_calc_tbl.cpp \
- sbr_envelope_unmapping.cpp \
- sbr_extract_extended_data.cpp \
- sbr_find_start_andstop_band.cpp \
- sbr_generate_high_freq.cpp \
- sbr_get_additional_data.cpp \
- sbr_get_cpe.cpp \
- sbr_get_dir_control_data.cpp \
- sbr_get_envelope.cpp \
- sbr_get_header_data.cpp \
- sbr_get_noise_floor_data.cpp \
- sbr_get_sce.cpp \
- sbr_inv_filt_levelemphasis.cpp \
- sbr_open.cpp \
- sbr_read_data.cpp \
- sbr_requantize_envelope_data.cpp \
- sbr_reset_dec.cpp \
- sbr_update_freq_scale.cpp \
- set_mc_info.cpp \
- sfb.cpp \
- shellsort.cpp \
- synthesis_sub_band.cpp \
- tns_ar_filter.cpp \
- tns_decode_coef.cpp \
- tns_inv_filter.cpp \
- trans4m_freq_2_time_fxp.cpp \
- trans4m_time_2_freq_fxp.cpp \
- unpack_idx.cpp \
- window_tables_fxp.cpp \
- pvmp4setaudioconfig.cpp \
-
- LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DOSCL_IMPORT_REF= -DOSCL_EXPORT_REF= -DOSCL_UNUSED_ARG=
-
- LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
-
- LOCAL_ARM_MODE := arm
-
- LOCAL_MODULE := libstagefright_aacdec
-
- include $(BUILD_STATIC_LIBRARY)
-
- ################################################################################
-
- include $(CLEAR_VARS)
-
- LOCAL_SRC_FILES := \
- SoftAAC.cpp
-
- LOCAL_C_INCLUDES := \
- frameworks/av/media/libstagefright/include \
- frameworks/native/include/media/openmax
-
- LOCAL_CFLAGS := -DOSCL_IMPORT_REF=
-
- LOCAL_STATIC_LIBRARIES := \
- libstagefright_aacdec
-
- LOCAL_SHARED_LIBRARIES := \
- libstagefright_omx libstagefright_foundation libutils
-
- LOCAL_MODULE := libstagefright_soft_aacdec
- LOCAL_MODULE_TAGS := optional
-
- include $(BUILD_SHARED_LIBRARY)
-
-endif # $(AAC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.cpp b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
deleted file mode 100644
index 7c82484..0000000
--- a/media/libstagefright/codecs/aacdec/SoftAAC.cpp
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "SoftAAC"
-#include <utils/Log.h>
-
-#include "SoftAAC.h"
-
-#include "pvmp4audiodecoder_api.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/hexdump.h>
-#include <media/stagefright/MediaErrors.h>
-
-namespace android {
-
-template<class T>
-static void InitOMXParams(T *params) {
- params->nSize = sizeof(T);
- params->nVersion.s.nVersionMajor = 1;
- params->nVersion.s.nVersionMinor = 0;
- params->nVersion.s.nRevision = 0;
- params->nVersion.s.nStep = 0;
-}
-
-SoftAAC::SoftAAC(
- const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component)
- : SimpleSoftOMXComponent(name, callbacks, appData, component),
- mConfig(new tPVMP4AudioDecoderExternal),
- mIsADTS(false),
- mDecoderBuf(NULL),
- mInputBufferCount(0),
- mUpsamplingFactor(2),
- mAnchorTimeUs(0),
- mNumSamplesOutput(0),
- mSignalledError(false),
- mOutputPortSettingsChange(NONE) {
- initPorts();
- CHECK_EQ(initDecoder(), (status_t)OK);
-}
-
-SoftAAC::~SoftAAC() {
- free(mDecoderBuf);
- mDecoderBuf = NULL;
-
- delete mConfig;
- mConfig = NULL;
-}
-
-void SoftAAC::initPorts() {
- OMX_PARAM_PORTDEFINITIONTYPE def;
- InitOMXParams(&def);
-
- def.nPortIndex = 0;
- def.eDir = OMX_DirInput;
- def.nBufferCountMin = kNumInputBuffers;
- def.nBufferCountActual = def.nBufferCountMin;
- def.nBufferSize = 8192;
- def.bEnabled = OMX_TRUE;
- def.bPopulated = OMX_FALSE;
- def.eDomain = OMX_PortDomainAudio;
- def.bBuffersContiguous = OMX_FALSE;
- def.nBufferAlignment = 1;
-
- def.format.audio.cMIMEType = const_cast<char *>("audio/aac");
- def.format.audio.pNativeRender = NULL;
- def.format.audio.bFlagErrorConcealment = OMX_FALSE;
- def.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
-
- addPort(def);
-
- def.nPortIndex = 1;
- def.eDir = OMX_DirOutput;
- def.nBufferCountMin = kNumOutputBuffers;
- def.nBufferCountActual = def.nBufferCountMin;
- def.nBufferSize = 8192;
- def.bEnabled = OMX_TRUE;
- def.bPopulated = OMX_FALSE;
- def.eDomain = OMX_PortDomainAudio;
- def.bBuffersContiguous = OMX_FALSE;
- def.nBufferAlignment = 2;
-
- def.format.audio.cMIMEType = const_cast<char *>("audio/raw");
- def.format.audio.pNativeRender = NULL;
- def.format.audio.bFlagErrorConcealment = OMX_FALSE;
- def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
-
- addPort(def);
-}
-
-status_t SoftAAC::initDecoder() {
- memset(mConfig, 0, sizeof(tPVMP4AudioDecoderExternal));
- mConfig->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED;
- mConfig->aacPlusEnabled = 1;
-
- // The software decoder doesn't properly support mono output on
- // AACplus files. Always output stereo.
- mConfig->desiredChannels = 2;
-
- UInt32 memRequirements = PVMP4AudioDecoderGetMemRequirements();
- mDecoderBuf = malloc(memRequirements);
-
- Int err = PVMP4AudioDecoderInitLibrary(mConfig, mDecoderBuf);
- if (err != MP4AUDEC_SUCCESS) {
- ALOGE("Failed to initialize MP4 audio decoder");
- return UNKNOWN_ERROR;
- }
-
- return OK;
-}
-
-OMX_ERRORTYPE SoftAAC::internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params) {
- switch (index) {
- case OMX_IndexParamAudioAac:
- {
- OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
- (OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
-
- if (aacParams->nPortIndex != 0) {
- return OMX_ErrorUndefined;
- }
-
- aacParams->nBitRate = 0;
- aacParams->nAudioBandWidth = 0;
- aacParams->nAACtools = 0;
- aacParams->nAACERtools = 0;
- aacParams->eAACProfile = OMX_AUDIO_AACObjectMain;
-
- aacParams->eAACStreamFormat =
- mIsADTS
- ? OMX_AUDIO_AACStreamFormatMP4ADTS
- : OMX_AUDIO_AACStreamFormatMP4FF;
-
- aacParams->eChannelMode = OMX_AUDIO_ChannelModeStereo;
-
- if (!isConfigured()) {
- aacParams->nChannels = 1;
- aacParams->nSampleRate = 44100;
- aacParams->nFrameLength = 0;
- } else {
- aacParams->nChannels = mConfig->encodedChannels;
- aacParams->nSampleRate = mConfig->samplingRate;
- aacParams->nFrameLength = mConfig->frameLength;
- }
-
- return OMX_ErrorNone;
- }
-
- case OMX_IndexParamAudioPcm:
- {
- OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
- (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
-
- if (pcmParams->nPortIndex != 1) {
- return OMX_ErrorUndefined;
- }
-
- pcmParams->eNumData = OMX_NumericalDataSigned;
- pcmParams->eEndian = OMX_EndianBig;
- pcmParams->bInterleaved = OMX_TRUE;
- pcmParams->nBitPerSample = 16;
- pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
- pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
- pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
-
- if (!isConfigured()) {
- pcmParams->nChannels = 1;
- pcmParams->nSamplingRate = 44100;
- } else {
- pcmParams->nChannels = mConfig->desiredChannels;
- pcmParams->nSamplingRate = mConfig->samplingRate;
- }
-
- return OMX_ErrorNone;
- }
-
- default:
- return SimpleSoftOMXComponent::internalGetParameter(index, params);
- }
-}
-
-OMX_ERRORTYPE SoftAAC::internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params) {
- switch (index) {
- case OMX_IndexParamStandardComponentRole:
- {
- const OMX_PARAM_COMPONENTROLETYPE *roleParams =
- (const OMX_PARAM_COMPONENTROLETYPE *)params;
-
- if (strncmp((const char *)roleParams->cRole,
- "audio_decoder.aac",
- OMX_MAX_STRINGNAME_SIZE - 1)) {
- return OMX_ErrorUndefined;
- }
-
- return OMX_ErrorNone;
- }
-
- case OMX_IndexParamAudioAac:
- {
- const OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
- (const OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
-
- if (aacParams->nPortIndex != 0) {
- return OMX_ErrorUndefined;
- }
-
- if (aacParams->eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP4FF) {
- mIsADTS = false;
- } else if (aacParams->eAACStreamFormat
- == OMX_AUDIO_AACStreamFormatMP4ADTS) {
- mIsADTS = true;
- } else {
- return OMX_ErrorUndefined;
- }
-
- return OMX_ErrorNone;
- }
-
- case OMX_IndexParamAudioPcm:
- {
- const OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
- (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
-
- if (pcmParams->nPortIndex != 1) {
- return OMX_ErrorUndefined;
- }
-
- return OMX_ErrorNone;
- }
-
- default:
- return SimpleSoftOMXComponent::internalSetParameter(index, params);
- }
-}
-
-bool SoftAAC::isConfigured() const {
- return mInputBufferCount > 0;
-}
-
-void SoftAAC::onQueueFilled(OMX_U32 portIndex) {
- if (mSignalledError || mOutputPortSettingsChange != NONE) {
- return;
- }
-
- List<BufferInfo *> &inQueue = getPortQueue(0);
- List<BufferInfo *> &outQueue = getPortQueue(1);
-
- if (portIndex == 0 && mInputBufferCount == 0) {
- ++mInputBufferCount;
-
- BufferInfo *info = *inQueue.begin();
- OMX_BUFFERHEADERTYPE *header = info->mHeader;
-
- mConfig->pInputBuffer = header->pBuffer + header->nOffset;
- mConfig->inputBufferCurrentLength = header->nFilledLen;
- mConfig->inputBufferMaxLength = 0;
-
- Int err = PVMP4AudioDecoderConfig(mConfig, mDecoderBuf);
- if (err != MP4AUDEC_SUCCESS) {
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, err, NULL);
- return;
- }
-
- inQueue.erase(inQueue.begin());
- info->mOwnedByUs = false;
- notifyEmptyBufferDone(header);
-
- notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
- mOutputPortSettingsChange = AWAITING_DISABLED;
- return;
- }
-
- while (!inQueue.empty() && !outQueue.empty()) {
- BufferInfo *inInfo = *inQueue.begin();
- OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
-
- BufferInfo *outInfo = *outQueue.begin();
- OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
-
- if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
- inQueue.erase(inQueue.begin());
- inInfo->mOwnedByUs = false;
- notifyEmptyBufferDone(inHeader);
-
- outHeader->nFilledLen = 0;
- outHeader->nFlags = OMX_BUFFERFLAG_EOS;
-
- outQueue.erase(outQueue.begin());
- outInfo->mOwnedByUs = false;
- notifyFillBufferDone(outHeader);
- return;
- }
-
- if (inHeader->nOffset == 0) {
- mAnchorTimeUs = inHeader->nTimeStamp;
- mNumSamplesOutput = 0;
- }
-
- size_t adtsHeaderSize = 0;
- if (mIsADTS) {
- // skip 30 bits, aac_frame_length follows.
- // ssssssss ssssiiip ppffffPc ccohCCll llllllll lll?????
-
- const uint8_t *adtsHeader = inHeader->pBuffer + inHeader->nOffset;
-
- bool signalError = false;
- if (inHeader->nFilledLen < 7) {
- ALOGE("Audio data too short to contain even the ADTS header. "
- "Got %ld bytes.", inHeader->nFilledLen);
- hexdump(adtsHeader, inHeader->nFilledLen);
- signalError = true;
- } else {
- bool protectionAbsent = (adtsHeader[1] & 1);
-
- unsigned aac_frame_length =
- ((adtsHeader[3] & 3) << 11)
- | (adtsHeader[4] << 3)
- | (adtsHeader[5] >> 5);
-
- if (inHeader->nFilledLen < aac_frame_length) {
- ALOGE("Not enough audio data for the complete frame. "
- "Got %ld bytes, frame size according to the ADTS "
- "header is %u bytes.",
- inHeader->nFilledLen, aac_frame_length);
- hexdump(adtsHeader, inHeader->nFilledLen);
- signalError = true;
- } else {
- adtsHeaderSize = (protectionAbsent ? 7 : 9);
-
- mConfig->pInputBuffer =
- (UChar *)adtsHeader + adtsHeaderSize;
-
- mConfig->inputBufferCurrentLength =
- aac_frame_length - adtsHeaderSize;
-
- inHeader->nOffset += adtsHeaderSize;
- inHeader->nFilledLen -= adtsHeaderSize;
- }
- }
-
- if (signalError) {
- mSignalledError = true;
-
- notify(OMX_EventError, OMX_ErrorStreamCorrupt,
- ERROR_MALFORMED, NULL);
-
- return;
- }
- } else {
- mConfig->pInputBuffer = inHeader->pBuffer + inHeader->nOffset;
- mConfig->inputBufferCurrentLength = inHeader->nFilledLen;
- }
-
- mConfig->inputBufferMaxLength = 0;
- mConfig->inputBufferUsedLength = 0;
- mConfig->remainderBits = 0;
-
- mConfig->pOutputBuffer =
- reinterpret_cast<Int16 *>(outHeader->pBuffer + outHeader->nOffset);
-
- mConfig->pOutputBuffer_plus = &mConfig->pOutputBuffer[2048];
- mConfig->repositionFlag = false;
-
- Int32 prevSamplingRate = mConfig->samplingRate;
- Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
-
- /*
- * AAC+/eAAC+ streams can be signalled in two ways: either explicitly
- * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual
- * rate system and the sampling rate in the final output is actually
- * doubled compared with the core AAC decoder sampling rate.
- *
- * Explicit signalling is done by explicitly defining SBR audio object
- * type in the bitstream. Implicit signalling is done by embedding
- * SBR content in AAC extension payload specific to SBR, and hence
- * requires an AAC decoder to perform pre-checks on actual audio frames.
- *
- * Thus, we could not say for sure whether a stream is
- * AAC+/eAAC+ until the first data frame is decoded.
- */
- if (decoderErr == MP4AUDEC_SUCCESS && mInputBufferCount <= 2) {
- ALOGV("audio/extended audio object type: %d + %d",
- mConfig->audioObjectType, mConfig->extendedAudioObjectType);
- ALOGV("aac+ upsampling factor: %d desired channels: %d",
- mConfig->aacPlusUpsamplingFactor, mConfig->desiredChannels);
-
- if (mInputBufferCount == 1) {
- mUpsamplingFactor = mConfig->aacPlusUpsamplingFactor;
- // Check on the sampling rate to see whether it is changed.
- if (mConfig->samplingRate != prevSamplingRate) {
- ALOGW("Sample rate was %d Hz, but now is %d Hz",
- prevSamplingRate, mConfig->samplingRate);
-
- // We'll hold onto the input buffer and will decode
- // it again once the output port has been reconfigured.
-
- // We're going to want to revisit this input buffer, but
- // may have already advanced the offset. Undo that if
- // necessary.
- inHeader->nOffset -= adtsHeaderSize;
- inHeader->nFilledLen += adtsHeaderSize;
-
- notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
- mOutputPortSettingsChange = AWAITING_DISABLED;
- return;
- }
- } else { // mInputBufferCount == 2
- if (mConfig->extendedAudioObjectType == MP4AUDIO_AAC_LC ||
- mConfig->extendedAudioObjectType == MP4AUDIO_LTP) {
- if (mUpsamplingFactor == 2) {
- // The stream turns out to be not aacPlus mode anyway
- ALOGW("Disable AAC+/eAAC+ since extended audio object "
- "type is %d",
- mConfig->extendedAudioObjectType);
- mConfig->aacPlusEnabled = 0;
- }
- } else {
- if (mUpsamplingFactor == 1) {
- // aacPlus mode does not buy us anything, but to cause
- // 1. CPU load to increase, and
- // 2. a half speed of decoding
- ALOGW("Disable AAC+/eAAC+ since upsampling factor is 1");
- mConfig->aacPlusEnabled = 0;
- }
- }
- }
- }
-
- size_t numOutBytes =
- mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels;
-
- if (decoderErr == MP4AUDEC_SUCCESS) {
- CHECK_LE(mConfig->inputBufferUsedLength, inHeader->nFilledLen);
-
- inHeader->nFilledLen -= mConfig->inputBufferUsedLength;
- inHeader->nOffset += mConfig->inputBufferUsedLength;
- } else {
- ALOGW("AAC decoder returned error %d, substituting silence",
- decoderErr);
-
- memset(outHeader->pBuffer + outHeader->nOffset, 0, numOutBytes);
-
- // Discard input buffer.
- inHeader->nFilledLen = 0;
-
- // fall through
- }
-
- if (decoderErr == MP4AUDEC_SUCCESS || mNumSamplesOutput > 0) {
- // We'll only output data if we successfully decoded it or
- // we've previously decoded valid data, in the latter case
- // (decode failed) we'll output a silent frame.
-
- if (mUpsamplingFactor == 2) {
- if (mConfig->desiredChannels == 1) {
- memcpy(&mConfig->pOutputBuffer[1024],
- &mConfig->pOutputBuffer[2048],
- numOutBytes * 2);
- }
- numOutBytes *= 2;
- }
-
- outHeader->nFilledLen = numOutBytes;
- outHeader->nFlags = 0;
-
- outHeader->nTimeStamp =
- mAnchorTimeUs
- + (mNumSamplesOutput * 1000000ll) / mConfig->samplingRate;
-
- mNumSamplesOutput += mConfig->frameLength * mUpsamplingFactor;
-
- outInfo->mOwnedByUs = false;
- outQueue.erase(outQueue.begin());
- outInfo = NULL;
- notifyFillBufferDone(outHeader);
- outHeader = NULL;
- }
-
- if (inHeader->nFilledLen == 0) {
- inInfo->mOwnedByUs = false;
- inQueue.erase(inQueue.begin());
- inInfo = NULL;
- notifyEmptyBufferDone(inHeader);
- inHeader = NULL;
- }
-
- if (decoderErr == MP4AUDEC_SUCCESS) {
- ++mInputBufferCount;
- }
- }
-}
-
-void SoftAAC::onPortFlushCompleted(OMX_U32 portIndex) {
- if (portIndex == 0) {
- // Make sure that the next buffer output does not still
- // depend on fragments from the last one decoded.
- PVMP4AudioDecoderResetBuffer(mDecoderBuf);
- }
-}
-
-void SoftAAC::onPortEnableCompleted(OMX_U32 portIndex, bool enabled) {
- if (portIndex != 1) {
- return;
- }
-
- switch (mOutputPortSettingsChange) {
- case NONE:
- break;
-
- case AWAITING_DISABLED:
- {
- CHECK(!enabled);
- mOutputPortSettingsChange = AWAITING_ENABLED;
- break;
- }
-
- default:
- {
- CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED);
- CHECK(enabled);
- mOutputPortSettingsChange = NONE;
- break;
- }
- }
-}
-
-} // namespace android
-
-android::SoftOMXComponent *createSoftOMXComponent(
- const char *name, const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData, OMX_COMPONENTTYPE **component) {
- return new android::SoftAAC(name, callbacks, appData, component);
-}
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.h b/media/libstagefright/codecs/aacdec/SoftAAC.h
deleted file mode 100644
index 2e75005..0000000
--- a/media/libstagefright/codecs/aacdec/SoftAAC.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SOFT_AAC_H_
-
-#define SOFT_AAC_H_
-
-#include "SimpleSoftOMXComponent.h"
-
-struct tPVMP4AudioDecoderExternal;
-
-namespace android {
-
-struct SoftAAC : public SimpleSoftOMXComponent {
- SoftAAC(const char *name,
- const OMX_CALLBACKTYPE *callbacks,
- OMX_PTR appData,
- OMX_COMPONENTTYPE **component);
-
-protected:
- virtual ~SoftAAC();
-
- virtual OMX_ERRORTYPE internalGetParameter(
- OMX_INDEXTYPE index, OMX_PTR params);
-
- virtual OMX_ERRORTYPE internalSetParameter(
- OMX_INDEXTYPE index, const OMX_PTR params);
-
- virtual void onQueueFilled(OMX_U32 portIndex);
- virtual void onPortFlushCompleted(OMX_U32 portIndex);
- virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
-
-private:
- enum {
- kNumInputBuffers = 4,
- kNumOutputBuffers = 4,
- };
-
- tPVMP4AudioDecoderExternal *mConfig;
- bool mIsADTS;
- void *mDecoderBuf;
-
- size_t mInputBufferCount;
- size_t mUpsamplingFactor;
- int64_t mAnchorTimeUs;
- int64_t mNumSamplesOutput;
-
- bool mSignalledError;
-
- enum {
- NONE,
- AWAITING_DISABLED,
- AWAITING_ENABLED
- } mOutputPortSettingsChange;
-
- void initPorts();
- status_t initDecoder();
- bool isConfigured() const;
-
- DISALLOW_EVIL_CONSTRUCTORS(SoftAAC);
-};
-
-} // namespace android
-
-#endif // SOFT_AAC_H_
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index ff95f9f..d88813e 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -15,6 +15,7 @@
*/
#define LOG_TAG "SoftAAC2"
+//#define LOG_NDEBUG 0
#include <utils/Log.h>
#include "SoftAAC2.h"
@@ -26,6 +27,14 @@
#define FILEREAD_MAX_LAYERS 2
+#define DRC_DEFAULT_MOBILE_REF_LEVEL 64 /* 64*-0.25dB = -16 dB below full scale for mobile conf */
+#define DRC_DEFAULT_MOBILE_DRC_CUT 127 /* maximum compression of dynamic range for mobile conf */
+#define MAX_CHANNEL_COUNT 6 /* maximum number of audio channels that can be decoded */
+// names of properties that can be used to override the default DRC settings
+#define PROP_DRC_OVERRIDE_REF_LEVEL "aac_drc_reference_level"
+#define PROP_DRC_OVERRIDE_CUT "aac_drc_cut"
+#define PROP_DRC_OVERRIDE_BOOST "aac_drc_boost"
+
namespace android {
template<class T>
@@ -85,7 +94,7 @@ void SoftAAC2::initPorts() {
def.eDir = OMX_DirOutput;
def.nBufferCountMin = kNumOutputBuffers;
def.nBufferCountActual = def.nBufferCountMin;
- def.nBufferSize = 8192 * 2;
+ def.nBufferSize = 4096 * MAX_CHANNEL_COUNT;
def.bEnabled = OMX_TRUE;
def.bPopulated = OMX_FALSE;
def.eDomain = OMX_PortDomainAudio;
@@ -110,6 +119,35 @@ status_t SoftAAC2::initDecoder() {
}
}
mIsFirst = true;
+
+ // for streams that contain metadata, use the mobile profile DRC settings unless overridden
+ // by platform properties:
+ char value[PROPERTY_VALUE_MAX];
+ // * AAC_DRC_REFERENCE_LEVEL
+ if (property_get(PROP_DRC_OVERRIDE_REF_LEVEL, value, NULL)) {
+ unsigned refLevel = atoi(value);
+ ALOGV("AAC decoder using AAC_DRC_REFERENCE_LEVEL of %d instead of %d",
+ refLevel, DRC_DEFAULT_MOBILE_REF_LEVEL);
+ aacDecoder_SetParam(mAACDecoder, AAC_DRC_REFERENCE_LEVEL, refLevel);
+ } else {
+ aacDecoder_SetParam(mAACDecoder, AAC_DRC_REFERENCE_LEVEL, DRC_DEFAULT_MOBILE_REF_LEVEL);
+ }
+ // * AAC_DRC_ATTENUATION_FACTOR
+ if (property_get(PROP_DRC_OVERRIDE_CUT, value, NULL)) {
+ unsigned cut = atoi(value);
+ ALOGV("AAC decoder using AAC_DRC_ATTENUATION_FACTOR of %d instead of %d",
+ cut, DRC_DEFAULT_MOBILE_DRC_CUT);
+ aacDecoder_SetParam(mAACDecoder, AAC_DRC_ATTENUATION_FACTOR, cut);
+ } else {
+ aacDecoder_SetParam(mAACDecoder, AAC_DRC_ATTENUATION_FACTOR, DRC_DEFAULT_MOBILE_DRC_CUT);
+ }
+ // * AAC_DRC_BOOST_FACTOR (note: no default, using cut)
+ if (property_get(PROP_DRC_OVERRIDE_BOOST, value, NULL)) {
+ unsigned boost = atoi(value);
+ ALOGV("AAC decoder using AAC_DRC_BOOST_FACTOR of %d", boost);
+ aacDecoder_SetParam(mAACDecoder, AAC_DRC_BOOST_FACTOR, boost);
+ }
+
return status;
}
@@ -320,22 +358,39 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
inInfo->mOwnedByUs = false;
notifyEmptyBufferDone(inHeader);
- // flush out the decoder's delayed data by calling DecodeFrame one more time, with
- // the AACDEC_FLUSH flag set
- INT_PCM *outBuffer =
- reinterpret_cast<INT_PCM *>(outHeader->pBuffer + outHeader->nOffset);
- AAC_DECODER_ERROR decoderErr = aacDecoder_DecodeFrame(mAACDecoder,
- outBuffer,
- outHeader->nAllocLen,
- AACDEC_FLUSH);
- if (decoderErr != AAC_DEC_OK) {
- mSignalledError = true;
- notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL);
- return;
+ if (!mIsFirst) {
+ // flush out the decoder's delayed data by calling DecodeFrame
+ // one more time, with the AACDEC_FLUSH flag set
+ INT_PCM *outBuffer =
+ reinterpret_cast<INT_PCM *>(
+ outHeader->pBuffer + outHeader->nOffset);
+
+ AAC_DECODER_ERROR decoderErr =
+ aacDecoder_DecodeFrame(mAACDecoder,
+ outBuffer,
+ outHeader->nAllocLen,
+ AACDEC_FLUSH);
+
+ if (decoderErr != AAC_DEC_OK) {
+ mSignalledError = true;
+
+ notify(OMX_EventError, OMX_ErrorUndefined, decoderErr,
+ NULL);
+
+ return;
+ }
+
+ outHeader->nFilledLen =
+ mStreamInfo->frameSize
+ * sizeof(int16_t)
+ * mStreamInfo->numChannels;
+ } else {
+ // Since we never discarded frames from the start, we won't have
+ // to add any padding at the end either.
+
+ outHeader->nFilledLen = 0;
}
- outHeader->nFilledLen =
- mStreamInfo->frameSize * sizeof(int16_t) * mStreamInfo->numChannels;
outHeader->nFlags = OMX_BUFFERFLAG_EOS;
outQueue.erase(outQueue.begin());
@@ -404,7 +459,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
}
// Fill and decode
- INT_PCM *outBuffer = reinterpret_cast<INT_PCM *>(outHeader->pBuffer + outHeader->nOffset);
+ INT_PCM *outBuffer = reinterpret_cast<INT_PCM *>(
+ outHeader->pBuffer + outHeader->nOffset);
+
bytesValid[0] = inBufferLength[0];
int prevSampleRate = mStreamInfo->sampleRate;
@@ -493,7 +550,8 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
// (decode failed) we'll output a silent frame.
if (mIsFirst) {
mIsFirst = false;
- // the first decoded frame should be discarded to account for decoder delay
+ // the first decoded frame should be discarded to account
+ // for decoder delay
numOutBytes = 0;
}
diff --git a/media/libstagefright/codecs/aacdec/aac_mem_funcs.h b/media/libstagefright/codecs/aacdec/aac_mem_funcs.h
deleted file mode 100644
index ce7cb12..0000000
--- a/media/libstagefright/codecs/aacdec/aac_mem_funcs.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: aac_mem_funcs.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-
-#include <string.h>
-
-#ifndef AAC_MEM_FUNCS_H
-#define AAC_MEM_FUNCS_H
-
-#define pv_memset(to, c, n) memset(to, c, n)
-
-
-#define pv_memcpy(to, from, n) memcpy(to, from, n)
-#define pv_memmove(to, from, n) memmove(to, from, n)
-#define pv_memcmp(p, q, n) memcmp(p, q, n)
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp b/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp
deleted file mode 100644
index 2786dcc..0000000
--- a/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: analysis_sub_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 vec[], Input vector, 32-bit
- const Int32 *cosTerms, Cosine Terms
- Int maxbands number of bands used
- Int32 *scratch_mem Scratch memory
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "analysis_sub_band.h"
-#include "dst32.h"
-#include "idct32.h"
-#include "mdst.h"
-
-#include "aac_mem_funcs.h"
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-#ifdef HQ_SBR
-
-
-const Int32 exp_1_5_phi[32] =
-{
-
- 0x7FEA04B6, 0x7F380E1C, 0x7DD6176E, 0x7BC6209F,
- 0x790A29A4, 0x75A6326E, 0x719E3AF3, 0x6CF94326,
- 0x67BD4AFB, 0x61F15269, 0x5B9D5964, 0x54CA5FE4,
- 0x4D8165DE, 0x45CD6B4B, 0x3DB87023, 0x354E7460,
- 0x2C9977FB, 0x23A77AEF, 0x1A837D3A, 0x113A7ED6,
- 0x07D97FC2, 0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60,
- 0xE26D7C89, 0xD9587A06, 0xD07976D9, 0xC7DB7308,
- 0xBF8C6E97, 0xB796698C, 0xB00563EF, 0xA8E25DC8,
-
-};
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void analysis_sub_band_LC(Int32 vec[64],
- Int32 cosine_total[],
- Int32 maxBand,
- Int32 scratch_mem[][64])
-{
- Int32 i;
- Int32 *cosine_term = &scratch_mem[0][0];
- Int32 *sine_term = &scratch_mem[0][32];
-
- Int32 *pt_cos_t;
-
-
- Int32 *pt_vec = &vec[0];
- Int32 *pt_vec_32 = &vec[32];
-
- Int32 *pt_cos = cosine_term;
- Int32 *pt_sin = sine_term;
-
- for (i = 8; i != 0; i--)
- {
- Int32 tmp1 = *(pt_vec_32++);
- Int32 tmp3 = *(pt_vec_32++);
- Int32 tmp2 = *(pt_vec++);
- Int32 tmp4 = *(pt_vec++);
- *(pt_cos++) = (tmp1 - tmp2) >> 1;
- *(pt_cos++) = (tmp3 - tmp4) >> 1;
- *(pt_sin++) = (tmp1 + tmp2);
- *(pt_sin++) = (tmp3 + tmp4);
- tmp1 = *(pt_vec_32++);
- tmp3 = *(pt_vec_32++);
- tmp2 = *(pt_vec++);
- tmp4 = *(pt_vec++);
- *(pt_cos++) = (tmp1 - tmp2) >> 1;
- *(pt_cos++) = (tmp3 - tmp4) >> 1;
- *(pt_sin++) = (tmp1 + tmp2);
- *(pt_sin++) = (tmp3 + tmp4);
- }
-
-
- idct_32(cosine_term, scratch_mem[1]);
-
- dst_32(sine_term, scratch_mem[1]);
-
- pt_cos = cosine_term;
- pt_sin = sine_term;
-
- pt_cos_t = cosine_total;
-
- for (i = 0; i < maxBand; i += 4)
- {
- *(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++));
- *(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++));
- *(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++));
- *(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++));
- }
-
- pt_cos_t = &cosine_total[maxBand];
-
- for (i = (32 - maxBand); i != 0; i--)
- {
- *(pt_cos_t++) = 0;
- }
-}
-
-
-#ifdef HQ_SBR
-
-
-void analysis_sub_band(Int32 vec[64],
- Int32 cosine_total[],
- Int32 sine_total[],
- Int32 maxBand,
- Int32 scratch_mem[][64])
-{
- Int32 i;
- Int32 *sine_term1 = &scratch_mem[0][0];
- Int32 *sine_term2 = &scratch_mem[0][32];
-
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
-
- const Int32 *pt_exp;
- Int32 exp_1_5;
-
- Int32 *pt_vec = &vec[0];
- Int32 *pt_vec_32 = &vec[32];
-
- Int32 *pt_cos1 = pt_vec;
- Int32 *pt_sin1 = sine_term1;
- Int32 *pt_cos2 = pt_vec_32;
- Int32 *pt_sin2 = sine_term2;
-
-
- pv_memcpy(sine_term1, vec, 64*sizeof(*vec));
-
- mdst_32(sine_term1, scratch_mem[1]);
- mdst_32(sine_term2, scratch_mem[1]);
-
- mdct_32(&vec[ 0]);
- mdct_32(&vec[32]);
-
- pt_cos1 = &vec[ 0];
- pt_cos2 = &vec[32];
-
-
- pt_sin1 = sine_term1;
- pt_sin2 = sine_term2;
-
- pt_vec = cosine_total;
- pt_vec_32 = sine_total;
- pt_exp = exp_1_5_phi;
-
- temp3 = (*(pt_cos1++) - *(pt_sin2++));
- temp4 = (*(pt_sin1++) + *(pt_cos2++));
-
- for (i = 0; i < maxBand; i += 2)
- {
-
- exp_1_5 = *(pt_exp++);
- temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5);
- temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
-
- *(pt_vec++) = shft_lft_1(temp1);
- *(pt_vec_32++) = shft_lft_1(temp2);
-
- temp3 = (*(pt_cos1++) + *(pt_sin2++));
- temp4 = (*(pt_sin1++) - *(pt_cos2++));
-
- exp_1_5 = *(pt_exp++);
- temp1 = cmplx_mul32_by_16(temp3, temp4, exp_1_5);
- temp2 = cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
-
- *(pt_vec++) = shft_lft_1(temp1);
- *(pt_vec_32++) = shft_lft_1(temp2);
-
- temp3 = (*(pt_cos1++) - *(pt_sin2++));
- temp4 = (*(pt_sin1++) + *(pt_cos2++));
- }
-
-
- pt_cos1 = &cosine_total[maxBand]; /* in the chance that maxband is not even */
- pt_sin1 = &sine_total[maxBand];
-
- for (i = (32 - maxBand); i != 0; i--)
- {
- *(pt_cos1++) = 0;
- *(pt_sin1++) = 0;
- }
-
-}
-
-
-#endif
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/analysis_sub_band.h b/media/libstagefright/codecs/aacdec/analysis_sub_band.h
deleted file mode 100644
index 815456c..0000000
--- a/media/libstagefright/codecs/aacdec/analysis_sub_band.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/analysis_sub_band.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef ANALYSIS_SUB_BAND_H
-#define ANALYSIS_SUB_BAND_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- void analysis_sub_band_LC(Int32 vec[64],
- Int32 cosine_total[],
- Int32 maxBand,
- Int32 scratch_mem[][64]);
-
-#ifdef HQ_SBR
-
-
- void analysis_sub_band(Int32 vec[64],
- Int32 cosine_total[],
- Int32 sine_total[],
- Int32 maxBand,
- Int32 scratch_mem[][64]);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ANALYSIS_SUB_BAND_H */
diff --git a/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp b/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp
deleted file mode 100644
index ab36c6a..0000000
--- a/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp
+++ /dev/null
@@ -1,454 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/apply_ms_synt.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated pseudocode to correct capitalized format for the IF
- FOR and WHILE statements.
-
- Description: Delete local variable start_indx, since it is never used.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- pFrameInfo = Pointer to structure that holds information about each group.
- (long block flag, number of windows, scalefactor bands
- per group, etc.)
- [const pFrameInfo * const]
-
- group = Array that contains indexes of the
- first window in the next group.
- [const Int *, length 8]
-
- mask_map = Array that denotes whether M/S stereo is turned on for
- each grouped scalefactor band.
- [const Int *, length MAX_SFB]
-
- codebook_map = Array that denotes which Huffman codebook was used for
- the encoding of each grouped scalefactor band.
- [const Int *, length MAX_SFB]
-
- coefLeft = Array containing the fixed-point spectral coefficients
- for the left channel.
- [Int32 *, length 1024]
-
- coefRight = Array containing the fixed-point spectral coefficients
- for the right channel.
- [Int32 *, length 1024]
-
- q_formatLeft = The Q-format for the left channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAX_SFB]
-
- q_formatRight = The Q-format for the right channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAX_SFB]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coefLeft = Contains the new spectral information.
-
- coefRight = Contains the new spectral information.
-
- q_formatLeft = Q-format may be updated with changed to fixed-point
- data in coefLeft.
-
- q_formatRight = Q-format may be updated with changed to fixed-point
- data in coefRight.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function steps through all of the tools that are applied on a
- scalefactor band basis.
-
- The use of M/S stereo is checked for. For M/S decoding to take
- place, ms_mask_map must be TRUE for that particular SFB, AND the Huffman
- codebook used must be < NOISE_HCB.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.7.1 M/S stereo
- Subpart 4.6.2 ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pCoefRight = coefRight;
- pCoefLeft = coefLeft;
-
- window_start = 0;
- tot_sfb = 0;
-
- coef_per_win = pFrameInfo->coef_per_win[0];
-
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- DO
-
- pBand = pFrameInfo->win_sfb_top[window_start];
-
- partition = *(pGroup);
-
- pGroup = pGroup + 1;
-
- band_start = 0;
-
- wins_in_group = (partition - window_start);
-
- FOR (sfb = sfb_per_win; sfb > 0; sfb--)
-
- band_stop = *(pBand);
-
- pBand = pBand + 1;
-
- codebook = *(pCodebookMap);
-
- pCodebookMap = pCodebookMap + 1;
-
- mask_enabled = *(pMaskMap);
-
- pMaskMap = pMaskMap + 1;
-
- IF (codebook < NOISE_HCB)
- THEN
- IF (mask_enabled != FALSE)
- THEN
- band_length = band_stop - band_start;
-
- CALL
- ms_synt(
- wins_in_group,
- coef_per_win,
- sfb_per_win,
- band_length,
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]),
- &(q_formatLeft[tot_sfb]),
- &(q_formatRight[tot_sfb]) );
-
- MODIFYING
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]),
- &(q_formatLeft[tot_sfb]),
- &(q_formatRight[tot_sfb])
-
- RETURNING
- None
- ENDIF
- ENDIF
- band_start = band_stop;
-
- tot_sfb = tot_sfb + 1;
-
- ENDFOR
-
- pCoefRight = pCoefRight + coef_per_win * wins_in_group;
- pCoefLeft = pCoefLeft + coef_per_win * wins_in_group;
-
- wins_in_group = wins_in_group - 1;
-
- tot_sfb = tot_sfb + sfb_per_win * wins_in_group;
-
- window_start = partition;
-
- WHILE (partition < pFrameInfo->num_win);
-
- return;
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "apply_ms_synt.h"
-#include "e_huffmanconst.h"
-#include "ms_synt.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void apply_ms_synt(
- const FrameInfo * const pFrameInfo,
- const Int group[],
- const Bool mask_map[],
- const Int codebook_map[],
- Int32 coefLeft[],
- Int32 coefRight[],
- Int q_formatLeft[MAXBANDS],
- Int q_formatRight[MAXBANDS])
-
-{
-
- Int32 *pCoefRight;
-
- Int32 *pCoefLeft;
-
- Int tot_sfb;
- Int sfb;
-
- Int band_length;
- Int band_start;
- Int band_stop;
- Int coef_per_win;
-
- Int codebook;
- Int partition;
- Int window_start;
-
- Int sfb_per_win;
- Int wins_in_group;
-
- const Int16 *pBand;
- const Int *pCodebookMap = codebook_map;
- const Int *pGroup = group;
- const Bool *pMaskMap = mask_map;
-
- Bool mask_enabled;
-
- pCoefRight = coefRight;
- pCoefLeft = coefLeft;
-
- window_start = 0;
- tot_sfb = 0;
-
- /*
- * Each window in the frame should have the same number of coef's,
- * so coef_per_win is constant in all the loops
- */
- coef_per_win = pFrameInfo->coef_per_win[0];
-
- /*
- * Because the number of scalefactor bands per window should be
- * constant for each frame, sfb_per_win can be determined outside
- * of the loop.
- *
- * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows
- * sfb_per_win = 49 for long windows
- */
-
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- do
- {
- pBand = pFrameInfo->win_sfb_top[window_start];
-
- /*
- * Partition is equal to the first window in the next group
- *
- * { Group 0 }{ Group 1 }{ Group 2 }{Group 3}
- * [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
- *
- * pGroup[0] = 2
- * pGroup[1] = 5
- * pGroup[2] = 7
- * pGroup[3] = 8
- */
-
- partition = *(pGroup++);
-
- band_start = 0;
-
- wins_in_group = (partition - window_start);
-
- for (sfb = sfb_per_win; sfb > 0; sfb--)
- {
- /* band is offset table, band_stop is last coef in band */
- band_stop = *(pBand++);
-
- codebook = *(pCodebookMap++);
-
- mask_enabled = *(pMaskMap++);
-
- /*
- * When a codebook < NOISE_HCB is found, apply M/S to that
- * scalefactorband.
- *
- * Example... sfb[3] == NOISE_HCB
- *
- * [ Group 1 ]
- * [win 0 ][win 1 ]
- * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7]
- *
- * The for(sfb) steps through the sfb's 0-7 in win 0.
- *
- * Finding sfb[3]'s codebook == NOISE_HCB, the code
- * steps through all the windows in the group (they share
- * the same scalefactors) and replaces that sfb with noise.
- */
-
- if (codebook < NOISE_HCB)
- {
- if (mask_enabled != FALSE)
- {
- band_length = band_stop - band_start;
-
- ms_synt(
- wins_in_group,
- coef_per_win,
- sfb_per_win,
- band_length,
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]),
- &(q_formatLeft[tot_sfb]),
- &(q_formatRight[tot_sfb]));
- }
- }
- band_start = band_stop;
-
- tot_sfb++;
-
- } /* for (sfb) */
-
- /*
- * Increment pCoefRight and pCoefLeft by
- * coef_per_win * the number of windows
- */
-
- pCoefRight += coef_per_win * wins_in_group;
- pCoefLeft += coef_per_win * wins_in_group--;
-
- /*
- * Increase tot_sfb by sfb_per_win times the number of windows minus 1.
- * The minus 1 comes from the fact that tot_sfb is already pointing
- * to the first sfb in the 2nd window of the group.
- */
- tot_sfb += sfb_per_win * wins_in_group;
-
- window_start = partition;
-
- }
- while (partition < pFrameInfo->num_win);
-
- /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */
-
- return;
-
-} /* apply_ms_synt() */
-
-
diff --git a/media/libstagefright/codecs/aacdec/apply_ms_synt.h b/media/libstagefright/codecs/aacdec/apply_ms_synt.h
deleted file mode 100644
index ed7fb7a..0000000
--- a/media/libstagefright/codecs/aacdec/apply_ms_synt.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/apply_ms_synt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for apply_ms_synt().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef APPLY_MS_SYNT_H
-#define APPLY_MS_SYNT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void apply_ms_synt(
- const FrameInfo * const pFrameInfo,
- const Int group[],
- const Bool mask_map[],
- const Int codebook_map[],
- Int32 coefLeft[],
- Int32 coefRight[],
- Int q_formatLeft[MAXBANDS],
- Int q_formatRight[MAXBANDS]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/apply_tns.cpp b/media/libstagefright/codecs/aacdec/apply_tns.cpp
deleted file mode 100644
index 96ecd27..0000000
--- a/media/libstagefright/codecs/aacdec/apply_tns.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: apply_tns.c
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- coef = Array of input coefficients.
- [Int32 *, length 1024]
-
- q_format = Array of q-formats, one per scalefactor band, for the
- entire frame. In the case of tns_inv_filter, only the
- first element is used, since the input to tns_inv_filter
- is all of the same q-format.
- [Int * const, length MAX_SFB]
-
- pFrameInfo = Pointer to structure that holds information about each group.
- (long block flag, number of windows, scalefactor bands
- per group, etc.)
- [const FrameInfo * const]
-
- pTNS_frame_info = pointer to structure containing the details on each
- TNS filter (order, filter coefficients,
- coefficient res., etc.)
- [TNS_frame_info * const]
-
- inverse_flag = TRUE if inverse filter is to be applied.
- FALSE if forward filter is to be applied.
- [Bool]
-
- scratch_Int_buffer = Pointer to scratch memory to store the
- filter's state memory. Used by both
- tns_inv_filter.
- [Int *, length TNS_MAX_ORDER]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coef[] = TNS altered data.
- q_format = q-formats in TNS scalefactor bands may be modified.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function applies either the TNS forward or TNS inverse filter, based
- on inverse_flag being FALSE or TRUE, respectively.
-
- For the TNS forward filter, the data fed into tns_ar_filter is normalized
- all to the same q-format.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- The input, coef, should use all 32-bits, else the scaling by tns_ar_filter
- may eliminate the data.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.8 (Temporal Noise Shaping)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- NO PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tns_frame_info.h"
-#include "s_tnsfilt.h"
-#include "s_frameinfo.h"
-#include "tns_inv_filter.h"
-#include "tns_ar_filter.h"
-#include "apply_tns.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void apply_tns(
- Int32 coef[],
- Int q_format[],
- const FrameInfo * const pFrameInfo,
- TNS_frame_info * const pTNS_frame_info,
- const Bool inverse_flag,
- Int32 scratch_Int_buffer[])
-{
- Int num_tns_bands;
- Int num_TNS_coef;
-
- Int f;
-
- Int tempInt;
- Int tempInt2;
-
- Int sfb_per_win;
- Int sfbWidth;
-
- Int coef_per_win;
- Int min_q;
- Int win;
-
- Int32 *pCoef = coef;
- Int32 *pTempCoef;
-
- Int *pStartQformat = q_format;
-
- Int *pQformat;
- Int32 *pLpcCoef;
-
- Int sfb_offset;
-
- const Int16 *pWinSfbTop;
-
- TNSfilt *pFilt;
-
- coef_per_win = pFrameInfo->coef_per_win[0];
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- win = 0;
-
- pLpcCoef = pTNS_frame_info->lpc_coef;
-
- pFilt = pTNS_frame_info->filt;
-
- do
- {
- for (f = pTNS_frame_info->n_filt[win]; f > 0; f--)
- {
- /* Skip to the next filter if the order is 0 */
- tempInt = pFilt->order;
-
- if (tempInt > 0)
- {
- /*
- * Do not call tns_ar_filter or tns_inv_filter
- * if the difference
- * between start_coef and stop_stop is <= 0.
- *
- */
- num_TNS_coef = (pFilt->stop_coef - pFilt->start_coef);
-
- if (num_TNS_coef > 0)
- {
- if (inverse_flag != FALSE)
- {
- tns_inv_filter(
- &(pCoef[pFilt->start_coef]),
- num_TNS_coef,
- pFilt->direction,
- pLpcCoef,
- pFilt->q_lpc,
- pFilt->order,
- scratch_Int_buffer);
- }
- else
- {
- num_tns_bands = (pFilt->stop_band - pFilt->start_band);
-
- /*
- * pQformat is initialized only once.
- *
- * Here is how TNS is applied on scalefactor bands
- *
- * [0][1][2][3][4][5][6][7][8]
- * | \
- * start_band stop_band
- *
- * In this example, TNS would be applied to 8
- * scalefactor bands, 0-7.
- *
- * pQformat is initially set to &(pStartQformat[8])
- *
- * 1st LOOP
- * Entry: pQformat = &(pStartQformat[8])
- *
- * pQformat is pre-decremented 8 times in the
- * search for min_q
- *
- * Exit: pQformat = &(pStartQformat[0])
- *
- * 2nd LOOP
- * Entry: pQformat = &(pStartQformat[0])
- *
- * pQformat is post-incremented 8 times in the
- * normalization of the data loop.
- *
- * Exit: pQformat = &(pStartQformat[8]
- *
- *
- * shift_amt = tns_ar_filter(...)
- *
- * 3rd LOOP
- * Entry: pQformat = &(pStartQformat[8])
- *
- * pQformat is pre-decremented 8 times in the
- * adjustment of the q-format to min_q - shift_amt
- *
- * Exit: pQformat = &(pStartQformat[0])
- *
- */
-
- pQformat =
- &(pStartQformat[pFilt->stop_band]);
-
- /*
- * Scan the array of q-formats and find the minimum over
- * the range where the filter is to be applied.
- *
- * At the end of this scan,
- * pQformat = &(q-format[pFilt->start_band]);
- *
- */
-
- min_q = INT16_MAX;
-
- for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
- {
- tempInt2 = *(--pQformat);
-
- if (tempInt2 < min_q)
- {
- min_q = tempInt2;
- }
- } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
-
- /*
- * Set up the pointers so we can index into coef[]
- * on a scalefactor band basis.
- */
- tempInt = pFilt->start_band;
-
- tempInt--;
-
- /* Initialize sfb_offset and pWinSfbTop */
- if (tempInt >= 0)
- {
- pWinSfbTop =
- &(pFrameInfo->win_sfb_top[win][tempInt]);
-
- sfb_offset = *(pWinSfbTop++);
- }
- else
- {
- pWinSfbTop = pFrameInfo->win_sfb_top[win];
- sfb_offset = 0;
- }
-
- pTempCoef = pCoef + pFilt->start_coef;
-
- /* Scale the data in the TNS bands to min_q q-format */
- for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
- {
- sfbWidth = *(pWinSfbTop++) - sfb_offset;
-
- sfb_offset += sfbWidth;
-
- tempInt2 = *(pQformat++) - min_q;
-
- /*
- * This should zero out the data in one scalefactor
- * band if it is so much less than the neighboring
- * scalefactor bands.
- *
- * The only way this "should" happen is if one
- * scalefactor band contains zero data.
- *
- * Zero data can be of any q-format, but we always
- * set it very high to avoid the zero-data band being
- * picked as the one to normalize to in the scan for
- * min_q.
- *
- */
- if (tempInt2 > 31)
- {
- tempInt2 = 31;
- }
-
- for (sfbWidth >>= 2; sfbWidth > 0; sfbWidth--)
- {
- *(pTempCoef++) >>= tempInt2;
- *(pTempCoef++) >>= tempInt2;
- *(pTempCoef++) >>= tempInt2;
- *(pTempCoef++) >>= tempInt2;
- }
-
- } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
-
- tempInt2 =
- tns_ar_filter(
- &(pCoef[pFilt->start_coef]),
- num_TNS_coef,
- pFilt->direction,
- pLpcCoef,
- pFilt->q_lpc,
- pFilt->order);
-
- /*
- * Update the q-format for all the scalefactor bands
- * taking into account the adjustment caused by
- * tns_ar_filter
- */
-
- min_q -= tempInt2;
-
- for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
- {
- *(--pQformat) = min_q;
- }
-
- } /* if (inverse_flag != FALSE) */
-
- } /* if (num_TNS_coef > 0) */
-
- pLpcCoef += pFilt->order;
-
- } /* if (tempInt > 0) */
-
- pFilt++;
-
- } /* for (f = pTNSinfo->n_filt; f > 0; f--) */
-
- pCoef += coef_per_win;
- pStartQformat += sfb_per_win;
-
- win++;
-
- }
- while (win < pFrameInfo->num_win);
-
- return;
-
-} /* apply_tns() */
diff --git a/media/libstagefright/codecs/aacdec/apply_tns.h b/media/libstagefright/codecs/aacdec/apply_tns.h
deleted file mode 100644
index 85fb851..0000000
--- a/media/libstagefright/codecs/aacdec/apply_tns.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/apply_tns.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated per review comments.
-
- Description: Changed function prototype to mirror changes made in apply_tns.c
-
- Description: The scratch memory was mistakenly declared here as type "Int32"
- It should have been "Int"
-
- Who: Date:
- Description:
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- apply_tns.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef APPLY_TNS_H
-#define APPLY_TNS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tns_frame_info.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void apply_tns(
- Int32 coef[],
- Int q_format[],
- const FrameInfo * const pFrameInfo,
- TNS_frame_info * const pTNS_frame_info,
- const Bool inverse_flag,
- Int32 scratch_Int_buffer[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/bit_reversal_swap.h b/media/libstagefright/codecs/aacdec/bit_reversal_swap.h
deleted file mode 100644
index 2669f87..0000000
--- a/media/libstagefright/codecs/aacdec/bit_reversal_swap.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./include/bit_reversal_swap.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed definitions from Int to Int32 for Data[]
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function bit_reversal_swap()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BIT_REVERSAL_SWAP_H
-#define BIT_REVERSAL_SWAP_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int Index_64_a[];
-extern const Int Index_64_b[];
-
-extern const Int Index_512_a[];
-extern const Int Index_512_b[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void bit_reversal_swap(
- Int32 Data[],
- const Int *pIndex_a,
- const Int *pIndex_b);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* BIT_REVERSAL_SWAP_H */
diff --git a/media/libstagefright/codecs/aacdec/buf_getbits.cpp b/media/libstagefright/codecs/aacdec/buf_getbits.cpp
deleted file mode 100644
index 34f4f60..0000000
--- a/media/libstagefright/codecs/aacdec/buf_getbits.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: buf_getbits.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: hBitBuf Handle to Bitbuffer
- n Number of bits to read
-
- Return: bits
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads n bits from Bitbuffer
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n)
-{
-
- /* read bits from MSB side */
- if (hBitBuf->buffered_bits <= 16)
- {
- hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
- hBitBuf->buffer_word |= *(hBitBuf->char_ptr++);
- hBitBuf->buffered_bits += 16;
- }
-
- hBitBuf->buffered_bits -= n;
- hBitBuf->nrBitsRead += n;
-
- return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & ((1 << n) - 1));
-
-}
-
-
-UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf)
-{
-
- /* read bits from MSB side */
- if (hBitBuf->buffered_bits <= 16)
- {
- hBitBuf->buffer_word = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
- hBitBuf->buffer_word |= *(hBitBuf->char_ptr++);
- hBitBuf->buffered_bits += 16;
- }
-
- hBitBuf->buffered_bits--;
- hBitBuf->nrBitsRead++;
-
- return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & 1);
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/buf_getbits.h b/media/libstagefright/codecs/aacdec/buf_getbits.h
deleted file mode 100644
index 1b5d252..0000000
--- a/media/libstagefright/codecs/aacdec/buf_getbits.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: buf_getbits.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BUF_GETBITS_H
-#define BUF_GETBITS_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bit_buffer.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n);
-
- UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/buffer_normalization.h b/media/libstagefright/codecs/aacdec/buffer_normalization.h
deleted file mode 100644
index 031216a..0000000
--- a/media/libstagefright/codecs/aacdec/buffer_normalization.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/buffer_normalization.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed definitions from Int to Int32 for IO_buffer[]
-
- Description: Added copyrigth notice, added 'const' definitions to function
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function buffer_normalization()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BUFFER_NORMALIZATION_H
-#define BUFFER_NORMALIZATION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define ALL_ZEROS_BUFFER -100
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void buffer_normalization(
- Int q_format,
- Int32 IO_buffer[],
- const Int buffer_size,
- Int * const pExp);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* BUFFER_NORMALIZATION_H */
diff --git a/media/libstagefright/codecs/aacdec/byte_align.cpp b/media/libstagefright/codecs/aacdec/byte_align.cpp
deleted file mode 100644
index e75c79e..0000000
--- a/media/libstagefright/codecs/aacdec/byte_align.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to a BITS structure that holds information
- regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pInputStream->usedBits is rounded up to a number that represents the next
- byte boundary.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Makes the input stream structure pointed to align to the next byte boundary.
- If it is already at a byte boundary it is left alone.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-void byte_align(
- BITS *pInputStream)
-
- MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
- (pInputStream->usedBits + 7) % 8)
-
- RETURN(nothing)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- STACK USAGE:
-
- where:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*
- * A negative number was used for this mask so that it works on both
- * 16-bit or 32-bit machines. The mask must be cast to unsigned int to
- * work with TI compiler, ver 1.80.
- */
-#define BYTE_ALIGN_MASK ((UInt)(-8))
-
-#define BYTE_ALIGN_ROUNDUP 7
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void byte_align(
- BITS *pInputStream)
-{
- /*
- * Round up to the next byte by adding 7 and masking off with
- * FFF8 or FFFFFFF8. The masking operation is a faster way to
- * perform modulo arithmetic if the number is a power of 2.
- *
- * This code is the same as
- * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8
- */
- pInputStream->usedBits += BYTE_ALIGN_ROUNDUP;
- pInputStream->usedBits &= BYTE_ALIGN_MASK;
-
- return;
-}
-
diff --git a/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp b/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp
deleted file mode 100644
index ee32398..0000000
--- a/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp
+++ /dev/null
@@ -1,416 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_auto_corr.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include "calc_auto_corr.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#include "fxp_mul32.h"
-#include "pv_normalize.h"
-
-#define N 2
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void calc_auto_corr_LC(struct ACORR_COEFS *ac,
- Int32 realBuf[][32],
- Int32 bd,
- Int32 len)
-{
- Int32 j;
- Int32 temp1;
- Int32 temp3;
- Int32 temp5;
-
- int64_t temp_r01r;
- int64_t temp_r02r;
- int64_t temp_r11r;
- int64_t temp_r12r;
- int64_t temp_r22r;
- int64_t max = 0;
-
-
- temp1 = (realBuf[ 0][bd]) >> N;
- temp3 = (realBuf[-1][bd]) >> N;
- temp5 = (realBuf[-2][bd]) >> N;
-
-
- temp_r11r = fxp_mac64_Q31(0, temp3, temp3); /* [j-1]*[j-1] */
- temp_r12r = fxp_mac64_Q31(0, temp3, temp5); /* [j-1]*[j-2] */
- temp_r22r = fxp_mac64_Q31(0, temp5, temp5); /* [j-2]*[j-2] */
-
- temp_r01r = 0;
- temp_r02r = 0;
-
- for (j = 1; j < len; j++)
- {
- temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3); /* [j ]*[j-1] */
- temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5); /* [j ]*[j-2] */
- temp_r11r = fxp_mac64_Q31(temp_r11r, temp1, temp1); /* [j-1]*[j-1] */
-
- temp5 = temp3;
- temp3 = temp1;
- temp1 = (realBuf[j][bd]) >> N;
- }
-
-
- temp_r22r += temp_r11r;
- temp_r12r += temp_r01r; /* [j-1]*[j-2] */
-
- temp_r22r = fxp_mac64_Q31(temp_r22r, -temp3, temp3);
-
- temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3);
- temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5);
-
- max |= temp_r01r ^(temp_r01r >> 63);
- max |= temp_r02r ^(temp_r02r >> 63);
- max |= temp_r11r;
- max |= temp_r12r ^(temp_r12r >> 63);
- max |= temp_r22r;
-
- if (max)
- {
- temp1 = (UInt32)(max >> 32);
- if (temp1)
- {
- temp3 = 33 - pv_normalize(temp1);
- ac->r01r = (Int32)(temp_r01r >> temp3);
- ac->r02r = (Int32)(temp_r02r >> temp3);
- ac->r11r = (Int32)(temp_r11r >> temp3);
- ac->r12r = (Int32)(temp_r12r >> temp3);
- ac->r22r = (Int32)(temp_r22r >> temp3);
-
- }
- else
- {
- temp3 = pv_normalize(((UInt32)max) >> 1) - 2;
-
- if (temp3 > 0)
- {
- ac->r01r = (Int32)(temp_r01r << temp3);
- ac->r02r = (Int32)(temp_r02r << temp3);
- ac->r11r = (Int32)(temp_r11r << temp3);
- ac->r12r = (Int32)(temp_r12r << temp3);
- ac->r22r = (Int32)(temp_r22r << temp3);
- }
- else
- {
- temp3 = -temp3;
- ac->r01r = (Int32)(temp_r01r >> temp3);
- ac->r02r = (Int32)(temp_r02r >> temp3);
- ac->r11r = (Int32)(temp_r11r >> temp3);
- ac->r12r = (Int32)(temp_r12r >> temp3);
- ac->r22r = (Int32)(temp_r22r >> temp3);
- }
-
- }
-
- /*
- * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
- */
- /* 1/(1 + 1e-6) == 1 - 1e-6 */
- /* 2^-20 == 1e-6 */
- ac->det = fxp_mul32_Q30(ac->r12r, ac->r12r);
-
- ac->det -= ac->det >> 20;
-
- ac->det = fxp_mul32_Q30(ac->r11r, ac->r22r) - ac->det;
- }
- else
- {
- pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
- }
-
-
-}
-
-
-#ifdef HQ_SBR
-
-
-void calc_auto_corr(struct ACORR_COEFS *ac,
- Int32 realBuf[][32],
- Int32 imagBuf[][32],
- Int32 bd,
- Int32 len)
-{
-
-
- Int32 j;
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 temp5;
- Int32 temp6;
-
- int64_t accu1 = 0;
- int64_t accu2 = 0;
- int64_t accu3 = 0;
- int64_t accu4 = 0;
- int64_t accu5 = 0;
-
-
- int64_t temp_r12r;
- int64_t temp_r12i;
- int64_t temp_r22r;
- int64_t max = 0;
-
-
- temp1 = realBuf[0 ][bd] >> N;
- temp2 = imagBuf[0 ][bd] >> N;
- temp3 = realBuf[0-1][bd] >> N;
- temp4 = imagBuf[0-1][bd] >> N;
- temp5 = realBuf[0-2][bd] >> N;
- temp6 = imagBuf[0-2][bd] >> N;
-
- temp_r22r = fxp_mac64_Q31(0, temp5, temp5);
- temp_r22r = fxp_mac64_Q31(temp_r22r, temp6, temp6);
- temp_r12r = fxp_mac64_Q31(0, temp3, temp5);
- temp_r12r = fxp_mac64_Q31(temp_r12r, temp4, temp6);
- temp_r12i = -fxp_mac64_Q31(0, temp3, temp6);
- temp_r12i = fxp_mac64_Q31(temp_r12i, temp4, temp5);
-
- for (j = 1; j < len; j++)
- {
- accu1 = fxp_mac64_Q31(accu1, temp3, temp3);
- accu1 = fxp_mac64_Q31(accu1, temp4, temp4);
- accu2 = fxp_mac64_Q31(accu2, temp1, temp3);
- accu2 = fxp_mac64_Q31(accu2, temp2, temp4);
- accu3 = fxp_mac64_Q31(accu3, temp2, temp3);
- accu3 = fxp_mac64_Q31(accu3, -temp1, temp4);
- accu4 = fxp_mac64_Q31(accu4, temp1, temp5);
- accu4 = fxp_mac64_Q31(accu4, temp2, temp6);
- accu5 = fxp_mac64_Q31(accu5, temp2, temp5);
- accu5 = fxp_mac64_Q31(accu5, -temp1, temp6);
-
- temp5 = temp3;
- temp6 = temp4;
- temp3 = temp1;
- temp4 = temp2;
- temp1 = realBuf[j][bd] >> N;
- temp2 = imagBuf[j][bd] >> N;
- }
-
-
- temp_r22r += accu1;
- temp_r12r += accu2;
- temp_r12i += accu3;
-
-
- accu1 = fxp_mac64_Q31(accu1, temp3, temp3);
- accu1 = fxp_mac64_Q31(accu1, temp4, temp4);
- accu2 = fxp_mac64_Q31(accu2, temp1, temp3);
- accu2 = fxp_mac64_Q31(accu2, temp2, temp4);
- accu3 = fxp_mac64_Q31(accu3, temp2, temp3);
- accu3 = fxp_mac64_Q31(accu3, -temp1, temp4);
- accu4 = fxp_mac64_Q31(accu4, temp1, temp5);
- accu4 = fxp_mac64_Q31(accu4, temp2, temp6);
- accu5 = fxp_mac64_Q31(accu5, temp2, temp5);
- accu5 = fxp_mac64_Q31(accu5, -temp1, temp6);
-
-
- max |= accu5 ^(accu5 >> 63);
- max |= accu4 ^(accu4 >> 63);
- max |= accu3 ^(accu3 >> 63);
- max |= accu2 ^(accu2 >> 63);
- max |= accu1;
- max |= temp_r12r ^(temp_r12r >> 63);
- max |= temp_r12i ^(temp_r12i >> 63);
- max |= temp_r22r;
-
- if (max)
- {
-
- temp1 = (UInt32)(max >> 32);
- if (temp1)
- {
- temp1 = 34 - pv_normalize(temp1);
- ac->r11r = (Int32)(accu1 >> temp1);
- ac->r01r = (Int32)(accu2 >> temp1);
- ac->r01i = (Int32)(accu3 >> temp1);
- ac->r02r = (Int32)(accu4 >> temp1);
- ac->r02i = (Int32)(accu5 >> temp1);
- ac->r12r = (Int32)(temp_r12r >> temp1);
- ac->r12i = (Int32)(temp_r12i >> temp1);
- ac->r22r = (Int32)(temp_r22r >> temp1);
- }
- else
- {
- temp1 = pv_normalize(((UInt32)max) >> 1) - 3;
-
- if (temp1 > 0)
- {
- ac->r11r = (Int32)(accu1 << temp1);
- ac->r01r = (Int32)(accu2 << temp1);
- ac->r01i = (Int32)(accu3 << temp1);
- ac->r02r = (Int32)(accu4 << temp1);
- ac->r02i = (Int32)(accu5 << temp1);
- ac->r12r = (Int32)(temp_r12r << temp1);
- ac->r12i = (Int32)(temp_r12i << temp1);
- ac->r22r = (Int32)(temp_r22r << temp1);
- }
- else
- {
- temp1 = -temp1;
- ac->r11r = (Int32)(accu1 >> temp1);
- ac->r01r = (Int32)(accu2 >> temp1);
- ac->r01i = (Int32)(accu3 >> temp1);
- ac->r02r = (Int32)(accu4 >> temp1);
- ac->r02i = (Int32)(accu5 >> temp1);
- ac->r12r = (Int32)(temp_r12r >> temp1);
- ac->r12i = (Int32)(temp_r12i >> temp1);
- ac->r22r = (Int32)(temp_r22r >> temp1);
- }
-
- }
-
- /*
- * ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
- */
- /* 1/(1 + 1e-6) == 1 - 1e-6 */
- /* 2^-20 == 1e-6 */
-
- ac->det = fxp_mul32_Q29(ac->r12i, ac->r12i);
- ac->det = fxp_mac32_Q29(ac->r12r, ac->r12r, ac->det);
-
- ac->det -= ac->det >> 20;
-
- ac->det = -fxp_msu32_Q29(ac->r11r, ac->r22r, ac->det);
-
- }
- else
- {
- pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
- }
-
-}
-
-#endif
-
-
-
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_auto_corr.h b/media/libstagefright/codecs/aacdec/calc_auto_corr.h
deleted file mode 100644
index 0f0dae2..0000000
--- a/media/libstagefright/codecs/aacdec/calc_auto_corr.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_auto_corr.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_AUTO_CORR_H
-#define CALC_AUTO_CORR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-struct ACORR_COEFS
-{
- Int32 r11r;
- Int32 r01r;
- Int32 r02r;
- Int32 r12r;
- Int32 r22r;
-#ifdef HQ_SBR
- Int32 r01i;
- Int32 r02i;
- Int32 r12i;
-#endif
- Int32 det;
-};
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void calc_auto_corr_LC(struct ACORR_COEFS *ac,
- Int32 realBuf[][32],
- Int32 bd,
- Int32 len);
-
-
-#ifdef HQ_SBR
-
- void calc_auto_corr(struct ACORR_COEFS *ac,
- Int32 realBuf[][32],
- Int32 imagBuf[][32],
- Int32 bd,
- Int32 len);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp b/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp
deleted file mode 100644
index 4047502..0000000
--- a/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/calc_gsfb_table.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: (1) Modified to bring in-line with PV standards
- (2) Removed if(pFrameInfo->islong), only short windows will
- call this routine from getics.c
-
- Description: Modified per review comments
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pFrameInfo = pointer to structure that holds information for current
- frame. Data type FrameInfo
-
- group[] = array that contains the grouping information of short
- windows (stop index of windows in each group).
- Data type Int
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pFrameInfo -> frame_sfb_top contains the cumulative bandwidth of
- scalefactor bands in each group
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function is only invoked when short windows are present. It calculates
- the number of groups in one frame, and the scalefactor bandwidth of each
- scalefactor band in each group.
- All windows within one group share the same scalefactors and are interleaved
- on a scalefactor band basis. Within each group, the actual length of one
- scalefactor band equals to the number of windows times the number of
- coefficients in a regular scalefactor band.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall replace the contents of pFrameInfo->frame_sfb_top
- with the cumulative bandwidth of each scalefactor band in each group
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p54. 4.5.2.3.2 decoding process
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- offset = 0;
- group_idx = 0;
-
- DO
- pFrameInfo->group_len[group_idx] = group[group_idx] - offset;
- offset = group[group_idx];
- group_idx++;
-
- WHILE (offset < NUM_SHORT_WINDOWS);
-
-
- pFrameInfo->num_groups = group_idx;
-
- pFrameSfbTop = pFrameInfo->frame_sfb_top;
- offset = 0;
-
- FOR (group_idx = 0; group_idx < pFrameInfo->num_groups; group_idx++)
-
- len = pFrameInfo->group_len[group_idx];
-
- FOR (sfb = 0; sfb < pFrameInfo->sfb_per_win[group_idx]; sfb++)
-
- offset += pFrameInfo->sfb_width_128[sfb] * len;
- *pFrameSfbTop++ = offset;
-
- ENDFOR
-
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void calc_gsfb_table(
- FrameInfo *pFrameInfo,
- Int group[])
-{
-
- Int group_idx;
- Int offset;
- Int *pFrameSfbTop;
- Int *pSfbWidth128;
- Int sfb;
- Int nsfb;
- Int len;
- Int ngroups;
-
- /* clear out the default values set by infoinit */
- /* */
- pv_memset(pFrameInfo->frame_sfb_top,
- 0,
- MAXBANDS*sizeof(pFrameInfo->frame_sfb_top[0]));
- /* */
- /* first calculate the group length*/
- offset = 0;
- ngroups = 0;
- do
- {
- pFrameInfo->group_len[ngroups] = group[ngroups] - offset;
- offset = group[ngroups];
- ngroups++;
-
- }
- while (offset < NUM_SHORT_WINDOWS);
-
-
- /* calculate the cumulative scalefactor bandwidth for one frame */
- pFrameInfo->num_groups = ngroups;
-
- pFrameSfbTop = pFrameInfo->frame_sfb_top;
- offset = 0;
-
-
- for (group_idx = 0; group_idx < ngroups; group_idx++)
- {
- len = pFrameInfo->group_len[ group_idx];
- nsfb = pFrameInfo->sfb_per_win[group_idx];
-
- pSfbWidth128 = pFrameInfo->sfb_width_128;
-
- for (sfb = nsfb; sfb > 0; sfb--)
- {
- offset += *pSfbWidth128++ * len;
- *pFrameSfbTop++ = offset;
- }
- }
-
-
-} /* calc_gsfb_table */
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp
deleted file mode 100644
index 5ec3f69..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp
+++ /dev/null
@@ -1,360 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_anafilterbank.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "calc_sbr_anafilterbank.h"
-#include "qmf_filterbank_coeff.h"
-#include "analysis_sub_band.h"
-
-#include "aac_mem_funcs.h"
-#include "fxp_mul32.h"
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_anafilterbank_LC(Int32 * Sr,
- Int16 * X,
- Int32 scratch_mem[][64],
- Int32 maxBand)
-{
-
- Int i;
- Int32 *p_Y_1;
- Int32 *p_Y_2;
-
- Int16 * pt_X_1;
- Int16 * pt_X_2;
- Int32 realAccu1;
- Int32 realAccu2;
-
- Int32 tmp1;
- Int32 tmp2;
-
-
- const Int32 * pt_C;
-
- p_Y_1 = scratch_mem[0];
-
-
- p_Y_2 = p_Y_1 + 63;
- pt_C = &sbrDecoderFilterbankCoefficients_an_filt_LC[0];
-
- pt_X_1 = X;
-
-
- realAccu1 = fxp_mul32_by_16(Qfmt27(-0.51075594183097F), pt_X_1[-192]);
-
- realAccu1 = fxp_mac32_by_16(Qfmt27(-0.51075594183097F), -pt_X_1[-128], realAccu1);
- realAccu1 = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), pt_X_1[-256], realAccu1);
- *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.01876919066980F), -pt_X_1[ -64], realAccu1);
-
-
- /* create array Y */
-
- pt_X_1 = &X[-1];
- pt_X_2 = &X[-319];
-
-
- for (i = 15; i != 0; i--)
- {
- tmp1 = *(pt_X_1--);
- tmp2 = *(pt_X_2++);
-
- realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
- realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
- tmp1 = pt_X_1[ -63];
- tmp2 = pt_X_2[ +63];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -127];
- tmp2 = pt_X_2[ +127];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -191];
- tmp2 = pt_X_2[ +191];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -255];
- tmp2 = pt_X_2[ +255];
- *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
- tmp1 = *(pt_X_1--);
- tmp2 = *(pt_X_2++);
- realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
- realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
-
- tmp1 = pt_X_1[ -63];
- tmp2 = pt_X_2[ +63];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -127];
- tmp2 = pt_X_2[ +127];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -191];
- tmp2 = pt_X_2[ +191];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -255];
- tmp2 = pt_X_2[ +255];
- *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
- }
-
-
- tmp1 = *(pt_X_1--);
- tmp2 = *(pt_X_2++);
- realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
- realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
-
- tmp1 = pt_X_1[ -63];
- tmp2 = pt_X_2[ +63];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -127];
- tmp2 = pt_X_2[ +127];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -191];
- tmp2 = pt_X_2[ +191];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -255];
- tmp2 = pt_X_2[ +255];
- *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
-
- pt_X_1 = X;
-
- realAccu2 = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]);
-
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.00370548843500F), pt_X_1[-288], realAccu2);
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[ -96], realAccu2);
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[-224], realAccu2);
- *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), pt_X_1[-160], realAccu2);
-
-
- analysis_sub_band_LC(scratch_mem[0],
- Sr,
- maxBand,
- (Int32(*)[64])scratch_mem[1]);
-
-}
-
-
-
-#ifdef HQ_SBR
-
-void calc_sbr_anafilterbank(Int32 * Sr,
- Int32 * Si,
- Int16 * X,
- Int32 scratch_mem[][64],
- Int32 maxBand)
-{
- Int i;
- Int32 *p_Y_1;
- Int32 *p_Y_2;
-
-
-
-
- const Int32 * pt_C;
- Int16 * pt_X_1;
- Int16 * pt_X_2;
- Int32 realAccu1;
- Int32 realAccu2;
-
- Int32 tmp1;
- Int32 tmp2;
-
-
- p_Y_1 = scratch_mem[0];
-
-
- p_Y_2 = p_Y_1 + 63;
- pt_C = &sbrDecoderFilterbankCoefficients_an_filt[0];
-
- realAccu1 = fxp_mul32_by_16(Qfmt27(-0.36115899F), X[-192]);
-
-
- realAccu1 = fxp_mac32_by_16(Qfmt27(-0.36115899F), -X[-128], realAccu1);
- realAccu1 = fxp_mac32_by_16(Qfmt27(-0.013271822F), X[-256], realAccu1);
- *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(-0.013271822F), -X[ -64], realAccu1);
-
- /* create array Y */
-
- pt_X_1 = &X[-1];
- pt_X_2 = &X[-319];
-
-
- for (i = 31; i != 0; i--)
- {
- tmp1 = *(pt_X_1--);
- tmp2 = *(pt_X_2++);
- realAccu1 = fxp_mul32_by_16(*(pt_C), tmp1);
- realAccu2 = fxp_mul32_by_16(*(pt_C++), tmp2);
- tmp1 = pt_X_1[ -63];
- tmp2 = pt_X_2[ 63];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -127];
- tmp2 = pt_X_2[ 127];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -191];
- tmp2 = pt_X_2[ 191];
- realAccu1 = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- realAccu2 = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- tmp1 = pt_X_1[ -255];
- tmp2 = pt_X_2[ 255];
- *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
- *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
- }
-
-
- realAccu2 = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]);
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2);
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2);
- realAccu2 = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2);
-
-
- *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2);
-
-
- analysis_sub_band(scratch_mem[0],
- Sr,
- Si,
- maxBand,
- (Int32(*)[64])scratch_mem[1]);
-
-}
-
-
-#endif
-
-
-
-#endif /* AAC_PLUS */
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h b/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h
deleted file mode 100644
index c93848e..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_anafilterbank.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_SBR_ANAFILTERBANK_H
-#define CALC_SBR_ANAFILTERBANK_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
-#define ROUND_ANAFIL 0
-//#define ROUND_ANAFIL 0
-#define ROUND_ANAFIL_LC (0)
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-
- void calc_sbr_anafilterbank_LC(Int32 * Sr,
- Int16 * X,
- Int32 scratch_mem[][64],
- Int32 maxBand);
-
-
-#ifdef HQ_SBR
-
- void calc_sbr_anafilterbank(Int32 * Sr,
- Int32 * Si,
- Int16 * X,
- Int32 scratch_mem[][64],
- Int32 maxBand);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* CALC_SBR_ANAFILTERBANK_H */
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp
deleted file mode 100644
index 4fb3535..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp
+++ /dev/null
@@ -1,2203 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: calc_sbr_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "calc_sbr_envelope.h"
-#include "sbr_envelope_calc_tbl.h"
-#include "sbr_create_limiter_bands.h"
-#include "aac_mem_funcs.h"
-
-#include "fxp_mul32.h"
-#include "pv_normalize.h"
-
-#include "sbr_aliasing_reduction.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#include "pv_sqrt.h"
-
-#include "pv_div.h"
-#include "fxp_mul32.h"
-#include "pv_normalize.h"
-
-#define Q30fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F))
-#define Q15fmt(x) (Int32)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void envelope_application_LC(Int32 *aBufR,
- Int32 *nrg_gain_man,
- Int32 *nrg_gain_exp,
- Int32 *noise_level_man,
- Int32 *noise_level_exp,
- Int32 *nrg_tone_man,
- Int32 *nrg_tone_exp,
- Int32 band_nrg_tone_detector,
- const Int32 *frame_info,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 i,
- Int32 lowSubband,
- Int32 noSubbands,
- Int32 noNoiseFlag);
-
-
- void energy_estimation_LC(Int32 *aBufR,
- Int32 *nrg_est_man,
- Int32 *nrg_est_exp,
- const Int32 *frame_info,
- Int32 i,
- Int32 k,
- Int32 c,
- Int32 ui2);
-
-#ifdef HQ_SBR
-
-
- void envelope_application(Int32 *aBufR,
- Int32 *aBufI,
- Int32 *nrg_gain_man,
- Int32 *nrg_gain_exp,
- Int32 *noise_level_man,
- Int32 *noise_level_exp,
- Int32 *nrg_tone_man,
- Int32 *nrg_tone_exp,
- Int32 *fBuf_man[64],
- Int32 *fBuf_exp[64],
- Int32 *fBufN_man[64],
- Int32 *fBufN_exp[64],
- const Int32 *frame_info,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 i,
- Int32 lowSubband,
- Int32 noSubbands,
- Int32 noNoiseFlag,
- Int32 band_nrg_tone_detector,
- Int32 maxSmoothLength,
- Int32 smooth_length);
-
-
- void energy_estimation(Int32 *aBufR,
- Int32 *aBufI,
- Int32 *nrg_est_man,
- Int32 *nrg_est_exp,
- const Int32 *frame_info,
- Int32 i,
- Int32 k,
- Int32 c,
- Int32 ui2);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_envelope(SBR_FRAME_DATA *frameData,
- Int32 *aBufR,
- Int32 *aBufI,
- Int freqBandTable1[2][MAX_FREQ_COEFFS + 1],
- const Int32 *nSfb,
- Int32 freqBandTable2[MAX_NOISE_COEFFS + 1],
- Int32 nNBands,
- Int32 reset,
- Int32 *degreeAlias,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 hFp[64],
- Int32 *sUp,
- Int32 limSbc[][13],
- Int32 *gateMode,
-#ifdef HQ_SBR
- Int32 *fBuf_man[64],
- Int32 *fBuf_exp[64],
- Int32 *fBufN_man[64],
- Int32 *fBufN_exp[64],
-#endif
- Int32 scratch_mem[][64],
- struct PATCH Patch,
- Int32 sqrt_cache[][4],
- Int32 LC_flag)
-{
-
- Int32 c;
- Int32 li;
- Int32 ui;
- Int32 i;
- Int32 j;
- Int32 k = 0;
- Int32 l;
- Int m = 0;
- Int kk = 0;
- Int o;
- Int next = -1;
- Int32 ui2;
- Int flag;
- Int noNoiseFlag;
- Int *ptr;
-
-
- UInt32 nrg = 0;
- Int32 nrg_exp = 0;
- struct intg_div quotient;
- struct intg_sqrt root_sq;
-
- Int32 aux1;
-
- Int32 *nL_man = frameData->sbrNoiseFloorLevel_man;
- Int32 *nL_exp = frameData->sbrNoiseFloorLevel_exp;
-
- Int32 *sfb_nrg_man = frameData->iEnvelope_man;
- Int32 *sfb_nrg_exp = frameData->iEnvelope_exp;
-
- Int32 tmp_q1;
- Int32 tmp_q2;
-
- Int32 g_max_man;
- Int32 g_max_exp;
-
- Int32 p_ref_man;
- Int32 p_ref_exp;
-
- Int32 p_est_man;
- Int32 p_est_exp;
-
- Int32 p_adj_man;
- Int32 p_adj_exp;
- Int32 avg_gain;
-
- Int32 boost_gain_q;
-
- Int32 band_nrg_tone_detector;
-
- Int32 *nrg_est_man = scratch_mem[0];
- Int32 *nrg_est_exp = scratch_mem[1];
- Int32 *nrg_ref_man = scratch_mem[2];
- Int32 *nrg_ref_exp = scratch_mem[3];
- Int32 *nrg_gain_man = scratch_mem[4];
- Int32 *nrg_gain_exp = scratch_mem[5];
- Int32 *noise_level_man = scratch_mem[6];
- Int32 *noise_level_exp = scratch_mem[7];
- Int32 *nrg_tone_man = scratch_mem[8];
- Int32 *nrg_tone_exp = scratch_mem[9];
- Int32 *hF = scratch_mem[10];
-
-
-
- const Int32 *frame_info = frameData->frameInfo;
- Int32 int_mode = frameData->sbr_header.interpolFreq;
-
-
-
-
-
- Int32 dontUseTheseGainValues[64];
-
-#ifdef HQ_SBR
-
- Int32 n;
- Int32 smooth_length;
- Int32 smoothingLength = frameData->sbr_header.smoothingLength;
- Int32 maxSmoothLength = smoothLengths[0];
-
-#endif
-
- Int32 limiterBand = frameData->sbr_header.limiterBands;
- Int32 limiterGains = frameData->sbr_header.limiterGains;
- Int32 *addHarmonics = frameData->addHarmonics;
-
- Int32 lowSubband = freqBandTable1[LOW_RES][0];
- Int32 noSubbands = freqBandTable1[LOW_RES][nSfb[LOW_RES]] - lowSubband;
- Int32 nEnv = frame_info[0];
- Int32 sEnv = frame_info[(nEnv + 1)<<1];
-
- /* ensure that noSubbands in the range [0,64] */
- noSubbands = (noSubbands >> 31) ^ noSubbands;
- if (noSubbands > 64)
- {
- noSubbands = 64;
- }
-
- if (reset)
- {
- *sUp = 1;
- *phase_index = 0;
- sbr_create_limiter_bands(limSbc,
- gateMode,
- freqBandTable1[LOW_RES],
- Patch,
- nSfb[LOW_RES]);
- }
-
- /* Mapping. */
- pv_memset((void*)hF, 0, (sizeof(*hF) << 6));
-
- ptr = freqBandTable1[HI];
- l = *(ptr++);
-
- for (i = nSfb[HI]; i != 0; i--)
- {
- k = *(ptr++);
- j = ((k + l) >> 1) - lowSubband;
- l = k;
- hF[j] = *(addHarmonics++);
- }
-
-
- /* Envelope adjustment. */
-
- for (i = 0; i < nEnv; i++)
- {
-
- if (frame_info[1+i] == frame_info[(nEnv<<1)+4+kk])
- {
- kk++, next++;
- }
-
- noNoiseFlag = (i == sEnv || i == frameData->prevEnvIsShort) ? 1 : 0;
-
-#ifdef HQ_SBR
- smooth_length = (noNoiseFlag ? 0 : smoothLengths[smoothingLength]);
-#endif
-
-
- /* Estimate levels. */
- c = 0;
- o = 0;
-
- band_nrg_tone_detector = 0;
-
- Int kkkk = freqBandTable1[ frame_info[nEnv+2+i] ][0];
-
- for (j = 0; j < nSfb[frame_info[nEnv+2+i]]; j++)
- {
- li = freqBandTable1[ frame_info[nEnv+2+i] ][j ];
- ui = freqBandTable1[ frame_info[nEnv+2+i] ][j + 1];
- flag = 0;
-
- for (k = li; k < ui; k++)
- { /* Calculate the average energy over the current envelope, */
- ui2 = (frame_info[1+i] << 1);
-
- if (LC_flag == ON)
- {
- energy_estimation_LC((Int32 *)aBufR,
- nrg_est_man,
- nrg_est_exp,
- frame_info,
- i,
- k - kkkk,
- c,
- ui2);
- }
-#ifdef HQ_SBR
- else
- {
-
- energy_estimation((Int32 *)aBufR,
- (Int32 *)aBufI,
- nrg_est_man,
- nrg_est_exp,
- frame_info,
- i,
- k - kkkk,
- c,
- ui2);
- }
-#endif
-
- flag = (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? 1 : flag;
- c++;
- }
-
-
- ui2 = freqBandTable2[o+1];
-
- if (!int_mode)
- { /* If no interpolation is used, */
-
- tmp_q1 = -100;
-
- for (k = c - (ui - li); k < c; k++)
- {
- if (tmp_q1 < nrg_est_exp[k])
- {
- tmp_q1 = nrg_est_exp[k];
- }
- }
-
- nrg = 0;
- for (k = c - (ui - li); k < c; k++)
- { /* average the energy in all the QMF bands, */
- nrg += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); /* for the whole scalefactor band. */
- }
- nrg /= (ui - li);
- nrg_exp = tmp_q1;
-
- }
-
- c -= (ui - li);
-
- for (k = 0; k < ui - li; k++)
- {
- o = (k + li >= ui2) ? o + 1 : o;
- ui2 = freqBandTable2[o+1];
- /*
- * If no interpolation is used, use the averaged energy from above,
- * otherwise do nothing.
- */
-
-
- if (!int_mode)
- {
- nrg_est_man[c] = nrg;
- nrg_est_exp[c] = nrg_exp;
- }
-
- if (LC_flag == ON)
- {
- nrg_est_exp[c] += 1;
-
- if (flag)
- {
- dontUseTheseGainValues[k + li - lowSubband] = 1;
- }
- else
- {
- dontUseTheseGainValues[k + li - lowSubband] = 0;
- }
- }
-
- nrg_ref_man[c] = sfb_nrg_man[m];
- nrg_ref_exp[c] = sfb_nrg_exp[m];
-
- /*
- * compute nL/(1 + nL); where nL = nL_man*2^nL_exp
- */
- aux1 = next * nNBands + o;
-
- tmp_q1 = nL_exp[aux1];
-
- if (tmp_q1 >= 0)
- {
- pv_div(nL_man[aux1], nL_man[aux1] + (0x3FFFFFFF >> tmp_q1), &quotient);
- }
- else
- {
- tmp_q1 = nL_man[aux1] >> (-tmp_q1);
- pv_div(tmp_q1, tmp_q1 + 0x3FFFFFFF, &quotient);
- }
-
- /*
- * tmp_q1 = nL/(1 + nL)*nrg_ref[c];
- */
-
- tmp_q1 = fxp_mul32_Q30(quotient.quotient >> quotient.shift_factor, nrg_ref_man[c]);
-
- if (flag)
- {
- /*
- * Calculate levels and gain, dependent on whether a synthetic, a sine is present or not.
- *
- * nrg_gain[c]=(float)pv_sqrt( tmp/(nrg_est[c] + 1), sqrt_cache[1] );
- */
-
-
- pv_div(tmp_q1, nrg_est_man[c] + 1, &quotient);
- /*
- * nrg_est_man[c] is an integer number, while tmp_q1 and quotient.quotient
- * are fractions in Q30
- */
-
- tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30;
-
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[1]);
- nrg_gain_man[c] = root_sq.root; /* in Q28 format */
- nrg_gain_exp[c] = root_sq.shift_factor;
-
-
- /*
- * nrg_tone[c]=(float)( (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ?
- * pv_sqrt(nrg_ref[c]/(1+tmp_nL), sqrt_cache[2]) : 0);
- */
- if (hF[c] && (i >= sEnv || hFp[c+lowSubband]))
- {
- /*
- * nrg_ref[c] and nL, as well as quotient.quotient
- * are fractions in Q30
- */
-
- /* aux1 == next*nNBands + o */
-
- tmp_q2 = nL_exp[aux1];
- /*
- * nrg_ref[c]/(1+tmp_nL)
- */
-
- if (tmp_q2 >= 0)
- {
- pv_div(nrg_ref_man[c], nL_man[aux1] + (0x3FFFFFFF >> tmp_q2), &quotient);
- }
- else
- {
- tmp_q2 = nL_man[aux1] >> (-tmp_q2);
- pv_div(nrg_ref_man[c], tmp_q2 + 0x3FFFFFFF, &quotient);
- tmp_q2 = 0; /* exponent has been applied to the sum ((man>>exp) + 1) */
- }
-
- tmp_q2 = nrg_ref_exp[c] - tmp_q2 - quotient.shift_factor;
-
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[2]);
- nrg_tone_man[c] = root_sq.root;
- nrg_tone_exp[c] = root_sq.shift_factor;
-
- }
- else
- {
- nrg_tone_man[c] = 0;
- nrg_tone_exp[c] = 0;
- }
-
- }
- else
- {
- if (noNoiseFlag)
- {
- /*
- * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c] /(nrg_est[c] + 1), sqrt_cache[3]);
- */
-
- pv_div(nrg_ref_man[c], nrg_est_man[c] + 1, &quotient);
-
- /*
- * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
- * quotient.quotient are fractions in Q30
- */
-
- tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30;
-
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[3]);
- nrg_gain_man[c] = root_sq.root;
- nrg_gain_exp[c] = root_sq.shift_factor;
-
- }
- else
- {
- /*
- * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)), sqrt_cache[4]);
- */
- /* aux1 == next*nNBands + o */
-
- tmp_q2 = nL_exp[aux1];
- /*
- * nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL))
- */
-
- if (nrg_est_man[c] == 0)
- {
- tmp_q2 = 0; /* avoid division by 0 in next if-else, this could be due to
- rounding noise */
- }
-
-
- if (tmp_q2 >= 0)
- {
-
- tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, nL_man[aux1] + (0x3FFFFFFF >> tmp_q2));
- pv_div(nrg_ref_man[c], tmp_q2, &quotient);
- /*
- * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
- * quotient.quotient are fractions in Q30
- */
- tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1];
- if (nrg_est_man[c])
- {
- tmp_q2 -= nrg_est_exp[c];
- }
-
- tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1];
- }
- else
- {
- if (tmp_q2 > - 10)
- {
- tmp_q2 = nL_man[aux1] >> (-tmp_q2);
-
- tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, tmp_q2 + 0x3FFFFFFF);
- }
- else
- {
- tmp_q2 = nrg_est_man[c] + 1;
- }
-
-
- pv_div(nrg_ref_man[c], tmp_q2, &quotient);
- /*
- * nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
- * quotient.quotient are fractions in Q30
- */
-
- tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30;
- if (nrg_est_man[c])
- {
- tmp_q2 -= nrg_est_exp[c];
- }
-
- }
-
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[4]);
- nrg_gain_man[c] = root_sq.root;
- nrg_gain_exp[c] = root_sq.shift_factor;
-
- }
-
- nrg_tone_man[c] = 0;
- nrg_tone_exp[c] = -100;
-
- }
-
- band_nrg_tone_detector |= nrg_tone_man[c]; /* detect any tone activity */
-
- pv_sqrt(tmp_q1, nrg_ref_exp[c], &root_sq, sqrt_cache[5]);
- noise_level_man[c] = root_sq.root;
- noise_level_exp[c] = root_sq.shift_factor;
-
- c++;
-
- } /* ---- end-for-loop (k) ------ */
- m++;
-
- } /* -------- Estimate levels end-for-loop (j) ----- */
-
-
-
- /*
- * Limiter
- */
-
-
- for (c = 0; c < gateMode[limiterBand]; c++)
- {
-
- p_ref_man = 0;
- p_est_man = 0;
-
- /*
- * get max exponent for the reference and estimated energy
- */
- p_ref_exp = -100;
- p_est_exp = -100;
-
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
- if (p_ref_exp < nrg_ref_exp[k])
- {
- p_ref_exp = nrg_ref_exp[k]; /* max */
- }
- if (p_est_exp < nrg_est_exp[k])
- {
- p_est_exp = nrg_est_exp[k]; /* max */
- }
- }
-
- k -= limSbc[limiterBand][c]; /* number of element used in the addition */
-
- while (k != 0) /* bit guard protection depends on log2(k) */
- {
- k >>= 1;
- p_ref_exp++; /* add extra bit-overflow-guard, nrg_ref_exp is in Q30 format */
- }
-
-
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- { /*Calculate the average gain for the current limiter band.*/
- p_ref_man += (nrg_ref_man[k] >> (p_ref_exp - nrg_ref_exp[k]));
- p_est_man += (nrg_est_man[k] >> (p_est_exp - nrg_est_exp[k]));
-
- }
-
- if (p_est_man)
- {
- /*
- * "average gain" (not equal to average of nrg_gain)
- */
- pv_div(p_ref_man, p_est_man, &quotient);
-
- tmp_q2 = p_ref_exp - 30 - p_est_exp - quotient.shift_factor;
-
- /*
- * avg_gain = sqrt(p_ref/p_est)
- */
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[6]);
- avg_gain = root_sq.root;
- g_max_exp = root_sq.shift_factor;
-
- /*
- * maximum gain allowed is calculated from table.
- */
-
- /*
- * g_max = avg_gain * limGains[limiterGains];
- */
-
- g_max_man = fxp_mul32_Q30(avg_gain, limGains[limiterGains]); /* table is in Q30 */
-
- if (limiterGains == 3)
- {
- g_max_exp = limGains[4];
- }
-
- tmp_q1 = g_max_exp >= 16 ? g_max_exp : 16;
-
- tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp);
- tmp_q1 = Q28fmt(1.52587890625F) >> (tmp_q1 - 16);
-
- if (tmp_q2 > tmp_q1)
- {
- /* upper limit, +100 dB */
- g_max_man = Q28fmt(1.52587890625F);
- g_max_exp = 16;
- }
- }
- else
- {
- /* Qfmt(1.52587890625F) exp = 16 */
- g_max_man = Q28fmt(1.52587890625F);
- g_max_exp = 16;
- }
-
- /*
- * Compute Adjusted power p_adj
- */
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
-
- tmp_q1 = g_max_exp >= nrg_gain_exp[k] ? g_max_exp : nrg_gain_exp[k];
-
- tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp);
- tmp_q1 = nrg_gain_man[k] >> (tmp_q1 - nrg_gain_exp[k]);
- /*
- * if(g_max <= nrg_gain[k])
- */
- if (tmp_q2 <= tmp_q1)
- {
- tmp_q1 = fxp_mul32_Q28(noise_level_man[k], g_max_man);
- pv_div(tmp_q1, nrg_gain_man[k], &quotient);
- noise_level_man[k] = quotient.quotient >> 2; /* in Q28 */
- noise_level_exp[k] = noise_level_exp[k] + g_max_exp - quotient.shift_factor - nrg_gain_exp[k];
-
- nrg_gain_man[k] = g_max_man; /* gains with noise supression */
- nrg_gain_exp[k] = g_max_exp;
- }
- }
-
- p_adj_exp = -100;
-
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
- tmp_q1 = nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28; /* 28 to match shift down by mult32_Q28 */
-
- if (p_adj_exp < tmp_q1)
- {
- p_adj_exp = tmp_q1;
- }
- if (nrg_tone_man[k])
- {
- tmp_q1 = (nrg_tone_exp[k] << 1);
- if (p_adj_exp < tmp_q1)
- {
- p_adj_exp = tmp_q1;
- }
- }
- else if (!noNoiseFlag)
- {
- tmp_q1 = (noise_level_exp[k] << 1);
-
- if (p_adj_exp < tmp_q1)
- {
- p_adj_exp = tmp_q1;
- }
- }
- }
-
- p_adj_exp += 1; /* overflow bit-guard*/
-
- p_adj_man = 0;
-
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
- /*
- * p_adj += nrg_gain[k]*nrg_gain[k]*nrg_est[k];
- */
-
- if (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 59)
- {
- tmp_q1 = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]);
- tmp_q1 = fxp_mul32_Q28(tmp_q1, nrg_est_man[k]);
- p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28)));
- }
-
- if (nrg_tone_man[k])
- {
- /*
- * p_adj += nrg_tone[k]*nrg_tone[k];
- */
- if (p_adj_exp - (nrg_tone_exp[k] << 1) < 31)
- {
- tmp_q1 = fxp_mul32_Q28(nrg_tone_man[k], nrg_tone_man[k]);
- p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_tone_exp[k] << 1)));
- }
- }
- else if (!noNoiseFlag)
- {
- /*
- * p_adj += noise_level[k]*noise_level[k];
- */
-
- if (p_adj_exp - (noise_level_exp[k] << 1) < 31)
- {
- tmp_q1 = fxp_mul32_Q28(noise_level_man[k], noise_level_man[k]);
- p_adj_man += (tmp_q1 >> (p_adj_exp - (noise_level_exp[k] << 1)));
- }
-
- }
- }
-
-
- if (p_adj_man)
- {
- pv_div(p_ref_man, p_adj_man, &quotient);
- tmp_q2 = p_ref_exp - p_adj_exp - 58 - quotient.shift_factor; /* 58 <> Q30 + Q28 */
-
- pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[7]);
-
- if (root_sq.shift_factor > -28)
- {
- boost_gain_q = root_sq.root << (root_sq.shift_factor + 28);
- }
- else
- {
- boost_gain_q = root_sq.root >> (-28 - root_sq.shift_factor);
- }
-
- tmp_q1 = root_sq.shift_factor >= -28 ? root_sq.shift_factor : -28;
-
- tmp_q2 = root_sq.root >> (tmp_q1 - root_sq.shift_factor);
- tmp_q1 = Q28fmt(1.584893192f) >> (tmp_q1 + 28);
-
-
- if (tmp_q2 > tmp_q1)
- {
- boost_gain_q = Q28fmt(1.584893192f);
- }
- }
- else
- {
- boost_gain_q = Q28fmt(1.584893192f);
- }
-
- if (band_nrg_tone_detector)
- {
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
- nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q);
- noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q);
- nrg_tone_man[k] = fxp_mul32_Q28(nrg_tone_man[k], boost_gain_q);
- }
- }
- else
- {
-
- for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
- {
- nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q);
- noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q);
- }
-
-
- }
-
- } /* Limiter End for loop (c) */
-
-
- if (LC_flag == ON)
- {
-
- /*
- * Aliasing correction
- */
-
- sbr_aliasing_reduction(degreeAlias,
- nrg_gain_man,
- nrg_gain_exp,
- nrg_est_man,
- nrg_est_exp,
- dontUseTheseGainValues,
- noSubbands,
- lowSubband,
- sqrt_cache,
- scratch_mem[3]);
-
- if (*sUp) /* Init only done once upon reset */
- {
- *sUp = 0;
- }
-
- envelope_application_LC((Int32 *)aBufR,
- nrg_gain_man,
- nrg_gain_exp,
- noise_level_man,
- noise_level_exp,
- nrg_tone_man,
- nrg_tone_exp,
- band_nrg_tone_detector,
- frame_info,
- harm_index,
- phase_index,
- i,
- lowSubband,
- noSubbands,
- noNoiseFlag);
- }
-#ifdef HQ_SBR
- else
- {
-
- if (*sUp) /* Init only done once upon reset */
- {
- for (n = 0; n < maxSmoothLength; n++)
- {
- pv_memcpy(fBuf_man[n], nrg_gain_man, noSubbands*sizeof(*fBuf_man[n]));
- pv_memcpy(fBufN_man[n], noise_level_man, noSubbands*sizeof(*fBufN_man[n]));
- pv_memcpy(fBuf_exp[n], nrg_gain_exp, noSubbands*sizeof(*fBuf_exp[n]));
- pv_memcpy(fBufN_exp[n], noise_level_exp, noSubbands*sizeof(*fBufN_exp[n]));
- }
- *sUp = 0;
- }
-
-
- envelope_application((Int32 *)aBufR,
- (Int32 *)aBufI,
- nrg_gain_man,
- nrg_gain_exp,
- noise_level_man,
- noise_level_exp,
- nrg_tone_man,
- nrg_tone_exp,
- fBuf_man,
- fBuf_exp,
- fBufN_man,
- fBufN_exp,
- frame_info,
- harm_index,
- phase_index,
- i,
- lowSubband,
- noSubbands,
- noNoiseFlag,
- band_nrg_tone_detector,
- maxSmoothLength,
- smooth_length);
-
- }
-#endif
-
- } /* ----- Envelope adjustment end for-loop (i) ---- */
-
-
- pv_memcpy(&hFp[0] + lowSubband,
- hF,
- (64 - lowSubband)*sizeof(*hF));
-
- if (sEnv == nEnv)
- {
- frameData->prevEnvIsShort = 0;
- }
- else
- {
- frameData->prevEnvIsShort = -1;
- }
-
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void envelope_application_LC(Int32 *aBufR,
- Int32 *nrg_gain_man,
- Int32 *nrg_gain_exp,
- Int32 *noise_level_man,
- Int32 *noise_level_exp,
- Int32 *nrg_tone_man,
- Int32 *nrg_tone_exp,
- Int32 band_nrg_tone_detector,
- const Int32 *frame_info,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 i,
- Int32 lowSubband,
- Int32 noSubbands,
- Int32 noNoiseFlag)
-{
-
- Int32 *ptrReal;
- Int32 sb_gain_man;
- Int32 sb_noise_man;
- Int32 sb_noise_exp;
- Int32 l;
- Int32 k;
- Int32 tmp_q1;
- Int32 tmp_q2;
- Int32 tone_count;
- Int16 tmp_16;
- Int32 indexMinus1;
- Int32 indexPlus1;
-
-
- /*
- * Application
- */
-
- if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */
- {
-
- /*
- * pre-calculate tone application
- */
- for (k = 0; k < noSubbands; k++)
- {
- tmp_q2 = (-nrg_tone_exp[k]);
- tmp_q1 = nrg_tone_man[k];
- tmp_q2 = tmp_q1 >> tmp_q2;
- tmp_q1 = fxp_mul32_by_16(tmp_q2, Q15fmt(0.0163f));
- nrg_tone_man[k] = tmp_q2;
- nrg_tone_exp[k] = tmp_q1;
- noise_level_exp[k] += 1;
- nrg_gain_exp[k] += 28;
- }
-
- for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
- {
- ptrReal = (aBufR + l * SBR_NUM_BANDS);
-
- tone_count = 0;
-
- indexPlus1 = (*harm_index + 1) & 3;
-
- if (indexPlus1 & 1) /* if indexPlus1 is odd */
- {
- for (k = 0; k < noSubbands; k++)
- {
-
- sb_gain_man = nrg_gain_man[k];
- tmp_q1 = *ptrReal;
- tmp_q2 = nrg_gain_exp[k];
- tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
- if (tmp_q2 < 0)
- {
- if (tmp_q2 > -32)
- {
- *ptrReal = tmp_q1 >> (-tmp_q2);
- }
- }
- else
- {
- *ptrReal = tmp_q1 << tmp_q2;
- }
-
- *phase_index = (*phase_index + 1) & 511;
-
- if (!nrg_tone_man[k] && !noNoiseFlag)
-
- {
- tmp_16 = rP_LCx[*phase_index];
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -32)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- }
- }
-
- tmp_q1 = nrg_tone_man[k];
-
- if (*harm_index)
- {
- *ptrReal -= tmp_q1;
- }
- else
- {
- *ptrReal += tmp_q1;
- }
-
- if (tmp_q1)
- {
- tone_count++;
- }
-
- ptrReal++;
-
- } /* for-loop (k) */
-
- }
- else /* if indexPlus1 is even */
- {
- indexMinus1 = (*harm_index - 1) & 3;
-
- /* --- k = 0 ----- */
-
- sb_gain_man = nrg_gain_man[0];
- tmp_q1 = *ptrReal;
- tmp_q2 = nrg_gain_exp[0];
- tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
- if (tmp_q2 < 0)
- {
- if (tmp_q2 > -32)
- {
- *ptrReal = tmp_q1 >> (-tmp_q2);
- }
- }
- else
- {
- *ptrReal = tmp_q1 << tmp_q2;
- }
-
- *phase_index = (*phase_index + 1) & 511;
-
- tmp_q1 = nrg_tone_exp[0];
- tmp_q2 = nrg_tone_exp[1];
-
- if ((indexPlus1 != 0) ^((lowSubband & 1) != 0))
- {
- *(ptrReal - 1) -= tmp_q1;
- *(ptrReal) += tmp_q2;
- }
- else
- {
- *(ptrReal - 1) += tmp_q1;
- *(ptrReal) -= tmp_q2;
- }
-
- if (!nrg_tone_man[0] && !noNoiseFlag)
- {
- tmp_16 = rP_LCx[*phase_index];
- sb_noise_man = noise_level_man[0];
- sb_noise_exp = noise_level_exp[0];
-
- tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -32)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- }
- }
- else
- {
- tone_count++;
- }
-
- ptrReal++;
-
- /* ---- */
-
- for (k = 1; k < noSubbands - 1; k++)
- {
-
- sb_gain_man = nrg_gain_man[k];
- tmp_q1 = *ptrReal;
- tmp_q2 = nrg_gain_exp[k];
- tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
- if (tmp_q2 < 0)
- {
- if (tmp_q2 > -32)
- {
- *ptrReal = tmp_q1 >> (-tmp_q2);
- }
- }
- else
- {
- *ptrReal = tmp_q1 << tmp_q2;
- }
-
- *phase_index = (*phase_index + 1) & 511;
-
-
- if (tone_count < 16)
- {
- tmp_q1 = nrg_tone_exp[k - 1];
- tmp_q2 = nrg_tone_exp[k + 1];
-
- tmp_q1 -= tmp_q2;
-
-
- if ((indexPlus1 != 0) ^(((k + lowSubband) & 1) != 0))
- {
- *(ptrReal) -= tmp_q1;
- }
- else
- {
- *(ptrReal) += tmp_q1;
- }
- } /* if (tone_count < 16) */
-
-
- if (!nrg_tone_man[k] && !noNoiseFlag)
- {
- tmp_16 = rP_LCx[*phase_index];
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -32)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- }
- }
- else
- {
- tone_count++;
- }
-
- ptrReal++;
-
- } /* for-loop (k) */
-
- sb_gain_man = nrg_gain_man[k];
- tmp_q1 = *ptrReal;
- tmp_q2 = nrg_gain_exp[k];
- tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
- if (tmp_q2 < 0)
- {
- if (tmp_q2 > -31)
- {
- *ptrReal = tmp_q1 >> (-tmp_q2);
- }
- }
- else
- {
- *ptrReal = tmp_q1 << tmp_q2;
- }
-
- *phase_index = (*phase_index + 1) & 511;
-
-
- if ((tone_count < 16) && !(indexMinus1 &1))
- {
- tmp_q1 = nrg_tone_exp[k - 1];
- tmp_q2 = nrg_tone_exp[k ];
-
- if ((indexMinus1 != 0) ^(((k + lowSubband) & 1) != 0))
- {
- *(ptrReal) += tmp_q1;
-
- if (k + lowSubband < 62)
- {
- *(ptrReal + 1) -= tmp_q2;
- }
- }
- else
- {
- *(ptrReal) -= tmp_q1;
-
- if (k + lowSubband < 62)
- {
- *(ptrReal + 1) += tmp_q2;
- }
- }
- } /* if (tone_count < 16) */
-
-
- if (!nrg_tone_man[k] && !noNoiseFlag)
- {
- tmp_16 = rP_LCx[*phase_index];
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -31)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- }
- }
-
- } /* if indexPlus1 is odd */
-
- *harm_index = indexPlus1;
-
-
- } /* for-loop (l) */
-
- }
- else /* if ( band_nrg_tone_detector) */
- {
-
- for (k = 0; k < noSubbands; k++)
- {
- tmp_q1 = noise_level_exp[k];
- tmp_q2 = nrg_gain_exp[k];
- noise_level_exp[k] = tmp_q1 + 1;
- nrg_gain_exp[k] = tmp_q2 + 28;
- }
-
- for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
- {
- ptrReal = (aBufR + l * SBR_NUM_BANDS);
-
- for (k = 0; k < noSubbands; k++)
- {
-
- tmp_q1 = *ptrReal;
- sb_gain_man = nrg_gain_man[k];
-
- tmp_q2 = nrg_gain_exp[k];
-
- tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
- if (tmp_q2 < 0)
- {
- if (tmp_q2 > -31)
- {
- *ptrReal = tmp_q1 >> (-tmp_q2);
- }
- }
- else
- {
- *ptrReal = tmp_q1 << tmp_q2;
- }
-
- *phase_index = (*phase_index + 1) & 511;
-
- if (! noNoiseFlag)
- {
- tmp_16 = rP_LCx[*phase_index];
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -31)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- }
- }
-
- ptrReal++;
-
- } /* for-loop (k) */
-
- *harm_index = (*harm_index + 1) & 3;
-
-
- } /* for-loop (l) */
-
- }
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-#define Qfmt15(a) (Int32)(a*((Int32)1<<15) + (a>=0?0.5F:-0.5F))
-
-
-const Int16 pow2[39] = { 0, 0, 1, 0, 2,
- 0, Qfmt15(2 / 6.0f), 0, 3, 0, Qfmt15(2 / 10.0f), 0, Qfmt15(2 / 12.0f), 0, Qfmt15(2 / 14.0f), 0, 4,
- 0, Qfmt15(2 / 18.0f), 0, Qfmt15(2 / 20.0f), 0, Qfmt15(2 / 22.0f), 0, Qfmt15(2 / 24.0f),
- 0, Qfmt15(2 / 26.0f), 0, Qfmt15(2 / 28.0f), 0, Qfmt15(2 / 30.0f), 0, 5, 0, Qfmt15(2 / 34.0f),
- 0, Qfmt15(2 / 36.0f), 0, Qfmt15(2 / 38.0f)
- };
-
-void energy_estimation_LC(Int32 *aBufR,
- Int32 *nrg_est_man,
- Int32 *nrg_est_exp,
- const Int32 *frame_info,
- Int32 i,
- Int32 k,
- Int32 c,
- Int32 ui2)
-{
-
-
- Int32 aux1;
- Int32 aux2;
- Int32 l;
-
-
- int64_t nrg_h = 0;
- Int32 tmp1;
- UInt32 tmp2;
-
- for (l = ui2; l < (frame_info[2+i] << 1); l++)
- {
-
- aux1 = aBufR[l++*SBR_NUM_BANDS + k ];
- aux2 = aBufR[l *SBR_NUM_BANDS + k ];
-
- nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
- nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
- }
-
- /*
- * Check for overflow and saturate if needed
- */
- if (nrg_h < 0)
- {
- nrg_h = 0x7fffffff;
- }
-
-
- if (nrg_h)
- {
- tmp2 = (UInt32)(nrg_h >> 32);
- if (tmp2)
- {
- aux2 = pv_normalize(tmp2);
- aux2 -= 1; /* ensure Q30 */
- nrg_h = (nrg_h << aux2) >> 33;
- tmp2 = (UInt32)(nrg_h);
- nrg_est_exp[c] = 33 - aux2;
- }
- else
- {
- tmp2 = (UInt32)(nrg_h >> 2);
- aux2 = pv_normalize(tmp2);
- aux2 -= 1; /* ensure Q30 */
-
- tmp2 = (tmp2 << aux2);
- nrg_est_exp[c] = -aux2 + 2;
- }
-
- tmp1 = (l - ui2);
-
- aux2 = pow2[tmp1];
- if (tmp1 == (tmp1 & (-tmp1)))
- {
- nrg_est_man[c] = tmp2 >> aux2;
- }
- else
- {
- nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2);
- }
-
- }
- else
- {
- nrg_est_man[c] = 0;
- nrg_est_exp[c] = -100;
- }
-
-
-
-
-
-}
-
-
-
-
-
-
-#if HQ_SBR
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void envelope_application(Int32 *aBufR,
- Int32 *aBufI,
- Int32 *nrg_gain_man,
- Int32 *nrg_gain_exp,
- Int32 *noise_level_man,
- Int32 *noise_level_exp,
- Int32 *nrg_tone_man,
- Int32 *nrg_tone_exp,
- Int32 *fBuf_man[64],
- Int32 *fBuf_exp[64],
- Int32 *fBufN_man[64],
- Int32 *fBufN_exp[64],
- const Int32 *frame_info,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 i,
- Int32 lowSubband,
- Int32 noSubbands,
- Int32 noNoiseFlag,
- Int32 band_nrg_tone_detector,
- Int32 maxSmoothLength,
- Int32 smooth_length)
-{
-
- Int32 *ptrReal;
- Int32 *ptrImag;
- Int32 sb_gain_man;
- Int32 sb_gain_exp;
- Int32 sb_noise_man;
- Int32 sb_noise_exp;
- Int32 l;
- Int32 k;
- Int32 n;
- Int32 tmp_q1;
- Int32 tmp_q2;
- Int32 aux1;
- Int32 aux2;
- Int32 filter_history = 0;
-
-
- if (band_nrg_tone_detector) /* Add tone energy only if energy is detected */
- {
-
- /*
- * pre-calculate tone application
- */
-
- ptrReal = nrg_tone_exp;
- ptrImag = nrg_tone_man;
- tmp_q1 = - *(ptrReal++);
- aux1 = *(ptrImag);
- for (k = 0; k < noSubbands; k++)
- {
- *(ptrImag++) = aux1 >> tmp_q1;
- tmp_q1 = - *(ptrReal++);
- aux1 = *(ptrImag);
- }
-
- /*
- * Application
- */
-
- for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
- {
- ptrReal = (aBufR + l * SBR_NUM_BANDS);
- ptrImag = (aBufI + l * SBR_NUM_BANDS);
-
- if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */
- {
- pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man));
- pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp));
- pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man));
- pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp));
- }
-
- /*
- * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation
- */
- for (k = 0; k < noSubbands; k++)
- {
- if (smooth_length == 0) /* no filter-smooth needed */
- {
- sb_gain_man = nrg_gain_man[k];
- sb_gain_exp = nrg_gain_exp[k];
-
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- }
- else
- { /* else smooth_length == 4 and fir_4 filter is being used */
-
- sb_gain_exp = fBuf_exp[maxSmoothLength][k];
-
- sb_noise_exp = fBufN_exp[maxSmoothLength][k];
-
- for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++)
- {
- if (sb_gain_exp < fBuf_exp[n][k])
- {
- sb_gain_exp = fBuf_exp[n][k];
- }
-
- if (sb_noise_exp < fBufN_exp[n][k])
- {
- sb_noise_exp = fBufN_exp[n][k];
- }
- }
-
- sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
- sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]);
-
- sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
- sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]);
-
- n = maxSmoothLength - smooth_length;
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]);
-
- }
-
-
-
- /*
- * *ptrReal = *ptrReal * sb_gain ;
- * *ptrImag = *ptrImag * sb_gain;
- */
- aux1 = *ptrReal;
- aux2 = *ptrImag;
- sb_gain_exp += 32;
- aux1 = fxp_mul32_Q31(aux1, sb_gain_man);
- aux2 = fxp_mul32_Q31(aux2, sb_gain_man);
-
-
- if (sb_gain_exp < 0)
- {
- sb_gain_exp = -sb_gain_exp;
- if (sb_gain_exp < 32)
- {
- *ptrReal = (aux1 >> sb_gain_exp);
- *ptrImag = (aux2 >> sb_gain_exp);
- }
- }
- else
- {
- *ptrReal = (aux1 << sb_gain_exp);
- *ptrImag = (aux2 << sb_gain_exp);
- }
-
-
-
- /*
- * if ( sb_noise != 0)
- * {
- * *ptrReal += sb_noise * rP[*phase_index][0];
- * *ptrImag += sb_noise * rP[*phase_index][1];
- * }
- */
- *phase_index = (*phase_index + 1) & 511;
-
- if (nrg_tone_man[k] || noNoiseFlag)
- {
- sb_noise_man = 0;
- sb_noise_exp = 0;
- }
- else
- {
-
- Int32 tmp = rPxx[*phase_index];
- sb_noise_exp += 1;
- tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp);
- tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp);
-
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -32)
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp);
- *ptrImag += tmp_q2 >> (-sb_noise_exp);
- }
- }
- else
- {
- *ptrReal += tmp_q1 << sb_noise_exp;
- *ptrImag += tmp_q2 << sb_noise_exp;
- }
- }
-
- /*
- * tmp_q1 = nrg_tone[k]
- */
-
- tmp_q1 = nrg_tone_man[k];
-
- if (*harm_index & 1)
- {
- if ((((k + lowSubband) & 1) != 0) ^(*harm_index != 1))
- {
- *ptrImag -= tmp_q1;
- }
- else
- {
- *ptrImag += tmp_q1;
- }
- }
- else
- {
- *ptrReal += (*harm_index) ? -tmp_q1 : tmp_q1;
- }
-
- *ptrReal++ <<= 10;
- *ptrImag++ <<= 10;
-
-
- } /* for-loop (k) */
-
-
- *harm_index = (*harm_index + 1) & 3;
-
- /*
- * Update smoothing filter history
- */
-
- if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */
- {
- /*
- * mantissas
- */
-
- ptrReal = (Int32 *)fBuf_man[0];
- ptrImag = (Int32 *)fBufN_man[0];
-
- for (n = 0; n < maxSmoothLength; n++)
- {
- fBuf_man[n] = fBuf_man[n+1];
- fBufN_man[n] = fBufN_man[n+1];
- }
-
- fBuf_man[maxSmoothLength] = ptrReal;
- fBufN_man[maxSmoothLength] = ptrImag;
-
- /*
- * exponents
- */
- ptrReal = (Int32 *)fBuf_exp[0];
- ptrImag = (Int32 *)fBufN_exp[0];
-
- for (n = 0; n < maxSmoothLength; n++)
- {
- fBuf_exp[n] = fBuf_exp[n+1];
- fBufN_exp[n] = fBufN_exp[n+1];
- }
-
- fBuf_exp[maxSmoothLength] = ptrReal;
- fBufN_exp[maxSmoothLength] = ptrImag;
- }
-
- } /* for-loop (l) */
-
-
- }
- else /* ---- if ( band_nrg_tone_detector) ---- */
- {
-
- /*
- * Application
- */
-
- for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
- {
- ptrReal = (aBufR + l * SBR_NUM_BANDS);
- ptrImag = (aBufI + l * SBR_NUM_BANDS);
-
- if (filter_history <= maxSmoothLength) /* no more update is needed as buffer will have same info */
- {
- pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man));
- pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp));
- pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man));
- pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp));
- }
-
- /*
- * nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation
- */
- for (k = 0; k < noSubbands; k++)
- {
- if (smooth_length == 0) /* no filter-smooth needed */
- {
- sb_gain_man = nrg_gain_man[k];
- sb_gain_exp = nrg_gain_exp[k];
-
- sb_noise_man = noise_level_man[k];
- sb_noise_exp = noise_level_exp[k];
-
- }
- else
- { /* else smooth_length == 4 and fir_4 filter is being used */
-
- sb_gain_exp = fBuf_exp[maxSmoothLength][k];
-
- sb_noise_exp = fBufN_exp[maxSmoothLength][k];
-
- for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++)
- {
- if (sb_gain_exp < fBuf_exp[n][k])
- {
- sb_gain_exp = fBuf_exp[n][k];
- }
-
- if (sb_noise_exp < fBufN_exp[n][k])
- {
- sb_noise_exp = fBufN_exp[n][k];
- }
- }
-
- sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
- sb_gain_man = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]);
-
- sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
- sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]);
-
- n = maxSmoothLength - smooth_length;
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f));
- sb_gain_man += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
- tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f));
- sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]);
-
- }
-
-
-
- /*
- * *ptrReal = *ptrReal * sb_gain ;
- * *ptrImag = *ptrImag * sb_gain;
- */
- aux1 = *ptrReal;
- aux2 = *ptrImag;
- sb_gain_exp += 32;
- aux1 = fxp_mul32_Q31(aux1, sb_gain_man);
- aux2 = fxp_mul32_Q31(aux2, sb_gain_man);
-
-
-
- /*
- * if ( sb_noise != 0)
- * {
- * *ptrReal += sb_noise * rP[*phase_index][0];
- * *ptrImag += sb_noise * rP[*phase_index][1];
- * }
- */
-
-
- if (sb_gain_exp < 0)
- {
- if (sb_gain_exp > -32)
- {
- if (sb_gain_exp > -10)
- {
- *ptrReal = aux1 << (10 + sb_gain_exp);
- *ptrImag = aux2 << (10 + sb_gain_exp);
- }
- else
- {
- *ptrReal = aux1 >> (-sb_gain_exp - 10);
- *ptrImag = aux2 >> (-sb_gain_exp - 10);
- }
- }
- }
- else
- {
- *ptrReal = aux1 << (sb_gain_exp + 10);
- *ptrImag = aux2 << (sb_gain_exp + 10);
- }
-
-
-
-
- /*
- * if ( sb_noise != 0)
- * {
- * *ptrReal += sb_noise * rP[*phase_index][0];
- * *ptrImag += sb_noise * rP[*phase_index][1];
- * }
- */
- *phase_index = (*phase_index + 1) & 511;
-
- if (!noNoiseFlag)
- {
-
- Int32 tmp = rPxx[*phase_index];
- sb_noise_exp += 1;
- tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp);
- tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp);
-
- if (sb_noise_exp < 0)
- {
- if (sb_noise_exp > -32)
- {
- if (sb_noise_exp > -10)
- {
- *ptrReal += tmp_q1 << (10 + sb_noise_exp);
- *ptrImag += tmp_q2 << (10 + sb_noise_exp);
- }
- else
- {
- *ptrReal += tmp_q1 >> (-sb_noise_exp - 10);
- *ptrImag += tmp_q2 >> (-sb_noise_exp - 10);
- }
- }
- }
- else
- {
- *ptrReal += tmp_q1 << (sb_noise_exp + 10);
- *ptrImag += tmp_q2 << (sb_noise_exp + 10);
- }
- }
-
- ptrReal++;
- ptrImag++;
-
-
- } /* for-loop (k) */
-
-
- *harm_index = (*harm_index + 1) & 3;
-
- /*
- * Update smoothing filter history
- */
-
- if (filter_history++ < maxSmoothLength) /* no more update is needed as buffer will have same info */
- {
- /*
- * mantissas
- */
-
- ptrReal = (Int32 *)fBuf_man[0];
- ptrImag = (Int32 *)fBufN_man[0];
-
- for (n = 0; n < maxSmoothLength; n++)
- {
- fBuf_man[n] = fBuf_man[n+1];
- fBufN_man[n] = fBufN_man[n+1];
- }
-
- fBuf_man[maxSmoothLength] = ptrReal;
- fBufN_man[maxSmoothLength] = ptrImag;
-
- /*
- * exponents
- */
- ptrReal = (Int32 *)fBuf_exp[0];
- ptrImag = (Int32 *)fBufN_exp[0];
-
- for (n = 0; n < maxSmoothLength; n++)
- {
- fBuf_exp[n] = fBuf_exp[n+1];
- fBufN_exp[n] = fBufN_exp[n+1];
- }
-
- fBuf_exp[maxSmoothLength] = ptrReal;
- fBufN_exp[maxSmoothLength] = ptrImag;
- }
-
- } /* for-loop (l) */
-
- } /* if ( band_nrg_tone_detector) */
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void energy_estimation(Int32 *aBufR,
- Int32 *aBufI,
- Int32 *nrg_est_man,
- Int32 *nrg_est_exp,
- const Int32 *frame_info,
- Int32 i,
- Int32 k,
- Int32 c,
- Int32 ui2)
-{
-
- Int32 aux1;
- Int32 aux2;
- Int32 l;
-
-
-
- int64_t nrg_h = 0;
- Int32 tmp1;
- Int32 tmp2;
-
- aux1 = aBufR[ui2*SBR_NUM_BANDS + k];
- aux2 = aBufI[ui2*SBR_NUM_BANDS + k];
- for (l = ui2 + 1; l < (frame_info[2+i] << 1); l++)
- {
- nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
- nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
- aux1 = aBufR[l*SBR_NUM_BANDS + k];
- aux2 = aBufI[l*SBR_NUM_BANDS + k];
- }
- nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
- nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
-
-
- /*
- * Check for overflow and saturate if needed
- */
- if (nrg_h < 0)
- {
- nrg_h = 0x7fffffff;
- }
-
- if (nrg_h)
- {
-
- aux1 = (UInt32)(nrg_h >> 32);
- if (aux1)
- {
- aux2 = pv_normalize(aux1);
- if (aux2)
- {
- aux2 -= 1; /* ensure Q30 */
- nrg_h = (nrg_h << aux2) >> 33;
- tmp2 = (UInt32)(nrg_h);
- nrg_est_exp[c] = 33 - aux2;
- }
- else
- {
- tmp2 = (UInt32)(aux1 >> 1);
- nrg_est_exp[c] = 33 ;
-
-
- }
- }
- else
- {
- aux1 = (UInt32)(nrg_h >> 1);
- aux2 = pv_normalize(aux1);
-
- tmp2 = (aux1 << aux2);
- nrg_est_exp[c] = -aux2 + 1;
-
-
- }
-
-
-
- tmp1 = (l - ui2);
- aux2 = pow2[tmp1];
- if (tmp1 == (tmp1 & (-tmp1)))
- {
- nrg_est_man[c] = tmp2 >> aux2;
- }
- else
- {
- nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2);
- }
- }
- else
- {
- nrg_est_man[c] = 0;
- nrg_est_exp[c] = -100;
- }
-
-
-}
-
-
-
-
-
-#endif
-
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h b/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h
deleted file mode 100644
index 2a6ae57..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_envelope.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALCULATE_SBR_ENVELOPE_H
-#define CALCULATE_SBR_ENVELOPE_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_sbr_frame_data.h"
-#include "sbr_generate_high_freq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- void calc_sbr_envelope(SBR_FRAME_DATA *frameData,
- Int32 *aBufR,
- Int32 *aBufI,
- Int freqBandTable1[2][MAX_FREQ_COEFFS + 1],
- const Int32 *nSfb,
- Int32 freqBandTable2[MAX_NOISE_COEFFS + 1],
- Int32 nNBands,
- Int32 reset,
- Int32 *degreeAlias,
- Int32 *harm_index,
- Int32 *phase_index,
- Int32 hFp[64],
- Int32 *sUp,
- Int32 limSbc[][13],
- Int32 *gateMode,
-#ifdef HQ_SBR
- Int32 *fBuf_man[64],
- Int32 *fBuf_exp[64],
- Int32 *fBufN_man[64],
- Int32 *fBufN_exp[64],
-#endif
- Int32 scratch_mem[][64],
- struct PATCH Patch,
- Int32 sqrt_cache[][4],
- Int32 LC_flag);
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* CALCULATE_SBR_ENVELOPE_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp
deleted file mode 100644
index e557aa1..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp
+++ /dev/null
@@ -1,639 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_synfilterbank.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "calc_sbr_synfilterbank.h"
-#include "qmf_filterbank_coeff.h"
-#include "synthesis_sub_band.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#if defined (PV_ARM_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
- Int32 x;
- __asm
- {
- qdadd y, y, y
- mov y, y, asr #16
- }
-
- return((Int16)y);
-}
-
-#define saturate2( a, b, c, d) *c = sat( a); \
- *d = sat( b); \
- c += 2; \
- d -= 2;
-
-
-#elif defined (PV_ARM_V4)
-
-
-__inline Int16 sat(Int32 y)
-{
- Int32 x;
- Int32 z = 31; /* rvct compiler problem */
- __asm
- {
- sub y, y, y, asr 2
- mov y, y, asr N
- mov x, y, asr #15
- teq x, y, asr z
- eorne y, INT16_MAX, y, asr #31
- }
-
- return((Int16)y);
-}
-
-#define saturate2( a, b, c, d) *c = sat( a); \
- *d = sat( b); \
- c += 2; \
- d -= 2;
-
-#elif defined(PV_ARM_GCC_V5)
-
-__inline Int16 sat(Int32 y)
-{
- register Int32 x;
- register Int32 ra = y;
-
-
- asm volatile(
- "qdadd %0, %1, %1\n\t"
- "mov %0, %0, asr #16"
- : "=&r*i"(x)
- : "r"(ra));
-
- return ((Int16)x);
-}
-
-
-#define saturate2( a, b, c, d) *c = sat( a); \
- *d = sat( b); \
- c += 2; \
- d -= 2;
-
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-#include "armintr.h"
-
-#define saturate2( a, b, c, d) *c = _DAddSatInt( a, a)>>16; \
- *d = _DAddSatInt( b, b)>>16; \
- c += 2; \
- d -= 2;
-
-#else
-
-
-#define saturate2( a, b, c, d) a -= (a>>2); \
- a = (a>>N); \
- if((a>>15) != (a>>31)) \
- { \
- a = ((a >> 31) ^ INT16_MAX); \
- } \
- *c = (Int16)a; \
- c += 2; \
- b -= (b>>2); \
- b = (b>>N); \
- if((b>>15) != (b>>31)) \
- { \
- b = ((b >> 31) ^ INT16_MAX); \
- } \
- *d = (Int16)b; \
- d -= 2;
-
-
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_synfilterbank_LC(Int32 * Sr,
- Int16 * timeSig,
- Int16 V[1280],
- bool bDownSampleSBR)
-{
- Int32 i;
-
- Int32 realAccu1;
- Int32 realAccu2;
- const Int32 *pt_C2;
-
- Int16 *pt_V1;
- Int16 *pt_V2;
-
-
- Int16 *pt_timeSig;
-
- Int16 *pt_timeSig_2;
- Int32 test1;
- Int16 tmp1;
- Int16 tmp2;
-
- /* shift filterstates */
-
- Int32 * pt_Sr = Sr;
-
-
- if (bDownSampleSBR == false)
- {
-
- synthesis_sub_band_LC(pt_Sr, V);
-
- /* content of V[] is at most 16 bits */
-
- pt_timeSig = &timeSig[0];
- pt_timeSig_2 = &timeSig[64];
-
-
- tmp1 = V[ 704];
- tmp2 = V[ 768];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
- tmp1 = -V[ 512];
- tmp2 = V[ 960];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
- tmp1 = V[ 448];
- tmp2 = V[1024];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
- tmp1 = -V[ 256];
- tmp2 = V[ 192];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
-
- tmp1 = V[ 32];
- tmp2 = V[1248];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
- tmp1 = V[ 224];
- tmp2 = V[1056];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
- tmp1 = V[ 992];
- tmp2 = V[ 288];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
- tmp1 = V[ 480];
- tmp2 = V[ 800];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
- tmp1 = V[ 736];
- tmp2 = V[ 544];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
-
-
-
- saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
- pt_timeSig_2 = &timeSig[126];
-
- pt_V1 = &V[1];
- pt_V2 = &V[1279];
-
- pt_C2 = &sbrDecoderFilterbankCoefficients[0];
-
- for (i = 31; i != 0; i--)
- {
- test1 = *(pt_C2++);
- tmp1 = *(pt_V1++);
- tmp2 = *(pt_V2--);
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
- tmp1 = pt_V1[ 191];
- tmp2 = pt_V2[ -191];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 255];
- tmp2 = pt_V2[ -255];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 447];
- tmp2 = pt_V2[ -447];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 511];
- tmp2 = pt_V2[ -511];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 703];
- tmp2 = pt_V2[ -703];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 767];
- tmp2 = pt_V2[ -767];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 959];
- tmp2 = pt_V2[ -959];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 1023];
- tmp2 = pt_V2[ -1023];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 1215];
- tmp2 = pt_V2[ -1215];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
- }
- }
- else
- {
-
- synthesis_sub_band_LC_down_sampled(Sr, V);
-
- /*
- * window signal
- * calculate output samples
- */
-
-
- pt_V1 = &V[0];
- pt_V2 = &V[96];
-
-
- Int32 * pt_out = Sr;
-
- for (i = 0; i < 8; i++)
- {
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- }
-
- const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
- pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
-
- for (int k = 0; k < 5; k++)
- {
- pt_out -= 32;
- for (i = 0; i < 16; i++)
- {
- realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
- realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
- realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
- *(pt_out++) += realAccu1 >> 5;
- *(pt_out++) += realAccu2 >> 5;
-
- }
- pt_V1 += 96;
- pt_V2 += 96;
- pt_C1 += 16;
- pt_C2 += 16;
- }
- pt_out -= 32;
-
- for (i = 0; i < 32; i++)
- {
- timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
- }
-
- }
-
-}
-
-
-
-#ifdef HQ_SBR
-
-void calc_sbr_synfilterbank(Int32 * Sr,
- Int32 * Si,
- Int16 * timeSig,
- Int16 V[1280],
- bool bDownSampleSBR)
-{
- Int32 i;
-
- const Int32 *pt_C2;
-
- Int32 realAccu1;
- Int32 realAccu2;
-
- Int16 *pt_V1;
- Int16 *pt_V2;
-
- Int16 *pt_timeSig;
-
- Int16 *pt_timeSig_2;
- Int32 test1;
- Int16 tmp1;
- Int16 tmp2;
-
-
- if (bDownSampleSBR == false)
- {
- synthesis_sub_band(Sr, Si, V);
-
- /* content of V[] is at most 16 bits */
- pt_timeSig = &timeSig[0];
- pt_timeSig_2 = &timeSig[64];
-
- tmp1 = V[ 704];
- tmp2 = V[ 768];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
- tmp1 = -V[ 512];
- tmp2 = V[ 960];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
- tmp1 = V[ 448];
- tmp2 = V[1024];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
- tmp1 = -V[ 256];
- tmp2 = V[ 192];
- realAccu1 = fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
- realAccu1 = fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
-
- tmp1 = V[ 32];
- tmp2 = V[1248];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
- tmp1 = V[ 224];
- tmp2 = V[1056];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
- tmp1 = V[ 992];
- tmp2 = V[ 288];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
- tmp1 = V[ 480];
- tmp2 = V[ 800];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
- tmp1 = V[ 736];
- tmp2 = V[ 544];
- realAccu2 = fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
- realAccu2 = fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
-
-
- saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
- pt_timeSig_2 = &timeSig[126];
-
- pt_V1 = &V[1];
- pt_V2 = &V[1279];
-
- pt_C2 = &sbrDecoderFilterbankCoefficients[0];
-
- for (i = 31; i != 0; i--)
- {
- test1 = *(pt_C2++);
- tmp1 = *(pt_V1++);
- tmp2 = *(pt_V2--);
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
- tmp1 = pt_V1[ 191];
- tmp2 = pt_V2[ -191];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 255];
- tmp2 = pt_V2[ -255];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 447];
- tmp2 = pt_V2[ -447];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 511];
- tmp2 = pt_V2[ -511];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 703];
- tmp2 = pt_V2[ -703];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 767];
- tmp2 = pt_V2[ -767];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 959];
- tmp2 = pt_V2[ -959];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- test1 = *(pt_C2++);
- tmp1 = pt_V1[ 1023];
- tmp2 = pt_V2[ -1023];
- realAccu1 = fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
- tmp1 = pt_V1[ 1215];
- tmp2 = pt_V2[ -1215];
- realAccu1 = fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
- saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
- }
-
- }
- else
- {
-
- synthesis_sub_band_down_sampled(Sr, Si, V);
-
-
- Int32 * pt_out = Sr;
-
- for (i = 0; i < 8; i++)
- {
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- *(pt_out++) = 0;
- }
-
-
- /*
- * window signal
- * calculate output samples
- */
-
- pt_V1 = &V[0];
- pt_V2 = &V[96];
-
-
- const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
- pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
-
- for (Int k = 0; k < 5; k++)
- {
- pt_out -= 32;
- for (i = 0; i < 16; i++)
- {
- realAccu1 = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
- realAccu2 = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
- realAccu1 = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
- realAccu2 = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
- *(pt_out++) += realAccu1 >> 5;
- *(pt_out++) += realAccu2 >> 5;
- }
- pt_V1 += 96;
- pt_V2 += 96;
- pt_C1 += 16;
- pt_C2 += 16;
- }
- pt_out -= 32;
-
- for (i = 0; i < 32; i++)
- {
- timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
- }
-
- }
-}
-
-
-#endif /* --- HQ_SBR --- */
-
-
-#endif /* --- AAC_PLUS --- */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h b/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h
deleted file mode 100644
index 28bd6de..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_SBR_SYNFILTERBANK_H
-#define CALC_SBR_SYNFILTERBANK_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-#define N 14
-
-#define ROUND_SYNFIL (32768 + 4096)
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-
- void calc_sbr_synfilterbank_LC(Int32 * Sr,
- Int16 * timeSig,
- Int16 V[1280],
- bool bDownSampleSBR);
-
-#ifdef HQ_SBR
-
-
- void calc_sbr_synfilterbank(Int32 * Sr,
- Int32 * Si,
- Int16 * timeSig,
- Int16 V[1280],
- bool bDownSampleSBR);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/chans.h b/media/libstagefright/codecs/aacdec/chans.h
deleted file mode 100644
index 325b5cd..0000000
--- a/media/libstagefright/codecs/aacdec/chans.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: chans.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Placed file in the correct template format.
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CHANS_H
-#define CHANS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
- /* #define is required in order to use these args in #if () directive */
-#define ICChans 0
-#define DCChans 0
-#define XCChans 0
-#define CChans 0
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
- enum
- {
- /*
- * channels for 5.1 main profile configuration
- * (modify for any desired decoder configuration)
- */
- FChans = 2, /* front channels: left, center, right */
- FCenter = 0, /* 1 if decoder has front center channel */
- SChans = 0, /* side channels: */
- BChans = 0, /* back channels: left surround, right surround */
- BCenter = 0, /* 1 if decoder has back center channel */
- LChans = 0, /* LFE channels */
- XChans = 0, /* scratch space for parsing unused channels */
-
- Chans = FChans + SChans + BChans + LChans + XChans
- };
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CHANS_H */
-
diff --git a/media/libstagefright/codecs/aacdec/check_crc.cpp b/media/libstagefright/codecs/aacdec/check_crc.cpp
deleted file mode 100644
index 17f3b87..0000000
--- a/media/libstagefright/codecs/aacdec/check_crc.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: check_crc.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- INPUT
-
-
- OUTPUT
-
- errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "check_crc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void check_crc(HANDLE_CRC hCrcBuf, UInt32 bValue, Int32 nBits)
-{
- Int32 i;
- UInt32 bMask = (1UL << (nBits - 1));
-
- for (i = 0; i < nBits; i++, bMask >>= 1)
- {
- UInt16 flag = (UInt16)((hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0);
- UInt16 flag1 = (UInt16)((bMask & bValue) ? 1 : 0);
-
- flag ^= flag1;
- hCrcBuf->crcState <<= 1;
- if (flag)
- hCrcBuf->crcState ^= hCrcBuf->crcPoly;
- }
-
-}
-
diff --git a/media/libstagefright/codecs/aacdec/check_crc.h b/media/libstagefright/codecs/aacdec/check_crc.h
deleted file mode 100644
index 9293d47..0000000
--- a/media/libstagefright/codecs/aacdec/check_crc.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: check_crc.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CHECK_CRC_H
-#define CHECK_CRC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_crc_buffer.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- void check_crc(HANDLE_CRC hCrcBuf,
- UInt32 bValue,
- Int32 nBits);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/dct16.cpp b/media/libstagefright/codecs/aacdec/dct16.cpp
deleted file mode 100644
index 75bd4ba..0000000
--- a/media/libstagefright/codecs/aacdec/dct16.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: dct16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 16
-
- Int32 flag 1 forward dct16, 0 modified dct-16
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement dct of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "dct16.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dct_16(Int32 vec[], Int flag)
-{
- Int32 tmp0;
- Int32 tmp1;
- Int32 tmp2;
- Int32 tmp3;
- Int32 tmp4;
- Int32 tmp5;
- Int32 tmp6;
- Int32 tmp7;
- Int32 tmp_o0;
- Int32 tmp_o1;
- Int32 tmp_o2;
- Int32 tmp_o3;
- Int32 tmp_o4;
- Int32 tmp_o5;
- Int32 tmp_o6;
- Int32 tmp_o7;
- Int32 itmp_e0;
- Int32 itmp_e1;
- Int32 itmp_e2;
-
- /* split input vector */
-
-
- tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F));
- tmp0 = vec[ 0] + vec[15];
-
- tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F));
- tmp7 = vec[ 7] + vec[ 8];
-
- itmp_e0 = (tmp0 + tmp7);
- tmp7 = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F));
-
- tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F));
- tmp1 = vec[ 1] + vec[14];
- tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F));
- tmp6 = vec[ 6] + vec[ 9];
-
- itmp_e1 = (tmp1 + tmp6);
- tmp6 = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F));
-
- tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F));
- tmp2 = vec[ 2] + vec[13];
- tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F));
- tmp5 = vec[ 5] + vec[10];
-
- itmp_e2 = (tmp2 + tmp5);
- tmp5 = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F));
-
- tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F));
- tmp3 = vec[ 3] + vec[12];
- tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F));
- tmp4 = vec[ 4] + vec[11];
-
- tmp1 = (tmp3 + tmp4);
- tmp4 = fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F));
-
- /* split even part of tmp_e */
-
- tmp0 = (itmp_e0 + tmp1);
- tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F));
-
-
- tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F));
- tmp2 = (itmp_e1 + itmp_e2);
-
- vec[ 0] = (tmp0 + tmp2) >> 1;
- vec[ 8] = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F));
- vec[12] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
- vec[ 4] = tmp1 + tmp3;
- vec[ 4] += vec[12];
-
- /* split odd part of tmp_e */
-
- tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
- tmp7 += tmp4;
- tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
-
- tmp6 += tmp5;
-
- vec[10] = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F));
- vec[ 2] = tmp7 + tmp6;
- vec[14] = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
-
- tmp1 += tmp3 + vec[14];
- vec[ 2] += tmp1;
- vec[ 6] = tmp1 + vec[10];
-
- vec[10] += vec[14];
-
-
- // dct8;
-
- tmp7 = tmp_o0 + tmp_o7;
- tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F));
-
- tmp6 = tmp_o1 + tmp_o6;
- tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F));
-
- tmp5 = tmp_o2 + tmp_o5;
- tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F));
-
- tmp4 = tmp_o3 + tmp_o4;
-
- tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F));
-
- if (!flag)
- {
- tmp7 = -tmp7;
- tmp_o7 = -tmp_o7;
- tmp6 = -tmp6;
- tmp_o1 = -tmp_o1;
- tmp5 = -tmp5;
- tmp_o5 = -tmp_o5;
- tmp4 = -tmp4;
- tmp_o3 = -tmp_o3;
- }
-
- // even part
-
- tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
- tmp0 = tmp7 + tmp4;
- tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
- tmp2 = tmp6 + tmp5;
-
- vec[ 9] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
- vec[ 1] = tmp0 + tmp2;
- vec[13] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
-
- vec[ 5] = tmp1 + tmp3 + vec[13];
-
- // odd part
-
- tmp0 = tmp_o7 + tmp_o3;
- tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F));
- tmp2 = tmp_o1 + tmp_o5;
- tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F));
-
- vec[11] = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
- vec[ 3] = tmp0 + tmp2;
- vec[15] = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
- vec[ 7] = tmp1 + tmp3 + vec[15];
-
-
- vec[ 3] += vec[ 7];
- vec[ 7] += vec[11];
- vec[11] += vec[15];
-
- vec[ 1] += vec[ 3];
- vec[ 3] += vec[ 5];
- vec[ 5] += vec[ 7];
- vec[ 7] += vec[ 9];
- vec[ 9] += vec[11];
- vec[11] += vec[13];
- vec[13] += vec[15];
-
-
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/dct16.h b/media/libstagefright/codecs/aacdec/dct16.h
deleted file mode 100644
index 6f8fcb2..0000000
--- a/media/libstagefright/codecs/aacdec/dct16.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dct16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DCT16_H
-#define DCT16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void dct_16(Int32 vec[], Int flag);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DCT16_H */
diff --git a/media/libstagefright/codecs/aacdec/dct64.cpp b/media/libstagefright/codecs/aacdec/dct64.cpp
deleted file mode 100644
index a21a814..0000000
--- a/media/libstagefright/codecs/aacdec/dct64.cpp
+++ /dev/null
@@ -1,569 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dct64.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 64
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement dct of lenght 64
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dct16.h"
-#include "dct64.h"
-
-#include "pv_audio_type_defs.h"
-#include "synthesis_sub_band.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt(a) (Int32)(a*((Int32)1<<26) + (a>=0?0.5F:-0.5F))
-#define Qfmt31(a) (Int32)(a*0x7FFFFFFF)
-
-const Int32 CosTable_48[48] =
-{
- Qfmt31(0.50015063602065F) , Qfmt31(0.50135845244641F) ,
- Qfmt31(0.50378872568104F) , Qfmt31(0.50747117207256F) ,
- Qfmt31(0.51245147940822F) , Qfmt31(0.51879271310533F) ,
- Qfmt31(0.52657731515427F) , Qfmt31(0.53590981690799F) ,
- Qfmt31(0.54692043798551F) , Qfmt31(0.55976981294708F) ,
- Qfmt31(0.57465518403266F) , Qfmt31(0.59181853585742F) ,
- Qfmt31(0.61155734788251F) , Qfmt31(0.63423893668840F) ,
- Qfmt31(0.66031980781371F) , Qfmt31(0.69037212820021F) ,
- Qfmt31(0.72512052237720F) , Qfmt31(0.76549416497309F) ,
- Qfmt31(0.81270209081449F) , Qfmt31(0.86834471522335F) ,
- Qfmt(0.93458359703641F) , Qfmt(1.01440826499705F) ,
- Qfmt(1.11207162057972F) , Qfmt(1.23383273797657F) ,
- Qfmt(1.38929395863283F) , Qfmt(1.59397228338563F) ,
- Qfmt(1.87467598000841F) , Qfmt(2.28205006800516F) ,
- Qfmt(2.92462842815822F) , Qfmt(4.08461107812925F) ,
- Qfmt(6.79675071167363F) , Qfmt(20.37387816723145F) , /* 32 */
- Qfmt(0.50060299823520F) , Qfmt(0.50547095989754F) ,
- Qfmt(0.51544730992262F) , Qfmt(0.53104259108978F) ,
- Qfmt(0.55310389603444F) , Qfmt(0.58293496820613F) ,
- Qfmt(0.62250412303566F) , Qfmt(0.67480834145501F) ,
- Qfmt(0.74453627100230F) , Qfmt(0.83934964541553F) ,
- Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) ,
- Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) ,
- Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F)
-};
-
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; dct_64
-----------------------------------------------------------------------------*/
-
-void pv_split_LC(Int32 *vector,
- Int32 *temp_o)
-{
-
- Int32 i;
- Int32 *pt_vector = &vector[0];
- Int32 *pt_vector_N_1 = &vector[31];
- const Int32 *pt_cosTerms = &CosTable_48[32];
- Int32 *pt_temp_o = temp_o;
- Int32 tmp1;
- Int32 tmp2;
- Int32 tmp3;
-
-
- tmp1 = *(pt_vector);
- tmp2 = *(pt_vector_N_1--);
- for (i = 16; i != 0; i--)
- {
- tmp3 = *(pt_cosTerms++);
- *(pt_vector++) = tmp1 + tmp2;
- *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), tmp3);
- tmp1 = *(pt_vector);
- tmp2 = *(pt_vector_N_1--);
- }
-
-}
-
-
-#ifdef HQ_SBR
-
-
-void dct_64(Int32 vec[], Int32 *scratch_mem)
-{
- Int32 *temp_e1;
- Int32 *temp_o1;
-
- Int32 *pt_vec;
-
- Int i;
-
- Int32 aux1;
- Int32 aux2;
- Int32 aux3;
- Int32 aux4;
-
- const Int32 *cosTerms = &CosTable_48[31];
-
- temp_o1 = &vec[32];
- temp_e1 = temp_o1 - 1;
-
-
- for (i = 6; i != 0; i--)
- {
- aux1 = *(temp_e1);
- aux2 = *(temp_o1);
- aux3 = *(cosTerms--);
- *(temp_e1--) = aux1 + aux2;
- *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
- aux1 = *(temp_e1);
- aux2 = *(temp_o1);
- aux3 = *(cosTerms--);
- *(temp_e1--) = aux1 + aux2;
- *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
- }
-
-
- for (i = 10; i != 0; i--)
- {
- aux1 = *(temp_e1);
- aux2 = *(temp_o1);
- aux3 = *(cosTerms--);
- *(temp_e1--) = aux1 + aux2;
- *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
- aux1 = *(temp_e1);
- aux2 = *(temp_o1);
- aux3 = *(cosTerms--);
- *(temp_e1--) = aux1 + aux2;
- *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
- }
-
-
- pv_split(&vec[16]);
-
- dct_16(&vec[16], 0);
- dct_16(vec, 1); // Even terms
-
- pv_merge_in_place_N32(vec);
-
- pv_split_z(&vec[32]);
-
- dct_16(&vec[32], 1); // Even terms
- dct_16(&vec[48], 0);
-
- pv_merge_in_place_N32(&vec[32]);
-
-
-
- aux1 = vec[32];
- aux3 = vec[33];
- aux4 = vec[ 1]; /* vec[ 1] */
-
- /* -----------------------------------*/
- aux1 = vec[32] + vec[33];
- vec[ 0] += aux1;
- vec[ 1] += aux1;
-
- aux1 = vec[34];
- aux2 = vec[ 2]; /* vec[ 2] */
- aux3 += aux1;
- vec[ 2] = aux4 + aux3;
- aux4 = vec[ 3]; /* vec[ 3] */
- vec[ 3] = aux2 + aux3;
-
- aux3 = vec[35];
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[32] = vec[ 4];
- vec[33] = vec[ 5];
- vec[ 4] = aux2 + aux1;
- vec[ 5] = aux4 + aux1;
-
- aux1 = vec[36];
- aux2 = vec[32]; /* vec[ 4] */
- aux3 += aux1;
- vec[34] = vec[ 6];
- vec[35] = vec[ 7];
- vec[ 6] = aux4 + aux3;
- vec[ 7] = aux2 + aux3;
-
- aux3 = vec[37];
- aux4 = vec[33]; /* vec[ 5] */
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[32] = vec[ 8];
- vec[33] = vec[ 9];
- vec[ 8] = aux2 + aux1;
- vec[ 9] = aux4 + aux1;
-
- aux1 = vec[38];
- aux2 = vec[34]; /* vec[ 6] */
- aux3 += aux1;
- vec[34] = vec[10];
- vec[10] = aux4 + aux3;
- aux4 = vec[35]; /* vec[ 7] */
- vec[35] = vec[11];
- vec[11] = aux2 + aux3;
-
- aux3 = vec[39];
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[36] = vec[12];
- vec[37] = vec[13];
- vec[12] = aux2 + aux1;
- vec[13] = aux4 + aux1;
-
- aux1 = vec[40];
- aux2 = vec[32]; /* vec[ 8] */
- aux3 += aux1;
- vec[32] = vec[14];
- vec[14] = aux4 + aux3;
- aux4 = vec[33]; /* vec[ 9] */
- vec[33] = vec[15];
- vec[15] = aux2 + aux3;
-
- aux3 = vec[41];
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[38] = vec[16];
- vec[39] = vec[17];
- vec[16] = aux2 + aux1;
- vec[17] = aux4 + aux1;
-
- aux1 = vec[42];
- aux2 = vec[34]; /* vec[10] */
- aux3 += aux1;
- vec[34] = vec[18];
- vec[18] = aux4 + aux3;
- aux4 = vec[35]; /* vec[11] */
- vec[35] = vec[19];
- vec[19] = aux2 + aux3;
-
- aux3 = vec[43];
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[40] = vec[20];
- vec[41] = vec[21];
- vec[20] = aux2 + aux1;
- vec[21] = aux4 + aux1;
-
- aux1 = vec[44];
- aux2 = vec[36]; /* vec[12] */
- aux3 += aux1;
- vec[42] = vec[22];
- vec[43] = vec[23];
- vec[22] = aux4 + aux3;
- vec[23] = aux2 + aux3;
-
- aux3 = vec[45];
- aux4 = vec[37]; /* vec[13] */
-
- /* -----------------------------------*/
-
-
- scratch_mem[0] = vec[24];
- scratch_mem[1] = vec[25];
- aux1 += aux3;
- vec[24] = aux2 + aux1;
- vec[25] = aux4 + aux1;
-
- aux1 = vec[46];
- aux2 = vec[32]; /* vec[14] */
- scratch_mem[2] = vec[26];
- scratch_mem[3] = vec[27];
- aux3 += aux1;
- vec[26] = aux4 + aux3;
- vec[27] = aux2 + aux3;
-
- aux3 = vec[47];
- aux4 = vec[33]; /* vec[15] */
-
- /* -----------------------------------*/
- scratch_mem[4] = vec[28];
- scratch_mem[5] = vec[29];
- aux1 += aux3;
- vec[28] = aux2 + aux1;
- vec[29] = aux4 + aux1;
-
- aux1 = vec[48];
- aux2 = vec[38]; /* vec[16] */
- scratch_mem[6] = vec[30];
- scratch_mem[7] = vec[31];
- aux3 += aux1;
- vec[30] = aux4 + aux3;
- vec[31] = aux2 + aux3;
-
- aux3 = vec[49];
- aux4 = vec[39]; /* vec[17] */
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[32] = aux2 + aux1;
- vec[33] = aux4 + aux1;
-
- aux1 = vec[50];
- aux2 = vec[34]; /* vec[18] */
- aux3 += aux1;
- vec[34] = aux4 + aux3;
- aux4 = vec[35]; /* vec[19] */
- vec[35] = aux2 + aux3;
-
- aux3 = vec[51];
-
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[36] = aux2 + aux1;
- vec[37] = aux4 + aux1;
-
- aux1 = vec[52];
- aux2 = vec[40]; /* vec[20] */
- aux3 += aux1;
- vec[38] = aux4 + aux3;
- vec[39] = aux2 + aux3;
-
- aux3 = vec[53];
- aux4 = vec[41]; /* vec[21] */
-
- /* -----------------------------------*/
- aux1 += aux3;
- vec[40] = aux2 + aux1;
- vec[41] = aux4 + aux1;
-
- aux1 = vec[54];
- aux2 = vec[42]; /* vec[22] */
- aux3 += aux1;
- vec[42] = aux4 + aux3;
- aux4 = vec[43]; /* vec[23] */
- vec[43] = aux2 + aux3;
-
- aux3 = vec[55];
-
- /* -----------------------------------*/
-
- pt_vec = &vec[44];
- temp_o1 = &vec[56];
- temp_e1 = &scratch_mem[0];
-
- for (i = 4; i != 0; i--)
- {
- aux1 += aux3;
- *(pt_vec++) = aux2 + aux1;
- *(pt_vec++) = aux4 + aux1;
-
- aux1 = *(temp_o1++);
- aux3 += aux1;
- aux2 = *(temp_e1++);
- *(pt_vec++) = aux4 + aux3;
- *(pt_vec++) = aux2 + aux3;
-
- aux3 = *(temp_o1++);
- aux4 = *(temp_e1++);
- }
-
- aux1 += aux3;
- vec[60] = aux2 + aux1;
- vec[61] = aux4 + aux1;
- vec[62] = aux4 + aux3;
-
-}
-
-
-#endif
-
-/*----------------------------------------------------------------------------
-; pv_split
-----------------------------------------------------------------------------*/
-
-
-void pv_split(Int32 *temp_o)
-{
-
- Int32 i;
- const Int32 *pt_cosTerms = &CosTable_48[47];
- Int32 *pt_temp_o = temp_o;
- Int32 *pt_temp_e = pt_temp_o - 1;
- Int32 tmp1;
- Int32 tmp2;
- Int32 cosx;
-
- for (i = 8; i != 0; i--)
- {
- tmp2 = *(pt_temp_o);
- tmp1 = *(pt_temp_e);
- cosx = *(pt_cosTerms--);
- *(pt_temp_e--) = tmp1 + tmp2;
- *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
- tmp1 = *(pt_temp_e);
- tmp2 = *(pt_temp_o);
- cosx = *(pt_cosTerms--);
- *(pt_temp_e--) = tmp1 + tmp2;
- *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
- }
-}
-
-
-
-void pv_split_z(Int32 *vector)
-{
- Int32 i;
- Int32 *pt_vector = &vector[31];
- const Int32 *pt_cosTerms = &CosTable_48[32];
- Int32 *pt_temp_e = vector;
- Int32 tmp1;
- Int32 tmp2;
- Int32 cosx;
-
- for (i = 8; i != 0; i--)
- {
- tmp1 = *(pt_vector);
- tmp2 = *(pt_temp_e);
- cosx = *(pt_cosTerms++);
- *(pt_temp_e++) = tmp1 + tmp2;
- *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
- tmp2 = *(pt_temp_e);
- tmp1 = *(pt_vector);
- cosx = *(pt_cosTerms++);
- *(pt_temp_e++) = tmp1 + tmp2;
- *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
- }
-}
-
-
-void pv_merge_in_place_N32(Int32 vec[])
-{
-
- Int32 temp[4];
-
- temp[0] = vec[14];
- vec[14] = vec[ 7];
- temp[1] = vec[12];
- vec[12] = vec[ 6];
- temp[2] = vec[10];
- vec[10] = vec[ 5];
- temp[3] = vec[ 8];
- vec[ 8] = vec[ 4];
- vec[ 6] = vec[ 3];
- vec[ 4] = vec[ 2];
- vec[ 2] = vec[ 1];
-
- vec[ 1] = vec[16] + vec[17];
- vec[16] = temp[3];
- vec[ 3] = vec[18] + vec[17];
- vec[ 5] = vec[19] + vec[18];
- vec[18] = vec[9];
- temp[3] = vec[11];
-
- vec[ 7] = vec[20] + vec[19];
- vec[ 9] = vec[21] + vec[20];
- vec[20] = temp[2];
- temp[2] = vec[13];
- vec[11] = vec[22] + vec[21];
- vec[13] = vec[23] + vec[22];
- vec[22] = temp[3];
- temp[3] = vec[15];
- vec[15] = vec[24] + vec[23];
- vec[17] = vec[25] + vec[24];
- vec[19] = vec[26] + vec[25];
- vec[21] = vec[27] + vec[26];
- vec[23] = vec[28] + vec[27];
- vec[25] = vec[29] + vec[28];
- vec[27] = vec[30] + vec[29];
- vec[29] = vec[30] + vec[31];
- vec[24] = temp[1];
- vec[26] = temp[2];
- vec[28] = temp[0];
- vec[30] = temp[3];
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/dct64.h b/media/libstagefright/codecs/aacdec/dct64.h
deleted file mode 100644
index 3d5e82b..0000000
--- a/media/libstagefright/codecs/aacdec/dct64.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dct64.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DCT64_H
-#define DCT64_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
- extern const Int32 CosTable_48[48];
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void pv_split_LC(Int32 *vector,
- Int32 *temp_o);
-
-
-#ifdef HQ_SBR
-
- void dct_64(Int32 vec[], Int32 *scratch_mem);
-
-#endif
-
- void pv_split(Int32 *temp_o);
-
- void pv_split_z(Int32 *vector);
-
- void pv_merge_in_place_N32(Int32 vec[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DCT64_H */
diff --git a/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp b/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp
deleted file mode 100644
index 0d1561b..0000000
--- a/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp
+++ /dev/null
@@ -1,708 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/decode_huff_cw_binary.c
- Funtions:
- decode_huff_cw_tab1
- decode_huff_cw_tab2
- decode_huff_cw_tab3
- decode_huff_cw_tab4
- decode_huff_cw_tab5
- decode_huff_cw_tab6
- decode_huff_cw_tab7
- decode_huff_cw_tab8
- decode_huff_cw_tab9
- decode_huff_cw_tab10
- decode_huff_cw_tab11
- decode_huff_cw_scl
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated per review comments
- (1) make cw sgined and change "if(cw&0x80000000)" to if(cw<0)
- (2)
-
- Description: Create specific functions for different huffman tables.
-
-
- Description: Added ( Int16) castings to eliminate several compiler warnings
-
-
- Description: Modified huffman tables to allocate int32 variables instead of
- int16, which lead to data missaligned for some compiler.
- Eliminated casting and unused variables
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- BITS *pInputStream = pointer to input bit stream
-
- Local Stores/Buffers/Pointers Needed:
-
-
- Global Stores/Buffers/Pointers Needed:
-
-
- Outputs:
- idx = bit field extracted from a leaf entry of packed Huffman Tables
-
- Pointers and Buffers Modified:
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- These functions are used to decode huffman codewords from the input
- bitstream using combined binary search and look-up table approach.
-
- First the codewords are grouped and the input symbol is determined
- which group it belongs. Then within that group, a look-up table is
- used to determine which codeword the symbol is.
- The table is created by ordering the codeword in the table according to their
- normalized shifted binary value, i.e., all the codewords are left
- shifted to meet the maximum codelength. Example, max codelength is
- 10, the codeword with lenth 3 will left shift by 7.
- The binary values of after the shift are sorted.
- Then the sorted table is divided into several partition.
- At the VLC decoding period, input is read in at max codelenght.
- The partition is decided using if-else logic.
- Inside each partition, a look-up table is used to map the input value
- to a correct symbol. Table entries can appear to be repeated according
- to the humming distance between adjacent codewords.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) Introduction to Algorithms,
- Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest.
- The MIT press, 1990
-
- (3) "Selecting an Optimal Huffman Decoder for AAC",
- Vladimir Z. Mesarovic, et al.
- AES 111th Convention, September 21-24, 2001, New York, USA
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define MAX_CW_LEN (19)
-#define MASK_IDX (0x1FF)
-#define MASK_RIGHT (0xFE00)
-
-#define UPPER16 (16)
-#define MASK_LOW16 (0xFFFF)
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int decode_huff_cw_tab1(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 11,
- pInputStream);
- if ((cw >> 10) == 0)
- {
- pInputStream->usedBits -= (11 - 1);
- return 40; /* idx is 40 */
- }
- else if ((cw >> 6) <= 23)
- {
- tab = (cw >> 6) - 16;
- }
- else if ((cw >> 4) <= 119)
- {
- tab = (cw >> 4) - 96 + 8;
- }
- else if ((cw >> 2) <= 503)
- {
- tab = (cw >> 2) - 480 + 32;
- }
- else
- {
- tab = cw - 2016 + 56;
- }
-
- tab = *(huff_tab1 + tab);
-
- pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab2(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get9_n_lessbits(
- 9,
- pInputStream);
- if ((cw >> 6) == 0)
- {
- pInputStream->usedBits -= (9 - 3); /* used 3 bits */
- return 40; /* idx is 40 */
- }
- else if ((cw >> 3) <= 49)
- {
- tab = (cw >> 3) - 8;
- }
- else if ((cw >> 2) <= 114)
- {
- tab = (cw >> 2) - 100 + 42;
- }
- else if ((cw >> 1) <= 248)
- {
- tab = (cw >> 1) - 230 + 57;
- }
- else
- {
- tab = cw - 498 + 76;
- }
-
- tab = *(huff_tab2 + tab);
-
- pInputStream->usedBits -= (9 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab3(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 16,
- pInputStream);
- if ((cw >> 15) == 0)
- {
- pInputStream->usedBits -= (16 - 1); /* used 1 bits */
- return 0; /* idx is 0 */
- }
- else if ((cw >> 10) <= 57)
- {
- tab = (cw >> 10) - 32;
- }
- else if ((cw >> 7) <= 500)
- {
- tab = (cw >> 7) - 464 + 26;
- }
- else if ((cw >> 6) <= 1016)
- {
- tab = (cw >> 6) - 1002 + 63;
- }
- else if ((cw >> 4) <= 4092)
- {
- tab = (cw >> 4) - 4068 + 78;
- }
- else
- {
- tab = cw - 65488 + 103;
- }
-
- tab = *(huff_tab3 + tab);
-
- pInputStream->usedBits -= (16 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab4(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 12,
- pInputStream);
-
- if ((cw >> 7) <= 25)
- {
- tab = (cw >> 7);
- }
- else if ((cw >> 4) <= 246)
- {
- tab = (cw >> 4) - 208 + 26;
- }
- else if ((cw >> 2) <= 1017)
- {
- tab = (cw >> 2) - 988 + 65;
- }
- else
- {
- tab = cw - 4072 + 95;
- }
-
- tab = *(huff_tab4 + tab);
-
- pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab5(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 13,
- pInputStream);
-
- if ((cw >> 12) == 0)
- {
- pInputStream->usedBits -= (13 - 1); /* used 1 bits */
- return 40; /* idx is 40 */
- }
- else if ((cw >> 8) <= 27)
- {
- tab = (cw >> 8) - 16;
- }
- else if ((cw >> 5) <= 243)
- {
- tab = (cw >> 5) - 224 + 12;
- }
- else if ((cw >> 3) <= 1011)
- {
- tab = (cw >> 3) - 976 + 32;
- }
- else if ((cw >> 2) <= 2041)
- {
- tab = (cw >> 2) - 2024 + 68;
- }
- else
- {
- tab = cw - 8168 + 86;
- }
-
- tab = *(huff_tab5 + tab);
-
- pInputStream->usedBits -= (13 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab6(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 11,
- pInputStream);
-
- if ((cw >> 7) <= 8)
- {
- tab = (cw >> 7);
- }
- else if ((cw >> 4) <= 116)
- {
- tab = (cw >> 4) - 72 + 9;
- }
- else if ((cw >> 2) <= 506)
- {
- tab = (cw >> 2) - 468 + 54;
- }
- else
- {
- tab = cw - 2028 + 93;
- }
-
- tab = *(huff_tab6 + tab);
-
- pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab7(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 12,
- pInputStream);
-
- if ((cw >> 11) == 0)
- {
- pInputStream->usedBits -= (12 - 1); /* used 1 bits */
- return 0; /* idx is 0 */
- }
- else if ((cw >> 6) <= 55)
- {
- tab = (cw >> 6) - 32;
- }
- else if ((cw >> 4) <= 243)
- {
- tab = (cw >> 4) - 224 + 24;
- }
- else if ((cw >> 2) <= 1018)
- {
- tab = (cw >> 2) - 976 + 44;
- }
- else
- {
- tab = cw - 4076 + 87;
- }
-
- tab = *(huff_tab7 + tab);
-
- pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab8(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 10,
- pInputStream);
-
- if ((cw >> 5) <= 20)
- {
- tab = (cw >> 5);
- }
- else if ((cw >> 3) <= 117)
- {
- tab = (cw >> 3) - 84 + 21;
- }
- else if ((cw >> 2) <= 250)
- {
- tab = (cw >> 2) - 236 + 55;
- }
- else
- {
- tab = cw - 1004 + 70;
- }
-
- tab = *(huff_tab8 + tab);
-
- pInputStream->usedBits -= (10 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab9(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 15,
- pInputStream);
-
- if ((cw >> 11) <= 12)
- {
- tab = (cw >> 11);
- }
- else if ((cw >> 8) <= 114)
- {
- tab = (cw >> 8) - 104 + 13;
- }
- else if ((cw >> 6) <= 486)
- {
- tab = (cw >> 6) - 460 + 24;
- }
- else if ((cw >> 5) <= 993)
- {
- tab = (cw >> 5) - 974 + 51;
- }
- else if ((cw >> 4) <= 2018)
- {
- tab = (cw >> 4) - 1988 + 71;
- }
- else if ((cw >> 3) <= 4075)
- {
- tab = (cw >> 3) - 4038 + 102;
- }
- else if ((cw >> 2) <= 8183)
- {
- tab = (cw >> 2) - 8152 + 140;
- }
- else
- {
- tab = cw - 32736 + 172;
- }
-
- tab = *(huff_tab9 + tab);
-
- pInputStream->usedBits -= (15 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab10(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 12,
- pInputStream);
-
- if ((cw >> 6) <= 41)
- {
- tab = (cw >> 6);
- }
- else if ((cw >> 5) <= 100)
- {
- tab = (cw >> 5) - 84 + 42;
- }
- else if ((cw >> 4) <= 226)
- {
- tab = (cw >> 4) - 202 + 59;
- }
- else if ((cw >> 3) <= 484)
- {
- tab = (cw >> 3) - 454 + 84;
- }
- else if ((cw >> 2) <= 1010)
- {
- tab = (cw >> 2) - 970 + 115;
- }
- else if ((cw >> 1) <= 2043)
- {
- tab = (cw >> 1) - 2022 + 156;
- }
- else
- {
- tab = cw - 4088 + 178;
- }
-
- tab = *(huff_tab10 + tab);
-
- pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab11(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = get17_n_lessbits(
- 12,
- pInputStream);
-
- if ((cw >> 6) <= 26)
- {
- tab = (cw >> 6);
- }
- else if ((cw >> 5) <= 69)
- {
- tab = (cw >> 5) - 54 + 27;
- }
- else if ((cw >> 4) <= 198)
- {
- tab = (cw >> 4) - 140 + 43;
- }
- else if ((cw >> 3) <= 452)
- {
- tab = (cw >> 3) - 398 + 102;
- }
- else if ((cw >> 2) <= 1000)
- {
- tab = (cw >> 2) - 906 + 157;
- }
- else if ((cw >> 1) <= 2044)
- {
- tab = (cw >> 1) - 2002 + 252;
- }
- else
- {
- tab = cw - 4090 + 295;
- }
-
- tab = *(huff_tab11 + tab);
-
- pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_scl(
- BITS *pInputStream)
-{
- Int32 tab;
- Int32 cw;
-
- cw = getbits(
- 19,
- pInputStream);
-
- if ((cw >> 18) == 0)
- {
- pInputStream->usedBits -= (19 - 1); /* used 1 bits */
- return 60; /* idx is 60 */
- }
- else if ((cw >> 13) <= 59)
- {
- tab = (cw >> 13) - 32;
- }
- else if ((cw >> 10) <= 505)
- {
- tab = (cw >> 10) - 480 + 28;
- }
- else if ((cw >> 7) <= 4089)
- {
- tab = (cw >> 7) - 4048 + 54;
- }
- else if ((cw >> 5) <= 16377)
- {
- tab = (cw >> 5) - 16360 + 96;
- }
- else if ((cw >> 3) <= 65526)
- {
- tab = (cw >> 3) - 65512 + 114;
- }
- else if ((cw >> 1) <= 262120)
- {
- tab = (cw >> 1) - 262108 + 129;
- }
- else
- {
- tab = cw - 524242 + 142;
- }
-
- tab = *(huff_tab_scl + tab);
-
- pInputStream->usedBits -= (19 - (tab & MASK_LOW16));
- return ((Int)(tab >> UPPER16));
-}
-
diff --git a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp b/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp
deleted file mode 100644
index 41cd187..0000000
--- a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: decode_noise_floorlevels.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "decode_noise_floorlevels.h"
-#include "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData)
-
-{
- Int32 env;
- Int32 i;
-
- Int32 * frameInfo = hFrameData->frameInfo;
- Int32 nNfb = hFrameData->nNfb;
- Int32 * domain_vec = hFrameData->domain_vec2;
-
- Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
- Int32 * prevNoiseLevel_man = hFrameData->prevNoiseLevel_man;
-
- Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3];
-
- for (env = 0; env < nEnv; env++)
- {
- if (domain_vec[env] == 0)
- {
- prevNoiseLevel_man[0] = *(sbrNoiseFloorLevel_man++);
-
- for (i = 1; i < nNfb; i++)
- {
- *sbrNoiseFloorLevel_man += *(sbrNoiseFloorLevel_man - 1);
- prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
- }
- }
- else
- {
- for (i = 0; i < nNfb; i++)
- {
- *sbrNoiseFloorLevel_man += prevNoiseLevel_man[i];
- prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
- }
- }
-
- }
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h b/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h
deleted file mode 100644
index a9c3551..0000000
--- a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: decode_noise_floorlevels.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef DECODENOISEFLOORLEVELS_H
-#define DECODENOISEFLOORLEVELS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/deinterleave.cpp b/media/libstagefright/codecs/aacdec/deinterleave.cpp
deleted file mode 100644
index 5298b19..0000000
--- a/media/libstagefright/codecs/aacdec/deinterleave.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/deinterleave.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: (1) Modified with new template, rename variables
- (2) Removed for-loop to calculate win_inc, win_inc = SN2 (128)
- (3) Replaced for-loop with memcpy
- (4) Converted Int16 -> Int
-
- Description: Modified per review comments
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- interleaved = input array that contains interleaved coefficients
- Data Type Int
-
- deinterleaved = output array that will be updated with de-interleaved
- coefficients of input array. Data Type Int
-
- pFrameInfo = pointer to structure that holds information of current
- frame. Data Type FrameInfo
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- deinterleaved contents updated with de-interleaved coefficients from
- the input array: interleaved
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs the deinterleaving across all short windows in
- each group
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the contents of pDeinterleaved with the
- de-interleaved 1024 coefficients of one frame
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p78 quant_to_spec
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pInterleaved = interleaved;
- pDeinterleaved = deinterleaved;
-
- pSfbPerWin = pFrameInfo->sfb_per_win;
- ngroups = pFrameInfo->num_groups;
- pGroupLen = pFrameInfo->group_len;
-
- pGroup = pDeinterleaved;
-
- FOR (group = ngroups; group > 0; group--)
-
- pSfbWidth = pFrameInfo->sfb_width_128;
- sfb_inc = 0;
- pStart = pInterleaved;
-
- FOR (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
-
- pWin = pGroup;
-
- FOR (win = pGroupLen[ngroups-group]; win > 0; win--)
-
- pDeinterleaved = pWin + sfb_inc;
-
- pv_memcpy(
- pDeinterleaved,
- pInterleaved,
- *pSfbWidth*sizeof(*pInterleaved));
-
- pInterleaved += *pSfbWidth;
-
- pWin += SN2;
-
- ENDFOR (win)
-
- sfb_inc += *pSfbWidth++;
-
- ENDFOR (sfb)
-
- pGroup += (pInterleaved - pStart);
-
- ENDFOR (group)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void deinterleave(
- Int16 interleaved[],
- Int16 deinterleaved[],
- FrameInfo *pFrameInfo)
-{
-
- Int group; /* group index */
- Int sfb; /* scalefactor band index */
- Int win; /* window index */
- Int16 *pGroup;
- Int16 *pWin;
- Int16 *pStart;
- Int16 *pInterleaved;
- Int16 *pDeinterleaved;
- Int sfb_inc;
-
- Int ngroups;
- Int *pGroupLen;
- Int *pSfbPerWin;
- Int *pSfbWidth;
-
- pInterleaved = interleaved;
- pDeinterleaved = deinterleaved;
-
- pSfbPerWin = pFrameInfo->sfb_per_win;
- ngroups = pFrameInfo->num_groups;
- pGroupLen = pFrameInfo->group_len;
-
- pGroup = pDeinterleaved;
-
- for (group = ngroups; group > 0; group--)
- {
- pSfbWidth = pFrameInfo->sfb_width_128;
- sfb_inc = 0;
- pStart = pInterleaved;
-
- /* Perform the deinterleaving across all windows in a group */
-
- for (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
- {
- pWin = pGroup;
-
- for (win = pGroupLen[ngroups-group]; win > 0; win--)
- {
- pDeinterleaved = pWin + sfb_inc;
-
- pv_memcpy(
- pDeinterleaved,
- pInterleaved,
- *pSfbWidth*sizeof(*pInterleaved));
-
- pInterleaved += *pSfbWidth;
-
- pWin += SN2;
-
- } /* for (win) */
-
- sfb_inc += *pSfbWidth++;
-
- } /* for (sfb) */
-
- pGroup += (pInterleaved - pStart);
-
- } /* for (group) */
-
-} /* deinterleave */
diff --git a/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp b/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp
deleted file mode 100644
index ffa980d..0000000
--- a/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/digit_reversal_tables.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
- ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
- Tables for digit reverse operation
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
-------------------------------------------------------------------------------
- Digit Reverse tables
-------------------------------------------------------------------------------
-*/
-
-const Int16 digit_reverse_64[ 64] =
-{
- + 0, + 32, + 64, + 96,
- + 8, + 40, + 72, + 104,
- + 16, + 48, + 80, + 112,
- + 24, + 56, + 88, + 120,
- + 2, + 34, + 66, + 98,
- + 10, + 42, + 74, + 106,
- + 18, + 50, + 82, + 114,
- + 26, + 58, + 90, + 122,
- + 4, + 36, + 68, + 100,
- + 12, + 44, + 76, + 108,
- + 20, + 52, + 84, + 116,
- + 28, + 60, + 92, + 124,
- + 6, + 38, + 70, + 102,
- + 14, + 46, + 78, + 110,
- + 22, + 54, + 86, + 118,
- + 30, + 62, + 94, + 126
-};
-
-
-const Int16 digit_reverse_256[ 256] =
-{
- + 0, + 128, + 256, + 384,
- + 32, + 160, + 288, + 416,
- + 64, + 192, + 320, + 448,
- + 96, + 224, + 352, + 480,
- + 8, + 136, + 264, + 392,
- + 40, + 168, + 296, + 424,
- + 72, + 200, + 328, + 456,
- + 104, + 232, + 360, + 488,
- + 16, + 144, + 272, + 400,
- + 48, + 176, + 304, + 432,
- + 80, + 208, + 336, + 464,
- + 112, + 240, + 368, + 496,
- + 24, + 152, + 280, + 408,
- + 56, + 184, + 312, + 440,
- + 88, + 216, + 344, + 472,
- + 120, + 248, + 376, + 504,
- + 2, + 130, + 258, + 386,
- + 34, + 162, + 290, + 418,
- + 66, + 194, + 322, + 450,
- + 98, + 226, + 354, + 482,
- + 10, + 138, + 266, + 394,
- + 42, + 170, + 298, + 426,
- + 74, + 202, + 330, + 458,
- + 106, + 234, + 362, + 490,
- + 18, + 146, + 274, + 402,
- + 50, + 178, + 306, + 434,
- + 82, + 210, + 338, + 466,
- + 114, + 242, + 370, + 498,
- + 26, + 154, + 282, + 410,
- + 58, + 186, + 314, + 442,
- + 90, + 218, + 346, + 474,
- + 122, + 250, + 378, + 506,
- + 4, + 132, + 260, + 388,
- + 36, + 164, + 292, + 420,
- + 68, + 196, + 324, + 452,
- + 100, + 228, + 356, + 484,
- + 12, + 140, + 268, + 396,
- + 44, + 172, + 300, + 428,
- + 76, + 204, + 332, + 460,
- + 108, + 236, + 364, + 492,
- + 20, + 148, + 276, + 404,
- + 52, + 180, + 308, + 436,
- + 84, + 212, + 340, + 468,
- + 116, + 244, + 372, + 500,
- + 28, + 156, + 284, + 412,
- + 60, + 188, + 316, + 444,
- + 92, + 220, + 348, + 476,
- + 124, + 252, + 380, + 508,
- + 6, + 134, + 262, + 390,
- + 38, + 166, + 294, + 422,
- + 70, + 198, + 326, + 454,
- + 102, + 230, + 358, + 486,
- + 14, + 142, + 270, + 398,
- + 46, + 174, + 302, + 430,
- + 78, + 206, + 334, + 462,
- + 110, + 238, + 366, + 494,
- + 22, + 150, + 278, + 406,
- + 54, + 182, + 310, + 438,
- + 86, + 214, + 342, + 470,
- + 118, + 246, + 374, + 502,
- + 30, + 158, + 286, + 414,
- + 62, + 190, + 318, + 446,
- + 94, + 222, + 350, + 478,
- + 126, + 254, + 382, + 510
-};
-
-
-
-
-const Int16 digit_reverse_swap_256[ 241] =
-{
- + 2, + 128, + 4, + 256,
- + 6, + 384, + 8, + 32,
- + 10, + 160, + 12, + 288,
- + 14, + 416, + 16, + 64,
- + 18, + 192, + 20, + 320,
- + 22, + 448, + 24, + 96,
- + 26, + 224, + 28, + 352,
- + 30, + 480, + 34, + 136,
- + 36, + 264, + 38, + 392,
- + 42, + 168, + 44, + 296,
- + 46, + 424, + 48, + 72,
- + 50, + 200, + 52, + 328,
- + 54, + 456, + 56, + 104,
- + 58, + 232, + 60, + 360,
- + 62, + 488, + 66, + 144,
- + 68, + 272, + 70, + 400,
- + 74, + 176, + 76, + 304,
- + 78, + 432, + 82, + 208,
- + 84, + 336, + 86, + 464,
- + 88, + 112, + 90, + 240,
- + 92, + 368, + 94, + 496,
- + 98, + 152, + 100, + 280,
- + 102, + 408, + 106, + 184,
- + 108, + 312, + 110, + 440,
- + 114, + 216, + 116, + 344,
- + 118, + 472, + 122, + 248,
- + 124, + 376, + 126, + 504,
- + 132, + 258, + 134, + 386,
- + 138, + 162, + 140, + 290,
- + 142, + 418, + 146, + 194,
- + 148, + 322, + 150, + 450,
- + 154, + 226, + 156, + 354,
- + 158, + 482, + 164, + 266,
- + 166, + 394, + 172, + 298,
- + 174, + 426, + 178, + 202,
- + 180, + 330, + 182, + 458,
- + 186, + 234, + 188, + 362,
- + 190, + 490, + 196, + 274,
- + 198, + 402, + 204, + 306,
- + 206, + 434, + 212, + 338,
- + 214, + 466, + 218, + 242,
- + 220, + 370, + 222, + 498,
- + 228, + 282, + 230, + 410,
- + 236, + 314, + 238, + 442,
- + 244, + 346, + 246, + 474,
- + 252, + 378, + 254, + 506,
- + 262, + 388, + 268, + 292,
- + 270, + 420, + 276, + 324,
- + 278, + 452, + 284, + 356,
- + 286, + 484, + 294, + 396,
- + 302, + 428, + 308, + 332,
- + 310, + 460, + 316, + 364,
- + 318, + 492, + 326, + 404,
- + 334, + 436, + 342, + 468,
- + 348, + 372, + 350, + 500,
- + 358, + 412, + 366, + 444,
- + 374, + 476, + 382, + 508,
- + 398, + 422, + 406, + 454,
- + 414, + 486, + 438, + 462,
- + 446, + 494, + 478, + 502
-};
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void digit_reversal_swapping(Int32 *y, Int32 *x);
-
-#ifdef __cplusplus
-}
-#endif
-
-void digit_reversal_swapping(Int32 *y, Int32 *x)
-{
- Int16 i, j;
- Int32 tmp[2];
- const Int16 *pTable;
-
- pTable = digit_reverse_swap_256;
-
- for (Int k = 120; k != 0; k--)
- {
- i = *pTable++;
- j = *pTable++;
- tmp[0] = y[i];
- tmp[1] = y[i+1];
- y[i] = y[j];
- y[i+1] = y[j+1];
- y[j] = tmp[0];
- y[j+1] = tmp[1];
-
- tmp[0] = x[j];
- tmp[1] = x[j+1];
- x[j] = x[i];
- x[j+1] = x[i+1];
- x[i] = tmp[0];
- x[i+1] = tmp[1];
-
- }
-
-}
diff --git a/media/libstagefright/codecs/aacdec/digit_reversal_tables.h b/media/libstagefright/codecs/aacdec/digit_reversal_tables.h
deleted file mode 100644
index 7fdaaf7..0000000
--- a/media/libstagefright/codecs/aacdec/digit_reversal_tables.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/DIGIT_REVERSAL_TABLES.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions digit_reversal_tables
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef DIGIT_REVERSAL_TABLES_H
-#define DIGIT_REVERSAL_TABLES_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int16 digit_reverse_64[];
-extern const Int16 digit_reverse_256[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* DIGIT_REVERSAL_TABLES_H */
diff --git a/media/libstagefright/codecs/aacdec/dst16.cpp b/media/libstagefright/codecs/aacdec/dst16.cpp
deleted file mode 100644
index 41c9259..0000000
--- a/media/libstagefright/codecs/aacdec/dst16.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 16
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement discrete sine transform of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "dst16.h"
-#include "dst8.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT 28
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 CosTable_8[8] =
-{
- Qfmt(0.50241928618816F), Qfmt(0.52249861493969F),
- Qfmt(0.56694403481636F), Qfmt(0.64682178335999F),
- Qfmt(0.78815462345125F), Qfmt(1.06067768599035F),
- Qfmt(1.72244709823833F), Qfmt(5.10114861868916F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dst_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */
-{
- Int32 *temp_even = scratch_mem;
-
- Int i;
- const Int32 *pt_cos = &CosTable_8[7];
- Int32 tmp0 = vec[15] >> 1;
- Int32 tmp1, tmp2;
- Int32 *pt_even = temp_even;
- Int32 *pt_odd = vec;
- Int32 *pt_vec = vec;
- Int32 *pt_vecN_1;
- Int32 tmp3;
-
-
- *(pt_even++) = *(pt_vec++);
- tmp1 = *(pt_vec++);
- *(pt_odd++) = tmp1;
-
- for (i = 3; i != 0; i--)
- {
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- tmp3 = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_odd++) = tmp3 + tmp2;
- tmp1 = tmp3;
-
- }
-
- *(pt_even) = *(pt_vec++);
- *(pt_odd++) = *(pt_vec) + tmp1;
-
-
- dst_8(temp_even);
- dst_8(vec);
-
- pt_vec = &vec[7];
-
- pt_even = &temp_even[7];
- pt_vecN_1 = &vec[8];
-
- tmp1 = *(pt_even--);
-
- for (i = 4; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vec--) = tmp3 + tmp1;
- *(pt_vecN_1++) = tmp3 - tmp1;
- tmp3 = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp3 - tmp2;
- *(pt_vec--) = tmp3 + tmp2;
- }
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst16.h b/media/libstagefright/codecs/aacdec/dst16.h
deleted file mode 100644
index bce73ba..0000000
--- a/media/libstagefright/codecs/aacdec/dst16.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST16_H
-#define DST16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void dst_16(Int32 vec[], Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DST16_H */
diff --git a/media/libstagefright/codecs/aacdec/dst32.cpp b/media/libstagefright/codecs/aacdec/dst32.cpp
deleted file mode 100644
index 5edecf1..0000000
--- a/media/libstagefright/codecs/aacdec/dst32.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst32.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 32
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement discrete sine transform of lenght 32
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dst32.h"
-#include "dst16.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT1 29
-#define Qfmt29(x) (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F))
-#define Qfmt31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-const Int32 CosTable_16[14] =
-{
- Qfmt31(0.50060299823520F), Qfmt31(0.50547095989754F),
- Qfmt31(0.51544730992262F), Qfmt31(0.53104259108978F),
- Qfmt31(0.55310389603444F), Qfmt31(0.58293496820613F),
- Qfmt31(0.62250412303566F), Qfmt31(0.67480834145501F),
- Qfmt31(0.74453627100230F), Qfmt31(0.83934964541553F),
- Qfmt29(0.97256823786196F), Qfmt29(1.16943993343288F),
- Qfmt29(1.48416461631417F), Qfmt29(2.05778100995341F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dst_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */
-{
- Int32 *temp_even = scratch_mem;
-
- Int32 i;
- const Int32 *pt_cos = &CosTable_16[13];
- Int32 tmp0 = vec[31] >> 1;
- Int32 tmp1, tmp2;
- Int32 *pt_even = temp_even;
- Int32 *pt_odd = vec;
- Int32 *pt_vec = vec;
- Int32 *pt_vecN_1 = vec;
- Int32 tmp3;
-
-
- tmp1 = 0;
-
- for (i = 5; i != 0; i--)
- {
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- tmp3 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_odd++) = tmp3 + tmp2;
- tmp1 = *(pt_vec++);
- *(pt_odd++) = tmp1 + tmp3;
- }
-
- *(pt_even) = *(pt_vec++);
- *(pt_odd) = *(pt_vec) + tmp1;
-
-
- dst_16(temp_even, &scratch_mem[16]);
- dst_16(vec, &scratch_mem[24]);
-
-
- pt_vecN_1 = &vec[16];
-
- tmp1 = temp_even[15];
-
- tmp3 = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2;
- tmp2 = temp_even[14];
- *(pt_vecN_1++) = tmp3 - tmp1;
- vec[15] = tmp3 + tmp1;
- tmp1 = temp_even[13];
- tmp3 = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F));
- *(pt_vecN_1++) = tmp3 - tmp2;
- vec[14] = tmp3 + tmp2;
-
- pt_even = &temp_even[12];
- pt_vec = &vec[13];
-
- for (i = 2; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vec--) = tmp3 + tmp1;
- *(pt_vecN_1++) = tmp3 - tmp1;
- tmp3 = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vec--) = tmp3 + tmp2;
- *(pt_vecN_1++) = tmp3 - tmp2;
- }
-
- for (i = 5; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q31((*(pt_vec) - tmp0) << 1, *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vec--) = tmp3 + tmp1;
- *(pt_vecN_1++) = tmp3 - tmp1;
- tmp3 = fxp_mul32_Q31((*(pt_vec) + tmp0) << 1, *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vec--) = tmp3 + tmp2;
- *(pt_vecN_1++) = tmp3 - tmp2;
- }
-
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst32.h b/media/libstagefright/codecs/aacdec/dst32.h
deleted file mode 100644
index c2bf1d2..0000000
--- a/media/libstagefright/codecs/aacdec/dst32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST32_H
-#define DST32_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
- extern const Int32 CosTable_16[];
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void dst_32(Int32 vec[], Int32 scratch_mem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DST32_H */
diff --git a/media/libstagefright/codecs/aacdec/dst8.cpp b/media/libstagefright/codecs/aacdec/dst8.cpp
deleted file mode 100644
index eaf8280..0000000
--- a/media/libstagefright/codecs/aacdec/dst8.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst8.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 8
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement discrete sine transform of lenght 8
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dst8.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT 29
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(x) (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F))
-
-
-void dst_8(Int32 vec[])
-{
-
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 temp5;
- Int32 temp6;
- Int32 temp7;
- Int32 tmp_a;
- Int32 tmp_aa;
- Int32 tmp_b;
- Int32 tmp_bb;
- Int32 tmp_c;
- Int32 tmp_cc;
- Int32 tmp_d;
- Int32 tmp_dd;
-
- temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/
- temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/
- temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/
- temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/
- temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F)); /* (1/(2*cos(6*phi)));*/
- temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F)); /* (1/(2*cos(7*phi)));*/
-
- /* even */
- tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F));
- tmp_b = (temp2 - temp6) + tmp_a;
-
- temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F));
- vec[0] = tmp_a + temp4;
- vec[1] = tmp_b + temp4;
- vec[2] = tmp_b - temp4;
- vec[3] = tmp_a - temp4;
-
-
- /* odd */
-
- tmp_a = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi))); */
- tmp_aa = (temp1 - temp7);
- tmp_bb = (temp5 - temp3);
- temp5 = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi))); */
-
-
- tmp_c = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F));
- tmp_cc = tmp_a - temp5;
-
- tmp_d = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c);
- tmp_dd = (tmp_aa + tmp_bb);
-
- tmp_dd += tmp_c;
- tmp_a = tmp_d + tmp_cc;
- vec[5] = tmp_a - vec[2];
- vec[2] += tmp_a;
-
- temp5 = tmp_dd + tmp_cc;
-
- vec[4] = temp5 - vec[3];
- vec[3] += temp5;
- vec[7] = tmp_c - vec[0];
- vec[0] += tmp_c;
- vec[6] = tmp_d - vec[1];
- vec[1] += tmp_d;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst8.h b/media/libstagefright/codecs/aacdec/dst8.h
deleted file mode 100644
index 2738e80..0000000
--- a/media/libstagefright/codecs/aacdec/dst8.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST8_H
-#define DST8_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void dst_8(Int32 vec[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* DST8_H */
diff --git a/media/libstagefright/codecs/aacdec/e_adif_const.h b/media/libstagefright/codecs/aacdec/e_adif_const.h
deleted file mode 100644
index 08b5415..0000000
--- a/media/libstagefright/codecs/aacdec/e_adif_const.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_ADIF_Const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for ADIF header related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_ADIF_CONST_H
-#define E_ADIF_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /*
- * audio data interchange format header
- */
- LEN_ADIF_ID = (32 / 8),
- LEN_COPYRT_PRES = 1,
- LEN_COPYRT_ID = (72 / 8),
- LEN_ORIG = 1,
- LEN_HOME = 1,
- LEN_BS_TYPE = 1,
- LEN_BIT_RATE = 23,
- LEN_NUM_PCE = 4,
- LEN_ADIF_BF = 20
-
-} eADIF_Const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_blockswitching.h b/media/libstagefright/codecs/aacdec/e_blockswitching.h
deleted file mode 100644
index bf6ad15..0000000
--- a/media/libstagefright/codecs/aacdec/e_blockswitching.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_BlockSwitching.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for BlockSwitching related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_BLOCK_SWITCHING_H
-#define E_BLOCK_SWITCHING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /*
- * block switching
- */
- LN = 2048,
- SN = 256,
- LN2 = LN / 2,
- SN2 = SN / 2,
- LN4 = LN / 4,
- SN4 = SN / 4,
- NSHORT = LN / SN,
- MAX_SBK = NSHORT,
- MAX_WIN = MAX_SBK,
-
- ONLY_LONG_WINDOW = 0,
- LONG_START_WINDOW,
- EIGHT_SHORT_WINDOW,
- LONG_STOP_WINDOW,
- NUM_WIN_SEQ,
-
- WLONG = ONLY_LONG_WINDOW,
- WSTART,
- WSHORT,
- WSTOP,
-
- MAXBANDS = 16 * NSHORT, /* max number of scale factor bands */
- MAXFAC = 121, /* maximum scale factor */
- MIDFAC = (MAXFAC - 1) / 2,
- SF_OFFSET = 100 /* global gain must be positive */
-} eBlockSwitching;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_coupling_mode.h b/media/libstagefright/codecs/aacdec/e_coupling_mode.h
deleted file mode 100644
index 68244bb..0000000
--- a/media/libstagefright/codecs/aacdec/e_coupling_mode.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_coupling_mode.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_COUPLING_MODE_H
-#define E_COUPLING_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- COUPLING_OFF,
- COUPLING_LEVEL,
- COUPLING_BAL
-}
-COUPLING_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_elementid.h b/media/libstagefright/codecs/aacdec/e_elementid.h
deleted file mode 100644
index 5f84643..0000000
--- a/media/libstagefright/codecs/aacdec/e_elementid.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./include/e_BLOCKTYPE.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for BlockType related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_ELEMENTID_H
-#define E_ELEMENTID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz
- * this is also the highest number of bins used
- * by predictor for any sampling rate
- */
- MAX_PRED_SFB = 40, /* 48 kHz only, now obsolete */
- MAX_PRED_BINS = 672,
-
- ID_SCE = 0,
- ID_CPE,
- ID_CCE,
- ID_LFE,
- ID_DSE,
- ID_PCE,
- ID_FIL,
- ID_END
-}
-ElementId;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_huffmanconst.h b/media/libstagefright/codecs/aacdec/e_huffmanconst.h
deleted file mode 100644
index 5d0e628..0000000
--- a/media/libstagefright/codecs/aacdec/e_huffmanconst.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_HuffmanConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Huffman related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_HUFFMAN_CONST_H
-#define E_HUFFMAN_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /*
- * specify huffman tables as signed (1) or unsigned (0)
- */
- HUF1SGN = 1,
- HUF2SGN = 1,
- HUF3SGN = 0,
- HUF4SGN = 0,
- HUF5SGN = 1,
- HUF6SGN = 1,
- HUF7SGN = 0,
- HUF8SGN = 0,
- HUF9SGN = 0,
- HUF10SGN = 0,
- HUF11SGN = 0,
-
- ZERO_HCB = 0,
- BY4BOOKS = 4,
- ESCBOOK = 11,
- NSPECBOOKS = ESCBOOK + 1,
- BOOKSCL = NSPECBOOKS,
- NBOOKS = NSPECBOOKS + 1,
- INTENSITY_HCB2 = 14,
- INTENSITY_HCB = 15,
- NOISE_HCB = 13,
- NOISE_HCB2 = 113,
-
- NOISE_PCM_BITS = 9,
- NOISE_PCM_OFFSET = (1 << (NOISE_PCM_BITS - 1)),
-
- NOISE_OFFSET = 90,
-
- LONG_SECT_BITS = 5,
- SHORT_SECT_BITS = 3
-} eHuffmanConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_infoinitconst.h b/media/libstagefright/codecs/aacdec/e_infoinitconst.h
deleted file mode 100644
index 788b5e9..0000000
--- a/media/libstagefright/codecs/aacdec/e_infoinitconst.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_infoinitConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Infoinit related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_INFOINIT_CONST_H
-#define E_INFOINIT_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "chans.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /* block switch windows for single channels or channel pairs */
- Winds = Chans,
-
- /* average channel block length, bytes */
- Avjframe = 341,
-
- TEXP = 128, /* size of exp cache table */
- MAX_IQ_TBL = 128, /* size of inv quant table */
- MAXFFT = LN4
-
-} infoinitConst;
-
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_invf_mode.h b/media/libstagefright/codecs/aacdec/e_invf_mode.h
deleted file mode 100644
index 57b3281..0000000
--- a/media/libstagefright/codecs/aacdec/e_invf_mode.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_invf_mode.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_INVF_MODE_H
-#define E_INVF_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- INVF_OFF,
- INVF_LOW_LEVEL,
- INVF_MID_LEVEL,
- INVF_HIGH_LEVEL,
-
- INVF_NO_OVERRIDE
-}
-INVF_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_maskstatus.h b/media/libstagefright/codecs/aacdec/e_maskstatus.h
deleted file mode 100644
index 010b6f8..0000000
--- a/media/libstagefright/codecs/aacdec/e_maskstatus.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_MaskStatus.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file gives the enum of mask_present value used in getmask.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_MASKSTATUS_H
-#define E_MASKSTATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-enum
-{
- MASK_NOT_PRESENT,
- MASK_FROM_BITSTREAM,
- MASK_ALL_FRAME,
- MASK_ERROR
-};
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_mp4ff_const.h b/media/libstagefright/codecs/aacdec/e_mp4ff_const.h
deleted file mode 100644
index 1006406..0000000
--- a/media/libstagefright/codecs/aacdec/e_mp4ff_const.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_MP4FF_const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file enums the constants used by MP4FF header
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_MP4FF_CONST_H
-#define E_MP4FF_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- LEN_OBJ_TYPE = 5,
- LEN_SAMP_RATE_IDX = 4,
- LEN_SAMP_RATE = 24,
- LEN_CHAN_CONFIG = 4,
- LEN_SYNC_EXTENSION_TYPE = 11,
- LEN_FRAME_LEN_FLAG = 1,
- LEN_DEPEND_ON_CORE = 1,
- LEN_CORE_DELAY = 14,
- LEN_EXT_FLAG = 1,
- LEN_EP_CONFIG = 2,
- LEN_LAYER_NUM = 3,
- LEN_SUB_FRAME = 5,
- LEN_LAYER_LEN = 11,
- LEN_SECT_RES_FLAG = 1,
- LEN_SCF_RES_FLAG = 1,
- LEN_SPEC_RES_FLAG = 1,
- LEN_EXT_FLAG3 = 1
-} eMP4FF_const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_progconfigconst.h b/media/libstagefright/codecs/aacdec/e_progconfigconst.h
deleted file mode 100644
index b5fdc08..0000000
--- a/media/libstagefright/codecs/aacdec/e_progconfigconst.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_ProgConfigConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for ProgConfig related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_PROG_CONFIG_CONST_H
-#define E_PROG_CONFIG_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- /*
- * Program Configuration
- */
- Main_Profile = 0,
- LC_Profile = 1,
-
- Fs_48 = 3,
- Fs_44 = 4,
- Fs_32 = 5,
-
- LEN_PROFILE = 2,
- LEN_SAMP_IDX = 4,
- LEN_NUM_ELE = 4,
- LEN_NUM_LFE = 2,
- LEN_NUM_DAT = 3,
- LEN_NUM_CCE = 4,
- LEN_MIX_PRES = 1,
- LEN_MMIX_IDX = 2,
- LEN_PSUR_ENAB = 1,
- LEN_ELE_IS_CPE = 1,
- LEN_IND_SW_CCE = 1,
- LEN_COMMENT_BYTES = 8
-
-} eProgConfigConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h b/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h
deleted file mode 100644
index a460d13..0000000
--- a/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_RawBitstreamConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for the Raw Bitstream related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_RAW_BITSTREAM_CONST_H
-#define E_RAW_BITSTREAM_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- LEN_SE_ID = 3,
- LEN_TAG = 4,
- LEN_COM_WIN = 1,
- LEN_ICS_RESERV = 1,
- LEN_WIN_SEQ = 2,
- LEN_WIN_SH = 1,
- LEN_MAX_SFBL = 6,
- LEN_MAX_SFBS = 4,
- LEN_CB = 4,
- LEN_SCL_PCM = 8,
- LEN_PRED_PRES = 1,
- LEN_PRED_RST = 1,
- LEN_PRED_RSTGRP = 5,
- LEN_PRED_ENAB = 1,
- LEN_MASK_PRES = 2,
- LEN_MASK = 1,
- LEN_PULSE_PRES = 1,
- LEN_TNS_PRES = 1,
- LEN_GAIN_PRES = 1,
-
- LEN_PULSE_NPULSE = 2,
- LEN_PULSE_ST_SFB = 6,
- LEN_PULSE_POFF = 5,
- LEN_PULSE_PAMP = 4,
- NUM_PULSE_LINES = 4,
- PULSE_OFFSET_AMP = 4,
-
- LEN_IND_CCE_FLG = 1,
- LEN_NCC = 3,
- LEN_IS_CPE = 1,
- LEN_CC_LR = 1,
- LEN_CC_DOM = 1,
- LEN_CC_SGN = 1,
- LEN_CCH_GES = 2,
- LEN_CCH_CGP = 1,
-
- LEN_D_ALIGN = 1,
- LEN_D_CNT = 8,
- LEN_D_ESC = 8,
- LEN_F_CNT = 4,
- LEN_F_ESC = 8,
- LEN_BYTE = 8,
- LEN_PAD_DATA = 8,
-
- LEN_PC_COMM = 9
-
-} eRawBitstreamConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_element_id.h b/media/libstagefright/codecs/aacdec/e_sbr_element_id.h
deleted file mode 100644
index 1b021ff..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_element_id.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_element_id.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_ELEMENT_ID_H
-#define E_SBR_ELEMENT_ID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- SBR_ID_SCE = 0,
- SBR_ID_CPE
-}
-SBR_ELEMENT_ID;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_error.h b/media/libstagefright/codecs/aacdec/e_sbr_error.h
deleted file mode 100644
index b6c8a90..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_error.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_error.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_ERROR_H
-#define E_SBR_ERROR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define HANDLE_ERROR_INFO Int32
-#define noError 0
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef enum
-{
- SBRDEC_OK = 0,
- SBRDEC_NOSYNCH,
- SBRDEC_ILLEGAL_PROGRAM,
- SBRDEC_ILLEGAL_TAG,
- SBRDEC_ILLEGAL_CHN_CONFIG,
- SBRDEC_ILLEGAL_SECTION,
- SBRDEC_ILLEGAL_SCFACTORS,
- SBRDEC_ILLEGAL_PULSE_DATA,
- SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED,
- SBRDEC_GC_NOT_IMPLEMENTED,
- SBRDEC_ILLEGAL_PLUS_ELE_ID,
- SBRDEC_CREATE_ERROR,
- SBRDEC_NOT_INITIALIZED,
- SBRDEC_TOO_MANY_SBR_ENVELOPES,
- SBRDEC_INVALID_BITSTREAM
-}
-SBR_ERROR;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_header_status.h b/media/libstagefright/codecs/aacdec/e_sbr_header_status.h
deleted file mode 100644
index 5b2a43f..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_header_status.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_header_status.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_HEADER_STATUS_H
-#define E_SBR_HEADER_STATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- HEADER_OK,
- HEADER_RESET,
- HEADER_NOT_INITIALIZED
-}
-SBR_HEADER_STATUS;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_master_status.h b/media/libstagefright/codecs/aacdec/e_sbr_master_status.h
deleted file mode 100644
index 16e43a4..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_master_status.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_master_status.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_MASTER_STATUS_H
-#define E_SBR_MASTER_STATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- MASTER_OK,
- MASTER_RESET
-}
-SBR_MASTER_STATUS;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h b/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h
deleted file mode 100644
index d9f8669..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_sync_state.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_SYNC_STATE_H
-#define E_SBR_SYNC_STATE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- SBR_NOT_INITIALIZED,
- UPSAMPLING,
- SBR_ACTIVE
-}
-SBR_SYNC_STATE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sr_mode.h b/media/libstagefright/codecs/aacdec/e_sr_mode.h
deleted file mode 100644
index eff00dd..0000000
--- a/media/libstagefright/codecs/aacdec/e_sr_mode.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sr_mode.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SR_MODE_H
-#define E_SR_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- SINGLE_RATE = 1,
- UP_BY_2
-}
-SR_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h b/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h
deleted file mode 100644
index 83cccce..0000000
--- a/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_tMP4AudioObjectType.h
-
- This file contains enumerated types for MP4 Audio Object Types, as defined
- in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_TMP4AUDIOOBJECTTYPE_H
-#define E_TMP4AUDIOOBJECTTYPE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- typedef enum eMP4AudioObjectType
- {
- MP4AUDIO_NULL = 0, /* */
- MP4AUDIO_AAC_MAIN = 1, /* */
- MP4AUDIO_AAC_LC = 2, /* LC = Low Complexity */
- MP4AUDIO_AAC_SSR = 3, /* SSR = Scalable Sampling Rate */
- MP4AUDIO_LTP = 4, /* LTP = Long Term Prediction */
- MP4AUDIO_SBR = 5, /* SBR = Spectral Band Replication */
- MP4AUDIO_AAC_SCALABLE = 6, /* scales both bitrate and sampling rate */
- MP4AUDIO_TWINVQ = 7, /* low bit rate */
- MP4AUDIO_CELP = 8,
- MP4AUDIO_HVXC = 9,
- /* 10 is reserved */
- /* 11 is reserved */
- MP4AUDIO_TTSI = 12,
- /* 13-16 are synthesis and MIDI types */
- MP4AUDIO_ER_AAC_LC = 17, /* */
- /* 18 is reserved */
- MP4AUDIO_ER_AAC_LTP = 19, /* */
- MP4AUDIO_ER_AAC_SCALABLE = 20, /* */
- MP4AUDIO_ER_TWINVQ = 21, /* */
- MP4AUDIO_ER_BSAC = 22, /* */
- MP4AUDIO_ER_AAC_LD = 23, /* */
- MP4AUDIO_ER_CELP = 24, /* */
- MP4AUDIO_ER_HVXC = 25, /* */
- MP4AUDIO_ER_HILN = 26, /* */
- MP4AUDIO_PARAMETRIC = 27, /* */
- MP4AUDIO_PS = 29 /* Explicit Parametric Stereo */
-
- } tMP4AudioObjectType;
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- /* Should not be any function declarations in this file */
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* E_TMP4AUDIOOBJECTTYPE_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_tns_const.h b/media/libstagefright/codecs/aacdec/e_tns_const.h
deleted file mode 100644
index 157d471..0000000
--- a/media/libstagefright/codecs/aacdec/e_tns_const.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_TNS_Const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for TNS related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_TNS_CONST_H
-#define E_TNS_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- TNS_MAX_BANDS = 49,
- TNS_MAX_ORDER = 20,
- TNS_MAX_WIN = 8,
- TNS_MAX_FILT = 3,
- Q_SPEC = 11,
- Q_LPC = 19
-
-} eTNS_Const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_window_sequence.h b/media/libstagefright/codecs/aacdec/e_window_sequence.h
deleted file mode 100644
index c4b933e..0000000
--- a/media/libstagefright/codecs/aacdec/e_window_sequence.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_WINDOW_SEQUENCE.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Window Sequence related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_WINDOW_SEQUENCE_H
-#define E_WINDOW_SEQUENCE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- ONLY_LONG_SEQUENCE,
- LONG_START_SEQUENCE,
- EIGHT_SHORT_SEQUENCE,
- LONG_STOP_SEQUENCE,
- NUM_WINDOW_SEQUENCE,
- ENSURE_WINDOW_SEQUENCE_INT_SIZE = 0x7FFFFF
-}
-WINDOW_SEQUENCE;
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_window_shape.h b/media/libstagefright/codecs/aacdec/e_window_shape.h
deleted file mode 100644
index 3eca438..0000000
--- a/media/libstagefright/codecs/aacdec/e_window_shape.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_Window_shape.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Window Sequence related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_WINDOW_SHAPE_H
-#define E_WINDOW_SHAPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
- SINE_WINDOW = 0,
- KAISER_BESSEL_WINDOW,
- NUM_WINDOW_SHAPES,
- ENSURE_WINDOW_SHAPE_INT_SIZE = 0x7FFFFF
-}
-WINDOW_SHAPE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp b/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp
deleted file mode 100644
index 778c88c..0000000
--- a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp
+++ /dev/null
@@ -1,789 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/esc_iquant_scaling.c
- Funtions: esc_iquant_scaling
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from esc_iquant_fxp.c code
-
- Description: Eliminated unused variables to avoid warnings, changed header
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- quantSpec[] = array of quantized compressed spectral coefficients, of
- data type Int and length sfbWidth.
-
- sfbWidth = number of array elements in quantSpec and the output array
- coef, data type Int.
-
- coef[] = output array of uncompressed coefficients, stored in a
- variable Q format, depending on the maximum value found
- for the group, array of Int32, length sfbWdith to be
- overwritten.
-
- QFormat = the output Q format for the array coef[].
-
-
- scale = scaling factor after separating power of 2 factor out from
- 0.25*(sfb_scale - 100), i.e., 0.25*sfb_scale.
-
- maxInput = maximum absolute value of quantSpec.
-
- Local Stores/Buffers/Pointers Needed: None.
-
- Global Stores/Buffers/Pointers Needed:
- inverseQuantTable = lookup table of const integer values to the one third
- power stored in Q27 format, in file iquant_table.c, const
- array of UInt32, of size 1025.
-
- Outputs: None
-
- Pointers and Buffers Modified:
- coef[] contents are overwritten with the uncompressed values from
- quantSpec[]
-
-
-
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs the inverse quantization of the spectral coeficients
- read from huffman decoding. It takes each input array value to the four
- thirds power, then scales it according to the scaling factor input argument
- ,and stores the result in the output array in a variable Q format
- depending upon the maximum input value found.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not have static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Section 10.3, "Decoding process", page 43.
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- maxInput = 0;
-
- FOR (i = sfbWidth - 1; i >= 0; i--)
- x = quantSpec[i];
-
- IF ( x >= 0)
- absX = x;
- ELSE
- absX = -x;
- ENDIF
-
- coef[i] = absX;
-
- IF (absX > maxInput)
- maxInput = absX;
- ENDIF
- ENDFOR
-
- IF (maxInput == 0)
- *pQFormat = QTABLE;
- ELSE
- temp = inverseQuantTable[(maxInput >> ORDER) + 1];
-
- temp += ((1 << (QTABLE))-1);
-
- temp >>= (QTABLE-1);
-
- temp *= maxInput;
-
- binaryDigits = 0;
- WHILE( temp != 0)
- temp >>= 1;
- binaryDigits++;
- WEND
-
- IF (binaryDigits < (SIGNED32BITS - QTABLE))
- binaryDigits = SIGNED32BITS - QTABLE;
- ENDIF
-
- *pQFormat = SIGNED32BITS - binaryDigits;
- shift = QTABLE - *pQFormat;
-
- IF (maxInput < TABLESIZE)
- FOR (i = sfbWidth - 1; i >= 0; i--)
- x = quantSpec[i];
-
- absX = coef[i];
-
- tmp_coef = x * (inverseQuantTable[absX] >> shift);
-
- b_low = (tmp_coef & 0xFFFF);
- b_high = (tmp_coef >> 16);
-
- mult_low = ( (UInt32) b_low * scale );
- mult_high = ( (Int32) b_high * scale );
-
- mult_low >>= 16;
-
- coef[i] = (Int32) (mult_high + mult_low);
-
- ENDFOR
- ELSE
- FOR (i = sfbWidth; i >= 0 ; i--)
- x = quantSpec[i];
- absX = coef[i];
-
- IF (absX < TABLESIZE)
- tmp_coef = x * (inverseQuantTable[absX] >> shift);
- ELSE
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
-
- approxOneThird = (w1 * FACTOR) >> shift;
-
-
- x1 = index * SPACING;
- w2 = inverseQuantTable[index+1];
-
- deltaOneThird = (w2 - w1) * (absX - x1);
-
- deltaOneThird >>= (shift + ORDER - 1);
-
- tmp_coef = x * (approxOneThird + deltaOneThird);
-
- ENDIF
-
- b_low = (mult_high & 0xFFFF);
- b_high = (mult_high >> 16);
-
- mult_low = ( (UInt32) b_low * scale );
- mult_high = ( (Int32) b_high * scale );
-
- mult_low >>= 16;
-
- coef[i] = (Int32) (mult_high + mult_low);
-
- ENDFOR
- ENDIF
- ENDIF
-
- RETURN
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "iquant_table.h"
-#include "esc_iquant_scaling.h"
-#include "aac_mem_funcs.h" /* For pv_memset */
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*
- * Read further on what order is.
- * Note: If ORDER is not a multiple of 3, FACTOR is not an integer.
- * Note: Portions of this function assume ORDER is 3, and so does the table
- * in iquant_table.c
- */
-#define ORDER (3)
-/*
- * For input values > TABLESIZE, multiply by FACTOR to get x ^ (1/3)
- * FACTOR = 2 ^ (ORDER/3)
- */
-#define FACTOR (2)
-
-/*
- * This is one more than the range of expected inputs.
- */
-#define INPUTRANGE (8192)
-
-/*
- * SPACING is 2 ^ ORDER, and is the spacing between points when in the
- * interpolation range.
- */
-#define SPACING (1<<ORDER)
-
-/*
- * The actual table size is one more than TABLESIZE, to allow for
- * interpolation for numbers near 8191
- */
-#define TABLESIZE (INPUTRANGE/SPACING)
-
-/*
- * Format the table is stored in.
- */
-#define QTABLE (27)
-
-/*
- * Number of bits for data in a signed 32 bit integer.
- */
-#define SIGNED32BITS (31)
-
-/*
- * Round up value for intermediate values obtained from the table
- */
-#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1)
-
-#define MASK_LOW16 0xffff
-#define UPPER16 16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
- * Processing in this function is performed in these steps:
- *
- * 1) Find the overall Q format for the entire group of inputs. This consists
- * of:
- * a) Finding the maximum input
- * b) estimate the maximum output
- * c) Using the table, get max ^ (4/3), taking into account the table is
- * in q format.
- * 2) For each array element, see if the value is directly inside the table.
- * a) If yes, just multiply by table value by itself, then shift as
- * appropriate.
- * b) If no, get an approximation (described below) for x ^ (1/3) by linearly
- * interpolating using lower values in the table, then multiply by a
- * correction factor, then multiply by x (see below).
- *
- * It more accurate to interpolate x ^ (1/3) then x ^ (4/3), so that is stored
- * in the lookup table. For values not in the table, interpolation is used:
- *
- * We want y = x ^ (4/3) = x * (x ^ (1/3))
- *
- * Let x = w * (2 ^ m) where m is a constant, = ORDER
- *
- * then x ^ (1/3) = w ^ (1/3) * (2 ^ (m/3))
- *
- * w is most likely not an integer, so an interpolation with floor(w) and
- * ceil(w) can be performed to approximate w ^ (1/3) by getting values out of
- * the table. Then to get x ^ (1/3), multiply by FACTOR. If m = 0, 3, 6,
- * then FACTOR is a simple power of 2, so a shift can do the job.
- *
- * The actual code employs some more tricks to speed things up, and because
- * the table is stored in Q format.
- *
- * Rather than saving the sign of each input, the unsigned value of
- * abs(x) ^ (1/3) is multiplied by the signed input value.
- */
-
-
-
-#if ( defined(_ARM) || defined(_ARM_V4))
-
-/*
- * Absolute value for 16 bit-numbers
- */
-__inline Int32 abs2(Int32 x)
-{
- Int32 z;
- /*
- z = x - (x<0);
- x = z ^ sign(z)
- */
- __asm
- {
- sub z, x, x, lsr #31
- eor x, z, z, asr #31
- }
- return (x);
-}
-
-
-#define pv_abs(x) abs2(x)
-
-
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-
-/*
- * Absolute value for 16 bit-numbers
- */
-__inline Int32 abs2(Int32 x)
-{
- register Int32 z;
- register Int32 y;
- register Int32 ra = x;
- asm volatile(
- "sub %0, %2, %2, lsr #31\n\t"
- "eor %1, %0, %0, asr #31"
- : "=&r*i"(z),
- "=&r*i"(y)
- : "r"(ra));
-
- return (y);
-}
-
-#define pv_abs(x) abs2(x)
-
-
-#else
-
-#define pv_abs(x) ((x) > 0)? (x) : (-x)
-
-#endif
-
-
-
-
-
-void esc_iquant_scaling(
- const Int16 quantSpec[],
- Int32 coef[],
- const Int sfbWidth,
- Int const QFormat,
- UInt16 scale,
- Int maxInput)
-{
- Int i;
- Int x;
- Int y;
- Int index;
- Int shift;
- UInt absX;
- UInt32 w1, w2;
- UInt32 deltaOneThird;
- UInt32 x1;
- UInt32 approxOneThird;
- Int32 mult_high;
-
-
-#if ( defined(_ARM) || defined(_ARM_V4))
-
- {
- Int32 *temp;
- Int32 R12, R11, R10, R9;
-
- deltaOneThird = sizeof(Int32) * sfbWidth;
- temp = coef;
-
- // from standard library call for __rt_memset
- __asm
- {
- MOV R12, #0x0
- MOV R11, #0x0
- MOV R10, #0x0
- MOV R9, #0x0
- SUBS deltaOneThird, deltaOneThird, #0x20
-loop:
- STMCSIA temp!, {R12, R11, R10, R9}
- STMCSIA temp!, {R12, R11, R10, R9}
- SUBCSS deltaOneThird, deltaOneThird, #0x20
- BCS loop
-
- MOVS deltaOneThird, deltaOneThird, LSL #28
- STMCSIA temp!, {R12, R11, R10, R9}
- STMMIIA temp!, {R12, R11}
- }
- }
-
-#else
- pv_memset(coef, 0, sizeof(Int32) * sfbWidth);
-#endif
-
- if (maxInput > 0)
- {
-
- shift = QTABLE - QFormat;
-
- if (scale != 0)
- {
- if (maxInput < TABLESIZE)
- {
-
- for (i = sfbWidth - 1; i >= 0; i -= 4)
- {
- x = quantSpec[i];
- y = quantSpec[i-1];
- if (x)
- {
- absX = pv_abs(x);
- mult_high = (x * (inverseQuantTable[absX] >> shift));
- coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
-
- if (y)
- {
- absX = pv_abs(y);
- mult_high = y * (inverseQuantTable[absX] >> shift);
- coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
-
- x = quantSpec[i-2];
- y = quantSpec[i-3];
- if (x)
- {
- absX = pv_abs(x);
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
-
- if (y)
- {
- absX = pv_abs(y);
- mult_high = y * (inverseQuantTable[absX] >> shift);
- coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
- } /* end for (i = sfbWidth - 1; i >= 0; i--) */
-
- } /* end if (maxInput < TABLESIZE)*/
-
- else /* maxInput >= TABLESIZE) */
- {
- for (i = sfbWidth - 1; i >= 0; i -= 4)
- {
- x = quantSpec[i];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
-
- }
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
-
- }
- } /* if(x) */
-
-
- x = quantSpec[i-1];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = (x * (inverseQuantTable[absX] >> shift));
- coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
-
- }
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
- } /* if(x) */
-
- x = quantSpec[i-2];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
- }
- } /* if(x) */
-
- x = quantSpec[i-3];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
-
- }
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
-
- }
- } /* if(x) */
-
- } /* end for (i = sfbWidth - 1; i >= 0; i--) */
- } /* end else for if (maxInput < TABLESIZE)*/
- }
- else /* scale == 0 */
- {
- if (maxInput < TABLESIZE)
- {
- for (i = sfbWidth - 1; i >= 0; i -= 4)
- {
- x = quantSpec[i];
- y = quantSpec[i-1];
- if (x)
- {
- absX = pv_abs(x);
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i] = mult_high >> 1;
- }
-
- if (y)
- {
- absX = pv_abs(y);
- mult_high = y * (inverseQuantTable[absX] >> shift);
- coef[i-1] = mult_high >> 1;
- }
-
- x = quantSpec[i-2];
- y = quantSpec[i-3];
- if (x)
- {
- absX = pv_abs(x);
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-2] = mult_high >> 1;
- }
-
- if (y)
- {
- absX = pv_abs(y);
- mult_high = y * (inverseQuantTable[absX] >> shift);
- coef[i-3] = mult_high >> 1;
- }
- }
-
- } /* end if (maxInput < TABLESIZE)*/
-
- else /* maxInput >= TABLESIZE) */
- {
- for (i = sfbWidth - 1; i >= 0; i -= 4)
- {
- x = quantSpec[i];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i] = (mult_high >> 1);
- } /* end if (absX < TABLESIZE) */
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i] = (mult_high >> 1);
- }
- } /* if(x) */
-
- x = quantSpec[i-1];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-1] = (mult_high >> 1);
- } /* end if (absX < TABLESIZE) */
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-1] = (mult_high >> 1);
- }
- } /* if(x) */
-
- x = quantSpec[i-2];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-2] = (mult_high >> 1);
- } /* end if (absX < TABLESIZE) */
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-2] = (mult_high >> 1);
- }
- } /* if(x) */
-
- x = quantSpec[i-3];
- if (x)
- {
- absX = pv_abs(x);
- if (absX < TABLESIZE)
- {
- mult_high = x * (inverseQuantTable[absX] >> shift);
- coef[i-3] = (mult_high >> 1);
- } /* end if (absX < TABLESIZE) */
- else
- {
- index = absX >> ORDER;
- w1 = inverseQuantTable[index];
- w2 = inverseQuantTable[index+1];
- approxOneThird = (w1 * FACTOR) >> shift;
- x1 = index << ORDER;
- deltaOneThird = (w2 - w1) * (absX - x1);
- deltaOneThird >>= (shift + 2);
- mult_high = x * (approxOneThird + deltaOneThird);
- coef[i-3] = (mult_high >> 1);
- }
-
- } /* if(x) */
-
- } /* end for (i = sfbWidth - 1; i >= 0; i--) */
-
- } /* end else for if (maxInput < TABLESIZE)*/
-
- } /* end else for if(scale!=0) */
-
- } /* end else for if(maxInput == 0) */
-
-} /* end esc_iquant_fxp */
-
-
diff --git a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h b/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h
deleted file mode 100644
index a846b9f..0000000
--- a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/esc_iquant_scaling.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for esc_iquant_scaling.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef ESC_IQUANT_SCALING_H
-#define ESC_IQUANT_SCALING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- void esc_iquant_scaling(
- const Int16 quantSpec[],
- Int32 coef[],
- const Int sfbWidth,
- Int const pQFormat,
- UInt16 scale,
- Int maxInput);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* ESC_IQUANT_SCALING_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/extractframeinfo.cpp b/media/libstagefright/codecs/aacdec/extractframeinfo.cpp
deleted file mode 100644
index 571cc98..0000000
--- a/media/libstagefright/codecs/aacdec/extractframeinfo.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: extractframeInfo.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: hBitBuf - bitbuffer handle
- v_frame_info - pointer to memorylocation where the frame-info will
- be stored.
-
- Return: none.
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-Extracts a frame_info vector from control data read from the bitstream.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "extractframeinfo.h"
-#include "buf_getbits.h"
-#include "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*
- * (int) ceil (log (bs_num_env + 1) / log (2))
- * ceil(log([0:5]+1)/log(2))
- */
-
-const Int32 bs_pointer_bits_tbl[MAX_ENVELOPES + 1] = { 0, 1, 2, 2, 3, 3};
-
-/*
- * (int)((float)numTimeSlots/bs_num_env + 0.5f)
- * floor(16./[0:5] + 0.5)
- */
-
-const Int32 T_16_ov_bs_num_env_tbl[MAX_ENVELOPES + 1] = { 2147483647, 16, 8,
- 5, 4, 3
- };
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf,
- SBR_FRAME_DATA * h_frame_data)
-{
-
- Int32 absBordLead = 0;
- Int32 nRelLead = 0;
- Int32 nRelTrail = 0;
- Int32 bs_num_env = 0;
- Int32 bs_num_rel = 0;
- Int32 bs_var_bord = 0;
- Int32 bs_var_bord_0 = 0;
- Int32 bs_var_bord_1 = 0;
- Int32 bs_pointer = 0;
- Int32 bs_pointer_bits;
- Int32 frameClass;
- Int32 temp;
- Int32 env;
- Int32 k;
- Int32 bs_num_rel_0 = 0;
- Int32 bs_num_rel_1 = 0;
- Int32 absBordTrail = 0;
- Int32 middleBorder = 0;
- Int32 bs_num_noise;
- Int32 lA = 0;
-
- Int32 tE[MAX_ENVELOPES + 1];
- Int32 tQ[2 + 1];
- Int32 f[MAX_ENVELOPES + 1];
- Int32 bs_rel_bord[3];
- Int32 bs_rel_bord_0[3];
- Int32 bs_rel_bord_1[3];
- Int32 relBordLead[3];
- Int32 relBordTrail[3];
-
-
- Int32 *v_frame_info = h_frame_data->frameInfo;
-
- SBR_ERROR err = SBRDEC_OK;
-
-
- /*
- * First read from the bitstream.
- */
-
- /* Read frame class */
- h_frame_data->frameClass = frameClass = buf_getbits(hBitBuf, SBR_CLA_BITS);
-
-
- switch (frameClass)
- {
-
- case FIXFIX:
- temp = buf_getbits(hBitBuf, SBR_ENV_BITS); /* 2 bits */
-
- bs_num_env = 1 << temp;
-
-
- f[0] = buf_getbits(hBitBuf, SBR_RES_BITS); /* 1 bit */
-
- for (env = 1; env < bs_num_env; env++)
- {
- f[env] = f[0];
- }
-
- nRelLead = bs_num_env - 1;
- absBordTrail = 16;
-
-
- break;
-
- case FIXVAR:
- bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
- bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
- bs_num_env = bs_num_rel + 1;
-
- for (k = 0; k < bs_num_env - 1; k++)
- {
- bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
- }
-
- bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
- bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
- for (env = 0; env < bs_num_env; env++)
- { /* 1 bit */
- f[bs_num_env - 1 - env] = buf_getbits(hBitBuf, SBR_RES_BITS);
- }
-
- absBordTrail = 16 + bs_var_bord;
- nRelTrail = bs_num_rel;
-
- break;
-
- case VARFIX:
- bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
- bs_num_rel = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
- bs_num_env = bs_num_rel + 1;
-
- for (k = 0; k < bs_num_env - 1; k++)
- {
- bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
- }
-
- bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
- bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
- for (env = 0; env < bs_num_env; env++)
- { /* 1 bit */
- f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
- }
-
- absBordTrail = 16;
- absBordLead = bs_var_bord;
- nRelLead = bs_num_rel;
-
- break;
-
- case VARVAR:
- bs_var_bord_0 = buf_getbits(hBitBuf, SBR_ABS_BITS); /* 2 bits */
- bs_var_bord_1 = buf_getbits(hBitBuf, SBR_ABS_BITS);
- bs_num_rel_0 = buf_getbits(hBitBuf, SBR_NUM_BITS); /* 2 bits */
- bs_num_rel_1 = buf_getbits(hBitBuf, SBR_NUM_BITS);
-
- bs_num_env = bs_num_rel_0 + bs_num_rel_1 + 1;
-
- for (k = 0; k < bs_num_rel_0; k++)
- { /* 2 bits */
- bs_rel_bord_0[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
- }
-
- for (k = 0; k < bs_num_rel_1; k++)
- { /* 2 bits */
- bs_rel_bord_1[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
- }
-
-
- bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
- bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
- for (env = 0; env < bs_num_env; env++)
- { /* 1 bit */
- f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
- }
-
- absBordLead = bs_var_bord_0;
- absBordTrail = 16 + bs_var_bord_1;
- nRelLead = bs_num_rel_0;
- nRelTrail = bs_num_rel_1;
-
- break;
-
- };
-
-
- /*
- * Calculate the framing.
- */
-
-
- switch (frameClass)
- {
- case FIXFIX:
- for (k = 0; k < nRelLead; k++)
- {
- relBordLead[k] = T_16_ov_bs_num_env_tbl[bs_num_env];
- }
- break;
- case VARFIX:
- for (k = 0; k < nRelLead; k++)
- {
- relBordLead[k] = bs_rel_bord[k];
- }
- break;
- case VARVAR:
- for (k = 0; k < nRelLead; k++)
- {
- relBordLead[k] = bs_rel_bord_0[k];
- }
- for (k = 0; k < nRelTrail; k++)
- {
- relBordTrail[k] = bs_rel_bord_1[k];
- }
- break;
- case FIXVAR:
- for (k = 0; k < nRelTrail; k++)
- {
- relBordTrail[k] = bs_rel_bord[k];
- }
- break;
- }
-
-
- tE[0] = absBordLead;
- tE[bs_num_env] = absBordTrail;
-
- for (env = 1; env <= nRelLead; env++)
- {
- tE[env] = absBordLead;
- for (k = 0; k <= env - 1; k++)
- {
- tE[env] += relBordLead[k];
- }
- }
-
- for (env = nRelLead + 1; env < bs_num_env; env++)
- {
- tE[env] = absBordTrail;
- for (k = 0; k <= bs_num_env - env - 1; k++)
- {
- tE[env] -= relBordTrail[k];
- }
- }
-
-
-
- switch (frameClass)
- {
- case FIXFIX:
- middleBorder = bs_num_env >> 1;
- break;
- case VARFIX:
- switch (bs_pointer)
- {
- case 0:
- middleBorder = 1;
- break;
- case 1:
- middleBorder = bs_num_env - 1;
- break;
- default:
- middleBorder = bs_pointer - 1;
- break;
- };
- break;
- case FIXVAR:
- case VARVAR:
- switch (bs_pointer)
- {
- case 0:
- case 1:
- middleBorder = bs_num_env - 1;
- break;
- default:
- middleBorder = bs_num_env + 1 - bs_pointer;
- break;
- };
- break;
- };
-
-
- tQ[0] = tE[0];
- if (bs_num_env > 1)
- {
- tQ[1] = tE[middleBorder];
- tQ[2] = tE[bs_num_env];
- bs_num_noise = 2;
- }
- else
- {
- tQ[1] = tE[bs_num_env];
- bs_num_noise = 1;
- }
-
- /*
- * Check consistency on freq bands
- */
-
- if ((tE[bs_num_env] < tE[0]) || (tE[0] < 0))
- {
- err = SBRDEC_INVALID_BITSTREAM;
- }
-
-
- switch (frameClass)
- {
- case FIXFIX:
- lA = -1;
- break;
- case VARFIX:
- switch (bs_pointer)
- {
- case 0:
- case 1:
- lA = -1;
- break;
- default:
- lA = bs_pointer - 1;
- break;
- };
- break;
- case FIXVAR:
- case VARVAR:
- switch (bs_pointer)
- {
- case 0:
- lA = - 1;
- break;
- default:
- lA = bs_num_env + 1 - bs_pointer;
- break;
- };
- break;
- };
-
- /*
- * Build the frameInfo vector...
- */
-
- v_frame_info[0] = bs_num_env; /* Number of envelopes*/
- pv_memcpy(v_frame_info + 1, tE, (bs_num_env + 1)*sizeof(Int32)); /* time borders*/
- /* frequency resolution */
- pv_memcpy(v_frame_info + 1 + bs_num_env + 1, f, bs_num_env*sizeof(Int32));
-
- temp = (1 + bs_num_env) << 1;
- v_frame_info[temp] = lA; /* transient envelope*/
- v_frame_info[temp + 1] = bs_num_noise; /* Number of noise envelopes */
- /* noise borders */
- pv_memcpy(v_frame_info + temp + 2, tQ, (bs_num_noise + 1)*sizeof(Int32));
-
-
- return (err);
-
-}
-
-
-
-
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/extractframeinfo.h b/media/libstagefright/codecs/aacdec/extractframeinfo.h
deleted file mode 100644
index 2fcfe37..0000000
--- a/media/libstagefright/codecs/aacdec/extractframeinfo.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: extractFrameInfo.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef EXTRACTFRAMEINFO_H
-#define EXTRACTFRAMEINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-#include "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef Int32 FRAME_INFO[LENGTH_FRAME_INFO];
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- SBR_ERROR extractFrameInfo(BIT_BUFFER * hBitBuf,
- SBR_FRAME_DATA * h_frame_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4.h b/media/libstagefright/codecs/aacdec/fft_rx4.h
deleted file mode 100644
index 8e7acb3..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/fft_rx4.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- (1) modified definition of w_64rx4 from Int to Int16
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fft_rx4()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FFT_RX4_H
-#define FFT_RX4_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FFT_RX4_LONG 256
-#define ONE_FOURTH_FFT_RX4_LONG ((FFT_RX4_LONG)>>2)
-#define FFT_RX4_SHORT 64
-#define ONE_FOURTH_FFT_RX4_SHORT ((FFT_RX4_SHORT)>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int16 w_64rx4[];
-extern const Int32 W_64rx4[];
-extern const Int32 W_256rx4[];
-extern const Int32 w_512rx2[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void fft_rx4_long(
- Int32 Data[],
- Int32 *peak_value);
-
- Int fft_rx4_short(
- Int32 Data[],
- Int32 *peak_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* FFT_RX4_H */
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp
deleted file mode 100644
index c517e7e..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_long.c
- Funtions: fft_rx4_long
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Eliminated search for max in the main loop.
- (2) Reduced precision on w_256rx4 from Q15 to Q10
-
- Description:
- (1) Created function fft_rx4_long_no_max to overcome LTP problem.
-
- Description:
- (1) Modified shift so the accumulation growths faster than the
- downshift, so now the input can be as high as 1.0 and saturation
- will not occurre. The accumulation times the Q10 format will
- never exceed 31 bits. This increases precision
- (2) Eliminated unneeded data moves, used before for max search.
- (3) Eliminated function fft_rx4_long_no_max.
-
- Description:
- (1) Added comment to explain max search elimination and
- Q format during multiplications
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Data = Input complex vector, arranged in the following order:
- real, imag, real, imag...
- This is a complex vector whose elements (real and Imag) are
- Int32.
- type Int32 *
-
- peak_value = Input, peak value of the input vector
- Output, peak value of the resulting vector
- type Int32 *
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- calculation are done in-place and returned in Data
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Fast Fourier Transform, radix 4 with Decimation in Frequency and block
- floating point arithmetic.
- The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of
- the smaller FFTs is then further divided into smaller ones and so on.
- It consists of log 4 N stages and each stage consists of N/4 dragonflies.
-
- An FFT is nothing but a bundle of multiplications and summations which
- may overflow during calculations.
-
-
- This routine uses a scheme to test and scale the result output from
- each FFT stage in order to fix the accumulation overflow.
-
- The Input Data should be in Q13 format to get the highest precision.
- At the end of each dragonfly calculation, a test for possible bit growth
- is made, if bit growth is possible the Data is scale down back to Q13.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should provide a fixed point FFT for an input array
- of size 256.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
- C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
- MODIFY( x[] )
- RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "fft_rx4.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void fft_rx4_long(
- Int32 Data[],
- Int32 *peak_value)
-
-{
- Int n1;
- Int n2;
- Int j;
- Int k;
- Int i;
-
- Int32 t1;
- Int32 t2;
- Int32 r1;
- Int32 r2;
- Int32 r3;
- Int32 r4;
- Int32 s1;
- Int32 s2;
- Int32 s3;
- Int32 *pData1;
- Int32 *pData2;
- Int32 *pData3;
- Int32 *pData4;
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 max;
-
- Int32 exp_jw1;
- Int32 exp_jw2;
- Int32 exp_jw3;
-
-
-
- const Int32 *pw = W_256rx4;
-
- n2 = FFT_RX4_LONG;
-
- for (k = FFT_RX4_LONG; k > 4; k >>= 2)
- {
-
- n1 = n2;
- n2 >>= 2;
-
- for (i = 0; i < FFT_RX4_LONG; i += n1)
- {
- pData1 = &Data[ i<<1];
- pData2 = pData1 + n1;
-
- temp1 = *pData1;
- temp2 = *pData2;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
-
- pData3 = pData1 + (n1 >> 1);
- pData4 = pData3 + n1;
- temp3 = *pData3++;
- temp4 = *pData4++;
-
- t1 = temp3 + temp4;
-
- *(pData1++) = (r1 + t1);
- t2 = temp3 - temp4;
- *(pData2++) = (r1 - t1);
-
- temp1 = *pData1;
- temp2 = *pData2;
-
- s1 = temp1 + temp2;
- temp3 = *pData3;
- s2 = temp1 - temp2;
- temp4 = *pData4;
- *pData3-- = (s2 - t2);
- *pData4-- = (s2 + t2);
-
- t1 = temp3 + temp4;
-
- *pData1 = (s1 + t1);
- *pData2 = (s1 - t1);
-
- r1 = temp3 - temp4;
-
- *pData4 = (r2 - r1);
- *pData3 = (r2 + r1);
-
- } /* i */
-
-
-
- for (j = 1; j < n2; j++)
- {
-
- exp_jw1 = (*pw++);
- exp_jw2 = (*pw++);
- exp_jw3 = (*pw++);
-
-
- for (i = j; i < FFT_RX4_LONG; i += n1)
- {
- pData1 = &Data[ i<<1];
- pData2 = pData1 + n1;
-
- temp1 = *pData1;
- temp2 = *pData2++;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
-
- pData3 = pData1 + (n1 >> 1);
- pData4 = pData3 + n1;
- temp3 = *pData3++;
- temp4 = *pData4++;
-
- r3 = temp3 + temp4;
- r4 = temp3 - temp4;
-
- *(pData1++) = (r1 + r3);
- r1 = (r1 - r3) << 1;
-
- temp2 = *pData2;
- temp1 = *pData1;
-
- s1 = temp1 + temp2;
- s2 = temp1 - temp2;
- s3 = (s2 + r4) << 1;
- s2 = (s2 - r4) << 1;
-
- temp3 = *pData3;
- temp4 = *pData4;
-
- t1 = temp3 + temp4;
- t2 = temp3 - temp4;
-
- *pData1 = (s1 + t1);
- s1 = (s1 - t1) << 1;
-
- *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2);
- r3 = (r2 - t2) << 1;
- *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2);
-
- r2 = (r2 + t2) << 1;
-
- *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1);
- *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1);
-
- *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3);
- *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3);
-
- } /* i */
-
- } /* j */
-
- } /* k */
-
-
- max = 0;
-
- pData1 = Data - 7;
-
-
- for (i = ONE_FOURTH_FFT_RX4_LONG; i != 0 ; i--)
- {
- pData1 += 7;
- pData2 = pData1 + 4;
-
-
- temp1 = *pData1;
- temp2 = *pData2++;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
-
- pData3 = pData1 + 2;
- pData4 = pData1 + 6;
- temp1 = *pData3++;
- temp2 = *pData4++;
-
- t1 = temp1 + temp2;
- t2 = temp1 - temp2;
-
- temp1 = (r1 + t1);
- r1 = (r1 - t1);
- *(pData1++) = temp1;
- max |= (temp1 >> 31) ^ temp1;
-
-
-
- temp2 = *pData2;
- temp1 = *pData1;
-
- s1 = temp1 + temp2;
- s2 = temp1 - temp2;
-
-
- temp1 = *pData3;
- temp2 = *pData4;
-
- s3 = (s2 + t2);
- s2 = (s2 - t2);
-
- t1 = temp1 + temp2;
- t2 = temp1 - temp2;
-
- temp1 = (s1 + t1);
- *pData1 = temp1;
- temp2 = (s1 - t1);
-
- max |= (temp1 >> 31) ^ temp1;
- *pData2-- = temp2;
- max |= (temp2 >> 31) ^ temp2;
-
- *pData2 = r1;
- max |= (r1 >> 31) ^ r1;
- *pData3-- = s2;
- max |= (s2 >> 31) ^ s2;
- *pData4-- = s3;
- max |= (s3 >> 31) ^ s3;
-
- temp1 = (r2 - t2);
- *pData4 = temp1;
- temp2 = (r2 + t2);
- *pData3 = temp2;
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
- } /* i */
-
- *peak_value = max;
-
- return ;
-
-}
-
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp
deleted file mode 100644
index 4a8a0d6..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp
+++ /dev/null
@@ -1,468 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_short.c
- Funtions: fft_rx4_short
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Eliminated search for max in the main loop.
- (2) Simplified the function by eliminating different conditions
- for exp.
- (3) Reduced precision on w_64rx4 from Q15 to Q12, so now the
- input can be as high as 1.0 and saturation will not occurre
- because the accumulation times the new Q12 format will never
- exceed 31 bits.
-
- Description:
- (1) Added comment to explain max search elimination and
- Q format during multiplications
- (2) Increased down shift from 1 to 2, to ensure that 32-bit
- numbers will not overflow when 2 consecutive adds are done
- This was found during code review.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Data = Input complex vector, arranged in the following order:
- real, imag, real, imag...
- This is a complex vector whose elements (real and Imag) are
- Int32.
- type Int32 *
-
- peak_value = Input, peak value of the input vector
- Output, peak value of the resulting vector
- type Int32 *
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exponent returns a shift to compensate the scaling introduced by
- overflow protection
-
- Pointers and Buffers Modified:
- calculation are done in-place and returned in Data
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Fast Fourier Transform, radix 4 with Decimation in Frequency and block
- floating point arithmetic.
- The radix-4 FFT simply divides the FFT into four smaller FFTs. Each of
- the smaller FFTs is then further divided into smaller ones and so on.
- It consists of log 4 N stages and each stage consists of N/4 dragonflies.
-
- An FFT is nothing but a bundle of multiplications and summations which
- may overflow during calculations.
-
-
- This routine uses a scheme to test and scale the result output from
- each FFT stage in order to fix the accumulation overflow.
-
- The Input Data should be in Q13 format to get the highest precision.
- At the end of each dragonfly calculation, a test for possible bit growth
- is made, if bit growth is possible the Data is scale down back to Q13.
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should provide a fixed point FFT for an input array
- of size 64.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
- C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
- MODIFY( x[] )
- RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "fft_rx4.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int fft_rx4_short(
- Int32 Data[],
- Int32 *peak_value)
-
-{
- Int n1;
- Int n2;
- Int n3;
- Int j;
- Int k;
- Int i;
- Int32 exp_jw1;
- Int32 exp_jw2;
- Int32 exp_jw3;
-
-
- Int32 t1;
- Int32 t2;
- Int32 r1;
- Int32 r2;
- Int32 r3;
- Int32 s1;
- Int32 s2;
- Int32 s3;
-
- Int32 *pData1;
- Int32 *pData2;
- Int32 *pData3;
- Int32 *pData4;
- const Int32 *pw;
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 max;
- Int exp;
- Int exponent = 0;
- Int shift;
-
-
- max = *peak_value;
- exp = 0;
-
- if (max > 0x008000)
- {
- exp = 8 - pv_normalize(max); /* use 24 bits */
-
- exponent = exp; /* keeps track of # of shifts */
-
- }
-
- n2 = FFT_RX4_SHORT;
-
- pw = W_64rx4;
-
-
- /* shift down to avoid possible overflow in first pass of the loop */
- shift = 2;
-
- for (k = FFT_RX4_SHORT; k > 4; k >>= 2)
- {
-
- n1 = n2;
- n2 >>= 2;
- n3 = n1 >> 1;
-
- exp -= 2;
-
- for (i = 0; i < FFT_RX4_SHORT; i += n1)
- {
- pData1 = &Data[ i<<1];
- pData3 = pData1 + n3;
- pData2 = pData1 + n1;
- pData4 = pData3 + n1;
-
- temp1 = *(pData1);
- temp2 = *(pData2);
- temp1 >>= shift;
- temp2 >>= shift;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
-
- temp3 = *(pData3++);
- temp4 = *(pData4++);
- temp3 >>= shift;
- temp4 >>= shift;
-
- t1 = temp3 + temp4;
- t2 = temp3 - temp4;
-
- *(pData1++) = (r1 + t1) >> exp;
- *(pData2++) = (r1 - t1) >> exp;
-
- temp1 = *pData1;
- temp2 = *pData2;
- temp1 >>= shift;
- temp2 >>= shift;
-
- s1 = temp1 + temp2;
- s2 = temp1 - temp2;
-
- temp3 = *pData3;
- temp4 = *pData4;
- temp3 >>= shift;
- temp4 >>= shift;
-
- t1 = temp3 + temp4;
- r1 = temp3 - temp4;
-
- *pData1 = (s1 + t1) >> exp;
- *pData2 = (s1 - t1) >> exp;
-
- *pData4-- = (s2 + t2) >> exp;
- *pData4 = (r2 - r1) >> exp;
-
- *pData3-- = (s2 - t2) >> exp;
- *pData3 = (r2 + r1) >> exp;
-
-
- } /* i */
-
- for (j = 1; j < n2; j++)
- {
- exp_jw1 = *pw++;
- exp_jw2 = *pw++;
- exp_jw3 = *pw++;
-
-
- for (i = j; i < FFT_RX4_SHORT; i += n1)
- {
- pData1 = &Data[ i<<1];
- pData3 = pData1 + n3;
- pData2 = pData1 + n1;
- pData4 = pData3 + n1;
-
- temp1 = *(pData1);
- temp2 = *(pData2++);
- temp1 >>= shift;
- temp2 >>= shift;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
- temp3 = *(pData3++);
- temp4 = *(pData4++);
- temp3 >>= shift;
- temp4 >>= shift;
-
- t1 = temp3 + temp4;
- t2 = temp3 - temp4;
-
- *(pData1++) = (r1 + t1) >> exp;
- r1 = (r1 - t1) >> exp;
-
- temp1 = *pData1;
- temp2 = *pData2;
- temp1 >>= shift;
- temp2 >>= shift;
-
- s1 = temp1 + temp2;
- s2 = temp1 - temp2;
-
- s3 = (s2 + t2) >> exp;
- s2 = (s2 - t2) >> exp;
-
- temp3 = *pData3;
- temp4 = *pData4 ;
- temp3 >>= shift;
- temp4 >>= shift;
-
- t1 = temp3 + temp4;
- t2 = temp3 - temp4;
-
- *pData1 = (s1 + t1) >> exp;
- s1 = (s1 - t1) >> exp;
-
-
- *pData2-- = cmplx_mul32_by_16(s1, -r1, exp_jw2) << 1;
- *pData2 = cmplx_mul32_by_16(r1, s1, exp_jw2) << 1;
-
- r3 = ((r2 - t2) >> exp);
- r2 = ((r2 + t2) >> exp);
-
- *pData3-- = cmplx_mul32_by_16(s2, -r2, exp_jw1) << 1;
- *pData3 = cmplx_mul32_by_16(r2, s2, exp_jw1) << 1;
-
- *pData4-- = cmplx_mul32_by_16(s3, -r3, exp_jw3) << 1;
- *pData4 = cmplx_mul32_by_16(r3, s3, exp_jw3) << 1;
-
- } /* i */
-
- } /* j */
-
- /*
- * this will reset exp and shift to zero for the second pass of the
- * loop
- */
- exp = 2;
- shift = 0;
-
- } /* k */
-
-
- max = 0;
-
- pData1 = Data - 7;
-
- for (i = ONE_FOURTH_FFT_RX4_SHORT; i != 0 ; i--)
- {
- pData1 += 7;
-
- pData3 = pData1 + 2;
- pData2 = pData1 + 4;
- pData4 = pData1 + 6;
-
- temp1 = *pData1;
- temp2 = *pData2++;
-
- r1 = temp1 + temp2;
- r2 = temp1 - temp2;
-
- temp1 = *pData3++;
- temp2 = *pData4++;
-
- t1 = temp1 + temp2;
- t2 = temp1 - temp2;
-
- temp1 = (r1 + t1);
- r1 = (r1 - t1);
- *(pData1++) = temp1;
- max |= (temp1 >> 31) ^ temp1;
-
-
-
- temp1 = *pData1;
- temp2 = *pData2;
-
- s1 = temp1 + temp2;
- s2 = temp1 - temp2;
-
- s3 = (s2 + t2);
- s2 = (s2 - t2);
-
- temp1 = *pData3;
- temp2 = *pData4;
-
- t1 = temp1 + temp2;
- t2 = temp1 - temp2;
-
- temp1 = (s1 + t1);
- temp2 = (s1 - t1);
- *pData1 = temp1;
- *pData2-- = temp2;
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
- *pData2 = r1;
- *pData3-- = s2;
- *pData4-- = s3;
- max |= (r1 >> 31) ^ r1;
- max |= (s2 >> 31) ^ s2;
- max |= (s3 >> 31) ^ s3;
-
- temp1 = (r2 - t2);
- temp2 = (r2 + t2);
- *pData4 = temp1;
- *pData3 = temp2;
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
- } /* i */
-
- *peak_value = max;
-
-
- return (exponent);
-
-}
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp
deleted file mode 100644
index 2476b87..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Reduce the accuracy of w_256rx4 and w_512rx2 to Q10 format.
- Try to to pack sin and cos into one 32-bit number to reduce the
- memory access, but doesn't help in speed, so commented out for now.
-
- Description:
- (1) Reduced precision of w_64rx4 from Q15 to Q12.
- (2) Increased precision of w_512rx2 from Q10 to Q13, Both changes
- increase overall decoder precision
-
- Description:
- (1) per code review comment, added description for table generation
- (2) modified definition of w_64rx4 from Int to Int16
-
-
- Who: Date:
- Description:
-
- ----------------------------------------------------------------------------
- MODULE DESCRIPTION
-
- Table generation
-
- n = 256 or 64;
- M = precision; 2^10, 2^12, 2^13
-
- for j=1; j<log4(n); j *= 4
-
- for i=0; i<n/4; i +=j
-
- phi_1 = 2*pi*i/n;
- phi_2 = 4*pi*i/n;
- phi_3 = 6*pi*i/n;
- M*[cos(phi_1) sin(phi_1) cos(phi_2) sin(phi_2) cos(phi_3) sin(phi_4)];
-
- end
-
- end
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fft_rx4.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
-------------------------------------------------------------------------------
- Forward FFT radix-4 tables
-------------------------------------------------------------------------------
-*/
-
-
-const Int32 W_64rx4[60] = /* 2 Q15 */
-{
-
- 0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
- 0x7D8918F9, 0x764130FB, 0x6A6D471C,
- 0x7A7C2528, 0x6A6D471C, 0x513362F1,
- 0x764130FB, 0x5A825A82, 0x30FB7641,
- 0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
- 0x6A6D471C, 0x30FB7641, 0xE7057D89,
- 0x62F15133, 0x18F97D89, 0xC3A870E2,
- 0x5A825A82, 0x00007FFF, 0xA57C5A82,
- 0x513362F1, 0xE7057D89, 0x8F1C3C56,
- 0x471C6A6D, 0xCF037641, 0x827518F9,
- 0x3C5670E2, 0xB8E26A6D, 0x809DF372,
- 0x30FB7641, 0xA57C5A82, 0x89BDCF03,
- 0x25287A7C, 0x9591471C, 0x9D0DAECB,
- 0x18F97D89, 0x89BD30FB, 0xB8E29591,
- 0x0C8C7F61, 0x827518F9, 0xDAD68582,
- 0x764130FB, 0x5A825A82, 0x30FB7641,
- 0x5A825A82, 0x00007FFF, 0xA57C5A82,
- 0x30FB7641, 0xA57C5A82, 0x89BDCF03,
-};
-
-
-
-const Int32 W_256rx4[495] = /* 2 Q15 */
-{
-
- 0x7FF50324, 0x7FD80648, 0x7FA6096A,
- 0x7FD80648, 0x7F610C8C, 0x7E9C12C8,
- 0x7FA6096A, 0x7E9C12C8, 0x7CE31C0B,
- 0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
- 0x7F090FAB, 0x7C291F1A, 0x776B2E11,
- 0x7E9C12C8, 0x7A7C2528, 0x73B536BA,
- 0x7E1D15E2, 0x78842B1F, 0x6F5E3F17,
- 0x7D8918F9, 0x764130FB, 0x6A6D471C,
- 0x7CE31C0B, 0x73B536BA, 0x64E84EBF,
- 0x7C291F1A, 0x70E23C56, 0x5ED755F5,
- 0x7B5C2223, 0x6DC941CE, 0x58425CB3,
- 0x7A7C2528, 0x6A6D471C, 0x513362F1,
- 0x79892826, 0x66CF4C3F, 0x49B468A6,
- 0x78842B1F, 0x62F15133, 0x41CE6DC9,
- 0x776B2E11, 0x5ED755F5, 0x398C7254,
- 0x764130FB, 0x5A825A82, 0x30FB7641,
- 0x750433DF, 0x55F55ED7, 0x28267989,
- 0x73B536BA, 0x513362F1, 0x1F1A7C29,
- 0x7254398C, 0x4C3F66CF, 0x15E27E1D,
- 0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
- 0x6F5E3F17, 0x41CE6DC9, 0x03247FF5,
- 0x6DC941CE, 0x3C5670E2, 0xF9B67FD8,
- 0x6C23447A, 0x36BA73B5, 0xF0537F09,
- 0x6A6D471C, 0x30FB7641, 0xE7057D89,
- 0x68A649B4, 0x2B1F7884, 0xDDDB7B5C,
- 0x66CF4C3F, 0x25287A7C, 0xD4DF7884,
- 0x64E84EBF, 0x1F1A7C29, 0xCC1F7504,
- 0x62F15133, 0x18F97D89, 0xC3A870E2,
- 0x60EB539B, 0x12C87E9C, 0xBB846C23,
- 0x5ED755F5, 0x0C8C7F61, 0xB3BF66CF,
- 0x5CB35842, 0x06487FD8, 0xAC6360EB,
- 0x5A825A82, 0x00007FFF, 0xA57C5A82,
- 0x58425CB3, 0xF9B67FD8, 0x9F13539B,
- 0x55F55ED7, 0xF3727F61, 0x992F4C3F,
- 0x539B60EB, 0xED367E9C, 0x93DB447A,
- 0x513362F1, 0xE7057D89, 0x8F1C3C56,
- 0x4EBF64E8, 0xE0E47C29, 0x8AFA33DF,
- 0x4C3F66CF, 0xDAD67A7C, 0x877A2B1F,
- 0x49B468A6, 0xD4DF7884, 0x84A22223,
- 0x471C6A6D, 0xCF037641, 0x827518F9,
- 0x447A6C23, 0xC94473B5, 0x80F50FAB,
- 0x41CE6DC9, 0xC3A870E2, 0x80260648,
- 0x3F176F5E, 0xBE306DC9, 0x8009FCDA,
- 0x3C5670E2, 0xB8E26A6D, 0x809DF372,
- 0x398C7254, 0xB3BF66CF, 0x81E1EA1C,
- 0x36BA73B5, 0xAECB62F1, 0x83D5E0E4,
- 0x33DF7504, 0xAA095ED7, 0x8675D7D8,
- 0x30FB7641, 0xA57C5A82, 0x89BDCF03,
- 0x2E11776B, 0xA12755F5, 0x8DAAC672,
- 0x2B1F7884, 0x9D0D5133, 0x9235BE30,
- 0x28267989, 0x992F4C3F, 0x9758B64A,
- 0x25287A7C, 0x9591471C, 0x9D0DAECB,
- 0x22237B5C, 0x923541CE, 0xA34BA7BC,
- 0x1F1A7C29, 0x8F1C3C56, 0xAA09A127,
- 0x1C0B7CE3, 0x8C4936BA, 0xB13F9B16,
- 0x18F97D89, 0x89BD30FB, 0xB8E29591,
- 0x15E27E1D, 0x877A2B1F, 0xC0E790A0,
- 0x12C87E9C, 0x85822528, 0xC9448C49,
- 0x0FAB7F09, 0x83D51F1A, 0xD1ED8893,
- 0x0C8C7F61, 0x827518F9, 0xDAD68582,
- 0x096A7FA6, 0x816212C8, 0xE3F3831B,
- 0x06487FD8, 0x809D0C8C, 0xED368162,
- 0x03247FF5, 0x80260648, 0xF6948058,
- 0x7F610C8C, 0x7D8918F9, 0x7A7C2528,
- 0x7D8918F9, 0x764130FB, 0x6A6D471C,
- 0x7A7C2528, 0x6A6D471C, 0x513362F1,
- 0x764130FB, 0x5A825A82, 0x30FB7641,
- 0x70E23C56, 0x471C6A6D, 0x0C8C7F61,
- 0x6A6D471C, 0x30FB7641, 0xE7057D89,
- 0x62F15133, 0x18F97D89, 0xC3A870E2,
- 0x5A825A82, 0x00007FFF, 0xA57C5A82,
- 0x513362F1, 0xE7057D89, 0x8F1C3C56,
- 0x471C6A6D, 0xCF037641, 0x827518F9,
- 0x3C5670E2, 0xB8E26A6D, 0x809DF372,
- 0x30FB7641, 0xA57C5A82, 0x89BDCF03,
- 0x25287A7C, 0x9591471C, 0x9D0DAECB,
- 0x18F97D89, 0x89BD30FB, 0xB8E29591,
- 0x0C8C7F61, 0x827518F9, 0xDAD68582,
- 0x764130FB, 0x5A825A82, 0x30FB7641,
- 0x5A825A82, 0x00007FFF, 0xA57C5A82,
- 0x30FB7641, 0xA57C5A82, 0x89BDCF03
-};
-
-
-
-/*
-------------------------------------------------------------------------------
- Forward FFT radix-2 table
-------------------------------------------------------------------------------
-*/
-
-
-const Int32 w_512rx2[127] =
-{
- /* Q15 */
- 0x7FFE0192, 0x7FF60324, 0x7FEA04B6,
- 0x7FD90648, 0x7FC207D9, 0x7FA7096B, 0x7F870AFB,
- 0x7F620C8C, 0x7F380E1C, 0x7F0A0FAB, 0x7ED6113A,
- 0x7E9D12C8, 0x7E601455, 0x7E1E15E2, 0x7DD6176E,
- 0x7D8A18F9, 0x7D3A1A83, 0x7CE41C0C, 0x7C891D93,
- 0x7C2A1F1A, 0x7BC6209F, 0x7B5D2224, 0x7AEF23A7,
- 0x7A7D2528, 0x7A0626A8, 0x798A2827, 0x790A29A4,
- 0x78852B1F, 0x77FB2C99, 0x776C2E11, 0x76D92F87,
- 0x764230FC, 0x75A6326E, 0x750533DF, 0x7460354E,
- 0x73B636BA, 0x73083825, 0x7255398D, 0x719E3AF3,
- 0x70E33C57, 0x70233DB8, 0x6F5F3F17, 0x6E974074,
- 0x6DCA41CE, 0x6CF94326, 0x6C24447B, 0x6B4B45CD,
- 0x6A6E471D, 0x698C486A, 0x68A749B4, 0x67BD4AFB,
- 0x66D04C40, 0x65DE4D81, 0x64E94EC0, 0x63EF4FFB,
- 0x62F25134, 0x61F15269, 0x60EC539B, 0x5FE454CA,
- 0x5ED755F6, 0x5DC8571E, 0x5CB45843, 0x5B9D5964,
- 0x5A825A82, 0x59645B9D, 0x58435CB4, 0x571E5DC8,
- 0x55F65ED7, 0x54CA5FE4, 0x539B60EC, 0x526961F1,
- 0x513462F2, 0x4FFB63EF, 0x4EC064E9, 0x4D8165DE,
- 0x4C4066D0, 0x4AFB67BD, 0x49B468A7, 0x486A698C,
- 0x471D6A6E, 0x45CD6B4B, 0x447B6C24, 0x43266CF9,
- 0x41CE6DCA, 0x40746E97, 0x3F176F5F, 0x3DB87023,
- 0x3C5770E3, 0x3AF3719E, 0x398D7255, 0x38257308,
- 0x36BA73B6, 0x354E7460, 0x33DF7505, 0x326E75A6,
- 0x30FC7642, 0x2F8776D9, 0x2E11776C, 0x2C9977FB,
- 0x2B1F7885, 0x29A4790A, 0x2827798A, 0x26A87A06,
- 0x25287A7D, 0x23A77AEF, 0x22247B5D, 0x209F7BC6,
- 0x1F1A7C2A, 0x1D937C89, 0x1C0C7CE4, 0x1A837D3A,
- 0x18F97D8A, 0x176E7DD6, 0x15E27E1E, 0x14557E60,
- 0x12C87E9D, 0x113A7ED6, 0x0FAB7F0A, 0x0E1C7F38,
- 0x0C8C7F62, 0x0AFB7F87, 0x096B7FA7, 0x07D97FC2,
- 0x06487FD9, 0x04B67FEA, 0x03247FF6, 0x01927FFE
-};
-
diff --git a/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp b/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp
deleted file mode 100644
index 535f177..0000000
--- a/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/find_adts_syncword.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Fixed error in logic that determines whether there are enough
- bits available to conduct a search for the syncword. The plus sign in
- the following condition should be a minus.
-
- if (pInputStream->usedBits <
- (pInputStream->availableBits + syncword_length)
-
- The length of the syncword should subtract from the number of available
- bits, not add.
-
- Description: Fixed condition when the end of file was found, unsigned
- comparison produced a undesired search. Fixed by casting comparison
- if ((Int)pInputStream->usedBits <
- ((Int)pInputStream->availableBits - syncword_length) )
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pSyncword = Pointer to variable containing the syncword that the
- function should be scanning for in the buffer. [ UInt32 * ]
-
- pInputStream = Pointer to a BITS structure, used by the function getbits
- to retrieve data from the bitstream. [ BITS * ]
-
- syncword_length = The length of the syncword. [ Int ]
-
- syncword_mask = A mask to be applied to the bitstream before comparison
- with the value pointed to by pSyncword. [ UInt32 ]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- None
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module scans the bitstream for a syncword of any length between 1 and 32.
- If certain bits in the syncword are to be ignored, that bit position should
- be set to 0 in both parameters *(pSyncword) and syncword_mask. This allows
- for a syncword to be constructed out of non-contiguous bits.
-
- Upon finding the syncword's position in the bitstream, a value denoting the
- syncword's degree of deviance from being byte-aligned (byte_align_offset)
- is set in the structure pointed to by pInputStream.
- This is a value between 0 and 7.
-
- If no syncword is found, the function returns status == ERROR.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- "Don't care" bits must be set to '0' in both *(pSyncword) and syncword_mask.
-
- This function should not be called if there are less than
- (8 + syncword_length) bits in the buffer.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 13818-7:1997(E)
- Part 7
- Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
-
- (2) ISO/IEC 11172-3:1993(E)
- Part 3
- Subpart 2.4.3 The audio decoding process
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF (pInputStream->usedBits <
- (pInputStream->availableBits + syncword_length) )
-
- max_search_length = (pInputStream->availableBits - pInputStream->usedBits);
-
- max_search_length = max_search_length - syncword_length;
-
- search_length = 0;
-
- adts_header =
- CALL getbits(syncword_length, pInputStream);
- MODIFYING pInputStream->usedBits
- RETURNING bits from bitstream of length (syncword_length)
-
- test_for_syncword = adts_header AND syncword_mask;
- test_for_syncword = test_for_syncword XOR syncword;
-
- WHILE ( (test_for_syncword != 0) && (search_length > 0) )
-
- search_length = search_length - 1;
-
- adts_header = adts_header << 1;
- adts_header = adts_header OR ...
-
- CALL getbits(syncword_length, pInputStream);
- MODIFYING pInputStream->usedBits
- RETURNING 1 bit from the bitstream
-
- test_for_syncword = adts_header AND syncword_mask;
- test_for_syncword = test_for_syncword XOR syncword;
-
- ENDWHILE
-
- IF (search_length == 0)
- status = ERROR;
- ENDIF
-
- *(pSyncword) = adts_header;
-
- pInputStream->byteAlignOffset =
- (pInputStream->usedBits - syncwordlength) AND 0x7;
-
- ELSE
- status = ERROR;
- ENDIF
-
- return (status);
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "find_adts_syncword.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define FIND_ADTS_ERROR -1
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int find_adts_syncword(
- UInt32 *pSyncword,
- BITS *pInputStream,
- Int syncword_length,
- UInt32 syncword_mask)
-{
-
- Int status = SUCCESS;
- UInt search_length;
- UInt32 adts_header = 0;
- UInt32 test_for_syncword;
- UInt32 syncword = *(pSyncword);
-
- /*
- * Determine the maximum number of bits available to this function for
- * the syncword search.
- */
- if ((Int)pInputStream->usedBits <
- ((Int)pInputStream->availableBits - syncword_length))
- {
- search_length = (pInputStream->availableBits - pInputStream->usedBits);
-
- search_length -= syncword_length;
-
- adts_header = getbits(syncword_length, pInputStream);
-
- /*
- * Mask the result in adts_header with the syncword_mask, so only the
- * bits relevant to syncword detection are compared to *(pSyncword).
- */
- test_for_syncword = adts_header & syncword_mask;
- test_for_syncword ^= syncword;
-
- /*
- * Scan bit-by-bit through the bitstream, until the function either
- * runs out of bits, or finds the syncword.
- */
-
- while ((test_for_syncword != 0) && (search_length > 0))
- {
- search_length--;
-
- adts_header <<= 1;
- adts_header |= getbits(1, pInputStream);
-
- test_for_syncword = adts_header & syncword_mask;
- test_for_syncword ^= syncword;
- }
-
- if (search_length == 0)
- {
- status = FIND_ADTS_ERROR;
- }
-
- /*
- * Return the syncword's position in the bitstream. Correct placement
- * of the syncword will result in byte_align_offset == 0.
- * If the syncword is found not to be byte-aligned, then return
- * the degree of disalignment, so further decoding can
- * be shifted as necessary.
- *
- */
- pInputStream->byteAlignOffset =
- (pInputStream->usedBits - syncword_length) & 0x7;
-
- } /* END if (pInputStream->usedBits < ...) */
-
- else
- {
- status = FIND_ADTS_ERROR;
- }
-
- *(pSyncword) = adts_header;
-
- return (status);
-
-} /* find_adts_syncword() */
diff --git a/media/libstagefright/codecs/aacdec/find_adts_syncword.h b/media/libstagefright/codecs/aacdec/find_adts_syncword.h
deleted file mode 100644
index d147bc5..0000000
--- a/media/libstagefright/codecs/aacdec/find_adts_syncword.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/find_adts_syncword.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for find_adts_syncword()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FIND_ADTS_SYNCWORD_H
-#define FIND_ADTS_SYNCWORD_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int find_adts_syncword(
- UInt32 *pSyncword,
- BITS *pInputStream,
- Int syncword_length,
- UInt32 syncword_mask);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp b/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp
deleted file mode 100644
index b85c7df..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fwd_long_complex_rot.c
- Funtions: fwd_long_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
- (1) Change the input arguments, no shifts information from
- long_fft_rx4 is passed, only a single max is passed.
- (2) Eliminate search for max, a fixed shift has replaced the
- search for max with minimal loss of precision.
- (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
- (1) Added comments per code review
- (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Data_in = Input vector (sized for long windows
- TWICE_FWD_LONG_CX_ROT_LENGTH), with time domain samples
- type Int32 *
-
- Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
- (sized for long windows TWICE_FWD_LONG_CX_ROT_LENGTH)
- type Int32 *
-
- max = Input, carries the maximum value of the input vector
- "Data_in"
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
- Results are return in "Data_out"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- fwd_long_complex_rot() performs the pre complex rotation for the MDCT
- for the case of long windows. It also performs digit reverse ordering of
- the first and second halves of the input vector "Data_in", as well as
- reordering of the two half vectors (following radix-2 decomposition)
- Word normalization is also done to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- fwd_long_complex_rot() should execute a pre-rotation by
- exp(-j(2pi/N)(k+1/8)), digit reverse ordering and normalization
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fwd_long_complex_rot.h"
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int fwd_long_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max)
-{
- Int i;
- const Int32 *p_rotate;
- Int32 temp_re;
- Int32 temp_im;
- Int32 *pData_in_ref1;
- Int32 *pData_in_ref2;
- Int32 exp_jw;
- Int32 temp_re_32;
- Int32 temp_im_32;
-
- Int32 *pData_out_1;
- Int32 *pData_out_2;
- Int32 *pData_out_3;
- Int32 *pData_out_4;
-
- Int32 *pData_in_1;
- Int32 *pData_in_2;
-
- Int exp;
-
- p_rotate = exp_rotation_N_2048;
-
- pData_in_ref1 = Data_in;
- pData_in_ref2 = &Data_in[TWICE_FWD_LONG_CX_ROT_LENGTH];
-
- pData_out_1 = Data_out;
- pData_out_2 = &Data_out[LONG_WINDOW_LENGTH_m_1];
- pData_out_3 = &Data_out[LONG_WINDOW_LENGTH];
- pData_out_4 = &Data_out[TWICE_LONG_WINDOW_LENGTH_m_1];
-
- /*
- * Data_out
- * >>>> <<<<
- * pData_out_3 pData_out_4
- * | | | | |
- * pData_out_1 pData_out_2
- * >>>> <<<<
- */
-
-
- exp = 16 - pv_normalize(max);
-
- if (exp < 0)
- {
- exp = 0;
- }
-
- /*
- * Apply A/2^(diff) + B
- */
-
-
- pData_in_1 = pData_in_ref1;
- pData_in_2 = pData_in_ref2;
-
- for (i = FWD_LONG_CX_ROT_LENGTH; i != 0; i--)
- {
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- exp_jw = *p_rotate++;
-
- /*
- * Use auxiliary variables to avoid double accesses to memory.
- * Data in is scaled to use only lower 16 bits.
- */
-
- temp_re = *(pData_in_1++) >> exp;
- temp_im = *(pData_in_1++) >> exp;
-
- /*
- * Pre-rotation
- */
-
- temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw));
- temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw));
-
- *(pData_out_1++) = - temp_re_32;
- *(pData_out_2--) = temp_im_32;
- *(pData_out_3++) = - temp_im_32;
- *(pData_out_4--) = temp_re_32;
-
- /*
- * Pointer increment to jump over imag (1 & 4) or real parts
- * (2 & 3)
- */
- pData_out_1++;
- pData_out_2--;
- pData_out_3++;
- pData_out_4--;
-
- /*
- * Repeat procedure for odd index at the output
- */
-
- exp_jw = *p_rotate++;
-
- temp_re = *(pData_in_2++) >> exp;
- temp_im = *(pData_in_2++) >> exp;
-
- temp_re_32 = (cmplx_mul32_by_16(temp_re, temp_im, exp_jw));
- temp_im_32 = (cmplx_mul32_by_16(temp_im, -temp_re, exp_jw));
-
- *(pData_out_1++) = - temp_re_32;
- *(pData_out_2--) = temp_im_32;
- *(pData_out_3++) = - temp_im_32;
- *(pData_out_4--) = temp_re_32;
-
- pData_out_1++;
- pData_out_2--;
- pData_out_3++;
- pData_out_4--;
-
- }
-
- return (exp + 1);
-}
diff --git a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h b/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h
deleted file mode 100644
index 5978906..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/fwd_long_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fwd_long_complex_rot
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FWD_LONG_COMPLEX_ROT_H
-#define FWD_LONG_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FWD_LONG_CX_ROT_LENGTH 256
-#define TWICE_FWD_LONG_CX_ROT_LENGTH (FWD_LONG_CX_ROT_LENGTH<<1)
-#define LONG_WINDOW_LENGTH 1024
-#define LONG_WINDOW_LENGTH_m_1 (LONG_WINDOW_LENGTH - 1)
-#define TWICE_LONG_WINDOW_LENGTH_m_1 ((LONG_WINDOW_LENGTH<<1) - 1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-
-Int fwd_long_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* FWD_LONG_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp b/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp
deleted file mode 100644
index 964f766..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./src/fwd_short_complex_rot.c
- Funtions: fwd_short_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
- (1) Change the input argument, only a single max is passed.
- (2) Eliminate search for max, a fixed shift has replaced the
- search for max with minimal loss of precision.
- (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
- (1) Added comments per code review
- (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Data_in = Input vector (sized for short windows
- 2*FWD_SHORT_CX_ROT_LENGTH elements), with freq. domain samples
- type Int32 *
-
- Data_out = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
- (sized for short windows 2*FWD_SHORT_CX_ROT_LENGTH)
- type Int32 *
-
- max = Input, carries the maximum value of the input vector
- "Data_in"
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
- Results are return in "Data_out"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- fwd_short_complex_rot() performs the complex rotation for the MDCT
- for the case of short windows. It performs digit reverse ordering as well
- word normalization to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- fwd_short_complex_rot() should execute a pre-rotation by
- exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fwd_short_complex_rot.h"
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "pv_normalize.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int fwd_short_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max)
-
-{
- Int i;
- Int16 I;
- const Int16 *pTable;
- const Int32 *p_rotate;
-
- Int32 *pData_in_1;
- Int exp;
- Int32 temp_re;
- Int32 temp_im;
-
- Int32 cos_n;
- Int32 sin_n;
- Int32 temp_re_32;
- Int32 temp_im_32;
-
- Int32 *pData_in_ref;
-
- Int32 *pData_out_1;
- Int32 *pData_out_2;
- Int32 *pData_out_3;
- Int32 *pData_out_4;
-
- pTable = digit_reverse_64;
- p_rotate = exp_rotation_N_256;
-
- pData_in_ref = Data_in;
-
- exp = 16 - pv_normalize(max);
-
- if (exp < 0)
- {
- exp = 0;
- }
-
- pData_out_1 = Data_out;
- pData_out_2 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1];
- pData_out_3 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH];
- pData_out_4 = &Data_out[FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1];
-
- /*
- * Data_out
- * >>>> <<<<
- * pData_out_3 pData_out_4
- * | | | | |
- * pData_out_1 pData_out_2
- * >>>> <<<<
- */
-
-
- for (i = FWD_SHORT_CX_ROT_LENGTH; i != 0; i--)
- {
- /*
- * Perform digit reversal by accessing index I from table
- */
-
- I = *pTable++;
- pData_in_1 = pData_in_ref + I;
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- sin_n = *p_rotate++;
- cos_n = sin_n >> 16;
- sin_n = sin_n & 0xFFFF;
-
- /*
- * Use auxiliary variables to avoid double accesses to memory.
- * Data in is scaled to use only lower 16 bits.
- */
-
- temp_re = *(pData_in_1++) >> exp;
- temp_im = *(pData_in_1) >> exp;
-
- /*
- * Pre-rotation
- */
-
- temp_re_32 = (temp_re * cos_n + temp_im * sin_n) >> 16;
- temp_im_32 = (temp_im * cos_n - temp_re * sin_n) >> 16;
-
- *(pData_out_1++) = - temp_re_32;
- *(pData_out_2--) = temp_im_32;
- *(pData_out_3++) = - temp_im_32;
- *(pData_out_4--) = temp_re_32;
-
- /*
- * Pointer increment to jump over imag (1 & 4) or real parts
- * (2 & 3)
- */
-
- pData_out_1++;
- pData_out_2--;
- pData_out_3++;
- pData_out_4--;
-
- } /* for(i) */
-
- return (exp);
-}
diff --git a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h b/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h
deleted file mode 100644
index 3d1e1f1..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fwd_short_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fwd_short_complex_rot
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FWD_SHORT_COMPLEX_ROT_H
-#define FWD_SHORT_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FWD_SHORT_CX_ROT_LENGTH 64
-#define TWICE_FWD_SHORT_CX_ROT_LENGTH (FWD_SHORT_CX_ROT_LENGTH<<1)
-#define TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<1) - 1)
-#define FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1 ((FWD_SHORT_CX_ROT_LENGTH<<2) - 1)
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int fwd_short_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* FWD_SHORT_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32.h b/media/libstagefright/codecs/aacdec/fxp_mul32.h
deleted file mode 100644
index 230cef5..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32
-#define FXP_MUL32
-
-#if defined(PV_ARM_V5)
-
-#include "fxp_mul32_arm_v5.h"
-
-#elif defined(PV_ARM_V4)
-
-#include "fxp_mul32_arm_v4.h"
-
-#elif defined(PV_ARM_MSC_EVC_V4)
-
-#include "fxp_mul32_c_msc_evc.h"
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-#include "fxp_mul32_c_msc_evc_armv5.h"
-
-#elif defined(PV_ARM_GCC_V5)
-
-#include "fxp_mul32_arm_gcc.h"
-
-#elif defined(PV_ARM_GCC_V4)
-
-#include "fxp_mul32_arm_v4_gcc.h"
-
-#else
-
-#ifndef C_EQUIVALENT
-#define C_EQUIVALENT
-#endif
-
-#include "fxp_mul32_c_equivalent.h"
-
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h
deleted file mode 100644
index dc58976..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h
+++ /dev/null
@@ -1,547 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_arm_gcc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_GCC
-#define FXP_MUL32_ARM_GCC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if (defined (PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5)) /* ARM GNU COMPILER */
-
-
-
-#define preload_cache( a)
-
-
- static inline Int32 shft_lft_1(Int32 y)
- {
- register Int32 x;
- register Int32 ra = y;
-
-
- asm volatile(
- "qadd %0, %1, %1\n\t"
- : "=&r*i"(x)
- : "r"(ra));
-
- return (x);
- }
-
- static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, const Int32 L_var2)
- {
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smulbb %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
-
- static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, const Int32 L_var2)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smultb %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
- static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, const Int32 L_var2)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smulbt %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
- static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, const Int32 L_var2)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smultt %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
- static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "smlabb %0, %1, %2, %3"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp);
- }
-
-
-
- static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "smlabb %0, %1, %2, %3"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp);
- }
-
-
- static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "smlabt %0, %1, %2, %3"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp);
- }
-
-
-
- static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
-{
- register Int32 cx_sum;
- register Int32 rx = (Int32)x;
- register Int32 ry = (Int32)y;
- register Int32 rexp = (Int32)exp_jw;
- asm volatile(
- "smulwt %0, %1, %3\n\t"
- "smlawb %0, %2, %3, %0"
- : "=&r*i"(cx_sum)
- : "r"(rx),
- "r"(ry),
- "r"(rexp));
-
- return (cx_sum);
- }
-
-
- static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smulwb %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-
- static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "smulwt %0, %1, %2"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb));
-
- return (tmp);
- }
-
-
-
- static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
-
- register Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "smlawb %0, %1, %2, %3"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp);
- }
-
-
- __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-{
- sum += (int64)L_var1 * L_var2;
- return (sum);
- }
-
-
-
-
- static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %4, %4, %0, asl #2\n\t"
- "add %0, %4, %1, lsr #30"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-{
-
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %0, %0, %4"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_sub;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "sub %0, %4, %0"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile(
- "smull %1, %0, %2, %3"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #2\n\t"
- "orr %0, %0, %1, lsr #30"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %4, %4, %0, lsl #3\n\t"
- "add %0, %4, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_sub;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "sub %4, %4, %0, lsl #3\n\t"
- "sub %0, %4, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
- static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #3\n\t"
- "orr %0, %0, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #4\n\t"
- "orr %0, %0, %1, lsr #28"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
- static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #5\n\t"
- "orr %0, %0, %1, lsr #27"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #6\n\t"
- "orr %0, %0, %1, lsr #26"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #12\n\t"
- "orr %0, %0, %1, lsr #20"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #17\n\t"
- "orr %0, %0, %1, lsr #15"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #18\n\t"
- "orr %0, %0, %1, lsr #14"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h
deleted file mode 100644
index 6869c54..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_c_equivalent.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_V4
-#define FXP_MUL32_ARM_V4
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(PV_ARM_V4)
-
-#define preload_cache( a)
-
-
- __inline Int32 shft_lft_1(Int32 L_var1)
- {
- Int32 x;
- Int32 z = 1; /* rvct compiler problem */
- __asm
- {
- mov x, L_var1, asl 1
- teq L_var1, x, asr z
- eorne x, INT32_MAX, L_var1, asr #31
- }
-
- return(x);
- }
-
-
- __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
-
- mov L_var2, L_var2, asl #16
- mov L_var2, L_var2, asr #16
- mov L_var1, L_var1, asl #16
- mov L_var1, L_var1, asr #16
-
-
- mul L_var1, L_var2, L_var1
- }
-
- return L_var1;
-
- }
-
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
-
- __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- mov L_var2, L_var2, asl #16
- mov L_var2, L_var2, asr #16
- mov L_var1, L_var1, asr #16
-
- mul L_var1, L_var2, L_var1
- }
- return L_var1;
- }
-
- __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- mov L_var2, L_var2, asr #16
- mov L_var1, L_var1, asl #16
- mov L_var1, L_var1, asr #16
-
- mul L_var1, L_var2, L_var1
- }
-
- return L_var1;
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- mov L_var2, L_var2, asr #16
- mov L_var1, L_var1, asr #16
-
- mul L_var1, L_var2, L_var1
- }
-
- return L_var1;
-
- }
-
- __inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- mla L_add, L_var1, L_var2, L_add
- }
- return (L_add);
- }
-
-
- __inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- mov L_var2, L_var2, asl #16
- mov L_var2, L_var2, asr #16
- mla L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
- __inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- mov L_var2, L_var2, asr #16
- mla L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
-
- __inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
- {
-
- Int32 result64_hi;
- Int32 rTmp0;
- Int32 iTmp0;
- __asm
- {
- mov rTmp0, exp_jw, asr #16
- mov rTmp0, rTmp0, asl #16
- mov iTmp0, exp_jw, asl #16
- smull rTmp0, result64_hi, x, rTmp0
- smlal iTmp0, result64_hi, y, iTmp0
- }
-
- return (result64_hi);
- }
-
-
- __inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
- {
- Int32 result64_hi;
- __asm
- {
- mov L_var2, L_var2, asl #16
- smull L_var1, result64_hi, L_var2, L_var1
- }
- return (result64_hi);
- }
-
-
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-
-
- __inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
- {
-
- Int32 result64_hi;
- __asm
- {
- mov L_var2, L_var2, asr #16
- mov L_var2, L_var2, asl #16
- smull L_var1, result64_hi, L_var2, L_var1
- }
- return (result64_hi);
-
- }
-
- __inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
-
- __asm
- {
- mov L_var2, L_var2, asl #16
- smlal L_var1, L_add, L_var2, L_var1
- }
-
- return (L_add);
- }
-
-
- __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
- {
- uint32 b = (UInt32)(sum);
- int32 c = Int32(sum >> 32);
- __asm
- {
- smlal b, c, L_var1, L_var2
- }
- return (((int64(c)) << 32) | b);
- }
-
-
- __inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- __asm
- {
- smull L_var1, result64_hi, L_var2, L_var1
- }
- return (result64_hi);
- }
-
-
- __inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2)
- {
- __asm
- {
- smlal L_var1, L_add, L_var2, L_var1
- }
- return L_add;
- }
-
- __inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2)
- {
- __asm
- {
- rsb L_var1, L_var1, #0
- smlal L_var1, L_sub, L_var2, L_var1
- }
- return L_sub;
- }
-
-
- __inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #2
- orr result64_hi, result64_hi, result64_lo, lsr #30
- }
- return (result64_hi);
- }
-
-
- __inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- add L_add, L_add, result64_hi, asl #2
- add L_add, L_add, result64_lo, lsr #30
- }
- return (L_add);
- }
-
-
- __inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #3
- orr result64_hi, result64_hi, result64_lo, lsr #29
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- add L_add, L_add, result64_hi, asl #3
- add L_add, L_add, result64_lo, lsr #29
- }
- return (L_add);
- }
-
- __inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- sub L_sub, L_sub, result64_hi, asl #3
- sub L_sub, L_sub, result64_lo, lsr #29
- }
- return (L_sub);
- }
-
- __inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #4
- orr result64_hi, result64_hi, result64_lo, lsr #28
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #5
- orr result64_hi, result64_hi, result64_lo, lsr #27
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #6
- orr result64_hi, result64_hi, result64_lo, lsr #26
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #12
- orr result64_hi, result64_hi, result64_lo, lsr #20
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #17
- orr result64_hi, result64_hi, result64_lo, lsr #15
- }
- return (result64_hi);
- }
-
-
-
-
- __inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #18
- orr result64_hi, result64_hi, result64_lo, lsr #14
- }
- return (result64_hi);
- }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h
deleted file mode 100755
index f4ab2f7..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h
+++ /dev/null
@@ -1,630 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_arm_v4_gcc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-
-
-#ifndef FXP_MUL32_V4_ARM_GCC
-#define FXP_MUL32_V4_ARM_GCC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined (_ARM_V4_GCC) /* ARM_V4 GNU COMPILER */
-
-
-#define preload_cache( a)
-
-
- static inline Int32 shft_lft_1(Int32 L_var1)
- {
- Int32 x;
- register Int32 ra = L_var1;
- Int32 z = INT32_MAX;
-
- asm volatile(
- "mov %0, %1, asl #1\n\t"
- "teq %1, %0, asr #1\n\t"
- "eorne %0, %2, %1, asr #31"
- : "=&r*i"(x)
- : "r"(ra),
- "r"(z));
-
- return(x);
- }
-
- static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %3, asl #16\n\t"
- "mov %0, %0, asr #16\n\t"
- "mov %1, %2, asl #16\n\t"
- "mov %1, %1, asr #16\n\t"
- "mul %0, %1, %0"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb));
-
- return (tmp1);
-
- }
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
-
- static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %3, asl #16\n\t"
- "mov %0, %0, asr #16\n\t"
- "mov %1, %2, asr #16\n\t"
- "mul %0, %1, %0"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb));
-
- return (tmp1);
-
- }
-
-
- static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %3, asr #16\n\t"
- "mov %1, %2, asl #16\n\t"
- "mov %1, %1, asr #16\n\t"
- "mul %0, %1, %0"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb));
-
- return (tmp1);
-
- }
-
-
- static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %3, asr #16\n\t"
- "mov %1, %2, asr #16\n\t"
- "mul %0, %1, %0"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb));
-
- return (tmp1);
-
- }
-
-
-
- static inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
-{
-
- Int32 tmp;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "mla %0, %1, %2, %3"
- : "=&r*i"(tmp)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp);
- }
-
-
-
- static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "mov %0, %3, asl #16\n\t"
- "mov %0, %0, asr #16\n\t"
- "mla %1, %0, %2, %4"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp2);
- }
-
-
-
- static inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
-{
-
- Int32 tmp1;
- Int32 tmp2;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "mov %0, %3, asr #16\n\t"
- "mla %1, %0, %2, %4"
- : "=&r*i"(tmp1),
- "=&r*i"(tmp2)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (tmp2);
-
- }
-
-
-
- static inline Int32 cmplx_mul32_by_16(Int32 x, Int32 y, Int32 exp_jw)
-{
-
- Int32 rTmp0;
- Int32 iTmp0;
- Int32 result64_hi;
- register Int32 ra = (Int32)x;
- register Int32 rb = (Int32)y;
- register Int32 rc = (Int32)exp_jw;
-
-
-
- asm volatile(
- "mov %0, %5, asr #16\n\t"
- "mov %1, %5, asl #16\n\t"
- "mov %0, %0, asl #16\n\t"
- : "=&r*i"(rTmp0),
- "=&r*i"(iTmp0),
- "=&r*i"(result64_hi)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
-
- asm volatile(
- "smull %0, %2, %3, %0\n\t"
- "smlal %1, %2, %4, %1"
- : "=&r*i"(rTmp0),
- "=&r*i"(iTmp0),
- "=&r*i"(result64_hi)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
-
-
- }
-
-
- static inline Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 rTmp0;
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %4, asl #16\n\t"
- "smull %2, %1, %0, %3"
- : "=&r*i"(rTmp0),
- "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-
-
- static inline Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
-{
-
- Int32 rTmp0;
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
-
- asm volatile(
- "mov %0, %4, asr #16\n\t"
- "mov %0, %0, asl #16\n\t"
- "smull %2, %1, %0, %3"
- : "=&r*i"(rTmp0),
- "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
-{
-
- Int32 rTmp0;
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)L_var1;
- register Int32 rb = (Int32)L_var2;
- register Int32 rc = (Int32)L_add;
-
- asm volatile(
- "mov %0, %4, asl #16\n\t"
- "mov %1, %5\n\t"
- "smlal %2, %1, %0, %3"
- : "=&r*i"(rTmp0),
- "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
- static inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-{
- sum += (int64)L_var1 * L_var2;
- return (sum);
- }
-
-
- static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %4, %4, %0, asl #2\n\t"
- "add %0, %4, %1, lsr #30"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-{
-
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %0, %0, %4"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_sub;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "sub %0, %4, %0"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile(
- "smull %1, %0, %2, %3"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #2\n\t"
- "orr %0, %0, %1, lsr #30"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_add;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "add %4, %4, %0, lsl #3\n\t"
- "add %0, %4, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- register Int32 rc = (Int32)L_sub;
-
- asm volatile("smull %1, %0, %2, %3\n\t"
- "sub %4, %4, %0, lsl #3\n\t"
- "sub %0, %4, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb),
- "r"(rc));
-
- return (result64_hi);
- }
-
- static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #3\n\t"
- "orr %0, %0, %1, lsr #29"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #4\n\t"
- "orr %0, %0, %1, lsr #28"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
- return (result64_hi);
- }
-
- static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #5\n\t"
- "orr %0, %0, %1, lsr #27"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #6\n\t"
- "orr %0, %0, %1, lsr #26"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #12\n\t"
- "orr %0, %0, %1, lsr #20"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
- static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #17\n\t"
- "orr %0, %0, %1, lsr #15"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-
-
- static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-{
- Int32 result64_hi;
- Int32 result64_lo;
- register Int32 ra = (Int32)a;
- register Int32 rb = (Int32)b;
- asm volatile("smull %1, %0, %2, %3\n\t"
- "mov %0, %0, lsl #18\n\t"
- "orr %0, %0, %1, lsr #14"
- : "=&r*i"(result64_hi),
- "=&r*i"(result64_lo)
- : "r"(ra),
- "r"(rb));
-
- return (result64_hi);
- }
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32_V4_ARM_GCC */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h
deleted file mode 100644
index 8ab108f..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h
+++ /dev/null
@@ -1,450 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_arm_v5.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_V5
-#define FXP_MUL32_ARM_V5
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(PV_ARM_V5)
-
-//#undef EXTENDED_ASM
-#define EXTENDED_ASM
-#define _ARM_V5_
-
-
- __inline Int32 shft_lft_1(Int32 L_var1)
- {
- __asm
- {
- qadd L_var1, L_var1, L_var1
- }
-
- return L_var1;
- }
-
-
- __inline Int32 fxp_mul_16_by_16(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- smulbb L_var1, L_var1, L_var2
- }
- return L_var1;
- }
-
-
- __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- smulbb L_var1, L_var1, L_var2
- }
- return L_var1;
- }
-
-
- __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- smultb L_var1, L_var1, L_var2
- }
- return L_var1;
- }
-
- __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- smultt L_var1, L_var1, L_var2
- }
- return L_var1;
- }
-
- __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
- {
- __asm
- {
- smulbt L_var1, L_var1, L_var2
- }
- return L_var1;
- }
-
-
-
- __inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlabb L_add, L_var1, L_var2, L_add
- }
- return (L_add);
- }
-
- __inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlabb L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
- __inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlabt L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
-
- __inline Int32 fxp_mac_16_by_16_tb(const Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlatb L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
- __inline Int32 fxp_mac_16_by_16_tt(const Int32 L_var1, Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlatt L_add, L_var1, L_var2, L_add
- }
- return L_add;
- }
-
- __inline Int32 fxp_mac32_by_16(Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- __asm
- {
- smlawb L_add, L_var1, L_var2, L_add
- }
- return (L_add);
- }
-
-
- __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
- {
- uint32 b = (UInt32)(sum);
- int32 c = Int32(sum >> 32);
- __asm
- {
- smlal b, c, L_var1, L_var2
- }
- return (((int64(c)) << 32) | b);
- }
-
-
- __inline Int32 fxp_mac32_Q31(Int32 L_add, Int32 L_var1, const Int32 L_var2)
- {
- __asm
- {
- smlal L_var1, L_add, L_var2, L_var1
- }
- return L_add;
- }
-
- __inline Int32 fxp_msu32_Q31(Int32 L_sub, Int32 L_var1, const Int32 L_var2)
- {
- __asm
- {
- rsb L_var1, L_var1, #0
- smlal L_var1, L_sub, L_var2, L_var1
- }
- return L_sub;
- }
-
- __inline Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- __asm
- {
- smull L_var1, result64_hi, L_var2, L_var1
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #2
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #30
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #30
-#endif
- }
- return (result64_hi);
- }
-
-
- __inline Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- add L_add, L_add, result64_hi, asl #2
- add L_add, L_add, result64_lo, lsr #30
- }
- return (L_add);
- }
-
-
- __inline Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #3
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #29
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #29
-#endif
- }
- return (result64_hi);
- }
-
-
-
- __inline Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- add L_add, L_add, result64_hi, asl #3
- add L_add, L_add, result64_lo, lsr #29
- }
- return (L_add);
- }
-
-
- __inline Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- sub L_sub, L_sub, result64_hi, asl #3
- sub L_sub, L_sub, result64_lo, lsr #29
- }
- return (L_sub);
- }
-
-
- __inline Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #4
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #28
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #28
-#endif
-
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #5
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #27
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #27
-#endif
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #6
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #26
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #26
-#endif
-
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #12
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #20
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #20
-#endif
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- __asm
- {
- smulwb result64_hi, L_var1, L_var2
- }
- return (result64_hi);
- }
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16(a, b)
-
- __inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- __asm
- {
- smulwt result64_hi, L_var1, L_var2
- }
- return (result64_hi);
- }
-
- __inline Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #17
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #15
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #15
-#endif
- }
- return (result64_hi);
- }
-
-
- __inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
- {
- Int32 result64_hi;
-
- __asm
- {
- smulwt result64_hi, L_var1, cmplx
- smlawb result64_hi, L_var2, cmplx, result64_hi
- }
- return (result64_hi);
-
- }
-
- __inline Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
- {
- Int32 result64_hi;
- Int32 result64_lo;
- __asm
- {
- smull result64_lo, result64_hi, L_var2, L_var1
- mov result64_hi, result64_hi, asl #18
-#ifdef EXTENDED_ASM
- mov result64_lo, result64_lo, lsr #14
- orr result64_hi, result64_lo, result64_hi
-#else
- orr result64_hi, result64_hi, result64_lo, lsr #14
-#endif
- }
- return (result64_hi);
- }
-
-
-#define preload_cache( a)
-
-
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h
deleted file mode 100644
index 5bcbe53..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_c_equivalent.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_C_EQUIVALENT
-#define FXP_MUL32_C_EQUIVALENT
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(C_EQUIVALENT)
-
-#define preload_cache( a)
-
- __inline Int32 shft_lft_1(Int32 L_var1)
- {
- if (((L_var1 << 1) >> 1) == L_var1)
- L_var1 <<= 1;
- else
- L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
-
- return (L_var1);
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = (L_var2 << 16) >> 16;
- L_var1 = (L_var1 << 16) >> 16;
-
- L_var1 *= L_var2;
-
- return L_var1;
-
- }
-
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
-
- __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = (L_var2 << 16) >> 16;
- L_var1 = L_var1 >> 16;
-
- L_var1 *= L_var2;
-
- return L_var1;
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = L_var2 >> 16;
- L_var1 = (L_var1 << 16) >> 16;
-
- L_var1 *= L_var2;
-
- return L_var1;
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = L_var2 >> 16;
- L_var1 = L_var1 >> 16;
-
- L_var1 *= L_var2;
-
- return L_var1;
-
- }
-
- __inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
- {
-
- L_add += L_var1 * L_var2;
-
- return L_add;
-
- }
-
-
-
-
-
- __inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
- {
- L_var2 = (L_var2 << 16) >> 16;
-
- L_add += L_var1 * L_var2;
-
- return L_add;
-
- }
-
-
- __inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
- {
- L_var2 = L_var2 >> 16;
-
- L_add += L_var1 * L_var2;
-
- return L_add;
-
- }
-
-
-
-
-
- __inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
- {
- Int32 rTmp0 = (Int16)(exp_jw >> 16);
- Int32 iTmp0 = exp_jw;
- Int32 z;
-
- z = (Int32)(((int64_t)x * (rTmp0 << 16)) >> 32);
- z += (Int32)(((int64_t)y * (iTmp0 << 16)) >> 32);
-
- return (z);
- }
-
-
- __inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
- {
- Int32 z;
-
- z = (Int32)(((int64_t) L_var1 * (L_var2 << 16)) >> 32);
- return(z);
- }
-
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-
- __inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
- {
- Int32 rTmp0 = (Int16)(L_var2 >> 16);
- Int32 z;
-
- z = (Int32)(((int64_t) L_var1 * (rTmp0 << 16)) >> 32);
-
- return(z);
- }
-
-
- __inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
- Int32 rTmp0 = L_var2 << 16;
-
- L_add += (Int32)(((int64_t) L_var1 * rTmp0) >> 32);
-
- return(L_add);
- }
-
- __inline int64_t fxp_mac64_Q31(int64_t sum, const Int32 L_var1, const Int32 L_var2)
- {
- sum += (int64_t)L_var1 * L_var2;
- return (sum);
- }
-
- __inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 32);
- }
-
- __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
- {
- return (L_add + (Int32)(((int64_t)(a) * b) >> 32));
- }
-
- __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
- {
- return (L_sub - (Int32)(((int64_t)(a) * b) >> 32));
- }
-
-
- __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 30);
- }
-
- __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64_t)(a) * b) >> 30));
- }
-
-
- __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 29);
- }
-
- __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64_t)(a) * b) >> 29));
- }
-
- __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
- {
- return (L_sub - (Int32)(((int64_t)(a) * b) >> 29));
- }
-
-
- __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 28);
- }
-
- __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 27);
- }
-
- __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 26);
- }
-
- __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 20);
- }
-
- __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 15);
- }
-
- __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64_t)(a) * b) >> 14);
- }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h
deleted file mode 100644
index 64397cf..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_msc_evc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-
-#ifndef FXP_MUL32_MSC_EVC
-#define FXP_MUL32_MSC_EVC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-#if defined(PV_ARM_MSC_EVC_V4)
-
-#include "cmnintrin.h"
-
-#define preload_cache( a)
-
- __inline Int32 shft_lft_1(Int32 L_var1)
- {
- if (((L_var1 << 1) >> 1) == L_var1)
- L_var1 <<= 1;
- else
- L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
-
- return L_var1;
-
- }
-
- __inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = (L_var2 << 16) >> 16;
- L_var1 = (L_var1 << 16) >> 16;
-
- return (L_var1*L_var2);
-
- }
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
- __inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = (L_var2 << 16) >> 16;
- L_var1 = L_var1 >> 16;
-
- return (L_var1*L_var2);
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = L_var2 >> 16;
- L_var1 = (L_var1 << 16) >> 16;
-
- return (L_var1*L_var2);
-
- }
-
-
- __inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
- {
- L_var2 = L_var2 >> 16;
- L_var1 = L_var1 >> 16;
-
- return (L_var1*L_var2);
-
- }
-
- __inline Int32 fxp_mac_16_by_16(Int16 L_var1, Int16 L_var2, Int32 L_add)
- {
- return (L_add + (L_var1*L_var2));
- }
-
-
-
- __inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1, Int32 L_var2, Int32 L_add)
- {
- L_var2 = (L_var2 << 16) >> 16;
-
- return (L_add + (L_var1*L_var2));
-
- }
-
-
- __inline Int32 fxp_mac_16_by_16_bt(Int16 L_var1, Int32 L_var2, Int32 L_add)
- {
- L_var2 = L_var2 >> 16;
-
- return (L_add + (L_var1*L_var2));
-
- }
-
-
- __inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
- {
- Int32 rTmp0 = (exp_jw >> 16) << 16;
- Int32 iTmp0 = exp_jw << 16;
- Int32 z;
-
-
- z = _MulHigh(rTmp0, x);
- z += _MulHigh(iTmp0, y);
-
- return (z);
- }
-
-
- __inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
- {
- Int32 rTmp0 = L_var2 << 16;
-
- return(_MulHigh(rTmp0, L_var1));
- }
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-
- __inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
- {
- Int32 rTmp0 = (Int16)(L_var2 >> 16);
-
- return(_MulHigh((rTmp0 << 16), L_var1));
- }
-
-
- __inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
- {
-
- Int32 rTmp0 = (L_var2 << 16);
-
- return(L_add + _MulHigh(rTmp0, L_var1));
- }
-
- __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
- {
- sum += (int64)L_var1 * L_var2;
- return (sum);
- }
-
-#define fxp_mul32_Q31( a, b) _MulHigh( b, a)
-
- __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
- {
- return (L_add + _MulHigh(b, a));
- }
-
- __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
- {
- return (L_sub - _MulHigh(b, a));
- }
-
-
- __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 30);
- }
-
- __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64)(a) * b) >> 30));
- }
-
-
- __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 29);
- }
-
- __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64)(a) * b) >> 29));
- }
-
- __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
- {
- return (L_sub - (Int32)(((int64)(a) * b) >> 29));
- }
-
-
- __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 28);
- }
-
- __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 27);
- }
-
- __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 26);
- }
-
- __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 20);
- }
-
- __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 15);
- }
-
- __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 14);
- }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h
deleted file mode 100644
index 04cbf49..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fxp_mul32_msc_evc_armv5.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_MSC_EVC_ARMV5
-#define FXP_MUL32_MSC_EVC_ARMV5
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-#if defined(PV_ARM_MSC_EVC_V5)
-
-#include "armintr.h"
-#include "cmnintrin.h"
-
-#define preload_cache( a)
-
-#define shft_lft_1( L_var1) _AddSatInt( L_var1, L_var1)
-
-#define fxp_mul_16_by_16bb( L_var1, L_var2) _SmulLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16(a, b) fxp_mul_16_by_16bb( a, b)
-
-#define fxp_mul_16_by_16tb( L_var1, L_var2) _SmulHiLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16bt( L_var1, L_var2) _SmulLoHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16tt( L_var1, L_var2) _SmulHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mac_16_by_16( L_var1, L_var2, L_add) _SmulAddLo_SW_SL( L_add, L_var1, L_var2)
-
-#define fxp_mac_16_by_16_bb(a, b, c) fxp_mac_16_by_16( a, b, c)
-
-#define fxp_mac_16_by_16_bt( L_var1, L_var2, L_add) _SmulAddLoHi_SW_SL( L_add, L_var1, L_var2)
-
-
- __inline Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
- {
- Int32 result64_hi;
-
- result64_hi = _SmulWHi_SW_SL(L_var1, cmplx);
- result64_hi = _SmulAddWLo_SW_SL(result64_hi, L_var2, cmplx);
-
- return (result64_hi);
- }
-
-#define fxp_mul32_by_16( L_var1, L_var2) _SmulWLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul32_by_16b( a, b) fxp_mul32_by_16( a, b)
-
-#define fxp_mul32_by_16t( L_var1, L_var2) _SmulWHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mac32_by_16( L_var1, L_var2, L_add) _SmulAddWLo_SW_SL( L_add, L_var1, L_var2)
-
-
- __inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
- {
- sum += (int64)L_var1 * L_var2;
- return (sum);
- }
-
-#define fxp_mul32_Q31( a, b) _MulHigh( b, a)
-
-
- __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
- {
- return (L_add + _MulHigh(b, a));
- }
-
-
- __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
- {
- return (L_sub - _MulHigh(b, a));
- }
-
-
- __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 30);
- }
-
- __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64)(a) * b) >> 30));
- }
-
-
- __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 29);
- }
-
- __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
- {
- return (L_add + (Int32)(((int64)(a) * b) >> 29));
- }
-
- __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
- {
- return (L_sub - (Int32)(((int64)(a) * b) >> 29));
- }
-
-
- __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 28);
- }
-
- __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 27);
- }
-
- __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 26);
- }
-
- __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 20);
- }
-
- __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 15);
- }
-
- __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
- {
- return (Int32)(((int64)(a) * b) >> 14);
- }
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h b/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h
deleted file mode 100644
index 72862e7..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fxp_mul32_pentium.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_PENTIUM
-#define FXP_MUL32_PENTIUM
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* FXP_MUL32 */
-
diff --git a/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp b/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp
deleted file mode 100644
index 08ccc4a..0000000
--- a/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp
+++ /dev/null
@@ -1,512 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to remove instances of pow() and sqrt(), and
- optimized for inclusion in fixed-point version of decoder.
-
- Description: Modified to include comments/optimizations from code review.
- Also, declared appropriate variables as type "const"
-
- Description: Adopted strategy of "one q-format per sfb" strategy, which
- eliminated the array q-format from this function. The q-format the
- random vector is stored in is now returned from the function.
-
- Description: Completely redesigned the routine to allow a simplified
- calculation of the adjusted noise, by eliminating the dependency
- on the band_length. Added polynomial approximation for the
- function 1/sqrt(power). Updated comments and pseudo-code
-
- Description: Modified function description, pseudocode, etc.
-
- Description:
- Modified casting to ensure proper operations for different platforms
-
- Description:
- Eliminiated access to memory for noise seed. Now a local variable is
- used. Also unrolled loops to speed up code.
-
- Description:
- Modified pointer decrement to a pointer increment, to ensure proper
- compiler behavior
-
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs: random_array[] = Array for storage of the power-scaled
- random values of length "band_length"
- Int32
-
- band_length = Length of random_array[]
- const Int
-
- pSeed = seed for random number generator
- Int32*
-
- power_scale = scale factor for this particular band
- const Int
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs: Function returns the q-format the random vector is stored in.
-
- Pointers and Buffers Modified:
- random_array[] = filled with random numbers scaled
- to the correct power as defined by the input value power_scale.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function generates a vector of uniformly distributed random numbers for
- the PNS block. The random numbers are each scaled by a scale_factor,
- defined in Ref(2) as
-
- 2^(scale_factor/4)
- ------------------
- sqrt(N*MEAN_NRG)
-
- where N == band_length, and MEAN_NRG is defined as...
-
- N-1
- ___
- 1 \
- --- > x(i)^2
- N /__
- i=0
-
- And x is the unscaled vector from the random number generator.
-
- This function takes advantage of the fact that the portion of the
- scale_factor that is divisible by 4 can be simply accounted for by varying
- the q-format.
-
- The scaling of the random numbers is thus broken into the
- equivalent equation below.
-
- 2^(scale_factor%4) 2^(floor(scale_factor/4))
- ------------------ *
- sqrt(N*MEAN_NRG)
-
-
- 2^(scale_factor%4) is stored in a simple 4-element table.
- 2^(floor(scale_factor/4) is accounted for by adjusting the q-format.
- sqrt(N*MEAN_NRG) is calculated and implemented via a polynomial approximation.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall produce uniformly distributed random 32-bit integers,
- with signed random values of average energy equal to the results of the ISO
- code's multiplying factor discussed in the FUNCTION DESCRIPTION section.
-
- Please see Ref (2) for a detailed description of the requirements.
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) Numerical Recipes in C Second Edition
- William H. Press Saul A. Teukolsky
- William T. Vetterling Brian P. Flannery
- Page 284
-
- (2) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.12 (Perceptual Noise Substitution)
-
- (3) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- power_adj = scale_mod_4[power_scale & 3];
-
- power = 0;
-
- FOR (k=band_length; k > 0; k--)
-
- *(pSeed) = *(pSeed) * 1664525L;
- *(pSeed) = *(pSeed) + 1013904223L;
-
- temp = (Int)(*(pSeed) >> 16);
-
- power = power + ((temp*temp) >> 6);
-
- *(pArray) = (Int32)temp;
-
- pArray = pArray + 1;
-
- ENDFOR
-
- k = 0;
- q_adjust = 30;
-
- IF (power)
- THEN
-
- WHILE ( power > 32767)
-
- power = power >> 1;
- k = k + 1;
-
- ENDWHILE
-
- k = k - 13;
-
- IF (k < 0)
- THEN
- k = -k;
- IF ( k & 1 )
- THEN
- power_adj = (power_adj*SQRT_OF_2)>>14;
- ENDIF
- q_adjust = q_adjust - ( k >> 1);
-
- ELSE IF (k > 0)
- THEN
- IF ( k & 1 )
- THEN
- power_adj = (power_adj*INV_SQRT_OF_2)>>14;
- ENDIF
- q_adjust = q_adjust + ( k >> 1);
- ENDIF
-
- pInvSqrtCoeff = inv_sqrt_coeff;
-
- inv_sqrt_power = (*(pInvSqrtCoeff)* power) >>15;
-
- pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
- inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
-
- pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
- FOR ( k=INV_SQRT_POLY_ORDER - 1; k>0; k--)
-
- inv_sqrt_power = ( inv_sqrt_power * power)>>15;
-
- inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
-
- pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
- ENDFOR
-
- inv_sqrt_power = (inv_sqrt_power*power_adj)>>13;
-
- FOR (k=band_length; k > 0; k--)
-
- pArray = pArray - 1;
-
- *(pArray) = *(pArray)*inv_sqrt_power;
-
- ENDFOR
-
- ENDIF
-
- q_adjust = q_adjust - (power_scale >> 2);
-
- return q_adjust;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "gen_rand_vector.h"
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define SQRT_OF_2 23170 /* sqrt(2) in Q14 */
-#define INV_SQRT_OF_2 11585 /* 1/sqrt(2) in Q14 */
-#define INV_SQRT_POLY_ORDER 4
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-/*
- * 2^([0:3]/4) = 1.0000 1.1892 1.4142 1.6818
- */
-const UInt scale_mod_4[4] = { 16384, 19484, 23170, 27554};
-
-/*
- * polynomial approx. in Q12 (type Int)
- */
-
-const Int inv_sqrt_coeff[INV_SQRT_POLY_ORDER+1] =
- { 4680, -17935, 27697, -22326, 11980};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int gen_rand_vector(
- Int32 random_array[],
- const Int band_length,
- Int32* pSeed,
- const Int power_scale)
-{
-
- Int k;
- UInt power_adj;
- Int q_adjust = 30;
-
- Int32 temp;
- Int32 seed;
- Int32 power;
-
- Int32* pArray = &random_array[0];
-
- Int32 inv_sqrt_power;
- const Int *pInvSqrtCoeff;
-
- /*
- * The out of the random number generator is scaled is such a way
- * that is independent of the band length.
- * The output is computed as:
- *
- * x(i)
- * output = ------------------ * 2^(power_scale%4) 2^(floor(power_scale/4))
- * bl
- * sqrt( SUM x(i)^2 )
- * 0
- *
- * bl == band length
- */
-
-
- /*
- * get 2^(power_scale%4)
- */
-
-
- power = 0;
-
- seed = *pSeed;
-
- /*
- * band_length is always an even number (check tables in pg.66 IS0 14496-3)
- */
- if (band_length < 0 || band_length > LONG_WINDOW)
- {
- return q_adjust; /* avoid any processing on error condition */
- }
-
- for (k = (band_length >> 1); k != 0; k--)
- {
- /*------------------------------------------------
- Numerical Recipes in C
- Page 284
- ------------------------------------------------*/
- seed *= 1664525L;
- seed += 1013904223L;
-
- temp = seed >> 16;
-
- seed *= 1664525L;
- seed += 1013904223L;
-
- /* shift by 6 make room for band length accumulation */
- power += ((temp * temp) >> 6);
- *pArray++ = temp;
-
- temp = seed >> 16;
- power += ((temp * temp) >> 6);
- *pArray++ = temp;
-
- } /* END for (k=half_band_length; k > 0; k--) */
-
-
- *pSeed = seed;
-
- /*
- * If the distribution is uniform, the power is expected to use between
- * 28 and 27 bits, by shifting down by 13 bits the power will be a
- * Q15 number.
- * For different band lengths, the power uses between 20 and 29 bits
- */
-
-
- k = 0;
-
- if (power)
- {
- /*
- * approximation requires power between 0.5 < power < 1 in Q15.
- */
-
- while (power > 32767)
- {
- power >>= 1;
- k++;
- }
-
- /*
- * expected power bit usage == 27 bits
- */
-
- k -= 13;
-
- power_adj = scale_mod_4[power_scale & 3];
-
- if (k < 0)
- {
- k = -k;
- if (k & 1)
- { /* multiply by sqrt(2) */
- power_adj = (UInt)(((UInt32) power_adj * SQRT_OF_2) >> 14);
- }
- q_adjust -= (k >> 1); /* adjust Q instead of shifting up */
- }
- else if (k > 0)
- {
- if (k & 1)
- { /* multiply by 1/sqrt(2) */
- power_adj = (UInt)(((UInt32) power_adj * INV_SQRT_OF_2) >> 14);
- }
- q_adjust += (k >> 1); /* adjust Q instead of shifting down */
- }
-
- /*
- * Compute 1/sqrt(power), where 0.5 < power < 1.0 is approximated
- * using a polynomial order INV_SQRT_POLY_ORDER
- */
-
- pInvSqrtCoeff = inv_sqrt_coeff;
-
- inv_sqrt_power = (*(pInvSqrtCoeff++) * power) >> 15;
- inv_sqrt_power += *(pInvSqrtCoeff++);
- inv_sqrt_power = (inv_sqrt_power * power) >> 15;
- inv_sqrt_power += *(pInvSqrtCoeff++);
- inv_sqrt_power = (inv_sqrt_power * power) >> 15;
- inv_sqrt_power += *(pInvSqrtCoeff++);
- inv_sqrt_power = (inv_sqrt_power * power) >> 15;
- inv_sqrt_power += *(pInvSqrtCoeff);
-
- inv_sqrt_power = (inv_sqrt_power * power_adj) >> 13;
-
- pArray = &random_array[0];
-
- for (k = (band_length >> 1); k != 0; k--)
- {
- temp = *(pArray) * inv_sqrt_power;
- *(pArray++) = temp;
- temp = *(pArray) * inv_sqrt_power;
- *(pArray++) = temp;
- } /* END for (k=half_band_length; k > 0; k--) */
-
- } /* if(power) */
-
- /*
- * Adjust Q with the value corresponding to 2^(floor(power_scale/4))
- */
-
- q_adjust -= (power_scale >> 2);
-
- return (q_adjust);
-
-} /* gen_rand_vector */
diff --git a/media/libstagefright/codecs/aacdec/gen_rand_vector.h b/media/libstagefright/codecs/aacdec/gen_rand_vector.h
deleted file mode 100644
index 17b5490..0000000
--- a/media/libstagefright/codecs/aacdec/gen_rand_vector.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: gen_rand_vector.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Added include of pv_audio_type_defs.h
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for gen_rand_vector.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef gen_rand_vector_H
-#define gen_rand_vector_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int gen_rand_vector(
- Int32 random_array[],
- const Int band_length,
- Int32 *pSeed,
- const Int power_scale);
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_adif_header.cpp b/media/libstagefright/codecs/aacdec/get_adif_header.cpp
deleted file mode 100644
index 8a1e74b..0000000
--- a/media/libstagefright/codecs/aacdec/get_adif_header.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adif_header.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Change to PV template, remove default config parameter,
- move some functionality into get_prog_config().
-
- Description: Update per code review
- 1) Add parameter pScratchPCE
- 2) Change way ADIF_ID is read in.
- 3) Fix comments
- 4) ADD a test for status != SUCCESS in loop.
-
- Description: The ADIF_Header has now been delegated to the "scratch memory"
- union. This change inside s_tDec_Int_File.h had to be reflected here also.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pVars = pointer to the structure that contains the current state
- of this instance of the library, of data type pointer to
- tDec_Int_File
-
- pScratchPCE = pointer to a ProgConfig structure used as scratch in the
- the function get_prog_config. of data type pointer to
- ProgConfig
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- The function returns 0 if no error occurred, non-zero otherwise.
-
- Pointers and Buffers Modified:
- pVars->adif_header contents are updated with the some of the ADIF header
- contents
- pVars->tempProgConfig contents are overwritten with last PCE found,
- which is most likely the first one found.
- pVars->prog_config contents are updated with the first PCE found.
- pVars->inputStream contents are modify in such a way that the
- stream is moved further along in the buffer.
- pVars->SFBWidth128 contents may be updated.
- pVars->winSeqInfo contents may be updated.
- pScratchPCE contents may be updated.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads in the ADIF Header found at the front of ADIF streams.
- If the header is not found an error is returned. An ADIF header can contain
- from zero to sixteen program configuration elements (PCE). This function, and
- the rest of the library, saves and uses the first PCE found.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- Function shall not use static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
- page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- CALL getbits(
- neededBits = 2 * LEN_BYTE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( theIDFromFile )
-
- CALL getbits(
- neededBits = 2 * LEN_BYTE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( temp )
-
- theIDFromFile = (theIDFromFile << (2*LEN_BYTE)) | temp;
-
- IF (theIDFromFile != ADIF_ID)
- THEN
-
- pInputStream->usedBits -= (4 * LEN_BYTE);
-
- status = -1;
- ELSE
- CALL getbits(
- neededBits = LEN_COPYRT_PRES,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( temp )
-
- IF (temp != FALSE) THEN
- FOR (i = LEN_COPYRT_ID; i > 0; i--)
- CALL getbits(
- neededBits = LEN_BYTE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
-
- END FOR
- END IF
-
- CALL getbits(
- neededBits = LEN_ORIG + LEN_HOME,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
-
- CALL getbits(
- neededBits = LEN_BS_TYPE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( bitStreamType )
-
- CALL getbits(
- neededBits = LEN_BIT_RATE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( pHeader->bitrate )
-
- CALL getbits(
- neededBits = LEN_NUM_PCE,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( numConfigElementsMinus1 )
-
- FOR ( i = numConfigElementsMinus1;
- (i >= 0) && (status == SUCCESS);
- i--)
-
- IF (bitStreamType == CONSTANT_RATE_BITSTREAM) THEN
- CALL getbits(
- neededBits = LEN_ADIF_BF,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- END IF
-
- CALL get_prog_config(
- pVars = pVars)
- MODIFYING( pVars->prog_config )
- RETURNING( status )
-
- END FOR
- END IF
-
- RETURN (status)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_adif_const.h"
-
-#include "s_progconfig.h"
-#include "s_adif_header.h"
-#include "s_bits.h"
-#include "s_mc_info.h"
-#include "s_frameinfo.h"
-#include "s_tdec_int_file.h"
-
-#include "get_prog_config.h"
-#include "ibstream.h"
-
-#include "get_adif_header.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*
- * This constant is simply the characters 'A' 'D' 'I' 'F' compressed into
- * a UInt32. Any possible endian problems that exist must be solved by
- * the function that fills the buffer and getbits(), or this constant and
- * the rest of the bit stream will not work.
- */
-#define ADIF_ID (0x41444946)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int get_adif_header(
- tDec_Int_File *pVars,
- ProgConfig *pScratchPCE)
-{
- Int i;
- UInt32 temp;
- Int numConfigElementsMinus1;
- Int bitStreamType;
- UInt32 theIDFromFile;
-
- BITS *pInputStream = &pVars->inputStream;
- ADIF_Header *pHeader = &pVars->scratch.adif_header;
- Int status = SUCCESS;
-
- /*
- * The ADIF_ID field is 32 bits long, one more than what getbits() can
- * do, so read the field in two parts. There is no point in saving the
- * string - it either matches or it does not. If it matches, it must
- * have been 'ADIF'
- */
-
- theIDFromFile = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
-
- temp = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
-
- theIDFromFile = (theIDFromFile << (2 * LEN_BYTE)) | temp;
-
-
- if (theIDFromFile != ADIF_ID)
- {
- /*
- * Rewind the bit stream pointer so a search for ADTS header
- * can start at the beginning.
- */
-
- pInputStream->usedBits -= (4 * LEN_BYTE);
-
- /*
- * The constant in the next line needs to be updated when
- * error handling method is determined.
- */
- status = -1;
- }
- else
- {
- /*
- * To save space, the unused fields are read in, but not saved.
- */
-
- /* copyright string */
- temp =
- get1bits(/* LEN_COPYRT_PRES,*/
- pInputStream);
-
- if (temp != FALSE)
- {
- /*
- * Read in and ignore the copyright string. If restoring
- * watch out for count down loop.
- */
-
- for (i = LEN_COPYRT_ID; i > 0; i--)
- {
- get9_n_lessbits(LEN_BYTE,
- pInputStream);
- } /* end for */
-
- /*
- * Make sure to terminate the string with '\0' if restoring
- * the the copyright string.
- */
-
- } /* end if */
-
- /* Combine the original/copy and fields into one call */
- get9_n_lessbits(
- LEN_ORIG + LEN_HOME,
- pInputStream);
-
- bitStreamType =
- get1bits(/* LEN_BS_TYPE,*/
- pInputStream);
-
- pHeader->bitrate =
- getbits(
- LEN_BIT_RATE,
- pInputStream);
-
- /*
- * Read in all the Program Configuration Elements.
- * For this library, only one of the up to 16 possible PCE's will be
- * saved. Since each PCE must be read, a temporary PCE structure is
- * used, and if that PCE is the one to use, it is copied into the
- * single PCE. This is done inside of get_prog_config()
- */
-
- numConfigElementsMinus1 = get9_n_lessbits(LEN_NUM_PCE,
- pInputStream);
-
- for (i = numConfigElementsMinus1;
- (i >= 0) && (status == SUCCESS);
- i--)
- {
- /*
- * For ADIF contant bit rate streams, the _encoder_ buffer
- * fullness is transmitted. This version of an AAC decoder has
- * no use for this variable; yet it must be read in to move
- * the bitstream pointers.
- */
-
- if (bitStreamType == CONSTANT_RATE_BITSTREAM)
- {
- getbits(
- LEN_ADIF_BF,
- pInputStream);
- } /* end if */
-
- pVars->adif_test = 1;
- /* Get one program configuration element */
- status =
- get_prog_config(
- pVars,
- pScratchPCE);
-
-#ifdef AAC_PLUS
-
- /*
- * For implicit signalling, no hint that sbr or ps is used, so we need to
- * check the sampling frequency of the aac content, if lesser or equal to
- * 24 KHz, by defualt upsample, otherwise, do nothing
- */
- if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
- pVars->mc_info.audioObjectType == MP4AUDIO_AAC_LC)
- {
- pVars->mc_info.upsamplingFactor = 2;
- pVars->prog_config.sampling_rate_idx -= 3;
- pVars->mc_info.sbrPresentFlag = 1;
- pVars->sbrDecoderData.SbrChannel[0].syncState = UPSAMPLING;
- pVars->sbrDecoderData.SbrChannel[1].syncState = UPSAMPLING;
- }
-#endif
-
-
-
- } /* end for */
-
-
- } /* end 'else' of --> if (theIDFromFile != ADIF_ID) */
-
- return status;
-
-} /* end get_adif_header */
diff --git a/media/libstagefright/codecs/aacdec/get_adif_header.h b/media/libstagefright/codecs/aacdec/get_adif_header.h
deleted file mode 100644
index 8bc3411..0000000
--- a/media/libstagefright/codecs/aacdec/get_adif_header.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adif_header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Add parameter to get_adif_header() function.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_adif_header.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ADIF_HEADER_H
-#define GET_ADIF_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define CONSTANT_RATE_BITSTREAM (0)
-#define VARIABLE_RATE_BITSTREAM (1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_adif_header(
- tDec_Int_File *pVars,
- ProgConfig *pScratchPCE);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_adts_header.cpp b/media/libstagefright/codecs/aacdec/get_adts_header.cpp
deleted file mode 100644
index 3ac2756..0000000
--- a/media/libstagefright/codecs/aacdec/get_adts_header.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adts_header.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove default_config variable
-
- Description: change enter_mc_info to set_mc_info
-
- Description: (1) add error checking for channel_config > 2
- (2) eliminated call to check_mc_info
- (3) use (profile + 1) when calling set_mc_info
- (4) use winmap when calling set_mc_info
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pVars = Pointer to structure that holds file-scope variables.
- [ tDec_Int_File * ]
-
- pSyncword = Pointer to variable that holds the 28-bit fixed
- header upon the exit of this function. [ UInt32 * ]
-
- pInvoke = Pointer to variable that keeps track of how many
- "short" (14 bit) headers have been successfully
- parsed from the bitstream. [ Int * ]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- Status = SUCCESS or ERROR CODE
-
- Pointers and Buffers Modified:
- pVars->prog_config Updated with program information data as read from
- the ADTS header.
-
- pSyncword Value pointed to is updated with the contents of
- the 28-bit fixed header.
-
- pInvoke Value pointed to is updated to reflect the number
- of successful "short" (14 bit) headers that have
- been successfully parsed from the bitstream.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Acronym Definitions
- ADTS Audio Data Transport Stream
- CRC Cyclic Redundancy Code
-
- This function calls find_adts_syncword to find the next ADTS header. Until
- three consistent headers have been read, the syncword used for detection
- consists of the 12-bit syncword and the 2-bit Layer. After three consistent
- headers are read, the entire fixed header is used for a robust 28-bit
- syncword.
-
- Configuration information is then extracted from the bitstream.
-
- The bitstream information is packed as follows.
- Comments about the correct interpretation of these bits are contained within
- the code.
-
- CRC_absent sampling_rate_idx
- \ / \
- \ / \
- \ Profile / \ UNUSED
- \ / \ / \ /
-|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|
- \ _______________ / | \ / \ /
- \-------|0xFFF syncword |-------/ | Layer == '00' for AAC \ /
- \-------------/ | \ /
- | \/
- ID == '1' for MPEG-2 AAC channel_config
- copyright_id_bit == '0' for MPEG-4 AAC
- /
- home /
- / /
-|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|
- | \ \ _____________ /
- | \ \--------|frame length |---------/
- orig_copy \ \-----------/
- \ ______________________________
- copyright_id_start | TOTAL HEADER LENGTH: 56 bits|
- |-----------------------------|
-|43|44|45|46|47|48|49|50|51|52|53|54|55| | FIXED HEADER BITS 00-27 |
- \ _______________ / | | | VARIABLE HEADER BITS 28-55 |
- \-----|buffer_fullness|----/ \ / |_____________________________|
- \-------------/ |
- headerless_frames
-
- In addition to the bits displayed above, if the value CRC_absent is '0' an
- additional 16 bits corresponding to a CRC word are read from the bitstream,
- following the header.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- After the ADTS syncword is detected, this function shall parse the
- information residing behind the syncword in the bitstream.
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 13818-7:1997(E)
- Part 7
- Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
-
- (2) ISO/IEC 11172-3:1993(E)
- Part 3
- Subpart 2.4.3 The audio decoding process
-
- (3) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those UIntending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF (*(pInvoke) > 3)
-
- CALL find_adts_syncword(
- pSyncword,
- &(pVars->inputStream),
- LENGTH_FIXED_HEADER,
- MASK_28BITS);
- RETURNING status
- ELSE
-
- *(pSyncword) = SYNCWORD_15BITS;
-
- CALL find_adts_syncword(
- pSyncword,
- &(pVars->inputStream),
- LENGTH_SYNCWORD,
- ID_BIT_FILTER);
-
- MODIFYING *(pSyncword) = 28-bit fixed header (long syncword)
- RETURNING status
-
- CALL getbits(
- (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
- &(pVars->inputStream));
-
- MODIFYING pVars->inputStream
- RETURNING adts_header = remaining bits in the fixed header
-
- *(pSyncword) <<= 13;
- *(pSyncword) = *(pSyncword) OR adts_header;
-
- pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) AND 0x0001;
-
- lower_16 = (UInt)adts_header;
-
- pVars->prog_config.profile = (lower_16 >> 10) AND 0x3;
-
- pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) AND 0xF;
-
- channel_configuration = (lower_16 >> 2) AND 0x7;
-
- channel_configuration = channel_configuration - 1;
- pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
-
- pVars->prog_config.front.num_ele = 1;
-
- pVars->prog_config.front.ele_tag[0] = 0;
-
- pVars->prog_config.mono_mix.present = 0;
- pVars->prog_config.stereo_mix.present = 0;
- pVars->prog_config.matrix_mix.present = 0;
-
- CALL set_mc_info(
- &(pVars->mc_info),
- &(pVars->savedMCInfo),
- &(pVars->prog_config),
- pVars->pWinSeqInfo,
- pVars->SFBWidth128);
- MODIFYING pVars->mc_info = multi-channel configuration information
- RETURNING status = SUCCESS/FAILURE
-
- IF ( (*pInvoke) != 0)
- CALL check_mc_info(
- &(pVars->mc_info),
- &(pVars->savedMCInfo),
- FALSE);
- RETURNING status = SUCCESS/FAILURE
- ELSE
- CALL check_mc_info(
- &(pVars->mc_info),
- &(pVars->savedMCInfo),
- TRUE);
- MODIFYING pVars->savedMCInfo = pVars->mc_info
- RETURNING status = SUCCESS/FAILURE
- ENDIF
-
- IF (status == SUCCESS)
- (*pInvoke) = (*pInvoke) + 1;
- ELSE
- (*pInvoke) = 0;
- ENDIF
-
- ENDIF
-
- CALL getbits(
- LENGTH_VARIABLE_HEADER,
- &(pVars->inputStream));
- RETURNING adts_header = 28-bits (the contents of the variable header.)
-
- pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) AND 0x1FFF;
-
- lower_16 = (UInt)adts_header;
-
- pVars->prog_config.buffer_fullness = (lower_16 >> 2) AND 0x7FF;
-
- pVars->prog_config.headerless_frames = (lower_16 AND 0x0003);
-
- IF (pVars->prog_config.CRC_absent == 0)
-
- CALL getbits(
- LENGTH_CRC,
- &(pVars->inputStream) );
- RETURNING pVars->prog_config.CRC_check = 16-bit CRC
-
- ENDIF
-
- pVars->default_config = 0;
-
- IF (byte_align_offset > 7)
- status = 1;
- ENDIF
-
- return (status);
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h"
-#include "set_mc_info.h"
-#include "find_adts_syncword.h"
-#include "get_adts_header.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LENGTH_VARIABLE_HEADER 28
-#define LENGTH_FIXED_HEADER 28
-#define LENGTH_SYNCWORD 15
-#define LENGTH_CRC 16
-
-#define ID_BIT_FILTER 0x7FFB
-#define SYNCWORD_15BITS 0x7FF8
-#define MASK_28BITS 0x0FFFFFFFL
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_adts_header(
- tDec_Int_File *pVars,
- UInt32 *pSyncword,
- Int *pInvoke,
- Int CorrectlyReadFramesCount)
-{
- UInt32 adts_header;
- UInt lower_16;
- Int status = SUCCESS;
- UInt channel_configuration;
-
- /*
- * Search for the LONG ADTS syncword (comprised of the entire fixed header)
- * if the number of CorrectlyReadFrames is > CorrectlyReadFramesCount
- *
- * Otherwise, search for just the short syncword.
- */
- if (*(pInvoke) > CorrectlyReadFramesCount)
- {
- /*
- * Find the long ADTS syncword
- * (comprised of the entire ADTS fixed header)
- */
-
- status = find_adts_syncword(pSyncword,
- &(pVars->inputStream),
- LENGTH_FIXED_HEADER,
- MASK_28BITS);
- }
- else
- {
-
- *(pSyncword) = SYNCWORD_15BITS;
-
- status = find_adts_syncword(pSyncword,
- &(pVars->inputStream),
- LENGTH_SYNCWORD,
- ID_BIT_FILTER);
-
- /*
- * Extract the data from the header following the syncword
- */
- adts_header = getbits((LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
- &(pVars->inputStream));
-
- *(pSyncword) <<= (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD);
- *(pSyncword) |= adts_header;
-
- /* Denotes whether a CRC check should be performed */
- pVars->prog_config.CRC_absent = ((UInt)(adts_header >> 12)) & 0x0001;
-
- /*
- * All the unread bits in adts_header reside in the lower
- * 16-bits at this point. Perform a typecast for faster
- * execution on 16-bit processors.
- */
- lower_16 = (UInt)adts_header;
-
- /*
- * Profile consists of 2 bits, which indicate
- * the profile used.
- *
- * '00' AAC_MAIN profile
- * '01' AAC_LC (Low Complexity) profile
- * '10' AAC_SSR (Scaleable Sampling Rate) profile
- * '11' AAC_LTP (Long Term Prediction) profile
- */
- pVars->prog_config.profile = (lower_16 >> 10) & 0x3;
-
- if (pVars->prog_config.profile == MP4AUDIO_AAC_SSR)
- {
- status = 1; /* Not supported */
- }
-
- /*
- * Sampling_rate_idx consists of 4 bits
- * see Ref #1 for their interpretation.
- */
- pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) & 0xF;
-
- /*
- * private_bit is a bit for private use. ISO/IEC will not make
- * use of this bit in the future.
- *
- * We currently make no use of it, but parsing the information
- * from the bitstream could be easily implemented with the
- * following instruction...
- *
- * private_bit = (lower_16 & 0x0400) >> 10;
- */
-
- /*
- * These 3 bits indicate the channel configuration used.
- *
- * If '0' then the channel configuration is unspecified here,
- * and must be given by a program configuration element in
- * the raw data block.
- *
- * If '1' then the channel configuration is MONO.
- * If '2' then the channel configuration is STEREO
- *
- * 3-7 represent channel configurations which this library
- * will not support in the forseeable future.
- */
- channel_configuration = (lower_16 >> 2) & 0x7;
- /* do not support more than 2 channels */
- if (channel_configuration > 2)
- {
- status = 1;
- }
-
- /*
- * The following 2 bits encode copyright information.
- * original_copy is '0' if there is no copyright in the bitstream.
- * '1' if the bitstream is copyright protected.
- *
- * home is '0' for a copy, '1' for an original.
- *
- * PacketVideo currently does nothing with this information,
- * however, parsing the data from the bitstream could be easily
- * implemented with the following instructions...
- *
- * original_copy = (lower_16 >> 1) & 0x1;
- *
- * home = (lower_16 & 0x1);
- *
- */
-
- /* Set up based on information extracted from the ADTS FIXED header */
-
- /* This equals 1 for STEREO, 0 for MONO */
- if (channel_configuration)
- {
- channel_configuration--;
- }
- pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
-
- /* This value is constant for both MONO and STEREO */
- pVars->prog_config.front.num_ele = 1;
-
- /* ADTS does not specify this tag value - do we even use it? */
- pVars->prog_config.front.ele_tag[0] = 0;
-
- /* Disable all mix related variables */
- pVars->prog_config.mono_mix.present = 0;
- pVars->prog_config.stereo_mix.present = 0;
- pVars->prog_config.matrix_mix.present = 0;
-
- /* enter configuration into MC_Info structure */
- if (status == SUCCESS)
- {
- /* profile + 1 == audioObjectType */
- status =
- set_mc_info(
- &(pVars->mc_info),
- (tMP4AudioObjectType)(pVars->prog_config.profile + 1),
- pVars->prog_config.sampling_rate_idx,
- pVars->prog_config.front.ele_tag[0],
- pVars->prog_config.front.ele_is_cpe[0],
- pVars->winmap, /* changed from pVars->pWinSeqInfo, */
- pVars->SFBWidth128);
-
- } /* if (status == SUCCESS) */
-
-
-#ifdef AAC_PLUS
-
- /*
- * For implicit signalling, no hint that sbr or ps is used, so we need to
- * check the sampling frequency of the aac content, if lesser or equal to
- * 24 KHz, by defualt upsample, otherwise, do nothing
- */
- if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE))
- {
- pVars->mc_info.upsamplingFactor = 2;
- pVars->prog_config.sampling_rate_idx -= 3;
- pVars->mc_info.sbrPresentFlag = 1;
- pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_ACTIVE;
- pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_ACTIVE;
- }
-#endif
-
-
- /*
- * The tag and is_cpe will be checked in huffdecode,
- * remove this check routine.
- */
- /*if (status == SUCCESS)
- *{
- * if ( (*pInvoke) != 0)
- * {
- * status =
- * check_mc_info(
- * &(pVars->mc_info),
- * &(pVars->savedMCInfo),
- * FALSE);
- * }
- * else
- * {
- * status =
- * check_mc_info(
- * &(pVars->mc_info),
- * &(pVars->savedMCInfo),
- * TRUE);
- * }
- *
- *}*/ /* if (status == SUCCESS) */
-
- /*
- * This keeps track of how many headers have been read in the file.
- * After the three successful headers with the same configuration
- * are read in, the entire ADTS fixed header is used as the syncword
- * for a more robust 28-bit long syncword
- */
-
- if (status == SUCCESS)
- {
- (*pInvoke)++;
- }
- else
- {
- (*pInvoke) = 0;
- }
-
- } /* END if (*(pInvoke) > 3) */
-
- /* Grab the bits in the ADTS variable header */
- adts_header = getbits(
- LENGTH_VARIABLE_HEADER,
- &(pVars->inputStream));
- /*
- * copyright_identification bit is a single bit of the 72-bit
- * copyright_id field. This consists of a 8-bit copyright identifier
- * and a 64-bit copyright_number. 72 headers must be decoded
- * to reconstruct the entire copyright_id field.
- *
- * copyright_identification_start is a single bit flagging
- * the beginning bit of the copyright_id field. '1' for start of
- * copyright_id, '0' otherwise.
- *
- *
- * PacketVideo currently does nothing with this information,
- * however, parsing the data from the bitstream could be easily
- * implemented with the following instructions...
- *
- * copyright_id_bit = ((UInt)(adts_header >> 27)) & 0x1;
- *
- * copyright_id_start = ((UInt)(adts_header >> 26)) & 0x1;
- */
-
- /*
- * frame_length is a 13-bit field which indicates the length,
- * in bytes, of the frame including error_check and headers.
- * This information can theoretically be used to help verify syncwords.
- */
- pVars->prog_config.frame_length = ((UInt)(adts_header >> 13)) & 0x1FFF;
-
- /*
- * All the unread bits in adts_header reside in the lower
- * 16-bits at this point. Perform a typecast for faster
- * execution on 16-bit processors.
- */
- lower_16 = (UInt)adts_header;
-
- /*
- * Indicates the number of 32-bit words remaining in the
- * encoder buffer after the encoding of the first raw
- * data block. This value is 0x7ff for variable bit
- * rate encoders, since buffer fullness does not apply
- * to Variable Bit Rate (VBR) encoders.
- */
- pVars->prog_config.buffer_fullness = (lower_16 >> 2) & 0x7FF;
-
- /*
- * headerless_frames indicates the number of
- * frames with no headers to be processed before the reading
- * in of the next header.
- *
- * In ADTS, up to 4 "no header frames" can exist between
- * syncwords.
- *
- * EXAMPLES:
- *
- * Legend: (Sync words denoted by X, frames
- * deonted by FRAME_#)
- *
- * Example(1): The ADTS sequence below packs 5
- * frames per header.
- * Here, headerless_frames would always be read in as "4"
- *
- * |X||FRAME_0||FRAME_1||FRAME_2||FRAME_3||FRAME_4||X||FRAME_0|
- *
- * Example(2): The ADTS sequence below packs 1 frame per header.
- * Here, headerless_frames would always be read in as "0"
- *
- * |X||FRAME_0||X||FRAME_1||X||FRAME_2|
- *
- */
- pVars->prog_config.headerless_frames = (lower_16 & 0x0003);
-
- if (pVars->prog_config.CRC_absent == 0)
- {
- pVars->prog_config.CRC_check = (UInt)getbits(
- LENGTH_CRC,
- &(pVars->inputStream));
- }
-
- /* pVars->current_program = 0; */ /* shall be set after PCE is read */
-
- return (status);
-
-} /* END get_adts_header */
diff --git a/media/libstagefright/codecs/aacdec/get_adts_header.h b/media/libstagefright/codecs/aacdec/get_adts_header.h
deleted file mode 100644
index 13afa05..0000000
--- a/media/libstagefright/codecs/aacdec/get_adts_header.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_adts_header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file has the function declaration for get_adts_header().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ADTS_HEADER_H
-#define GET_ADTS_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_adts_header(
- tDec_Int_File *pVars,
- UInt32 *pSyncword,
- Int *pInvoke,
- Int CorrectlyReadFramesCount);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp b/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp
deleted file mode 100644
index 092f397..0000000
--- a/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp
+++ /dev/null
@@ -1,691 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/get_audio_specific_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Modified per second review comments
- (1) change audioObjectType to Int
- (2) do not set pVars->prog_config.profile
- (3) clean up status flag, default to SUCCESS
- (4) fix multiple lines comments
-
- Description: Change getbits.h to ibstream.h
-
- Description: Modified per review comments
- (1) updated revision history
- (2) declare audioObjectType as enum type
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less.
-
- Description: Added support for backward and non-backward (explicit)
- mode for Parametric Stereo (PS) used in enhanced AAC+
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pVars = pointer to the structure that holds all information for
- this instance of the library. pVars->prog_config is directly
- used, and pVars->mc_info, pVars->prog_config,
- pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly
- for calling set_mc_info. Data type pointer to tDec_Int_File
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- status = 0 if successfully decoded AudioSpecificConfig
- 1 if un-supported config is used for this release
-
- Pointers and Buffers Modified:
- pVars->prog_config contents are updated with the information read in.
- pVars->mc_info contents are updated with channel information.
- pVars->pWinSeqInfo contents are updated with window information.
- pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the bitstream for the structure "AudioSpecificConfig",
- and sets the decoder configuration that is needed by the decoder to be able
- to decode the media properly.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global variables
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- Part 3
- Subpart 1 p18 1.6 Interface to MPEG-4 Systems
- Subpart 4 p13 4.4.1 GA Specific Configuration
- Amendment p10 6.2.1 AudioSpecificInfo
- Amendment p78 8.2 Decoder configuration (GASpecificConfig)
-
- (2) AAC DecoderSpecificInfo Information
- PacketVideo descriptions - San Diego
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = SUCCESS;
-
- pInputStream = &(pVars->inputStream);
-
- temp = CALL getbits(
- neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
- pInputStream = pInputStream)
- MODIFYING (pInputStream)
- RETURNING (temp)
-
- audioObjectType = (temp & 0x1f0) >> 4;
-
- pVars->prog_config.profile = audioObjectType;
-
- pVars->prog_config.sampling_rate_idx = temp & 0xf;
-
- IF (pVars->prog_config.sampling_rate_idx == 0xf)
- THEN
- sampling_rate = CALL getbits(
- neededBits = LEN_SAMP_RATE,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (sampling_rate)
- ENDIF
-
- channel_config = CALL getbits(
- neededBits = LEN_CHAN_CONFIG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (channel_config)
-
- IF (channel_config > 2)
- THEN
- status = 1;
- ENDIF
-
- IF (((audioObjectType == MP4AUDIO_AAC_MAIN) OR
- (audioObjectType == MP4AUDIO_AAC_LC) OR
- (audioObjectType == MP4AUDIO_AAC_SSR) OR
- (audioObjectType == MP4AUDIO_LTP) OR
- (audioObjectType == MP4AUDIO_AAC_SCALABLE) OR
- (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1))
- THEN
- status = CALL get_GA_specific_config(
- pVars = pVars,
- channel_config = channel_config,
- audioObjectType = audioObjectType,
- pInputStream = pInputStream);
- MODIFYING (pVars->mc_info,channel_config,pInputStream)
- RETURNING (status)
-
- ENDIF
-
- IF (audioObjectType == MP4AUDIO_CELP)
- THEN
- status = 1;
- ENDIF
-
- IF (audioObjectType == MP4AUDIO_HVXC)
- THEN
- status = 1;
- ENDIF
-
- IF (audioObjectType == MP4AUDIO_TTSI)
- THEN
- status = 1;
- ENDIF
-
- IF ((audioObjectType == 13) OR (audioObjectType == 14) OR
- (audioObjectType == 15) OR (audioObjectType == 16))
- THEN
- status = 1;
- ENDIF
-
- IF (((audioObjectType == MP4AUDIO_ER_AAC_LC) OR
- (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR
- (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
- (audioObjectType == MP4AUDIO_ER_TWINVQ) OR
- (audioObjectType == MP4AUDIO_ER_BSAC) OR
- (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1))
- THEN
- status = 1;
- ENDIF
-
- IF (audioObjectType == MP4AUDIO_ER_CELP)
- THEN
- status = 1;
- ENDIF
-
- IF (audioObjectType == MP4AUDIO_ER_HVXC)
- THEN
- status = 1;
- ENDIF
-
- IF ((audioObjectType == MP4AUDIO_ER_HILN) OR
- (audioObjectType == MP4AUDIO_PARAMETRIC))
- THEN
- status = 1;
- ENDIF
-
- IF ((audioObjectType == MP4AUDIO_ER_AAC_LC) OR
- (audioObjectType == MP4AUDIO_ER_AAC_LTP) OR
- (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
- (audioObjectType == MP4AUDIO_ER_TWINVQ) OR
- (audioObjectType == MP4AUDIO_ER_BSAC) OR
- (audioObjectType == MP4AUDIO_ER_AAC_LD) OR
- (audioObjectType == MP4AUDIO_ER_CELP) OR
- (audioObjectType == MP4AUDIO_ER_HVXC) OR
- (audioObjectType == MP4AUDIO_ER_HILN) OR
- (audioObjectType == MP4AUDIO_PARAMETRIC))
- THEN
- epConfig = CALL getbits(
- neededBits = LEN_EP_CONFIG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (epConfig)
-
- IF (epConfig == 2)
- THEN
- status = 1;
- ENDIF
-
- ENDIF
-
- RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_mp4ff_const.h"
-#include "e_tmp4audioobjecttype.h"
-#include "get_audio_specific_config.h"
-#include "get_ga_specific_config.h"
-#include "ibstream.h"
-#include "sfb.h" /* Where samp_rate_info[] is declared */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_audio_specific_config(tDec_Int_File * const pVars)
-{
-
- UInt temp;
- tMP4AudioObjectType audioObjectType;
- //UInt32 sampling_rate;
- UInt channel_config;
- UInt syncExtensionType;
- UInt extensionAudioObjectType = 0;
- UInt extensionSamplingFrequencyIndex = 0;
- BITS *pInputStream;
- Int status;
-
- status = SUCCESS;
-
- pInputStream = &(pVars->inputStream);
-
- pVars->mc_info.upsamplingFactor = 1; /* default to regular AAC */
-
- temp = get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
- pInputStream);
-
- /*
- * The following code can directly set the values of elements in
- * MC_Info, rather than first setting the values in pVars->prog_config
- * and then copy these values to MC_Info by calling set_mc_info.
- * In order to keep consistent with get_prog_config (ADIF) and
- * get_adts_header (ADTS), the code here is still copying
- * the info, and set the pVars->current_program = 0
- */
-
- /* AudioObjectType */
- audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4);
-
- pVars->mc_info.ExtendedAudioObjectType = audioObjectType; /* default */
- /* saving an audioObjectType into a profile field */
- /* pVars->prog_config.profile = audioObjectType; */
-
- /* sampling rate index */
- pVars->prog_config.sampling_rate_idx = temp & 0xf;
-
- if (pVars->prog_config.sampling_rate_idx > 0xb)
- {
- /*
- * Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp)
- * 7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape
- */
- if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */
- {
- /*
- * sampling rate not listed in Table 1.6.2,
- * this release does not support this
- */
- /*sampling_rate = getbits( LEN_SAMP_RATE,
- pInputStream);*/
- getbits(LEN_SAMP_RATE, pInputStream); /* future use */
- }
-
- status = 1;
- }
-
- channel_config = get9_n_lessbits(LEN_CHAN_CONFIG,
- pInputStream);
-
- if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled))
- {
- /*
- * AAC lib does not support more than two channels
- * signal error when in decoder mode
- * do not test when in utility mode
- */
- status = 1;
-
- }
-
- if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS)
- {
- /* to disable explicit backward compatiblity check */
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
- pVars->mc_info.sbrPresentFlag = 1;
-
- if (audioObjectType == MP4AUDIO_PS)
- {
- pVars->mc_info.psPresentFlag = 1;
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
- }
-
- extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */
- get9_n_lessbits(LEN_SAMP_RATE_IDX,
- pInputStream);
- if (extensionSamplingFrequencyIndex == 0x0f)
- {
- /*
- * sampling rate not listed in Table 1.6.2,
- * this release does not support this
- */
- /*sampling_rate = getbits( LEN_SAMP_RATE,
- pInputStream);*/
- getbits(LEN_SAMP_RATE, pInputStream);
- }
-
- audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE ,
- pInputStream);
- }
-
-
- if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN) ||*/
- (audioObjectType == MP4AUDIO_AAC_LC) ||
- /*(audioObjectType == MP4AUDIO_AAC_SSR) ||*/
- (audioObjectType == MP4AUDIO_LTP) /*||*/
- /*(audioObjectType == MP4AUDIO_AAC_SCALABLE) ||*/
- /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS))
- {
- status = get_GA_specific_config(pVars,
- pInputStream,
- channel_config,
- audioObjectType);
-
- /*
- * verify that Program config returned a supported audio object type
- */
-
- if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) &&
- (pVars->mc_info.audioObjectType != MP4AUDIO_LTP))
- {
- return 1; /* status != SUCCESS invalid aot */
- }
- }
- else
- {
- return 1; /* status != SUCCESS invalid aot or invalid parameter */
- }
-
- /*
- * SBR tool explicit signaling ( backward compatible )
- */
- if (extensionAudioObjectType != MP4AUDIO_SBR)
- {
- syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
- pInputStream);
-
- if (syncExtensionType == 0x2b7)
- {
- extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */
- LEN_OBJ_TYPE,
- pInputStream);
-
- if (extensionAudioObjectType == MP4AUDIO_SBR)
- {
- pVars->mc_info.sbrPresentFlag = get1bits(pInputStream); /* sbrPresentFlag */
- if (pVars->mc_info.sbrPresentFlag == 1)
- {
- extensionSamplingFrequencyIndex =
- get9_n_lessbits( /* extensionSamplingFrequencyIndex */
- LEN_SAMP_RATE_IDX,
- pInputStream);
- if (pVars->aacPlusEnabled == true)
- {
-#ifdef AAC_PLUS
- pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
- samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
-
- if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
- {
- /*
- * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
- */
- if (pVars->prog_config.sampling_rate_idx < 6)
- {
- pVars->aacPlusEnabled = false;
- }
-
- pVars->mc_info.bDownSampledSbr = true;
- }
- pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
-
-#endif
- }
-
- if (extensionSamplingFrequencyIndex == 0x0f)
- {
- /*
- * sampling rate not listed in Table 1.6.2,
- * this release does not support this
- */
- /*sampling_rate = getbits( LEN_SAMP_RATE,
- pInputStream);*/
- getbits(LEN_SAMP_RATE, pInputStream);
- }
- /* syncExtensionType */
- syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
- pInputStream);
- if (syncExtensionType == 0x548)
- {
- pVars->mc_info.psPresentFlag = get1bits(pInputStream); /* psPresentFlag */
- if (pVars->mc_info.psPresentFlag)
- {
- extensionAudioObjectType = MP4AUDIO_PS;
- }
- }
- else
- {
- /*
- * Rewind bitstream pointer so that the syncExtensionType reading has no
- * effect when decoding raw bitstream
- */
- pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
- }
-
- pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
- }
- }
- }
- else if (!status)
- {
- /*
- * Rewind bitstream pointer so that the syncExtensionType reading has no
- * effect when decoding raw bitstream
- */
- pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
-
-#ifdef AAC_PLUS
-
- /*
- * For implicit signalling, no hint that sbr or ps is used, so we need to
- * check the sampling frequency of the aac content, if lesser or equal to
- * 24 KHz, by defualt upsample, otherwise, do nothing
- */
- if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
- audioObjectType == MP4AUDIO_AAC_LC)
- {
- pVars->mc_info.upsamplingFactor = 2;
- pVars->prog_config.sampling_rate_idx -= 3;
- pVars->mc_info.sbrPresentFlag = 1;
- pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
- pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
-
- }
-#endif
-
- }
- }
- else /* MP4AUDIO_SBR was detected */
- {
- /*
- * Set the real output frequency use by the SBR tool, define tentative upsample ratio
- */
- if (pVars->aacPlusEnabled == true)
- {
-#ifdef AAC_PLUS
- pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
- samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
-
- if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
- {
- /*
- * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
- */
- if (pVars->prog_config.sampling_rate_idx < 6)
- {
- pVars->aacPlusEnabled = false;
- }
- pVars->mc_info.bDownSampledSbr = true;
- }
- pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
-
-
-
-#endif
-
-
-
-
- }
-
- } /* if ( extensionAudioObjectType != MP4AUDIO_SBR ) */
-
- /*
- * The following object types are not supported in this release,
- * however, keep these interfaces for future implementation
- */
-
- /*
- *if (audioObjectType == MP4AUDIO_CELP)
- *{
- * status = 1;
- *}
- */
-
- /*
- *if (audioObjectType == MP4AUDIO_HVXC)
- *{
- * status = 1;
- *}
- */
-
- /*
- *if (audioObjectType == MP4AUDIO_TTSI)
- *{
- * status = 1;
- *}
- */
-
- /*
- *if ((audioObjectType == 13) || (audioObjectType == 14) ||
- * (audioObjectType == 15) || (audioObjectType == 16))
- *{
- * status = 1;
- *}
- */
-
- /* The following objects are Amendment 1 objects */
- /*
- *if (((audioObjectType == MP4AUDIO_ER_AAC_LC) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_LTP) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
- * (audioObjectType == MP4AUDIO_ER_TWINVQ) ||
- * (audioObjectType == MP4AUDIO_ER_BSAC) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1))
- *{
- */
- /*
- * should call get_GA_specific_config
- * for this release, do not support Error Resilience
- * temporary solution is set status flag and exit decoding
- */
- /* status = 1;
- *}
- */
-
- /*
- *if (audioObjectType == MP4AUDIO_ER_CELP)
- * {
- * status = 1;
- *}
- */
-
- /*
- *if (audioObjectType == MP4AUDIO_ER_HVXC)
- *{
- * status = 1;
- *}
- */
-
- /*
- *if ((audioObjectType == MP4AUDIO_ER_HILN) ||
- * (audioObjectType == MP4AUDIO_PARAMETRIC))
- *{
- * status = 1;
- *}
- */
-
- /*
- *if ((audioObjectType == MP4AUDIO_ER_AAC_LC) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_LTP) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
- * (audioObjectType == MP4AUDIO_ER_TWINVQ) ||
- * (audioObjectType == MP4AUDIO_ER_BSAC) ||
- * (audioObjectType == MP4AUDIO_ER_AAC_LD) ||
- * (audioObjectType == MP4AUDIO_ER_CELP) ||
- * (audioObjectType == MP4AUDIO_ER_HVXC) ||
- * (audioObjectType == MP4AUDIO_ER_HILN) ||
- * (audioObjectType == MP4AUDIO_PARAMETRIC))
- *{
- */
- /* error protection config */
- /*
- * epConfig =
- * getbits(
- * LEN_EP_CONFIG,
- * pInputStream);
- *
- * if (epConfig == 2)
- * {
- */
- /* should call ErrorProtectionSpecificConfig() */
- /*
- * status = 1;
- * }
- *
- *}
- */
-
- return status;
-
-}
diff --git a/media/libstagefright/codecs/aacdec/get_audio_specific_config.h b/media/libstagefright/codecs/aacdec/get_audio_specific_config.h
deleted file mode 100644
index b7cfcf5..0000000
--- a/media/libstagefright/codecs/aacdec/get_audio_specific_config.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_audio_specific_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function declaration for get_audio_specific_config
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_AUDIO_SPECIFIC_CONFIG_H
-#define GET_AUDIO_SPECIFIC_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_audio_specific_config(
- tDec_Int_File * const pVars
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_dse.cpp b/media/libstagefright/codecs/aacdec/get_dse.cpp
deleted file mode 100644
index d64087f..0000000
--- a/media/libstagefright/codecs/aacdec/get_dse.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to a BITS structure that holds information
- regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pInputStream->usedBits is rounded up to a number that represents the next
- byte boundary.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Adquire Data Stream element (DSE) from raw bitstream
- At this time this function just drops the information.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-void byte_align(
- BITS *pInputStream)
-
- MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
- (pInputStream->usedBits + 7) % 8)
-
- RETURN(nothing)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- STACK USAGE:
-
- where:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "get_dse.h"
-#include "ibstream.h"
-#include "getbits.h"
-#include "s_bits.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void get_dse(
- Char *DataStreamBytes,
- BITS *pInputStream)
-{
- Int i;
- Int data_byte_align_flag;
- UInt count;
- Int esc_count;
- Char *pDataStreamBytes;
-
- pDataStreamBytes = DataStreamBytes;
-
- /*
- * Get element instance tag ( 4 bits)
- * ( max of 16 per raw data block)
- */
- get9_n_lessbits(LEN_TAG, pInputStream);
-
- /*
- * get data_byte_align_flag ( 1 bit0 to see if byte alignment is
- * performed within the DSE
- */
- data_byte_align_flag = get1bits(pInputStream);
-
- /*
- * get count ( 8 bits)
- */
- count = get9_n_lessbits(LEN_D_CNT, pInputStream);
-
- /*
- * if count == 255, its value it is incremented by a
- * second 8 bit value, esc_count. This final value represents
- * the number of bytes in the DSE
- */
- if (count == (1 << LEN_D_CNT) - 1)
- {
- esc_count = (Int)get9_n_lessbits(LEN_D_ESC, pInputStream); /* 8 bits */
- count += esc_count;
- }
-
- /*
- * Align if flag is set
- */
- if (data_byte_align_flag)
- {
- byte_align(pInputStream);
- }
-
- for (i = count; i != 0; i--)
- {
- *(pDataStreamBytes++) = (Char) get9_n_lessbits(
- LEN_BYTE,
- pInputStream);
- }
-
- return;
-
-} /* end get_dse */
-
diff --git a/media/libstagefright/codecs/aacdec/get_dse.h b/media/libstagefright/codecs/aacdec/get_dse.h
deleted file mode 100644
index 3563f71..0000000
--- a/media/libstagefright/codecs/aacdec/get_dse.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_dse.h
- Funtions:
- get_dse
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_DSE_H
-#define GET_DSE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void get_dse(
- Char *DataStreamBytes,
- BITS *pInputStream);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_ele_list.cpp b/media/libstagefright/codecs/aacdec/get_ele_list.cpp
deleted file mode 100644
index 0534c13..0000000
--- a/media/libstagefright/codecs/aacdec/get_ele_list.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_ele_list.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Change to PacketVideo standard, rename variables.
-
- Description: Add own header file, make pInputStream second param for speed.
-
- Description: Changes per code review:
- 1) Include header file
- 2) Convert to count down
- 3) Add return (not in review)
-
- Description:
- (1) Updated copyright header
- (2) Replaced include of "interface.h" with "e_ProgConfig.h"
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pElementList = pointer to an EleList structure - only the field num_ele
- needs to be set. Data type pointer to EleList.
-
- pInputStream = pointer to a BITS structure, used by the function getbits
- to provide data. Data type pointer to BITS
-
- enableCPE = boolean value indicating the area to be read contains
- a channel pair element field. Data type Bool
-
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified:
- pElementList contents are updated with information pertaining to channel
- configuration.
-
- pInputBuffer contents are updated to the next location to be read from
- the input stream.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function is called several times by get_prog_config() to read in part of
- the program configuration data related to channel setup.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not have static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
- page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- elementCount = pElementList->num_ele;
-
- FOR (index = 0; index < elementCount; index++)
- IF (enableCPE != FALSE) THEN
- pElementList->ele_is_cpe[index] =
- getbits(LEN_ELE_IS_CPE, pInputStream);
- ELSE
- pElementList->ele_is_cpe[index] = 0;
- END IF
-
- pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream);
-
- END FOR
-
- RETURNS nothing
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-#include "e_progconfigconst.h"
-#include "ibstream.h"
-#include "get_ele_list.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void get_ele_list(
- EleList *pElementList,
- BITS *pInputStream,
- const Bool enableCPE)
-{
- Int index;
- Int *pEleIsCPE;
- Int *pEleTag;
-
- pEleIsCPE = &pElementList->ele_is_cpe[0];
- pEleTag = &pElementList->ele_tag[0];
-
- for (index = pElementList->num_ele; index > 0; index--)
- {
- if (enableCPE != FALSE)
- {
- *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream);
- }
- else
- {
- *pEleIsCPE++ = FALSE;
- }
-
- *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream);
-
- } /* end for (index) */
-
- return;
-
-} /* end get_ele_list */
-
diff --git a/media/libstagefright/codecs/aacdec/get_ele_list.h b/media/libstagefright/codecs/aacdec/get_ele_list.h
deleted file mode 100644
index 82f140b..0000000
--- a/media/libstagefright/codecs/aacdec/get_ele_list.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_ele_list.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_ele_list.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ELE_LIST_H
-#define GET_ELE_LIST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void get_ele_list(
- EleList *pElementList,
- BITS *pInputStream,
- const Bool enableCPE);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp b/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp
deleted file mode 100644
index 65c00ea..0000000
--- a/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_GA_specific_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Change getbits.h to ibstream.h
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Updated to use scratch memory for the temporary prog config.
-
- Description: Replace some instances of getbits to get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pVars = pointer to the structure that holds all information for
- this instance of the library. pVars->prog_config
- pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128
- are needed for calling set_mc_info.
- Data type pointer to tDec_Int_File
-
- channel_config = variable that indicates the channel configuration
- information, in this decoder library, only values
- 0, 1, and 2 are allowed.
- Data type UInt
-
- audioObjectType = variable that indicates the Audio Object Type.
- Data type UInt.
-
- pInputStream = pointer to a BITS structure that holds information
- regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- status = 0 if success
- 1 otherwise
-
- Pointers and Buffers Modified:
- pVars->mc_info contents are updated with channel information.
- if infoinit is called within set_mc_info, then
- pVars->pWinSeqInfo contents are updated with window information.
- pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function takes the sampling_rate_idx, channel_config, and
- audioObjectType from AudioSpecificConfig() and set the decoder configuration
- necessary for the decoder to decode properly.
- It also reads the bitstream for frame length, scalable bitstream information
- and extension information to General Audio defined in MPEG-4 phase 1
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global variables
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- Part 3
- Subpart 1 p18 1.6 Interface to MPEG-4 Systems
- Subpart 4 p13 4.4.1 GA Specific Configuration
- Amendment p10 6.2.1 AudioSpecificInfo
- Amendment p78 8.2 Decoder configuration (GASpecificConfig)
-
- (2) AAC DecoderSpecificInfo Information
- PacketVideo descriptions - San Diego
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- frameLenFlag = CALL getbits(
- neededBits = LEN_FRAME_LEN_FLAG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (frameLenFlag)
-
- dependsOnCoreCoder = CALL getbits(
- neededBits = LEN_DEPEND_ON_CORE,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (dependsOnCoreCoder)
-
- IF (dependsOnCoreCoder != FALSE)
- THEN
- coreCoderDelay = CALL getbits(
- neededBits = LEN_CORE_DELAY,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (coreCoderDelay)
- ENDIF
-
- extFlag = CALL getbits(
- neededBits = LEN_EXT_FLAG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (extFlag)
-
- IF (channel_config == 0)
- THEN
- status = CALL get_prog_config(
- pVars = pVars,
- pScratchPCE = &pVars->scratch_prog_config);
- MODIFYING (pVars, pScratchPCE)
- RETURNING (status)
-
- ELSE
- channel_config--;
- pVars->prog_config.front.ele_is_cpe[0] = channel_config;
- pVars->prog_config.front.ele_tag[0] = 0;
-
- status = CALL set_mc_info(
- pMC_Info = &(pVars->mc_info),
- audioObjectType = audioObjectType,
- sampling_rate_idx = pVars->prog_config.sampling_rate_idx,
- tag = pVars->prog_config.front.ele_tag[0],
- is_cpe = pVars->prog_config.front.ele_is_cpe[0],
- pWinSeqInfo = pVars->pWinSeqInfo,
- sfbwidth128 = pVars->SFBWidth128);
- MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128)
- RETURNING (SUCCESS)
- ENDIF
-
- IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR
- (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
- THEN
- layer_num = CALL getbits(
- neededBits = LEN_LAYER_NUM,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (layer_num)
-
- status = 1;
- ENDIF
-
- IF (extFlag != FALSE)
- THEN
- IF (audioObjectType == MP4AUDIO_ER_BSAC)
- THEN
- numOfSubFrame = CALL getbits(
- neededBits = LEN_SUB_FRAME,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (numOfSubFrame)
-
- layer_len = CALL getbits(
- neededBits = LEN_LAYER_LEN,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (layer_len)
-
- ENDIF
-
- IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR
- (audioObjectType == 23))
- THEN
- aacSectionDataResilienceFlag =
- CALL getbits(
- neededBits = LEN_SECT_RES_FLAG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (aacSectionDataResilienceFlag)
-
- aacScalefactorDataResilienceFlag =
- CALL getbits(
- neededBits = LEN_SFB_RES_FLAG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (aacScalefactorDataResilienceFlag)
-
- aacSpectralDataResilienceFlag =
- CALL getbits(
- neededBits = LEN_SPEC_RES_FLAG,
- pInputStream = pInputStream);
- MODIFYING (pInputStream)
- RETURNING (aacSpectralDataResilienceFlag)
- ENDIF
-
- status = 1;
-
- ENDIF
-
- RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_mp4ff_const.h"
-#include "e_tmp4audioobjecttype.h"
-#include "s_tdec_int_file.h"
-#include "get_ga_specific_config.h"
-#include "set_mc_info.h"
-#include "get_prog_config.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_GA_specific_config(
- tDec_Int_File * const pVars,
- BITS *pInputStream,
- UInt channel_config,
- const tMP4AudioObjectType audioObjectType
-)
-{
-
- Int status = SUCCESS;
- UInt dependsOnCoreCoder;
- /* Int coreCoderDelay; */
- UInt extFlag;
-
- /* These variables are left for future implementation */
- /* UInt layer_num; */
- /* UInt numOfSubFrame; */
- /* UInt layer_len; */
- /* UInt aacSectionDataResilienceFlag; */
- /* UInt aacScalefactorDataResilienceFlag; */
- /* UInt aacSpectralDataResilienceFlag; */
- Int extFlag3;
-
- /*
- * frame length flag == 0, 1024 samples/frame
- * frame length flag == 1, 960 samples/frame
- */
- get1bits(/* LEN_FRAME_LEN_FLAG,*/
- pInputStream);
-
- /*
- * dependsOnCoreCoder == 1, core coder has different sampling rate
- * in a scalable bitstream
- */
- dependsOnCoreCoder =
- get1bits(/* LEN_DEPEND_ON_CORE,*/
- pInputStream);
-
- if (dependsOnCoreCoder != FALSE)
- {
- /*coreCoderDelay =
- * getbits(
- * LEN_CORE_DELAY,
- * pInputStream);
- */
-
- status = 1; /* do not support scalable coding in this release */
- }
-
- /*
- * extension flag indicates if Amendment 1 objects are used or not
- * extension flag == 0 objects = 1, 2, 3, 4, 6, 7
- * extension flag == 1 objects = 17, 19, 20, 21, 22, 23
- */
- extFlag = get1bits(pInputStream); /* LEN_EXT_FLAG,*/
-
-
- /* Force checks for implicit channel configuration */
- pVars->mc_info.implicit_channeling = 1;
-
- if (status == SUCCESS)
- {
-
- if (channel_config == 0)
- {
- status = get_prog_config(pVars,
- &pVars->scratch.scratch_prog_config);
-
- if (status != SUCCESS)
- {
- pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono */
- pVars->mc_info.nch = 1;
- pVars->prog_config.front.ele_tag[0] = 0;
-
- status = SUCCESS;
- }
- }
- else
- {
- /*
- * dummy tag = 0 and
- * set up decoding configurations
- */
- channel_config--;
- pVars->prog_config.front.ele_is_cpe[0] = channel_config;
- pVars->prog_config.front.ele_tag[0] = 0;
-
- status =
- set_mc_info(
- &(pVars->mc_info),
- audioObjectType, /* previously profile */
- pVars->prog_config.sampling_rate_idx,
- pVars->prog_config.front.ele_tag[0],
- pVars->prog_config.front.ele_is_cpe[0],
- pVars->winmap, /*pVars->pWinSeqInfo,*/
- pVars->SFBWidth128);
-
- } /* if (channel_config) */
-
- } /* if(status) */
-
- /*
- * This layer_num is not found in ISO/IEC specs,
- * but it is defined in San Diego spec for scalable bitstream
- */
- if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) ||
- (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
- {
- /*layer_num =
- * getbits(
- * LEN_LAYER_NUM,
- * pInputStream);
- */
-
- status = 1; /* for this release only */
- }
-
- if (extFlag)
- {
- /*
- * currently do not implement these functionalities
- * defined in Amendment 1
- * keep it here for future release
- */
- if (audioObjectType == MP4AUDIO_ER_BSAC)
- {
- status = 1; /* NOT SUPPORTED */
- /*
- numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream);
-
- layer_len = getbits( LEN_LAYER_LEN, pInputStream);
- */
- }
-
- /*
- * The following code is equivalent to
- * if ((audioObjectType == 17) || (audioObjectType == 18) ||
- * (audioObjectType == 19) || (audioObjectType == 20) ||
- * (audioObjectType == 21) || (audioObjectType == 23))
- */
-
- if (((audioObjectType > 16) && (audioObjectType < 22)) ||
- (audioObjectType == 23))
- {
- status = 1; /* NOT SUPPORTED */
- /*
- aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG,
- pInputStream);
-
- aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG,
- pInputStream);
-
- aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG,
- pInputStream);
- */
- }
- /*
- * this flag is tbd in version 3 of ISO/IEC spec
- * if the encoder generates this bit, then it has to be read
- * current adif2mp4ff does not write this bit. If this bit is to
- * be read, it can be done by the following code:
- */
-
- extFlag3 = get1bits(pInputStream); /* LEN_EXT_FLAG3 */
-
- if (extFlag3)
- {
- status = 1; /* NOT SUPPORTED */
- }
-
- }
-
- return status;
-}
diff --git a/media/libstagefright/codecs/aacdec/get_ga_specific_config.h b/media/libstagefright/codecs/aacdec/get_ga_specific_config.h
deleted file mode 100644
index 7c77da5..0000000
--- a/media/libstagefright/codecs/aacdec/get_ga_specific_config.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_GA_specific_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType
- (2) update revision history
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for get_GA_specific_config.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_GA_SPECIFIC_CONFIG_H
-#define GET_GA_SPECIFIC_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_GA_specific_config(
- tDec_Int_File * const pVars,
- BITS *pInputStream,
- UInt channel_config,
- const tMP4AudioObjectType audioObjectType
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_ics_info.cpp b/media/libstagefright/codecs/aacdec/get_ics_info.cpp
deleted file mode 100644
index 17204cc..0000000
--- a/media/libstagefright/codecs/aacdec/get_ics_info.cpp
+++ /dev/null
@@ -1,608 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/get_ics_info.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Clean up code.
-
- Description: Fix comments before review, remove lpflag[]
-
- Description: Update per review comments, and match ISO/IEC 14496-3
-
- Description: Update per peer review comments.
-
- Description: Remove "rollback" of used bits, since lt_decode is to change.
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- audioObjectType = MP4 Audio Object Type for the current song. Only if
- this is set to LTP (MP4AUDIO_LTP) will long term
- prediction bits be retrieved. Data type
- tMP4AudioObjectType, which is an enumeration, which in
- turn is an Int.
-
- pInputStream = pointer to a BITS structure, used by the function getbits
- to provide data. This is the second parameter to this
- function to match its position in getbits().
- Data type pointer to BITS structure
-
- common_window = field read in huffdecode, which tells whether information
- is shared between the left and right channel. Long term
- prediction (LTP) data is NOT shared even if its a common
- window, so this flag is needed to see if another set of
- LTP possibly needs to be read. If this flag is false,
- pSecondLTPStatus is not touched, it could be NULL if
- need be. Data type Bool, which is Int.
-
- pWindowSequence = pointer to where the the window type of the current
- frame and channel should be placed, of data type
- WINDOW_SEQUENCE, which is Int. It can take on one
- of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE,
- EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE,
-
- pWindowShape = pointer to where the window shape for the current frame
- and channel should be placed, of data type WINDOW_SHAPE,
- which is Int. It can take on the one of these two values:
- SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the
- "filterbank" section of decoding.
-
- group = array that holds the index of the first window in each
- group. Data type array of Int, eight elements.
-
- p_max_sfb = pointer to where the maximum number of scale factor bands
- for the current frame and channel will be placed. Data
- type of pointer to Int.
-
- p_winmap = array of pointers to all of the possible four window
- configurations. This parameter did not need to be pointers,
- and could be changed in the future. Data type array of pointers
- to FrameInfo structures, length 4.
-
- pFirstLTPStatus = pointer to a structure where the first LTP
- information will be stored. It would be confusing and wrong
- to call this left LTP status since if common_window = FALSE,
- this function will be called twice - once for the left, once
- for the right. It could be done, but extra conditional code
- would need to be done.
- Data type pointer to LT_PRED_STATUS structure.
-
- pSecondLTPStatus = pointer to where the right channel of LTP
- information will be stored only if common_window is non-zero.
- Data type pointer to LT_PRED_STATUS structure.
-
- Local Stores/Buffers/Pointers Needed: None.
-
- Global Stores/Buffers/Pointers Needed: None.
-
- Outputs:
- status = 0 implies no error occurred, non-zero otherwise.
-
- Pointers and Buffers Modified:
- pInputStream contents are modified in such a way that the number of bits
- read increases.
- pWindowSequence contents are updated with the current window for this
- frame and channel
- group[] contents will be modified to grouping information. See getgroup
- source code for a better description of what this is.
- p_max_sfb contents will be updated with the maximum scale factor bands
- for this frame and channel.
- pFirstLTPStatus contents may be updated if the stream has long term
- prediction information.
- pSecondLTPStatus contents may be updated if common_window != 0 and LTP data
- is present.
-
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function retrieves the individual channel stream (ICS) information
- from the bitstream. The information read for the current
- frame and channel is:
- - window sequence
- - window shape for use in the filter bank
- - number of scale factor bands
- - long term predication (LTP) information
- - grouping information
-
- This function does NOT support MPEG2 style AAC Frequency Domain Predictor,
- not to be confused with LTP (Long Term Prediction). If such data is found
- to be on the file an error is generated.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function is not to use static or global data.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding
- of audio-visual objects Part 3: Audio Subpart 4:"
- Table 4.4.6 - Syntax of ics_info(), page 16.
-
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = 0;
- first_ltp_data_present = FALSE;
- second_ltp_data_present = FALSE;
-
-
- CALL getbits(
- neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
- pInputStream = pInputStream)
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- windowSequence = (temp >> LEN_WIN_SH) & ((0x1<<LEN_WIN_SEQ)-1);
-
- *pWindowShape = (temp) & ((0x1<<LEN_WIN_SH)-1);
-
- IF (windowSequence == EIGHT_SHORT_SEQUENCE)
- THEN
- CALL getbits(
- neededBits = LEN_MAX_SFBS,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(local_max_sfb = returnValue)
-
- CALL getgroup(
- group = group,
- pInputStream = pInputStream)
- MODIFYING(group)
- MODIFYING(pInputStream)
- RETURNING(nothing)
-
-
- ELSE
-
- group[0] = 1;
-
- CALL getbits(
- neededBits = LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(temp = returnValue)
-
- predictor_data_present =
- (Bool) getbits(
- LEN_BOOLEAN,
- pInputStream);
-
- local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
-
- predictor_data_present =
- (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1));
-
- IF (local_max_sfb > allowed_max_sfb)
- THEN
- status = 1
- ELSEIF (audioObjectType == MP4AUDIO_LTP)
- THEN
- IF (predictor_data_present != FALSE)
- THEN
- CALL getbits(
- neededBits = LEN_LTP_DATA_PRESENT,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(first_ltp_data_present = returnValue)
-
- IF (ltp_data_present != FALSE)
- THEN
-
- CALL lt_decode(
- win_type = windowSequence,
- pInputStream = pInputStream,
- max_sfb = local_max_sfb,
- pLt_pred = pFirstLTPStatus)
- MODIFYING(pInputStream)
- MODIFYING(pFirstLTPStatus)
- RETURNING(nothing)
-
- ENDIF
-
- IF (common_window != FALSE)
- THEN
- CALL getbits(
- neededBits = LEN_LTP_DATA_PRESENT,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(second_ltp_data_present = returnValue)
-
- IF (second_ltp_data_present != FALSE)
- THEN
-
- CALL lt_decode(
- win_type = windowSequence,
- pInputStream = pInputStream,
- max_sfb = local_max_sfb,
- pLt_pred = pSecondLTPStatus)
- MODIFYING(pInputStream)
- MODIFYING(pSecondLTPStatus)
- RETURNING(nothing)
- ENDIF
- ENDIF
- ENDIF
- ELSE
- IF (predictor_data_present != FALSE)
- THEN
- status = 1
- ENDIF
- END IF
- ENDIF
-
- pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
-
- IF (common_window != FALSE)
- THEN
- pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
- ENDIF
-
- pFrameInfo = p_winmap[*p_wnd];
- IF (local_max_sfb > pFrameInfo->sfb_per_frame)
- THEN
- status = 1;
- ENDIF
-
- *(p_max_sfb) = local_max_sfb;
-
- MODIFY(*(pWindowSequence))
- MODIFY(*(pWinShape))
- MODIFY(*(p_max_sfb))
- MODIFY(group[])
- MODIFY(*pInputStream)
- MODIFY(*pFirstLTPStatus)
- MODIFY(*pSecondLTPStatus)
- RETURN (status);
-
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#include "e_rawbitstreamconst.h"
-#include "e_tmp4audioobjecttype.h"
-
-#include "s_bits.h"
-#include "s_frameinfo.h"
-#include "s_lt_pred_status.h"
-
-#include "ibstream.h"
-#include "lt_decode.h"
-#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */
-
-#include "get_ics_info.h"
-#include "huffman.h" /* For the declaration of getgroup */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define LEN_PREDICTOR_DATA_PRESENT (1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int get_ics_info(
- const tMP4AudioObjectType audioObjectType,
- BITS *pInputStream,
- const Bool common_window,
- WINDOW_SEQUENCE *pWindowSequence,
- WINDOW_SHAPE *pWindowShape,
- Int group[],
- Int *p_max_sfb,
- FrameInfo *p_winmap[],
- LT_PRED_STATUS *pFirstLTPStatus,
- LT_PRED_STATUS *pSecondLTPStatus)
-{
- WINDOW_SEQUENCE windowSequence;
- UInt temp;
- Bool predictor_data_present;
- UInt local_max_sfb;
- UInt allowed_max_sfb;
- Int status = SUCCESS;
- Bool first_ltp_data_present = FALSE;
- Bool second_ltp_data_present = FALSE;
-
- /*
- * The following three calls to getbits have been replaced with one
- * call for speed:
- *
- * getbits(LEN_ICS_RESERV, pInputStream);
- * windowSequence = getbits(LEN_WIN_SEQ, pInputStream);
- * *pWindowShape = getbits(LEN_WIN_SH, pInputStream);
- *
- */
-
- temp =
- get9_n_lessbits(
- LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
- pInputStream);
-
-
- windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1));
-
- *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1));
-
- /*
- * This pointer should not be NULL as long as the initialization code
- * has been run, so the test for NULL has been removed.
- */
- allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0];
-
- if (windowSequence == EIGHT_SHORT_SEQUENCE)
- {
- local_max_sfb = get9_n_lessbits(LEN_MAX_SFBS,
- pInputStream);
-
- getgroup(
- group,
- pInputStream);
-
- if (local_max_sfb > allowed_max_sfb)
- {
- status = 1; /* ERROR CODE - needs to be updated */
- }
-
- } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */
- else
- {
- /* There is only one group for long windows. */
- group[0] = 1;
-
- /*
- * The window is long, get the maximum scale factor bands,
- * and get long term prediction info.
- *
- * Reference [1] states that the audioObjectType is first tested,
- * then the predictor_data_present is read on either branch of the
- * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines
- * the two calls on both branches into one before the
- * if, and then in turn combines with another call to getbits, all
- * in the name of speed.
- *
- * This would be the individual calls, without checking the number
- * of scale factor bands:
- *
- * local_max_sfb =
- * (Int) getbits(
- * LEN_MAX_SFBL,
- * pInputStream);
- *
- * if (audioObjectType == MP4AUDIO_LTP)
- * {
- * predictor_data_present =
- * (Bool) getbits(
- * LEN_PREDICTOR_DATA_PRESENT,
- * pInputStream);
- *
- * ..... (read LTP data)
- *
- * }
- * else
- * {
- *
- * predictor_data_present =
- * (Bool) getbits(
- * LEN_PREDICTOR_DATA_PRESENT,
- * pInputStream);
- *
- * ..... (its an error for this library)
- * }
- */
- temp =
- get9_n_lessbits(
- LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
- pInputStream);
-
- local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
-
- predictor_data_present =
- (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1));
-
- if (local_max_sfb > allowed_max_sfb)
- {
- status = 1; /* ERROR CODE - needs to be updated */
- }
- else if (audioObjectType == MP4AUDIO_LTP)
- {
- /*
- * Note that the predictor data bit has already been
- * read.
- */
-
- /*
- * If the object type is LTP, the predictor data is
- * LTP. If the object type is not LTP, the predictor data
- * is so called "frequency predictor data", which is not
- * supported by this implementation. Refer to (1)
- */
- if (predictor_data_present != FALSE)
- {
- first_ltp_data_present =
- (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/
- pInputStream);
-
- if (first_ltp_data_present != FALSE)
- {
- lt_decode(
- windowSequence,
- pInputStream,
- local_max_sfb,
- pFirstLTPStatus);
- }
- if (common_window != FALSE)
- {
- second_ltp_data_present =
- (Bool) get1bits(/* LEN_LTP_DATA_PRESENT,*/
- pInputStream);
-
- if (second_ltp_data_present != FALSE)
- {
- lt_decode(
- windowSequence,
- pInputStream,
- local_max_sfb,
- pSecondLTPStatus);
- }
- } /* if (common_window != FALSE) */
-
- } /* if (predictor_data_present != FALSE) */
-
- } /* else if (audioObjectType == MP4AUDIO_LTP) */
- else
- {
- /*
- * Note that the predictor data bit has already been
- * read.
- */
-
- /*
- * The object type is not LTP. If there is data, its
- * frequency predictor data, not supported by this
- * implementation.
- */
- if (predictor_data_present != FALSE)
- {
- status = 1; /* ERROR CODE UPDATE LATER */
- } /* if (predictor_data_present != FALSE) */
-
- } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */
-
- } /* if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */
-
-
- /*
- * Save all local copies.
- */
- pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
- if (common_window != FALSE)
- {
- pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
- }
-
- *p_max_sfb = local_max_sfb;
-
- *pWindowSequence = windowSequence;
-
- return (status);
-
-} /* get_ics_info */
-
diff --git a/media/libstagefright/codecs/aacdec/get_ics_info.h b/media/libstagefright/codecs/aacdec/get_ics_info.h
deleted file mode 100644
index b94ef8e..0000000
--- a/media/libstagefright/codecs/aacdec/get_ics_info.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_ics_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the declaration for the function get_ics_info()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ICS_INFO_H
-#define GET_ICS_INFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tmp4audioobjecttype.h"
-#include "s_bits.h"
-#include "e_window_sequence.h"
-#include "e_window_shape.h"
-#include "s_frameinfo.h"
-#include "s_lt_pred_status.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int get_ics_info(
- const tMP4AudioObjectType audioObjectType,
- BITS *pInputStream,
- const Bool common_window,
- WINDOW_SEQUENCE *p_wnd,
- WINDOW_SHAPE *pWindowShape,
- Int group[],
- Int *p_max_sfb,
- FrameInfo *p_winmap[],
- LT_PRED_STATUS *pFirstLTPStatus,
- LT_PRED_STATUS *pSecondLTPStatus);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GET_ICS_INFO_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_prog_config.cpp b/media/libstagefright/codecs/aacdec/get_prog_config.cpp
deleted file mode 100644
index 6bddd57..0000000
--- a/media/libstagefright/codecs/aacdec/get_prog_config.cpp
+++ /dev/null
@@ -1,739 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_prog_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Move functionality from get_adif_header for when to change
- the current program configuration, add a temporary config
- to read into, clean up code, change function prototype.
-
- Description: Clean up
-
- Description: Update per review comments
-
- Description: Fix double 'could'
-
- Description: change enter_mc_info to set_mc_info
-
- Description: update comments
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pVars = pointer to the structure that holds all information for
- this instance of the library. pVars->prog_config is directly
- used, and pVars->mc_info, pVars->prog_config, pVars->winmap,
- pVars->SFBWidth128 are needed indirectly for calling
- set_mc_info. Data type pointer to tDec_Int_File structure.
-
- pScratchPCE = pointer to a temporary ProgConfig structure to be used
- to read in the program configuration element.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = zero if no error was found, non-zero otherwise.
-
- Pointers and Buffers Modified:
- pVars->prog_config contents are updated with the PCE read in.
- pVars->mc_info contents are updated with channel information.
- pVars->winmap contents are updated with window information.
- pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads from the input stream to memory for a temporary
- program configuration element (PCE). If the PCE read is the first
- encountered it is saved. Or, if the tag of the PCE read matches the tag of
- the first PCE encounted, it is saved as well. This is a mechanism for
- changing the sampling rate.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
- page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = SUCCESS;
- pInputStream = &(pVars->inputStream);
-
-
- CALL getbits(
- neededBits = LEN_TAG,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( tag = returnValue )
-
- CALL getbits(
- neededBits = LEN_PROFILE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( pScratchPCE->profile = returnValue )
-
- CALL getbits(
- neededBits = LEN_PROFILE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( pScratchPCE->sampling_rate_idx = returnValue )
-
- CALL getbits(
- neededBits = LEN_NUM_ELE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->front.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_NUM_ELE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->side.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_NUM_ELE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->back.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_NUM_LFE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->lfe.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_NUM_DAT,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->data.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_NUM_CCE,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->coupling.num_ele = temp;
-
- CALL getbits(
- neededBits = LEN_MIX_PRES,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( flag = returnValue )
-
- pScratchPCE->mono_mix.present = flag;
-
- IF (flag != FALSE)
- THEN
- CALL getbits(
- neededBits = LEN_TAG,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->mono_mix.ele_tag = temp;
-
- ENDIF
-
- CALL getbits(
- neededBits = LEN_MIX_PRES,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( flag = returnValue )
-
- pScratchPCE->stereo_mix.present = flag;
-
- IF (flag != FALSE)
- THEN
-
- CALL getbits(
- neededBits = LEN_TAG,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->stereo_mix.ele_tag = temp;
-
- ENDIF
-
- CALL getbits(
- neededBits = LEN_MIX_PRES,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( flag = returnValue )
-
- flag =
- getbits(
- LEN_MIX_PRES,
- pInputStream);
-
- pScratchPCE->matrix_mix.present = flag;
-
- IF (flag != FALSE)
- THEN
- CALL getbits(
- neededBits = LEN_MMIX_IDX,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->matrix_mix.ele_tag = temp;
-
- CALL getbits(
- neededBits = LEN_PSUR_ENAB,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( temp = returnValue )
-
- pScratchPCE->matrix_mix.pseudo_enab = temp;
-
- ENDIF
-
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->front,
- pInputStream = pInputStream,
- enableCPE = TRUE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->front )
- RETURNING( nothing )
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->side,
- pInputStream = pInputStream,
- enableCPE = TRUE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->side )
- RETURNING( nothing )
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->back,
- pInputStream = pInputStream,
- enableCPE = TRUE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->back )
- RETURNING( nothing )
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->lfe,
- pInputStream = pInputStream,
- enableCPE = FALSE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->lfe )
- RETURNING( nothing )
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->data,
- pInputStream = pInputStream,
- enableCPE = FALSE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->data )
- RETURNING( nothing )
-
- CALL get_ele_list(
- pElementList = &pScratchPCE->coupling,
- pInputStream = pInputStream,
- enableCPE = TRUE )
- MODIFYING( pInputStream )
- MODIFYING( pScratchPCE->coupling )
- RETURNING( nothing )
-
-
- CALL byte_align(
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( nothing )
-
- CALL getbits(
- neededBits = LEN_COMMENT_BYTES,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( numChars = returnValue )
-
- FOR (i = numChars; i > 0; i--)
-
- CALL getbits(
- neededBits = LEN_COMMENT_BYTES,
- pInputStream = pInputStream )
- MODIFYING( pInputStream )
- RETURNING( nothing )
-
- ENDFOR
-
- IF (pVars->current_program < 0)
- THEN
- pVars->current_program = tag;
- ENDIF
-
-
- IF (tag == pVars->current_program)
- THEN
-
- CALL pv_memcpy(
- to = &pVars->prog_config,
- from = pScratchPCE,
- n = sizeof(ProgConfig))
- MODIFYING( pVars->prog_config )
- RETURNING( nothing )
-
- CALL set_mc_info(
- pMC_Info = &pVars->mc_info,
- objectType = pVars->prog_config.profile + 1,
- samplin_rate_idx = pVars->prog_config.sampling_rate_idx,
- tag = pVars->prog_config.front.ele_tag[0],
- is_cpe = pVars->prog_config.front.ele_is_cpe[0],
- pWinSeqInfo = pVars->winmap,
- pSfbwidth128 = pVars->SFBWidth128)
- MODIFYING( pVars->mc_info )
- MODIFYING( pVars->winmap )
- MODIFYING( pVars->SFBWidth128 )
- RETURN( status = return_value )
-
- ENDIF
-
- MODIFY( pVars->mc_info )
- MODIFY( pVars->winmap )
- MODIFY( pVars->SFBWidth128 )
- RETURN (status)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "s_elelist.h"
-#include "s_tdec_int_file.h"
-#include "s_tdec_int_chan.h"
-#include "e_progconfigconst.h"
-#include "ibstream.h"
-#include "get_ele_list.h"
-#include "aac_mem_funcs.h"
-#include "set_mc_info.h"
-#include "get_prog_config.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int get_prog_config(
- tDec_Int_File *pVars,
- ProgConfig *pScratchPCE)
-{
- Int i;
- UInt tag;
- Int numChars;
- UInt temp;
- Bool flag;
- Int status = SUCCESS;
- BITS *pInputStream = &(pVars->inputStream);
-
-
- /*
- * The tag is used at the very end to see if this PCE is
- * the one to be used. Otherwise it does not need to be saved for the
- * the simple configurations to be used in this version of an AAC
- * decoder.
- *
- * All of the bits of this PCE must be read even if this PCE will not
- * be used. They are read into a temporary PCE, then later it is decided
- * whether to keep this PCE.
- *
- * To allow quick removal of the fields from the ProgConfig structure
- * that will probably not be used at a later date,
- * while still advancing the bitstream pointer,the return value of
- * getbits is saved into a temporary variable, then transfered to
- * the structure item.
- */
- tag =
- get9_n_lessbits(
- LEN_TAG,
- pInputStream);
-
- pScratchPCE->profile =
- get9_n_lessbits(
- LEN_PROFILE,
- pInputStream);
-
- pScratchPCE->sampling_rate_idx =
- get9_n_lessbits(
- LEN_SAMP_IDX,
- pInputStream);
-
- if (!pVars->adif_test && pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx)
- {
- /* rewind the pointer as implicit channel configuration maybe the case */
- pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX);
-
- return (1); /* mismatch cannot happen */
- }
-
-
- /*
- * Retrieve the number of element lists for each of
- * front, side, back, lfe, data, and coupling.
- *
- * For two-channel stereo or mono, only the data in the front needs
- * to be saved. However, ALL fields need to be skipped over in some
- * fashion. Also, the number of elements needs to be temporarily saved
- * to call get_ele_list(). If that function was changed to pass in
- * the number of points to be read, the memory set aside inside the
- * ProgConfig structure could be removed.
- */
-
- /*
- * The next six function calls could be combined into one, then use
- * shifts and masks to retrieve the individual fields.
- */
- temp =
- get9_n_lessbits(
- LEN_NUM_ELE,
- pInputStream);
-
- pScratchPCE->front.num_ele = temp;
-
- /* Needed only to read in the element list. */
- temp =
- get9_n_lessbits(
- LEN_NUM_ELE,
- pInputStream);
-
- pScratchPCE->side.num_ele = temp;
-
- /* Needed only to read in the element list. */
- temp =
- get9_n_lessbits(
- LEN_NUM_ELE,
- pInputStream);
-
- pScratchPCE->back.num_ele = temp;
-
- /* Needed only to read in the element list. */
- temp =
- get9_n_lessbits(
- LEN_NUM_LFE,
- pInputStream);
-
- pScratchPCE->lfe.num_ele = temp;
-
- /* Needed only to read in the element list. */
- temp =
- get9_n_lessbits(
- LEN_NUM_DAT,
- pInputStream);
- pScratchPCE->data.num_ele = temp;
-
- /* Needed only to read in the element list. */
- temp =
- get9_n_lessbits(
- LEN_NUM_CCE,
- pInputStream);
-
- pScratchPCE->coupling.num_ele = temp;
-
- /*
- * Read in mix down data.
- *
- * Whether these fields can be removed and have proper operation
- * will be determined at a later date.
- */
-
- /* Read presence of mono_mix */
- flag =
- get1bits(/* LEN_MIX_PRES,*/
- pInputStream);
-
- pScratchPCE->mono_mix.present = flag;
-
- if (flag != FALSE)
- {
- temp =
- get9_n_lessbits(
- LEN_TAG,
- pInputStream);
-
- pScratchPCE->mono_mix.ele_tag = temp;
-
- } /* end if (flag != FALSE) */
-
- /* Read presence of stereo mix */
- flag =
- get1bits(/* LEN_MIX_PRES,*/
- pInputStream);
-
- pScratchPCE->stereo_mix.present = flag;
-
- if (flag != FALSE)
- {
- temp =
- get9_n_lessbits(
- LEN_TAG,
- pInputStream);
-
- pScratchPCE->stereo_mix.ele_tag = temp;
-
- } /* end if (flag != FALSE) */
-
- /* Read presence of matrix mix */
- flag =
- get1bits(/* LEN_MIX_PRES,*/
- pInputStream);
-
- pScratchPCE->matrix_mix.present = flag;
-
- if (flag != FALSE)
- {
- temp =
- get9_n_lessbits(
- LEN_MMIX_IDX,
- pInputStream);
-
- pScratchPCE->matrix_mix.ele_tag = temp;
-
- temp =
- get1bits(/* LEN_PSUR_ENAB,*/
- pInputStream);
-
- pScratchPCE->matrix_mix.pseudo_enab = temp;
-
- } /* end if (flag != FALSE) */
-
- /*
- * Get each of the element lists. Only the front information will be
- * used for the PV decoder, but the usedBits field of pInputStream must
- * be advanced appropriately.
- *
- * This could be optimized by advancing the bit stream for the
- * elements that do not need to be read.
- */
- get_ele_list(
- &pScratchPCE->front,
- pInputStream,
- TRUE);
-
- get_ele_list(
- &pScratchPCE->side,
- pInputStream,
- TRUE);
-
- get_ele_list(
- &pScratchPCE->back,
- pInputStream,
- TRUE);
-
- get_ele_list(
- &pScratchPCE->lfe,
- pInputStream,
- FALSE);
-
- get_ele_list(
- &pScratchPCE->data,
- pInputStream,
- FALSE);
-
- get_ele_list(
- &pScratchPCE->coupling,
- pInputStream,
- TRUE);
-
- /*
- * The standard requests a byte alignment before reading in the
- * comment. This can be done because LEN_COMMENT_BYTES == 8.
- */
- byte_align(pInputStream);
-
- numChars =
- get9_n_lessbits(
- LEN_COMMENT_BYTES, pInputStream);
-
- /*
- * Ignore the comment - it requires 65 bytes to store (or worse on DSP).
- * If this field is restored, make sure to append a trailing '\0'
- */
- for (i = numChars; i > 0; i--)
- {
- pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE,
- pInputStream);
-
- } /* end for */
-
- if (pVars->current_program < 0)
- {
- /*
- * If this is the first PCE, it becomes the current, regardless of
- * its tag number.
- */
- pVars->current_program = tag;
-
- } /* end if (pVars->current_program < 0) */
-
-
- if (tag == (UInt)pVars->current_program)
- {
- /*
- * This branch is reached under two conditions:
- * 1) This is the first PCE found, it was selected in the above if
- * block. In all encoders found thus far, the tag value has been
- * zero.
- * 2) A PCE has been sent by the encoder with a tag that matches the
- * the first one sent. It will then be re-read. No encoder found
- * thus far re-sends a PCE, when looking at ADIF files.
- *
- * Regardless, the temporary PCE will now be copied into the
- * the one official program configuration.
- */
- pv_memcpy(
- &pVars->prog_config,
- pScratchPCE,
- sizeof(ProgConfig));
-
- /* enter configuration into MC_Info structure */
- status =
- set_mc_info(
- &pVars->mc_info,
- (tMP4AudioObjectType)(pVars->prog_config.profile + 1),
- pVars->prog_config.sampling_rate_idx,
- pVars->prog_config.front.ele_tag[0],
- pVars->prog_config.front.ele_is_cpe[0],
- pVars->winmap,
- pVars->SFBWidth128);
-
- } /* end if (tag == pVars->current_program) */
-
- return (status);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/get_prog_config.h b/media/libstagefright/codecs/aacdec/get_prog_config.h
deleted file mode 100644
index 646ba46..0000000
--- a/media/libstagefright/codecs/aacdec/get_prog_config.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_prog_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_prog_config.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_PROG_CONFIG_H
-#define GET_PROG_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_progconfig.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_prog_config(
- tDec_Int_File *pVars,
- ProgConfig *pTempPCE);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_pulse_data.cpp b/media/libstagefright/codecs/aacdec/get_pulse_data.cpp
deleted file mode 100644
index f9c24f4..0000000
--- a/media/libstagefright/codecs/aacdec/get_pulse_data.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_pulse_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Put into PV format
-
- Description: 1) Change loop to use pointers.
- 2) Rename to from get_nec_nc to get_pulse_data
-
- Description: Changes per code review
- 1) Fix pathname
- 2) Read in two fields to save call to getbits
- 3) Change how pPulseInfo->number_pulse is stored.
-
- Description: Placed typecast to Int in places where UInt->Int
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to a BITS structure, used by the function getbits
- to provide data. Data type pointer to BITS structure
-
- pPulseInfo = pointer to pulse data structure to be filled with data
- concerning pulses in the frequency domain.
- Data type pointer to PulseInfo
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = return value, zero signifies success, non-zero otherwise.
- Presently this function only returns a success, error
- checking may be added later.
- Data type Int.
-
- Pointers and Buffers Modified:
-
- pPulseInfo contents are updated with pulse information. Specifically,
- pPulseInfo->number_pulse with the number of pulses found, and
- pPulseInfo->pulse_start_sfb is set to the first scale factor band.
- Then pPulseInfo->pulse_offset and pPulseInfo->pulse_amp are filled
- with data. For these array, only the number of pulses defined will be
- set, those values beyond the number of pulses will retain their previous
- value and should not be read from.
- Note: The value in pPulseInfo->number_pulse is different by a value of
- one from the original ISO code.
-
- pInputBuffer contents are updated to the next location to be read from
- the input stream.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function fills in the pulse data structure with information to be used
- later for restoring pulses in the spectrum.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Table 6.17 - Syntax of pulse_data(),
- page 15, and section 9.3 "Decoding process", starting on page 41.
-
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = SUCCESS;
-
- CALL getbits(neededBits = LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB,
- pInputStream = pInputStream)
- MODIFYING(*pInputStream)
- RETURNING(temp)
-
- pPulseInfo->number_pulse = 1 + (temp >> LEN_PULSE_ST_SFB);
- pPulseInfo->pulse_start_sfb = temp & ((1 << LEN_PULSE_ST_SFB) - 1);
-
- pPulseOffset = &pPulseInfo->pulse_offset[0];
- pPulseAmp = &pPulseInfo->pulse_amp[0];
-
- FOR (i = PulseInfo->number_pulse; i > 0; i--)
- CALL getbits(neededBits = LEN_PULSE_POFF + LEN_PULSE_PAMP,
- pInputStream = pInputStream)
- MODIFYING(*pInputStream)
- RETURNING(temp)
-
- *pPulseOffset++ = temp >> LEN_PULSE_PAMP;
- *pPulseAmp++ = temp & ((1 << LEN_PULSE_PAMP) - 1);
- END FOR
-
- MODIFYING (*pInputStream)
- MODIFYING (*pPulseInfo)
-
- RETURN status
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-#include "e_rawbitstreamconst.h"
-#include "get_pulse_data.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_pulse_data(
- PulseInfo *pPulseInfo,
- BITS *pInputStream)
-{
- Int i;
- Int *pPulseOffset;
- Int *pPulseAmp;
- Int status = SUCCESS;
- UInt temp;
-
- /*
- * Read in both field fields at once to save cycles. These are the
- * original lines of code:
- * pPulseInfo->number_pulse = getbits(LEN_PULSE_NPULSE, pInputStream);
- * pPulseInfo->pulse_start_sfb = getbits(LEN_PULSE_ST_SFB, pInputStream);
- */
-
- temp =
- get9_n_lessbits(
- LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB,
- pInputStream);
-
- pPulseInfo->number_pulse = (Int)(1 + (temp >> LEN_PULSE_ST_SFB));
- pPulseInfo->pulse_start_sfb = (Int)(temp & ((1 << LEN_PULSE_ST_SFB) - 1));
-
- pPulseOffset = &pPulseInfo->pulse_offset[0];
- pPulseAmp = &pPulseInfo->pulse_amp[0];
-
- /*
- * This loop needs to count one more than the number read in from
- * the bitstream - look at reference [1].
- */
-
- for (i = pPulseInfo->number_pulse; i > 0; i--)
- {
- /*
- * Read in both fields. Original lines:
- * *pPulseOffset++ = getbits(LEN_PULSE_POFF, pInputStream);
- * *pPulseAmp++ = getbits(LEN_PULSE_PAMP, pInputStream);
- */
-
- temp =
- get9_n_lessbits(
- LEN_PULSE_POFF + LEN_PULSE_PAMP,
- pInputStream);
-
- *pPulseOffset++ = (Int)(temp >> LEN_PULSE_PAMP);
-
- *pPulseAmp++ = (Int)(temp & ((1 << LEN_PULSE_PAMP) - 1));
- }
-
- return (status);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/get_pulse_data.h b/media/libstagefright/codecs/aacdec/get_pulse_data.h
deleted file mode 100644
index 267f534..0000000
--- a/media/libstagefright/codecs/aacdec/get_pulse_data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_pulse_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change structure name.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_pulse_data.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_PULSE_DATA_H
-#define GET_PULSE_DATA_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int get_pulse_data(
- PulseInfo *pPulseInfo,
- BITS *pInputStream);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GET_PULSE_DATA_H */
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp b/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp
deleted file mode 100644
index b6ec365..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_bitstream.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- INPUT
-
- SBRDECODER self,
- SBRBITSTREAM * stream,
- float *timeData,
- int numChannels
-
- OUTPUT
-
- errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- sbr decoder processing, set up SBR decoder phase 2 in case of
- different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-#include "get_sbr_bitstream.h"
-#include "pv_audio_type_defs.h"
-#include "sbr_crc_check.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, BITS *pInputStream)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
-
- Int32 count;
- Int32 esc_count;
- Int32 Extention_Type;
- Int32 i;
-
- count = get9_n_lessbits(LEN_F_CNT, pInputStream);
- if (count == 15)
- {
- esc_count = get9_n_lessbits(LEN_F_ESC, pInputStream);
- count = esc_count + 14;
- }
-
-
-
- Extention_Type = get9_n_lessbits(LEN_F_CNT, pInputStream);
-
-
- if (((Extention_Type == SBR_EXTENSION) || (Extention_Type == SBR_EXTENSION_CRC))
- && (count < MAXSBRBYTES) && (count) && (sbrBitStream->NrElements < MAXNRELEMENTS))
- {
-
- sbrBitStream->sbrElement[sbrBitStream->NrElements].ExtensionType = Extention_Type;
- sbrBitStream->sbrElement[sbrBitStream->NrElements].Payload = count;
- sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[0] = (UChar) get9_n_lessbits(LEN_F_CNT, pInputStream);
- for (i = 1 ; i < count ; i++)
- {
- sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[i] = (UChar) get9_n_lessbits(8, pInputStream);
- }
-
- sbrBitStream->NrElements += 1;
-
- }
- else
- {
- pInputStream->usedBits += (count - 1) * LEN_BYTE;
- pInputStream->usedBits += 4; /* compenste for LEN_F_CNT (=4) bits read for Extention_Type */
-
- }
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h b/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h
deleted file mode 100644
index 8094b1a..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_bitstream.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_BITSTREAM_H
-#define GET_SBR_BITSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_rawbitstreamconst.h"
-#include "s_sbrbitstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream,
- BITS *pInputStream);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp b/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp
deleted file mode 100644
index 38ddc0b..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_startfreq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "get_sbr_startfreq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int v_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}
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int get_sbr_startfreq(const Int32 fs,
- const Int32 start_freq)
-{
- Int k0_min = 0;
- Int32 index;
-
-
- switch (fs)
- {
- case 16000:
- index = 0;
- k0_min = 24;
- break;
- case 22050:
- index = 1;
- k0_min = 17;
- break;
- case 24000:
- index = 2;
- k0_min = 16;
- break;
- case 32000:
- index = 3;
- k0_min = 16;
- break;
- case 44100:
- index = 4;
- k0_min = 12;
- break;
- case 48000:
- index = 4;
- k0_min = 11;
- break;
- case 64000:
- index = 4;
- k0_min = 10;
- break;
- case 88200:
- case 96000:
- index = 5;
- k0_min = 7;
- break;
-
- default:
- index = 6;
- }
- return (k0_min + v_offset[index][start_freq]);
-
-}
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h b/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h
deleted file mode 100644
index 10fa160..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_startfreq.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_STARTFREQ_H
-#define GET_SBR_STARTFREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_sbr_startfreq(const Int32 fs,
- const Int32 start_freq);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp b/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp
deleted file mode 100644
index e32c61d..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_stopfreq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- if(fs < 32000)
- {
- k1_min = (Int) ( ( (float) (6000 * 2 * 64) / fs ) + 0.5 );
- }
- else
- {
- if (fs < 64000)
- {
- k1_min = (Int) ( ( (float) (8000 * 2 * 64) / fs ) + 0.5 );
- }
- else
- {
- k1_min = (Int) ( ((float) (10000 * 2 * 64) / fs ) + 0.5);
- }
- }
-
- return((Int)( k1_min * pow( 64.0 / k1_min,(stop_freq)/13.0) + 0.5));
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "get_sbr_stopfreq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-const UChar sbr_stopfreq_tbl[6][13] =
-{
-
- { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59}, /* 48000 */
- { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59}, /* 44100 */
- { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61}, /* 32000 and 24000 */
- { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61}, /* 22050 */
- { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62} /* 16000 */
-
-};
-
-Int get_sbr_stopfreq(const Int32 fs,
- const Int32 stop_freq)
-{
-
- Int i;
-
- switch (fs)
- {
- case 48000:
- i = 0;
- break;
-
- case 32000:
- case 24000:
- i = 2;
- break;
-
- case 22050:
- i = 3;
- break;
-
- case 16000:
- i = 4;
- break;
-
- case 44100:
- default:
- i = 1;
- break;
- }
-
- return((Int)sbr_stopfreq_tbl[i][stop_freq]);
-
-}
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h b/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h
deleted file mode 100644
index 341a3d4..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_stopfreq.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_STOPFREQ_H
-#define GET_SBR_STOPFREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_sbr_stopfreq(const Int32 fs,
- const Int32 stop_freq);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sign_bits.h b/media/libstagefright/codecs/aacdec/get_sign_bits.h
deleted file mode 100644
index 445d2f2..0000000
--- a/media/libstagefright/codecs/aacdec/get_sign_bits.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_sign_bits.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Update comments for the structure
-
- Description: Change include file. Above description probably from another
- header file.
-
- Description: Fix pathname above
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the function get_sign_bits()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SIGN_BITS_H
-#define GET_SIGN_BITS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void get_sign_bits(
- Int q[],
- BITS *pInputStream,
- const Int q_len
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GET_SIGN_BITS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_tns.cpp b/media/libstagefright/codecs/aacdec/get_tns.cpp
deleted file mode 100644
index e0b021b..0000000
--- a/media/libstagefright/codecs/aacdec/get_tns.cpp
+++ /dev/null
@@ -1,573 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_tns.c
-
- Date: 10/25/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Brought code in-line with PV standards. Some minor
- optimizations (count-down for loops, etc.) were made.
-
- Description: Made cosmetic changes as suggested during review. Also,
- changed calculation of s_mask and n_mask from table-based to being
- calculated based on res_index. Also, the flag coef_res was changed
- from having a range of [3,4] to having a range of [0,1], which corresponds
- exactly with the true value that is passed via the bitstream.
-
- Description: Modified to use more efficient TNS memory structure.
-
- Description: Updated to reflect more efficient usage of memory by the TNS
- filters.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Moved pInputStream to be the 2nd parameter, for a slight
- optimization on some platforms.
-
- Description: Moved pSfbTop outside of the loops, since its value does
- not change.
-
- Description: Replace some instances of getbits to get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- FrameInfo *pFrameInfo
- Pointer to structure that holds information about each block.
- (long block flag,
- number of subblocks,
- scalefactor bands per subblock, etc.)
-
- BITS *pInputStream
- Pointer to a BITS structure that is
- passed on to function getbits to pull information from the bitstream.
-
- TNS_Frame_info *pTnsFrameInfo
- Pointer to filter data structure - to be populated by this function.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- TNS_frame_info *pTnsFrameInfo
-
- pTnsFrameInfo->n_filt = Number of tns filters to be applied to the data.
-
- pTnsFrameInfo->filt[]->order = The order of each individual TNS filter.
-
- pTnsFrameInfo->filt[]->coef_res = The resolution of the filter coefficients
-
- pTnsFrameInfo->filt[]->start_band = start of spectral band
-
- pTnsFrameInfo->filt[]->stop_band = end of spectral band
-
- pTnsFrameInfo->filt[]->coef[] = Each filter's coefficients are filled with
- data read from the input bitstream.
-
- pTnsFrameInfo->filt[]->direction = A flag is set for each TNS filter.
-
- If the direction flag (on the bitstream) = 0, then the filter
- is applied to the block of spectral data in normal (upward) fashion.
-
- If the direction flag (on the bitstream) = 1, then the filter
- is applied in a reverse (downward) fashion.
- (Starting with the last element in the block of data.)
-
- The value stored in filt[]->direction maps the values [0,1] to [1,-1] for
- a more intuitive storage of this flag's meaning.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the TNS filter information from the bitstream, and stores
- the filter order, LPC coefficients, and the number of TNS filters to
- be applied in the structure TNS_frame_info.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This code should match the ISO code in functionality, with the exception
- that coef_res has range of [0,1] (PV code) instead of [3,4] (ISO code)
-
- coef_res is only used by tns_decode_coef.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "get_tns.h"
-#include "s_mc_info.h"
-#include "s_frameinfo.h"
-#include "s_tnsfilt.h"
-#include "s_tns_frame_info.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_window_sequence.h"
-#include "e_progconfigconst.h"
-
-#include "tns_decode_coef.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#define SCALE_FACTOR_BAND_OFFSET(x) ( ((x) > 0) ? pSFB_top[(x)-1] : 0 )
-#define MINIMUM(x,y) ( ((x) < (y)) ? (x) : (y) )
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*
- * The entries in the ensuing tables provide the maximum permissable
- * number of scalefactor bands for each TNS filter. This value is effected
- * by the sampling rate, and window type.
- */
-
-const Int tns_max_bands_tbl_long_wndw[(1<<LEN_SAMP_IDX)] =
- {31, /* 96000 Hz */
- 31, /* 88200 Hz */
- 34, /* 64000 Hz */
- 40, /* 48000 Hz */
- 42, /* 44100 Hz */
- 51, /* 32000 Hz */
- 46, /* 24000 Hz */
- 46, /* 22050 Hz */
- 42, /* 16000 Hz */
- 42, /* 12000 Hz */
- 42, /* 11025 Hz */
- 39, /* 8000 Hz */
- 0,
- 0,
- 0,
- 0
- };
-
-const Int tns_max_bands_tbl_short_wndw[(1<<LEN_SAMP_IDX)] =
- {9, /* 96000 Hz */
- 9, /* 88200 Hz */
- 10, /* 64000 Hz */
- 14, /* 48000 Hz */
- 14, /* 44100 Hz */
- 14, /* 32000 Hz */
- 14, /* 24000 Hz */
- 14, /* 22050 Hz */
- 14, /* 16000 Hz */
- 14, /* 12000 Hz */
- 14, /* 11025 Hz */
- 14, /* 8000 Hz */
- 0,
- 0,
- 0,
- 0
- };
-
-/*
- * For completeness, here are the table entries for object types that make
- * use of PQF filter bank. We do not currently support this; these are
- * given here only to ease future implementation.
- *
- * const Int tns_max_bands_tbl_long_wndw_PQF[(1<<LEN_SAMP_IDX)] =
- * {28, ; 96000
- * 28, ; 88200
- * 27, ; 64000
- * 26, ; 48000
- * 26, ; 44100
- * 26, ; 32000
- * 29, ; 24000
- * 29, ; 22050
- * 23, ; 16000
- * 23, ; 12000
- * 23, ; 11025
- * 19, ; 8000
- * 0,
- * 0,
- * 0,
- * 0};
- *
- * const Int tns_max_bands_tbl_short_wndw_PQF[(1<<LEN_SAMP_IDX)] =
- * {7, ; 96000
- * 7, ; 88200
- * 7, ; 64000
- * 6, ; 48000
- * 6, ; 44100
- * 6, ; 32000
- * 7, ; 24000
- * 7, ; 22050
- * 8, ; 16000
- * 8, ; 12000
- * 8, ; 11025
- * 7, ; 8000
- * 0,
- * 0,
- * 0,
- * 0};
- */
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void get_tns(
- const Int max_bands,
- BITS * const pInputStream,
- const WINDOW_SEQUENCE wnd_seq,
- const FrameInfo * const pFrameInfo,
- const MC_Info * const pMC_Info,
- TNS_frame_info * const pTnsFrameInfo,
- Int32 scratchTnsDecCoefMem[])
-{
-
- const Int16 * const pSFB_top = pFrameInfo->win_sfb_top[0];
-
- Int f;
- Int t;
- Int win;
- UInt tempInt;
-
- Int num_filt_bits;
- Int num_order_bits;
- Int num_start_band_bits;
-
- Int top;
- Int res;
- Int res_index;
- Int compress;
-
- Int sfb_per_win;
-
- Int32 *pLpcCoef;
- Int32 *pStartLpcCoef;
- Int s_mask;
- Int n_mask;
-
- Int tns_bands;
- UInt max_order;
- Int coef_res;
-
-
- TNSfilt *pFilt;
-
- if (wnd_seq != EIGHT_SHORT_SEQUENCE)
- {
- num_filt_bits = 2;
- num_order_bits = 5;
- num_start_band_bits = 6;
-
- tns_bands = tns_max_bands_tbl_long_wndw[pMC_Info->sampling_rate_idx];
-
- /*
- * Definition from 14496-3:1999 doc. Our first encoder follows this rule,
- * later encoders don't
- */
-
- if (pMC_Info->sampling_rate_idx > 4) /* if (sampling_rate <= 32000 */
- {
- max_order = 20;
- }
- else
- {
- max_order = 12;
- }
- }
- else
- {
- num_filt_bits = 1;
- num_order_bits = 3;
- num_start_band_bits = 4;
-
- tns_bands = tns_max_bands_tbl_short_wndw[pMC_Info->sampling_rate_idx];
-
- max_order = 7;
- }
-
- /*
- * After this branch, tns_bands will be equal to the minimum of
- * the passed in variable, nbands, and the result from the
- * tns_max_bands_tbl
- */
-
- if (max_bands < tns_bands)
- {
- tns_bands = max_bands;
- }
-
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- win = 0;
-
- pLpcCoef = pTnsFrameInfo->lpc_coef;
-
- pFilt = pTnsFrameInfo->filt;
-
- do
- {
- tempInt = get9_n_lessbits(num_filt_bits,
- pInputStream);
-
- pTnsFrameInfo->n_filt[win] = tempInt;
-
- if (tempInt != 0)
- {
- /*
- * coef_res = [0, 1]
- * Switch between a resolution of 3 and 4 bits respectively
- *
- * if coef_res = 0, the coefficients have a range of
- *
- * -4 -3 -2 -1 0 1 2 3
- *
- * if coef_res = 1, the coefficients have a range of
- *
- * -8 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 4 5 6 7
- *
- * The arrays in ./src/tns_tab.c are completely based on
- * the value of coef_res.
- */
- res = get1bits(
- pInputStream);
-
- /* res is post-incremented for correct calculation of res_index */
- coef_res = res++;
-
- top = sfb_per_win;
-
- for (f = pTnsFrameInfo->n_filt[win]; f > 0; f--)
- {
- tempInt = MINIMUM(top, tns_bands);
-
- pFilt->stop_coef = SCALE_FACTOR_BAND_OFFSET(tempInt);
-
- pFilt->stop_band = tempInt;
-
- top -= get9_n_lessbits(num_start_band_bits,
- pInputStream);
-
- tempInt = MINIMUM(top, tns_bands);
-
- pFilt->start_coef = SCALE_FACTOR_BAND_OFFSET(tempInt);
-
- pFilt->start_band = tempInt;
-
- tempInt = get9_n_lessbits(num_order_bits,
- pInputStream);
-
- pFilt->order = tempInt;
-
- if (tempInt != 0)
- {
- if (tempInt > max_order)
- {
- pFilt->order = max_order;
- }
-
- /*
- * This maps the bitstream's [0,1] to
- * pFilt->direction = [1,-1]
- */
-
- tempInt = get1bits(pInputStream);
-
- pFilt->direction = (-(Int)tempInt) | 0x1;
-
- /*
- * compress = [0,1]
- * If compress is true, the MSB has
- * been omitted from transmission (Ref. 1)
- *
- * For coef_res = 0, this limits the range of
- * transmitted coefficients to...
- *
- * -2 -1 0 1
- *
- * For coef_res = 1, the coefficients have
- * a range of...
- *
- * -4 -3 -2 -1 0 1 2 3
- */
- compress = get1bits(pInputStream);
-
- /*
- * res has a range of [1,2]
- * compress has a range of [0,1]
- * So (res - compress) has range [0,2];
- */
- res_index = res - compress;
-
- s_mask = 2 << res_index;
-
- /*
- * If res_index = 0, grab 2 bits of data
- * If res_index = 1, grab 3 bits of data
- * If res_index = 2, grab 4 bits of data
- */
- res_index += 2;
-
- pStartLpcCoef = pLpcCoef;
-
- for (t = pFilt->order; t > 0; t--)
- {
- /*
- * These are the encoded coefficients, which will
- * later be decoded into LPC coefficients by
- * the function tns_decode_coef()
- */
- tempInt = get9_n_lessbits(res_index,
- pInputStream);
-
- n_mask = -((Int)tempInt & s_mask);
-
- /*
- * n_mask is used to sign_extend the
- * value, if it is negative.
- *
- */
- *(pLpcCoef++) = tempInt | n_mask;
- }
-
- /* Decode the TNS coefficients */
-
- tempInt = pFilt->stop_coef - pFilt->start_coef;
-
- if (tempInt > 0)
- {
- pFilt->q_lpc =
- tns_decode_coef(
- pFilt->order,
- coef_res,
- pStartLpcCoef,
- scratchTnsDecCoefMem);
- }
-
- } /* if (pTnsFilt->order != 0) */
-
- pFilt++;
-
- } /* END for (f=pTnsInfo->n_filt; f>0; f--, pTnsFilt++) */
-
- } /* if (pTnsInfo->n_filt != 0) */
-
- win++;
-
- }
- while (win < pFrameInfo->num_win);
-
- return;
-
-} /* get_tns */
diff --git a/media/libstagefright/codecs/aacdec/get_tns.h b/media/libstagefright/codecs/aacdec/get_tns.h
deleted file mode 100644
index 731484f..0000000
--- a/media/libstagefright/codecs/aacdec/get_tns.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_tns.h
-
- Author:
- Date: 03/08/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description: Modified to include updated function declaration, which reflects
- the combination of the get_tns and tns_setup_filter routines. Also, moved
- pInputStream to be the 2nd parameter, for a slight optimization.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function definition for get_tns.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_TNS_H
-#define GET_TNS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_mc_info.h"
-#include "s_tns_frame_info.h"
-#include "s_bits.h"
-#include "e_window_sequence.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- void get_tns(
- const Int max_bands,
- BITS * const pInputStream,
- const WINDOW_SEQUENCE wnd_seq,
- const FrameInfo * const pFrameInfo,
- const MC_Info * const pMC_Info,
- TNS_frame_info * const pTnsFrameInfo,
- Int32 scratchTnsDecCoefMem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GET_TNS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/getbits.h b/media/libstagefright/codecs/aacdec/getbits.h
deleted file mode 100644
index e854be5..0000000
--- a/media/libstagefright/codecs/aacdec/getbits.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getbits.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Update comments for the structure
-
- Description: Move structur to another file
-
- Who: Date: MM/DD/YYYY
- Description:
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the function getbits().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GETBITS_H
-#define GETBITS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#define INBUF_ARRAY_INDEX_SHIFT (3)
-#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT))
-#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1)
-
-#define MAX_GETBITS (25)
-
-#define CHECK_INPUT_BUFFER_LIMITS 1
-
- __inline UInt32 getbits(
- const UInt neededBits,
- BITS *pInputStream)
- {
- UInt32 returnValue = 0;
- UInt offset;
- UInt bitIndex;
- UChar *pElem; /* Needs to be same type as pInput->pBuffer */
-
- offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
- pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
- offset = pInputStream->inputBufferCurrentLength - offset;
- /* check if access to input buffer does not go beyond boundaries */
- if (offset > 3)
- {
- returnValue = (((UInt32) * (pElem)) << 24) |
- (((UInt32) * (pElem + 1)) << 16) |
- (((UInt32) * (pElem + 2)) << 8) |
- ((UInt32) * (pElem + 3));
- }
- else /* then access only available bytes */
- {
- /* Access to the bitstream beyond frame boundaries are not allowed,
- * Here, only what was available before the end of the frame will
- * be processed. Non-accessible bytes will be filled in with zeros.
- * Zero values guarantees that the data structures are filled in with values
- * that eventually will signal an error (like invalid parameters) or that allow
- * completion of the parsing routine.
- * Overrun is detected on file pvmp4audiodecodeframe.cpp.
- */
- switch (offset)
- {
- case 3:
- returnValue = (((UInt32) * (pElem + 2)) << 8);
- case 2:
- returnValue |= (((UInt32) * (pElem + 1)) << 16);
- case 1:
- returnValue |= (((UInt32) * (pElem)) << 24);
- default:
- break;
- }
- }
-
-
-#else
-
- returnValue = (((UInt32) * (pElem)) << 24) |
- (((UInt32) * (pElem + 1)) << 16) |
- (((UInt32) * (pElem + 2)) << 8) |
- ((UInt32) * (pElem + 3));
-#endif
-
- /* Remove extra high bits by shifting up */
- bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
- /* This line is faster way to mask off the high bits. */
- returnValue = returnValue << (bitIndex);
-
- /* Move the field down. */
- returnValue = returnValue >> (32 - neededBits);
-
- pInputStream->usedBits += neededBits;
-
- return (returnValue);
-
- }
-
-
-
- __inline UInt get1bits(
- BITS *pInputStream)
- {
- UInt returnValue;
- UInt offset;
- UInt bitIndex;
- UChar *pElem; /* Needs to be same type as pInput->pBuffer */
-
- offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
- pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
- returnValue = (offset < pInputStream->inputBufferCurrentLength) ? ((UInt) * (pElem)) : 0;
-#else
- returnValue = ((UInt32) * (pElem));
-#endif
-
-
- /* Remove extra high bits by shifting up */
- bitIndex = (UInt)((pInputStream->usedBits++) & INBUF_BIT_MODULO_MASK);
-
- /* This line is faster way to mask off the high bits. */
- returnValue = 0xFF & (returnValue << (bitIndex));
-
- /* Move the field down. */
-
- return ((UInt)(returnValue >> 7));
-
- }
-
-
-
- __inline UInt get9_n_lessbits(
- const UInt neededBits,
- BITS *pInputStream)
-
- {
- UInt returnValue;
- UInt offset;
- UInt bitIndex;
- UChar *pElem; /* Needs to be same type as pInput->pBuffer */
-
- offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
- pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
-
- offset = pInputStream->inputBufferCurrentLength - offset;
- /* check if access to input buffer does not go beyond boundaries */
- if (offset > 1)
- {
- returnValue = (((UInt32) * (pElem)) << 8) |
- ((UInt32) * (pElem + 1));
- }
- else /* then access only available bytes */
- {
- /* Access to the bitstream beyond frame boundaries are not allowed,
- * Here, only what was available before the end of the frame will
- * be processed. Non-accessible bytes will be filled in with zeros.
- * Zero values guarantees that the data structures are filled in with values
- * that eventually will signal an error (like invalid parameters) or that allow
- * completion of the parsing routine.
- * Overrun is detected on file pvmp4audiodecodeframe.cpp
- */
- switch (offset)
- {
- case 1:
- returnValue = (((UInt32) * (pElem)) << 8);
- break;
- default:
- returnValue = 0;
- break;
- }
- }
-
-
-#else
- returnValue = (((UInt32) * (pElem)) << 8) |
- ((UInt32) * (pElem + 1)) ;
-#endif
-
- /* Remove extra high bits by shifting up */
- bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
- pInputStream->usedBits += neededBits;
-
- /* This line is faster way to mask off the high bits. */
- returnValue = 0xFFFF & (returnValue << (bitIndex));
-
- /* Move the field down. */
-
- return (UInt)(returnValue >> (16 - neededBits));
-
- }
-
- __inline UInt32 get17_n_lessbits(
- const UInt neededBits,
- BITS *pInputStream)
- {
- UInt32 returnValue;
- UInt offset;
- UInt bitIndex;
- UChar *pElem; /* Needs to be same type as pInput->pBuffer */
-
- offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
- pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
- offset = pInputStream->inputBufferCurrentLength - offset;
- /* check if access to input buffer does not go beyond boundaries */
-
- if (offset > 2)
- {
- returnValue = (((UInt32) * (pElem)) << 16) |
- (((UInt32) * (pElem + 1)) << 8) |
- ((UInt32) * (pElem + 2));
- }
- else /* then access only available bytes */
- {
- /* Access to the bitstream beyond frame boundaries are not allowed,
- * Here, only what was available before the end of the frame will
- * be processed. Non-accessible bytes will be filled in with zeros.
- * Zero values guarantees that the data structures are filled in with values
- * that eventually will signal an error (like invalid parameters) or that allow
- * completion of the parsing routine.
- * Overrun is detected on file pvmp4audiodecodeframe.cpp
- */
- returnValue = 0;
- switch (offset)
- {
- case 2:
- returnValue = (((UInt32) * (pElem + 1)) << 8);
- case 1:
- returnValue |= (((UInt32) * (pElem)) << 16);
- default:
- break;
- }
- }
-
-#else
-
- returnValue = (((UInt32) * (pElem)) << 16) |
- (((UInt32) * (pElem + 1)) << 8) |
- ((UInt32) * (pElem + 2));
-#endif
-
- /* Remove extra high bits by shifting up */
- bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
- /* This line is faster way to mask off the high bits. */
- returnValue = 0xFFFFFF & (returnValue << (bitIndex));
-
- /* Move the field down. */
- returnValue = returnValue >> (24 - neededBits);
-
- pInputStream->usedBits += neededBits;
-
- return (returnValue);
-
- }
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GETBITS_H*/
-
-
diff --git a/media/libstagefright/codecs/aacdec/getfill.cpp b/media/libstagefright/codecs/aacdec/getfill.cpp
deleted file mode 100644
index 3c4fc4c..0000000
--- a/media/libstagefright/codecs/aacdec/getfill.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getfill.c
- Funtions: getfill
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: 1. Used template to re-organize function and filled out
- Input/Output and Function definition section.
- 2. Optimized code.
-
- Description: Made the following changes based on review comments.
- 1. Exchanging MODIFYING and RETURNING on line 87, 88.
- 2. Added MPEG reference.
- 3. Changed "fill" to "pass over", "bitstreams are" to
- "bitstream is" in FUNCTION DESCRIPTION section.
- 4. Fixed tabs.
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to structure BITS containing input stream
- information.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pInputStream->usedBits is updated to the newly calculated value.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function passes over fill bits in the raw data block to adjust the
- instantaneous bit rate when the bitstream is to be transmitted over a
- constant rate channel.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p15 (Table 4.4.11)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- CALL getbits(
- LEN_F_CNT,
- pInputStream);
- MODIFYING (pInputStream)
- RETURNING (cnt)
-
- IF ( cnt == (1<<LEN_F_CNT)-1 )
-
- CALL getbits(
- LEN_F_ESC,
- pInputStream);
- MODIFYING (pInputStream)
- RETURNING (esc_cnt)
-
- cnt += esc_cnt - 1;
-
- ENDIF
-
- pInputStream->usedBits += cnt * LEN_BYTE;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_rawbitstreamconst.h"
-#include "getfill.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void getfill(BITS *pInputStream)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- Int cnt;
- Int esc_cnt;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- cnt = get9_n_lessbits(
- LEN_F_CNT,
- pInputStream);
-
- if (cnt == (1 << LEN_F_CNT) - 1) /* if (cnt == 15) */
- {
- esc_cnt = get9_n_lessbits(
- LEN_F_ESC,
- pInputStream);
-
- cnt += esc_cnt - 1;
- }
-
- /*
- * The following codes are replaced by directly updating usedBits
- * in BITS structure. This will save one call for getbits().
- *
- * for (i=0; i<cnt; i++)
- * { getbits(LEN_BYTE, pInputStream); }
- */
-
- pInputStream->usedBits += cnt * LEN_BYTE;
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
-
-} /* getfill */
-
diff --git a/media/libstagefright/codecs/aacdec/getfill.h b/media/libstagefright/codecs/aacdec/getfill.h
deleted file mode 100644
index 3ba976a..0000000
--- a/media/libstagefright/codecs/aacdec/getfill.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getfill.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed "definition" to "declaration" on line 28 per
- review comments.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file contains prototype declaration for getfill function.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GETFILL_H
-#define GETFILL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void getfill(BITS *pInputStream);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/getgroup.cpp b/media/libstagefright/codecs/aacdec/getgroup.cpp
deleted file mode 100644
index 0f909cd..0000000
--- a/media/libstagefright/codecs/aacdec/getgroup.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getgroup.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: (1) Modified to bring code in-line with PV standards
- (2) Eliminated if(first_short) statement, move for-loop
- inside if statement
- (3) Modified UChar -> Int on data types of group
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less.
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to structure that holds input bitstream
- information. Type BITS
-
- group[] = array that holds the index of the first window in each
- group. Type Int
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- group contains the index of first windows in each group
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the window grouping information associated with an
- Individual Channel Stream (ICS). If the window sequence is
- EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a
- set of short windows form a group then they share scalefactors, intensity
- positions and PNS information. The first short window is always a new group
- so no grouping bit is transmitted. Subsequent short windows are in the same
- group if the associated grouping bit is 1. A new group is started if the
- associated grouping bit is 0.
- The pointer pGroup points to an array that stores the first window index
- of next group. For example, if the window grouping is:
-
- window index: | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
- grouping : |<- 0 ->| 1 |<- 2 ->|<- 3 ->|
-
- Then:
-
- group[] : | 2 | 3 | 6 | 8 |
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the contents of the array pointed to by pGroup
- with the first window indexes of groups starting from the second group.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4
- p16 (Table 4.4.6)
- p55 (Recovering ics_info)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF (pFrameInfo->coef_per_win[0] > SN2)
-
- *pGroup++ = 1;
- *pGroup = 1;
-
- ELSE
-
- FOR (win = 1; win < pFrameInfo->num_win; win++)
-
- IF (getbits(1,pInputStream) == 0)
-
- *pGroup++ = win;
-
- ENDIF
-
- ENDFOR (win)
-
- *pGroup = win;
-
- ENDIF(pFrameInfo)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define SEVEN 7
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void getgroup(
- Int group[],
- BITS *pInputStream)
-{
- Int win;
- Int *pGroup;
- UInt mask;
- UInt groupBits;
-
- pGroup = group;
-
- mask = 0x40;
-
- /* only short-window sequences are grouped!
- * first short window is always a new group,
- * start reading bitstream from the second
- * window, a new group is indicated by an
- * "0" bit in the input stream
- */
- groupBits =
- get9_n_lessbits(
- SEVEN,
- pInputStream);
-
- for (win = 1; win < NUM_SHORT_WINDOWS; win++)
- {
- if ((groupBits & mask) == 0)
- {
- *pGroup++ = win;
-
- } /* if (groupBits) */
-
- mask >>= 1;
-
- } /* for (win) */
-
- *pGroup = win;
-
-} /* getgroup */
diff --git a/media/libstagefright/codecs/aacdec/getics.cpp b/media/libstagefright/codecs/aacdec/getics.cpp
deleted file mode 100644
index 8d76744..0000000
--- a/media/libstagefright/codecs/aacdec/getics.cpp
+++ /dev/null
@@ -1,674 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getics.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables
-
- Description: Remove pass-in parameter global_gain, define it on stack.
-
- Description: (1) Modified to bring in-line with PV standards
- (2) Modified pass in parameters
- (3) Removed multiple returns, removed some if branch
- (4) Replace for loop with pv_memset
-
- Description: Remove prstflag, fix copyright.
-
- Description: Fix pseudo-code
-
- Description: Remove lpflag from get_ics_info
-
- Description: (1) Removed widx, therefore, pChVarsWin is eliminated from
- pass in parameter
-
- Description: merged the above changes from Michael and Wen
-
- Description: Removed initialization of "pTnsFrameInfo->num_subblocks" since
- this element was removed from that structure, as a part of
- rearchitecting the TNS routines to use memory more efficiently.
-
- Description:
- (1) Added #include of "e_HuffmanConst.h"
- Previously, this function was relying on another include file
- to include "e_HuffmanConst.h"
-
- (2) Updated the copyright header.
-
- (3) Added #include of <stdlib.h> for NULL macro definition.
-
- Description:
- (1) Removed the first parameter to getics.c This extra
- FrameInfo was not needed, the contents of winmap can be used.
- (2) Removed the memcpy of the data from winmap to the temporary
- FrameInfo.
-
- Description: Replace some instances of getbits to get1bits
- when only 1 bit is read.
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pInputStream = pointer to structure that holds input stream,
- Type BITS
-
- common_window = flag that indicates whether left and right channel
- share the same window sequence & shape, Type Int
-
- pVars = pointer to structure that holds decoder information
- Type tDec_Int_File
-
- pChVarsCh = pointer to structure that holds channel related
- decoding information, Type tDec_Int_Chan
-
- group[] = pointer to array that contains window grouping
- information of current frame, Type UChar
-
- pMax_sfb = pointer to variable that stores maximum active
- scalefactor bands of current frame, Type UChar
-
- pCodebookMap = pointer to array that holds the indexes of all
- Huffman codebooks used for current frame, ordered
- from section 0 to last section. Type UChar
-
- pTnsFrameInfo = pointer to structure that holds TNS information.
- Type TNS_frame_info
-
- pWinMap = array of pointers which points to structures that
- hold information of long and short window sequences
- Type FrameInfo
-
- pPulseInfo = pointer to structure that holds pulse data decoding
- information, Type Nec_info
-
- sect[] = array of structures that hold section codebook and
- section length in current frame, Type SectInfo
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- status = 0 if success
- 1 otherwise
-
- Pointers and Buffers Modified:
- pCodebookMap contents are replaced by the indexes of all the huffman
- codebooks used for current frame
-
- pWinMap For short windows, the contents of frame_sfb_top are
- modified by calc_gsfb_table, with the top coefficient
- index of each scalefactor band.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes individual channel stream by calling other Huffman
- decoding functions.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function replaces the contents of pCodebookMap with the decoded
- codebook indexes. By calling hufffac, it decodes scale factor data. Call
- huffspec_fxp to decode spectral coefficients of current frame.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p24 (Table 4.4.24)
- p54 (4.5.2.3.2)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pGroup = group;
-
- global_gain = CALL getbits(
- neededBits = LEN_SCL_PCM,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- ReTURNING(global_gain)
-
- IF (common_window == FALSE)
- THEN
- status = CALL get_ics_info(
- pVars->mc_info.audioObjectType,
- pInputStream,
- common_window,
- &pChVars->wnd,
- &pChVars->wnd_shape_this_bk,
- group,
- pMax_sfb,
- pWinMap,
- &pChVars->lt_status,
- NULL)
- MODIFYING(pInputStream,pChVars,group,max_sfb,lt_status)
- RETURNING(status)
- ENDIF
-
- memcpy(pFrameInfo, pWinMap[pChVars->wnd], sizeof(FrameInfo))
-
- IF (*pMax_sfb > 0)
- THEN
-
- i = 0;
- totSfb = 0;
-
- DO
-
- totSfb++;
-
- WHILE( *pGroup++ < pFrameInfo->num_win);
-
- totSfb *= pFrameInfo->sfb_per_win[0];
-
- nsect = CALL huffcb(
- sect,
- pInputStream,
- pFrameInfo->sectbits,
- totSfb,
- pFrameInfo->sfb_per_win[0],
- *pMax_sfb)
- MODIFYING(sect,pInputStream,sectbits)
- RETURNING(nsect)
-
- IF (nsect == 0)
- THEN
- status = 1
-
- ENDIF
-
- sectStart = 0;
- FOR (i = 0; i < nsect; i++)
-
- cb = sect[i].sect_cb;
- sectWidth = sect[i].sect_end - sectStart;
- sectStart += sectWidth;
-
- WHILE (sectWidth > 0)
-
- *pCodebookMap++ = cb
- sectWidth--
- ENDWHILE
-
- ENDFOR (i)
-
- ELSE
-
- memset(pCodebookMap,ZERO_HCB,MAXBANDS*sizeof(*pCodebookMap));
-
- ENDIF (*pMax_sfb)
-
- IF (pFrameInfo->islong == FALSE)
- THEN
- CALL calc_gsfb_table(
- pFramInfo = pFrameInfo,
- group[] = group)
- MODIFYING(pFrameInfo->frame_sfb_top)
- RETURNING(void)
- ENDIF
-
- IF (status == SUCCESS)
- THEN
- status = CALL hufffac(
- pFrameInfo,
- pInputStream,
- group,
- nsect,
- sect,
- global_gain,
- pChVars->factors,
- pVars->huffBookUsed)
- MODIFYING(pInputStream,factors)
- RETURNING(status)
-
- ENDIF (status)
-
- IF (status == SUCCESS)
- THEN
- present = CALL getbits(
- neededBits = LEN_PULSE_PRES,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(present)
-
- pPulseInfo->pulse_data_present = present;
-
- IF (present != FALSE)
- THEN
- IF (pFrameInfo->islong == 1)
- THEN
- CALL get_pulse_data(
- pPulseInfo = pPulseInfo,
- pInputStream = pInputStream)
- MODIFYING(pInputStream,pPulseInfo)
- RETURNING(void)
-
- ELSE
-
- status = 1;
-
- ENDIF (pFrameInfo)
- ENDIF (present)
-
- ENDIF (status)
-
- IF (status == SUCCESS)
- THEN
- present = CALL getbits(
- neededBits = LEN_TNS_PRES,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(present)
-
- pTnsFrameInfo->tns_data_present = present;
-
- IF (present != FALSE)
- THEN
- CALL get_tns(
- pFrameInfo = pFrameInfo,
- pTnsFrameInfo = pTnsFrameInfo,
- pInputStream = pInputStream)
- MODIFYING(pInputStream, pTnsFrameInfo)
- RETURNING(void)
- ELSE
-
- FOR (i = pTnsFrameInfo->n_subblocks - 1; i >= 0 ; i--)
-
- pTnsFrameInfo->info[i].n_filt = 0;
- ENDFOR
-
- ENDIF(present)
-
- ENDIF (status)
-
- IF (status == SUCCESS)
- THEN
- present = CALL getbits(
- neededBits = LEN_GAIN_PRES,
- pInputStream = pInputStream)
- MODIFYING(pInputStream)
- RETURNING(present)
-
- IF (present != FALSE)
- THEN
- status = 1;
- ENDIF
- ENDIF (status)
-
- IF (status == SUCCESS)
- THEN
- status = CALL huffspec_fxp(
- pFrameInfo,
- pInputStream,
- nsect,
- sect,
- pChVars->factors,
- pChVars->fxpCoef,
- pVars->quantSpec,
- pVars->tmp_spec,
- pWinMap[ONLY_LONG_WINDOW],
- pPulseInfo,
- pChVars->qFormat)
- MODIFYING(pInputStream,fxpCoef,quantSpec,tmp_spec,qFormat)
- RETURNING(status)
- ENDIF
-
- RETURN status
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_huffmanconst.h"
-#include "huffman.h"
-#include "aac_mem_funcs.h"
-#include "get_tns.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int getics(
- BITS *pInputStream,
- Int common_window,
- tDec_Int_File *pVars,
- tDec_Int_Chan *pChVars,
- Int group[],
- Int *pMax_sfb,
- Int *pCodebookMap,
- TNS_frame_info *pTnsFrameInfo,
- FrameInfo **pWinMap,
- PulseInfo *pPulseInfo,
- SectInfo sect[])
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- Int status = SUCCESS;
-
- Int nsect = 0;
- Int i;
- Int cb;
- Int sectWidth;
- Int sectStart;
- Int totSfb;
- Int *pGroup;
-
- FrameInfo *pFrameInfo;
-
- Int global_gain; /* originally passed in from huffdecode */
- Bool present;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- pGroup = group;
-
- /* read global gain from Input bitstream */
- global_gain =
- get9_n_lessbits(
- LEN_SCL_PCM,
- pInputStream);
-
- if (common_window == FALSE)
- {
- status = get_ics_info(
- pVars->mc_info.audioObjectType,
- pInputStream,
- common_window,
- &pChVars->wnd,
- &pChVars->wnd_shape_this_bk,
- group,
- pMax_sfb,
- pWinMap,
- &pChVars->pShareWfxpCoef->lt_status,
- NULL);
- }
-
- pFrameInfo = pWinMap[pChVars->wnd];
-
- /* First, calculate total number of scalefactor bands
- * for this grouping. Then, decode section data
- */
- if (*pMax_sfb > 0)
- {
-
- /* calculate total number of sfb */
- i = 0;
- totSfb = 0;
-
- do
- {
- totSfb++;
-
- }
- while (*pGroup++ < pFrameInfo->num_win);
-
- totSfb *= pFrameInfo->sfb_per_win[0];
-
- /* decode section data */
- nsect =
- huffcb(
- sect,
- pInputStream,
- pFrameInfo->sectbits,
- totSfb,
- pFrameInfo->sfb_per_win[0],
- *pMax_sfb);
-
- if (nsect == 0)
- {
- status = 1; /* decode section data error */
-
- }/* if (nsect) */
-
- /* generate "linear" description from section info
- * stored as codebook for each scalefactor band and group
- * when nsect == 0, for-loop does not execute
- */
- sectStart = 0;
- for (i = 0; i < nsect; i++)
- {
- cb = sect[i].sect_cb;
- sectWidth = sect[i].sect_end - sectStart;
- sectStart += sectWidth;
-
- while (sectWidth > 0)
- {
- *pCodebookMap++ = cb; /* cannot use memset for Int */
- sectWidth--;
- }
-
- } /* for (i) */
-
- }
- else
- {
- /* set all sections with ZERO_HCB */
- pv_memset(
- pCodebookMap,
- ZERO_HCB,
- MAXBANDS*sizeof(*pCodebookMap));
- /*
- for (i=MAXBANDS; i>0; i--)
- {
- *(pCodebookMap++) = ZERO_HCB;
- }
- */
-
- } /* if (*pMax_sfb) */
-
- /* calculate band offsets
- * (because of grouping and interleaving this cannot be
- * a constant: store it in pFrameInfo->frame_sfb_top)
- */
- if (pFrameInfo->islong == FALSE)
- {
- calc_gsfb_table(
- pFrameInfo,
- group);
- }
-
- /* decode scale factor data */
- if (status == SUCCESS)
- {
- status =
- hufffac(
- pFrameInfo,
- pInputStream,
- group,
- nsect,
- sect,
- global_gain,
- pChVars->pShareWfxpCoef->factors,
- pVars->scratch.huffbook_used);
-
- } /* if (status) */
-
- /* noiseless coding */
- if (status == SUCCESS)
- {
- present =
- get1bits(pInputStream);
-
- pPulseInfo->pulse_data_present = present;
-
- if (present != FALSE)
- {
- if (pFrameInfo->islong == 1)
- {
- status = get_pulse_data(
- pPulseInfo,
- pInputStream);
- }
- else
- {
- /* CommonExit(1,"Pulse data not allowed for short blocks"); */
- status = 1;
-
- } /* if (pFrameInfo) */
- } /* if (present) */
-
- } /* if (status) */
-
-
- /* decode tns data */
- if (status == SUCCESS)
- {
- present =
- get1bits(pInputStream);
-
- pTnsFrameInfo->tns_data_present = present;
-
- if (present != FALSE)
- {
- get_tns(
- pChVars->pShareWfxpCoef->max_sfb,
- pInputStream,
- pChVars->wnd,
- pFrameInfo,
- &pVars->mc_info,
- pTnsFrameInfo,
- pVars->scratch.tns_decode_coef);
- }
- else
- {
- for (i = pFrameInfo->num_win - 1; i >= 0 ; i--)
- {
- pTnsFrameInfo->n_filt[i] = 0;
- }
-
- } /* if(present) */
-
- } /* if (status) */
-
- /* gain control */
- if (status == SUCCESS)
- {
- present =
- get1bits(pInputStream);
-
- if (present != FALSE)
- {
- /* CommonExit(1, "Gain control not implemented"); */
- status = 1;
- }
- } /* if (status) */
-
- if (status == SUCCESS)
- {
- status =
- huffspec_fxp(
- pFrameInfo,
- pInputStream,
- nsect,
- sect,
- pChVars->pShareWfxpCoef->factors,
- pChVars->fxpCoef,
- pVars->share.a.quantSpec,
- pVars->scratch.tmp_spec,
- pWinMap[ONLY_LONG_WINDOW],
- pPulseInfo,
- pChVars->pShareWfxpCoef->qFormat);
- }
-
- /*----------------------------------------------------------------------------
- ; Return status
- ----------------------------------------------------------------------------*/
-
- return status;
-
-} /* getics */
diff --git a/media/libstagefright/codecs/aacdec/getmask.cpp b/media/libstagefright/codecs/aacdec/getmask.cpp
deleted file mode 100644
index 2fd34f1..0000000
--- a/media/libstagefright/codecs/aacdec/getmask.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getmask.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
- Replaced for-loop style memory initialization with memset()
-
- Description: (1) Modified to bring code in-line with PV standard
- (2) Removed multiple returns, Replaced multiple 'if's with
- switch
-
- Description: (1) Modified per review comments
- (2) increment pointer pMask after memset
-
- Description: Make the maximum number of bits requested from getbits
- become a constant.
-
- Description: Typecast 1 to UInt32 for bitmask to avoid masking on a 16-bit
- platform
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less.
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pFrameInfo = pointer to structure that holds information for current
- frame, Type FrameInfo
-
- pInputStream= pointer to structure that holds input stream information
- Type BITS
-
- pGroup = pointer to array that holds the stop window index for
- each group in current frame, Type Int
-
- max_sfb = number of active sfbs for each window, Type Int
-
- mask[] = array that holds the MS_mask information
- Type Int
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- mask_present = 0 (no Mid/Side mixed)
- 2 (Mid/Side mixed present for entire frame)
- 1 (Mid/Side mixed information read from bitstream)
- -1 (invalid mask_present read from bitstream)
-
- Pointers and Buffers Modified:
- pMask contents replaced by MS information of each scalefactor band
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the Mid/Side(MS) mask information from the input
- bitstream. If the mask_present field is equal to 2, the mask bits is set to
- 1 for the entire frame. If mask_present has a value of 0, the function
- returns 0, If mask_present is set to 1, the Mid/Side(MS) information is
- read from the input stream. When mask_present is 3, an error code (-1) is
- generated.
- The Mid/Side(MS) information is later used for mixing the left and right
- channel sounds. Each scalefactor band has its own MS information.
-
- (ISO comments: read a synthesis mask, read a synthesis mask uses
- EXTENDED_MS_MASK and grouped mask )
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall replace the contents of pMask with the MS information
- of each scalefactor band
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4
- p15 (Table 4.4.5 getmask)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- CALL getbits(LEN_MASK_PRES, pInputStream)
- MODIFYING (pInputStream)
- RETURNING (mask present information)
- mask_present = mask present information
-
- SWITCH (mask_present)
-
- CASE (0):
- BREAK;
-
- CASE (2):
- nwin = pFrameInfo->num_win;
- FOR(win = 0; win < nwin; win = *(pGroup++))
-
- FOR(sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--)
- *(pMask++) = 1;
- ENDFOR
-
- ENDFOR
-
- BREAK;
-
- CASE(1):
-
- nwin = pFrameInfo->num_win;
-
- nToDo = max_sfb;
-
- WHILE (nToDo > 0)
- nCall = nToDo;
-
- IF (nCall > MAX_GETBITS)
- THEN
- nCall = MAX_GETBITS;
- ENDIF
-
- tempMask =
- getbits(
- nCall,
- pInputStream);
-
- bitmask = 1 << (nCall - 1);
- FOR (sfb = nCall; sfb > 0; sfb--)
- *(pMask++) = (tempMask & bitmask) >> (sfb - 1);
- bitmask >>= 1;
- ENDFOR
-
- nToDo -= nCall;
- END WHILE
-
- pv_memset(
- pMask,
- 0,
- (pFrameInfo->sfb_per_win[win]-max_sfb)*sizeof(*pMask));
-
- ENDFOR (win)
-
- BREAK
-
- DEFAULT:
- mask_present = -1
-
- ENDSWITCH
-
- RETURN mask_present
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-#include "aac_mem_funcs.h"
-#include "e_maskstatus.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int getmask(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int group[],
- Int max_sfb,
- Int mask[])
-{
-
- Int win; /* window index */
- Int sfb;
- Int mask_present;
- Int *pMask;
- Int *pGroup;
- Int nwin;
- Int nCall;
- Int nToDo;
- UInt32 tempMask;
- UInt32 bitmask;
-
- pMask = mask;
- pGroup = group;
-
- mask_present =
- get9_n_lessbits(
- LEN_MASK_PRES,
- pInputStream);
-
- switch (mask_present)
- {
- case(MASK_NOT_PRESENT):
- /* special EXTENDED_MS_MASK cases */
- /* no ms at all */
- break;
-
- case(MASK_ALL_FRAME):
- /* MS for whole spectrum on, mask bits set to 1 */
- nwin = pFrameInfo->num_win;
- for (win = 0; win < nwin; win = *(pGroup++))
- {
- for (sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--)
- {
- *(pMask++) = 1; /* cannot use memset for Int type */
- }
-
- }
-
- break;
-
- case(MASK_FROM_BITSTREAM):
- /* MS_mask_present==1, get mask information*/
- nwin = pFrameInfo->num_win;
- for (win = 0; win < nwin; win = *(pGroup++))
- {
- /*
- * the following code is equivalent to
- *
- * for(sfb = max_sfb; sfb > 0; sfb--)
- * {
- * *(pMask++) =
- * getbits(
- * LEN_MASK,
- * pInputStream);
- * }
- *
- * in order to save the calls to getbits, the above
- * for-loop is broken into two parts
- */
-
- nToDo = max_sfb;
-
- while (nToDo > 0)
- {
- nCall = nToDo;
-
- if (nCall > MAX_GETBITS)
- {
- nCall = MAX_GETBITS;
- }
-
- tempMask =
- getbits(
- nCall,
- pInputStream);
-
- bitmask = (UInt32) 1 << (nCall - 1);
- for (sfb = nCall; sfb > 0; sfb--)
- {
- *(pMask++) = (Int)((tempMask & bitmask) >> (sfb - 1));
- bitmask >>= 1;
- }
-
- nToDo -= nCall;
- }
-
- /*
- * set remaining sfbs to zero
- * re-use nCall to save one variable on stack
- */
-
- nCall = pFrameInfo->sfb_per_win[win] - max_sfb;
-
-
- if (nCall >= 0)
- {
- pv_memset(pMask,
- 0,
- nCall*sizeof(*pMask));
-
- pMask += nCall;
- }
- else
- {
- mask_present = MASK_ERROR;
- break;
- }
-
-
- } /* for (win) */
-
- break;
-
- default:
- /* error */
- break;
-
- } /* switch (mask_present) */
-
- return mask_present;
-
-} /* getmask */
diff --git a/media/libstagefright/codecs/aacdec/hcbtables.h b/media/libstagefright/codecs/aacdec/hcbtables.h
deleted file mode 100644
index a35fed0..0000000
--- a/media/libstagefright/codecs/aacdec/hcbtables.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: hcbtables.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) Add declaration of binary tree tables
- (2) #if optimized Linear Search Huffman decoding
-
- Description: Modified per review comments
- (1) delete #if optimized Linear Search Huffman decoding
- (2) modified copyright header
-
- Description: (1) Add declaration different huffman tables
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Declare the structure array for Huffman Codebooks information.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef _HCBTABLES_H
-#define _HCBTABLES_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "s_hcb.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /* ISO: Hcb book[NSPECBOOKS + 2]; */
-
- extern const Hcb hcbbook_binary[13];
- extern const Int32 huff_tab1[88];
- extern const Int32 huff_tab2[90];
- extern const Int32 huff_tab3[151];
- extern const Int32 huff_tab4[119];
- extern const Int32 huff_tab5[110];
- extern const Int32 huff_tab6[113];
- extern const Int32 huff_tab7[107];
- extern const Int32 huff_tab8[90];
- extern const Int32 huff_tab9[204];
- extern const Int32 huff_tab10[186];
- extern const Int32 huff_tab11[301];
- extern const UInt32 huff_tab_scl[188];
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp b/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp
deleted file mode 100644
index d097af1..0000000
--- a/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp
+++ /dev/null
@@ -1,1938 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: hcbtables.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modifiy per review comments
- (1) delete the following comments:
- The LAV field has been deleted, since it is never used.
-
- Description: Remove old structure of huffman table and add new table structure.
-
- Description: Modified structure to avoid assigning addresses to constant
- tables. This solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers
- - Eliminated references to contant vector addresses in
- hcbbook_binary
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs: None
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This file defines the 12 packed Huffman Tables and a structure that reference
- to these tables.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- ISO/IEC 14496-3: 1999(E)
- Subpart 4 p78 (Table 4.6.1 and Table 4.6.2)
- p77 (pseudo code)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-#include "s_hcb.h"
-#include "hcbtables.h"
-
-/* This file store packed Huffman tables for binary tree search */
-
-/*
- * all tables are packed in the following way:
- * right pointer (7 bits) idx (9 bits)
- */
-
-
-const Hcb hcbbook_binary[13] =
-{
-
- { 0, -1, -1, -1, -1 }, /* ZERO_HCB */
- { 1, 4, 3, 1, 1 }, /* codebook 1 */
- { 2, 4, 3, 1, 1 }, /* codebook 2 */
- { 3, 4, 3, 0, 0 }, /* codebook 3 */
- { 4, 4, 3, 0, 0 }, /* codebook 4 */
- { 5, 2, 9, 4, 1 },
- { 6, 2, 9, 4, 1 },
- { 7, 2, 8, 0, 0 },
- { 8, 2, 8, 0, 0 },
- { 9, 2, 13, 0, 0 },
- {10, 2, 13, 0, 0 },
- {11, 2, 17, 0, 0 }, /* codebook 11 ESC book */
- {12, -1, -1, -1, -1 } /* scalefactor codebook */
-
-
-};
-
-
-/* New look-up table for huffman decoding
- Created by ordering the codeword in the table according to their
- normalized shifted binary value, i.e., all the codewords are left
- shifted to meet the maximum codelength. Example, max codelength is
- 10, the codeword with lenth 3 will left shift by 7.
- The binary values of after the shift are sorted.
- Then the sorted table is divided into several partition.
- At the VLC decoding period, input is read in at max codelenght.
- The partition is decided using if-else logic.
- Inside each partition, a look-up table is used to map the input value
- to a correct symbol. Table entries can appear to be repeated according
- to the humming distance between adjacent codewords.
-*/
-
-const Int32 huff_tab1[88] =
-{
- 0x430005,
- 0xd0005,
- 0x270005,
- 0x310005,
- 0x290005,
- 0x250005,
- 0x2b0005,
- 0x1f0005,
- 0x3a0007,
- 0x160007,
- 0x260007,
- 0x2e0007,
- 0x220007,
- 0x2a0007,
- 0x4c0007,
- 0x240007,
- 0x40007,
- 0x1c0007,
- 0x400007,
- 0x300007,
- 0x100007,
- 0x2c0007,
- 0x460007,
- 0x200007,
- 0x340007,
- 0x320007,
- 0xa0007,
- 0x440007,
- 0xc0007,
- 0x420007,
- 0xe0007,
- 0x1e0007,
- 0x490009,
- 0x130009,
- 0x3d0009,
- 0x330009,
- 0x2f0009,
- 0x230009,
- 0x210009,
- 0x370009,
- 0x410009,
- 0x2d0009,
- 0x190009,
- 0xf0009,
- 0x70009,
- 0x1d0009,
- 0x3b0009,
- 0x390009,
- 0x150009,
- 0x10009,
- 0x1b0009,
- 0x350009,
- 0x450009,
- 0x4d0009,
- 0x170009,
- 0x4f0009,
- 0x5000a,
- 0x5000a,
- 0x9000a,
- 0x9000a,
- 0x4b000a,
- 0x4b000a,
- 0x3f000a,
- 0x3f000a,
- 0xb000a,
- 0xb000a,
- 0x3000a,
- 0x3000a,
- 0x11000a,
- 0x11000a,
- 0x47000a,
- 0x47000a,
- 0x3c000b,
- 0x14000b,
- 0x18000b,
- 0x38000b,
- 0x50000b,
- 0x8000b,
- 0x48000b,
- 0x6000b,
- 0xb,
- 0x4a000b,
- 0x3e000b,
- 0x1a000b,
- 0x12000b,
- 0x2000b,
- 0x36000b,
- 0x4e000b
-};
-
-const Int32 huff_tab2[90] =
-{
- 0x430004,
- 0x430004,
- 0x430004,
- 0x430004,
- 0xd0005,
- 0xd0005,
- 0x290005,
- 0x290005,
- 0x250005,
- 0x250005,
- 0x270005,
- 0x270005,
- 0x1f0005,
- 0x1f0005,
- 0x2b0005,
- 0x2b0005,
- 0x310005,
- 0x310005,
- 0x220006,
- 0x160006,
- 0x2e0006,
- 0x2a0006,
- 0x300006,
- 0x260006,
- 0xc0006,
- 0x3a0006,
- 0x400006,
- 0x40006,
- 0x240006,
- 0x460006,
- 0x440006,
- 0x200006,
- 0x100006,
- 0x320006,
- 0x1c0006,
- 0xe0006,
- 0x1e0006,
- 0xa0006,
- 0x4c0006,
- 0x340006,
- 0x2c0006,
- 0x420006,
- 0x2f0007,
- 0x410007,
- 0x130007,
- 0x210007,
- 0x3d0007,
- 0x4b0007,
- 0x470007,
- 0x190007,
- 0x1d0007,
- 0x4f0007,
- 0xf0007,
- 0x10007,
- 0xb0007,
- 0x370007,
- 0x490007,
- 0x3b0008,
- 0x150008,
- 0x70008,
- 0x110008,
- 0x50008,
- 0x30008,
- 0x1b0008,
- 0x450008,
- 0x3f0008,
- 0x2d0008,
- 0x350008,
- 0x170008,
- 0x90008,
- 0x330008,
- 0x390008,
- 0x230008,
- 0x4d0008,
- 0x3c0008,
- 0x140008,
- 0x380009,
- 0x9,
- 0x180009,
- 0x1a0009,
- 0x500009,
- 0x60009,
- 0x3e0009,
- 0x120009,
- 0x80009,
- 0x480009,
- 0x360009,
- 0x20009,
- 0x4a0009,
- 0x4e0009
-};
-
-const Int32 huff_tab3[151] =
-{
- 0x1b0004,
- 0x1b0004,
- 0x1b0004,
- 0x1b0004,
- 0x10004,
- 0x10004,
- 0x10004,
- 0x10004,
- 0x90004,
- 0x90004,
- 0x90004,
- 0x90004,
- 0x30004,
- 0x30004,
- 0x30004,
- 0x30004,
- 0x240005,
- 0x240005,
- 0x40005,
- 0x40005,
- 0xc0006,
- 0xa0006,
- 0x1e0006,
- 0xd0006,
- 0x1c0006,
- 0x270006,
- 0x280007,
- 0x280007,
- 0x280007,
- 0x280007,
- 0x1f0007,
- 0x1f0007,
- 0x1f0007,
- 0x1f0007,
- 0x250007,
- 0x250007,
- 0x250007,
- 0x250007,
- 0x360008,
- 0x360008,
- 0x20008,
- 0x20008,
- 0x50008,
- 0x50008,
- 0x3f0008,
- 0x3f0008,
- 0x300008,
- 0x300008,
- 0x70009,
- 0x100009,
- 0x2d0009,
- 0xe0009,
- 0x420009,
- 0x60009,
- 0x150009,
- 0xf0009,
- 0x120009,
- 0xb0009,
- 0x390009,
- 0x310009,
- 0x160009,
- 0x2a0009,
- 0x2b0009,
- 0x2e000a,
- 0x21000a,
- 0x22000a,
- 0x13000a,
- 0x43000a,
- 0x29000a,
- 0x40000a,
- 0x20000a,
- 0x8000a,
- 0x11000a,
- 0x4b000a,
- 0x33000a,
- 0x1d000a,
- 0x37000a,
- 0x19000a,
- 0x48000b,
- 0x48000b,
- 0x34000b,
- 0x34000b,
- 0x26000b,
- 0x26000b,
- 0x3a000b,
- 0x3a000b,
- 0x2c000b,
- 0x2c000b,
- 0x4c000b,
- 0x4c000b,
- 0x18000b,
- 0x18000b,
- 0x17000b,
- 0x17000b,
- 0x23000c,
- 0x49000c,
- 0x45000c,
- 0x4e000c,
- 0x1a000c,
- 0x4f000c,
- 0x46000c,
- 0x32000c,
- 0x35000c,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x14000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x3c000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x2f000d,
- 0x3d000e,
- 0x3d000e,
- 0x3d000e,
- 0x3d000e,
- 0x44000e,
- 0x44000e,
- 0x44000e,
- 0x44000e,
- 0x41000e,
- 0x41000e,
- 0x41000e,
- 0x41000e,
- 0x50000f,
- 0x50000f,
- 0x4d000f,
- 0x4d000f,
- 0x47000f,
- 0x47000f,
- 0x3b000f,
- 0x3b000f,
- 0x38000f,
- 0x38000f,
- 0x4a0010,
- 0x3e0010
-};
-
-const Int32 huff_tab4[119] =
-{
- 0x280004,
- 0x280004,
- 0xd0004,
- 0xd0004,
- 0x250004,
- 0x250004,
- 0x270004,
- 0x270004,
- 0x1f0004,
- 0x1f0004,
- 0x1b0004,
- 0x1b0004,
- 0x240004,
- 0x240004,
- 0x4,
- 0x4,
- 0x40004,
- 0x40004,
- 0x1e0004,
- 0x1e0004,
- 0x1c0005,
- 0xc0005,
- 0x10005,
- 0xa0005,
- 0x30005,
- 0x90005,
- 0x430007,
- 0x430007,
- 0x2b0007,
- 0x2b0007,
- 0x310007,
- 0x310007,
- 0x290007,
- 0x290007,
- 0x420007,
- 0x420007,
- 0x400007,
- 0x400007,
- 0x300007,
- 0x300007,
- 0x3a0007,
- 0x3a0007,
- 0x100007,
- 0x100007,
- 0xe0008,
- 0x2a0008,
- 0x160008,
- 0x200008,
- 0x2e0008,
- 0x260008,
- 0x220008,
- 0x3f0008,
- 0x390008,
- 0x2d0008,
- 0x370008,
- 0xb0008,
- 0x150008,
- 0x50008,
- 0xf0008,
- 0x130008,
- 0x1d0008,
- 0x70008,
- 0x210008,
- 0x360008,
- 0x20008,
- 0x120009,
- 0x120009,
- 0x60009,
- 0x60009,
- 0x340009,
- 0x340009,
- 0x4c0009,
- 0x4c0009,
- 0x460009,
- 0x460009,
- 0x2c0009,
- 0x2c0009,
- 0x320009,
- 0x320009,
- 0x440009,
- 0x440009,
- 0x33000a,
- 0x4b000a,
- 0x45000a,
- 0x19000a,
- 0x11000a,
- 0x49000a,
- 0x17000a,
- 0x3d000a,
- 0x23000a,
- 0x4f000a,
- 0x2f000a,
- 0x3b000a,
- 0x41000a,
- 0x35000a,
- 0x47000b,
- 0x47000b,
- 0x4d000b,
- 0x4d000b,
- 0x18000b,
- 0x18000b,
- 0x48000b,
- 0x48000b,
- 0x8000b,
- 0x8000b,
- 0x3c000b,
- 0x3c000b,
- 0x14000b,
- 0x14000b,
- 0x38000b,
- 0x38000b,
- 0x50000b,
- 0x50000b,
- 0x1a000b,
- 0x1a000b,
- 0x4e000b,
- 0x4e000b,
- 0x4a000c,
- 0x3e000c
-};
-
-const Int32 huff_tab5[110] =
-{
- 0x1f0004,
- 0x1f0004,
- 0x310004,
- 0x310004,
- 0x290004,
- 0x290004,
- 0x270004,
- 0x270004,
- 0x300005,
- 0x200005,
- 0x1e0005,
- 0x320005,
- 0x160007,
- 0x160007,
- 0x2a0007,
- 0x2a0007,
- 0x3a0007,
- 0x3a0007,
- 0x260007,
- 0x260007,
- 0x150008,
- 0x3b0008,
- 0x1d0008,
- 0x330008,
- 0x170008,
- 0x390008,
- 0x210008,
- 0x2f0008,
- 0xd0008,
- 0x430008,
- 0x250008,
- 0x2b0008,
- 0xc0009,
- 0xc0009,
- 0x340009,
- 0x340009,
- 0x440009,
- 0x440009,
- 0x1c0009,
- 0x1c0009,
- 0xe0009,
- 0xe0009,
- 0x420009,
- 0x420009,
- 0x2e0009,
- 0x2e0009,
- 0x220009,
- 0x220009,
- 0x180009,
- 0x180009,
- 0x3c0009,
- 0x3c0009,
- 0x140009,
- 0x140009,
- 0x380009,
- 0x380009,
- 0xb000a,
- 0x41000a,
- 0x19000a,
- 0x37000a,
- 0x45000a,
- 0x3d000a,
- 0xf000a,
- 0x13000a,
- 0x24000a,
- 0x4000a,
- 0x4d000a,
- 0x4c000a,
- 0x3000b,
- 0x2c000b,
- 0x4b000b,
- 0x1b000b,
- 0x35000b,
- 0x23000b,
- 0x5000b,
- 0x2d000b,
- 0x40000b,
- 0xa000b,
- 0x10000b,
- 0x1a000b,
- 0x2000b,
- 0x4e000b,
- 0x36000b,
- 0x3e000b,
- 0x46000b,
- 0x6000b,
- 0x12000c,
- 0x12000c,
- 0x4a000c,
- 0x4a000c,
- 0x3f000c,
- 0x3f000c,
- 0x1000c,
- 0x1000c,
- 0x7000c,
- 0x7000c,
- 0x47000c,
- 0x47000c,
- 0x11000c,
- 0x11000c,
- 0x4f000c,
- 0x4f000c,
- 0x49000c,
- 0x49000c,
- 0x9000c,
- 0x9000c,
- 0x48000d,
- 0x8000d,
- 0x50000d,
- 0xd
-};
-const Int32 huff_tab6[113] =
-{
- 0x280004,
- 0x310004,
- 0x270004,
- 0x290004,
- 0x1f0004,
- 0x320004,
- 0x200004,
- 0x300004,
- 0x1e0004,
- 0x390006,
- 0x390006,
- 0x3b0006,
- 0x3b0006,
- 0x170006,
- 0x170006,
- 0x150006,
- 0x150006,
- 0x160006,
- 0x160006,
- 0x210006,
- 0x210006,
- 0x3a0006,
- 0x3a0006,
- 0x2f0006,
- 0x2f0006,
- 0x330006,
- 0x330006,
- 0x260006,
- 0x260006,
- 0x1d0006,
- 0x1d0006,
- 0x2a0006,
- 0x2a0006,
- 0x380006,
- 0x380006,
- 0x180006,
- 0x180006,
- 0x140006,
- 0x140006,
- 0x3c0006,
- 0x3c0006,
- 0xe0007,
- 0x440007,
- 0x420007,
- 0x220007,
- 0xc0007,
- 0x340007,
- 0x2e0007,
- 0x1c0007,
- 0x430007,
- 0xd0007,
- 0x250007,
- 0x2b0007,
- 0x450007,
- 0xb0008,
- 0xb0008,
- 0x190008,
- 0x190008,
- 0x3d0008,
- 0x3d0008,
- 0x410008,
- 0x410008,
- 0x370008,
- 0x370008,
- 0x130008,
- 0x130008,
- 0xf0008,
- 0xf0008,
- 0x460008,
- 0x460008,
- 0x400009,
- 0xa0009,
- 0x100009,
- 0x2d0009,
- 0x1b0009,
- 0x4d0009,
- 0x50009,
- 0x30009,
- 0x350009,
- 0x4b0009,
- 0x230009,
- 0x240009,
- 0x60009,
- 0x20009,
- 0x3e0009,
- 0x120009,
- 0x40009,
- 0x4e0009,
- 0x4a0009,
- 0x1a0009,
- 0x4c0009,
- 0x360009,
- 0x2c0009,
- 0x9000a,
- 0x9000a,
- 0x11000a,
- 0x11000a,
- 0x3f000a,
- 0x3f000a,
- 0x49000a,
- 0x49000a,
- 0x47000a,
- 0x47000a,
- 0x4f000a,
- 0x4f000a,
- 0x7000a,
- 0x7000a,
- 0x1000a,
- 0x1000a,
- 0x50000b,
- 0x8000b,
- 0xb,
- 0x48000b
-};
-
-const Int32 huff_tab7[107] =
-{
- 0x80003,
- 0x80003,
- 0x80003,
- 0x80003,
- 0x80003,
- 0x80003,
- 0x80003,
- 0x80003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x10003,
- 0x90004,
- 0x90004,
- 0x90004,
- 0x90004,
- 0x110006,
- 0xa0006,
- 0x100006,
- 0x20006,
- 0x190007,
- 0x190007,
- 0xb0007,
- 0xb0007,
- 0x120007,
- 0x120007,
- 0x180007,
- 0x180007,
- 0x30007,
- 0x30007,
- 0x130008,
- 0x1a0008,
- 0xc0008,
- 0x210008,
- 0xd0008,
- 0x290008,
- 0x1b0008,
- 0x140008,
- 0x40008,
- 0x200008,
- 0x220009,
- 0x220009,
- 0x150009,
- 0x150009,
- 0x2a0009,
- 0x2a0009,
- 0x50009,
- 0x50009,
- 0x310009,
- 0x310009,
- 0x280009,
- 0x280009,
- 0xe0009,
- 0xe0009,
- 0x230009,
- 0x230009,
- 0x1d0009,
- 0x1d0009,
- 0x1c0009,
- 0x1c0009,
- 0x2b0009,
- 0x2b0009,
- 0x160009,
- 0x160009,
- 0x320009,
- 0x320009,
- 0xf0009,
- 0xf0009,
- 0x1e000a,
- 0x6000a,
- 0x30000a,
- 0x24000a,
- 0x39000a,
- 0x25000a,
- 0x3a000a,
- 0x2c000a,
- 0x33000a,
- 0x17000a,
- 0x3b000a,
- 0x34000a,
- 0x2d000a,
- 0x26000a,
- 0x1f000a,
- 0x38000b,
- 0x38000b,
- 0x7000b,
- 0x7000b,
- 0x35000b,
- 0x35000b,
- 0x2e000b,
- 0x2e000b,
- 0x3c000b,
- 0x3c000b,
- 0x27000b,
- 0x27000b,
- 0x2f000b,
- 0x2f000b,
- 0x3d000b,
- 0x3d000b,
- 0x3e000c,
- 0x36000c,
- 0x37000c,
- 0x3f000c
-};
-const Int32 huff_tab8[90] =
-{
- 0x90003,
- 0x90003,
- 0x90003,
- 0x90003,
- 0x110004,
- 0x110004,
- 0x80004,
- 0x80004,
- 0xa0004,
- 0xa0004,
- 0x10004,
- 0x10004,
- 0x120004,
- 0x120004,
- 0x5,
- 0x100005,
- 0x20005,
- 0x190005,
- 0xb0005,
- 0x1a0005,
- 0x130005,
- 0x1b0006,
- 0x1b0006,
- 0x210006,
- 0x210006,
- 0xc0006,
- 0xc0006,
- 0x220006,
- 0x220006,
- 0x140006,
- 0x140006,
- 0x180006,
- 0x180006,
- 0x30006,
- 0x30006,
- 0x230006,
- 0x230006,
- 0x1c0006,
- 0x1c0006,
- 0x2a0006,
- 0x2a0006,
- 0x290007,
- 0x150007,
- 0xd0007,
- 0x2b0007,
- 0x1d0007,
- 0x240007,
- 0x2c0007,
- 0x40007,
- 0x250007,
- 0x200007,
- 0x160007,
- 0x320007,
- 0x310007,
- 0xe0007,
- 0x1e0008,
- 0x330008,
- 0x2d0008,
- 0x280008,
- 0x340008,
- 0x50008,
- 0x260008,
- 0x390008,
- 0x3a0008,
- 0x170008,
- 0x350008,
- 0x3b0008,
- 0xf0008,
- 0x2e0008,
- 0x1f0008,
- 0x360009,
- 0x360009,
- 0x3c0009,
- 0x3c0009,
- 0x300009,
- 0x300009,
- 0x270009,
- 0x270009,
- 0x60009,
- 0x60009,
- 0x3d0009,
- 0x3d0009,
- 0x3e0009,
- 0x3e0009,
- 0x370009,
- 0x370009,
- 0x2f000a,
- 0x38000a,
- 0x7000a,
- 0x3f000a
-};
-const Int32 huff_tab9[204] =
-{
- 0x1,
- 0x1,
- 0x1,
- 0x1,
- 0x1,
- 0x1,
- 0x1,
- 0x1,
- 0xd0003,
- 0xd0003,
- 0x10003,
- 0x10003,
- 0xe0004,
- 0x1b0006,
- 0x1b0006,
- 0xf0006,
- 0xf0006,
- 0x1a0006,
- 0x1a0006,
- 0x20006,
- 0x20006,
- 0x280007,
- 0x1c0007,
- 0x100007,
- 0x270008,
- 0x270008,
- 0x30008,
- 0x30008,
- 0x1d0008,
- 0x1d0008,
- 0x290008,
- 0x290008,
- 0x110008,
- 0x110008,
- 0x350008,
- 0x350008,
- 0x1e0008,
- 0x1e0008,
- 0x120008,
- 0x120008,
- 0x360009,
- 0x2a0009,
- 0x40009,
- 0x340009,
- 0x420009,
- 0x1f0009,
- 0x130009,
- 0x2b0009,
- 0x430009,
- 0x4f0009,
- 0x370009,
- 0x5000a,
- 0x20000a,
- 0x41000a,
- 0x14000a,
- 0x2c000a,
- 0x15000a,
- 0x69000a,
- 0x38000a,
- 0x44000a,
- 0x50000a,
- 0x5c000a,
- 0x6000a,
- 0x6a000a,
- 0x22000a,
- 0x2d000a,
- 0x21000a,
- 0x39000a,
- 0x76000a,
- 0x16000a,
- 0x5d000a,
- 0x4e000b,
- 0x45000b,
- 0x51000b,
- 0x6b000b,
- 0x7000b,
- 0x77000b,
- 0x2f000b,
- 0x3a000b,
- 0x2e000b,
- 0x8000b,
- 0x83000b,
- 0x52000b,
- 0x23000b,
- 0x46000b,
- 0x68000b,
- 0x5b000b,
- 0x5e000b,
- 0x84000b,
- 0x78000b,
- 0x6c000b,
- 0x17000b,
- 0x5f000b,
- 0x53000b,
- 0x47000b,
- 0x3c000b,
- 0x3b000b,
- 0x30000b,
- 0x90000b,
- 0x49000b,
- 0x75000b,
- 0x6d000b,
- 0x85000c,
- 0x24000c,
- 0x9000c,
- 0x91000c,
- 0x79000c,
- 0x54000c,
- 0x9d000c,
- 0x3d000c,
- 0x6e000c,
- 0x18000c,
- 0x7a000c,
- 0x86000c,
- 0x48000c,
- 0x60000c,
- 0x25000c,
- 0x19000c,
- 0x9e000c,
- 0x92000c,
- 0x31000c,
- 0x4a000c,
- 0x55000c,
- 0x6f000c,
- 0x93000c,
- 0xa000c,
- 0x61000c,
- 0x9f000c,
- 0x82000c,
- 0x87000c,
- 0x3e000c,
- 0x56000c,
- 0x26000c,
- 0x7b000c,
- 0x7c000c,
- 0x3f000c,
- 0x8f000c,
- 0x57000c,
- 0x32000c,
- 0x4b000c,
- 0x70000d,
- 0x63000d,
- 0xa1000d,
- 0x33000d,
- 0x94000d,
- 0x62000d,
- 0xa0000d,
- 0x95000d,
- 0x88000d,
- 0x40000d,
- 0x64000d,
- 0x4c000d,
- 0xb000d,
- 0xa2000d,
- 0x58000d,
- 0x9c000d,
- 0x89000d,
- 0x4d000d,
- 0x65000d,
- 0x7d000d,
- 0xc000d,
- 0x96000d,
- 0x71000d,
- 0x7e000d,
- 0x8a000d,
- 0x66000d,
- 0xa3000d,
- 0x59000d,
- 0x73000d,
- 0x97000d,
- 0x67000d,
- 0x5a000d,
- 0x72000e,
- 0x72000e,
- 0x8b000e,
- 0x8b000e,
- 0x74000e,
- 0x74000e,
- 0x7f000e,
- 0x7f000e,
- 0x80000e,
- 0x80000e,
- 0x81000e,
- 0x81000e,
- 0x8d000e,
- 0x8d000e,
- 0xa5000e,
- 0xa5000e,
- 0x8c000e,
- 0x8c000e,
- 0x98000e,
- 0x98000e,
- 0xa4000e,
- 0xa4000e,
- 0x99000e,
- 0x99000e,
- 0xa6000e,
- 0xa6000e,
- 0xa7000e,
- 0xa7000e,
- 0x8e000f,
- 0x9a000f,
- 0x9b000f,
- 0xa8000f
-};
-const Int32 huff_tab10[186] =
-{
- 0xe0004,
- 0xe0004,
- 0xe0004,
- 0xe0004,
- 0xf0004,
- 0xf0004,
- 0xf0004,
- 0xf0004,
- 0x1b0004,
- 0x1b0004,
- 0x1b0004,
- 0x1b0004,
- 0x1c0005,
- 0x1c0005,
- 0xd0005,
- 0xd0005,
- 0x10005,
- 0x10005,
- 0x100005,
- 0x100005,
- 0x290005,
- 0x290005,
- 0x280005,
- 0x280005,
- 0x1d0005,
- 0x1d0005,
- 0x2a0005,
- 0x2a0005,
- 0x1a0006,
- 0x20006,
- 0x1e0006,
- 0x360006,
- 0x110006,
- 0x350006,
- 0x6,
- 0x370006,
- 0x2b0006,
- 0x270006,
- 0x30006,
- 0x380006,
- 0x1f0006,
- 0x430006,
- 0x120007,
- 0x420007,
- 0x440007,
- 0x2c0007,
- 0x450007,
- 0x390007,
- 0x500007,
- 0x200007,
- 0x510007,
- 0x340007,
- 0x4f0007,
- 0x40007,
- 0x130007,
- 0x2d0007,
- 0x460007,
- 0x520007,
- 0x3a0007,
- 0x530008,
- 0x5d0008,
- 0x2e0008,
- 0x210008,
- 0x470008,
- 0x6a0008,
- 0x5e0008,
- 0x410008,
- 0x5c0008,
- 0x50008,
- 0x690008,
- 0x140008,
- 0x6b0008,
- 0x5f0008,
- 0x3b0008,
- 0x220008,
- 0x540008,
- 0x600008,
- 0x150008,
- 0x2f0008,
- 0x6c0008,
- 0x3c0008,
- 0x480008,
- 0x6d0008,
- 0x490008,
- 0x610009,
- 0x550009,
- 0x770009,
- 0x4e0009,
- 0x560009,
- 0x780009,
- 0x300009,
- 0x760009,
- 0x230009,
- 0x60009,
- 0x6e0009,
- 0x790009,
- 0x3d0009,
- 0x840009,
- 0x160009,
- 0x620009,
- 0x6f0009,
- 0x7a0009,
- 0x630009,
- 0x850009,
- 0x4a0009,
- 0x860009,
- 0x240009,
- 0x830009,
- 0x310009,
- 0x7b0009,
- 0x570009,
- 0x680009,
- 0x3e0009,
- 0x5b0009,
- 0x910009,
- 0x64000a,
- 0x92000a,
- 0x88000a,
- 0x17000a,
- 0x90000a,
- 0x7c000a,
- 0x7000a,
- 0x70000a,
- 0x87000a,
- 0x32000a,
- 0x4b000a,
- 0x71000a,
- 0x94000a,
- 0x8000a,
- 0x93000a,
- 0x25000a,
- 0x65000a,
- 0x58000a,
- 0x89000a,
- 0x3f000a,
- 0x18000a,
- 0x9e000a,
- 0x7d000a,
- 0x9f000a,
- 0x95000a,
- 0x4c000a,
- 0xa0000a,
- 0x96000a,
- 0xa1000a,
- 0x33000a,
- 0x59000a,
- 0x75000a,
- 0x8a000a,
- 0x82000a,
- 0x9d000a,
- 0x9000a,
- 0x40000a,
- 0x7e000a,
- 0xa2000a,
- 0x26000a,
- 0x72000a,
- 0x7f000b,
- 0x19000b,
- 0x97000b,
- 0xa3000b,
- 0x66000b,
- 0x4d000b,
- 0x5a000b,
- 0x8b000b,
- 0x73000b,
- 0xa4000b,
- 0xa000b,
- 0x67000b,
- 0x8f000b,
- 0x8c000b,
- 0x98000b,
- 0x99000b,
- 0xb000b,
- 0x9a000b,
- 0x80000b,
- 0x8d000b,
- 0x9c000b,
- 0x74000b,
- 0xa5000c,
- 0x8e000c,
- 0x81000c,
- 0x9b000c,
- 0xa7000c,
- 0xc000c,
- 0xa6000c,
- 0xa8000c
-};
-const Int32 huff_tab11[301] =
-{
- 0x4,
- 0x4,
- 0x4,
- 0x4,
- 0x120004,
- 0x120004,
- 0x120004,
- 0x120004,
- 0x1200005,
- 0x1200005,
- 0x110005,
- 0x110005,
- 0x10005,
- 0x10005,
- 0x230005,
- 0x230005,
- 0x130005,
- 0x130005,
- 0x240005,
- 0x240005,
- 0x140006,
- 0x340006,
- 0x350006,
- 0x220006,
- 0x250006,
- 0x20006,
- 0x360006,
- 0x450007,
- 0x150007,
- 0x460007,
- 0x260007,
- 0x470007,
- 0x370007,
- 0x330007,
- 0x30007,
- 0x560007,
- 0x570007,
- 0x270007,
- 0x480007,
- 0x160007,
- 0x580007,
- 0x380007,
- 0x590007,
- 0x490008,
- 0x680008,
- 0x280008,
- 0x670008,
- 0x690008,
- 0x390008,
- 0x170008,
- 0x540008,
- 0x430008,
- 0x1150008,
- 0x1130008,
- 0x1140008,
- 0x6a0008,
- 0x1160008,
- 0x440008,
- 0x4a0008,
- 0x40008,
- 0x320008,
- 0x5a0008,
- 0x650008,
- 0x1170008,
- 0x1120008,
- 0x1180008,
- 0x290008,
- 0x790008,
- 0x3a0008,
- 0x6b0008,
- 0x5b0008,
- 0x760008,
- 0x11a0008,
- 0x7a0008,
- 0x780008,
- 0x1190008,
- 0x870008,
- 0x210008,
- 0x180008,
- 0x4b0008,
- 0x11b0008,
- 0x7b0008,
- 0x11c0008,
- 0x980008,
- 0x1110008,
- 0x6c0008,
- 0xa90008,
- 0x2a0008,
- 0x5c0008,
- 0xba0008,
- 0x11d0008,
- 0x8b0008,
- 0x8a0008,
- 0x3b0008,
- 0x550008,
- 0x11e0008,
- 0xcb0008,
- 0x7c0008,
- 0x4c0008,
- 0x6d0008,
- 0x7d0008,
- 0x50008,
- 0x8c0009,
- 0x11f0009,
- 0xdc0009,
- 0x190009,
- 0x890009,
- 0xfe0009,
- 0x5d0009,
- 0xed0009,
- 0x3c0009,
- 0x8d0009,
- 0x7e0009,
- 0x2b0009,
- 0x8e0009,
- 0x9b0009,
- 0x9c0009,
- 0x10f0009,
- 0x4d0009,
- 0x6e0009,
- 0x660009,
- 0x9d0009,
- 0x5e0009,
- 0x8f0009,
- 0x7f0009,
- 0x1a0009,
- 0xad0009,
- 0x60009,
- 0xac0009,
- 0x9a0009,
- 0x9e0009,
- 0x4e0009,
- 0x2c0009,
- 0x9f0009,
- 0x3d0009,
- 0x6f0009,
- 0xae0009,
- 0x900009,
- 0xaf0009,
- 0xa00009,
- 0xbe0009,
- 0x1b0009,
- 0x770009,
- 0xb00009,
- 0x800009,
- 0x3e0009,
- 0x5f0009,
- 0xab0009,
- 0x4f0009,
- 0xbd0009,
- 0xdf0009,
- 0x700009,
- 0xe00009,
- 0x2d0009,
- 0x1100009,
- 0x600009,
- 0xc00009,
- 0xbf000a,
- 0xa1000a,
- 0x81000a,
- 0x91000a,
- 0x10000a,
- 0x51000a,
- 0x7000a,
- 0x40000a,
- 0xc1000a,
- 0xde000a,
- 0xe1000a,
- 0xcf000a,
- 0x2f000a,
- 0xe2000a,
- 0x92000a,
- 0x71000a,
- 0xb2000a,
- 0xb1000a,
- 0xf0000a,
- 0xd0000a,
- 0x1c000a,
- 0x50000a,
- 0xbc000a,
- 0x3f000a,
- 0x1e000a,
- 0xce000a,
- 0x82000a,
- 0x41000a,
- 0x61000a,
- 0x62000a,
- 0xf2000a,
- 0x52000a,
- 0xc2000a,
- 0xf1000a,
- 0xd1000a,
- 0xe3000a,
- 0xd2000a,
- 0x88000a,
- 0xc3000a,
- 0x2e000a,
- 0xa2000a,
- 0xf3000a,
- 0x73000a,
- 0xb4000a,
- 0x101000a,
- 0x93000a,
- 0xa3000a,
- 0xf4000a,
- 0xb3000a,
- 0x63000a,
- 0xc4000a,
- 0xef000a,
- 0x30000a,
- 0x72000a,
- 0x1d000a,
- 0xe5000a,
- 0x8000a,
- 0xe4000a,
- 0x83000a,
- 0xd3000a,
- 0x84000a,
- 0x102000a,
- 0xcd000a,
- 0x74000a,
- 0x31000a,
- 0x104000a,
- 0x103000a,
- 0x1f000a,
- 0xa4000a,
- 0x53000a,
- 0xf5000a,
- 0x95000a,
- 0xe6000a,
- 0x94000a,
- 0x64000a,
- 0x42000a,
- 0xb5000a,
- 0xc5000a,
- 0xd4000a,
- 0x105000a,
- 0x106000a,
- 0x96000a,
- 0x100000a,
- 0x85000a,
- 0x99000a,
- 0x9000a,
- 0xa6000a,
- 0xa5000a,
- 0xd5000a,
- 0xf6000a,
- 0xb7000a,
- 0xf7000a,
- 0xd6000a,
- 0x75000a,
- 0x86000a,
- 0xa7000b,
- 0x107000b,
- 0xc6000b,
- 0xc9000b,
- 0x20000b,
- 0xb6000b,
- 0xb8000b,
- 0xe8000b,
- 0xe7000b,
- 0xc8000b,
- 0xc7000b,
- 0x97000b,
- 0xf9000b,
- 0xe9000b,
- 0xd9000b,
- 0x108000b,
- 0xf8000b,
- 0xaa000b,
- 0xd7000b,
- 0xa8000b,
- 0xa000b,
- 0xd8000b,
- 0xbb000b,
- 0xda000b,
- 0xb9000b,
- 0xea000b,
- 0xd000b,
- 0xfa000b,
- 0x109000b,
- 0x10a000b,
- 0xca000b,
- 0xfb000b,
- 0xdd000b,
- 0xb000b,
- 0xeb000b,
- 0x10b000b,
- 0x10c000b,
- 0xdb000b,
- 0xee000b,
- 0xfc000b,
- 0xec000b,
- 0xcc000b,
- 0xfd000b,
- 0xe000c,
- 0xc000c,
- 0x10d000c,
- 0xff000c,
- 0xf000c,
- 0x10e000c
-};
-
-const UInt32 huff_tab_scl[188] =
-{
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3b0003,
- 0x3d0004,
- 0x3d0004,
- 0x3d0004,
- 0x3d0004,
- 0x3a0004,
- 0x3a0004,
- 0x3a0004,
- 0x3a0004,
- 0x3e0004,
- 0x3e0004,
- 0x3e0004,
- 0x3e0004,
- 0x390005,
- 0x390005,
- 0x3f0005,
- 0x3f0005,
- 0x380006,
- 0x400006,
- 0x370006,
- 0x410006,
- 0x420007,
- 0x420007,
- 0x420007,
- 0x420007,
- 0x360007,
- 0x360007,
- 0x360007,
- 0x360007,
- 0x430007,
- 0x430007,
- 0x430007,
- 0x430007,
- 0x350008,
- 0x350008,
- 0x440008,
- 0x440008,
- 0x340008,
- 0x340008,
- 0x450008,
- 0x450008,
- 0x330008,
- 0x330008,
- 0x460009,
- 0x320009,
- 0x310009,
- 0x470009,
- 0x48000a,
- 0x48000a,
- 0x48000a,
- 0x48000a,
- 0x30000a,
- 0x30000a,
- 0x30000a,
- 0x30000a,
- 0x49000a,
- 0x49000a,
- 0x49000a,
- 0x49000a,
- 0x2f000a,
- 0x2f000a,
- 0x2f000a,
- 0x2f000a,
- 0x4a000a,
- 0x4a000a,
- 0x4a000a,
- 0x4a000a,
- 0x2e000a,
- 0x2e000a,
- 0x2e000a,
- 0x2e000a,
- 0x4c000b,
- 0x4c000b,
- 0x4b000b,
- 0x4b000b,
- 0x4d000b,
- 0x4d000b,
- 0x4e000b,
- 0x4e000b,
- 0x2d000b,
- 0x2d000b,
- 0x2b000b,
- 0x2b000b,
- 0x2c000c,
- 0x4f000c,
- 0x2a000c,
- 0x29000c,
- 0x50000c,
- 0x28000c,
- 0x51000d,
- 0x51000d,
- 0x27000d,
- 0x27000d,
- 0x52000d,
- 0x52000d,
- 0x26000d,
- 0x26000d,
- 0x53000d,
- 0x53000d,
- 0x25000e,
- 0x23000e,
- 0x55000e,
- 0x21000e,
- 0x24000e,
- 0x22000e,
- 0x54000e,
- 0x20000e,
- 0x57000f,
- 0x57000f,
- 0x59000f,
- 0x59000f,
- 0x1e000f,
- 0x1e000f,
- 0x1f000f,
- 0x1f000f,
- 0x560010,
- 0x1d0010,
- 0x1a0010,
- 0x1b0010,
- 0x1c0010,
- 0x180010,
- 0x580010,
- 0x190011,
- 0x190011,
- 0x160011,
- 0x160011,
- 0x170011,
- 0x170011,
- 0x5a0012,
- 0x150012,
- 0x130012,
- 0x30012,
- 0x10012,
- 0x20012,
- 0x12,
- 0x620013,
- 0x630013,
- 0x640013,
- 0x650013,
- 0x660013,
- 0x750013,
- 0x610013,
- 0x5b0013,
- 0x5c0013,
- 0x5d0013,
- 0x5e0013,
- 0x5f0013,
- 0x600013,
- 0x680013,
- 0x6f0013,
- 0x700013,
- 0x710013,
- 0x720013,
- 0x730013,
- 0x740013,
- 0x6e0013,
- 0x690013,
- 0x6a0013,
- 0x6b0013,
- 0x6c0013,
- 0x6d0013,
- 0x760013,
- 0x60013,
- 0x80013,
- 0x90013,
- 0xa0013,
- 0x50013,
- 0x670013,
- 0x780013,
- 0x770013,
- 0x40013,
- 0x70013,
- 0xf0013,
- 0x100013,
- 0x120013,
- 0x140013,
- 0x110013,
- 0xb0013,
- 0xc0013,
- 0xe0013,
- 0xd0013
-};
diff --git a/media/libstagefright/codecs/aacdec/huffcb.cpp b/media/libstagefright/codecs/aacdec/huffcb.cpp
deleted file mode 100644
index 30f38fa..0000000
--- a/media/libstagefright/codecs/aacdec/huffcb.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/huffcb.c
- Funtions:
- huffcb
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Change variable names for clarity,
- change variables 'base', 'sect_len_inc', and 'esc_val' to
- UChar type.
-
- Description: Add "if ((pSect[-1] % sfb_per_win) > max_sfb)" statement to
- detect the error condition.
- add more white space.
-
- Description: eliminated "pSect[-1]%sfb_per_win" operation
-
- Description: eliminated "pSect[-1]%sfb_per_win" operation
-
- Description: (1) Pass in SectInfo pSect
- (2) put BITS *pInputStream as second parameter
-
- Description: Fix a failure for thrid party AAC encoding.
- The problem came when the total and the
- maximun number of active scale factor bands do not coincide.
- This is a rare situation but produces a problem when decoding
- encoders that tolerate this.
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- UChar *pSect = pointer to array that contains the interleaved
- information of huffman codebook index and section
- length. Array contains:
- [codebook index]
- [section boundary]
- [codebook index]
- [section boundary]
- ...
-
- Int sectbits = array that defines the number of bits
- used for expressing the escape value of
- section length
-
- Int tot_sfb = total number of sfb in one Frame
-
- Int sfb_per_win = number of sfb in each sub-block (window)
-
- UChar max_sfb = 1 + number of active sfbs - see reference (2) p56
-
- BITS *pInputStream = pointer to input stream
-
-
- Local Stores/Buffers/Pointers Needed:
-
- UChar base = number of sfb in already detected sections
-
- UChar sect_len_inc = section length increment in number of sfbs'
-
- UChar esc_val = escape value for section length
-
- Int bits = number of bits needed for expressing section length
-
-
- Global Stores/Buffers/Pointers Needed:
-
-
- Outputs:
-
- num_sect = total number of sections in one frame
-
-
- Pointers and Buffers Modified:
-
- UChar *pSect = pointer to array where huffman codebook index and
- section length are stored
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Background knowledge: 1024(960) coef's are separated into several sections,
- each section is encoded with one single Huffman codebook, and each section
- has a length of multiples of sfb.
-
- max_sfb <= sfb_per_win <= tot_sfb
- tot_sfb = total number of scalefactor bands in one frame (1024 coefs)
-
- This function reads the codebook index and section boundaries (expressed
- in number of sfb) from the input bitstream, store these information in
- *pSect, and return the number of sections been detected. Returns 0 if there
- is an error.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should fill the array *pSect with section Huffman codebook
- indexes and section boundaries
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3 1999(E)
- Subpart 4 p55 (Recovering section_data())
- p24-25 (Syntax of section_data())
-
- (3) M. Bosi, K. Brandenburg, etc., "ISO/IEC MPEG-2 Advanced Audio Coding,"
- J. Audio Eng. Soc., Vol.45, No.10, 1997 October
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- bits_needed_for_ESC = sectbits[0];
- ESC_value = (1<<bits_needed_for_ESC) - 1;
- num_of_section = 0;
-
-
- FOR (base = 0; base<total_sfb AND num_of_section<total_sfb)
- {
- *pSect++ = getbits(LEN_CB, pInputStream); (read huffman_codebook_num)
- sect_length_incr = getbits(bits_needed_for_ESC, pInputStream);
-
- WHILE (sect_length_incr == ESC_value AND base < total_sfb)
- {
- base += ESC_value;
- sect_length_incr = getbits(bits_needed_for_ESC, ebits);
- }
- ENDWHILE
-
- base += sect_length_incr;
- *pSect++ = base;
- num_of_section++;
-
- IF (num_of_sfb_for_this_group==max_sfb)
- {
- *pSect++ = 0; (use huffman codebook 0)
- base += sfb_per_win - max_sfb;
- *pSect++ = base;
- num_of_section++;
- }
- ENDIF
-
- IF (num_of_sfb_for_this_group > max_sfb)
- break;
- ENDIF
-
- }
- ENDFOR
-
- IF (base != total_sfb OR num_of_section>total_sfb)
- return 0;
- ENDIF
-
- return num_sect;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int huffcb(
- SectInfo *pSect,
- BITS *pInputStream,
- Int sectbits[],
- Int tot_sfb,
- Int sfb_per_win,
- Int max_sfb)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
-
- Int base; /* section boundary */
- Int sect_len_incr;
- Int esc_val; /* ESC of section length = 31(long), =7 (short) */
- Int bits; /* # of bits used to express esc_val */
- Int num_sect;
- Int active_sfb;
- Int group_base;
-
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- bits = sectbits[0]; /* 3 for SHORT_WIN, 5 for LONG_WIN */
- esc_val = (1 << bits) - 1; /* ESC_value for section length */
- num_sect = 0;
- base = 0;
- group_base = 0;
-
- /* read until the end of one frame */
- while ((base < tot_sfb) && (num_sect < tot_sfb))
- {
-
- pSect->sect_cb = get9_n_lessbits(
- LEN_CB,
- pInputStream); /* section codebook */
-
- sect_len_incr = get9_n_lessbits(
- bits,
- pInputStream); /* length_incr */
-
-
- /* read until non-ESC value, see p55 reference 2 */
- while ((sect_len_incr == esc_val) && (base < tot_sfb))
- {
- base += esc_val;
-
- sect_len_incr = get9_n_lessbits(
- bits,
- pInputStream);
- }
-
- base += sect_len_incr;
- pSect->sect_end = base; /* total # of sfb until current section */
- pSect++;
- num_sect++;
-
- /* active_sfb = base % sfb_per_win; */
- active_sfb = base - group_base;
-
- /*
- * insert a zero section for regions above max_sfb for each group
- * Make sure that active_sfb is also lesser than tot_sfb
- */
-
- if ((active_sfb == max_sfb) && (active_sfb < tot_sfb))
- {
- base += (sfb_per_win - max_sfb);
- pSect->sect_cb = 0; /* huffman codebook 0 */
- pSect->sect_end = base;
- num_sect++;
- pSect++;
- group_base = base;
- }
- else if (active_sfb > max_sfb)
- {
- /* within each group, the sections must delineate the sfb
- * from zero to max_sfb so that the 1st section within each
- * group starts at sfb0 and the last section ends at max_sfb
- * see p55 reference 2
- */
- break;
- }
-
- } /* while (base=0) */
-
-
- if (base != tot_sfb || num_sect > tot_sfb)
- {
- num_sect = 0; /* error */
- }
-
- return num_sect;
-
-} /* huffcb */
-
-
diff --git a/media/libstagefright/codecs/aacdec/huffdecode.cpp b/media/libstagefright/codecs/aacdec/huffdecode.cpp
deleted file mode 100644
index 890a6fb..0000000
--- a/media/libstagefright/codecs/aacdec/huffdecode.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: huffdecode.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Change variable types.
-
- Description: (1) Modified to bring in-line with PV standards.
- (2) Eliminated global_gain on stack,
- getics() has to define this parameter on its stack.
- (3) Eliminated multiple returns
- (4) Altered return logic of getics()
- (5) Convert Real coef -> Int32 coef
- (6) Move BITS *pInputStream to 2nd parameter of huffdecode.c
- and getics.c
- (7) Pass pFrameInfo per channel, because two channels can have
- different windows
-
- Description: (1) Eliminated function call to chn_config
- (2) Eliminate widx calculation
- (3) copy channel info from left to right when common_window
- is enabled
- (4) add error checking of getmask return value
-
- Description: Change default_position to current_program
-
- Description: Remove prstflag
-
- Description: Modify call to get_ics_info
-
- Description: Modified so getmask is NOT called if the status returned
- from get_ics_info indicates an error.
-
- Description:
- (1) Added include of "e_ElementId.h"
- Previously, this function was relying on another include file
- to include e_ElementId.h
-
- (2) Updated the copyright header.
-
- Description: Modified to include usage of the new "shared memory" structures
- defined in s_tDec_Int_File.h and s_tDec_Int_Chan.h
-
- Description:
- (1) Updated to reflect the fact that the temporary FrameInfo used by getics.c
- was moved into the region of memory shared with fxpCoef.
-
- Description:
- (1) Removed first parameter to getics. The temporary FrameInfo was
- unnecessary.
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Description: Relaxed tag verification. Some encoder do not match the tag
- to the channel ID (as the standard request to differentiate
- different channel), in our wireless work, with only mono
- or stereo channel, this become restrictive to some encoders
-
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- id_syn_ele = identification flag for channel syntactic element, Int
-
- pInputStream= pointer to input bitstream, BITS.
-
- pVars = pointer to structure that holds information for decoding,
- tDec_Int_File
-
- pChVars[] = pointer to structure that holds channel information,
- tDec_Int_Chan
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- status = 0 if success
- non-zero otherwise
-
- Pointers and Buffers Modified:
- pChVars->sect contents updated by newly decoded section information
- of current frame
-
- pChVars->factors contents updated by newly decoded scalefactors
-
- pChVars->ch_coef contents updated by newly decoded spectral coefficients
-
- PChVars->tns contents updated by newly decoded TNS information
-
- pVars->hasmask contents updated by newly decoded Mid/Side mask
- information
-
- pVars->pulseInfo contents updated by newly decoded pulse data information
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function offers a framework for decoding the data of the next 1024
- samples. It maps the channel configuration according to the id_syn_ele flag,
- configures the channel information, and calls getics to do huffman decoding
- The function returns 1 if there was an error
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should set up the channel configuration for huffman decoding
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p15 (single_channel_element, channel_pair_element)
- p15 (Table 4.4.5 getmask)
- p16 (Table 4.4.6 get_ics_info)
- p24 (Table 4.4.24 getics)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- tag = CALL getbits(LEN_TAG,pInputStream)
- MODIFYING(pInputStream)
- RETURNING(tag)
-
- common_window = 0;
-
- IF (id_syn_ele == ID_CPE)
- THEN
- common_window = CALL getbits(LEN_COM_WIN,pInputStream);
- MODIFYING(pInputStream)
- RETURNING(common_window)
- ENDIF
-
- pMcInfo = &pVars->mc_info;
-
- IF ( (pMcInfo->ch_info[0].cpe != id_syn_ele) OR
- (pMcInfo->ch_info[0].tag != tag) )
- THEN
- status = 1;
- ENDIF
-
-
- IF (status == SUCCESS)
- THEN
- IF (id_syn_ele == ID_SCE)
- THEN
-
- leftCh = 0;
- RIGHT = 0;
- pChVars[leftCh]->hasmask = 0;
- ELSEIF (id_syn_ele == ID_CPE)
-
- leftCh = 0;
- rightCh = 1;
-
- IF (common_window != FALSE)
- THEN
-
- CALL get_ics_info(
- audioObjectType = pVars->mc_info.audioObjectType,
- pInputStream = pInputStream,
- common_window = common_window,
- pWindowSequence = &pChVars[leftCh]->wnd,
- &pChVars[leftCh]->wnd_shape_this_bk,
- pChVars[leftCh]->group,
- &pChVars[leftCh]->max_sfb,
- pVars->winmap,
- &pChVars[leftCh]->lt_status,
- &pChVars[rightCh]->lt_status);
- MODIFYING(pInputStream, wnd, wnd_shape_this_bk,group,
- max_sfb, lt_status)
- RETURNING(status)
-
- IF (status == SUCCESS)
- THEN
-
- pChVars[rightCh]->wnd = pChVars[leftCh]->wnd;
- pChVars[rightCh]->wnd_shape_this_bk =
- pChVars[leftCh]->wnd_shape_this_bk;
- pChVars[rightCh]->max_sfb = pChVars[leftCh]->max_sfb;
- pv_memcpy(
- pChVars[rightCh]->group,
- pChVars[leftCh]->group,
- NSHORT*sizeof(pChVars[leftCh]->group[0]));
-
- hasmask = CALL getmask(
- pVars->winmap[pChVars[leftCh]->wnd],
- pInputStream,
- pChVars[leftCh]->group,
- pChVars[leftCh]->max_sfb,
- pChVars[leftCh]->mask);
- MODIFYING(pInputStream, mask)
- RETURNING(hasmask)
-
- IF (hasmask == MASK_ERROR)
- THEN
- status = 1;
- ENDIF
- pChVars[leftCh]->hasmask = hasmask;
- pChVars[rightCh]->hasmask = hasmask;
-
- ENDIF
-
- ELSE
-
- pChVars[leftCh]->hasmask = 0;
- pChVars[rightCh]->hasmask = 0;
- ENDIF(common_window)
-
- ENDIF(id_syn_ele)
-
- ENDIF (status)
-
- ch = leftCh;
-
- WHILE((ch <= rightCh) AND (status == SUCCESS))
-
- status = CALL getics(
- pInputStream,
- common_window,
- pVars,
- pChVars[ch],
- pChVars[ch]->group,
- &pChVars[ch]->max_sfb,
- pChVars[ch]->cb_map,
- &pChVars[ch]->tns,
- pVars->winmap,
- &pVars->pulseInfo,
- pChVars[ch]->sect);
- MODIFYING(pInputStream,pVarsp,ChVars[ch],group,
- max_sfb,tns,pulseInfo,sect)
- RETURNING(status)
-
- ch++;
-
- ENDWHILE
-
- RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "huffman.h"
-#include "e_maskstatus.h"
-#include "e_elementid.h"
-#include "get_ics_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT (0)
-#define RIGHT (1)
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int huffdecode(
- Int id_syn_ele,
- BITS *pInputStream,
- tDec_Int_File *pVars,
- tDec_Int_Chan *pChVars[])
-
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- Int ch;
- Int common_window;
- Int hasmask;
- Int status = SUCCESS;
- Int num_channels = 0;
- MC_Info *pMcInfo;
-
- per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */
- per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- get9_n_lessbits(
- LEN_TAG,
- pInputStream);
-
- /* suppose an un-supported id_syn_ele will never be passed */
-
- common_window = 0;
-
- if (id_syn_ele == ID_CPE)
- {
- common_window =
- get1bits(pInputStream);
- }
-
- pMcInfo = &pVars->mc_info;
-
- /*
- * check if provided info (num of channels) on audio config,
- * matches read bitstream data, if not, allow update only once.
- * In almost all cases it should match.
- */
- if ((pMcInfo->ch_info[0].cpe != id_syn_ele))
- {
- if (pVars->mc_info.implicit_channeling) /* check done only once */
- {
- pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /* collect info from bitstream
- * implicit_channeling flag is locked
- * after 1st frame, to avoid toggling
- * parameter in the middle of the clip
- */
- pMcInfo->nch = (id_syn_ele & 1) + 1; /* update number of channels */
- }
- else
- {
- status = 1; /* ERROR break if syntax error persist */
- }
- }
-
- if (status == SUCCESS)
- {
- if (id_syn_ele == ID_SCE)
- {
-
- num_channels = 1;
- pVars->hasmask = 0;
- }
- else if (id_syn_ele == ID_CPE)
- {
- pChLeftShare = pChVars[LEFT]->pShareWfxpCoef;
- pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
- num_channels = 2;
-
- if (common_window != FALSE)
- {
-
- status = get_ics_info(
- (tMP4AudioObjectType) pVars->mc_info.audioObjectType,
- pInputStream,
- (Bool)common_window,
- (WINDOW_SEQUENCE *) & pChVars[LEFT]->wnd,
- (WINDOW_SHAPE *) & pChVars[LEFT]->wnd_shape_this_bk,
- pChLeftShare->group,
- (Int *) & pChLeftShare->max_sfb,
- pVars->winmap,
- (LT_PRED_STATUS *) & pChLeftShare->lt_status,
- (LT_PRED_STATUS *) & pChRightShare->lt_status);
-
- if (status == SUCCESS)
- {
- /* copy left channel info to right channel */
- pChVars[RIGHT]->wnd = pChVars[LEFT]->wnd;
- pChVars[RIGHT]->wnd_shape_this_bk =
- pChVars[LEFT]->wnd_shape_this_bk;
- pChRightShare->max_sfb = pChLeftShare->max_sfb;
- pv_memcpy(
- pChRightShare->group,
- pChLeftShare->group,
- NSHORT*sizeof(pChLeftShare->group[0]));
-
- hasmask = getmask(
- pVars->winmap[pChVars[LEFT]->wnd],
- pInputStream,
- pChLeftShare->group,
- pChLeftShare->max_sfb,
- pVars->mask);
-
- if (hasmask == MASK_ERROR)
- {
- status = 1; /* ERROR code */
- }
- pVars->hasmask = hasmask;
-
- } /* if (status == 0) */
- }
- else
- {
- pVars->hasmask = 0;
- } /* if (common_window) */
-
- } /* if (id_syn_ele) */
-
- } /* if (status) */
-
- ch = 0;
- while ((ch < num_channels) && (status == SUCCESS))
- {
- pChLeftShare = pChVars[ch]->pShareWfxpCoef;
-
- status = getics(
- pInputStream,
- common_window,
- pVars,
- pChVars[ch],
- pChLeftShare->group,
- &pChLeftShare->max_sfb,
- pChLeftShare->cb_map,
- &pChLeftShare->tns,
- pVars->winmap,
- &pVars->share.a.pulseInfo,
- pVars->share.a.sect);
-
- ch++;
-
- } /* while (ch) */
-
- /*----------------------------------------------------------------------------
- ; Return status
- ----------------------------------------------------------------------------*/
-
- return status;
-
-} /* huffdecode */
-
diff --git a/media/libstagefright/codecs/aacdec/hufffac.cpp b/media/libstagefright/codecs/aacdec/hufffac.cpp
deleted file mode 100644
index e5a9c59..0000000
--- a/media/libstagefright/codecs/aacdec/hufffac.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/hufffac.c
- Funtions:
- hufffac
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: (1) Modified with new templates,
- (2) Modified variable names for clarity
- (3) adjusted variables of "for loop"
- (4) eliminated multiple returns, use return valid
-
- Description: (1) Change return logic: 0 if success, 1 if error
- (2) Define SectInfo structure to store section codebook index
- and section boundary
- (3) Substitute "switch" with "if- else if"
- (4) move BITS *pInputStream to second pass-in parameter
- (5) pass in huffBookUsed[] to save stack size
-
- Description: (1) Remove pass in parameter Hcb pBook
-
- Description: Use binary tree search in decode_huff_cw_binary
-
- Description: Use decode_huff_scl function.
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- *pFrameInfo = pointer to structure that holds information
- of each Frame. type FrameInfo
-
- *pInputStream = pointer to input bitstream. type BITS
-
- *pGroup = pointer to array that contains the index of the first
- window in each group, type UChar
-
- nsect = number of sections to be decoded. type Int
-
- *pSect = pointer to structure array that contains the huffman
- codebook index and section boundary for each section,
- type SectInfo
-
- global_gain = initial value for "DPCM encoded" scalefactors and noise
- energy, type Int
-
- *pFactors = pointer to array that stores the decoded scalefactors,
- intensity position or noise energy, type Int
-
- huffBookUsed = array that will hold the huffman codebook index for
- each sfb, type Int
-
- *pBook = pointer to structure that contains the huffman codebook
- information, such as dimension, Largest Absolute Value
- (LAV) of each huffman codebook, etc. type Hcb
-
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- 0 if success
- 1 if error
-
- Pointers and Buffers Modified:
-
- Int *pFactors contains the newly decoded scalefactors and/or
- intensity position and/or noise energy level
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function first reads the Huffman codebook index of all sections within
- one Frame. Then, depending on the huffman codebook index of each section,
- the function decodes the scalefactors, and/or intensity positions
- (INTENSITY_HCB, INTENSITY_HCB2), and/or noise energy (NOISE_HCB)
- for every scalefactor band in each section.
- The function returns 0 upon successful decoding, returns 1 if error.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the content of the array pFactors with the
- decoded scalefactors and/or intensity positions and/or noise energy
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p72-73 (scalefactors)
- p76 (decoding)
- p78 (Table 4.6.1, Table 4.6.2)
- p93-94 (INTENSITY_HCB)
- p123 (NOISE_HCB)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = SUCCESS;
-
- CALL pv_memset(pHuffBookUsed, ZERO_HCB, MAXBANDS*sizeof(*pHuffBookUsed));
-
- CALL pv_memset(pFactors, ZERO_HCB, MAXBANDS*sizeof(*pFactors));
-
- sect_start = 0;
-
- FOR(sect_idx = nsect; sect_idx > 0; sect_idx--)
- {
- sect_cb = pSect->sect_cb;
- sect_end = pSect->sect_end;
- pSect++;
-
- CALL pv_memset(
- &pHuffBookUsed[sect_start],
- sect_cb,
- (sect_end - sect_start));
-
- }
- ENDFOR
-
- fac = global_gain;
- is_pos = 0;
- noise_nrg = global_gain - NOISE_OFFSET;
-
- pTable = pBook[BOOKSCL].pTable;
- group_win = 0;
- group_end = 0;
-
- WHILE((group_end < pFrameInfo->num_win)&&(status == SUCCESS))
- {
- nsfb_win = pFrameInfo->sfb_per_win[group_end];
- group_end = *pGroup++;
-
- FOR(sfb = 0; sfb < nsfb_win; sfb++)
- {
- IF ((pHuffBookUsed[sfb] > 0)&&(pHuffBookUsed[sfb] < BOOKSCL))
- {
- cw_index = CALL decode_huff_cw_binary(pTable, pInputStream);
-
- fac += cw_index - MIDFAC;
-
- IF((fac >= 2*TEXP) || (fac < 0))
- {
- status = 1;
- }
- ELSE
- {
- pFactors[sfb] = fac;
- }
- ENDIF (fac)
-
- }
- ELSE IF (pHuffBookUsed[sfb] == ZERO_HCB)
- {
- do nothing;
- }
-
- ELSE IF ((pHuffBookUsed[sfb] == INTENSITY_HCB)||
- (pHuffBookUsed[sfb] == INTENSITY_HCB2))
- {
- cw_index = CALL decode_huff_cw_binary(pTable, pInputStream);
-
- is_pos += cw_index - MIDFAC;
- pFactors[sfb] = is_pos;
- }
-
- ELSE IF (pHuffBookUsed[sfb] == NOISE_HCB)
- {
- IF (noise_pcm_flag == TRUE)
- {
- noise_pcm_flag = FALSE;
- dpcm_noise_nrg = CALL getbits(
- NOISE_PCM_BITS,
- pInputStream);
-
- dpcm_noise_nrg -= NOISE_PCM_OFFSET;
- }
- ELSE
- {
- dpcm_noise_nrg = CALL decode_huff_cw_binary(
- pTable,
- pInputStream);
-
- dpcm_noise_nrg -= MIDFAC;
- }
- ENDIF (noise_pcm_flag)
-
- noise_nrg += dpcm_noise_nrg;
- pFactors[sfb] = noise_nrg;
- }
-
- ELSE IF (pHuffBookUsed[sfb] == BOOKSCL)
- {
- status = 1;
- }
- ENDIF (pHuffBookUsed[sfb])
-
- }
- ENDFOR (sfb)
-
- IF (pFrameInfo->islong == FALSE)
- {
-
- FOR(group_win++; group_win < group_end; group_win++)
- {
- FOR (sfb=0; sfb < nsfb_win; sfb++)
- {
- pFactors[sfb + nsfb_win] = pFactors[sfb];
- }
- ENDFOR
-
- pFactors += nsfb_win;
- }
- ENDFOR
-
- }
- ENDIF (pFrameInfo)
-
- pHuffBookUsed += nsfb_win;
- pFactors += nsfb_win;
-
- }
- ENDWHILE (group_end)
-
- return status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h" /* pv_memset */
-#include "s_frameinfo.h"
-#include "s_bits.h"
-#include "s_sectinfo.h"
-#include "s_huffman.h"
-#include "ibstream.h"
-
-#include "hcbtables.h"
-#include "e_huffmanconst.h"
-#include "e_infoinitconst.h"
-#include "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int hufffac(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int *pGroup, /* may be changed to Int */
- Int nsect,
- SectInfo *pSect, /* may be changed to Int */
- Int global_gain,
- Int *pFactors,
- Int huffBookUsed[])
-{
- Int sect_idx;
- Int group_end; /* index of 1st window in next group */
- Int group_win; /* window index within group */
- Int cw_index; /* huff codeword index */
- Int nsfb_win; /* # of scfbands per window */
- Int sfb; /* scalefactor band index */
- Int sect_cb; /* huff codebook # for each section */
- Int fac; /* decoded scf */
- Int is_pos; /* intensity stereo position */
- Int noise_pcm_flag = TRUE; /* first PNS sfb */
- Int dpcm_noise_nrg; /* dpcm noise energy */
- Int noise_nrg; /* noise energy */
- Int status = SUCCESS; /* status of decoding */
- Int *pHuffBookUsed = &huffBookUsed[0];
-
-
- pv_memset(pFactors,
- ZERO_HCB,
- MAXBANDS*sizeof(*pFactors));
-
-
- if (nsect)
- {
- /* read section length and codebook */
-
- if (nsect == 1) /* long window */
- {
- sect_cb = pSect->sect_cb; /* codebook for this section */
-
- /* all sfbs in one section share the same codebook */
-
- for (sfb = pSect->sect_end >> 2; sfb != 0; sfb--)
- {
- *(pHuffBookUsed++) = sect_cb;
- *(pHuffBookUsed++) = sect_cb;
- *(pHuffBookUsed++) = sect_cb;
- *(pHuffBookUsed++) = sect_cb;
- }
- for (sfb = pSect->sect_end & 3; sfb != 0; sfb--)
- {
- *(pHuffBookUsed++) = sect_cb;
- }
-
- }
- else /* short */
- {
- Int sect_start = 0; /* start index of sfb for each section */
- for (sect_idx = nsect; sect_idx > 0; sect_idx--)
- {
- sect_cb = pSect->sect_cb; /* codebook for this section */
-
- /* all sfbs in one section share the same codebook */
- for (sfb = sect_start; sfb < pSect->sect_end; sfb++)
- {
- pHuffBookUsed[sfb] = sect_cb;
- }
-
- pSect++;
- sect_start = sfb;
-
- } /* for (sect_idx) */
- }
- }
- else
- {
- /* clear array for the case of max_sfb == 0 */
- pv_memset(pHuffBookUsed,
- ZERO_HCB,
- MAXBANDS*sizeof(*pHuffBookUsed));
- }
-
- pHuffBookUsed = &huffBookUsed[0];
-
- /* scale factors and noise energy are dpcm relative to global gain
- * intensity positions are dpcm relative to zero
- */
- fac = global_gain;
- is_pos = 0;
- noise_nrg = global_gain - NOISE_OFFSET;
-
- /* get scale factors,
- * use reserved Table entry = 12, see reference (2) p78 Table 4.6.2
- */
- group_win = 0;
- group_end = 0;
-
-
- /* group by group decoding scalefactors and/or noise energy
- * and/or intensity position
- */
- while ((group_end < pFrameInfo->num_win) && (status == SUCCESS))
- {
- nsfb_win = pFrameInfo->sfb_per_win[group_end];
- group_end = *pGroup++; /* index of 1st window in next group */
-
- /* decode scf in first window of each group */
-
- for (sfb = 0; sfb < nsfb_win; sfb++)
- {
-
- switch (pHuffBookUsed[sfb])
- {
- case ZERO_HCB:
- break;
- case INTENSITY_HCB:
- case INTENSITY_HCB2:
- /* intensity books */
- /* decode intensity position */
- cw_index = decode_huff_scl(pInputStream);
-
- is_pos += cw_index - MIDFAC;
- pFactors[sfb] = is_pos;
- break;
- case NOISE_HCB:
- /* noise books */
- /* decode noise energy */
- if (noise_pcm_flag == TRUE)
- {
- noise_pcm_flag = FALSE;
- dpcm_noise_nrg = get9_n_lessbits(NOISE_PCM_BITS,
- pInputStream);
-
- dpcm_noise_nrg -= NOISE_PCM_OFFSET;
- }
- else
- {
- dpcm_noise_nrg = decode_huff_scl(pInputStream);
-
- dpcm_noise_nrg -= MIDFAC;
- } /* if (noise_pcm_flag) */
-
- noise_nrg += dpcm_noise_nrg;
- pFactors[sfb] = noise_nrg;
- break;
- case BOOKSCL:
- status = 1; /* invalid books */
- sfb = nsfb_win; /* force out */
- break;
- default:
- /* spectral books */
- /* decode scale factors */
- cw_index = decode_huff_scl(pInputStream);
-
- fac += cw_index - MIDFAC; /* 1.5 dB */
- if ((fac >= 2*TEXP) || (fac < 0))
- {
- status = 1; /* error, MUST 0<=scf<256, Ref. p73 */
- }
- else
- {
- pFactors[sfb] = fac; /* store scf */
- } /* if (fac) */
- }
-
- } /* for (sfb=0), first window decode ends */
-
- /* expand scf to other windows in the same group */
- if (pFrameInfo->islong == FALSE)
- {
-
- for (group_win++; group_win < group_end; group_win++)
- {
- for (sfb = 0; sfb < nsfb_win; sfb++)
- {
- pFactors[sfb + nsfb_win] = pFactors[sfb];
- }
- pFactors += nsfb_win;
- }
-
- } /* if (pFrameInfo->islong), one group decode ends */
-
-
- /* points to next group */
- pHuffBookUsed += nsfb_win;
- pFactors += nsfb_win;
-
- } /* while (group_end), all groups decode end */
-
- return status;
-
-} /* hufffac */
-
diff --git a/media/libstagefright/codecs/aacdec/huffman.h b/media/libstagefright/codecs/aacdec/huffman.h
deleted file mode 100644
index 030ae23..0000000
--- a/media/libstagefright/codecs/aacdec/huffman.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .huffman.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Put declaration of getfill in this file.
-
- Description: Remove prstflag from get_ics_info declaration.
-
- Description: Trivial change of the data type of one of the parameters to
- get_ics_info.
-
- Description: Change where get_ics_info is declared.
-
- Description: Clean up comments
-
- Description: (1) Add declaration of binary tree search function for Huffman
- decoding
- (2) #if the traditional and optimized linear seach methods.
-
- Description: Modified per review comments
- (1) delete #if traditional and optimized linear seach methods
-
- Description: Merged Ken's change on getics: delete pFrameInfo from argument
- list
-
- Description: Added function definition for table specific huffman decoding
- functions.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- include function prototype definitions for Huffman decoding module
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef HUFFMAN_H
-#define HUFFMAN_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_sectinfo.h"
-#include "s_pulseinfo.h"
-#include "s_tdec_int_file.h"
-#include "s_tdec_int_chan.h"
-#include "ibstream.h"
-
-#include "s_hcb.h"
-#include "hcbtables.h"
-
-#include "get_pulse_data.h"
-#include "get_ics_info.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-#define DIMENSION_4 4
-#define DIMENSION_2 2
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int decode_huff_cw_tab1(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab2(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab3(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab4(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab5(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab6(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab7(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab8(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab9(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab10(
- BITS *pInputStream);
-
- Int decode_huff_cw_tab11(
- BITS *pInputStream);
-
- Int decode_huff_scl(
- BITS *pInputStream);
-
- Int infoinit(
- const Int sampling_rate_idx,
- FrameInfo **ppWin_seq_info,
- Int *pSfbwidth128);
-
- Int huffcb(
- SectInfo *pSect,
- BITS *pInputStream,
- Int *pSectbits,
- Int tot_sfb,
- Int sfb_per_sbk,
- Int max_sfb);
-
- Int hufffac(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int *pGroup,
- Int nsect,
- SectInfo *pSect,
- Int global_gain,
- Int *pFactors,
- Int huffBookUsed[]);
-
- Int huffspec_fxp(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int nsect,
- SectInfo *pSectInfo,
- Int factors[],
- Int32 coef[],
- Int16 quantSpec[],
- Int16 tmp_spec[],
- const FrameInfo *pLongFrameInfo,
- PulseInfo *pPulseInfo,
- Int qFormat[]);
-
- Int huffdecode(
- Int id_syn_ele,
- BITS *pInputStream,
- tDec_Int_File *pVars,
- tDec_Int_Chan *pChVars[]);
-
- void deinterleave(
- Int16 interleaved[],
- Int16 deinterleaved[],
- FrameInfo *pFrameInfo);
-
- Int getics(
-
- BITS *pInputStream,
- Int common_window,
- tDec_Int_File *pVars,
- tDec_Int_Chan *pChVars,
- Int group[],
- Int *pMax_sfb,
- Int *pCodebookMap,
- TNS_frame_info *pTnsInfo,
- FrameInfo **pWinMap,
- PulseInfo *pPulseInfo,
- SectInfo sect[]);
-
- void calc_gsfb_table(
- FrameInfo *pFrameInfo,
- Int group[]);
-
- Int getmask(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int *pGroup,
- Int max_sfb,
- Int *pMask);
-
- void getgroup(
- Int group[],
- BITS *pInputStream);
-
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp b/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp
deleted file mode 100644
index b18c12d..0000000
--- a/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp
+++ /dev/null
@@ -1,671 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: huffspec_fxp.c
- Funtions:
- huffspec_fxp
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: (1) Modified to keep in-line with PV standards
- (2) Eliminated "continue" in if(sect_cb==ZERO_HCB||...)
-
- Description: (1) Use SectInfo *pSect
- (2) Convert 'Real' to 'Int32', float -> fixed-point
- (3) move BITS *pInputStream to second parameter
- (4) pass in quantSpec and tmp_spec, scratch shared with hufffac
- (5) pass in FrameInfo *pLongFrameInfo, eliminate only_long_info
-
- Description: (1) Eliminate parameter Hcb *book, because of eliminating
- function 'hufftab.c', Hcb hcbbook defined as a
- const structure in 'hcbtables.h'.
- (2) Replace three nested 'for' loops with a for-while loop in
- the rescaling part.
- (3) Change esc_iquant-> esc_iquant_fxp, call esc_iquant_fxp()
- by sfb
-
- Description: Cleaned up include files.
-
- Description: Correct definition of stack variable "scale".
- It was defined as Int, but it receives an UInt value,
- this present a problem when Int is 16 bits and
- the sign bit is not interpreted correctly. This does not
- shows for 32-bit implementations. This problem manifest itself
- as a flipping sign on some spectral coefficients (the ones
- multiplied by 0x8000).
-
- Description: Typecast b_low and b_high to 32-bits before multiplication, this
- assures propoer compilation on a 16-bit platform (TI-C55x)
-
- Description: Modified to speed up decode_huff_cw
-
- Description: pass codebook index to decode_huff_cw, delete pointer to Huffman
- structure
-
- Description: keep memset to quantSpec, remove memset to temp_spec
-
- Description: Modified per review comments
-
- Description: Use Binary tree search in decode_huff_cw_binary
-
- Description: Modified per review comments
- (1) delete unused codes
-
- Description: (1) Change the interface to decode huffman codeword.
- (2) Move the scaling inside the inverse quantization.
- (3) Change scaling factor accuracy to 10 bits.
-
- Description:
- (1) delete unused variable max_fac
-
- Description: Addresses of huffman tables are now found by means of a
- switch statement, this solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pFrameInfo = ptr to structure that holds Information of current Frame,
- type FrameInfo
-
- pInputStream = ptr to structure of bitstream, type BITS
-
- nsect = number of sections in current Frame, at fs = 44.1 kHz,
- range [0, 49] long block, [0,112] short blocks. type Int
-
- pSect = ptr to structure that holds section codebook and boundary
- type SectInfo
-
- factors[] = array that contains scalefactors for each sfb, type Int16
-
- coef[] = array that holds inverse quantized coefs, Int32 QFormat.
-
- quantSpec[] = array that holds quantized spectral coefs, type Int
-
- tmp_spec[] = temporary buffer to hold the de-interleaved coefs.
-
- pLongFrameInfo = ptr to structure that holds long frame info
-
- Local Stores/Buffers/Pointers Needed:
- exptable = array contains the Q15 format data for 2^0, 2^0.25, 2^0.5,
- and 2^0.75, type const Int.
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
-
- return 0 if decoding properly.
-
- Pointers and Buffers Modified:
-
- pInputStream read codeword index and/or sign bits and/or ESC value
-
- coef contains the newly inverse quantized 1024 spec coefs,
- type Int32 Q-format from esc_iquant()
-
- quantSpec contains decoded quantized 1024 spec coefs, type Int
-
- tmp_spec contains the de-interleaved version of quantSpec
-
- qFormat contains Q-Format for each scalefactor band
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function first reads the section info (codebook and boundary), then
- decode the spectral coefficients if a spectral codebook is used.
- If necessary, get the sign bits, ESC value or the NEC_pulse data. In case of
- short window sequences, the decoded data is de-interleaved before
- multiplied by scalefactors.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should set the content of the array 'coef' with the inverse
- quantized and rescaled value of spectral coefficients.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart (4) p56 (spectral_data() parsing and decoding)
- p26 (Syntax of spectral_data())
- p74-78 (decoding: unpack_idx, get_sign_bits,
- getescape, pulse_nc, deinterleave)
- p72 (inverse quantization: esc_iquant)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "esc_iquant_scaling.h"
-#include "huffman.h"
-#include "unpack_idx.h"
-#include "pulse_nc.h"
-#include "iquant_table.h"
-#include "e_huffmanconst.h"
-
-
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ORDER (3)
-
-/*
- * Format the table is stored in.
- */
-#define QTABLE (27)
-
-/*
- * Number of bits for data in a signed 32 bit integer.
- */
-#define SIGNED32BITS (31)
-
-/*
- * Round up value for intermediate values obtained from the table
- */
-#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const UInt16 exptable[4] =
-{
- 0, /* (2^0.00)<<15 (Q10), use zero to signal no scaling required! */
- 19485, /* (2^0.25)<<15 */
- 23171, /* (2^0.50)<<15 */
- 27555 /* (2^0.75)<<15 */
-
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int huffspec_fxp(
- FrameInfo *pFrameInfo,
- BITS *pInputStream,
- Int nsect,
- SectInfo *pSectInfo,
- Int factors[],
- Int32 coef[],
- Int16 quantSpec[],
- Int16 tmp_spec[],
- const FrameInfo *pLongFrameInfo,
- PulseInfo *pPulseInfo,
- Int qFormat[])
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- const Hcb *pHcb;
- Int i;
- Int sfb;
- Int idx_count;
- Int sect_cb; /* section codebook */
- Int dim;
- Int idx;
- Int stop_idx; /* index of 1st coef in next sfb */
- Int sect_start; /* start index of sfb in one section*/
- Int sect_end; /* index of 1st sfb in next section */
- Int *pSfbStart;
- Int *pSfb;
- Int16 *pQuantSpec; /* probably could be short */
- Int max = 0;
- /* rescaling parameters */
- Int nsfb;
- Int tot_sfb;
- Int fac;
-
- Int32 *pCoef; /* ptr to coef[], inverse quantized coefs */
- UInt16 scale;
-
- Int power_scale_div_4;
- Int sfbWidth;
-
- void (*pUnpack_idx)(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max);
-
- Int(*pDec_huff_tab)(BITS *) = NULL;
-
- UInt32 temp;
- Int binaryDigits, QFormat;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- sect_start = 0;
- stop_idx = 0;
-
- /* pSfb: ptr to array that holds stop index of each sfb */
- pSfbStart = pFrameInfo->frame_sfb_top;
-
- if (pSfbStart == NULL)
- {
- return (-1); /* error condition */
- }
-
- pSfb = pSfbStart;
-
- /* decoding spectral values section by section */
- for (i = nsect; i > 0; i--)
- {
- /* read the codebook and section length */
- sect_cb = pSectInfo->sect_cb; /* codebook */
- if ((sect_cb > 15) || (sect_cb < 0))
- {
- return (-1); /* error condition */
- }
- sect_end = pSectInfo->sect_end; /* # of sfbs */
-
- if (sect_end < 0)
- {
- return (-1); /* error condition */
- }
-
- pSectInfo++;
-
- /* sect_cb sect_cb - 1
- * ZERO_HCB 1111b
- * 1 0000b
- * 2 0001b
- * 3 0010b
- * 4 0011b
- * 5 0100b
- * 6 0101b
- * 7 0110b
- * 8 0111b
- * 9 1000b
- * 10 1001b
- * 11 1010b
- * 12 1011b
- * NOISE_HCB 1100b
- * INTENSITY_HCB2 1101b
- * INTENSITY_HCB 1110b
- * if ( ((sect_cb - 1) & 0xC) == 0xC ) is identical to
- * if !((sect_cb == ZERO_HCB) || (sect_cb == NOISE_HCB) ||
- * (sec_cb == INTENSITY_HCB) || (sect_cb==INTENSITY_HCB2) )
- * use this compare scheme to speed up the execution
- */
-
- if (((sect_cb - 1) & 0xC) != 0xC)
- {
- /* decode spec in one section */
- if (sect_cb > BY4BOOKS)
- {
- dim = DIMENSION_2; /* set codebook dimension */
- }
- else
- {
- dim = DIMENSION_4;
- }
-
- pHcb = &hcbbook_binary[sect_cb];
-
- if (sect_cb == ESCBOOK)
- {
- pUnpack_idx = &unpack_idx_esc;
- }
- else if (pHcb->signed_cb == FALSE)
- {
- pUnpack_idx = &unpack_idx_sgn;
- }
- else
- {
- pUnpack_idx = &unpack_idx;
- }
-
-
- switch (sect_cb)
- {
- case 1:
- pDec_huff_tab = decode_huff_cw_tab1;
- break;
- case 2:
- pDec_huff_tab = decode_huff_cw_tab2;
- break;
- case 3:
- pDec_huff_tab = decode_huff_cw_tab3;
- break;
- case 4:
- pDec_huff_tab = decode_huff_cw_tab4;
- break;
- case 5:
- pDec_huff_tab = decode_huff_cw_tab5;
- break;
- case 6:
- pDec_huff_tab = decode_huff_cw_tab6;
- break;
- case 7:
- pDec_huff_tab = decode_huff_cw_tab7;
- break;
- case 8:
- pDec_huff_tab = decode_huff_cw_tab8;
- break;
- case 9:
- pDec_huff_tab = decode_huff_cw_tab9;
- break;
- case 10:
- pDec_huff_tab = decode_huff_cw_tab10;
- break;
- case 11:
- pDec_huff_tab = decode_huff_cw_tab11;
- break;
- default:
- return (-1); /* error condition */
- }
-
- /* move ptr to first sfb of current section */
- pQuantSpec = quantSpec + stop_idx;
-
- /* step through all sfbs in current section */
- for (sfb = sect_start; sfb < sect_end; sfb++)
- {
- idx_count = *pSfb - stop_idx;
- stop_idx = *pSfb++;
-
- /* decode all coefs for one sfb */
- while ((idx_count > 0) && (idx_count < 1024))
- {
-
- idx = (*pDec_huff_tab)(pInputStream);
-
- (*pUnpack_idx)(pQuantSpec,
- idx,
- pHcb,
- pInputStream,
- &max); /* unpack idx -> coefs */
-
- pQuantSpec += dim;
- idx_count -= dim;
-
- } /* while(idx_count) */
-
- } /* for (sfb=sect_start) */
- }
- else
- {
-
- /* current section uses ZERO_HCB, NOISE_HCB, etc */
-
- /* move sfb pointer to the start sfb of next section */
- pSfb = pSfbStart + sect_end;
- /* number of coefs in current section */
- idx_count = *(pSfb - 1) - stop_idx;
-
- if ((idx_count > 1024) || (idx_count < 0))
- {
- return (-1); /* error condition */
- }
-
- /*
- * This memset is necessary in terms of (1) net savings in total
- * MIPS and (2) accurate Q-Formats for fft_rx2
- * In case a scalefactor band uses ZERO_HCB, all coefficients of
- * that sfb should be zeros. Without this call to memset, the
- * coefficients for a ZERO_HCB sfb are the "leftovers" of the
- * previous frame, which may not have all zero values. This leads
- * to a drastical increase in the cycles consumed by esc_iquant_fxp
- * and fft_rx2, which is the most "expensive" function of the
- * library.
- * This memset also guarantees the Q_Format for sfbs with all zero
- * coefficients will be set properly.
- * Profiling data on ARM and TMS320C55x proves that there is a net
- * gain in total MIPS if a memset is called here.
- */
- pv_memset(&quantSpec[stop_idx],
- 0,
- idx_count * sizeof(quantSpec[0]));
-
- /*
- * This memset is called because pQuantSpec points to tmp_spec
- * after deinterleaving
- */
-
- pv_memset(&tmp_spec[stop_idx],
- 0,
- idx_count * sizeof(tmp_spec[0]));
-
-
- /* stop_idx is the index of the 1st coef of next section */
- stop_idx = *(pSfb - 1);
-
- }/* if (sect_cb) */
-
- sect_start = sect_end;
-
- } /* for (i=nsect) */
-
- /* noisless coding reconstruction */
- if (pFrameInfo->islong != FALSE)
- {
- if (pPulseInfo->pulse_data_present == 1)
- {
- pulse_nc(quantSpec,
- pPulseInfo,
- pLongFrameInfo,
- &max); /* add pulse data */
- }
-
- pQuantSpec = quantSpec;
-
- }
- else
- {
- deinterleave(quantSpec,
- tmp_spec,
- pFrameInfo);
-
- pQuantSpec = tmp_spec;
- }
-
-
- /* inverse quantization, Q_format: Int32 */
- /* rescaling */
-
- /* what we can do here is assuming that we already know maxInput for each band, we have to go
- though each one of them for re-quant and scaling, and pick the right qFormat to apply to
- all spectral coeffs.*/
-
- if ((max < 0) || (max > 8192)) /* (8192>>ORDER) == 1024 is the inverseQuantTable size */
- {
- return (-1); /* error condition */
- }
- else
- {
- /* Get (max/SPACING) ^ (1/3), in Q Format */
- temp = inverseQuantTable[(max >> ORDER) + 1];
- }
-
-
- /* Round up before shifting down to Q0 */
- temp += ROUND_UP;
-
- /* shift down to Q0 and multiply by 2 (FACTOR) in one step */
- temp >>= (QTABLE - 1);
-
- /* Now get max ^ (4/3) in Q0 */
- temp *= max;
-
-
- binaryDigits = 31 - pv_normalize(temp);
-
-
- /* Prevent negative shifts caused by low maximums. */
- if (binaryDigits < (SIGNED32BITS - QTABLE))
- {
- binaryDigits = SIGNED32BITS - QTABLE;
- }
-
- QFormat = SIGNED32BITS - binaryDigits;
-
- /********************/
- tot_sfb = 0;
- nsfb = pFrameInfo->sfb_per_win[0];
- pCoef = coef;
-
- for (i = pFrameInfo->num_win; i > 0; i--)
- {
- stop_idx = 0;
-
- for (sfb = 0; sfb < nsfb; sfb++)
- {
- sfbWidth = pFrameInfo->win_sfb_top[0][sfb] - stop_idx;
-
- if ((sfbWidth < 0) || (sfbWidth > 1024))
- {
- return (-1); /* error condition */
- }
-
- stop_idx += sfbWidth;
-
- fac = factors[tot_sfb] - SF_OFFSET;
- scale = exptable[fac & 0x3];
-
- power_scale_div_4 = fac >> 2;
-
- power_scale_div_4++;
-
- qFormat[tot_sfb] = QFormat;
-
- esc_iquant_scaling(pQuantSpec,
- pCoef,
- sfbWidth,
- QFormat,
- scale,
- max);
-
- pQuantSpec += sfbWidth;
- qFormat[tot_sfb] -= power_scale_div_4;
- pCoef += sfbWidth;
-
- tot_sfb++;
-
- } /* for (sfb) */
- } /* for (i) */
-
-
- /*----------------------------------------------------------------------------
- ; Return status
- ----------------------------------------------------------------------------*/
- return SUCCESS;
-
-} /* huffspec_fxp */
diff --git a/media/libstagefright/codecs/aacdec/ibstream.h b/media/libstagefright/codecs/aacdec/ibstream.h
deleted file mode 100644
index 8b644dc..0000000
--- a/media/libstagefright/codecs/aacdec/ibstream.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ibstream.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change names of constants.
-
- Description: Change the buffer from UInt to UInt32
-
- Description: Remove declaration of getbits and include header file
-
- Description: Change input buffer to UChar
- Add constant
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains defines, structures, and function definitions for the
- input bit stream used in the AAC Decoder.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IBSTREAM_H
-#define IBSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define INBUF_ARRAY_INDEX_SHIFT (3)
-#define INBUF_BIT_WIDTH (1<<(INBUF_ARRAY_INDEX_SHIFT))
-#define INBUF_BIT_MODULO_MASK ((INBUF_BIT_WIDTH)-1)
-
-#define MAX_GETBITS (25)
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void byte_align(
- BITS *pInputStream);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* IBSTREAM_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/idct16.cpp b/media/libstagefright/codecs/aacdec/idct16.cpp
deleted file mode 100644
index 324fe9e..0000000
--- a/media/libstagefright/codecs/aacdec/idct16.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: idct16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 16
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement inverse discrete cosine transform of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "idct16.h"
-#include "idct8.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT 28
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-#define Qfmt31(x) (Int32)(x*(0x7FFFFFFF) + (x>=0?0.5F:-0.5F))
-
-const Int32 CosTable_8i[8] =
-{
- Qfmt31(0.50241928618816F), Qfmt31(0.52249861493969F),
- Qfmt31(0.56694403481636F), Qfmt31(0.64682178335999F),
- Qfmt(0.78815462345125F), Qfmt(1.06067768599035F),
- Qfmt(1.72244709823833F), Qfmt(5.10114861868916F)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void idct_16(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 8 */
-{
- Int32 *temp_even = scratch_mem;
-
- Int32 i;
- const Int32 *pt_cos = CosTable_8i;
- Int32 tmp1, tmp2;
- Int32 *pt_even = temp_even;
- Int32 *pt_odd = vec;
- Int32 *pt_vec = vec;
-
- Int32 tmp3;
- Int32 *pt_vecN_1;
-
-
- *(pt_even++) = *(pt_vec++);
- tmp1 = *(pt_vec++);
- *(pt_odd++) = tmp1;
-
- for (i = 2; i != 0; i--)
- {
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- tmp3 = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_odd++) = tmp3 + tmp2;
- tmp1 = tmp3;
- }
-
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- tmp3 = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_odd++) = tmp3 + tmp2;
-
-
- *(pt_even) = *(pt_vec++);
- *(pt_odd++) = *(pt_vec) + tmp3;
-
-
- idct_8(temp_even);
- idct_8(vec);
-
-
- pt_cos = &CosTable_8i[7];
-
- pt_vec = &vec[7];
-
- pt_even = &temp_even[7];
- pt_vecN_1 = &vec[8];
-
- tmp1 = *(pt_even--);
-
- for (i = 2; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q28(*(pt_vec), *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp2 - tmp3;
- *(pt_vec--) = tmp2 + tmp3;
- }
-
- tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp2 - tmp3;
- *(pt_vec--) = tmp2 + tmp3;
- tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q31(*(pt_vec), *(pt_cos)) << 1;
- *(pt_vecN_1) = tmp2 - tmp3;
- *(pt_vec) = tmp2 + tmp3;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/idct16.h b/media/libstagefright/codecs/aacdec/idct16.h
deleted file mode 100644
index afade07..0000000
--- a/media/libstagefright/codecs/aacdec/idct16.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: idct16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT16_H
-#define IDCT16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- void idct_16(Int32 vec[], Int32 scratch_mem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IDCT16_H */
diff --git a/media/libstagefright/codecs/aacdec/idct32.cpp b/media/libstagefright/codecs/aacdec/idct32.cpp
deleted file mode 100644
index ac9773b..0000000
--- a/media/libstagefright/codecs/aacdec/idct32.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: idct32.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 32
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement inverse discrete cosine transform of lenght 32
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "idct32.h"
-#include "dst32.h"
-#include "idct16.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-
-#define R_SHIFT1 29
-#define Qfmt1(x) (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt3(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void idct_32(Int32 vec[], Int32 scratch_mem[]) /* scratch_mem size 32 */
-{
- Int32 *temp_even = scratch_mem;
-
- Int32 i;
- const Int32 *pt_cos = CosTable_16;
- Int32 tmp1, tmp2;
- Int32 *pt_even = temp_even;
- Int32 *pt_odd = vec;
- Int32 *pt_vec = vec;
- Int32 *pt_vecN_1;
- Int32 tmp3;
-
-
- *(pt_even++) = *(pt_vec++);
- tmp1 = *(pt_vec++);
- tmp2 = 0;
-
- for (i = 7; i != 0; i--)
- {
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_even++) = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
- tmp1 = *(pt_vec++);
- }
-
- *(pt_odd++) = tmp2 + tmp1;
- *(pt_even++) = *(pt_vec++);
- tmp2 = *(pt_vec++);
- *(pt_odd++) = tmp2 + tmp1;
-
-
- idct_16(temp_even, &scratch_mem[16]);
- idct_16(vec, &scratch_mem[24]);
-
-
- pt_cos = &CosTable_16[13];
-
- pt_vec = &vec[15];
-
- pt_even = &temp_even[15];
- pt_vecN_1 = &vec[16];
-
- tmp1 = *(pt_even--);
-
-
- tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.63687550772175F)) << 2;
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.85190210461718F));
-
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp2 - tmp3;
- *(pt_vec--) = tmp2 + tmp3;
-
- for (i = 2; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q29(*(pt_vec), *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp2 - tmp3;
- *(pt_vec--) = tmp2 + tmp3;
- }
-
- for (i = 5; i != 0; i--)
- {
- tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--));
- tmp2 = *(pt_even--);
- *(pt_vecN_1++) = tmp1 - tmp3;
- *(pt_vec--) = tmp1 + tmp3;
- tmp3 = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--));
- tmp1 = *(pt_even--);
- *(pt_vecN_1++) = tmp2 - tmp3;
- *(pt_vec--) = tmp2 + tmp3;
- }
-}
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/idct32.h b/media/libstagefright/codecs/aacdec/idct32.h
deleted file mode 100644
index 12c685a..0000000
--- a/media/libstagefright/codecs/aacdec/idct32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: idct32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT32_H
-#define IDCT32_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void idct_32(Int32 vec[], Int32 scratch_mem[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IDCT32_H */
diff --git a/media/libstagefright/codecs/aacdec/idct8.cpp b/media/libstagefright/codecs/aacdec/idct8.cpp
deleted file mode 100644
index 8f040ce..0000000
--- a/media/libstagefright/codecs/aacdec/idct8.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: idct8.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 8
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement inverse discrete cosine transform of lenght 8
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "idct8.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT 29
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void idct_8(Int32 vec[])
-{
-
- Int32 tmp0;
- Int32 tmp1;
- Int32 tmp2;
- Int32 tmp3;
- Int32 tmp4;
- Int32 tmp5;
- Int32 tmp6;
- Int32 tmp7;
- Int32 tmp8;
-
-
- tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F));
-
- tmp1 = vec[0] + tmp5;
- tmp5 = vec[0] - tmp5;
-
- tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F)); /* (1/(2*cos(2*phi)));*/
- tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F)); /* (1/(2*cos(6*phi)));*/
-
- tmp0 = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F)); /* (1/(2*cos(2*phi))); */
- tmp7 = (tmp3 + tmp7) + tmp0;
-
- vec[0] = tmp1 + tmp7;
- tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F)); /* (1/(2*cos( phi)));*/
- vec[1] = tmp5 + tmp0;
- vec[2] = tmp5 - tmp0;
- tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F)); /* (1/(2*cos(3*phi)));*/
- vec[3] = tmp1 - tmp7;
-
- tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F)); /* (1/(2*cos(5*phi)));*/
- tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F)); /* (1/(2*cos(7*phi)));*/
-
- tmp7 = tmp2 + tmp8;
- tmp5 = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F));
- tmp8 = tmp4 + tmp6;
- tmp6 = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F));
-
- tmp0 = tmp7 + tmp8;
- tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F));
-
- tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F));
- tmp1 = (tmp5 + tmp6) + tmp3;
-
- tmp5 = tmp0 + tmp1;
- tmp6 = tmp1 + tmp2;
- tmp7 = tmp2 + tmp3;
-
- vec[7] = vec[0] - tmp5;
- vec[0] += tmp5;
- vec[6] = vec[1] - tmp6;
- vec[1] += tmp6;
- vec[5] = vec[2] - tmp7;
- vec[2] += tmp7;
- vec[4] = vec[3] - tmp3;
- vec[3] += tmp3;
-
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/idct8.h b/media/libstagefright/codecs/aacdec/idct8.h
deleted file mode 100644
index ad7eaae..0000000
--- a/media/libstagefright/codecs/aacdec/idct8.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: idct8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT8_H
-#define IDCT8_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- void idct_8(Int32 vec[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* IDCT8_H */
diff --git a/media/libstagefright/codecs/aacdec/imdct_fxp.cpp b/media/libstagefright/codecs/aacdec/imdct_fxp.cpp
deleted file mode 100644
index ad67f20..0000000
--- a/media/libstagefright/codecs/aacdec/imdct_fxp.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: imdct_fxp.c
- Funtions: imdct_fxp
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- data_quant = Input vector, with quantized spectral lines:
- type Int32
-
- freq_2_time_buffer = Scratch memory used for in-place FFT calculation,
- min size required 1024,
- type Int32
-
- n = Length of input vector "data_quant". Currently 256 or 2048
- type const Int
-
- Q_format = Q_format of the input vector "data_quant"
- type Int
-
- max = Maximum value inside input vector "data_quant"
- type Int32
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- shift = shift factor to reflect scaling introduced by IFFT and imdct_fxp,
-
- Pointers and Buffers Modified:
- Results are return in "Data_Int_precision"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- The IMDCT is a linear orthogonal lapped transform, based on the idea of
- time domain aliasing cancellation (TDAC).
- IMDCT is critically sampled, which means that though it is 50% overlapped,
- a sequence data after IMDCT has the same number of coefficients as samples
- before the transform (after overlap-and-add). This means, that a single
- block of IMDCT data does not correspond to the original block on which the
- IMDCT was performed. When subsequent blocks of inverse transformed data
- are added (still using 50% overlap), the errors introduced by the
- transform cancels out.Thanks to the overlapping feature, the IMDCT is very
- useful for quantization. It effectively removes the otherwise easily
- detectable blocking artifact between transform blocks.
-
- N = twice the length of input vector X
- y = vector of length N, will hold fixed point IDCT
- p = 0:1:N-1
-
- 2 N/2-1
- y(p) = --- SUM X(m)*cos(pi/(2*N)*(2*p+1+N/2)*(2*m+1))
- N m=0
-
- The window that completes the TDAC is applied before calling this function.
- The IMDCT can be calculated using an IFFT, for this, the IMDCT need be
- rewritten as an odd-time odd-frequency discrete Fourier transform. Thus,
- the IMDCT can be calculated using only one n/4 point FFT and some pre and
- post-rotation of the sample points.
-
-
- where X(k) is the input with N frequency lines
-
- X(k) ----------------------------
- |
- |
- Pre-rotation by exp(j(2pi/N)(k+1/8))
- |
- |
- N/4- point IFFT
- |
- |
- Post-rotation by exp(j(2pi/N)(n+1/8))
- |
- |
- ------------- x(n) In the time domain
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should provide a fixed point IMDCT with an average
- quantization error less than 1 % (variance and mean).
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] Analysis/Synthesis Filter Bank design based on time domain
- aliasing cancellation
- Jhon Princen, et. al.
- IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986
- Pg 1153 - 1161
-
- [2] Regular FFT-related transform kernels for DCT/DST based
- polyphase filterbanks
- Rolf Gluth
- Proc. ICASSP 1991, pg. 2205 - 2208
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- Cx, Cy are complex number
-
-
- exp = log2(n)-1
-
- FOR ( k=0; k< n/2; k +=2)
-
- Cx = - data_quant[k] + j data_quant[n/2-1 - k]
-
- freq_2_time_buffer = Cx * exp(j(2pi/n)(k+1/8))
-
- ENDFOR
-
- CALL IFFT( freq_2_time_buffer, n/4)
-
- MODIFYING( freq_2_time_buffer )
-
- RETURNING( shift )
-
- FOR ( k=0; k< n/4; k +=2)
-
- Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1]
-
- Cy = Cx * exp(j(2pi/n)(k+1/8))
-
- data_quant[3n/4-1 - k ] = Real(Cy)
- data_quant[ n/4-1 - k ] = - Imag(Cy)
- data_quant[3n/4 + k ] = Real(Cy)
- data_quant[ n/4 + k ] = Imag(Cy)
-
- ENDFOR
-
- FOR ( k=n/4; k< n/2; k +=2)
-
- Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1]
-
- Cy = Cx * exp(j(2pi/n)(k+1/8))
-
- data_quant[3n/4-1 - k ] = Real(Cy)
- data_quant[ n/4 + k ] = - Real(Cy)
- data_quant[5n/4 - k ] = Imag(Cy)
- data_quant[ n/4 + k ] = Imag(Cy)
-
- ENDFOR
-
- MODIFIED data_quant[]
-
- RETURN (exp - shift)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "imdct_fxp.h"
-
-
-#include "mix_radix_fft.h"
-#include "digit_reversal_tables.h"
-#include "fft_rx4.h"
-#include "inv_short_complex_rot.h"
-#include "inv_long_complex_rot.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ERROR_IN_FRAME_SIZE 10
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int imdct_fxp(Int32 data_quant[],
- Int32 freq_2_time_buffer[],
- const Int n,
- Int Q_format,
- Int32 max)
-{
-
- Int32 exp_jw;
- Int shift = 0;
-
- const Int32 *p_rotate;
- const Int32 *p_rotate_2;
-
- Int32 *p_data_1;
- Int32 *p_data_2;
-
- Int32 temp_re32;
- Int32 temp_im32;
-
- Int shift1 = 0;
- Int32 temp1;
- Int32 temp2;
-
- Int k;
- Int n_2 = n >> 1;
- Int n_4 = n >> 2;
-
-
-
- if (max != 0)
- {
-
- switch (n)
- {
- case SHORT_WINDOW_TYPE:
- p_rotate = exp_rotation_N_256;
- shift = 21; /* log2(n)-1 + 14 acomodates 2/N factor */
- break;
-
- case LONG_WINDOW_TYPE:
- p_rotate = exp_rotation_N_2048;
- shift = 24; /* log2(n)-1 +14 acomodates 2/N factor */
- break;
-
- default:
- /*
- * There is no defined behavior for a non supported frame
- * size. By returning a fixed scaling factor, the input will
- * scaled down and the will be heard as a low level noise
- */
- return(ERROR_IN_FRAME_SIZE);
-
- }
-
- /*
- * p_data_1 p_data_2
- * | |
- * RIRIRIRIRIRIRIRIRIRIRIRIRIRIRI....RIRIRIRIRIRI
- * | |
- *
- */
-
- p_data_1 = data_quant; /* uses first half of buffer */
- p_data_2 = &data_quant[n_2 - 1]; /* uses second half of buffer */
-
- p_rotate_2 = &p_rotate[n_4-1];
-
- shift1 = pv_normalize(max) - 1; /* -1 to leave room for addition */
- Q_format -= (16 - shift1);
- max = 0;
-
-
- if (shift1 >= 0)
- {
- temp_re32 = *(p_data_1++) << shift1;
- temp_im32 = *(p_data_2--) << shift1;
-
- for (k = n_4 >> 1; k != 0; k--)
- {
- /*
- * Real and Imag parts have been swaped to use FFT as IFFT
- */
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
- exp_jw = *p_rotate++;
-
- temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
- temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw);
-
- temp_im32 = *(p_data_1--) << shift1;
- temp_re32 = *(p_data_2--) << shift1;
- *(p_data_1++) = temp1;
- *(p_data_1++) = temp2;
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
-
- /*
- * Real and Imag parts have been swaped to use FFT as IFFT
- */
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- exp_jw = *p_rotate_2--;
-
- temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
- temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw);
-
-
- temp_re32 = *(p_data_1++) << shift1;
- temp_im32 = *(p_data_2--) << shift1;
-
- *(p_data_2 + 2) = temp1;
- *(p_data_2 + 3) = temp2;
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
- }
- }
- else
- {
- temp_re32 = *(p_data_1++) >> 1;
- temp_im32 = *(p_data_2--) >> 1;
-
- for (k = n_4 >> 1; k != 0; k--)
- {
- /*
- * Real and Imag parts have been swaped to use FFT as IFFT
- */
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
- exp_jw = *p_rotate++;
-
- temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
- temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw);
-
- temp_im32 = *(p_data_1--) >> 1;
- temp_re32 = *(p_data_2--) >> 1;
- *(p_data_1++) = temp1;
- *(p_data_1++) = temp2;
-
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
-
- /*
- * Real and Imag parts have been swaped to use FFT as IFFT
- */
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
- exp_jw = *p_rotate_2--;
-
- temp1 = cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
- temp2 = -cmplx_mul32_by_16(temp_re32, temp_im32, exp_jw);
-
- temp_re32 = *(p_data_1++) >> 1;
- temp_im32 = *(p_data_2--) >> 1;
-
- *(p_data_2 + 3) = temp2;
- *(p_data_2 + 2) = temp1;
-
- max |= (temp1 >> 31) ^ temp1;
- max |= (temp2 >> 31) ^ temp2;
-
- }
- }
-
-
- if (n != SHORT_WINDOW_TYPE)
- {
-
- shift -= mix_radix_fft(data_quant,
- &max);
-
- shift -= inv_long_complex_rot(data_quant,
- max);
-
- }
- else /* n_4 is 64 */
- {
-
- shift -= fft_rx4_short(data_quant, &max);
-
-
- shift -= inv_short_complex_rot(data_quant,
- freq_2_time_buffer,
- max);
-
- pv_memcpy(data_quant,
- freq_2_time_buffer,
- SHORT_WINDOW*sizeof(*data_quant));
- }
-
- }
- else
- {
- Q_format = ALL_ZEROS_BUFFER;
- }
-
- return(shift + Q_format);
-
-} /* imdct_fxp */
diff --git a/media/libstagefright/codecs/aacdec/imdct_fxp.h b/media/libstagefright/codecs/aacdec/imdct_fxp.h
deleted file mode 100644
index 5837750..0000000
--- a/media/libstagefright/codecs/aacdec/imdct_fxp.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: imdct_fxp.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: This extern had the incorrect length of the arrays. The true
- lengths are 128 and 1024, not 64 and 512.
-
- Description: Modified interface so a vector with extended precision is
- returned, this is a 32 bit vector whose MSB 16 bits will be
- extracted later. Added copyright notice.
-
- Description: Modified function interface to accomodate the normalization
- that now is done in this function.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function imdct_fxp()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IMDCT_FXP_H
-#define IMDCT_FXP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
-#define LONG_WINDOW_TYPE 2048
-#define SHORT_WINDOW_TYPE 256
-
-#define ALL_ZEROS_BUFFER 31
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- extern const Int32 exp_rotation_N_256[64];
- extern const Int32 exp_rotation_N_2048[512];
- /*
- extern const Int exp_rotation_N_256[128];
- extern const Int exp_rotation_N_2048[1024];
- */
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int imdct_fxp(
- Int32 data_quant[],
- Int32 freq_2_time_buffer[],
- const Int n,
- Int Q_format,
- Int32 max
- );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* IMDCT_FXP_H */
diff --git a/media/libstagefright/codecs/aacdec/infoinit.cpp b/media/libstagefright/codecs/aacdec/infoinit.cpp
deleted file mode 100644
index 7bdcdcd..0000000
--- a/media/libstagefright/codecs/aacdec/infoinit.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: infoinit.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Pass eight_short_info and the array 'sfbwidth128'.
- Change function arguments' names for clarity
-
- Description: move sfb definitions to "sfb.h", and "sfb.c", eliminated
- the function "huffbookinit.c"
-
- Description: Remove initialization of the never used array,
- pFrameInfo->group_offs
-
- Description:
- (1) Changed "stdinc.h" to <stdlib.h> - this avoids linking in the math
- library and stdio.h. (All for just defining the NULL pointer macro)
-
- (2) Updated copyright header.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Addresses of constant vectors are now found by means of a
- switch statement, this solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pSi = pointer to sampling rate info
- ppWin_seq_info = pointer array to window sequence Info struct
- pSfbwidth128 = pointer to sfb bandwidth array of short window
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
- ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values
- ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function sets the values of 'Info' structure for blocks containing long
- and short window sequences, the following structures are being set:
-
- win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW],
- only_long_info and eight_short_info
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p66 (sfb tables)
- p111 (4.6.10)
- p200 (Annex 4.B.5)
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pFrameInfo = pointer to only_long_info;
- win_seq_info[ONLY_LONG_WINDOW] = pFrameInfo;
- pFrameInfo{all structure members} = setup values;
-
-
- pFrameInfo = pointer to eight_short_info;
- win_seq_info[EIGHT_SHORT_WINDOW] = pFrameInfo;
- pFrameInfo{all structure.members} = setup values;
-
-
- FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++)
-
- win_seq_info[window_seq].members = setup values;
-
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sr_info.h"
-#include "s_frameinfo.h"
-#include "e_blockswitching.h"
-#include "e_huffmanconst.h"
-#include "sfb.h"
-#include "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int infoinit(
- const Int samp_rate_idx,
- FrameInfo **ppWin_seq_info,
- Int *pSfbwidth128)
-
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
-
- Int i;
- Int sfb_idx, sfb_sbk;
- Int bins_sbk;
- Int win_seq;
- Int start_idx, end_idx;
- Int nsfb_short;
- Int16 *sfbands;
- FrameInfo *pFrameInfo;
-
- const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]);
-
- const Int16 * pt_SFbands1024 = NULL;
- const Int16 * pt_SFbands128 = NULL;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
-
- switch (pSi->samp_rate)
- {
- case 96000:
- case 88200:
- pt_SFbands1024 = sfb_96_1024;
- pt_SFbands128 = sfb_64_128; /* equal to table sfb_96_128, (eliminated) */
- break;
- case 64000:
- pt_SFbands1024 = sfb_64_1024;
- pt_SFbands128 = sfb_64_128;
- break;
- case 48000:
- case 44100:
- pt_SFbands1024 = sfb_48_1024;
- pt_SFbands128 = sfb_48_128;
- break;
- case 32000:
- pt_SFbands1024 = sfb_32_1024;
- pt_SFbands128 = sfb_48_128;
- break;
- case 24000:
- case 22050:
- pt_SFbands1024 = sfb_24_1024;
- pt_SFbands128 = sfb_24_128;
- break;
- case 16000:
- case 12000:
- case 11025:
- pt_SFbands1024 = sfb_16_1024;
- pt_SFbands128 = sfb_16_128;
- break;
- case 8000:
- pt_SFbands1024 = sfb_8_1024;
- pt_SFbands128 = sfb_8_128;
- break;
- default:
- // sampling rate not supported
- return -1;
- }
-
- /* long block info */
-
- pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW];
- pFrameInfo->islong = 1;
- pFrameInfo->num_win = 1;
- pFrameInfo->coef_per_frame = LN2; /* = 1024 */
-
- pFrameInfo->sfb_per_win[0] = pSi->nsfb1024;
- pFrameInfo->sectbits[0] = LONG_SECT_BITS;
- pFrameInfo->win_sfb_top[0] = (Int16 *)pt_SFbands1024;
-
- pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */
- pFrameInfo->num_groups = 1; /* long block, one group */
- pFrameInfo->group_len[0] = 1; /* only one window */
-
- /* short block info */
- pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW];
- pFrameInfo->islong = 0;
- pFrameInfo->num_win = NSHORT;
- pFrameInfo->coef_per_frame = LN2;
-
- for (i = 0; i < pFrameInfo->num_win; i++)
- {
- pFrameInfo->sfb_per_win[i] = pSi->nsfb128;
- pFrameInfo->sectbits[i] = SHORT_SECT_BITS;
- pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128;
- }
-
- /* construct sfb width table */
- pFrameInfo->sfb_width_128 = pSfbwidth128;
- for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++)
- {
- end_idx = pt_SFbands128[i];
- pSfbwidth128[i] = end_idx - start_idx;
- start_idx = end_idx;
- }
-
-
- /* common to long and short */
- for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++)
- {
-
- if (ppWin_seq_info[win_seq] != NULL)
- {
- pFrameInfo = ppWin_seq_info[win_seq];
- pFrameInfo->sfb_per_frame = 0;
- sfb_sbk = 0;
- bins_sbk = 0;
-
- for (i = 0; i < pFrameInfo->num_win; i++)
- {
-
- /* compute coef_per_win */
- pFrameInfo->coef_per_win[i] =
- pFrameInfo->coef_per_frame / pFrameInfo->num_win;
-
- /* compute sfb_per_frame */
- pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i];
-
- /* construct default (non-interleaved) bk_sfb_top[] */
- sfbands = pFrameInfo->win_sfb_top[i];
- for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i];
- sfb_idx++)
- {
- pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] =
- sfbands[sfb_idx] + bins_sbk;
- }
-
- bins_sbk += pFrameInfo->coef_per_win[i];
- sfb_sbk += pFrameInfo->sfb_per_win[i];
- } /* for i = sbk ends */
- }
-
- } /* for win_seq ends */
-
- return SUCCESS;
-
-} /* infoinit */
diff --git a/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp b/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp
deleted file mode 100644
index fc47dd3..0000000
--- a/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: init_sbr_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- initializes sbr decoder structure
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "init_sbr_dec.h"
-#include "aac_mem_funcs.h"
-#include "extractframeinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 init_sbr_dec(Int32 codecSampleRate,
- Int upsampleFac,
- SBR_DEC *sbrDec,
- SBR_FRAME_DATA *hFrameData)
-{
- Int32 outFrameSize;
- Int32 coreCodecFrameSize = 1024;
-#ifdef HQ_SBR
- Int32 i;
-#endif
-
-
- sbrDec->sbStopCodec = upsampleFac << 5;
- sbrDec->prevLowSubband = upsampleFac << 5;
-
-
- /* set sbr sampling frequency */
- sbrDec->outSampleRate = 2 * codecSampleRate;
- outFrameSize = upsampleFac * coreCodecFrameSize;
-
- hFrameData->nSfb[LO] = 0; /* number of scale factor bands for high resp.low frequency resolution */
- hFrameData->nSfb[HI] = 0;
- hFrameData->offset = 0;
-
- hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands;
- hFrameData->prevEnvIsShort = -1;
-
- /* Initializes pointers */
-#ifdef HQ_SBR
- for (i = 0; i < 5; i++)
- {
- hFrameData->fBuf_man[i] = hFrameData->fBuffer_man[i];
- hFrameData->fBufN_man[i] = hFrameData->fBufferN_man[i];
- hFrameData->fBuf_exp[i] = hFrameData->fBuffer_exp[i];
- hFrameData->fBufN_exp[i] = hFrameData->fBufferN_exp[i];
- }
-#endif
-
-
- pv_memset((void *)hFrameData->sbr_invf_mode_prev,
- 0,
- MAX_NUM_NOISE_VALUES*sizeof(INVF_MODE));
-
- /* Direct assignments */
-
- sbrDec->noCols = 32;
-
- sbrDec->bufWriteOffs = 6 + 2;
- sbrDec->bufReadOffs = 2;
- sbrDec->qmfBufLen = sbrDec->noCols + sbrDec->bufWriteOffs;
-
- sbrDec->lowBandAddSamples = 288;
-
- sbrDec->startIndexCodecQmf = 0;
-
- sbrDec->lowSubband = 32;
-
-
- return outFrameSize;
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/init_sbr_dec.h b/media/libstagefright/codecs/aacdec/init_sbr_dec.h
deleted file mode 100644
index 844fa0e..0000000
--- a/media/libstagefright/codecs/aacdec/init_sbr_dec.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: init_sbr_dec.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INIT_SBR_DEC_H
-#define INIT_SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "sbr_dec.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int32 init_sbr_dec(Int32 codecSampleRate,
- Int upsampleFac,
- SBR_DEC *sbrDec,
- SBR_FRAME_DATA *hFrameData);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/intensity_right.cpp b/media/libstagefright/codecs/aacdec/intensity_right.cpp
deleted file mode 100644
index 106298a..0000000
--- a/media/libstagefright/codecs/aacdec/intensity_right.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: intensity_right.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments.
-
- Description: Noticed that the code could be more efficient by
- using some other method for storing the sign. The code was changed to
- use a signed Int to store the table, and an adjustment of the q-format to
- reflect the difference between the data being shifted by 16 and the table
- being stored in q-15 format.
-
- Description: Updated pseudocode
-
- Description: When the multiplication of two 16-bits variables is stored in
- an 32-bits variable, the result should be typecasted explicitly
- to Int32 before it is stored.
- *(pCoefRight++) = (Int32) tempInt2 * multiplier;
-
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- scalefactor = Multiplier used to scale the data extracted from the left
- channel for use on the right.
- [const Int]
-
- coef_per_win = Number of coefficients per window.
- (128 for short, 1024 for long)
- [const Int]
-
- sfb_per_win = Number of scalefactor bands per window. This should be
- a number divisible by four.
- [const Int]
-
- wins_in_group = The number of windows in the group being decoded.
- This number falls within the range 1-8.
- [const Int]
-
- band_length = The length of the scalefactor band being decoded.
- This value is divisible by 4.
- [const Int]
-
- codebook = Value that denotes which Huffman codebook was used for
- the encoding of this grouped scalefactor band.
- [const Int]
-
- ms_used = Flag that denotes whether M/S is active for this band.
- [const Bool]
-
- q_formatLeft = The Q-format for the left channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [const Int *, length MAXBANDS]
-
- q_formatRight = The Q-format for the right channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAXBANDS]
-
- coefLeft = Array containing the fixed-point spectral coefficients
- for the left channel.
- [const Int32 *, length 1024]
-
- coefRight = Array containing the fixed-point spectral coefficients
- for the right channel.
- [Int32 *, length 1024]
-
- Local Stores/Buffers/Pointers Needed:
- intensity_factor = Table which stores the values of
- 0.5^(0), 0.5^(1/4), 0.5^(2/4) and 0.5^(3/4)
- [UInt, length 4]
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coefRight[] Contains the new spectral information
-
- q_formatRight[] Q-format may be updated with changed fixed-point
- data in coefRight.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function applies Intensity Stereo, generating data on the right channel
- that is derived from data on the Left. A scalefactor is applied using the
- following formula...
-
- RightCh = LeftCh*0.5^(scalefactor/4)
-
- This function works for one scalefactor band, which may belong to a group.
- (i.e. the same scalefactor band repeated across multiple windows belonging
- to one group.)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- codebook must be either INTENSITY_HCB or INTENSITY_HCB2 when this function
- is called.
-
- ms_used must be 1 when TRUE, 0 when FALSE.
-
- wins_in_group falls within the range [1-8]
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
- multiplier = codebook AND 0x1;
-
- multiplier = multiplier XOR ms_used;
-
- multiplier = multiplier << 1;
-
- multiplier = multiplier - 1;
-
- multiplier = multiplier * intensity_factor[scalefactor & 0x3];
-
- scf_div_4 = (scalefactor >> 2);
-
- nextWinPtrUpdate = (coef_per_win - band_length);
-
- FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
- *(pQformatRight) = scf_div_4 + *(pQformatLeft) - 1;
-
- FOR (tempInt = band_length; tempInt > 0; tempInt--)
- tempInt2 = (Int)(*(pCoefLeft) >> 16);
-
- *(pCoefRight) = tempInt2 * multiplier;
-
- pCoefRight = pCoefRight + 1;
- pCoefLeft = pCoefLeft + 1;
-
- ENDFOR
-
- pCoefRight = pCoefRight + nextWinPtrUpdate;
- pCoefLeft = pCoefLeft + nextWinPtrUpdate;
-
- pQformatRight = pQformatRight + sfb_per_win;
- pQformatLeft = pQformatLeft + sfb_per_win;
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "intensity_right.h"
-#include "e_huffmanconst.h"
-
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int16 intensity_factor[4] =
-{
- 32767, /* (0.5^0.00)*2^15 - 1 (minus 1 for storage as type Int) */
- 27554, /* (0.5^0.25)*2^15 */
- 23170, /* (0.5^0.50)*2^15 */
- 19484
-}; /* (0.5^0.75)*2^15 */
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void intensity_right(
- const Int scalefactor,
- const Int coef_per_win,
- const Int sfb_per_win,
- const Int wins_in_group,
- const Int band_length,
- const Int codebook,
- const Bool ms_used,
- const Int q_formatLeft[],
- Int q_formatRight[],
- const Int32 coefLeft[],
- Int32 coefRight[])
-
-{
- const Int32 *pCoefLeft = coefLeft;
- Int32 *pCoefRight = coefRight;
-
- const Int *pQformatLeft = q_formatLeft;
- Int *pQformatRight = q_formatRight;
-
- Int multiplier;
- Int scf_div_4;
- Int nextWinPtrUpdate;
-
- /*
- * The sign of the intensity multiplier obeys the following table...
- *
- * codebook | ms_used | multiplier
- * --------------------------------------
- * INTENSITY_HCB | TRUE | -1
- * INTENSITY_HCB | FALSE | +1
- * INTENSITY_HCB2 | TRUE | +1
- * INTENSITY_HCB2 | FALSE | -1
- *
- * In binary, the above table is represented as...
- *
- * codebook | ms_used | multiplier
- * --------------------------------------
- * 1111b | 1 | -1
- * 1111b | 0 | +1
- * 1110b | 1 | +1
- * 1110b | 0 | -1
- *
- */
-
- /*
- * Deriving the correct value for "multiplier" is illustrated
- * below for all 4 possible combinations of codebook and ms_used
- */
-
- /*
- * 1111b AND 0x1 = 1b
- * 1111b AND 0x1 = 1b
- * 1110b AND 0x1 = 0b
- * 1110b AND 0x1 = 0b
- */
- multiplier = (codebook & 0x1);
-
- /*
- * 1b XOR 1 = 0b
- * 1b XOR 0 = 1b
- * 0b XOR 1 = 1b
- * 0b XOR 0 = 0b
- */
- multiplier ^= ms_used;
-
- /*
- * 0b << 1 = 0
- * 1b << 1 = 2
- * 1b << 1 = 2
- * 0b << 1 = 0
- */
- multiplier <<= 1;
-
- /*
- * 0 - 1 = -1
- * 2 - 1 = +1
- * 2 - 1 = +1
- * 0 - 1 = -1
- */
- multiplier--;
-
- multiplier *= intensity_factor[scalefactor & 0x3];
-
- scf_div_4 = (scalefactor >> 2);
-
- /*
- * Step through all the windows in this group, replacing this
- * band in each window's spectrum with
- * left-channel correlated data
- */
-
- nextWinPtrUpdate = (coef_per_win - band_length);
-
- for (Int win_indx = wins_in_group; win_indx > 0; win_indx--)
- {
-
- /*
- * Calculate q_formatRight
- *
- * q_formatLeft must be included, since the values
- * on the right-channel are derived from the values
- * on the left-channel.
- *
- * scalefactor/4 is included, since the intensity
- * formula is RightCh = LeftCh*0.5^(scalefactor/4)
- *
- * powers of 0.5 increase the q_format by 1.
- * (Another way to multiply something by 0.5^(x)
- * is to increase its q-format by x.)
- *
- * Finally the q-format must be decreased by 1.
- * The reason for this is because the table is stored
- * in q-15 format, but we are shifting by 16 to do
- * a 16 x 16 multiply.
- */
-
- *(pQformatRight) = scf_div_4 + *(pQformatLeft);
-
- /*
- * reconstruct right intensity values
- *
- * to make things faster, this for loop
- * can be partially unrolled, since band_length is a multiple
- * of four.
- */
-
-
- if (multiplier == 32767)
- {
- Int32 tempInt2 = *(pCoefLeft++);
- Int32 tempInt22 = *(pCoefLeft++);
-
- for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--)
- {
- *(pCoefRight++) = tempInt2;
- *(pCoefRight++) = tempInt22;
- tempInt2 = *(pCoefLeft++);
- tempInt22 = *(pCoefLeft++);
- }
-
- }
- else
- {
-
- Int32 tempInt2 = *(pCoefLeft++);
- Int32 tempInt22 = *(pCoefLeft++);
- for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--)
- {
- *(pCoefRight++) = fxp_mul32_by_16(tempInt2, multiplier) << 1;
- *(pCoefRight++) = fxp_mul32_by_16(tempInt22, multiplier) << 1;
- tempInt2 = *(pCoefLeft++);
- tempInt22 = *(pCoefLeft++);
- }
- }
-
- /*
- * Set pCoefRight and pCoefLeft to the beginning of
- * this sfb in the next window in the group.
- */
-
- pCoefRight += nextWinPtrUpdate;
- pCoefLeft += (nextWinPtrUpdate - 2);
-
- /*
- * Update pQformatRight and pQformatLeft to this sfb in
- * in the next window in the group.
- */
-
- pQformatRight += sfb_per_win;
- pQformatLeft += sfb_per_win;
-
- } /* for (win_indx) */
-
-
-} /* void intensity_right */
diff --git a/media/libstagefright/codecs/aacdec/intensity_right.h b/media/libstagefright/codecs/aacdec/intensity_right.h
deleted file mode 100644
index 823da07..0000000
--- a/media/libstagefright/codecs/aacdec/intensity_right.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: intensity_right.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change ms_used from Int to Bool
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function definitions for intensity_right
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INTENSITY_RIGHT_H
-#define INTENSITY_RIGHT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void intensity_right(
- const Int scalefactor,
- const Int coef_per_win,
- const Int sfb_per_win,
- const Int wins_in_group,
- const Int band_length,
- const Int codebook,
- const Bool ms_used,
- const Int q_formatLeft[],
- Int q_formatRight[],
- const Int32 coefLeft[],
- Int32 coefRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp b/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp
deleted file mode 100644
index 84a7ec8..0000000
--- a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .inv_long_complex_rot.c
- Funtions: inv_long_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change the input argument, no shifts information from long fft_rx4
- , do not have to check for shifts.
-
- Date: 10/18/2002
- Description:
- (1) Change the input argument, only a single max is passed.
- (2) Eliminate search for max, a fixed shift has replaced the
- search for max with minimal loss of precision.
- (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
- (1) Added comments per code review
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Data_in = Input vector (sized for long windows
- TWICE_INV_LONG_CX_ROT_LENGTH), with time domain samples
- type Int32 *
-
- Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)),
- (sized for long windows TWICE_INV_LONG_CX_ROT_LENGTH)
- type Int32 *
-
- max = Input, carries the maximum value of the input vector
- "Data_in"
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
- Results are return in "Data_out"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- inv_long_complex_rot() performs the complex rotation for the inverse MDCT
- for the case of long windows. It also performs digit reverse ordering of
- the first and second halves of the input vector "Data_in", as well as
- reordering of the two half vectors (following radix-2 decomposition)
- Word normalization is also done to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- inv_long_complex_rot() should execute a post-rotation by
- exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "inv_long_complex_rot.h"
-#include "imdct_fxp.h"
-#include "inv_long_complex_rot.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-
-Int inv_long_complex_rot(
- Int32 *Data,
- Int32 max)
-{
- Int i;
- Int16 I;
- const Int32 *p_rotate;
- Int32 temp_re;
- Int32 temp_im;
-
- Int32 exp_jw;
- Int32 *pData_in_1;
- Int32 *pData_in_2;
- Int exp;
- Int32 *pData_in_ref1;
- Int32 *pData_in_ref2;
-
-
- Int16 temp_re_0;
- Int16 temp_im_0;
- Int16 temp_re_1;
- Int16 temp_im_1;
- Int16 *p_Data_Int_precision;
- Int n = 2048;
- Int n_2 = n >> 1;
- Int n_4 = n >> 2;
- Int n_3_4 = n_2 + n_4;
-
- Int16 *px_1;
- Int16 *px_2;
- Int16 *px_3;
- Int16 *px_4;
-
- Int16 J;
- const Int32 *p_rotate2;
-
-
-
-
- p_rotate = &exp_rotation_N_2048[255];
- p_rotate2 = &exp_rotation_N_2048[256];
-
- pData_in_ref1 = Data;
- pData_in_ref2 = &Data[TWICE_INV_LONG_CX_ROT_LENGTH];
-
-
- /*
- * Apply A/2^(diff) + B
- */
-
- p_Data_Int_precision = (Int16 *)Data;
-
- exp = 16 - pv_normalize(max);
-
-
- /*
- * px2--> <--px1 px4--> <--px3
- *
- * | | |
- * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++|
- * | | | |
- * n/4 n/2 3n/4
- */
-
- I = 255;
- J = 256;
-
- pData_in_1 = pData_in_ref2 + I;
-
- px_1 = (Int16 *)pData_in_1;
- px_1++;
-
- pData_in_2 = pData_in_ref2 + J;
-
- px_4 = (Int16 *)pData_in_2;
-
-
-
- exp -= 1;
-
-
- for (i = INV_LONG_CX_ROT_LENGTH >> 1; i != 0; i--)
- {
-
- pData_in_2 = pData_in_ref1 + J;
-
- temp_im = *(pData_in_2++);
- temp_re = *(pData_in_2);
-
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
- exp_jw = *p_rotate2++;
-
- /*
- * Post-rotation
- */
-
-
-
- temp_re_0 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
- temp_im_0 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp);
-
-
- pData_in_1 = pData_in_ref2 + I;
-
- /*
- * Use auxiliary variables to avoid double accesses to memory.
- * Data in is scaled to use only lower 16 bits.
- */
-
- temp_re = *(pData_in_1--);
- temp_im = *(pData_in_1);
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
- exp_jw = *p_rotate--;
-
-
- /*
- * Post-rotation
- */
-
- temp_re_1 = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
- temp_im_1 = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp);
-
-
- /*
- * Repeat procedure for odd index at the output
- */
-
- pData_in_2 = pData_in_ref2 + J;
- J += 2;
-
- temp_im = *(pData_in_2++);
- temp_re = *(pData_in_2);
-
-
- *(px_1--) = temp_re_0;
- *(px_1--) = temp_im_1;
- *(px_4++) = temp_im_0;
- *(px_4++) = temp_re_1;
-
-
- exp_jw = *p_rotate2++;
-
-
- *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
- *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp);
-
-
-
- /*
- * Repeat procedure for odd index at the output
- */
-
- pData_in_1 = pData_in_ref1 + I;
- I -= 2;
-
- temp_re = *(pData_in_1--);
- temp_im = *(pData_in_1);
-
-
- exp_jw = *p_rotate--;
-
-
- *(px_4++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
- *(px_1--) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp);
-
- }
-
- /*
- * <--px1 px4-->
- *
- * | | |
- * |-------------|-------------|/////////////|\\\\\\\\\\\\\|
- * | | | |
- * n/4 n/2 3n/4
- */
-
-
- px_1 = p_Data_Int_precision + n_2 - 1;
- px_2 = p_Data_Int_precision;
-
- px_4 = p_Data_Int_precision + n_3_4 - 1;
-
- for (i = 0; i<INV_LONG_CX_ROT_LENGTH >> 1; i++)
- {
-
- Int16 temp_re_0 = *(px_4--);
- Int16 temp_im_1 = *(px_4--);
- Int16 temp_re_2 = *(px_4--);
- Int16 temp_im_3 = *(px_4--);
- *(px_1--) = temp_re_0;
- *(px_1--) = temp_im_1;
- *(px_1--) = temp_re_2;
- *(px_1--) = temp_im_3;
-
- *(px_2++) = (-temp_re_0);
- *(px_2++) = (-temp_im_1);
- *(px_2++) = (-temp_re_2);
- *(px_2++) = (-temp_im_3);
-
- }
-
-
- px_4 = p_Data_Int_precision + n_2;
-
-
- pv_memcpy(px_4, pData_in_ref2 + 256, TWICE_INV_LONG_CX_ROT_LENGTH*sizeof(*px_4));
-
-
-
- /*
- * px2--> <--px1 px4--> <--px3
- *
- * | | |
- * |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++|
- * | | | |
- * n/4 n/2 3n/4
- */
- px_3 = p_Data_Int_precision + n - 1;
-
-
- for (i = 0; i<INV_LONG_CX_ROT_LENGTH >> 1; i++)
- {
-
- Int16 temp_im_0 = *(px_4++);
- Int16 temp_re_1 = *(px_4++);
- Int16 temp_im_2 = *(px_4++);
- Int16 temp_re_3 = *(px_4++);
- *(px_3--) = temp_im_0;
- *(px_3--) = temp_re_1;
- *(px_3--) = temp_im_2;
- *(px_3--) = temp_re_3;
-
- }
-
-
- return (exp + 1);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h b/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h
deleted file mode 100644
index 8b95867..0000000
--- a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_long_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function inv_long_complex_rot()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INV_LONG_COMPLEX_ROT_H
-#define INV_LONG_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define INV_LONG_CX_ROT_LENGTH 256
-#define TWICE_INV_LONG_CX_ROT_LENGTH (INV_LONG_CX_ROT_LENGTH<<1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int inv_long_complex_rot(
- Int32 *Data,
- Int32 max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* INV_LONG_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp b/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp
deleted file mode 100644
index 5b4f1c5..0000000
--- a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_short_complex_rot.c
- Funtions: inv_short_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
- (1) Change the input argument, only a single max is passed.
- (2) Eliminate search for max, a fixed shift has replaced the
- search for max with minimal loss of precision.
- (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
- (1) Added comments per code review
- (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Data_in = Input vector (sized for short windows
- 2*INV_SHORT_CX_ROT_LENGTH elements), with time domain samples
- type Int32 *
-
- Data_out = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)),
- (sized for short windows 2*INV_SHORT_CX_ROT_LENGTH)
- type Int32 *
-
- max = Input, carries the maximum value of the input vector
- "Data_in"
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
- Results are return in "Data_out"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- inv_short_complex_rot() performs the complex rotation for the inverse MDCT
- for the case of short windows. It performs digit reverse ordering as well
- word normalization to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- inv_short_complex_rot() should execute a post-rotation by
- exp( j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "inv_short_complex_rot.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-Int inv_short_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max)
-
-{
- Int i;
- Int16 I;
- const Int16 *pTable;
- const Int32 *p_rotate;
-
- Int32 *pData_in_1;
- Int exp;
- Int32 temp_re;
- Int32 temp_im;
-
- Int32 exp_jw;
- Int16 *pData_re;
- Int16 *pData_im;
- Int32 *pData_in_ref;
-
- Int16 temp_re_0;
- Int16 temp_im_0;
- Int16 temp_re_1;
- Int16 temp_im_1;
- Int16 *p_data_1;
- Int16 *p_data_2;
- Int16 *p_Data_Int_precision;
- Int16 *p_Data_Int_precision_1;
- Int16 *p_Data_Int_precision_2;
-
- Int n = 256;
- Int n_2 = n >> 1;
- Int n_4 = n >> 2;
- Int n_8 = n >> 3;
- Int n_3_4 = n_2 + n_4;
-
-
- p_data_1 = (Int16 *)Data_out;
- p_data_1 += n;
- pData_re = p_data_1;
- pData_im = p_data_1 + n_4;
-
-
- p_rotate = exp_rotation_N_256;
- pTable = digit_reverse_64;
-
- pData_in_ref = Data_in;
-
- exp = 16 - pv_normalize(max);
-
-
- if (exp < 0)
- {
- exp = 0;
- }
-
- exp -= 1;
-
- for (i = INV_SHORT_CX_ROT_LENGTH; i != 0; i--)
- {
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- /*
- * Perform digit reversal by accessing index I from table
- */
-
- I = *pTable++;
- pData_in_1 = pData_in_ref + I;
- /*
- * Use auxiliary variables to avoid double accesses to memory.
- * Data in is scaled to use only lower 16 bits.
- */
-
- temp_im = *(pData_in_1++);
- temp_re = *(pData_in_1);
-
- exp_jw = *p_rotate++;
-
- /*
- * Post-rotation
- */
-
- *(pData_re++) = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
- *(pData_im++) = (Int16)(cmplx_mul32_by_16(temp_im, temp_re, exp_jw) >> exp);
- }
-
-
- p_data_2 = pData_im - 1;
-
-
- p_Data_Int_precision = (Int16 *)Data_out;
- p_Data_Int_precision_1 = p_Data_Int_precision + n_3_4 - 1;
- p_Data_Int_precision_2 = p_Data_Int_precision + n_3_4;
-
- for (i = n_8 >> 1; i != 0; i--)
- {
- temp_re_0 = (*(p_data_1++));
- temp_re_1 = (*(p_data_1++));
- temp_im_0 = (*(p_data_2--));
- temp_im_1 = (*(p_data_2--));
-
- *(p_Data_Int_precision_1--) = temp_re_0;
- *(p_Data_Int_precision_1--) = temp_im_0;
- *(p_Data_Int_precision_1--) = temp_re_1;
- *(p_Data_Int_precision_1--) = temp_im_1;
-
- *(p_Data_Int_precision_2++) = temp_re_0;
- *(p_Data_Int_precision_2++) = temp_im_0;
- *(p_Data_Int_precision_2++) = temp_re_1;
- *(p_Data_Int_precision_2++) = temp_im_1;
-
- }
-
-
- /*
- * loop is split to avoid conditional testing inside loop
- */
-
- p_Data_Int_precision_2 = p_Data_Int_precision;
-
- for (i = n_8 >> 1; i != 0; i--)
- {
-
- temp_re_0 = (*(p_data_1++));
- temp_re_1 = (*(p_data_1++));
- temp_im_0 = (*(p_data_2--));
- temp_im_1 = (*(p_data_2--));
-
- *(p_Data_Int_precision_1--) = temp_re_0;
- *(p_Data_Int_precision_1--) = temp_im_0;
- *(p_Data_Int_precision_1--) = temp_re_1;
- *(p_Data_Int_precision_1--) = temp_im_1;
-
- *(p_Data_Int_precision_2++) = (Int16)(-temp_re_0);
- *(p_Data_Int_precision_2++) = (Int16)(-temp_im_0);
- *(p_Data_Int_precision_2++) = (Int16)(-temp_re_1);
- *(p_Data_Int_precision_2++) = (Int16)(-temp_im_1);
-
- }
-
- return (exp + 1);
-}
diff --git a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h b/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h
deleted file mode 100644
index 97ed730..0000000
--- a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_short_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions inv_short_complex_rot()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INV_SHORT_COMPLEX_ROT_H
-#define INV_SHORT_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define INV_SHORT_CX_ROT_LENGTH 64
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int inv_short_complex_rot(
- Int32 *Data_in,
- Int32 *Data_out,
- Int32 max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* INV_SHORT_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/iquant_table.cpp b/media/libstagefright/codecs/aacdec/iquant_table.cpp
deleted file mode 100644
index aee47d6..0000000
--- a/media/libstagefright/codecs/aacdec/iquant_table.cpp
+++ /dev/null
@@ -1,1131 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: iquant_table.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- None, just contains tables.
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Holds a table used for esc_iquant, containing the values of x^1/3 in
- Q format.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
- of moving pictures and associated audio information - Part 7: Advanced
- Audio Coding (AAC)", Section 10.3, "Decoding process", page 43.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
- None.
-
-------------------------------------------------------------------------------
- RESOURCES USED
- None.
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "iquant_table.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*
- This table contains the value of x ^ (1/3) where x is in the range of
- [0..1024], in Q27 format.
- Note that the length of the table is 1025, and not 1024 - this is because
- the function esc_iquant may need to do an interpolation for numbers near
- 8191, which in that case it needs to get 8192 ^(1/3).
- */
-const UInt32 inverseQuantTable[] =
-{
- 0x00000000, /* 0 */
- 0x08000000, /* 1 */
- 0x0a14517d, /* 2 */
- 0x0b89ba25, /* 3 */
- 0x0cb2ff53, /* 4 */
- 0x0dae07de, /* 5 */
- 0x0e897685, /* 6 */
- 0x0f4daedd, /* 7 */
- 0x10000000, /* 8 */
- 0x10a402fd, /* 9 */
- 0x113c4841, /* 10 */
- 0x11cab613, /* 11 */
- 0x1250bfe2, /* 12 */
- 0x12cf8890, /* 13 */
- 0x1347f8ab, /* 14 */
- 0x13bacd65, /* 15 */
- 0x1428a2fa, /* 16 */
- 0x1491fc15, /* 17 */
- 0x14f74744, /* 18 */
- 0x1558e2f7, /* 19 */
- 0x15b72095, /* 20 */
- 0x161246d7, /* 21 */
- 0x166a9399, /* 22 */
- 0x16c03d55, /* 23 */
- 0x17137449, /* 24 */
- 0x17646369, /* 25 */
- 0x17b33124, /* 26 */
- 0x18000000, /* 27 */
- 0x184aef29, /* 28 */
- 0x18941ad8, /* 29 */
- 0x18db9cb7, /* 30 */
- 0x19218c2e, /* 31 */
- 0x1965fea5, /* 32 */
- 0x19a907c2, /* 33 */
- 0x19eab998, /* 34 */
- 0x1a2b24d0, /* 35 */
- 0x1a6a58d5, /* 36 */
- 0x1aa863ee, /* 37 */
- 0x1ae5535d, /* 38 */
- 0x1b213377, /* 39 */
- 0x1b5c0fbd, /* 40 */
- 0x1b95f2ec, /* 41 */
- 0x1bcee70f, /* 42 */
- 0x1c06f590, /* 43 */
- 0x1c3e2745, /* 44 */
- 0x1c74847a, /* 45 */
- 0x1caa1501, /* 46 */
- 0x1cdee035, /* 47 */
- 0x1d12ed0b, /* 48 */
- 0x1d464212, /* 49 */
- 0x1d78e582, /* 50 */
- 0x1daadd3a, /* 51 */
- 0x1ddc2ecf, /* 52 */
- 0x1e0cdf8c, /* 53 */
- 0x1e3cf476, /* 54 */
- 0x1e6c7257, /* 55 */
- 0x1e9b5dba, /* 56 */
- 0x1ec9baf6, /* 57 */
- 0x1ef78e2c, /* 58 */
- 0x1f24db4e, /* 59 */
- 0x1f51a620, /* 60 */
- 0x1f7df23c, /* 61 */
- 0x1fa9c314, /* 62 */
- 0x1fd51bf2, /* 63 */
- 0x20000000, /* 64 */
- 0x202a7244, /* 65 */
- 0x205475a6, /* 66 */
- 0x207e0cee, /* 67 */
- 0x20a73aca, /* 68 */
- 0x20d001cc, /* 69 */
- 0x20f8646d, /* 70 */
- 0x2120650e, /* 71 */
- 0x214805fa, /* 72 */
- 0x216f4963, /* 73 */
- 0x2196316c, /* 74 */
- 0x21bcc020, /* 75 */
- 0x21e2f77a, /* 76 */
- 0x2208d961, /* 77 */
- 0x222e67ad, /* 78 */
- 0x2253a425, /* 79 */
- 0x22789082, /* 80 */
- 0x229d2e6e, /* 81 */
- 0x22c17f82, /* 82 */
- 0x22e5854f, /* 83 */
- 0x23094155, /* 84 */
- 0x232cb509, /* 85 */
- 0x234fe1d5, /* 86 */
- 0x2372c918, /* 87 */
- 0x23956c26, /* 88 */
- 0x23b7cc47, /* 89 */
- 0x23d9eabb, /* 90 */
- 0x23fbc8b9, /* 91 */
- 0x241d676e, /* 92 */
- 0x243ec7ff, /* 93 */
- 0x245feb86, /* 94 */
- 0x2480d319, /* 95 */
- 0x24a17fc3, /* 96 */
- 0x24c1f28b, /* 97 */
- 0x24e22c6c, /* 98 */
- 0x25022e5f, /* 99 */
- 0x2521f954, /* 100 */
- 0x25418e33, /* 101 */
- 0x2560ede2, /* 102 */
- 0x2580193e, /* 103 */
- 0x259f111f, /* 104 */
- 0x25bdd657, /* 105 */
- 0x25dc69b4, /* 106 */
- 0x25facbfe, /* 107 */
- 0x2618fdf8, /* 108 */
- 0x26370060, /* 109 */
- 0x2654d3ef, /* 110 */
- 0x2672795c, /* 111 */
- 0x268ff156, /* 112 */
- 0x26ad3c8a, /* 113 */
- 0x26ca5ba2, /* 114 */
- 0x26e74f41, /* 115 */
- 0x27041808, /* 116 */
- 0x2720b695, /* 117 */
- 0x273d2b81, /* 118 */
- 0x27597762, /* 119 */
- 0x27759acb, /* 120 */
- 0x2791964b, /* 121 */
- 0x27ad6a6f, /* 122 */
- 0x27c917c0, /* 123 */
- 0x27e49ec5, /* 124 */
- 0x28000000, /* 125 */
- 0x281b3bf3, /* 126 */
- 0x2836531b, /* 127 */
- 0x285145f3, /* 128 */
- 0x286c14f5, /* 129 */
- 0x2886c096, /* 130 */
- 0x28a1494b, /* 131 */
- 0x28bbaf85, /* 132 */
- 0x28d5f3b3, /* 133 */
- 0x28f01641, /* 134 */
- 0x290a179b, /* 135 */
- 0x2923f82a, /* 136 */
- 0x293db854, /* 137 */
- 0x2957587e, /* 138 */
- 0x2970d90a, /* 139 */
- 0x298a3a59, /* 140 */
- 0x29a37cca, /* 141 */
- 0x29bca0bb, /* 142 */
- 0x29d5a687, /* 143 */
- 0x29ee8e87, /* 144 */
- 0x2a075914, /* 145 */
- 0x2a200684, /* 146 */
- 0x2a38972c, /* 147 */
- 0x2a510b5f, /* 148 */
- 0x2a696370, /* 149 */
- 0x2a819fae, /* 150 */
- 0x2a99c069, /* 151 */
- 0x2ab1c5ed, /* 152 */
- 0x2ac9b088, /* 153 */
- 0x2ae18085, /* 154 */
- 0x2af9362c, /* 155 */
- 0x2b10d1c6, /* 156 */
- 0x2b28539b, /* 157 */
- 0x2b3fbbef, /* 158 */
- 0x2b570b09, /* 159 */
- 0x2b6e412b, /* 160 */
- 0x2b855e97, /* 161 */
- 0x2b9c6390, /* 162 */
- 0x2bb35056, /* 163 */
- 0x2bca2527, /* 164 */
- 0x2be0e242, /* 165 */
- 0x2bf787e4, /* 166 */
- 0x2c0e1649, /* 167 */
- 0x2c248dad, /* 168 */
- 0x2c3aee4a, /* 169 */
- 0x2c513859, /* 170 */
- 0x2c676c13, /* 171 */
- 0x2c7d89af, /* 172 */
- 0x2c939164, /* 173 */
- 0x2ca98368, /* 174 */
- 0x2cbf5ff1, /* 175 */
- 0x2cd52731, /* 176 */
- 0x2cead95e, /* 177 */
- 0x2d0076a9, /* 178 */
- 0x2d15ff45, /* 179 */
- 0x2d2b7363, /* 180 */
- 0x2d40d332, /* 181 */
- 0x2d561ee4, /* 182 */
- 0x2d6b56a7, /* 183 */
- 0x2d807aaa, /* 184 */
- 0x2d958b19, /* 185 */
- 0x2daa8823, /* 186 */
- 0x2dbf71f4, /* 187 */
- 0x2dd448b7, /* 188 */
- 0x2de90c98, /* 189 */
- 0x2dfdbdc0, /* 190 */
- 0x2e125c5c, /* 191 */
- 0x2e26e892, /* 192 */
- 0x2e3b628d, /* 193 */
- 0x2e4fca75, /* 194 */
- 0x2e642070, /* 195 */
- 0x2e7864a8, /* 196 */
- 0x2e8c9741, /* 197 */
- 0x2ea0b862, /* 198 */
- 0x2eb4c831, /* 199 */
- 0x2ec8c6d3, /* 200 */
- 0x2edcb46c, /* 201 */
- 0x2ef09121, /* 202 */
- 0x2f045d14, /* 203 */
- 0x2f18186a, /* 204 */
- 0x2f2bc345, /* 205 */
- 0x2f3f5dc7, /* 206 */
- 0x2f52e812, /* 207 */
- 0x2f666247, /* 208 */
- 0x2f79cc88, /* 209 */
- 0x2f8d26f4, /* 210 */
- 0x2fa071ac, /* 211 */
- 0x2fb3acd0, /* 212 */
- 0x2fc6d87f, /* 213 */
- 0x2fd9f4d7, /* 214 */
- 0x2fed01f8, /* 215 */
- 0x30000000, /* 216 */
- 0x3012ef0c, /* 217 */
- 0x3025cf39, /* 218 */
- 0x3038a0a6, /* 219 */
- 0x304b636d, /* 220 */
- 0x305e17ad, /* 221 */
- 0x3070bd81, /* 222 */
- 0x30835504, /* 223 */
- 0x3095de51, /* 224 */
- 0x30a85985, /* 225 */
- 0x30bac6b9, /* 226 */
- 0x30cd2609, /* 227 */
- 0x30df778d, /* 228 */
- 0x30f1bb60, /* 229 */
- 0x3103f19c, /* 230 */
- 0x31161a59, /* 231 */
- 0x312835b0, /* 232 */
- 0x313a43ba, /* 233 */
- 0x314c4490, /* 234 */
- 0x315e3849, /* 235 */
- 0x31701efd, /* 236 */
- 0x3181f8c4, /* 237 */
- 0x3193c5b4, /* 238 */
- 0x31a585e6, /* 239 */
- 0x31b7396f, /* 240 */
- 0x31c8e066, /* 241 */
- 0x31da7ae1, /* 242 */
- 0x31ec08f6, /* 243 */
- 0x31fd8abc, /* 244 */
- 0x320f0047, /* 245 */
- 0x322069ac, /* 246 */
- 0x3231c702, /* 247 */
- 0x3243185c, /* 248 */
- 0x32545dcf, /* 249 */
- 0x32659770, /* 250 */
- 0x3276c552, /* 251 */
- 0x3287e78a, /* 252 */
- 0x3298fe2c, /* 253 */
- 0x32aa094a, /* 254 */
- 0x32bb08f9, /* 255 */
- 0x32cbfd4a, /* 256 */
- 0x32dce652, /* 257 */
- 0x32edc423, /* 258 */
- 0x32fe96d0, /* 259 */
- 0x330f5e6a, /* 260 */
- 0x33201b04, /* 261 */
- 0x3330ccb0, /* 262 */
- 0x33417380, /* 263 */
- 0x33520f85, /* 264 */
- 0x3362a0d0, /* 265 */
- 0x33732774, /* 266 */
- 0x3383a380, /* 267 */
- 0x33941506, /* 268 */
- 0x33a47c17, /* 269 */
- 0x33b4d8c4, /* 270 */
- 0x33c52b1b, /* 271 */
- 0x33d5732f, /* 272 */
- 0x33e5b10f, /* 273 */
- 0x33f5e4ca, /* 274 */
- 0x34060e71, /* 275 */
- 0x34162e14, /* 276 */
- 0x342643c1, /* 277 */
- 0x34364f88, /* 278 */
- 0x34465178, /* 279 */
- 0x345649a1, /* 280 */
- 0x34663810, /* 281 */
- 0x34761cd6, /* 282 */
- 0x3485f800, /* 283 */
- 0x3495c99d, /* 284 */
- 0x34a591bb, /* 285 */
- 0x34b55069, /* 286 */
- 0x34c505b4, /* 287 */
- 0x34d4b1ab, /* 288 */
- 0x34e4545b, /* 289 */
- 0x34f3edd2, /* 290 */
- 0x35037e1d, /* 291 */
- 0x3513054b, /* 292 */
- 0x35228367, /* 293 */
- 0x3531f881, /* 294 */
- 0x354164a3, /* 295 */
- 0x3550c7dc, /* 296 */
- 0x35602239, /* 297 */
- 0x356f73c5, /* 298 */
- 0x357ebc8e, /* 299 */
- 0x358dfca0, /* 300 */
- 0x359d3408, /* 301 */
- 0x35ac62d1, /* 302 */
- 0x35bb8908, /* 303 */
- 0x35caa6b9, /* 304 */
- 0x35d9bbf0, /* 305 */
- 0x35e8c8b9, /* 306 */
- 0x35f7cd20, /* 307 */
- 0x3606c92f, /* 308 */
- 0x3615bcf3, /* 309 */
- 0x3624a878, /* 310 */
- 0x36338bc8, /* 311 */
- 0x364266ee, /* 312 */
- 0x365139f6, /* 313 */
- 0x366004ec, /* 314 */
- 0x366ec7d9, /* 315 */
- 0x367d82c9, /* 316 */
- 0x368c35c6, /* 317 */
- 0x369ae0dc, /* 318 */
- 0x36a98414, /* 319 */
- 0x36b81f7a, /* 320 */
- 0x36c6b317, /* 321 */
- 0x36d53ef7, /* 322 */
- 0x36e3c323, /* 323 */
- 0x36f23fa5, /* 324 */
- 0x3700b488, /* 325 */
- 0x370f21d5, /* 326 */
- 0x371d8797, /* 327 */
- 0x372be5d7, /* 328 */
- 0x373a3ca0, /* 329 */
- 0x37488bf9, /* 330 */
- 0x3756d3ef, /* 331 */
- 0x37651489, /* 332 */
- 0x37734dd1, /* 333 */
- 0x37817fd1, /* 334 */
- 0x378faa92, /* 335 */
- 0x379dce1d, /* 336 */
- 0x37abea7c, /* 337 */
- 0x37b9ffb7, /* 338 */
- 0x37c80dd7, /* 339 */
- 0x37d614e6, /* 340 */
- 0x37e414ec, /* 341 */
- 0x37f20df1, /* 342 */
- 0x38000000, /* 343 */
- 0x380deb20, /* 344 */
- 0x381bcf5a, /* 345 */
- 0x3829acb6, /* 346 */
- 0x3837833d, /* 347 */
- 0x384552f8, /* 348 */
- 0x38531bee, /* 349 */
- 0x3860de28, /* 350 */
- 0x386e99af, /* 351 */
- 0x387c4e89, /* 352 */
- 0x3889fcc0, /* 353 */
- 0x3897a45b, /* 354 */
- 0x38a54563, /* 355 */
- 0x38b2dfdf, /* 356 */
- 0x38c073d7, /* 357 */
- 0x38ce0152, /* 358 */
- 0x38db885a, /* 359 */
- 0x38e908f4, /* 360 */
- 0x38f68329, /* 361 */
- 0x3903f701, /* 362 */
- 0x39116483, /* 363 */
- 0x391ecbb6, /* 364 */
- 0x392c2ca1, /* 365 */
- 0x3939874d, /* 366 */
- 0x3946dbc0, /* 367 */
- 0x39542a01, /* 368 */
- 0x39617218, /* 369 */
- 0x396eb40c, /* 370 */
- 0x397befe4, /* 371 */
- 0x398925a7, /* 372 */
- 0x3996555c, /* 373 */
- 0x39a37f09, /* 374 */
- 0x39b0a2b7, /* 375 */
- 0x39bdc06a, /* 376 */
- 0x39cad82b, /* 377 */
- 0x39d7ea01, /* 378 */
- 0x39e4f5f0, /* 379 */
- 0x39f1fc01, /* 380 */
- 0x39fefc3a, /* 381 */
- 0x3a0bf6a2, /* 382 */
- 0x3a18eb3e, /* 383 */
- 0x3a25da16, /* 384 */
- 0x3a32c32f, /* 385 */
- 0x3a3fa691, /* 386 */
- 0x3a4c8441, /* 387 */
- 0x3a595c46, /* 388 */
- 0x3a662ea6, /* 389 */
- 0x3a72fb67, /* 390 */
- 0x3a7fc28f, /* 391 */
- 0x3a8c8425, /* 392 */
- 0x3a99402e, /* 393 */
- 0x3aa5f6b1, /* 394 */
- 0x3ab2a7b3, /* 395 */
- 0x3abf533a, /* 396 */
- 0x3acbf94d, /* 397 */
- 0x3ad899f1, /* 398 */
- 0x3ae5352c, /* 399 */
- 0x3af1cb03, /* 400 */
- 0x3afe5b7d, /* 401 */
- 0x3b0ae6a0, /* 402 */
- 0x3b176c70, /* 403 */
- 0x3b23ecf3, /* 404 */
- 0x3b306830, /* 405 */
- 0x3b3cde2c, /* 406 */
- 0x3b494eeb, /* 407 */
- 0x3b55ba74, /* 408 */
- 0x3b6220cc, /* 409 */
- 0x3b6e81f9, /* 410 */
- 0x3b7ade00, /* 411 */
- 0x3b8734e5, /* 412 */
- 0x3b9386b0, /* 413 */
- 0x3b9fd364, /* 414 */
- 0x3bac1b07, /* 415 */
- 0x3bb85d9e, /* 416 */
- 0x3bc49b2f, /* 417 */
- 0x3bd0d3be, /* 418 */
- 0x3bdd0751, /* 419 */
- 0x3be935ed, /* 420 */
- 0x3bf55f97, /* 421 */
- 0x3c018453, /* 422 */
- 0x3c0da427, /* 423 */
- 0x3c19bf17, /* 424 */
- 0x3c25d52a, /* 425 */
- 0x3c31e662, /* 426 */
- 0x3c3df2c6, /* 427 */
- 0x3c49fa5b, /* 428 */
- 0x3c55fd24, /* 429 */
- 0x3c61fb27, /* 430 */
- 0x3c6df468, /* 431 */
- 0x3c79e8ed, /* 432 */
- 0x3c85d8b9, /* 433 */
- 0x3c91c3d2, /* 434 */
- 0x3c9daa3c, /* 435 */
- 0x3ca98bfc, /* 436 */
- 0x3cb56915, /* 437 */
- 0x3cc1418e, /* 438 */
- 0x3ccd156a, /* 439 */
- 0x3cd8e4ae, /* 440 */
- 0x3ce4af5e, /* 441 */
- 0x3cf0757f, /* 442 */
- 0x3cfc3714, /* 443 */
- 0x3d07f423, /* 444 */
- 0x3d13acb0, /* 445 */
- 0x3d1f60bf, /* 446 */
- 0x3d2b1055, /* 447 */
- 0x3d36bb75, /* 448 */
- 0x3d426224, /* 449 */
- 0x3d4e0466, /* 450 */
- 0x3d59a23f, /* 451 */
- 0x3d653bb4, /* 452 */
- 0x3d70d0c8, /* 453 */
- 0x3d7c6180, /* 454 */
- 0x3d87ede0, /* 455 */
- 0x3d9375ec, /* 456 */
- 0x3d9ef9a8, /* 457 */
- 0x3daa7918, /* 458 */
- 0x3db5f43f, /* 459 */
- 0x3dc16b23, /* 460 */
- 0x3dccddc7, /* 461 */
- 0x3dd84c2e, /* 462 */
- 0x3de3b65d, /* 463 */
- 0x3def1c58, /* 464 */
- 0x3dfa7e22, /* 465 */
- 0x3e05dbc0, /* 466 */
- 0x3e113535, /* 467 */
- 0x3e1c8a85, /* 468 */
- 0x3e27dbb3, /* 469 */
- 0x3e3328c4, /* 470 */
- 0x3e3e71bb, /* 471 */
- 0x3e49b69c, /* 472 */
- 0x3e54f76b, /* 473 */
- 0x3e60342b, /* 474 */
- 0x3e6b6ce0, /* 475 */
- 0x3e76a18d, /* 476 */
- 0x3e81d237, /* 477 */
- 0x3e8cfee0, /* 478 */
- 0x3e98278d, /* 479 */
- 0x3ea34c40, /* 480 */
- 0x3eae6cfe, /* 481 */
- 0x3eb989ca, /* 482 */
- 0x3ec4a2a8, /* 483 */
- 0x3ecfb79a, /* 484 */
- 0x3edac8a5, /* 485 */
- 0x3ee5d5cb, /* 486 */
- 0x3ef0df10, /* 487 */
- 0x3efbe478, /* 488 */
- 0x3f06e606, /* 489 */
- 0x3f11e3be, /* 490 */
- 0x3f1cdda2, /* 491 */
- 0x3f27d3b6, /* 492 */
- 0x3f32c5fd, /* 493 */
- 0x3f3db47b, /* 494 */
- 0x3f489f32, /* 495 */
- 0x3f538627, /* 496 */
- 0x3f5e695c, /* 497 */
- 0x3f6948d5, /* 498 */
- 0x3f742494, /* 499 */
- 0x3f7efc9d, /* 500 */
- 0x3f89d0f3, /* 501 */
- 0x3f94a19a, /* 502 */
- 0x3f9f6e94, /* 503 */
- 0x3faa37e4, /* 504 */
- 0x3fb4fd8e, /* 505 */
- 0x3fbfbf94, /* 506 */
- 0x3fca7dfb, /* 507 */
- 0x3fd538c4, /* 508 */
- 0x3fdfeff3, /* 509 */
- 0x3feaa38a, /* 510 */
- 0x3ff5538e, /* 511 */
- 0x40000000, /* 512 */
- 0x400aa8e4, /* 513 */
- 0x40154e3d, /* 514 */
- 0x401ff00d, /* 515 */
- 0x402a8e58, /* 516 */
- 0x40352921, /* 517 */
- 0x403fc06a, /* 518 */
- 0x404a5436, /* 519 */
- 0x4054e488, /* 520 */
- 0x405f7164, /* 521 */
- 0x4069facb, /* 522 */
- 0x407480c1, /* 523 */
- 0x407f0348, /* 524 */
- 0x40898264, /* 525 */
- 0x4093fe16, /* 526 */
- 0x409e7663, /* 527 */
- 0x40a8eb4c, /* 528 */
- 0x40b35cd4, /* 529 */
- 0x40bdcafe, /* 530 */
- 0x40c835cd, /* 531 */
- 0x40d29d43, /* 532 */
- 0x40dd0164, /* 533 */
- 0x40e76231, /* 534 */
- 0x40f1bfae, /* 535 */
- 0x40fc19dc, /* 536 */
- 0x410670c0, /* 537 */
- 0x4110c45a, /* 538 */
- 0x411b14af, /* 539 */
- 0x412561c0, /* 540 */
- 0x412fab90, /* 541 */
- 0x4139f222, /* 542 */
- 0x41443578, /* 543 */
- 0x414e7595, /* 544 */
- 0x4158b27a, /* 545 */
- 0x4162ec2c, /* 546 */
- 0x416d22ac, /* 547 */
- 0x417755fd, /* 548 */
- 0x41818621, /* 549 */
- 0x418bb31a, /* 550 */
- 0x4195dcec, /* 551 */
- 0x41a00399, /* 552 */
- 0x41aa2722, /* 553 */
- 0x41b4478b, /* 554 */
- 0x41be64d6, /* 555 */
- 0x41c87f05, /* 556 */
- 0x41d2961a, /* 557 */
- 0x41dcaa19, /* 558 */
- 0x41e6bb03, /* 559 */
- 0x41f0c8db, /* 560 */
- 0x41fad3a3, /* 561 */
- 0x4204db5d, /* 562 */
- 0x420ee00c, /* 563 */
- 0x4218e1b1, /* 564 */
- 0x4222e051, /* 565 */
- 0x422cdbeb, /* 566 */
- 0x4236d484, /* 567 */
- 0x4240ca1d, /* 568 */
- 0x424abcb8, /* 569 */
- 0x4254ac58, /* 570 */
- 0x425e98fe, /* 571 */
- 0x426882ae, /* 572 */
- 0x42726969, /* 573 */
- 0x427c4d31, /* 574 */
- 0x42862e09, /* 575 */
- 0x42900bf3, /* 576 */
- 0x4299e6f1, /* 577 */
- 0x42a3bf05, /* 578 */
- 0x42ad9432, /* 579 */
- 0x42b76678, /* 580 */
- 0x42c135dc, /* 581 */
- 0x42cb025e, /* 582 */
- 0x42d4cc01, /* 583 */
- 0x42de92c7, /* 584 */
- 0x42e856b2, /* 585 */
- 0x42f217c4, /* 586 */
- 0x42fbd5ff, /* 587 */
- 0x43059166, /* 588 */
- 0x430f49f9, /* 589 */
- 0x4318ffbc, /* 590 */
- 0x4322b2b1, /* 591 */
- 0x432c62d8, /* 592 */
- 0x43361036, /* 593 */
- 0x433fbaca, /* 594 */
- 0x43496298, /* 595 */
- 0x435307a2, /* 596 */
- 0x435ca9e8, /* 597 */
- 0x4366496e, /* 598 */
- 0x436fe636, /* 599 */
- 0x43798041, /* 600 */
- 0x43831790, /* 601 */
- 0x438cac28, /* 602 */
- 0x43963e08, /* 603 */
- 0x439fcd33, /* 604 */
- 0x43a959ab, /* 605 */
- 0x43b2e372, /* 606 */
- 0x43bc6a89, /* 607 */
- 0x43c5eef3, /* 608 */
- 0x43cf70b2, /* 609 */
- 0x43d8efc7, /* 610 */
- 0x43e26c34, /* 611 */
- 0x43ebe5fb, /* 612 */
- 0x43f55d1e, /* 613 */
- 0x43fed19f, /* 614 */
- 0x44084380, /* 615 */
- 0x4411b2c1, /* 616 */
- 0x441b1f66, /* 617 */
- 0x44248970, /* 618 */
- 0x442df0e1, /* 619 */
- 0x443755bb, /* 620 */
- 0x4440b7fe, /* 621 */
- 0x444a17ae, /* 622 */
- 0x445374cc, /* 623 */
- 0x445ccf5a, /* 624 */
- 0x44662758, /* 625 */
- 0x446f7ccb, /* 626 */
- 0x4478cfb2, /* 627 */
- 0x4482200f, /* 628 */
- 0x448b6de5, /* 629 */
- 0x4494b935, /* 630 */
- 0x449e0201, /* 631 */
- 0x44a7484b, /* 632 */
- 0x44b08c13, /* 633 */
- 0x44b9cd5d, /* 634 */
- 0x44c30c29, /* 635 */
- 0x44cc4879, /* 636 */
- 0x44d5824f, /* 637 */
- 0x44deb9ac, /* 638 */
- 0x44e7ee93, /* 639 */
- 0x44f12105, /* 640 */
- 0x44fa5103, /* 641 */
- 0x45037e8f, /* 642 */
- 0x450ca9ab, /* 643 */
- 0x4515d258, /* 644 */
- 0x451ef899, /* 645 */
- 0x45281c6e, /* 646 */
- 0x45313dd8, /* 647 */
- 0x453a5cdb, /* 648 */
- 0x45437977, /* 649 */
- 0x454c93ae, /* 650 */
- 0x4555ab82, /* 651 */
- 0x455ec0f3, /* 652 */
- 0x4567d404, /* 653 */
- 0x4570e4b7, /* 654 */
- 0x4579f30c, /* 655 */
- 0x4582ff05, /* 656 */
- 0x458c08a4, /* 657 */
- 0x45950fea, /* 658 */
- 0x459e14d9, /* 659 */
- 0x45a71773, /* 660 */
- 0x45b017b8, /* 661 */
- 0x45b915aa, /* 662 */
- 0x45c2114c, /* 663 */
- 0x45cb0a9e, /* 664 */
- 0x45d401a1, /* 665 */
- 0x45dcf658, /* 666 */
- 0x45e5e8c4, /* 667 */
- 0x45eed8e6, /* 668 */
- 0x45f7c6c0, /* 669 */
- 0x4600b253, /* 670 */
- 0x46099ba0, /* 671 */
- 0x461282a9, /* 672 */
- 0x461b6770, /* 673 */
- 0x462449f6, /* 674 */
- 0x462d2a3c, /* 675 */
- 0x46360844, /* 676 */
- 0x463ee40f, /* 677 */
- 0x4647bd9f, /* 678 */
- 0x465094f5, /* 679 */
- 0x46596a12, /* 680 */
- 0x46623cf8, /* 681 */
- 0x466b0da8, /* 682 */
- 0x4673dc24, /* 683 */
- 0x467ca86c, /* 684 */
- 0x46857283, /* 685 */
- 0x468e3a69, /* 686 */
- 0x46970021, /* 687 */
- 0x469fc3ab, /* 688 */
- 0x46a88509, /* 689 */
- 0x46b1443b, /* 690 */
- 0x46ba0144, /* 691 */
- 0x46c2bc25, /* 692 */
- 0x46cb74df, /* 693 */
- 0x46d42b74, /* 694 */
- 0x46dcdfe4, /* 695 */
- 0x46e59231, /* 696 */
- 0x46ee425c, /* 697 */
- 0x46f6f068, /* 698 */
- 0x46ff9c54, /* 699 */
- 0x47084622, /* 700 */
- 0x4710edd4, /* 701 */
- 0x4719936b, /* 702 */
- 0x472236e7, /* 703 */
- 0x472ad84b, /* 704 */
- 0x47337798, /* 705 */
- 0x473c14cf, /* 706 */
- 0x4744aff1, /* 707 */
- 0x474d48ff, /* 708 */
- 0x4755dffb, /* 709 */
- 0x475e74e6, /* 710 */
- 0x476707c1, /* 711 */
- 0x476f988e, /* 712 */
- 0x4778274d, /* 713 */
- 0x4780b400, /* 714 */
- 0x47893ea8, /* 715 */
- 0x4791c746, /* 716 */
- 0x479a4ddc, /* 717 */
- 0x47a2d26b, /* 718 */
- 0x47ab54f3, /* 719 */
- 0x47b3d577, /* 720 */
- 0x47bc53f7, /* 721 */
- 0x47c4d074, /* 722 */
- 0x47cd4af0, /* 723 */
- 0x47d5c36c, /* 724 */
- 0x47de39e9, /* 725 */
- 0x47e6ae69, /* 726 */
- 0x47ef20ec, /* 727 */
- 0x47f79173, /* 728 */
- 0x48000000, /* 729 */
- 0x48086c94, /* 730 */
- 0x4810d730, /* 731 */
- 0x48193fd5, /* 732 */
- 0x4821a685, /* 733 */
- 0x482a0b40, /* 734 */
- 0x48326e07, /* 735 */
- 0x483acedd, /* 736 */
- 0x48432dc1, /* 737 */
- 0x484b8ab5, /* 738 */
- 0x4853e5bb, /* 739 */
- 0x485c3ed2, /* 740 */
- 0x486495fd, /* 741 */
- 0x486ceb3c, /* 742 */
- 0x48753e91, /* 743 */
- 0x487d8ffd, /* 744 */
- 0x4885df80, /* 745 */
- 0x488e2d1d, /* 746 */
- 0x489678d3, /* 747 */
- 0x489ec2a4, /* 748 */
- 0x48a70a91, /* 749 */
- 0x48af509b, /* 750 */
- 0x48b794c4, /* 751 */
- 0x48bfd70c, /* 752 */
- 0x48c81774, /* 753 */
- 0x48d055fe, /* 754 */
- 0x48d892aa, /* 755 */
- 0x48e0cd7a, /* 756 */
- 0x48e9066e, /* 757 */
- 0x48f13d88, /* 758 */
- 0x48f972c9, /* 759 */
- 0x4901a632, /* 760 */
- 0x4909d7c3, /* 761 */
- 0x4912077e, /* 762 */
- 0x491a3564, /* 763 */
- 0x49226175, /* 764 */
- 0x492a8bb4, /* 765 */
- 0x4932b420, /* 766 */
- 0x493adabc, /* 767 */
- 0x4942ff87, /* 768 */
- 0x494b2283, /* 769 */
- 0x495343b1, /* 770 */
- 0x495b6312, /* 771 */
- 0x496380a7, /* 772 */
- 0x496b9c71, /* 773 */
- 0x4973b670, /* 774 */
- 0x497bcea7, /* 775 */
- 0x4983e515, /* 776 */
- 0x498bf9bc, /* 777 */
- 0x49940c9e, /* 778 */
- 0x499c1db9, /* 779 */
- 0x49a42d11, /* 780 */
- 0x49ac3aa5, /* 781 */
- 0x49b44677, /* 782 */
- 0x49bc5088, /* 783 */
- 0x49c458d8, /* 784 */
- 0x49cc5f69, /* 785 */
- 0x49d4643c, /* 786 */
- 0x49dc6750, /* 787 */
- 0x49e468a9, /* 788 */
- 0x49ec6845, /* 789 */
- 0x49f46627, /* 790 */
- 0x49fc624f, /* 791 */
- 0x4a045cbe, /* 792 */
- 0x4a0c5575, /* 793 */
- 0x4a144c76, /* 794 */
- 0x4a1c41c0, /* 795 */
- 0x4a243555, /* 796 */
- 0x4a2c2735, /* 797 */
- 0x4a341763, /* 798 */
- 0x4a3c05de, /* 799 */
- 0x4a43f2a7, /* 800 */
- 0x4a4bddc0, /* 801 */
- 0x4a53c729, /* 802 */
- 0x4a5baee3, /* 803 */
- 0x4a6394ef, /* 804 */
- 0x4a6b794f, /* 805 */
- 0x4a735c02, /* 806 */
- 0x4a7b3d09, /* 807 */
- 0x4a831c67, /* 808 */
- 0x4a8afa1b, /* 809 */
- 0x4a92d626, /* 810 */
- 0x4a9ab089, /* 811 */
- 0x4aa28946, /* 812 */
- 0x4aaa605d, /* 813 */
- 0x4ab235ce, /* 814 */
- 0x4aba099b, /* 815 */
- 0x4ac1dbc5, /* 816 */
- 0x4ac9ac4c, /* 817 */
- 0x4ad17b31, /* 818 */
- 0x4ad94876, /* 819 */
- 0x4ae1141a, /* 820 */
- 0x4ae8de1f, /* 821 */
- 0x4af0a686, /* 822 */
- 0x4af86d50, /* 823 */
- 0x4b00327d, /* 824 */
- 0x4b07f60d, /* 825 */
- 0x4b0fb803, /* 826 */
- 0x4b17785f, /* 827 */
- 0x4b1f3722, /* 828 */
- 0x4b26f44b, /* 829 */
- 0x4b2eafde, /* 830 */
- 0x4b3669d9, /* 831 */
- 0x4b3e223e, /* 832 */
- 0x4b45d90e, /* 833 */
- 0x4b4d8e4a, /* 834 */
- 0x4b5541f2, /* 835 */
- 0x4b5cf407, /* 836 */
- 0x4b64a48a, /* 837 */
- 0x4b6c537c, /* 838 */
- 0x4b7400dd, /* 839 */
- 0x4b7bacaf, /* 840 */
- 0x4b8356f2, /* 841 */
- 0x4b8affa7, /* 842 */
- 0x4b92a6ce, /* 843 */
- 0x4b9a4c69, /* 844 */
- 0x4ba1f079, /* 845 */
- 0x4ba992fd, /* 846 */
- 0x4bb133f8, /* 847 */
- 0x4bb8d369, /* 848 */
- 0x4bc07151, /* 849 */
- 0x4bc80db2, /* 850 */
- 0x4bcfa88c, /* 851 */
- 0x4bd741df, /* 852 */
- 0x4bded9ad, /* 853 */
- 0x4be66ff6, /* 854 */
- 0x4bee04bb, /* 855 */
- 0x4bf597fc, /* 856 */
- 0x4bfd29bc, /* 857 */
- 0x4c04b9f9, /* 858 */
- 0x4c0c48b6, /* 859 */
- 0x4c13d5f2, /* 860 */
- 0x4c1b61af, /* 861 */
- 0x4c22ebed, /* 862 */
- 0x4c2a74ad, /* 863 */
- 0x4c31fbf0, /* 864 */
- 0x4c3981b6, /* 865 */
- 0x4c410600, /* 866 */
- 0x4c4888d0, /* 867 */
- 0x4c500a25, /* 868 */
- 0x4c578a00, /* 869 */
- 0x4c5f0862, /* 870 */
- 0x4c66854c, /* 871 */
- 0x4c6e00bf, /* 872 */
- 0x4c757abb, /* 873 */
- 0x4c7cf341, /* 874 */
- 0x4c846a52, /* 875 */
- 0x4c8bdfee, /* 876 */
- 0x4c935416, /* 877 */
- 0x4c9ac6cb, /* 878 */
- 0x4ca2380e, /* 879 */
- 0x4ca9a7de, /* 880 */
- 0x4cb1163e, /* 881 */
- 0x4cb8832d, /* 882 */
- 0x4cbfeead, /* 883 */
- 0x4cc758bd, /* 884 */
- 0x4ccec15f, /* 885 */
- 0x4cd62894, /* 886 */
- 0x4cdd8e5c, /* 887 */
- 0x4ce4f2b7, /* 888 */
- 0x4cec55a7, /* 889 */
- 0x4cf3b72c, /* 890 */
- 0x4cfb1747, /* 891 */
- 0x4d0275f8, /* 892 */
- 0x4d09d340, /* 893 */
- 0x4d112f21, /* 894 */
- 0x4d188999, /* 895 */
- 0x4d1fe2ab, /* 896 */
- 0x4d273a57, /* 897 */
- 0x4d2e909d, /* 898 */
- 0x4d35e57f, /* 899 */
- 0x4d3d38fc, /* 900 */
- 0x4d448b16, /* 901 */
- 0x4d4bdbcd, /* 902 */
- 0x4d532b21, /* 903 */
- 0x4d5a7914, /* 904 */
- 0x4d61c5a7, /* 905 */
- 0x4d6910d9, /* 906 */
- 0x4d705aab, /* 907 */
- 0x4d77a31e, /* 908 */
- 0x4d7eea34, /* 909 */
- 0x4d862feb, /* 910 */
- 0x4d8d7445, /* 911 */
- 0x4d94b743, /* 912 */
- 0x4d9bf8e6, /* 913 */
- 0x4da3392d, /* 914 */
- 0x4daa7819, /* 915 */
- 0x4db1b5ac, /* 916 */
- 0x4db8f1e6, /* 917 */
- 0x4dc02cc7, /* 918 */
- 0x4dc76650, /* 919 */
- 0x4dce9e81, /* 920 */
- 0x4dd5d55c, /* 921 */
- 0x4ddd0ae1, /* 922 */
- 0x4de43f10, /* 923 */
- 0x4deb71eb, /* 924 */
- 0x4df2a371, /* 925 */
- 0x4df9d3a3, /* 926 */
- 0x4e010283, /* 927 */
- 0x4e083010, /* 928 */
- 0x4e0f5c4b, /* 929 */
- 0x4e168735, /* 930 */
- 0x4e1db0cf, /* 931 */
- 0x4e24d918, /* 932 */
- 0x4e2c0012, /* 933 */
- 0x4e3325bd, /* 934 */
- 0x4e3a4a1a, /* 935 */
- 0x4e416d2a, /* 936 */
- 0x4e488eec, /* 937 */
- 0x4e4faf62, /* 938 */
- 0x4e56ce8c, /* 939 */
- 0x4e5dec6b, /* 940 */
- 0x4e6508ff, /* 941 */
- 0x4e6c2449, /* 942 */
- 0x4e733e4a, /* 943 */
- 0x4e7a5702, /* 944 */
- 0x4e816e71, /* 945 */
- 0x4e888498, /* 946 */
- 0x4e8f9979, /* 947 */
- 0x4e96ad13, /* 948 */
- 0x4e9dbf67, /* 949 */
- 0x4ea4d075, /* 950 */
- 0x4eabe03e, /* 951 */
- 0x4eb2eec4, /* 952 */
- 0x4eb9fc05, /* 953 */
- 0x4ec10803, /* 954 */
- 0x4ec812bf, /* 955 */
- 0x4ecf1c39, /* 956 */
- 0x4ed62471, /* 957 */
- 0x4edd2b68, /* 958 */
- 0x4ee4311f, /* 959 */
- 0x4eeb3596, /* 960 */
- 0x4ef238cd, /* 961 */
- 0x4ef93ac6, /* 962 */
- 0x4f003b81, /* 963 */
- 0x4f073afe, /* 964 */
- 0x4f0e393f, /* 965 */
- 0x4f153642, /* 966 */
- 0x4f1c320a, /* 967 */
- 0x4f232c96, /* 968 */
- 0x4f2a25e8, /* 969 */
- 0x4f311dff, /* 970 */
- 0x4f3814dc, /* 971 */
- 0x4f3f0a80, /* 972 */
- 0x4f45feeb, /* 973 */
- 0x4f4cf21f, /* 974 */
- 0x4f53e41a, /* 975 */
- 0x4f5ad4de, /* 976 */
- 0x4f61c46c, /* 977 */
- 0x4f68b2c4, /* 978 */
- 0x4f6f9fe6, /* 979 */
- 0x4f768bd3, /* 980 */
- 0x4f7d768c, /* 981 */
- 0x4f846011, /* 982 */
- 0x4f8b4862, /* 983 */
- 0x4f922f81, /* 984 */
- 0x4f99156d, /* 985 */
- 0x4f9ffa27, /* 986 */
- 0x4fa6ddb0, /* 987 */
- 0x4fadc008, /* 988 */
- 0x4fb4a12f, /* 989 */
- 0x4fbb8127, /* 990 */
- 0x4fc25ff0, /* 991 */
- 0x4fc93d8a, /* 992 */
- 0x4fd019f5, /* 993 */
- 0x4fd6f533, /* 994 */
- 0x4fddcf43, /* 995 */
- 0x4fe4a827, /* 996 */
- 0x4feb7fde, /* 997 */
- 0x4ff2566a, /* 998 */
- 0x4ff92bca, /* 999 */
- 0x50000000, /* 1000 */
- 0x5006d30b, /* 1001 */
- 0x500da4ed, /* 1002 */
- 0x501475a5, /* 1003 */
- 0x501b4535, /* 1004 */
- 0x5022139c, /* 1005 */
- 0x5028e0dc, /* 1006 */
- 0x502facf4, /* 1007 */
- 0x503677e5, /* 1008 */
- 0x503d41b0, /* 1009 */
- 0x50440a55, /* 1010 */
- 0x504ad1d5, /* 1011 */
- 0x50519830, /* 1012 */
- 0x50585d67, /* 1013 */
- 0x505f217a, /* 1014 */
- 0x5065e469, /* 1015 */
- 0x506ca635, /* 1016 */
- 0x507366df, /* 1017 */
- 0x507a2667, /* 1018 */
- 0x5080e4cd, /* 1019 */
- 0x5087a212, /* 1020 */
- 0x508e5e37, /* 1021 */
- 0x5095193c, /* 1022 */
- 0x509bd320, /* 1023 */
- 0x50a28be6, /* 1024 */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
diff --git a/media/libstagefright/codecs/aacdec/iquant_table.h b/media/libstagefright/codecs/aacdec/iquant_table.h
deleted file mode 100644
index dadc3d0..0000000
--- a/media/libstagefright/codecs/aacdec/iquant_table.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: iquant_table.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for iquant_table.c, which contains a table used with
- esc_iquant.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IQUANT_TABLE_H
-#define IQUANT_TABLE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const UInt32 inverseQuantTable[];
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_prediction.cpp b/media/libstagefright/codecs/aacdec/long_term_prediction.cpp
deleted file mode 100644
index 69e4c46..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_prediction.cpp
+++ /dev/null
@@ -1,648 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_prediction.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes based on comments and experiment results.
-
- Description: Passed in buffer sizes based on review comments and prototype
- agreements.
-
- Description: 1. Passed in "weight_index" instead of "weight".
- 2. Added weight table.
-
- Description: 1. Removed some passed in buffer size variables since they are
- not used for long window.
- 2. Modified comments format.
-
- Description:
- Modified casting to ensure proper operations for different platforms
-
- Description:
- Implemented circular buffer techniques, which save 4096 memmoves per
- frame.
-
- Description:
- Implemented some optimizations found during the code review of this
- module. The optimizations related to the rules on the range of
- ltp_buffer_index and num_samples, which allows for a simpler
- code construct to be used in the processing of the predicted samples.
-
- Description:
- Add max calculation on the filter implementation, this to eliminate
- function buffer_adaptation() on the time to frequency transformation.
- Function interface changed. It now return the amount of shifting needed
- to garb only the top 16 MSB.
-
- Description:
- Replace clearing memory with for-loop with pvmemset function
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- win_seq = type of window sequence (WINDOW_SEQUENCE).
-
- weight_index = index (Int) of LTP coefficient table for all windows in
- current frame.
-
- delay = buffer (Int) containing delays for each window.
-
- buffer = history buffer (Int16) containing the reconstructed time domain
- signals of previous frames.
-
- buffer_offset = value (Int) that indicates the location of the first
- element in the LTP circular buffer. (Either 0 or 1024)
-
- time_quant = filterbank buffer (Int32) This buffer is used by the
- filterbank, but it's first 1024 elements are equivalent
- to the last 1024 elements in the conventionally
- implemented LTP buffer. Using this buffer directly avoids
- costly duplication of memory.
-
- predicted_samples = buffer (Int32) with length of 2048 to hold
- predicted time domain signals.
-
- buffer_index = index into buffer where the first sample of data from
- the frame (t-2) (two frames ago) resides. (Int)
-
- frame_length = length of one frame, type of Int.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- Amount of shifting needed to grab the top 16 MSB from teh predicted buffer
-
- Pointers and Buffers Modified:
- predicted_samples contents are the newly calculated predicted time
- domain signals
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Long term prediction (LTP) is used to reduce the redundancy of a signal
- between successive coding frames. This function performs prediction by
- applying 1-tap IIR filtering to calculate the predicted time domain
- signals of current frame from previous reconstructed frames stored in
- time domain history buffer.
-
- The equation used for IIR filter is as following.
-
- y(n) = weight * x(n - delay)
-
- where y(n) ----- predicted time domain signals
- x(n) ----- reconstructed time domain signals
- weight ----- LTP coefficient
- delay ----- optimal delay from 0 to 2047
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3: Audio
- Subpart 4.6.6 Long Term Prediction (LTP)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by Nokia in the course
- of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7,
- 14496-1, 2 and 3. This software module is an implementation of a part
- of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2
- aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4
- Audio standards free license to this software module or modifications
- thereof for use in hardware or software products claiming conformance
- to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this
- software module in hardware or software products are advised that this
- use may infringe existing patents. The original developer of this
- software module, the subsequent editors and their companies, and ISO/IEC
- have no liability for use of this software module or modifications
- thereof in an implementation. Copyright is not released for non MPEG-2
- aac/MPEG-4 Audio conforming products. The original developer retains
- full right to use the code for the developer's own purpose, assign or
- donate the code to a third party and to inhibit third party from using
- the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This
- copyright notice must be included in all copies or derivative works.
- Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pPredicted_samples = &predicted_samples[0];
-
- weight = codebook[weight_index];
-
- IF (win_seq != EIGHT_SHORT_SEQUENCE)
- THEN
-
- block_length = frame_length << 1;
-
- lag = delay[0];
-
- j = block_length - lag;
-
- IF (lag < frame_length)
- THEN
-
- num_samples = frame_length + lag;
-
- ELSE
-
- num_samples = block_length;
-
- ENDIF
-
- pBuffer = &buffer[j];
-
- FOR (i = num_samples; i>0; i--)
-
- *pPredicted_samples = weight * (*pBuffer);
- pPredicted_samples = pPredicted_samples + 1;
- pBuffer = pBuffer + 1;
-
- ENDFOR
-
- FOR (i = block_length - num_samples; i>0; i--)
-
- *pPredicted_samples = 0;
- pPredicted_samples = pPredicted_samples + 1;
-
- ENDFOR
-
- ELSE
-
- FOR (wnd = 0; wnd < short_window_num; wnd++)
-
- IF (win_prediction_used[wnd] != FALSE)
- THEN
-
- delay[wnd] = delay[0] + ltp_short_lag[wnd];
-
- lag = delay[wnd];
-
- j = wnd*short_block_length - lag;
-
- IF (lag < short_frame_length)
- THEN
-
- num_samples = short_frame_length + lag;
-
- ELSE
-
- num_samples = short_block_length;
-
- ENDIF
-
- pBuffer = &buffer[j];
-
- FOR (i = num_samples; i>0; i--)
-
- *pPredicted_samples = weight * (*pBuffer);
- pPredicted_samples = pPredicted_samples + 1;
- pBuffer = pBuffer + 1;
-
- ENDFOR
-
- FOR (i = short_block_length - num_samples; i>0; i--)
-
- *pPredicted_samples = 0;
- pPredicted_samples = pPredicted_samples + 1;
-
- ENDFOR
-
- ELSE
-
- CALL pv_memset(
- pPredicted_samples,
- 0,
- sizeof(*pPredicted_samples)*short_block_length);
- MODIFYING (predicted_samples[]);
-
- pPredicted_samples = pPredicted_samples + short_block_length;
-
- ENDIF [ IF (win_prediction_used[wnd] != FALSE) ]
-
- ENDFOR [ FOR (wnd=0; wnd<short_window_num; wnd++) ]
-
- ENDIF [ IF (win_seq != EIGHT_SHORT_SEQUENCE) ]
-
- RETURN
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "ltp_common_internal.h"
-#include "long_term_prediction.h"
-#include "aac_mem_funcs.h"
-#include "pv_normalize.h"
-#include "window_block_fxp.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/* Purpose: Codebook for LTP weight coefficients. Stored in Q15 format */
-const UInt codebook[CODESIZE] =
-{
- 18705, /* 0 */
- 22827, /* 1 */
- 26641, /* 2 */
- 29862, /* 3 */
- 32273, /* 4 */
- 34993, /* 5 */
- 39145, /* 6 */
- 44877 /* 7 */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int long_term_prediction(
- WINDOW_SEQUENCE win_seq,
- const Int weight_index,
- const Int delay[],
- const Int16 buffer[],
- const Int buffer_offset,
- const Int32 time_quant[],
- Int32 predicted_samples[], /* Q15 */
- const Int frame_length)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- /*
- * Window index
- *
- * Int wnd;
- *
- * will be enabled when short window information is available.
- */
-
- /* Pointer to time domain history buffer */
-
- const Int16 *pBuffer;
-
- const Int32 *pTimeQuant = time_quant;
-
- /* Pointer to array containing predicted samples */
- Int32 *pPredicted_samples;
-
- Int32 test;
- Int32 datum;
-
- /* IIR coefficient with Q15 format */
- UInt weight;
-
- /* Length of one block (two frames) */
- Int block_length;
-
- Int shift;
- Int k;
- Int ltp_buffer_index;
- Int jump_point;
- Int lag;
- Int num_samples;
-
- Int32 max = 0;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* Initialize pointers */
- pPredicted_samples = &predicted_samples[0];
-
- weight = codebook[weight_index];
-
- /****************************************/
- /* LTP decoding process for long window */
- /****************************************/
-
- if (win_seq != EIGHT_SHORT_SEQUENCE)
- {
- /****************************************************/
- /* Prediction based on previous time domain signals */
- /****************************************************/
- block_length = frame_length << 1;
-
- /* Calculate time lag for 1-tap IIR filter */
- lag = delay[0];
-
- ltp_buffer_index = block_length - lag;
-
- /* Calculate number of samples used in IIR filter */
- if (lag < frame_length)
- {
- num_samples = frame_length + lag;
- }
- else
- {
- num_samples = block_length;
- }
-
-
- /*
- * Calculate the predicted time domain signals from the
- * reconstructed time domain signals of previous frames.
- */
-
- /* The data is stored in TWO buffers, either as...
- *
- * [ t == 0 ]
- *
- * [ t == -1 ][ t == -2 ]
- *
- * OR...
- * [ t == 0 ]
- *
- * [ t == -2 ][ t == -1 ]
- *
- *
- *
- * In the first case, all of the buffers are non-contiguous,
- * and each must be handled separately. Code for this first case
- * will function correctly for both cases.
- *
- * In the second case, the buffers storing t == -2, and t == -1
- * data are contiguous, and an optimization could take advantage
- * of this, at the cost of an increase in code size for this function.
- */
-
- /* Decrement block_length by num_samples. This is important
- * for the loop at the end of the "ACCESS DATA IN THE LTP BUFFERS"
- * section that sets all remaining samples in the block to zero.
- */
-
- block_length -= num_samples;
-
-
-
-
-
-
- /*
- ************************************ ACCESS DATA IN THE LTP BUFFERS
- */
-
- /*
- * This section of the code handles the t == -2
- * buffer, which corresponds to 0 <= ltp_buffer_index < 1024
- *
- * BUFFER t == -2
- *
- * [0][][][][][][][][][][][...][][][][][][][][][][][][1023]
- *
- */
-
- jump_point = (frame_length - ltp_buffer_index);
-
- if (jump_point > 0)
- {
- pBuffer = &(buffer[ltp_buffer_index + buffer_offset]);
-
- for (k = jump_point; k > 0; k--)
- {
- /* Q15 = Q15 * Q0 */
- test = (Int32) weight * (*(pBuffer++));
- *(pPredicted_samples++) = test;
- max |= (test >> 31) ^ test;
- }
-
- num_samples -= jump_point;
-
- ltp_buffer_index += jump_point;
- }
-
- /*
- * This section of the code handles the t == -1
- * buffer, which corresponds to 1024 <= ltp_buffer_index < 2048
- *
- * BUFFER t == -1
- *
- * [1024][][][][][][][][][][][...][][][][][][][][][][][][2047]
- *
- */
-
- jump_point = 2 * frame_length - ltp_buffer_index;
-
- pBuffer = &(buffer[ltp_buffer_index - buffer_offset]);
-
- if (num_samples < jump_point)
- {
- jump_point = num_samples;
- }
-
- for (k = jump_point; k > 0; k--)
- {
- /* Q15 = Q15 * Q0 */
- test = (Int32) weight * (*(pBuffer++));
- *(pPredicted_samples++) = test;
- max |= (test >> 31) ^ test;
- }
-
- num_samples -= jump_point;
-
- ltp_buffer_index += jump_point;
-
- /*
- * This section of the code handles the t == 0
- * buffer, which corresponds to 2048 <= ltp_buffer_index < 3072
- *
- * BUFFER t == 0
- *
- * [2048][][][][][][][][][][][...][][][][][][][][][][][][3071]
- *
- */
- for (k = num_samples; k > 0; k--)
- {
-
- datum = *(pTimeQuant++) >> SCALING;
-
- /*
- * Limit the values in the 32-bit filterbank's buffer to
- * 16-bit resolution.
- *
- * Value's greater than 32767 or less than -32768 are saturated
- * to 32767 and -32768, respectively.
- */
-
- test = (Int32)datum * weight;
- *(pPredicted_samples++) = test;
- max |= (test >> 31) ^ test;
-
- }
-
- /* Set any remaining samples in the block to 0. */
-
- pv_memset(
- pPredicted_samples,
- 0,
- block_length*sizeof(*pPredicted_samples));
-
- } /* if (win_seq != EIGHT_SHORT_SEQUENCE) */
-
-
- /*****************************************/
- /* LTP decoding process for short window */
- /*****************************************/
-
- /*
- * For short window LTP, since there is no "ltp_short_lag"
- * information being passed, the following code for short
- * window LTP will be applied in the future when those
- * information are available.
- */
-
- /*
- *----------------------------------------------------------------------------
- * else
- * {
- * for (wnd = 0; wnd < short_window_num; wnd++)
- * {
- * if (win_prediction_used[wnd] != FALSE)
- * {
- * delay[wnd] = delay[0] + ltp_short_lag[wnd];
- *
- * lag = delay[wnd];
- *
- * j = wnd*short_block_length - lag;
- *
- * if (lag < short_frame_length)
- * {
- * num_samples = short_frame_length + lag;
- * }
- * else
- * {
- * num_samples = short_block_length;
- * }
- *
- * pBuffer = &buffer[j];
- *
- * for(i = num_samples; i>0; i--)
- * {
- * *(pPredicted_samples++) = weight * (*(pBuffer++));
- * }
- *
- * for(i = short_block_length - num_samples; i>0; i--)
- * {
- * *(pPredicted_samples++) = 0;
- * }
- * }
- * else
- * {
- * pv_memset(
- * pPredicted_samples,
- * 0,
- * sizeof(*pPredicted_samples)*short_block_length);
- *
- * pPredicted_samples += short_block_length;
- * }
- * }
- * }
- *----------------------------------------------------------------------------
- */
-
- shift = 16 - pv_normalize(max);
-
- if (shift < 0)
- {
- shift = 0;
- }
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return (shift);
-} /* long_term_prediction */
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_prediction.h b/media/libstagefright/codecs/aacdec/long_term_prediction.h
deleted file mode 100644
index 014934b..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_prediction.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_prediction.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified prototype with array size passed in per review
- comments.
-
- Description: Changed prototype with "weight_index" instead of "weight".
-
- Description: Removed some passed in buffer size variables since they are
- not being used for long window.
-
- Description: Temporarily define LTP_Q_FORMAT for current release.
- Need to change function prototype and pass out Q_format
- information later.
-
- Description: Updated function prototype to reflect the usage of a
- circular buffer by LTP.
-
- Description: Updated function interface with new return type
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function prototype declaration for long_term_prediction().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LONG_TERM_PREDICTION_H
-#define LONG_TERM_PREDICTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define LTP_Q_FORMAT (15)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- Int long_term_prediction(
- WINDOW_SEQUENCE win_seq,
- const Int weight_index,
- const Int delay[],
- const Int16 buffer[],
- const Int buffer_offset,
- const Int32 time_quant[],
- Int32 predicted_samples[], /* Q15 */
- const Int frame_length);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp b/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp
deleted file mode 100644
index c361db1..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp
+++ /dev/null
@@ -1,1158 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_synthesis.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made the following changes based on the review comments.
- 1. Separated "shift_factor>=0" on line 395 to "shift_factor>0"
- and "shift_factor=0" two cases.
- 2. Added comments on line 393 to explain why factor 2 is being
- used to calculate shift_factor.
- 3. Added comments for short window implementation.
- 4. Changed "*(pPredicted_spectral++) = *pPredicted_spectral>>2"
- to "*(pPredicted++)>>=2" although they are the same.
- 5. Changed pseudo code "X+=Y" to "X=X+Y".
- 6. Fixed ending comment of "for" loop.
- 7. Passed in the size of the array and deleted some of the
- include files.
-
- Description: Unroll the loops.
-
- Description: Changed index "wnd" in previous line 584 with "wnd_offset"
- and made other correspondent changes to the code.
-
-
- Description: Based on Ken's suggestion, modified the function with the
- passing-in Q format as scalefactor band basis in order to
- simplify TNS block functions.
-
- Description: Optimization.
-
- Description: Made changes based on review comments.
- 1. Changed misspellings.
- 2. Changed win_sfb_top[] from two dimensional array to one
- dimensional array and correspondently changed the code.
- 3. Changed function prototype to remove some redundant
- informations.
- 4. Fixed the adjusting Q format part code.
- 5. Fixed lines 825, 826 with correct updating pointers.
-
- Description: Due to TNS and LTP Q format issue, added code to adjust
- predicted_spectral() to maximum resolution before perform
- long term synthesis.
-
- Description: Modified based on review comments.
-
- Description: Changed "max" data type from UInt to UInt32.
-
- Description: Changed so that nothing is done for the case of "all zero"
- data coming from the output of Trans4m_time_2_freq. Also, included more
- efficient calculation of the abs(x). And, I updated the pseudocode.
-
- Description: Use an auxiliary variable temp, to avoid using the same
- pointer and a post-increment pointer in the same line. This may not
- work with all compilers.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- win_seq = type of window sequence (WINDOW_SEQUENCE).
- sfb_per_win = number of scalefactor bands for each window, 1024 for
- long window, 128 for short window, type of Int.
- win_sfb_top = buffer (Int16) containing the top coefficient per
- scalefactor band for each window.
- win_prediction_used = buffer (Int) containing the prediction flag
- information for short windows. Each item in the
- buffer toggles prediction on(1)/off(0) for each
- window separately.
- sfb_prediction_used = buffer (Int) containing the prediction flag
- information for scalefactor band(sfb). Each item
- toggle prediction on(1)/off(0) on each scalefactor
- band of every window.
- current_frame = channel buffer (Int32) containing the dequantized
- spectral coefficients or errors of current frame.
- q_format = buffer (Int) containing Q format for each scalefactor band of
- input current_frame.
- predicted_spectral = buffer (Int32) containing predicted spectral
- components of current frame.
- pred_q_format = Q format (Int) for predicted spectral components of
- current frame.
- coef_per_win = number of coefficients per window for short windows.
- type of Int.
- short_window_num = number of short windows, type of Int.
- reconstruct_sfb_num = number of scalefactor bands used for reconstruction
- for short windows, type of Int.
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- current_frame contents are the dequantized spectrum with a prediction
- vector added when prediction is turned on.
-
- q_format contents are updated with the new Q format (Int) for each
- scalefactor band of output current_frame buffer.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs long term synthesis using transmitted spectral
- coeffients or errors and predicted spectral components.
-
- Long term synthesis is part of long term prediction (LTP) which is used to
- reduce the redundancy of a signal between successive coding frames. The
- functionality of long term synthesis is to reconstruct the frequency domain
- spectral by adding the predicted spectral components and the transmitted
- spectral error when prediction is turned on.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3: Audio
- Subpart 4.6.6 Long Term Prediction (LTP)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by Nokia in the course
- of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7,
- 14496-1, 2 and 3. This software module is an implementation of a part
- of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2
- aac/MPEG-4 Audio standard. ISO/IEC gives users of the MPEG-2aac/MPEG-4
- Audio standards free license to this software module or modifications
- thereof for use in hardware or software products claiming conformance
- to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to use this
- software module in hardware or software products are advised that this
- use may infringe existing patents. The original developer of this
- software module, the subsequent editors and their companies, and ISO/IEC
- have no liability for use of this software module or modifications
- thereof in an implementation. Copyright is not released for non MPEG-2
- aac/MPEG-4 Audio conforming products. The original developer retains
- full right to use the code for the developer's own purpose, assign or
- donate the code to a third party and to inhibit third party from using
- the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This
- copyright notice must be included in all copies or derivative works.
- Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pPredicted_spectral = &predicted_spectral[0];
- pPredicted_spectral_start = pPredicted_spectral;
- pSfb_prediction_used = &sfb_prediction_used[0];
-
- IF (win_seq != EIGHT_SHORT_SEQUENCE)
- THEN
-
- sfb_offset = 0;
-
- pWinSfbTop = &pWin_sfb_top[0];
-
- pQ_format = &q_format[0];
-
- FOR (i = sfb_per_frame; i>0; i--)
-
- IF (*(pSfb_prediction_used++) != FALSE)
- THEN
-
- pPredicted_offset = pPredicted_spectral_start +
- sfb_offset;
- pCurrent_frame = &current_frame[sfb_offset];
-
- quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
- max = 0;
-
- pPredicted_spectral = pPredicted_offset;
-
- FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--)
-
- tmpInt32 = *(pPredicted_spectral++);
-
- IF (tmpInt32 < 0)
- THEN
-
- tmpInt32 = -tmpInt32;
-
- ENDIF
-
- max |= tmpInt32;
-
- ENDFOR
-
- tmpInt = 0;
-
- IF (max != 0)
- THEN
-
- WHILE (max < 0x40000000L)
-
- max <<= 1;
- tmpInt++;
-
- ENDWHILE
-
- pPredicted_spectral = pPredicted_offset;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
-
- ENDFOR
-
- adjusted_pred_q = pred_q_format + tmpInt;
-
- pPredicted_spectral = pPredicted_offset;
-
- shift_factor = *(pQ_format) - adjusted_pred_q;
-
- IF ((shift_factor >= 0) && (shift_factor < 31))
- THEN
-
- shift_factor = shift_factor + 1;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor)
- + (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor)
- + (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor)
- + (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor)
- + (*(pPredicted_spectral++)>>1);
-
- ENDFOR
-
- *(pQ_format) = adjusted_pred_q - 1;
-
- ELSEIF (shift_factor >= 31)
- THEN
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
-
- ENDFOR
-
- *(pQ_format) = adjusted_pred_q;
-
- ELSEIF ((shift_factor < 0) && (shift_factor > -31))
- THEN
-
- shift_factor = 1 - shift_factor;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
-
- ENDFOR
-
- *(pQ_format) = *(pQ_format) - 1;
-
- ENDIF
-
- ENDIF
-
- ENDIF [ IF (*(pSfb_prediction_used++) != FALSE) ]
-
- sfb_offset = *pWinSfbTop;
- pWinSfbTop = pWinSfbTop + 1;
- pQ_format = pQ_format + 1;
-
- ENDFOR [ FOR (i = sfb_per_frame; i>0; i--) ]
-
- ELSE
-
- pCurrent_frame_start = &current_frame[0];
-
- pQ_format_start = &q_format[0];
-
- num_sfb = sfb_per_win[0];
-
- FOR (wnd=0; wnd<short_window_num; wnd++)
-
- pWinSfbTop = &pWin_sfb_top[0];
-
- pQ_format = pQ_format_start;
-
- IF (win_prediction_used[wnd] != FALSE)
- THEN
-
- sfb_offset = 0;
-
- FOR (i = reconstruct_sfb_num; i > 0; i--)
-
- pPredicted_offset = pPredicted_spectral_start +
- sfb_offset;
- pCurrent_frame = pCurrent_frame_start + sfb_offset;
-
- quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
- max = 0;
-
- pPredicted_spectral = pPredicted_offset;
-
- FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--)
-
- tmpInt32 = *(pPredicted_spectral++);
-
- IF (tmpInt32 < 0)
- THEN
-
- tmpInt32 = -tmpInt32;
-
- ENDIF
-
- max |= tmpInt32;
-
- ENDFOR
-
- tmpInt = 0;
-
- IF (max != 0)
- THEN
-
- WHILE (max < 0x40000000L)
-
- max <<= 1;
- tmpInt++;
-
- ENDWHILE
-
-
- pPredicted_spectral = pPredicted_offset;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
- *(pPredicted_spectral++) <<= tmpInt;
-
- ENDFOR
-
- adjusted_pred_q = pred_q_format + tmpInt;
-
- pPredicted_spectral = pPredicted_offset;
-
- shift_factor = *(pQ_format) - adjusted_pred_q;
-
- IF ((shift_factor >= 0) && (shift_factor < 31))
- THEN
-
- shift_factor = shift_factor + 1;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor) +
- (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor) +
- (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor) +
- (*(pPredicted_spectral++)>>1);
- *(pCurrent_frame++) =
- (*pCurrent_frame>>shift_factor) +
- (*(pPredicted_spectral++)>>1);
-
- ENDFOR
-
- *(pQ_format) = adjusted_pred_q - 1;
-
- ELSEIF (shift_factor >= 31)
- THEN
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
- *(pCurrent_frame++) = *(pPredicted_spectral++);
-
- ENDFOR
-
- *(pQ_format) = adjusted_pred_q;
-
- ELSEIF ((shift_factor < 0) && (shift_factor > -31))
- THEN
-
- shift_factor = 1 - shift_factor;
-
- FOR (j = quarter_sfb_width; j>0 ; j--)
-
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
- *(pCurrent_frame++) = (*pCurrent_frame>>1) +
- (*(pPredicted_spectral++)>>shift_factor);
-
- ENDFOR
-
- *(pQ_format) = *(pQ_format) - 1;
-
- ENDIF
-
- ENDIF
-
- sfb_offset = *pWinSfbTop;
- pWinSfbTop = pWinSfbTop + 1;
- pQ_format = pQ_format + 1;
-
- ENDFOR [ FOR (i = reconstruct_sfb_num; i > 0; i--) ]
-
- ENDIF [ IF (win_prediction_used[wnd] != FALSE) ]
-
- pPredicted_spectral_start = pPredicted_spectral_start + num_sfb;
- pCurrent_frame_start = pCurrent_frame_start + num_sfb;
- wnd_offset = wnd_offset + num_sfb;
- pQ_format_start = pQ_format_start + num_sfb;
-
- ENDFOR [ FOR (wnd=0; wnd<short_window_num; wnd++) ]
-
- ENDIF [ IF (win_seq != EIGHT_SHORT_SEQUENCE) ]
-
- RETURN
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "long_term_synthesis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void long_term_synthesis(
- WINDOW_SEQUENCE win_seq,
- Int sfb_per_win,
- Int16 win_sfb_top[],
- Int win_prediction_used[],
- Int sfb_prediction_used[],
- Int32 current_frame[],
- Int q_format[], /* for each sfb */
- Int32 predicted_spectral[],
- Int pred_q_format, /* for predicted_spectral[] */
- Int coef_per_win,
- Int short_window_num,
- Int reconstruct_sfb_num)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- /* Scalefactor band offset */
- Int sfb_offset;
-
- /* Window index */
- Int wnd;
-
- /* Pointer to array containing predicted samples */
- Int32 *pPredicted_spectral;
-
- /* Pointer to the beginning of array containing predicted samples */
- Int32 *pPredicted_spectral_start;
-
- Int32 *pPredicted_offset;
-
- /* Pointer to array containing current spectral components for a channel*/
- Int32 *pCurrent_frame;
-
- /* Another pointer to array containing current spectral components */
- Int32 *pCurrent_frame_start;
-
- /* Pointer to prediction flag for each scalefactor band */
- Int *pSfb_prediction_used;
-
- /* Pointer to top coef per scalefactor band */
- Int16 *pWinSfbTop;
-
- /* Pointer to q_format array */
- Int *pQ_format;
- Int *pQ_format_start;
- Int32 temp;
-
- Int i;
- Int j;
-
- Int quarter_sfb_width;
- Int num_sfb;
- Int shift_factor;
-
- UInt32 max;
- Int32 tmpInt32;
-
- Int tmpInt;
- Int adjusted_pred_q;
- Int pred_shift;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /* Initialize pointers */
- pPredicted_spectral = &predicted_spectral[0];
- pPredicted_spectral_start = pPredicted_spectral;
-
- /*
- * NOTE:
- * sfb_prediction_used[] start from 0 or 1 depending on nok_lt_decode.c;
- * currently we agree to make it start from 0;
- */
- pSfb_prediction_used = &sfb_prediction_used[0];
-
- /*********************************/
- /* LTP synthesis for long window */
- /*********************************/
- if (win_seq != EIGHT_SHORT_SEQUENCE)
- {
-
- /*******************************************************/
- /* Reconstruction of current frequency domain spectrum */
- /*******************************************************/
-
- /* Initialize scalefactor band offset */
- sfb_offset = 0;
-
- /*
- * Reconstruction is processed on scalefactor band basis.
- * 1. When prediction is turned on, all the predicted spectral
- * components will be used for reconstruction.
- * 2. When prediction is turned off, reconstruction is not
- * needed. Spectral components of current frame will directly
- * come from the transmitted data.
- */
- pWinSfbTop = &win_sfb_top[0];
-
- pQ_format = &q_format[0];
-
- for (i = sfb_per_win; i > 0; i--)
- {
- /* Check prediction flag for each scalefactor band. */
- if (*(pSfb_prediction_used++) != FALSE)
- {
- /*
- * Prediction is on. Do reconstruction routine.
- * Reconstruct spectral component of current
- * frame by adding the predicted spectral
- * components and the quantized prediction
- * errors that reconstructed from transmitted
- * data when prediction is turned on.
- */
-
- /* Set pointers to the offset of scalefactor bands */
- pPredicted_offset = pPredicted_spectral_start +
- sfb_offset;
- pCurrent_frame = &current_frame[sfb_offset];
-
- /*
- * (*pWinSfbTop - sfb_offset) is number of coefficients
- * of the scalefactor band.
- * ">>2" is used to set up for later unrolling the loop.
- */
- quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
- /*
- * Adjust pred_q_format and predicted_spectral() to
- * maximum resolution.
- */
- max = 0;
-
- pPredicted_spectral = pPredicted_offset;
-
- /* Find the maximum absolute value */
- for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--)
- {
- tmpInt32 = *(pPredicted_spectral++);
-
- /*
- * Note: overflow is protected here even though
- * tmpInt32 = 0x80000000 is very rare case.
- *
- * if (tmpInt32 == LONG_MIN)
- * {
- * tmpInt32 = LONG_MAX;
- * }
- * if (tmpInt32 < 0)
- * {
- * tmpInt32 = -tmpInt32;
- * }
- */
-
- max |= tmpInt32 ^(tmpInt32 >> 31);
- }
-
- /*
- * IF the LTP data is all zeros
- * (max == 0) - do nothing for this sfb.
- */
-
- if (max != 0)
- {
- /* Find the number of bits to reach the max resolution */
- tmpInt = 0;
-
- while (max < 0x40000000L)
- {
- max <<= 1;
- tmpInt++;
- }
-
- /*
- * The following codes are combinded into shift factor
- * adjusting and reconstruction section.
- *
- * pPredicted_spectral = pPredicted_offset;
- * for(j = quarter_sfb_width; j>0 ; j--)
- * {
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * }
- *
- */
-
- /* Adjust Q format for predicted_spectral() */
- adjusted_pred_q = pred_q_format + tmpInt;
-
- /*
- * Adjust Q format to prevent overflow that may occur during
- * frequency domain reconstruction.
- *
- */
- pPredicted_spectral = pPredicted_offset;
-
- shift_factor = *(pQ_format) - adjusted_pred_q;
-
- if ((shift_factor >= 0) && (shift_factor < 31))
- {
- shift_factor = shift_factor + 1;
- pred_shift = tmpInt - 1;
-
- if (pred_shift >= 0)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- }
- }
- else
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- }
- }
-
- /* Updated new Q format for current scalefactor band */
- *(pQ_format) = adjusted_pred_q - 1;
- }
- else if (shift_factor >= 31)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- }
-
- /* Updated new Q format for current scalefactor band */
- *(pQ_format) = adjusted_pred_q ;
- }
- else if ((shift_factor < 0) && (shift_factor > -31))
- {
- shift_factor = 1 - shift_factor;
- pred_shift = tmpInt - shift_factor;
-
- if (pred_shift >= 0)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- }
- }
- else
- {
- pred_shift = -pred_shift;
-
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- }
- }
-
- /*
- * Updated new Q format for current scalefactor band
- *
- * This is NOT a pointer decrement
- */
- (*pQ_format)--;
- }
-
- } /* if (max != 0) */
-
- /*
- * For case (shift_factor <= -31), *pCurrent_frame and
- * *pQ_format do not need to be updated.
- */
-
- } /* if (*(pSfb_prediction_used++) != FALSE) */
-
- /* Updated to next scalefactor band. */
- sfb_offset = *(pWinSfbTop++);
-
- /* Updated pointer to next scalefactor band's Q-format */
- pQ_format++;
-
- } /* for (i = sfb_per_frame; i>0; i--) */
-
- } /* if (win_seq!=EIGHT_SHORT_SEQUENCE) */
-
- /**********************************/
- /* LTP synthesis for short window */
- /**********************************/
- else
- {
- /******************************************************/
- /*Reconstruction of current frequency domain spectrum */
- /******************************************************/
- pCurrent_frame_start = &current_frame[0];
-
- pQ_format_start = &q_format[0];
-
- num_sfb = sfb_per_win;
-
- /* Reconstruction is processed on window basis */
- for (wnd = 0; wnd < short_window_num; wnd++)
- {
- pWinSfbTop = &win_sfb_top[0];
-
- pQ_format = pQ_format_start;
-
- /* Check if prediction flag is on for each window */
- if (win_prediction_used[wnd] != FALSE)
- {
- /* Initialize scalefactor band offset */
- sfb_offset = 0;
-
- /*
- * Reconstruction is processed on scalefactor band basis.
- * 1. When prediction is turned on, all the predicted
- * spectral components will be used for reconstruction.
- * 2. When prediction is turned off, reconstruction is
- * not needed. Spectral components of current frame
- * will directly come from the transmitted data.
- */
-
- /*
- * According to ISO/IEC 14496-3 pg.91
- * Only the spectral components in first eight scalefactor
- * bands are added to the quantized prediction error.
- */
- for (i = reconstruct_sfb_num; i > 0; i--)
- {
- /* Set pointer to the offset of scalefactor bands */
- pPredicted_offset = pPredicted_spectral_start +
- sfb_offset;
- pCurrent_frame = pCurrent_frame_start + sfb_offset;
-
- /*
- * Prediction is on. Do reconstruction routine.
- * Reconstruct spectral component of
- * current frame by adding the predicted
- * spectral components and the quantized
- * prediction errors that reconstructed
- * from transmitted data when prediction
- * is turned on.
- */
-
- /*
- * (*pWinSfbTop - sfb_offset) is number of coefficients
- * of the scalefactor band.
- * ">>2" is used to set up for later unrolling the loop.
- */
- quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
- /*
- * Adjust pred_q_format and predicted_spectral() to
- * maximum resolution.
- */
- max = 0;
- pPredicted_spectral = pPredicted_offset;
-
- /* Find the maximum absolute value */
- for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--)
- {
- tmpInt32 = *(pPredicted_spectral++);
-
-
- /*
- * Note: overflow is protected here even though
- * tmpInt32 = 0x80000000 is very rare case.
- *
- * if (tmpInt32 == LONG_MIN)
- * {
- * tmpInt32 = LONG_MAX;
- * }
- * if (tmpInt32 < 0)
- * {
- * tmpInt32 = -tmpInt32;
- * }
- */
-
- max |= tmpInt32 ^(tmpInt32 >> 31);
- }
-
- if (max != 0)
- {
- /* Find the number of bits to reach
- * the max resolution
- */
- tmpInt = 0;
-
- while (max < 0x40000000L)
- {
- max <<= 1;
- tmpInt++;
- }
- /*
- * The following codes are combined into shift factor
- * adjusting and reconstruction section.
- *
- * pPredicted_spectral = pPredicted_offset;
- * for(j = quarter_sfb_width; j>0 ; j--)
- * {
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * *(pPredicted_spectral++) <<= tmpInt;
- * }
- *
- */
-
- /* Adjust Q format for predicted_spectral() */
- adjusted_pred_q = pred_q_format + tmpInt;
-
- /*
- * Adjust Q format to prevent overflow that may occur
- * during frequency domain reconstruction.
- */
- pPredicted_spectral = pPredicted_offset;
-
- shift_factor = *(pQ_format) - adjusted_pred_q;
-
- if ((shift_factor >= 0) && (shift_factor < 31))
- {
- shift_factor = shift_factor + 1;
-
- pred_shift = tmpInt - 1;
-
- if (pred_shift >= 0)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) << pred_shift);
-
- }
- }
- else
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- temp = *pCurrent_frame >> shift_factor;
- *(pCurrent_frame++) = temp
- + (*(pPredicted_spectral++) >> 1);
- }
- }
-
- /* Updated new Q format for current scalefactor band*/
- *(pQ_format) = adjusted_pred_q - 1;
- }
- else if (shift_factor >= 31)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- *(pCurrent_frame++) =
- *(pPredicted_spectral++) << tmpInt;
- }
-
- /* Updated new Q format for current scalefactor band*/
- *(pQ_format) = adjusted_pred_q;
- }
- else if ((shift_factor < 0) && (shift_factor > -31))
- {
- shift_factor = 1 - shift_factor;
-
- pred_shift = tmpInt - shift_factor;
-
- if (pred_shift >= 0)
- {
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) << pred_shift);
-
- }
- }
- else
- {
- pred_shift = -pred_shift;
-
- for (j = quarter_sfb_width; j > 0 ; j--)
- {
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- temp = *pCurrent_frame >> 1;
- *(pCurrent_frame++) = temp +
- (*(pPredicted_spectral++) >> pred_shift);
- }
- }
-
- /* Updated new Q format for current scalefactor band*/
- *(pQ_format) = *(pQ_format) - 1;
- }
-
- /*
- * For case (shift_factor <= -31), *pCurrent_frame and
- * *pQ_format do not need to be updated.
- */
-
- } /* if (max != 0) */
-
- /* Updated to next scalefactor band. */
- sfb_offset = *(pWinSfbTop++);
-
- /* Updated pointer to next scalefactor band's Q-format */
- pQ_format++;
-
- } /* for (i = reconstruct_sfb_num; i > 0; i--) */
-
- } /* if (win_prediction_used[wnd] != FALSE) */
-
- /* Updated to next window */
- pPredicted_spectral_start += coef_per_win;
- pCurrent_frame_start += coef_per_win;
- pQ_format_start += num_sfb;
-
- } /* for (wnd=0; wnd<short_window_num; wnd++) */
-
- } /* else */
-
- /*----------------------------------------------------------------------------
- ; Return nothing or data or data pointer
- ----------------------------------------------------------------------------*/
- return;
-} /* long_term_synthesis */
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_synthesis.h b/media/libstagefright/codecs/aacdec/long_term_synthesis.h
deleted file mode 100644
index 1195709..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_synthesis.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_synthesis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: 1. Changed protoype with array size passed in per review
- comments.
- 2. Moved #define NUM_RECONSTRUCTED_SFB to ltp_common_internal.h
-
- Description: Modified prototype based on review comments for new version
- long_term_synthesis.c.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function prototype declaration for long_term_synthesis().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LONG_TERM_SYNTHESIS_H
-#define LONG_TERM_SYNTHESIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void long_term_synthesis(
- WINDOW_SEQUENCE win_seq,
- Int sfb_per_win,
- Int16 win_sfb_top[],
- Int win_prediction_used[],
- Int sfb_prediction_used[],
- Int32 current_frame[],
- Int q_format[],
- Int32 predicted_spectral[],
- Int pred_q_format,
- Int coef_per_win,
- Int short_window_num,
- Int reconstruct_sfb_num);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/lt_decode.cpp b/media/libstagefright/codecs/aacdec/lt_decode.cpp
deleted file mode 100644
index e5f5f91..0000000
--- a/media/libstagefright/codecs/aacdec/lt_decode.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: lt_decode.c
-
-
-------------------------------------------------------------------------------
-
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: First round of optimizations.
-
- Description: pInputStream is now the 2nd parameter to this function.
-
- Description: Changed to work with MT's new get_ics_info.c function, which
- only calls lt_decode if LTP is enabled. This removes one grab from the
- bitstream and one "if" from this code. Also, changed setting of weight.
- Now, rather than setting the actual weight, I only set the index into
- a table in this function.
-
- Description: Replace some instances of getbits to get9_n_lessbits
- when the number of bits read is 9 or less and get1bits
- when only 1 bit is read.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- win_type Type of window (SHORT or LONG)
- [WINDOW_TYPE]
-
- max_sfb Maximum number of active scalefactor bands
- [Int]
-
- pLt_pred Pointer to structure containing information for
- long-term prediction.
- [LT_PRED_STATUS *]
-
- pInputStream Pointer to structure containing bitstream
- information.
- [BITS *]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pLt_pred->weight_index - updated with index into weight table for LTP.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes the bitstream elements for long term prediction
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by Nokia
- in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard
- ISO/IEC13818-7, 14496-1, 2 and 3. This software module is an implementation
- of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
- MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the
- MPEG-2aac/MPEG-4 Audio standards free license to this software module or
- modifications thereof for use in hardware or software products claiming
- conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those intending to
- use this software module in hardware or software products are advised that
- this use may infringe existing patents. The original developer of this
- software module, the subsequent editors and their companies, and ISO/IEC
- have no liability for use of this software module or modifications thereof
- in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
- Audio conforming products. The original developer retains full right to use
- the code for the developer's own purpose, assign or donate the code to a
- third party and to inhibit third party from using the code for non
- MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
- must be included in all copies or derivative works."
- Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pDelay[0] = (Int) getbits(
- LEN_LTP_LAG,
- pInputStream);
-
- temp_reg = (Int) getbits(
- LEN_LTP_COEF,
- pInputStream);
-
- pLt_pred->weight = codebook[temp_reg];
-
- last_band = max_sfb;
-
- IF (win_type != EIGHT_SHORT_SEQUENCE)
-
- IF (last_band > MAX_LT_PRED_LONG_SFB)
-
- last_band = MAX_LT_PRED_LONG_SFB;
-
- ENDIF
-
- FOR (m = last_band; m > 0; m--)
-
- *(pSfbPredictionUsed++) = (Int) getbits(
- LEN_LTP_LONG_USED,
- pInputStream);
- ENDFOR
-
- FOR (m = (max_sfb - last_band); m > 0; m--)
-
- *(pSfbPredictionUsed++) = 0;
-
- ENDFOR
-
- ELSE
-
- IF (last_band > MAX_LT_PRED_SHORT_SFB)
-
- last_band = MAX_LT_PRED_SHORT_SFB;
-
- ENDIF
-
- prev_subblock = pDelay[0];
-
- pWinPredictionUsed++;
-
- pTempPtr = &pSfbPredictionUsed[0];
-
- FOR (m = NUM_SHORT_WINDOWS; m > 0;)
-
- m--;
- temp_reg = (Int) getbits(
- LEN_LTP_SHORT_USED,
- pInputStream);
-
- *(pWinPredictionUsed++) = temp_reg;
-
- IF (temp_reg != FALSE)
- {
- *(pDelay++) = prev_subblock;
-
- FOR (k = last_band; k > 0; k--)
- {
- *(pTempPtr++) = 1;
- }
- break;
- ELSE
- {
- pDelay++;
- pTempPtr += last_band;
- }
-
- ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;)
-
- prev_subblock += LTP_LAG_OFFSET;
-
- FOR (; m > 0; m--)
-
- temp_reg = (Int) getbits (
- LEN_LTP_SHORT_USED,
- pInputStream);
-
- *(pWinPredictionUsed++) = temp_reg;
-
- IF (temp_reg != FALSE)
-
- temp_reg = (Int) getbits(
- LEN_LTP_SHORT_LAG_PRESENT,
- pInputStream);
- IF (temp_reg != 0)
-
- temp_reg = (Int) getbits(
- LEN_LTP_SHORT_LAG,
- pInputStream);
-
- *(pDelay++) = prev_subblock - temp_reg;
-
- ELSE
-
- *(pDelay++) = prev_subblock - LTP_LAG_OFFSET;
-
- ENDIF
-
- FOR (k = last_band; k > 0; k--)
- *(pTempPtr++) = 1;
- ENDFOR
-
- ELSE
-
- pDelay++;
- pTempPtr += last_band;
-
- ENDIF
-
- ENDFOR (; m > 0; m--)
-
- ENDIF (win_type != EIGHT_SHORT_SEQUENCE)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "lt_decode.h"
-#include "ltp_common_internal.h"
-#include "window_block_fxp.h"
-#include "e_window_sequence.h"
-#include "s_lt_pred_status.h"
-#include "s_bits.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void lt_decode(
- const WINDOW_SEQUENCE win_type,
- BITS *pInputStream,
- const Int max_sfb,
- LT_PRED_STATUS *pLt_pred)
-{
- Int wnd_num;
- Int k;
- Int last_band;
- Int prev_subblock;
- Int prev_subblock_nonzero;
- Int temp_reg;
-
- Bool *pWinPredictionUsed = pLt_pred->win_prediction_used;
- Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used;
- Int *pTempPtr;
- Int *pDelay = pLt_pred->delay;
-
- pDelay[0] = (Int) get17_n_lessbits(
- LEN_LTP_LAG, /* 11 bits */
- pInputStream);
-
- pLt_pred->weight_index = (Int) get9_n_lessbits(
- LEN_LTP_COEF, /* 3 bits */
- pInputStream);
-
- last_band = max_sfb;
-
- if (win_type != EIGHT_SHORT_SEQUENCE)
- {
-
- /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */
- if (last_band > MAX_LT_PRED_LONG_SFB)
- {
- last_band = MAX_LT_PRED_LONG_SFB;
- }
-
- for (k = last_band; k > 0; k--)
- {
- *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream);
- }
-
- /*
- * This is not a call to memset, because
- * (max_sfb - last_band) should typically be a small value.
- */
- for (k = (max_sfb - last_band); k > 0; k--)
- {
- *(pSfbPredictionUsed++) = FALSE;
- }
- }
- else /* (win_type == EIGHT_SHORT_SEQUENCE) */
- {
- /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */
-
- if (last_band > MAX_LT_PRED_SHORT_SFB)
- {
- last_band = MAX_LT_PRED_SHORT_SFB;
- }
-
- /*
- * The following two coding constructs are equivalent...
- *
- * first_time == 1
- * for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--)
- * {
- * if (condition)
- * {
- * if (first_time == 1)
- * {
- * CODE SECTION A
- * first_time = 0;
- * }
- * else
- * {
- * CODE SECTION B
- * }
- * }
- * }
- *
- * -----------------------------------EQUIVALENT TO------------
- *
- * wnd_num=NUM_SHORT_WINDOWS;
- *
- * do
- * {
- * wnd_num--;
- * if (condition)
- * {
- * CODE SECTION A
- * break;
- * }
- * } while( wnd_num > 0)
- *
- * while (wnd_num > 0)
- * {
- * if (condition)
- * {
- * CODE SECTION B
- * }
- * wnd_num--;
- * }
- *
- */
-
- prev_subblock = pDelay[0];
-
- pTempPtr = &pSfbPredictionUsed[0];
-
- wnd_num = NUM_SHORT_WINDOWS;
-
- prev_subblock_nonzero = prev_subblock;
- prev_subblock += LTP_LAG_OFFSET;
-
- do
- {
- /*
- * Place decrement of wnd_num here, to insure
- * that the decrement occurs before the
- * break out of the do-while loop.
- */
- wnd_num--;
-
- temp_reg = (Int) get1bits(pInputStream);
-
- *(pWinPredictionUsed++) = temp_reg;
-
- if (temp_reg != FALSE)
- {
- *(pDelay++) = prev_subblock_nonzero;
-
- for (k = last_band; k > 0; k--)
- {
- *(pTempPtr++) = TRUE;
- }
- for (k = (max_sfb - last_band); k > 0; k--)
- {
- *(pTempPtr++) = FALSE;
- }
- break;
-
- } /* if(pWinPredictionUsed) */
- else
- {
- pDelay++;
- pTempPtr += max_sfb;
- }
-
- }
- while (wnd_num > 0);
-
- /*
- * This while loop picks up where the previous one left off.
- * Notice that the code functions differently inside the loop
- */
-
- while (wnd_num > 0)
- {
- temp_reg = (Int) get1bits(pInputStream);
-
- *(pWinPredictionUsed++) = temp_reg;
-
- if (temp_reg != FALSE)
- {
- temp_reg = (Int) get1bits(pInputStream);
- if (temp_reg != 0)
- {
- temp_reg = (Int) get9_n_lessbits(
- LEN_LTP_SHORT_LAG,
- pInputStream);
-
- *(pDelay++) = prev_subblock - temp_reg;
- }
- else
- {
- *(pDelay++) = prev_subblock_nonzero;
- }
- for (k = last_band; k > 0; k--)
- {
- *(pTempPtr++) = TRUE;
- }
- for (k = (max_sfb - last_band); k > 0; k--)
- {
- *(pTempPtr++) = FALSE;
- }
-
- } /* if (temp_reg) */
- else
- {
- pDelay++;
- pTempPtr += max_sfb;
- }
-
- wnd_num--;
-
- } /* while(wnd_num) */
-
- } /* else (win_type == EIGHT_SHORT_SEQUENCE) */
-
-} /* lt_decode */
diff --git a/media/libstagefright/codecs/aacdec/lt_decode.h b/media/libstagefright/codecs/aacdec/lt_decode.h
deleted file mode 100644
index c655270..0000000
--- a/media/libstagefright/codecs/aacdec/lt_decode.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: lt_decode.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changing to move pInputStream to 2nd parameter.
-
- Description: Replaced "e_WINDOW_TYPE.h" with "e_WINDOW_SEQUENCE.h"
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the global function declaration for lt_decode
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LT_DECODE_H
-#define LT_DECODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "s_lt_pred_status.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void lt_decode(
- const WINDOW_SEQUENCE win_type,
- BITS *pInputStream,
- const Int max_sfb,
- LT_PRED_STATUS *pLt_pred);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/lt_prediction.h b/media/libstagefright/codecs/aacdec/lt_prediction.h
deleted file mode 100644
index e52a1e8..0000000
--- a/media/libstagefright/codecs/aacdec/lt_prediction.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**************************************************************************
-
-This software module was originally developed by
-Nokia in the course of development of the MPEG-2 AAC/MPEG-4
-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.
-This software module is an implementation of a part
-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC gives users of the
-MPEG-2aac/MPEG-4 Audio standards free license to this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the MPEG-2 aac/MPEG-4 Audio standards. Those
-intending to use this software module in hardware or software products
-are advised that this use may infringe existing patents. The original
-developer of this software module, the subsequent
-editors and their companies, and ISO/IEC have no liability for use of
-this software module or modifications thereof in an
-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
-Audio conforming products. The original developer retains full right to
-use the code for the developer's own purpose, assign or donate the code to a
-third party and to inhibit third party from using the code for non
-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
-must be included in all copies or derivative works.
-Copyright (c)1997.
-
-***************************************************************************/
-
-#ifndef _LT_PREDICTION_H
-#define _LT_PREDICTION_H
-
-#include "block.h"
-#include "ltp_common.h"
-#include "ibstream.h"
-#include "lt_decode.h"
-#include "s_frameinfo.h"
-#include "window_block.h"
-
-void init_lt_pred(LT_PRED_STATUS * lt_status);
-
-void lt_predict(
- Int object,
- FrameInfo *pFrameInfo,
- WINDOW_SEQUENCE win_seq,
- Wnd_Shape *pWin_shape,
- LT_PRED_STATUS *pLt_status,
- Real *pPredicted_samples,
- Real *pOverlap_buffer,
- Real *pCurrent_frame_copy,
- Real current_frame[]);
-
-short double_to_int(double sig_in);
-
-#endif /* not defined _LT_PREDICTION_H */
diff --git a/media/libstagefright/codecs/aacdec/ltp_common_internal.h b/media/libstagefright/codecs/aacdec/ltp_common_internal.h
deleted file mode 100644
index d76ac75..0000000
--- a/media/libstagefright/codecs/aacdec/ltp_common_internal.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**************************************************************************
-
-This software module was originally developed by
-
-Mikko Suonio (Nokia)
-
-in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard
-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an
-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools
-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives
-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this
-software module or modifications thereof for use in hardware or
-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio
-standards. Those intending to use this software module in hardware or
-software products are advised that this use may infringe existing
-patents. The original developer of this software module and his/her
-company, the subsequent editors and their companies, and ISO/IEC have
-no liability for use of this software module or modifications thereof
-in an implementation. Copyright is not released for non MPEG-2
-NBC/MPEG-4 Audio conforming products. The original developer retains
-full right to use the code for his/her own purpose, assign or donate
-the code to a third party and to inhibit third party from using the
-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This
-copyright notice must be included in all copies or derivative works.
-
-Copyright (c) 1997.
-
-***************************************************************************/
-
-#ifndef _LTP_COMMON_INTERNAL_H
-#define _LTP_COMMON_INTERNAL_H
-
-
-/*
- Purpose: Number of LTP coefficients. */
-#define LPC 1
-
-/*
- Purpose: Maximum LTP lag. */
-#define DELAY 2048
-
-/*
- Purpose: Length of the bitstream element ltp_data_present. */
-#define LEN_LTP_DATA_PRESENT 1
-
-/*
- Purpose: Length of the bitstream element ltp_lag. */
-#define LEN_LTP_LAG 11
-
-/*
- Purpose: Length of the bitstream element ltp_coef. */
-#define LEN_LTP_COEF 3
-
-/*
- Purpose: Length of the bitstream element ltp_short_used. */
-#define LEN_LTP_SHORT_USED 1
-
-/*
- Purpose: Length of the bitstream element ltp_short_lag_present. */
-#define LEN_LTP_SHORT_LAG_PRESENT 1
-
-/*
- Purpose: Length of the bitstream element ltp_short_lag. */
-#define LEN_LTP_SHORT_LAG 5
-
-/*
- Purpose: Offset of the lags written in the bitstream. */
-#define LTP_LAG_OFFSET 16
-
-/*
- Purpose: Length of the bitstream element ltp_long_used. */
-#define LEN_LTP_LONG_USED 1
-
-/*
- Purpose: Upper limit for the number of scalefactor bands
- which can use lt prediction with long windows.
- Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */
-#define MAX_LT_PRED_LONG_SFB 40
-
-/*
- Purpose: Upper limit for the number of scalefactor bands
- which can use lt prediction with short windows.
- Explanation: Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction. */
-#define MAX_LT_PRED_SHORT_SFB 13
-
-/*
- Purpose: Buffer offset to maintain block alignment.
- Explanation: This is only used for a short window sequence. */
-#define SHORT_SQ_OFFSET (BLOCK_LEN_LONG-(BLOCK_LEN_SHORT*4+BLOCK_LEN_SHORT/2))
-
-/*
- Purpose: Number of codes for LTP weight. */
-#define CODESIZE 8
-
-/* number of scalefactor bands used for reconstruction for short windows */
-#define NUM_RECONSTRUCTED_SFB (8)
-
-#endif /* _LTP_COMMON_INTERNAL_H */
diff --git a/media/libstagefright/codecs/aacdec/mdct_fxp.cpp b/media/libstagefright/codecs/aacdec/mdct_fxp.cpp
deleted file mode 100644
index df371e8..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_fxp.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_fxp.c
- Funtions: fft_rx2
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- data_quant = Input vector, with quantized Q15 spectral lines:
- type Int32
-
- Q_FFTarray = Scratch memory used for in-place IFFT calculation,
- min size required 1024, type Int32
-
- n = Length of input vector "data_quant". Currently 256 or 2048.
- type const Int
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- shift = shift factor to reflect scaling introduced by FFT and mdct_fxp,
-
- Pointers and Buffers Modified:
- calculation are done in-place and returned in "data_quant"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- The MDCT is a linear orthogonal lapped transform, based on the idea of
- time domain aliasing cancellation (TDAC).
- MDCT is critically sampled, which means that though it is 50% overlapped,
- a sequence data after MDCT has the same number of coefficients as samples
- before the transform (after overlap-and-add). This means, that a single
- block of MDCT data does not correspond to the original block on which the
- MDCT was performed. When subsequent blocks of data are added (still using
- 50% overlap), the errors introduced by the transform cancels out.
- Thanks to the overlapping feature, the MDCT is very useful for
- quantization. It effectively removes the otherwise easily detectable
- blocking artifact between transform blocks.
- N = length of input vector X
- X = vector of length N/2, will hold fixed point DCT
- k = 0:1:N-1
-
- N-1
- X(m) = 2 SUM x(k)*cos(pi/(2*N)*(2*k+1+N/2)*(2*m+1))
- k=0
-
-
- The window that completes the TDAC is applied before calling this function.
- The MDCT can be calculated using an FFT, for this, the MDCT needs to be
- rewritten as an odd-time odd-frequency discrete Fourier transform. Thus,
- the MDCT can be calculated using only one n/4 point FFT and some pre and
- post-rotation of the sample points.
-
- Computation of the MDCT implies computing
-
- x = ( y - y ) + j( y + y )
- n 2n N/2-1-2n N-1-2n N/2+2n
-
- using the Fast discrete cosine transform as described in [2]
-
- where x(n) is an input with N points
-
- x(n) ----------------------------
- |
- |
- Pre-rotation by exp(j(2pi/N)(n+1/8))
- |
- |
- N/4- point FFT
- |
- |
- Post-rotation by exp(j(2pi/N)(k+1/8))
- |
- |
- ------------- DCT
-
- By considering the N/2 overlap, a relation between successive input blocks
- is found:
-
- x (2n) = x (N/2 + 2n)
- m+1 m
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should provide a fixed point MDCT with an average
- quantization error less than 1 %.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] Analysis/Synthesis Filter Bank design based on time domain
- aliasing cancellation
- Jhon Princen, et. al.
- IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986
- Pg 1153 - 1161
-
- [2] Regular FFT-related transform kernels for DCT/DST based
- polyphase filterbanks
- Rolf Gluth
- Proc. ICASSP 1991, pg. 2205 - 2208
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- Cx, Cy are complex number
-
-
- exp = log2(n)-1
-
- FOR ( k=0; k< n/4; k +=2)
-
- Cx = (data_quant[3n/4 + k] + data_quant[3n/4 - 1 - k]) +
- j (data_quant[ n/4 + k] - data_quant[ n/4 - 1 - k])
-
- Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8))
-
- ENDFOR
-
- FOR ( k=n/4; k< n/2; k +=2)
-
- Cx = (data_quant[3n/4 - 1 - k] + data_quant[ - n/4 + k]) +
- j (data_quant[5n/4 - 1 - k] - data_quant[ n/4 + k])
-
- Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8))
-
- ENDFOR
-
- CALL FFT( Q_FFTarray, n/4)
-
- MODIFYING( Q_FFTarray )
-
- RETURNING( shift )
-
- FOR ( k=0; k< n/2; k +=2)
-
- Cx = Q_FFTarray[ k] + j Q_FFTarray[ k+1]
-
- Cy = 2 * Cx * exp(-j(2pi/n)(k+1/8))
-
- data_quant[ k ] = - Real(Cy)
- data_quant[ n/2 - 1 - k ] = Imag(Cy)
- data_quant[ n/2 + k ] = - Imag(Cy)
- data_quant[ n - k ] = Real(Cy)
-
- ENDFOR
-
- MODIFIED data_quant[]
-
- RETURN (-shift-1)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "mdct_fxp.h"
-#include "fft_rx4.h"
-#include "mix_radix_fft.h"
-#include "fwd_long_complex_rot.h"
-#include "fwd_short_complex_rot.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ERROR_IN_FRAME_SIZE 10
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int mdct_fxp(
- Int32 data_quant[],
- Int32 Q_FFTarray[],
- Int n)
-{
-
- Int32 temp_re;
- Int32 temp_im;
-
- Int32 temp_re_32;
- Int32 temp_im_32;
-
- Int16 cos_n;
- Int16 sin_n;
- Int32 exp_jw;
- Int shift;
-
-
- const Int32 *p_rotate;
-
-
- Int32 *p_data_1;
- Int32 *p_data_2;
- Int32 *p_data_3;
- Int32 *p_data_4;
-
- Int32 *p_Q_FFTarray;
-
- Int32 max1;
-
- Int k;
- Int n_2 = n >> 1;
- Int n_4 = n >> 2;
- Int n_8 = n >> 3;
- Int n_3_4 = 3 * n_4;
-
- switch (n)
- {
- case SHORT_WINDOW_TYPE:
- p_rotate = (Int32 *)exp_rotation_N_256;
- break;
-
- case LONG_WINDOW_TYPE:
- p_rotate = (Int32 *)exp_rotation_N_2048;
- break;
-
- default:
- /*
- * There is no defined behavior for a non supported frame
- * size. By returning a fixed scaling factor, the input will
- * scaled down and this will be heard as a low level noise
- */
- return(ERROR_IN_FRAME_SIZE);
-
- }
-
- /*--- Reordering and Pre-rotation by exp(-j(2pi/N)(r+1/8)) */
- p_data_1 = &data_quant[n_3_4];
- p_data_2 = &data_quant[n_3_4 - 1];
- p_data_3 = &data_quant[n_4];
- p_data_4 = &data_quant[n_4 - 1];
-
- p_Q_FFTarray = Q_FFTarray;
-
- max1 = 0;
-
- for (k = n_8; k > 0; k--)
- {
- /*
- * scale down to ensure numbers are Q15
- * temp_re and temp_im are 32-bit but
- * only the lower 16 bits are used
- */
-
- temp_re = (*(p_data_1++) + *(p_data_2--)) >> 1;
- temp_im = (*(p_data_3++) - *(p_data_4--)) >> 1;
-
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- exp_jw = *p_rotate++;
-
- cos_n = (Int16)(exp_jw >> 16);
- sin_n = (Int16)(exp_jw & 0xFFFF);
-
- temp_re_32 = temp_re * cos_n + temp_im * sin_n;
- temp_im_32 = temp_im * cos_n - temp_re * sin_n;
- *(p_Q_FFTarray++) = temp_re_32;
- *(p_Q_FFTarray++) = temp_im_32;
- max1 |= (temp_re_32 >> 31) ^ temp_re_32;
- max1 |= (temp_im_32 >> 31) ^ temp_im_32;
-
-
- p_data_1++;
- p_data_2--;
- p_data_4--;
- p_data_3++;
- }
-
-
- p_data_1 = &data_quant[n - 1];
- p_data_2 = &data_quant[n_2 - 1];
- p_data_3 = &data_quant[n_2];
- p_data_4 = data_quant;
-
- for (k = n_8; k > 0; k--)
- {
- /*
- * scale down to ensure numbers are Q15
- */
- temp_re = (*(p_data_2--) - *(p_data_4++)) >> 1;
- temp_im = (*(p_data_1--) + *(p_data_3++)) >> 1;
-
- p_data_2--;
- p_data_1--;
- p_data_4++;
- p_data_3++;
-
- /*
- * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
- */
-
- exp_jw = *p_rotate++;
-
- cos_n = (Int16)(exp_jw >> 16);
- sin_n = (Int16)(exp_jw & 0xFFFF);
-
- temp_re_32 = temp_re * cos_n + temp_im * sin_n;
- temp_im_32 = temp_im * cos_n - temp_re * sin_n;
-
- *(p_Q_FFTarray++) = temp_re_32;
- *(p_Q_FFTarray++) = temp_im_32;
- max1 |= (temp_re_32 >> 31) ^ temp_re_32;
- max1 |= (temp_im_32 >> 31) ^ temp_im_32;
-
-
- } /* for(k) */
-
-
-
- p_Q_FFTarray = Q_FFTarray;
-
- if (max1)
- {
-
- if (n != SHORT_WINDOW_TYPE)
- {
-
- shift = mix_radix_fft(
- Q_FFTarray,
- &max1);
-
- shift += fwd_long_complex_rot(
- Q_FFTarray,
- data_quant,
- max1);
-
- }
- else /* n_4 is 64 */
- {
-
- shift = fft_rx4_short(
- Q_FFTarray,
- &max1);
-
- shift += fwd_short_complex_rot(
- Q_FFTarray,
- data_quant,
- max1);
- }
-
- }
- else
- {
- shift = -31;
- }
-
- /*
- * returns shift introduced by FFT and mdct_fxp, 12 accounts for
- * regular downshift (14) and MDCT scale factor (-2)
- * number are returned as 16 bits
- */
- return (12 - shift);
-
-} /* mdct_fxp */
-
diff --git a/media/libstagefright/codecs/aacdec/mdct_fxp.h b/media/libstagefright/codecs/aacdec/mdct_fxp.h
deleted file mode 100644
index b8d5a80..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_fxp.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_fxp.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: This extern had the incorrect length of the arrays. The true
- lengths are 128 and 1024, not 64 and 512.
-
- Description: Modified interface so a vector with extended precision is
- returned. Added copyright notice.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function mdct_fxp()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MDCT_FXP_H
-#define MDCT_FXP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-#define LONG_WINDOW_TYPE 2048
-#define SHORT_WINDOW_TYPE 256
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- extern const Int exp_rotation_N_256[128];
- extern const Int exp_rotation_N_2048[1024];
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int mdct_fxp(
- Int32 data_quant[],
- Int32 Q_FFTarray[],
- Int n);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* MDCT_FXP_H */
diff --git a/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp
deleted file mode 100644
index 709cbf2..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Created from fft_rx2.c
-
- Description: Modified to include forward and inverse tables
-
- Who: Date:
- Description:
-
- ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
- MDCT rotation tables fixpoint tables
-
- For a table with N complex points:
-
- cos_n + j*sin_n == exp(j(2pi/N)(n+1/8))
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here. Include conditional
- ; compile variables also.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; LOCAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; LOCAL VARIABLE DEFINITIONS
- ; Variable declaration - defined here and used outside this module
- ----------------------------------------------------------------------------*/
-
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL FUNCTION REFERENCES
- ; Declare functions defined elsewhere and referenced in this module
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
-
-
-
- extern const Int32 exp_rotation_N_256[64] =
- {
-
- 0x5A820047, 0x5A7A0280, 0x5A6304B8, 0x5A3E06EF,
- 0x5A0C0926, 0x59CB0B5B, 0x597D0D8E, 0x59210FBF,
- 0x58B711EE, 0x5840141A, 0x57BB1643, 0x57281868,
- 0x56881A8A, 0x55DB1CA8, 0x55201EC1, 0x545820D5,
- 0x538322E5, 0x52A224EF, 0x51B326F3, 0x50B828F1,
- 0x4FB12AE9, 0x4E9D2CDA, 0x4D7D2EC5, 0x4C5230A8,
- 0x4B1A3284, 0x49D73458, 0x48883624, 0x472F37E7,
- 0x45CA39A2, 0x445A3B54, 0x42E03CFD, 0x415C3E9C,
- 0x3FCE4032, 0x3E3541BE, 0x3C944340, 0x3AE844B7,
- 0x39344624, 0x37774786, 0x35B148DD, 0x33E44A29,
- 0x320E4B69, 0x30304C9E, 0x2E4B4DC6, 0x2C5F4EE3,
- 0x2A6C4FF4, 0x287250F8, 0x267251F0, 0x246D52DB,
- 0x226153BA, 0x2051548B, 0x1E3B5550, 0x1C215607,
- 0x1A0256B1, 0x17DF574E, 0x15B957DD, 0x138F585F,
- 0x116358D3, 0x0F335939, 0x0D015992, 0x0ACE59DD,
- 0x08985A1A, 0x06625A49, 0x042A5A6A, 0x01F25A7D
- };
-
-
-
-
-
-
- extern const Int32 exp_rotation_N_2048[512] =
- {
-
- 0x5A820009, 0x5A820050, 0x5A820097, 0x5A8100DE,
- 0x5A810125, 0x5A80016C, 0x5A7E01B3, 0x5A7D01FA,
- 0x5A7B0242, 0x5A790289, 0x5A7702D0, 0x5A750317,
- 0x5A72035E, 0x5A7003A5, 0x5A6D03EC, 0x5A6A0433,
- 0x5A66047A, 0x5A6304C1, 0x5A5F0508, 0x5A5B054F,
- 0x5A560596, 0x5A5205DD, 0x5A4D0624, 0x5A48066A,
- 0x5A4306B1, 0x5A3E06F8, 0x5A38073F, 0x5A320786,
- 0x5A2C07CD, 0x5A260814, 0x5A20085A, 0x5A1908A1,
- 0x5A1208E8, 0x5A0B092F, 0x5A040975, 0x59FC09BC,
- 0x59F40A03, 0x59EC0A49, 0x59E40A90, 0x59DC0AD7,
- 0x59D30B1D, 0x59CA0B64, 0x59C10BAA, 0x59B80BF1,
- 0x59AE0C37, 0x59A50C7E, 0x599B0CC4, 0x59910D0A,
- 0x59860D51, 0x597C0D97, 0x59710DDD, 0x59660E23,
- 0x595B0E6A, 0x594F0EB0, 0x59440EF6, 0x59380F3C,
- 0x592C0F82, 0x59200FC8, 0x5913100E, 0x59061054,
- 0x58F9109A, 0x58EC10E0, 0x58DF1126, 0x58D1116B,
- 0x58C411B1, 0x58B611F7, 0x58A7123C, 0x58991282,
- 0x588A12C8, 0x587B130D, 0x586C1353, 0x585D1398,
- 0x584E13DD, 0x583E1423, 0x582E1468, 0x581E14AD,
- 0x580D14F2, 0x57FD1538, 0x57EC157D, 0x57DB15C2,
- 0x57CA1607, 0x57B9164C, 0x57A71690, 0x579516D5,
- 0x5783171A, 0x5771175F, 0x575E17A3, 0x574C17E8,
- 0x5739182C, 0x57261871, 0x571218B5, 0x56FF18FA,
- 0x56EB193E, 0x56D71982, 0x56C319C6, 0x56AF1A0A,
- 0x569A1A4F, 0x56851A93, 0x56701AD6, 0x565B1B1A,
- 0x56461B5E, 0x56301BA2, 0x561A1BE5, 0x56041C29,
- 0x55EE1C6D, 0x55D81CB0, 0x55C11CF3, 0x55AA1D37,
- 0x55931D7A, 0x557C1DBD, 0x55651E00, 0x554D1E43,
- 0x55351E86, 0x551D1EC9, 0x55051F0C, 0x54EC1F4F,
- 0x54D31F91, 0x54BB1FD4, 0x54A12016, 0x54882059,
- 0x546F209B, 0x545520DE, 0x543B2120, 0x54212162,
- 0x540721A4, 0x53EC21E6, 0x53D12228, 0x53B62269,
- 0x539B22AB, 0x538022ED, 0x5364232E, 0x53492370,
- 0x532D23B1, 0x531123F2, 0x52F42434, 0x52D82475,
- 0x52BB24B6, 0x529E24F7, 0x52812538, 0x52642578,
- 0x524625B9, 0x522825FA, 0x520B263A, 0x51EC267A,
- 0x51CE26BB, 0x51B026FB, 0x5191273B, 0x5172277B,
- 0x515327BB, 0x513427FB, 0x5114283A, 0x50F4287A,
- 0x50D428BA, 0x50B428F9, 0x50942938, 0x50742978,
- 0x505329B7, 0x503229F6, 0x50112A35, 0x4FF02A74,
- 0x4FCE2AB2, 0x4FAD2AF1, 0x4F8B2B2F, 0x4F692B6E,
- 0x4F472BAC, 0x4F242BEA, 0x4F022C29, 0x4EDF2C67,
- 0x4EBC2CA4, 0x4E992CE2, 0x4E752D20, 0x4E522D5D,
- 0x4E2E2D9B, 0x4E0A2DD8, 0x4DE62E15, 0x4DC22E53,
- 0x4D9D2E90, 0x4D792ECD, 0x4D542F09, 0x4D2F2F46,
- 0x4D0A2F83, 0x4CE42FBF, 0x4CBF2FFB, 0x4C993038,
- 0x4C733074, 0x4C4D30B0, 0x4C2630EC, 0x4C003127,
- 0x4BD93163, 0x4BB2319E, 0x4B8B31DA, 0x4B643215,
- 0x4B3D3250, 0x4B15328B, 0x4AED32C6, 0x4AC53301,
- 0x4A9D333C, 0x4A753376, 0x4A4C33B1, 0x4A2433EB,
- 0x49FB3425, 0x49D2345F, 0x49A83499, 0x497F34D3,
- 0x4955350C, 0x492C3546, 0x4902357F, 0x48D835B9,
- 0x48AD35F2, 0x4883362B, 0x48583664, 0x482E369C,
- 0x480336D5, 0x47D7370E, 0x47AC3746, 0x4781377E,
- 0x475537B6, 0x472937EE, 0x46FD3826, 0x46D1385E,
- 0x46A43895, 0x467838CD, 0x464B3904, 0x461E393B,
- 0x45F13972, 0x45C439A9, 0x459739E0, 0x45693A16,
- 0x453C3A4D, 0x450E3A83, 0x44E03AB9, 0x44B13AEF,
- 0x44833B25, 0x44553B5B, 0x44263B90, 0x43F73BC6,
- 0x43C83BFB, 0x43993C30, 0x43693C65, 0x433A3C9A,
- 0x430A3CCF, 0x42DA3D04, 0x42AA3D38, 0x427A3D6C,
- 0x424A3DA0, 0x42193DD4, 0x41E93E08, 0x41B83E3C,
- 0x41873E6F, 0x41563EA3, 0x41253ED6, 0x40F33F09,
- 0x40C23F3C, 0x40903F6F, 0x405E3FA1, 0x402C3FD4,
- 0x3FFA4006, 0x3FC74038, 0x3F95406A, 0x3F62409C,
- 0x3F2F40CE, 0x3EFC4100, 0x3EC94131, 0x3E964162,
- 0x3E634193, 0x3E2F41C4, 0x3DFB41F5, 0x3DC74226,
- 0x3D934256, 0x3D5F4286, 0x3D2B42B6, 0x3CF642E6,
- 0x3CC24316, 0x3C8D4346, 0x3C584375, 0x3C2343A5,
- 0x3BEE43D4, 0x3BB84403, 0x3B834432, 0x3B4D4460,
- 0x3B18448F, 0x3AE244BD, 0x3AAC44EB, 0x3A754519,
- 0x3A3F4547, 0x3A094575, 0x39D245A2, 0x399B45CF,
- 0x396445FD, 0x392D462A, 0x38F64656, 0x38BF4683,
- 0x388746B0, 0x385046DC, 0x38184708, 0x37E04734,
- 0x37A84760, 0x3770478B, 0x373847B7, 0x36FF47E2,
- 0x36C7480D, 0x368E4838, 0x36554863, 0x361D488E,
- 0x35E348B8, 0x35AA48E2, 0x3571490C, 0x35384936,
- 0x34FE4960, 0x34C44989, 0x348B49B3, 0x345149DC,
- 0x34164A05, 0x33DC4A2E, 0x33A24A56, 0x33684A7F,
- 0x332D4AA7, 0x32F24ACF, 0x32B74AF7, 0x327C4B1F,
- 0x32414B46, 0x32064B6E, 0x31CB4B95, 0x31904BBC,
- 0x31544BE3, 0x31184C0A, 0x30DD4C30, 0x30A14C56,
- 0x30654C7C, 0x30294CA2, 0x2FEC4CC8, 0x2FB04CEE,
- 0x2F734D13, 0x2F374D38, 0x2EFA4D5D, 0x2EBD4D82,
- 0x2E804DA7, 0x2E434DCB, 0x2E064DEF, 0x2DC94E13,
- 0x2D8C4E37, 0x2D4E4E5B, 0x2D104E7E, 0x2CD34EA2,
- 0x2C954EC5, 0x2C574EE8, 0x2C194F0A, 0x2BDB4F2D,
- 0x2B9D4F4F, 0x2B5E4F71, 0x2B204F93, 0x2AE14FB5,
- 0x2AA34FD7, 0x2A644FF8, 0x2A255019, 0x29E6503A,
- 0x29A7505B, 0x2968507C, 0x2929509C, 0x28E950BC,
- 0x28AA50DC, 0x286A50FC, 0x282B511C, 0x27EB513B,
- 0x27AB515B, 0x276B517A, 0x272B5199, 0x26EB51B7,
- 0x26AB51D6, 0x266A51F4, 0x262A5212, 0x25E95230,
- 0x25A9524E, 0x2568526B, 0x25275288, 0x24E652A5,
- 0x24A652C2, 0x246452DF, 0x242352FB, 0x23E25318,
- 0x23A15334, 0x235F5350, 0x231E536B, 0x22DC5387,
- 0x229B53A2, 0x225953BD, 0x221753D8, 0x21D553F3,
- 0x2193540D, 0x21515427, 0x210F5442, 0x20CD545B,
- 0x208B5475, 0x2048548F, 0x200654A8, 0x1FC354C1,
- 0x1F8154DA, 0x1F3E54F2, 0x1EFB550B, 0x1EB85523,
- 0x1E76553B, 0x1E335553, 0x1DF0556A, 0x1DAC5582,
- 0x1D695599, 0x1D2655B0, 0x1CE355C7, 0x1C9F55DD,
- 0x1C5C55F4, 0x1C18560A, 0x1BD55620, 0x1B915636,
- 0x1B4D564B, 0x1B095661, 0x1AC55676, 0x1A82568B,
- 0x1A3E569F, 0x19F956B4, 0x19B556C8, 0x197156DC,
- 0x192D56F0, 0x18E95704, 0x18A45717, 0x1860572A,
- 0x181B573E, 0x17D75750, 0x17925763, 0x174D5775,
- 0x17095788, 0x16C4579A, 0x167F57AB, 0x163A57BD,
- 0x15F557CE, 0x15B057DF, 0x156B57F0, 0x15265801,
- 0x14E15812, 0x149C5822, 0x14575832, 0x14115842,
- 0x13CC5851, 0x13875861, 0x13415870, 0x12FC587F,
- 0x12B6588E, 0x1271589D, 0x122B58AB, 0x11E558B9,
- 0x11A058C7, 0x115A58D5, 0x111458E2, 0x10CE58F0,
- 0x108858FD, 0x1042590A, 0x0FFD5916, 0x0FB75923,
- 0x0F71592F, 0x0F2A593B, 0x0EE45947, 0x0E9E5952,
- 0x0E58595E, 0x0E125969, 0x0DCC5974, 0x0D85597E,
- 0x0D3F5989, 0x0CF95993, 0x0CB2599D, 0x0C6C59A7,
- 0x0C2559B1, 0x0BDF59BA, 0x0B9959C4, 0x0B5259CD,
- 0x0B0B59D5, 0x0AC559DE, 0x0A7E59E6, 0x0A3859EE,
- 0x09F159F6, 0x09AA59FE, 0x09645A05, 0x091D5A0D,
- 0x08D65A14, 0x08905A1B, 0x08495A21, 0x08025A28,
- 0x07BB5A2E, 0x07745A34, 0x072D5A3A, 0x06E75A3F,
- 0x06A05A44, 0x06595A49, 0x06125A4E, 0x05CB5A53,
- 0x05845A57, 0x053D5A5C, 0x04F65A60, 0x04AF5A63,
- 0x04685A67, 0x04215A6A, 0x03DA5A6D, 0x03935A70,
- 0x034C5A73, 0x03055A76, 0x02BE5A78, 0x02775A7A,
- 0x02305A7C, 0x01E95A7D, 0x01A25A7F, 0x015B5A80,
- 0x01135A81, 0x00CC5A82, 0x00855A82, 0x003E5A82
- };
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/media/libstagefright/codecs/aacdec/mdst.cpp b/media/libstagefright/codecs/aacdec/mdst.cpp
deleted file mode 100644
index 19f82e3..0000000
--- a/media/libstagefright/codecs/aacdec/mdst.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: mdst.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input length 64
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- mdst
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "pv_audio_type_defs.h"
-#include "synthesis_sub_band.h"
-#include "dct16.h"
-#include "dct64.h"
-#include "mdst.h"
-
-#ifdef HQ_SBR
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#include "fxp_mul32.h"
-#include "dst32.h"
-
-
-#define Qfmt1(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-#define Qfmt(a) (Int32)(a*((Int32)1<<27) + (a>=0?0.5F:-0.5F))
-
-const Int32 CosTable_32[32] =
-{
- Qfmt1(0.50015063602065F), Qfmt1(0.50135845244641F),
- Qfmt1(0.50378872568104F), Qfmt1(0.50747117207256F),
- Qfmt1(0.51245147940822F), Qfmt1(0.51879271310533F),
- Qfmt1(0.52657731515427F), Qfmt1(0.53590981690799F),
- Qfmt1(0.54692043798551F), Qfmt1(0.55976981294708F),
- Qfmt1(0.57465518403266F), Qfmt1(0.59181853585742F),
- Qfmt1(0.61155734788251F), Qfmt1(0.63423893668840F),
- Qfmt1(0.66031980781371F), Qfmt1(0.69037212820021F),
- Qfmt1(0.72512052237720F), Qfmt1(0.76549416497309F),
- Qfmt1(0.81270209081449F), Qfmt1(0.86834471522335F),
- Qfmt(0.93458359703641F), Qfmt(1.01440826499705F),
- Qfmt(1.11207162057972F), Qfmt(1.23383273797657F),
- Qfmt(1.38929395863283F), Qfmt(1.59397228338563F),
- Qfmt(1.87467598000841F), Qfmt(2.28205006800516F),
- Qfmt(2.92462842815822F), Qfmt(4.08461107812925F),
- Qfmt(6.79675071167363F), Qfmt(10.18693908361573F)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; mdst_32
-----------------------------------------------------------------------------*/
-
-void mdst_32(Int32 vec[], Int32 scratch_mem[])
-{
-
- Int i;
- const Int32 *pt_cos = CosTable_32;
- Int32 *pt_vec = vec;
- Int32 tmp1;
- Int32 tmp2;
-
-
-
- Int32 tmp3;
-
- tmp3 = *(pt_vec++);
- tmp2 = *(pt_vec);
-
- for (i = 5; i != 0; i--)
- {
- *(pt_vec++) += tmp3;
- tmp1 = *(pt_vec);
- *(pt_vec++) += tmp2;
- tmp3 = *(pt_vec);
- *(pt_vec++) += tmp1;
- tmp2 = *(pt_vec);
- *(pt_vec++) += tmp3;
- tmp1 = *(pt_vec);
- *(pt_vec++) += tmp2;
- tmp3 = *(pt_vec);
- *(pt_vec++) += tmp1;
- tmp2 = *(pt_vec);
- }
-
- *(pt_vec) += tmp3;
-
- dst_32(vec, scratch_mem);
-
- pt_vec = vec;
-
- for (i = 5; i != 0; i--)
- {
- *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++));
- pt_vec++;
- }
-
- tmp2 >>= 1;
- for (i = 3; i != 0; i--)
- {
- *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++));
- pt_vec++;
- }
-
- *(pt_vec - 1) <<= 1;
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; mdct_32
-----------------------------------------------------------------------------*/
-
-void mdct_32(Int32 vec[])
-{
- Int i;
- Int32 *pt_vec = vec;
- Int32 tmp1, tmp2;
-
-
- const Int32 *pt_CosTable = CosTable_32;
-
-
- for (i = 5; i != 0; i--)
- {
- *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
- pt_vec++;
- }
- for (i = 3; i != 0; i--)
- {
- *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
- pt_vec++;
- *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
- pt_vec++;
- }
- *(pt_vec - 1) <<= 1;
-
-
- dct_32(vec);
-
-
- pt_vec = &vec[31];
-
- tmp1 = *(pt_vec--);
-
- for (i = 5; i != 0; i--)
- {
- tmp2 = *(pt_vec);
- *(pt_vec--) += tmp1;
- tmp1 = *(pt_vec);
- *(pt_vec--) += tmp2;
- tmp2 = *(pt_vec);
- *(pt_vec--) += tmp1;
- tmp1 = *(pt_vec);
- *(pt_vec--) += tmp2;
- tmp2 = *(pt_vec);
- *(pt_vec--) += tmp1;
- tmp1 = *(pt_vec);
- *(pt_vec--) += tmp2;
- }
-
- *(pt_vec) += tmp1;
-
-}
-
-#endif /* HQ_SBR */
-
-
-/*----------------------------------------------------------------------------
-; dct_32
-----------------------------------------------------------------------------*/
-
-
-void dct_32(Int32 vec[])
-{
-
- pv_split(&vec[16]);
-
- dct_16(&vec[16], 0);
- dct_16(vec, 1); // Even terms
-
- pv_merge_in_place_N32(vec);
-}
-
-#endif /* AAC_PLUS */
-
-
diff --git a/media/libstagefright/codecs/aacdec/mdst.h b/media/libstagefright/codecs/aacdec/mdst.h
deleted file mode 100644
index 5b3e1c9..0000000
--- a/media/libstagefright/codecs/aacdec/mdst.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef MDST_H
-#define MDST_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- void mdst_32(Int32 vec[], Int32 scratch_mem[]);
-
- void dct_32(Int32 vec[]);
-
- void mdct_32(Int32 vec[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* MDST_H */
diff --git a/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp b/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp
deleted file mode 100644
index 6081c46..0000000
--- a/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mix_radix_fft.c
- Funtions: mix_radix_fft
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Eliminated pointer dependency ( pData_1) on Buffer address.
- Modified for-loop to countdown loops.
-
- Description: No shift information going in/out from fft_rx4_long.
-
- Description:
- (1) Increased precision on the radix 2 fft coeff. (from Q10 to Q12)
- (2) Increased precision on the input (from 0.5 to 1.0).
- (3) Eliminated hardly used condition (exp = 0).
- (4) Change interface to fft_rx4_long, so now the same function is
- used for forward and inverse calculations.
-
- Description: per code review comments, eliminated unnecessary headers
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Data = Input vector, with quantized spectral with a pre-rotation
- by exp(j(2pi/N)(k+1/8))
- type Int32 *
-
- peak_value = Input, carries the maximum value in input vector "Data"
- Output, maximum value computed in the first FFT, used
- to set precision on next stages
- type Int32 *
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- exponent = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
- Results are return in "Data"
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- mix_radix_fft() mixes radix-2 and radix-4 FFT. This is needed to be able
- to use power of 4 length when the input length sequence is a power of 2.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- mix_radix_fft() should support only the FFT for the long window case of
- the inverse modified cosine transform (IMDCT)
-------------------------------------------------------------------------------
- REFERENCES
-
- ------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
- MODIFY( x[] )
- RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fft_rx4.h"
-#include "mix_radix_fft.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void digit_reversal_swapping(Int32 *y, Int32 *x);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int mix_radix_fft(
- Int32 *Data,
- Int32 *peak_value
-)
-
-{
-
- const Int32 *p_w;
- Int32 *pData_1;
- Int32 *pData_2;
-
- Int32 *pData_3;
- Int32 *pData_4;
-
- Int32 exp_jw;
- Int32 max1;
- Int32 max2;
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 diff1;
- Int32 diff2;
- Int i;
- Int exp;
-
- max1 = *peak_value;
- p_w = w_512rx2;
-
- pData_1 = Data;
- pData_3 = Data + HALF_FFT_RX4_LENGTH_FOR_LONG;
-
-
- /*
- * normalization to 0.9999 (0x7FFF) guarantees proper operation
- */
-
- exp = 8 - pv_normalize(max1); /* use 24 bits for mix radix fft */
-
- if (exp < 4)
- {
- exp = 4;
- }
-
-
- temp1 = (*pData_3);
- pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
- temp2 = (*pData_4++);
-
-
-
- diff1 = (temp1 - temp2) >> exp;
- *pData_3++ = (temp1 + temp2) >> exp;
-
- temp3 = (*pData_3);
- temp4 = (*pData_4);
-
- *pData_4-- = -diff1;
- *pData_3++ = (temp3 + temp4) >> exp;
- *pData_4 = (temp3 - temp4) >> exp;
-
- temp1 = (*pData_1);
- pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG;
- temp2 = (*pData_2++);
- temp4 = (*pData_2);
-
- *pData_1++ = (temp1 + temp2) >> exp;
-
- temp3 = (*pData_1);
- diff1 = (temp1 - temp2) >> exp ;
-
- *pData_1++ = (temp3 + temp4) >> exp;
- *pData_2-- = (temp3 - temp4) >> exp;
- *pData_2 = diff1;
-
- temp1 = (*pData_3);
- pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
- temp2 = (*pData_4++);
-
-
- for (i = ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG - 1; i != 0; i--)
- {
- /*
- * radix 2 Butterfly
- */
-
- diff1 = (temp1 - temp2) >> (exp - 4);
- *pData_3++ = (temp1 + temp2) >> exp;
-
- temp3 = (*pData_3);
- temp4 = (*pData_4);
-
- exp_jw = *p_w++;
-
-
- diff2 = (temp3 - temp4) >> (exp - 4);
- *pData_3++ = (temp3 + temp4) >> exp;
-
- *pData_4-- = -cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3;
- *pData_4 = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3;
-
-
- temp1 = (*pData_1);
- pData_2 = pData_1 + FFT_RX4_LENGTH_FOR_LONG;
- temp2 = (*pData_2++);
- temp4 = (*pData_2);
-
- *pData_1++ = (temp1 + temp2) >> exp;
-
- temp3 = (*pData_1);
- diff1 = (temp1 - temp2) >> (exp - 4);
-
- diff2 = (temp3 - temp4) >> (exp - 4);
- *pData_1++ = (temp3 + temp4) >> exp;
-
- *pData_2-- = cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3;
- *pData_2 = cmplx_mul32_by_16(diff1, diff2, exp_jw) >> 3;
-
- temp1 = (*pData_3);
- pData_4 = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
- temp2 = (*pData_4++);
-
- }/* for i */
-
-
- fft_rx4_long(
- Data,
- &max1);
-
-
- fft_rx4_long(
- &Data[FFT_RX4_LENGTH_FOR_LONG],
- &max2);
-
- digit_reversal_swapping(Data, &Data[FFT_RX4_LENGTH_FOR_LONG]);
-
- *peak_value = max1 | max2;
-
- return(exp);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/mix_radix_fft.h b/media/libstagefright/codecs/aacdec/mix_radix_fft.h
deleted file mode 100644
index 563c280..0000000
--- a/media/libstagefright/codecs/aacdec/mix_radix_fft.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mix_radix_fft.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions mix_radix_fft
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MIX_RADIX_FFT_H
-#define MIX_RADIX_FFT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FFT_RX4_LENGTH_FOR_LONG 512
-#define HALF_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>1)
-#define ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG (FFT_RX4_LENGTH_FOR_LONG>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int mix_radix_fft(
- Int32 *Data,
- Int32 *peak_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* MIX_RADIX_FFT_H */
diff --git a/media/libstagefright/codecs/aacdec/ms_map_mask.h b/media/libstagefright/codecs/aacdec/ms_map_mask.h
deleted file mode 100644
index fbbec78..0000000
--- a/media/libstagefright/codecs/aacdec/ms_map_mask.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- [Describe the contents of the include file.]
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MS_MAP_MASK_H
-#define MS_MAP_MASK_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void MS_map_mask(
- FrameInfo *info,
- Int *group,
- Int *mask,
- Int *cb_map);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/ms_synt.cpp b/media/libstagefright/codecs/aacdec/ms_synt.cpp
deleted file mode 100644
index 1f25516..0000000
--- a/media/libstagefright/codecs/aacdec/ms_synt.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ms_synt.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Cleaned up a bit, not finished.
-
- Description:
- Copied in code from pns_intensity_right.c, which has the same structure as
- this file. Also, merged in code from ms_map_mask.c
-
- Description:
- (1) Various optimizations (eliminated extra variables by making use of a
- single temporary register throughout the code, etc.)
- (2) Wrote pseudocode, pasted in correct function template, etc.
-
- Description: Unrolled loops to get speed up code
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- wins_in_group = Number of windows in the current group.
- [const Int]
-
- coef_per_win = Number of coefficients per window.
- [const Int]
-
- num_bands = Number of scalefactor bands.
- [const Int]
-
- band_length = Number of coefficients per scalefactor band.
- [const Int]
-
- pFirst_Window_CoefsL = Array containing the spectral coefficients for
- the left channel.
- [Int32 *, length LN]
- pFirst_Window_CoefsR = Array containing the spectral coefficients for
- the right channel.
- [Int32 *, length LN]
- q_formatLeft = Array containing the q-format used to encode each
- scalefactor band's data on the left channel.
- [Int *, length MAXBANDS]
- q_formatRight = Array containing the q-format used to encode each
- scalefactor band's data on the right channel.
- [Int *, length MAXBANDS]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- pFirst_Window_CoefsL The coefficients in the group will be modified per the
- formula for M/S stereo on each scalefactor band where
- M/S stereo is active.
-
- pFirst_Window_CoefsR The coefficients in the group will be modified per the
- formula for M/S stereo on each scalefactor band where
- M/S stereo is active.
-
- q_formatLeft The q_format may be modified on scalefactor bands
- where M/S stereo is active.
-
- q_formatRight The q_format may be modified on scalefactor bands
- where M/S stereo is active.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module applies the formula for M/S coding to one grouped scalefactor
- band. The ISO code has a similar function which applies M/S coding to an
- entire frame.
-
- It is the calling function's responsibility to check the map_mask array, which
- is filled by the function getmask. If a scalefactor band is identified as
- using M/S stereo, the coefficients in that array are calculated using
- the following formula...
-
- TempLeft = LeftCoefficient;
-
- LeftCoefficient = LeftCoefficient + RightCoefficient;
- RightCoefficient = TempLeft - RightCoefficient;
-
- This function should be inlined if the compiler supports C99 inlining,
- as this short function is only called by sfb_tools_ms().
- Therefore, inlining will not increase the code size.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.7.1 M/S stereo
- Subpart 4.6.2 ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- start_indx = 0;
-
- pCoefR = coefLeft;
- pCoefL = coefRight;
-
- FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
-
- tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx];
-
- IF (tempInt > 0)
- THEN
-
- shift_left_chan = 1 + tempInt;
- shift_right_chan = 1;
-
- q_formatLeft[start_indx] = (q_formatRight[start_indx] - 1);
- q_formatRight[start_indx] = (q_formatRight[start_indx] - 1);
-
- ELSE
- shift_left_chan = 1;
- shift_right_chan = 1 - tempInt;
-
- q_formatRight[start_indx] = (q_formatLeft[start_indx] - 1);
- q_formatLeft[start_indx] = (q_formatLeft[start_indx] - 1);
-
- ENDIF
-
- FOR (tempInt = band_length; tempInt > 0; tempInt--)
-
- temp_left = *(pCoefL) >> shift_left_chan;
- temp_right = *(pCoefR) >> shift_right_chan;
-
- *(pCoefL++) = temp_left + temp_right;
- *(pCoefR++) = temp_left - temp_right;
-
- ENDFOR
-
- tempInt = (coef_per_win - band_length);
-
- pCoefR = pCoefR + tempInt;
- pCoefL = pCoefL + tempInt;
-
- start_indx = start_indx + num_bands;
-
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ms_synt.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ms_synt(
- const Int wins_in_group,
- const Int coef_per_win,
- const Int num_bands,
- const Int band_length,
- Int32 coefLeft[],
- Int32 coefRight[],
- Int q_formatLeft[],
- Int q_formatRight[])
-{
-
- Int32 *pCoefL = coefLeft;
- Int32 *pCoefR = coefRight;
- Int start_indx = 0;
-
-
- if (band_length < 0 || band_length > LONG_WINDOW)
- {
- return; /* avoid any processing on error condition */
- }
-
-
- Int nextWinPtrUpdate = (coef_per_win - band_length);
-
- for (Int win_indx = wins_in_group; win_indx > 0; win_indx--)
- {
-
- if (q_formatRight[start_indx] < 31)
- {
- Int tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx];
-
- /* Normalize the left and right channel to the same q-format */
- if (tempInt > 0)
- {
- /*
- * shift_left_chan and shift_right_chan each have an offset
- * of 1. Even if the left and right channel share the same
- * q-format, we must shift each by 1 to guard against
- * overflow.
- */
- Int shift_left_chan = 1 + tempInt;
-
- /*
- * Following code line is equivalent to...
- * q_formatLeft = q_formatRight - 1;
- * q_formatRight = q_formatRight - 1;
- */
- q_formatLeft[start_indx] = --(q_formatRight[start_indx]);
-
-
- /*
- * band_length is always an even number (check tables in pg.66 IS0 14496-3)
- */
-
- Int32 temp_left = *(pCoefL) >> shift_left_chan;
- Int32 temp_right = *(pCoefR) >> 1;
-
-
-
- for (Int i = band_length; i != 0; i--)
- {
- *(pCoefL++) = temp_left + temp_right;
- *(pCoefR++) = temp_left - temp_right;
- temp_left = *(pCoefL) >> shift_left_chan;
- temp_right = *(pCoefR) >> 1;
-
- }
-
- }
- else
- {
- /*
- * shift_left_chan and shift_right_chan each have an offset
- * of 1. Even if the left and right channel share the same
- * q-format, we must shift each by 1 to guard against
- * overflow.
- */
- Int shift_right_chan = 1 - tempInt;
-
- /*
- * Following code line is equivalent to...
- * q_formatRight = q_formatLeft - 1;
- * q_formatLeft = q_formatLeft - 1;
- */
- q_formatRight[start_indx] = --(q_formatLeft[start_indx]);
-
- /*
- * band_length is always an even number (check tables in pg.66 IS0 14496-3)
- */
-
- Int32 temp_left = *(pCoefL) >> 1;
- Int32 temp_right = *(pCoefR) >> shift_right_chan;
-
- for (Int i = band_length; i != 0; i--)
- {
- *(pCoefL++) = temp_left + temp_right;
- *(pCoefR++) = temp_left - temp_right;
-
- temp_left = *(pCoefL) >> 1;
- temp_right = *(pCoefR) >> shift_right_chan;
-
- }
- }
-
- }
- else
- {
- /*
- * Nothing on right channel, just copy left into right
- */
- q_formatRight[start_indx] = (q_formatLeft[start_indx]);
-
- pv_memcpy(pCoefR, pCoefL, band_length*sizeof(*pCoefR));
- pCoefR += band_length;
- pCoefL += band_length;
- }
-
- /*
- * Increment the window pointers so they point
- * to the next window in the group
- */
- pCoefL += nextWinPtrUpdate;
- pCoefR += nextWinPtrUpdate;
-
- start_indx += num_bands;
-
- } /* for (win_indx) */
-
- return;
-
-} /* MS_synt */
diff --git a/media/libstagefright/codecs/aacdec/ms_synt.h b/media/libstagefright/codecs/aacdec/ms_synt.h
deleted file mode 100644
index a00e6e2..0000000
--- a/media/libstagefright/codecs/aacdec/ms_synt.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ms_synt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated to reflect new functionality of ms_synt() routine.
- (ms_synt now only decodes one grouped scalefactor band at a time.)
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for ms_synt().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MS_SYNT_H
-#define MS_SYNT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void ms_synt(
- const Int wins_in_group,
- const Int coef_per_win,
- const Int num_bands,
- const Int band_length,
- Int32 spectralCoefLeft[],
- Int32 spectralCoefRight[],
- Int q_formatLeft[],
- Int q_formatRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_corr.cpp b/media/libstagefright/codecs/aacdec/pns_corr.cpp
deleted file mode 100644
index 4cfe720..0000000
--- a/media/libstagefright/codecs/aacdec/pns_corr.cpp
+++ /dev/null
@@ -1,342 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_corr.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes per review comments, the most major of which
- being the change of the scaling into a 16 x 16 multiply.
-
- Description: When the multiplication of two 16-bits variables is stored in
- an 32-bits variable, the result should be typecasted explicitly
- to Int32 before it is stored.
- *(pCoefRight++) = (Int32) tempInt2 * multiplier;
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- scale = Multiplier used to scale the noise extracted from the left
- channel for use on the right.
- [const Int]
-
- coef_per_win = Number of coefficients per window.
- (128 for short, 1024 for long)
- [const Int]
-
- sfb_per_win = Number of scalefactors per window.
- [const Int]
-
- wins_in_group = The number of windows in the group being decoded.
- [const Int]
-
- band_length = The length of the scalefactor band being decoded.
- [const Int]
-
- sfb_prediction_used = Flag that denotes the activation of long term
- prediction on a per-scalefactor band,
- non-grouped basis.
- [const Int *, length MAX_SFB]
-
- q_formatLeft = The Q-format for the left channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [const Int]
-
- q_formatRight = The Q-format for the right channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAX_SFB]
-
- coefLeft = Array containing the fixed-point spectral coefficients
- for the left channel.
- [const Int32 *, length 1024]
-
- coefRight = Array containing the fixed-point spectral coefficients
- for the right channel.
- [Int32 *, length 1024]
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
- pcoefRight Contains the new spectral information
-
- q_formatRight Q-format may be updated with changed to fixed-point
- data in coefRight.
-
- sfb_prediction_used LTP may be disabled by presence of PNS tool on the
- same scalefactor band.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function derives noise from the left channel. The PNS tool is assumed
- to have been used on the same scalefactor band on the left channel. The
- noise on the left/right channels are not necessarily of the same amplitude,
- and therefore have separate scalefactors. The noise is thus scaled by the
- difference between the two transmitted scalefactors. This scaling is done
- in fixed-point using a constant 4-element table.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.7.1 M/S stereo
- Subpart 4.6.12.3 Decoding Process (PNS)
- Subpart 4.6.2 ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- q_format = q_formatLeft - (scale >> 2);
- q_format = q_format - 1;
- q_formatRight = q_format;
-
- multiplier = hcb2_scale_mod_4[scale & 0x3];
-
- pCoefLeft = coefLeft;
- pCoefRight = coefRight;
-
- start_indx = 0;
-
- FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
- q_formatRight[start_indx] = q_format;
-
- sfb_prediction_used[start_indx] = FALSE;
-
- start_indx = start_indx + sfb_per_win;
-
- FOR (tempInt = band_length; tempInt > 0; tempInt--)
-
- *(pCoefRight) = (*(pCoefLeft) >> 9) * multiplier;
- pCoefRight = pCoefRight + 1;
- pCoefLeft = pCoefLeft + 1;
-
- ENDFOR
-
- tempInt = (coef_per_win - band_length);
- pCoefRight = pCoefRight + tempInt;
- pCoefLeft = pCoefLeft + tempInt;
-
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_corr.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const UInt hcb2_scale_mod_4[4] =
-{
- 32768, /* (2.0^0.00)*2^15 */
- 38968, /* (2.0^0.25)*2^15 */
- 46341, /* (2.0^0.50)*2^15 */
- 55109
-}; /* (2.0^0.75)*2^15 */
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_corr(
- const Int scale,
- const Int coef_per_win,
- const Int sfb_per_win,
- const Int wins_in_group,
- const Int band_length,
- const Int q_formatLeft,
- Int q_formatRight[],
- const Int32 coefLeft[],
- Int32 coefRight[])
-{
- Int tempInt;
- Int nextWinPtrUpdate;
-
- Int q_format;
-
- Int start_indx;
- Int win_indx;
-
- const Int32 *pCoefLeft;
- Int32 *pCoefRight;
-
- UInt multiplier;
-
- /*
- * Generate noise correlated with the noise on the left channel
- *
- */
-
- /*
- * scale is interpreted as 2^(scale/4)
- * Therefore, we can adjust the q-format by floor(scale/4)
- * and save some complexity in the multiplier.
- */
- q_format = q_formatLeft - (scale >> 2);
-
- /*
- * Reduce the q-format by 1 to guard against overflow.
- * This must be done because the hcb2_scale_mod_4 table
- * must be stored in a common q-format, and we must shift
- * by 16 to get *pCoefLeft into a 16-bit value, but we
- * cannot store 2^0*2^16 and 2^0.75*2^16 in a table.
- */
- q_format--;
-
- multiplier = hcb2_scale_mod_4[scale & 0x3];
-
- pCoefLeft = coefLeft;
- pCoefRight = coefRight;
-
- nextWinPtrUpdate = (coef_per_win - band_length);
-
- /*
- * Step through all the windows in this group, replacing this
- * band in each window's spectrum with correlated random noise
- */
-
- start_indx = 0;
-
- for (win_indx = wins_in_group; win_indx > 0; win_indx--)
- {
- /*
- * Set the q-format for all scalefactor bands in the group.
- * Normally, we could not assume that grouped scalefactors
- * share the same q-format.
- * However, here we can make this assumption. The reason
- * being -- if this function is called, it is assumed
- * PNS was used on the left channel. When PNS is used,
- * all scalefactors in a group share the same q-format.
- *
- */
- q_formatRight[start_indx] = q_format;
-
- start_indx += sfb_per_win;
-
- /* reconstruct right noise values */
- for (tempInt = band_length; tempInt > 0; tempInt--)
- {
- *(pCoefRight++) = (Int32)(*(pCoefLeft++) >> 16) * multiplier;
- }
-
- pCoefRight += nextWinPtrUpdate;
- pCoefLeft += nextWinPtrUpdate;
-
- } /* for (win_indx) */
-
- return;
-
-} /* void pns_corr */
diff --git a/media/libstagefright/codecs/aacdec/pns_corr.h b/media/libstagefright/codecs/aacdec/pns_corr.h
deleted file mode 100644
index c892a8c..0000000
--- a/media/libstagefright/codecs/aacdec/pns_corr.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_corr.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes per review comments.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function declaration for pns_corr.c
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_CORR_H
-#define PNS_CORR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void pns_corr(
- const Int scale,
- const Int coef_per_win,
- const Int sfb_per_win,
- const Int wins_in_group,
- const Int band_length,
- const Int q_formatLeft,
- Int q_formatRight[],
- const Int32 coefLeft[],
- Int32 coefRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp b/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp
deleted file mode 100644
index f2d50c1..0000000
--- a/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp
+++ /dev/null
@@ -1,653 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_intensity_right.c
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- hasmask = mask status for the frame. Enumerated.
-
- pFrameInfo = Pointer to structure that holds information about each group.
- (long block flag, number of windows, scalefactor bands
- per group, etc.)
- [const pFrameInfo * const]
-
- group = Array that contains indexes of the
- first window in the next group.
- [const Int *, length num_win]
-
- mask_map = Array that denotes whether M/S stereo is turned on for
- each grouped scalefactor band.
- [const Int *, length MAX_SFB]
-
- codebook_map = Array that denotes which Huffman codebook was used for
- the encoding of each grouped scalefactor band.
- [const Int *, length MAX_SFB]
-
- factorsL = Array of grouped scalefactors for left chan.
- [const Int *, length MAX_SFB]
-
- factorsR = Array of scalefactors for right chan.
- [const Int *, length MAX_SFB]
-
- sfb_prediction_used = Flag that denotes the activation of long term prediction
- on a per-scalefactor band, non-grouped basis.
- [const Int *, length MAX_SFB]
-
- ltp_data_present = Flag that indicates whether LTP is enbaled for this frame.
- [const Bool]
-
- coefLeft = Array containing the fixed-point spectral coefficients
- for the left channel.
- [Int32 *, length 1024]
-
- coefRight = Array containing the fixed-point spectral coefficients
- for the right channel.
- [Int32 *, length 1024]
-
- q_formatLeft = The Q-format for the left channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAX_SFB]
-
- q_formatRight = The Q-format for the right channel's fixed-point spectral
- coefficients, on a per-scalefactor band, non-grouped basis.
- [Int *, length MAX_SFB]
-
- pCurrentSeed = Pointer to the current seed for the random number
- generator in the function gen_rand_vector().
- [Int32 * const]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coefLeft = Contains the new spectral information.
-
- coefRight = Contains the new spectral information.
-
- q_formatLeft = Q-format may be updated with changed to fixed-point
- data in coefLeft.
-
- q_formatRight = Q-format may be updated with changed to fixed-point
- data in coefRight.
-
- pCurrentSeed = Value pointed to by pCurrentSeed updated by calls
- to gen_rand_vector().
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function steps through all of the scalefactor bands, looking for
- either PNS or IS to be enabled on the right channel.
-
- If the codebook used is >= NOISE_HCB, the code then checks for the use
- of Huffman codebooks NOISE_HCB, INTENSITY_HCB, or INTENSITY_HCB2.
-
- When a SFB utilizing the codebook NOISE_HCB is detected, a check is made to
- see if M/S has also been enabled for that SFB.
-
- If M/S is not enabled, the band's spectral information is filled with
- scaled random data. The scaled random data is generated by the function
- gen_rand_vector. This is done across all windows in the group.
-
- If M/S is enabled, the band's spectral information is derived from the data
- residing in the same band on the left channel. The information on the right
- channel has independent scaling, so this is a bit more involved than a
- direct copy of the information on the left channel. This is done by calling
- the inline function pns_corr().
-
- When a SFB utilizing an intensity codebook is detected, the band's spectral
- information is generated from the information on the left channel.
- This is done across all windows in the group. M/S being enabled has the
- effect of reversing the sign of the data on the right channel. This code
- resides in the inline function intensity_right().
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.7.1 M/S stereo
- Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo)
- Subpart 4.6.12.3 Decoding Process (PNS)
- Subpart 4.6.2 ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
- pCoefRight = coefRight;
- pCoefLeft = coefLeft;
-
- window_start = 0;
- tot_sfb = 0;
- start_indx = 0;
-
- coef_per_win = pFrameInfo->coef_per_win[0];
-
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- DO
- pBand = pFrameInfo->win_sfb_top[window_start];
-
- partition = *pGroup;
- pGroup = pGroup + 1;
-
- band_start = 0;
-
- wins_in_group = (partition - window_start);
-
- FOR (sfb = sfb_per_win; sfb > 0; sfb--)
-
- band_stop = *(pBand);
- pBand = pBand + 1;
-
- codebook = *(pCodebookMap);
- pCodebookMap = pCodebookMap + 1;
-
- mask_enabled = *(pMaskMap);
- pMaskMap = pMaskMap + 1;
-
- band_length = band_stop - band_start;
-
- IF (codebook == NOISE_HCB)
-
- sfb_prediction_used[tot_sfb] &= ltp_data_present;
-
- IF (sfb_prediction_used[tot_sfb] == FALSE)
-
- mask_enabled = mask_enabled AND hasmask;
-
- IF (mask_enabled == FALSE)
-
- pWindow_CoefR = &(pCoefRight[band_start]);
-
- start_indx = tot_sfb;
-
- FOR (win_indx = wins_in_group;
- win_indx > 0;
- win_indx--)
-
- CALL
- q_formatRight[start_indx] =
- gen_rand_vector(
- pWindow_CoefR,
- band_length,
- pCurrentSeed,
- *(pFactorsRight));
- MODIFYING
- pCoefRight[band_start]
- RETURNING
- q_formatRight[start_indx]
-
- pWindow_CoefR += coef_per_win;
-
- start_indx = start_indx + sfb_per_win;
-
- ENDFOR
-
- ELSE
- CALL
- pns_corr(
- (*(pFactorsRight) -
- *(pFactorsLeft) ),
- coef_per_win,
- sfb_per_win,
- wins_in_group,
- band_length,
- q_formatLeft[tot_sfb],
- &(q_formatRight[tot_sfb]),
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]));
-
- MODIFYING
- pCoefRightt[band_start]
- q_formatRight[tot_sfb]
- RETURNING
- NONE
- ENDIF
-
- ENDIF
-
- ELSE IF (codebook >= INTENSITY_HCB2)
-
- mask_enabled = mask_enabled AND hasmask;
-
- CALL
- intensity_right(
- *(pFactorsRight),
- coef_per_win,
- sfb_per_win,
- wins_in_group,
- band_length,
- codebook,
- mask_enabled,
- &(q_formatLeft[tot_sfb]),
- &(q_formatRight[tot_sfb]),
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]));
-
- MODIFYING
- pCoefRightt[band_start]
- q_formatRight[tot_sfb]
- RETURNING
- NONE
-
- ENDIF
-
- band_start = band_stop;
-
- tot_sfb = tot_sfb + 1;
-
- ENDFOR
-
- coef_per_win = coef_per_win * (wins_in_group);
-
- wins_in_group = wins_in_group - 1;
-
- tot_sfb = tot_sfb + sfb_per_win * wins_in_group;
- pFactorsRight = pFactorsRight + sfb_per_win * wins_in_group;
- pFactorsLeft = pFactorsLeft + sfb_per_win * wins_in_group;
-
- pCoefRight = pCoefRight + coef_per_win;
- pCoefLeft = pCoefLeft + coef_per_win;
-
- window_start = partition;
-
- WHILE (partition < pFrameInfo->num_win);
-
- return;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_intensity_right.h"
-#include "e_huffmanconst.h"
-#include "gen_rand_vector.h"
-#include "intensity_right.h"
-#include "pns_corr.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_intensity_right(
- const Int hasmask,
- const FrameInfo * const pFrameInfo,
- const Int group[],
- const Bool mask_map[],
- const Int codebook_map[],
- const Int factorsL[],
- const Int factorsR[],
- Int sfb_prediction_used[],
- const Bool ltp_data_present,
- Int32 coefLeft[],
- Int32 coefRight[],
- Int q_formatLeft[MAXBANDS],
- Int q_formatRight[MAXBANDS],
- Int32 * const pCurrentSeed)
-{
-
- Int32 *pCoefRight;
- Int32 *pWindow_CoefR;
-
- Int32 *pCoefLeft;
-
- Int tot_sfb;
- Int start_indx;
- Int sfb;
-
- Int band_length;
- Int band_start;
- Int band_stop;
- Int coef_per_win;
-
- Int codebook;
- Int partition;
- Int window_start;
-
- Int sfb_per_win;
- Int wins_in_group;
- Int win_indx;
-
- const Int16 *pBand;
- const Int *pFactorsLeft = factorsL;
- const Int *pFactorsRight = factorsR;
- const Int *pCodebookMap = codebook_map;
- const Int *pGroup = group;
- const Bool *pMaskMap = mask_map;
-
- Bool mask_enabled;
-
- pCoefRight = coefRight;
- pCoefLeft = coefLeft;
-
- window_start = 0;
- tot_sfb = 0;
- start_indx = 0;
-
- /*
- * Each window in the frame should have the same number of coef's,
- * so coef_per_win is constant in all the loops
- */
- coef_per_win = pFrameInfo->coef_per_win[0];
-
- /*
- * Because the number of scalefactor bands per window should be
- * constant for each frame, sfb_per_win can be determined outside
- * of the loop.
- *
- * For 44.1 kHz sampling rate sfb_per_win = 14 for short windows
- * sfb_per_win = 49 for long windows
- */
-
- sfb_per_win = pFrameInfo->sfb_per_win[0];
-
- do
- {
- pBand = pFrameInfo->win_sfb_top[window_start];
-
- /*----------------------------------------------------------
- Partition is equal to the first window in the next group
-
- { Group 0 }{ Group 1 }{ Group 2 }{Group 3}
- [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
-
- pGroup[0] = 2
- pGroup[1] = 5
- pGroup[2] = 7
- pGroup[3] = 8
- -----------------------------------------------------------*/
- partition = *(pGroup++);
-
- band_start = 0;
-
- wins_in_group = (partition - window_start);
-
- for (sfb = sfb_per_win; sfb > 0; sfb--)
- {
- /* band is offset table, band_stop is last coef in band */
- band_stop = *(pBand++);
-
- codebook = *(pCodebookMap++);
-
- mask_enabled = *(pMaskMap++);
-
- /*
- * When a tool utilizing sfb is found, apply the correct tool
- * to that sfb in each window in the group
- *
- * Example... sfb[3] == NOISE_HCB
- *
- * [ Group 1 ]
- * [win 0 ][win 1 ]
- * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7]
- *
- * The for(sfb) steps through the sfb's 0-7 in win 0.
- *
- * Finding sfb[3]'s codebook == NOISE_HCB, the code
- * steps through all the windows in the group (they share
- * the same scalefactors) and replaces that sfb with noise.
- */
-
- /*
- * Experimental results suggest that ms_synt is the most
- * commonly used tool, so check for it first.
- *
- */
-
- band_length = band_stop - band_start;
-
- if (codebook == NOISE_HCB)
- {
- sfb_prediction_used[tot_sfb] &= ltp_data_present;
-
- if (sfb_prediction_used[tot_sfb] == FALSE)
- {
- /*
- * The branch and the logical AND interact in the
- * following manner...
- *
- * mask_enabled == 0 hasmask == X -- gen_rand_vector
- * mask_enabled == 1 hasmask == 1 -- pns_corr
- * mask_enabled == 0 hasmask == 1 -- gen_rand_vector
- * mask_enabled == 1 hasmask == 2 -- gen_rand_vector
- * mask_enabled == 0 hasmask == 2 -- gen_rand_vector
- */
-
- mask_enabled &= hasmask;
-
- if (mask_enabled == FALSE)
- {
- pWindow_CoefR = &(pCoefRight[band_start]);
-
- /*
- * Step through all the windows in this group,
- * replacing this band in each window's
- * spectrum with random noise
- */
- start_indx = tot_sfb;
-
- for (win_indx = wins_in_group;
- win_indx > 0;
- win_indx--)
- {
-
- /* generate random noise */
- q_formatRight[start_indx] =
- gen_rand_vector(
- pWindow_CoefR,
- band_length,
- pCurrentSeed,
- *(pFactorsRight));
-
- pWindow_CoefR += coef_per_win;
-
- start_indx += sfb_per_win;
- }
-
- }
- else
- {
- pns_corr(
- (*(pFactorsRight) -
- *(pFactorsLeft)),
- coef_per_win,
- sfb_per_win,
- wins_in_group,
- band_length,
- q_formatLeft[tot_sfb],
- &(q_formatRight[tot_sfb]),
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]));
-
- } /* if (mask_map == FALSE) */
-
- } /* if (sfb_prediction_used[tot_sfb] == FALSE) */
-
- } /* if (codebook == 0) */
- else if (codebook >= INTENSITY_HCB2)
- {
- /*
- * The logical AND flags the inversion of intensity
- * in the following manner.
- *
- * mask_enabled == X hasmask == 0 -- DO NOT INVERT
- * mask_enabled == 0 hasmask == X -- DO NOT INVERT
- * mask_enabled == 1 hasmask == 1 -- DO INVERT
- * mask_enabled == 0 hasmask == 1 -- DO NOT INVERT
- * mask_enabled == 1 hasmask == 2 -- DO NOT INVERT
- * mask_enabled == 0 hasmask == 2 -- DO NOT INVERT
- */
-
- mask_enabled &= hasmask;
-
- intensity_right(
- *(pFactorsRight),
- coef_per_win,
- sfb_per_win,
- wins_in_group,
- band_length,
- codebook,
- mask_enabled,
- &(q_formatLeft[tot_sfb]),
- &(q_formatRight[tot_sfb]),
- &(pCoefLeft[band_start]),
- &(pCoefRight[band_start]));
-
- } /* END else codebook must be INTENSITY_HCB or ... */
-
- band_start = band_stop;
-
- tot_sfb++;
-
- pFactorsLeft++;
- pFactorsRight++;
-
- } /* for (sfb) */
-
- /*
- * Increment pCoefRight and pCoefLeft by
- * coef_per_win * the number of windows
- */
-
- pCoefRight += coef_per_win * wins_in_group;
- pCoefLeft += coef_per_win * wins_in_group--;
-
- /*
- * Increase tot_sfb by sfb_per_win times the number of windows minus 1.
- * The minus 1 comes from the fact that tot_sfb is already pointing
- * to the first sfb in the 2nd window of the group.
- */
- tot_sfb += sfb_per_win * wins_in_group;
-
- pFactorsRight += sfb_per_win * wins_in_group;
- pFactorsLeft += sfb_per_win * wins_in_group;
-
- window_start = partition;
-
- }
- while (partition < pFrameInfo->num_win);
-
- /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */
-
- return;
-
-} /* pns_intensity_right() */
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_intensity_right.h b/media/libstagefright/codecs/aacdec/pns_intensity_right.h
deleted file mode 100644
index 7b6f79f..0000000
--- a/media/libstagefright/codecs/aacdec/pns_intensity_right.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_intensity_right.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Add hasmask parameter
-
- Description: Changed name to from right_ch_sfb_tools_ms to intensity_right
- to more correct reflect the purpose of the function.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- pns_intensity_right.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_INTENSITY_RIGHT_H
-#define PNS_INTENSITY_RIGHT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void pns_intensity_right(
- const Int hasmask,
- const FrameInfo * const pFrameInfo,
- const Int group[],
- const Bool mask_map[],
- const Int codebook_map[],
- const Int factorsL[],
- const Int factorsR[],
- Int sfb_prediction_used[],
- const Bool ltp_data_present,
- Int32 spectralCoefLeft[],
- Int32 spectralCoefRight[],
- Int q_formatLeft[MAXBANDS],
- Int q_formatRight[MAXBANDS],
- Int32 * const pCurrentSeed);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_left.cpp b/media/libstagefright/codecs/aacdec/pns_left.cpp
deleted file mode 100644
index 2446de2..0000000
--- a/media/libstagefright/codecs/aacdec/pns_left.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: pns_left.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Brought code in-line with PV standards.
- Merged PNS and Intensity blocks into one function.
- Modified routine to interface with a fixed-point implementation.
- Modified variable names for clarity.
- Improved for-loop structure that was previously checking
- the codebook used in each scale factor band multiple times.
-
- Description: Added some comments for clarity.
-
- Description: Changed strategy for q-format. Q-format for SFBs should not
- be grouped.
-
- Description: Function had to be modified to obey new interpretation of the
- sfb_prediction_used flag. LTP takes precedence, and PNS should not be
- executed when a collision occurs between these two tools.
-
- Description:
- (1) Added flag "ltp_data_present"
- (2) Where feasible, I updated the code to resemble right_ch_sfb_tools_ms.c
- Just for conformance, readability.
-
- Description: Added include file - "e_huffmanconst.h"
-
- Description: The same "Factors" pointer indexing problem that existed in
- right_ch_sfb_tools_ms also existed here in pns_left.c
-
- Description: Modified how groups and windows are handled, as the multigroup
- case was not correct
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- const FrameInfo *pFrameInfo = Pointer to structure that holds
- information about each group.
- (long block flag,
- number of windows,
- scalefactor bands per group, etc.)
-
- const Int group[] = Array that contains indexes of the
- the first window in the next group.
-
- const Int codebook_map[] = Array that denotes which Huffman
- codebook was used for the encoding
- of each scalefactor band.
-
- const Int factors[] = Array of scalefactors
-
- Int sfb_prediction_used[] = Flag that denotes the activation
- of long term prediction on a sfb
- basis.
-
- Bool ltp_data_present = Flag that denotes whether LTP
- is active for the entire frame. If
- this flag is FALSE,
- sfb_prediction_used is garbage.
-
- Int32 spectral_coef[] = Array of pointers pointing to the
- spectral coef's for the LEFT channel.
-
- Int q_format[] = Q-format for the information
- pointed to by spectral_coef.
- Indexed by scalefactor band.
-
- Int32 *pCurrentSeed = Pointer to the current seed for the
- random number generator.
- (gen_rand_vector)
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
- Int32 spectral_coef[] = Contains the new spectral information
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- The function steps through each scalefactor band in the group, and
- checks for the use of Huffman codebook NOISE_HCB.
-
- When a SFB utilizing NOISE_HCB is detected, the band in every window in the
- group has its spectral information filled with scaled random data.
-
- The scaled random data is generated by the function gen_rand_vector.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall replace bands that were encoded with the Huffman codebook
- NOISE_HCB with random noise as returned from gen_rand_vector(). The result
- shall be perceptually indistinguishable from the result obtained by the
- ISO decoder.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.5.5 Figures
- Subpart 4.6.2 ScaleFactors
- Subpart 4.6.12 Perceptual Noise Substituion (PNS)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pFirst_Window_Coefs = spectral_coef;
-
- window_start = 0;
-
- tot_sfb = 0;
-
- DO
-
- num_bands = pFrameInfo->sfb_per_win[window_start];
- pBand = pFrameInfo->win_sfb_top[window_start];
-
- partition = *(pGroup);
- pGroup = pGroup + 1;
-
- band_start = 0;
-
- coef_per_win = pFrameInfo->coef_per_win[window_start];
-
- wins_in_group = (partition - window_start);
-
- FOR (sfb = num_bands; sfb > 0; sfb--)
-
- band_stop = *pBand;
- pBand = pBand + 1;
-
- IF (*(pCodebookMap++) == NOISE_HCB )
-
- tempInt = sfb_prediction_used[tot_sfb] AND ltp_data_present;
-
- IF (tempInt == FALSE)
-
- pWindow_Coef = pFirst_Window_Coefs + band_start;
-
- band_length = (band_stop - band_start);
-
- start_indx = tot_sfb;
-
- tempInt = *(pFactors);
-
- FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
- CALL gen_rand_vector( pWindow_CoefR,
- band_length,
- pCurrentSeed,
- tempInt);
-
- MODIFYING pWindow_CoefR = scaled random noise
- pCurrentSeed = current state of the random
- noise generator.
-
- RETURNING q_format[start_indx] = q-format for this sfb.
-
- pWindow_Coef = pWindow_Coef + coef_per_win;
-
- start_indx = start_indx +
- pFrameInfo->sfb_per_win[win_indx];
-
- ENDFOR
-
- ENDIF
-
- ENDIF
-
- band_start = band_stop;
-
- tot_sfb = tot_sfb + 1;
-
- pFactors = pFactors + 1;
-
- ENDFOR
-
- coef_per_win = coef_per_win * wins_in_group;
- wins_in_group = wins_in_group - 1;
-
- tot_sfb = tot_sfb + num_bands * wins_in_group;
- pFactors = pFactors + num_bands * wins_in_group;
-
- pFirst_Window_Coefs = pFirst_Window_Coefs + coef_per_win;
-
- window_start = partition;
-
- WHILE (partition < pFrameInfo->num_win);
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_left.h"
-#include "e_huffmanconst.h"
-#include "gen_rand_vector.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_left(
- const FrameInfo *pFrameInfo,
- const Int group[],
- const Int codebook_map[],
- const Int factors[],
- const Int sfb_prediction_used[],
- const Bool ltp_data_present,
- Int32 spectral_coef[],
- Int q_format[],
- Int32 *pCurrentSeed)
-{
-
- Int tot_sfb;
- Int start_indx;
-
- Int sfb;
- Int band_stop;
-
- const Int16 *pBand;
-
- const Int *pCodebookMap = &(codebook_map[0]);
- const Int *pGroup = &(group[0]);
- const Int *pFactors = &(factors[0]);
-
- Int tempInt;
- Int32 *pWindow_Coef;
-
-
- Int32 *spec;
-
- Int partition;
- Int win_indx;
-
- tot_sfb = 0;
-
- spec = spectral_coef;
-
- /* PNS goes by group */
- win_indx = 0;
- partition = 0;
- do
- {
- Int num_bands = pFrameInfo->sfb_per_win[partition];
- pBand = pFrameInfo->win_sfb_top[partition];
-
- /*----------------------------------------------------------
- Partition is equal to the first window in the next group
-
- { Group 0 }{ Group 1 }{ Group 2 }{Group 3}
- [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
-
- pGroup[0] = 2
- pGroup[1] = 5
- pGroup[2] = 7
- pGroup[3] = 8
- -----------------------------------------------------------*/
-
- partition = *pGroup++; /* partition = index of last sbk in group */
-
- do
- {
- Int band_start = 0;
- for (sfb = 0; sfb < num_bands; sfb++)
- {
- band_stop = pBand[sfb]; /* band is offset table, band_stop is last coef in band */
-
- Int band_length = band_stop - band_start;
- if (pCodebookMap[sfb] == NOISE_HCB)
- {
-
- tempInt = sfb_prediction_used[tot_sfb] & ltp_data_present;
-
- if (tempInt == FALSE)
- {
- /* generate random noise */
- pWindow_Coef = spec + band_start;
-
- tempInt = pFactors[sfb];
-
- start_indx = tot_sfb++;
-
- /* reconstruct noise substituted values */
- /* generate random noise */
-
- q_format[start_indx] = gen_rand_vector(pWindow_Coef,
- band_length,
- pCurrentSeed,
- tempInt);
-
- } /* if (sfb_prediction_used[tot_sfb] == FALSE) */
-
- } /* if (*(pCodebookMap++) == NOISE_HCB) */
- else
- {
- tot_sfb ++; /* update absolute sfb counter */
- }
-
- band_start = band_stop;
-
- } /* for (sfb) */
-
- spec += pFrameInfo->coef_per_win[win_indx++];
- pFactors += num_bands;
-
- }
- while (win_indx < partition);
-
- pCodebookMap += pFrameInfo->sfb_per_win[win_indx-1];
-
- }
- while (partition < pFrameInfo->num_win);
-
-
- return;
-
-} /* pns */
diff --git a/media/libstagefright/codecs/aacdec/pns_left.h b/media/libstagefright/codecs/aacdec/pns_left.h
deleted file mode 100644
index c44b13c..0000000
--- a/media/libstagefright/codecs/aacdec/pns_left.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_left.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Removed #defines of LEFT and RIGHT, and the extra include
- file "e_huffmanconst.h"
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function definition for pns_left.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_LEFT_H
-#define PNS_LEFT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void pns_left(
- const FrameInfo *pFrameInfo,
- const Int group[],
- const Int codebook_map[],
- const Int factors[],
- const Int sfb_prediction_used[],
- const Bool ltp_data_present,
- Int32 spectral_coef[],
- Int q_format[],
- Int32 *pCurrentSeed);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
-
-
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp b/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp
deleted file mode 100644
index 48432f8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_all_pass_filter_coeff.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decorrelation is achieved by means of all-pass filtering
-
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_all_pass_fract_delay_filter.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS] =
-{
-
-
- { Qfmt15(0.74915491616071f), Qfmt15(0.64942584030892f), Qfmt15(0.56297290849050f) },
- { Qfmt15(0.71658296328416f), Qfmt15(0.62118993420853f), Qfmt15(0.53849582551265f) },
- { Qfmt15(0.68401101040761f), Qfmt15(0.59295402810815f), Qfmt15(0.51401874253480f) },
- { Qfmt15(0.65143905753106f), Qfmt15(0.56471812200776f), Qfmt15(0.97908331911390f) }, /* 3 */
- { Qfmt15(0.61886710465450f), Qfmt15(0.53648221590737f), Qfmt15(0.93012915315822f) },
- { Qfmt15(0.58629515177795f), Qfmt15(0.50824630980698f), Qfmt15(0.88117498720252f) },
- { Qfmt15(0.55372319890140f), Qfmt15(0.48001040370660f), Qfmt15(0.83222082124682f) },
- { Qfmt15(0.52115124602484f), Qfmt15(0.45177449760621f), Qfmt15(0.78326665529112f) },
- { Qfmt15(0.48857929314829f), Qfmt15(0.42353859150582f), Qfmt15(0.73431248933542f) },
- { Qfmt15(0.45600734027174f), Qfmt15(0.39530268540543f), Qfmt15(0.68535832337974f) },
- { Qfmt15(0.42343538739519f), Qfmt15(0.36706677930504f), Qfmt15(0.63640415742404f) },
- { Qfmt15(0.39086343451863f), Qfmt15(0.33883087320466f), Qfmt15(0.58744999146834f) },
- { Qfmt15(0.35829148164208f), Qfmt15(0.31059496710427f), Qfmt15(0.53849582551265f) },
- { Qfmt15(0.32571952876553f), Qfmt15(0.28235906100388f), Qfmt15(0.48954165955695f) },
- { Qfmt15(0.29314757588898f), Qfmt15(0.25412315490349f), Qfmt15(0.44058749360126f) },
- { Qfmt15(0.26057562301242f), Qfmt15(0.22588724880310f), Qfmt15(0.39163332764556f) },
- { Qfmt15(0.22800367013587f), Qfmt15(0.19765134270272f), Qfmt15(0.34267916168986f) },
- { Qfmt15(0.19543171725932f), Qfmt15(0.16941543660233f), Qfmt15(0.29372499573418f) },
- { Qfmt15(0.16285976438276f), Qfmt15(0.14117953050194f), Qfmt15(0.24477082977848f) },
- { Qfmt15(0.13028781150621f), Qfmt15(0.11294362440155f), Qfmt15(0.19581666382278f) },
- { Qfmt15(0.09771585862966f), Qfmt15(0.08470771830116f), Qfmt15(0.14686249786708f) },
- { Qfmt15(0.06514390575311f), Qfmt15(0.05647181220078f), Qfmt15(0.09790833191140f) },
- { Qfmt15(0.03257195287655f), Qfmt15(0.02823590610039f), Qfmt15(0.04895416595570f) }
-
-};
-
-
-
-
-
-const Char groupBorders[NO_IID_GROUPS + 1] =
-{
- 4, 5, 0, 1, 2, 3, 7, 6, 8, 9, 3, 4,
- 5, 6, 7, 8, 9, 11, 14, 18, 23, 35, 64
-};
-
-const Char bins2groupMap[NO_IID_GROUPS] =
-{
- 1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
-};
-
-
-
-
-/*
- * q_phi = 0.39
- *
- * cos(pi*([3:22]+0.5)*q_phi)
- */
-
-
-/*
- * sin(-pi*([3:22]+0.5)*q_phi)
- */
-
-
-const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS] =
-{
- 0xCB5474A9, 0x5BEC5914, 0x72F3C7B0, 0xF1F480C6, 0x8389E21E,
- 0xB9BA6AFC, 0x4CDB665C, 0x7A57DA5D, 0x06088024, 0x89BECF04,
- 0xA9DB5EAC, 0x3BE5711F, 0x7EB9EDF7, 0x19F582A9, 0x92DDBD1F,
- 0x9C1B5008, 0x29767919, 0x7FFC0203, 0x2D3F8843, 0x9EABACDF
-};
-
-/*
- * q(m) = { 0.43, 0.75, 0.347 }
- *
- * cos(pi*([3:22]+0.5)*q(m)) cos(pi*([3:22]+0.5)'*q)
- *
- * sin(-pi*([3:22]+0.5)*q(m))
- *
- */
-
-
-const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3] =
-{
- { 0x02037FFC, 0xCF0489BE, 0x9BFB4FE0 },
- { 0x7D5719F5, 0xCF047642, 0x18947D9E },
- { 0x34AD8B57, 0x7642CF04, 0x7ABF244A },
- { 0x99A4B325, 0x89BECF04, 0x58EFA3F1 },
- { 0x9EAB5321, 0x30FC7642, 0xD77E8694 },
- { 0x3BE5711F, 0x30FC89BE, 0x819CEBC7 },
- { 0x7B77DE39, 0x89BE30FC, 0xB3A166B8 },
- { 0xF9F88024, 0x764230FC, 0x37C57336 },
- { 0x81E8E9FE, 0xCF0489BE, 0x7FF103D2 },
- { 0xCF047642, 0xCF047642, 0x3E8B9052 },
- { 0x68B9499A, 0x7642CF04, 0xB9E594E8 },
- { 0x5EACA9DB, 0x89BECF04, 0x80A00CA5 },
- { 0xC09590D1, 0x30FC7642, 0xD05276CA },
- { 0x85A925A3, 0x30FC89BE, 0x53486134 },
- { 0x0A0B7F9B, 0x89BE30FC, 0x7CB2E319 },
- { 0x7EB91209, 0x764230FC, 0x20078412 },
- { 0x2D3F8843, 0xCF0489BE, 0xA0ECAA4D },
- { 0x9504B9BA, 0xCF047642, 0x880D2CAE },
- { 0xA4145914, 0x7642CF04, 0xF0287F04 },
- { 0x42E16D23, 0x89BECF04, 0x694C48C7 }
-};
-
-/*
- * Fractional delay vector
- *
- * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS
- *
- * q_phi = 0.39
- * f_center(k) frequency vector
- *
- *
- * f_center(k) = {0.5/4, 1.5/4, 2.5/4, 3.5/4,
- * -1.5/4, -0.5/4,
- * 3.5/2, 2.5/2, 4.5/2, 5.5/2};
- */
-
-
-
-const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS] =
-{
- 0x7E80EC79, 0x72BAC73D, 0x5C45A749, 0x3D398F97, 0x72BA38C3,
- 0x7E801387, 0xBA919478, 0x05068019, 0x895DCFF2, 0x834E1CE7,
-};
-
-
-
-
-
-/*
- * Fractional delay length matrix
- *
- * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k))
- *
- * q(m) = { 0.43, 0.75, 0.347 }
- * f_center(k) frequency vector
- *
- *
- * f_center(k) = { 0.5/4, 1.5/4, 2.5/4, 3.5/4,
- * -1.5/4, -0.5/4,
- * 3.5/2, 2.5/2, 4.5/2, 5.5/2};
- */
-
-const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3] =
-{
-
- { 0x7E2EEA7D, 0x7A7DDAD8, 0x7ED0EE9D },
- { 0x6FEDC1E5, 0x51349D0E, 0x7574CD1E },
- { 0x5506A052, 0x0C8C809E, 0x636CAF62 },
- { 0x3085898D, 0xC3A98F1D, 0x4A0D9799 },
- { 0x6FED3E1B, 0x513462F2, 0x757432E2 },
- { 0x7E2E1583, 0x7A7D2528, 0x7ED01163 },
- { 0xA4C8A634, 0xB8E36A6E, 0xD5AF8732 },
- { 0xF0F580E3, 0x8276E707, 0x1A7382C3 },
- { 0x80ABF2F4, 0x471D6A6E, 0x9D2FAEA4 },
- { 0x9478456F, 0x7D8AE707, 0x8152EDAB }
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h b/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h
deleted file mode 100644
index 0358acb..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_all_pass_filter_coeff.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for all pass filter coefficients
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALL_PASS_FILTER_COEFF_H
-#define PS_ALL_PASS_FILTER_COEFF_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-extern const Char groupBorders[NO_IID_GROUPS + 1];
-extern const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS];
-extern const Int32 aRevLinkDelaySer[];
-extern const Int16 aFractDelayPhaseFactorReQmf[NO_QMF_ALLPASS_CHANNELS];
-extern const Int16 aFractDelayPhaseFactorImQmf[NO_QMF_ALLPASS_CHANNELS];
-/* the old center frequencies (found in "else") were too small (factor 1/2) */
-extern const Int16 aFractDelayPhaseFactorReSubQmf[SUBQMF_GROUPS];
-extern const Int16 aFractDelayPhaseFactorImSubQmf[SUBQMF_GROUPS];
-extern const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS];
-extern const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS];
-extern const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3];
-extern const Char bins2groupMap[NO_IID_GROUPS];
-extern const Int32 aaFractDelayPhaseFactorSerReQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerImQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerReSubQmf[SUBQMF_GROUPS][3];
-extern const Int32 aaFractDelayPhaseFactorSerImSubQmf[SUBQMF_GROUPS][3];
-
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_ALL_PASS_FILTER_COEFF_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp b/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp
deleted file mode 100644
index 81761a6..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_all_pass_fract_delay_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decorrelation
- Decorrelation is achieved by means of all-pass filtering and delaying
- Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
- d_k(n). k index for frequency, n time index
-
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
- Delay is introduced to compensate QMF bands not passed through Hybrid
- Analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "ps_decorrelate.h"
-#include "aac_mem_funcs.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_pwr_transient_detection.h"
-#include "ps_all_pass_fract_delay_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*
- * For lower subbands
- * Apply all-pass filtering
- *
- */
-
-
-void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex,
- Int32 sb_delay,
- const Int32 *ppFractDelayPhaseFactorSer,
- Int32 ***pppRealDelayRBufferSer,
- Int32 ***pppImagDelayRBufferSer,
- Int32 *rIn,
- Int32 *iIn)
-{
-
- Int32 cmplx;
- Int16 rTmp0;
- Int32 rTmp;
- Int32 iTmp;
- Int32 *pt_rTmp;
- Int32 *pt_iTmp;
-
-
-
- /*
- * All pass filters
- * 2
- * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k)
- * z^(-2)*phi_fract(k)* | | ------------------------------------------------
- * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m))
- *
- *
- * Fractional delay matrix:
- *
- * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS
- *
- * Vectors: a(m), q(m), d(m) are constants
- *
- * m m 0 1 2
- * -------------------------------
- * delay length d(m) == 3 4 5 (Fs > 32 KHz)
- * fractional delay length q(m) == 0.43 0.75 0.347
- * filter coefficient a(m) == 0.65144 0.56472 0.48954
- *
- * g_decay_slope(k) is given
- */
-
-
- Int32 tmp_r;
- Int32 tmp_i;
-
- pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay];
-
- cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = Qfmt15(0.65143905753106f);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
-
-
- iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp;
-
- rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
-
- *rIn = rTmp;
-
- pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay];
-
-
-
- cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = Qfmt15(0.56471812200776f);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
-
-
- iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp;
-
- rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
- *rIn = rTmp;
-
- pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-
-
- cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = Qfmt15(0.97908331911390f);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
-
-
- iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp << 2;
-
- rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn);
- *rIn = rTmp << 2;
-}
-
-
-void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex,
- Int32 sb_delay,
- const Int32 *ppFractDelayPhaseFactorSer,
- Int32 ***pppRealDelayRBufferSer,
- Int32 ***pppImagDelayRBufferSer,
- Int32 *rIn,
- Int32 *iIn,
- Int32 decayScaleFactor)
-{
-
- Int32 cmplx;
- Int16 rTmp0;
- Int32 rTmp;
- Int32 iTmp;
- Int32 *pt_rTmp;
- Int32 *pt_iTmp;
- const Int16 *pt_delay;
-
-
-
- /*
- * All pass filters
- * 2
- * ___ Q_fract(k,m)*z^(-d(m)) - a(m)*g_decay_slope(k)
- * z^(-2)*phi_fract(k)* | | ------------------------------------------------
- * m=0 1 - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m))
- *
- *
- * Fractional delay matrix:
- *
- * Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k)) 0<= k <= SUBQMF_GROUPS
- *
- * Vectors: a(m), q(m), d(m) are constants
- *
- * m m 0 1 2
- * -------------------------------
- * delay length d(m) == 3 4 5 (Fs > 32 KHz)
- * fractional delay length q(m) == 0.43 0.75 0.347
- * filter coefficient a(m) == 0.65144 0.56472 0.48954
- *
- * g_decay_slope(k) is given
- */
-
-
- Int32 tmp_r;
- Int32 tmp_i;
-
- pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay];
-
- cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */
- pt_delay = aRevLinkDecaySerCoeff[decayScaleFactor];
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = *(pt_delay++);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
-
-
- iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp;
-
- rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
- *rIn = rTmp;
-
- pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay];
-
-
- cmplx = *(ppFractDelayPhaseFactorSer++); /* Q_fract(k,m) */
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = *(pt_delay++);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
- iTmp = fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp;
-
- rTmp = fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
- *rIn = rTmp;
-
- pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
- pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-
-
- cmplx = *(ppFractDelayPhaseFactorSer); /* Q_fract(k,m) */
- tmp_r = *pt_rTmp << 1;
- tmp_i = *pt_iTmp << 1;
-
- rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i, cmplx);
- rTmp0 = *(pt_delay);
- iTmp = cmplx_mul32_by_16(tmp_i, tmp_r, cmplx);
-
-
- iTmp = fxp_mac32_by_16(-*iIn, rTmp0, iTmp); /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
- *pt_iTmp = fxp_mac32_by_16(iTmp, rTmp0, *iIn); /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
- *iIn = iTmp << 2;
-
- rTmp = fxp_mac32_by_16(-*rIn, rTmp0, rTmp);
- *pt_rTmp = fxp_mac32_by_16(rTmp, rTmp0, *rIn);
- *rIn = rTmp << 2;
-
-}
-
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h b/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h
deleted file mode 100644
index b4e9876..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_all_pass_fract_delay_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_all_pass_fract_delay_filter()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALL_PASS_FRACT_DELAY_FILTER_H
-#define PS_ALL_PASS_FRACT_DELAY_FILTER_H
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define R_SHIFT 29
-#define Q29_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex,
- Int32 sb_delay,
- const Int32 *ppFractDelayPhaseFactorSer,
- Int32 ***pppRealDelayRBufferSer,
- Int32 ***pppImagDelayRBufferSer,
- Int32 *rIn,
- Int32 *iIn);
-
-
- void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex,
- Int32 sb_delay,
- const Int32 *ppFractDelayPhaseFactorSer,
- Int32 ***pppRealDelayRBufferSer,
- Int32 ***pppImagDelayRBufferSer,
- Int32 *rIn,
- Int32 *iIn,
- Int32 decayScaleFactor);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_ALL_PASS_FRACT_DELAY_FILTER_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp b/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp
deleted file mode 100644
index ab15651..0000000
--- a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_allocate_decoder.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reuses AAC+ HQ right channel, which is not used when PS is enabled
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef HQ_SBR
-
-#ifdef PARAMETRICSTEREO
-
-#include "s_sbr_channel.h"
-#include "aac_mem_funcs.h"
-#include "ps_hybrid_filter_bank_allocation.h"
-#include "s_ps_dec.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_allocate_decoder.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 30
-#define Q30_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int32 aRevLinkDelaySer[] = {3, 4, 5};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_allocate_decoder(SBRDECODER_DATA *self,
- UInt32 noSubSamples)
-{
- Int32 i, j;
- Int32 status;
-
- Int32 *ptr1;
- Int32 *ptr2;
- Int32 *ptr3;
- Int32 *ptr4;
- Int32 *ptr5;
- Int32 *ptr6;
- Int32 *ptr7;
-
- const Int32 pHybridResolution[] = { HYBRID_8_CPLX,
- HYBRID_2_REAL,
- HYBRID_2_REAL
- };
-
- STRUCT_PS_DEC *h_ps_dec = self->hParametricStereoDec;
-
- /* initialisation */
- h_ps_dec->noSubSamples = noSubSamples;
-
- h_ps_dec->invNoSubSamples = Q30_fmt(1.0f) / noSubSamples;
-
- /*
- * Reuse AAC+ HQ right channel, which is not used when PS is enabled
- */
- ptr1 = (Int32 *)(self->SbrChannel[1].frameData.codecQmfBufferReal[0]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */
-
- ptr2 = (&ptr1[658]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */
- /* 1162 - 658 = 504
- * = NO_QMF_ALLPASS_CHANNELS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im)
- */
-
- ptr3 = (&ptr1[1162]); /* reuse un-used right channel QMF_FILTER Synthesis buffer */
- /* 1426 - 1162 = 264
- * = SUBQMF_GROUPS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im)
- */
-
- ptr4 = (&ptr1[1426]); /* high freq generation buffers */
-
- ptr5 = (&ptr1[1490]); /* high freq generation buffers */
-
- ptr6 = (&ptr1[1618]); /* high freq generation buffers */
-
- ptr7 = (&ptr1[1810]); /* high freq generation buffers */
-
- /* whole allocation requires 1871 words, sbrQmfBufferImag has 1920 words */
-
-
- h_ps_dec->aPeakDecayFast = ptr1;
- ptr1 += NO_BINS;
-
- h_ps_dec->aPrevNrg = ptr1;
- ptr1 += NO_BINS;
-
- h_ps_dec->aPrevPeakDiff = ptr1;
- ptr1 += NO_BINS;
-
-
-
- status = ps_hybrid_filter_bank_allocation(&h_ps_dec->hHybrid,
- NO_QMF_CHANNELS_IN_HYBRID,
- pHybridResolution,
- &ptr1);
- h_ps_dec->mHybridRealLeft = ptr1;
- ptr1 += SUBQMF_GROUPS;
-
- h_ps_dec->mHybridImagLeft = ptr1;
- ptr1 += SUBQMF_GROUPS;
-
- h_ps_dec->mHybridRealRight = ptr1;
- ptr1 += SUBQMF_GROUPS;
-
- h_ps_dec->mHybridImagRight = ptr1;
- ptr1 += SUBQMF_GROUPS;
-
-
- h_ps_dec->delayBufIndex = 0;
-
-
-
- for (i = 0 ; i < NO_DELAY_CHANNELS ; i++) /* 41 */
- {
- if (i < SHORT_DELAY_START) /* 12 */
- {
- h_ps_dec->aNoSampleDelay[i] = LONG_DELAY;
- }
- else
- {
- h_ps_dec->aNoSampleDelay[i] = SHORT_DELAY;
- }
- }
-
-
- h_ps_dec->aaRealDelayBufferQmf = (Int32 **)ptr6;
- ptr6 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32);
-
- h_ps_dec->aaImagDelayBufferQmf = (Int32 **)ptr7;
- ptr7 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32);
-
- h_ps_dec->aaRealDelayBufferSubQmf = (Int32 **)ptr1;
- ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32);
-
- h_ps_dec->aaImagDelayBufferSubQmf = (Int32 **)ptr1;
- ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32);
-
- for (i = 0; i < NO_QMF_ICC_CHANNELS; i++) /* 61 */
- {
- int delay;
-
- if (i < NO_QMF_ALLPASS_CHANNELS) /* 20 */
- {
- delay = 2;
- h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr4;
- ptr4 += delay;
-
- h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr5;
- ptr5 += delay;
- }
- else
- {
-
- if (i >= (NO_QMF_ALLPASS_CHANNELS + SHORT_DELAY_START))
- {
- delay = SHORT_DELAY;
- }
- else
- {
- delay = LONG_DELAY;
- }
-
- h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr1;
- ptr1 += delay;
-
- h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr1;
- ptr1 += delay;
- }
- }
-
- for (i = 0; i < SUBQMF_GROUPS; i++)
- {
- h_ps_dec->aaRealDelayBufferSubQmf[i] = (Int32 *)ptr1;
- ptr1 += DELAY_ALLPASS;
-
- h_ps_dec->aaImagDelayBufferSubQmf[i] = (Int32 *)ptr1;
- ptr1 += DELAY_ALLPASS;
-
- }
-
- for (i = 0 ; i < NO_SERIAL_ALLPASS_LINKS ; i++) /* NO_SERIAL_ALLPASS_LINKS == 3 */
- {
-
- h_ps_dec->aDelayRBufIndexSer[i] = 0;
-
- h_ps_dec->aaaRealDelayRBufferSerQmf[i] = (Int32 **)ptr2;
- ptr2 += aRevLinkDelaySer[i];
-
- h_ps_dec->aaaImagDelayRBufferSerQmf[i] = (Int32 **)ptr2;
- ptr2 += aRevLinkDelaySer[i];
-
- h_ps_dec->aaaRealDelayRBufferSerSubQmf[i] = (Int32 **)ptr3;
- ptr3 += aRevLinkDelaySer[i];
-
- h_ps_dec->aaaImagDelayRBufferSerSubQmf[i] = (Int32 **)ptr3;
- ptr3 += aRevLinkDelaySer[i];
-
- for (j = 0; j < aRevLinkDelaySer[i]; j++)
- {
- h_ps_dec->aaaRealDelayRBufferSerQmf[i][j] = ptr2;
- ptr2 += NO_QMF_ALLPASS_CHANNELS; /* NO_QMF_ALLPASS_CHANNELS == 20 */
-
- h_ps_dec->aaaImagDelayRBufferSerQmf[i][j] = ptr2;
- ptr2 += NO_QMF_ALLPASS_CHANNELS;
-
- h_ps_dec->aaaRealDelayRBufferSerSubQmf[i][j] = ptr3;
- ptr3 += SUBQMF_GROUPS;
-
- h_ps_dec->aaaImagDelayRBufferSerSubQmf[i][j] = ptr3;
- ptr3 += SUBQMF_GROUPS;
-
- }
- }
-
-
- for (i = 0; i < NO_IID_GROUPS; i++) /* NO_IID_GROUPS == 22 */
- {
- h_ps_dec->h11Prev[i] = Q30_fmt(1.0f);
- h_ps_dec->h12Prev[i] = Q30_fmt(1.0f);
- }
-
-
-
- return status;
-} /*END CreatePsDec*/
-#endif
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h b/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h
deleted file mode 100644
index d5f152f..0000000
--- a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_allocate_decoder.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_allocate_decoder()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALLOCATE_DECODER_H
-#define PS_ALLOCATE_DECODER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int32 ps_allocate_decoder(SBRDECODER_DATA *self,
- UInt32 noSubSamples);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_ALLOCATE_DECODER_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_applied.cpp b/media/libstagefright/codecs/aacdec/ps_applied.cpp
deleted file mode 100644
index 77fd8a7..0000000
--- a/media/libstagefright/codecs/aacdec/ps_applied.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_applied.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Applies Parametric Stereo Tool to a QMF-analized mono signal
- providing a stereo image as output
-
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include "aac_mem_funcs.h"
-#include "ps_stereo_processing.h"
-#include "ps_decorrelate.h"
-#include "ps_hybrid_synthesis.h"
-#include "ps_hybrid_analysis.h"
-#include "ps_applied.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_applied(STRUCT_PS_DEC *h_ps_dec,
- Int32 rIntBufferLeft[][64],
- Int32 iIntBufferLeft[][64],
- Int32 *rIntBufferRight,
- Int32 *iIntBufferRight,
- Int32 scratch_mem[],
- Int32 band)
-
-{
-
- /*
- * Get higher frequency resolution in the lower QMF subbands
- * creating sub-subbands
- */
- ps_hybrid_analysis(rIntBufferLeft,
- iIntBufferLeft,
- h_ps_dec->mHybridRealLeft,
- h_ps_dec->mHybridImagLeft,
- h_ps_dec->hHybrid,
- scratch_mem,
- band);
-
- /*
- * By means of delaying and all-pass filtering, sub-subbands of
- * left ch. are decorrelate to creates right ch. sub-subbands
- */
-
- ps_decorrelate(h_ps_dec,
- *rIntBufferLeft,
- *iIntBufferLeft,
- rIntBufferRight,
- iIntBufferRight,
- scratch_mem);
-
- /*
- * sub-subbands of left and right ch. are processed according to
- * stereo clues.
- */
-
- ps_stereo_processing(h_ps_dec,
- *rIntBufferLeft,
- *iIntBufferLeft,
- rIntBufferRight,
- iIntBufferRight);
-
- /*
- * Reconstruct stereo signals
- */
-
- ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealLeft,
- (const Int32*)h_ps_dec->mHybridImagLeft,
- *rIntBufferLeft,
- *iIntBufferLeft,
- h_ps_dec->hHybrid);
-
- ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealRight,
- (const Int32*)h_ps_dec->mHybridImagRight,
- rIntBufferRight,
- iIntBufferRight,
- h_ps_dec->hHybrid);
-
-}/* END ps_applied */
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_applied.h b/media/libstagefright/codecs/aacdec/ps_applied.h
deleted file mode 100644
index 231d9c3..0000000
--- a/media/libstagefright/codecs/aacdec/ps_applied.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_applied.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_applied()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_APPLIED_H
-#define PS_APPLIED_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_applied(STRUCT_PS_DEC *h_ps_dec,
- Int32 rIntBufferLeft[][64],
- Int32 iIntBufferLeft[][64],
- Int32 *rIntBufferRight,
- Int32 *iIntBufferRight,
- Int32 scratch_mem[],
- Int32 band);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_APPLIED_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp b/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp
deleted file mode 100644
index c7ed60b..0000000
--- a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_bstr_decoding.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decodes parametric stereo
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "ps_bstr_decoding.h"
-#include "ps_decode_bs_utils.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const Int32 aNoIidBins[3] = {NO_LOW_RES_IID_BINS, NO_IID_BINS, NO_HI_RES_BINS};
-const Int32 aNoIccBins[3] = {NO_LOW_RES_ICC_BINS, NO_ICC_BINS, NO_HI_RES_BINS};
-const Int32 aFixNoEnvDecode[4] = {0, 1, 2, 4};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_bstr_decoding(STRUCT_PS_DEC *ps_dec)
-{
- UInt32 env;
- Int32 noIidSteps;
-
- if (!ps_dec->bPsDataAvail)
- {
- ps_dec->noEnv = 0;
- }
-
- noIidSteps = ps_dec->bFineIidQ ? NO_IID_STEPS_FINE : NO_IID_STEPS;
-
- for (env = 0; env < ps_dec->noEnv; env++)
- {
- Int32 *aPrevIidIndex;
- Int32 *aPrevIccIndex;
- if (env == 0)
- {
- aPrevIidIndex = ps_dec->aIidPrevFrameIndex;
- aPrevIccIndex = ps_dec->aIccPrevFrameIndex;
- }
- else
- {
- aPrevIidIndex = ps_dec->aaIidIndex[env-1];
- aPrevIccIndex = ps_dec->aaIccIndex[env-1];
- }
-
- /*
- * Differential Decoding of IID parameters over time/frequency
- */
- differential_Decoding(ps_dec->bEnableIid,
- ps_dec->aaIidIndex[env],
- aPrevIidIndex,
- ps_dec->abIidDtFlag[env],
- aNoIidBins[ps_dec->freqResIid],
- (ps_dec->freqResIid) ? 1 : 2,
- -noIidSteps,
- noIidSteps);
-
- /*
- * Differential Decoding of ICC parameters over time/frequency
- */
- differential_Decoding(ps_dec->bEnableIcc,
- ps_dec->aaIccIndex[env],
- aPrevIccIndex,
- ps_dec->abIccDtFlag[env],
- aNoIccBins[ps_dec->freqResIcc],
- (ps_dec->freqResIcc) ? 1 : 2,
- 0,
- NO_ICC_STEPS - 1);
-
-
- } /* for (env=0; env<ps_dec->noEnv; env++) */
-
- if (ps_dec->noEnv == 0)
- {
- ps_dec->noEnv = 1;
-
- if (ps_dec->bEnableIid)
- { /* NO_HI_RES_BINS == 34 */
- pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv-1],
- ps_dec->aIidPrevFrameIndex,
- NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex));
-
- }
- else
- {
- pv_memset((void *)ps_dec->aaIidIndex[ps_dec->noEnv-1],
- 0,
- NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex));
- }
- if (ps_dec->bEnableIcc)
- {
- pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv-1],
- ps_dec->aIccPrevFrameIndex,
- NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex));
- }
- else
- {
- pv_memset((void *)ps_dec->aaIccIndex[ps_dec->noEnv-1],
- 0,
- NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex));
- }
- }
-
- pv_memmove(ps_dec->aIidPrevFrameIndex,
- ps_dec->aaIidIndex[ps_dec->noEnv-1],
- NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex));
-
- pv_memmove(ps_dec->aIccPrevFrameIndex,
- ps_dec->aaIccIndex[ps_dec->noEnv-1],
- NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex));
-
- ps_dec->bPsDataAvail = 0;
-
- if (ps_dec->bFrameClass == 0)
- {
- Int32 shift;
-
- shift = ps_dec->noEnv >> 1;
-
- ps_dec->aEnvStartStop[0] = 0;
-
- for (env = 1; env < ps_dec->noEnv; env++)
- {
- ps_dec->aEnvStartStop[env] =
- (env * ps_dec->noSubSamples) >> shift;
- }
-
- ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples;
- }
- else
- { /* if (ps_dec->bFrameClass != 0) */
- ps_dec->aEnvStartStop[0] = 0;
-
- if (ps_dec->aEnvStartStop[ps_dec->noEnv] < ps_dec->noSubSamples)
- {
- ps_dec->noEnv++;
- ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples;
-
- pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv],
- ps_dec->aaIidIndex[ps_dec->noEnv-1],
- NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex));
-
- pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv],
- ps_dec->aaIccIndex[ps_dec->noEnv-1],
- NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex));
- }
-
- for (env = 1; env < ps_dec->noEnv; env++)
- {
- UInt32 thr;
- thr = ps_dec->noSubSamples - ps_dec->noEnv + env;
-
- if (ps_dec->aEnvStartStop[env] > thr)
- {
- ps_dec->aEnvStartStop[env] = thr;
- }
- else
- {
- thr = ps_dec->aEnvStartStop[env-1] + 1;
-
- if (ps_dec->aEnvStartStop[env] < thr)
- {
- ps_dec->aEnvStartStop[env] = thr;
- }
- }
- }
- } /* if (ps_dec->bFrameClass == 0) ... else */
-
- for (env = 0; env < ps_dec->noEnv; env++)
- {
- if (ps_dec->freqResIid == 2)
- {
- map34IndexTo20(ps_dec->aaIidIndex[env]);
- }
- if (ps_dec->freqResIcc == 2)
- {
- map34IndexTo20(ps_dec->aaIccIndex[env]);
- }
- }
-
-
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h b/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h
deleted file mode 100644
index 5212bf8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_bstr_decoding.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_bstr_decoding()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_BSTR_DECODING_H
-#define PS_BSTR_DECODING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int32 aNoIidBins[3];
-extern const Int32 aNoIccBins[3];
-
-extern const Int32 aFixNoEnvDecode[4];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_bstr_decoding(STRUCT_PS_DEC *h_ps_dec);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_BSTR_DECODING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp b/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp
deleted file mode 100644
index 03a53df..0000000
--- a/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_analysis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Does Hybrid analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "s_hybrid.h"
-#include "aac_mem_funcs.h"
-#include "ps_fft_rx8.h"
-#include "ps_channel_filtering.h"
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT 29
-#define Q29_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) + (a>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void two_ch_filtering(const Int32 *pQmf_r,
- const Int32 *pQmf_i,
- Int32 *mHybrid_r,
- Int32 *mHybrid_i)
-{
-
- Int32 cum0;
- Int32 cum1;
- Int32 cum2;
- Int32 tmp1;
- Int32 tmp2;
-
- tmp1 = pQmf_r[ 1] + pQmf_r[11];
- tmp2 = pQmf_i[ 1] + pQmf_i[11];
- cum1 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp1);
- cum2 = fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp2);
- tmp1 = pQmf_r[ 3] + pQmf_r[ 9];
- tmp2 = pQmf_i[ 3] + pQmf_i[ 9];
- cum1 = fxp_msu32_Q31(cum1, Qfmt31(0.14586278335076f), tmp1);
- cum2 = fxp_msu32_Q31(cum2, Qfmt31(0.14586278335076f), tmp2);
- tmp1 = pQmf_r[ 5] + pQmf_r[ 7];
- tmp2 = pQmf_i[ 5] + pQmf_i[ 7];
- cum1 = fxp_mac32_Q31(cum1, Qfmt31(0.61193261090336f), tmp1);
- cum2 = fxp_mac32_Q31(cum2, Qfmt31(0.61193261090336f), tmp2);
-
- cum0 = pQmf_r[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */
-
- mHybrid_r[0] = (cum0 + cum1);
- mHybrid_r[1] = (cum0 - cum1);
-
- cum0 = pQmf_i[HYBRID_FILTER_DELAY] >> 1; /* HYBRID_FILTER_DELAY == 6 */
-
- mHybrid_i[0] = (cum0 + cum2);
- mHybrid_i[1] = (cum0 - cum2);
-
-}
-
-
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void eight_ch_filtering(const Int32 *pQmfReal,
- const Int32 *pQmfImag,
- Int32 *mHybridReal,
- Int32 *mHybridImag,
- Int32 scratch_mem[])
-
-{
-
- Int32 real;
- Int32 imag;
- Int32 tmp1;
- Int32 tmp2;
-
- real = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfReal[ 4]);
-
- real = fxp_mac32_Q31(real, Qfmt31(0.01055120626280f), pQmfReal[12]);
- imag = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfImag[ 4]);
-
- imag = fxp_mac32_Q31(imag, Qfmt31(0.01055120626280f), pQmfImag[12]);
-
- mHybridReal[2] = (imag - real);
- mHybridImag[2] = -(imag + real);
-
- real = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfReal[ 3]);
-
- real = fxp_mac32_Q31(real, Qfmt31(0.04540841899650f), pQmfReal[11]);
- imag = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfImag[ 3]);
-
- imag = fxp_mac32_Q31(imag, Qfmt31(0.04540841899650f), pQmfImag[11]);
-
- tmp1 = fxp_mul32_Q29(Q29_fmt(-0.38268343236509f), real);
- mHybridReal[3] = fxp_mac32_Q29(Q29_fmt(0.92387953251129f), imag, tmp1);
- tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real);
- mHybridImag[3] = fxp_mac32_Q29(Q29_fmt(-0.38268343236509f), imag, tmp2);
-
-
- mHybridImag[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfReal[ 2] - pQmfReal[10]));
- mHybridReal[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfImag[10] - pQmfImag[ 2]));
-
-
- real = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfReal[ 1]);
-
- real = fxp_mac32_Q31(real, Qfmt31(0.14532227859182f), pQmfReal[ 9]);
- imag = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfImag[ 1]);
-
- imag = fxp_mac32_Q31(imag, Qfmt31(0.14532227859182f), pQmfImag[ 9]);
-
- tmp1 = fxp_mul32_Q29(Q29_fmt(0.92387953251129f), imag);
-
- mHybridReal[5] = fxp_mac32_Q31(tmp1, Qfmt31(0.76536686473018f), real);
- tmp2 = fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real);
-
- mHybridImag[5] = fxp_mac32_Q31(tmp2, Qfmt31(0.76536686473018f), imag);
-
- real = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfReal[ 0]);
-
- real = fxp_mac32_Q31(real, Qfmt31(0.13979654612668f), pQmfReal[ 8]);
- imag = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfImag[ 0]);
-
- imag = fxp_mac32_Q31(imag, Qfmt31(0.13979654612668f), pQmfImag[ 8]);
-
- mHybridReal[6] = (imag + real);
- mHybridImag[6] = (imag - real);
-
-
- tmp1 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfReal[ 7]);
- mHybridReal[7] = fxp_mac32_Q31(tmp1, Qfmt31(0.09026515280366f), pQmfImag[ 7]);
-
- tmp2 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfReal[ 7]);
-
- mHybridImag[7] = fxp_mac32_Q31(tmp2, Qfmt31(0.21791935610828f), pQmfImag[ 7]);
-
- mHybridReal[0] = pQmfReal[HYBRID_FILTER_DELAY] >> 3;
- mHybridImag[0] = pQmfImag[HYBRID_FILTER_DELAY] >> 3;
-
- tmp1 = fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfImag[ 5]);
-
- mHybridReal[1] = fxp_mac32_Q31(tmp1, Qfmt31(0.21791935610828f), pQmfReal[ 5]);
-
-
- tmp2 = fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfImag[ 5]);
- mHybridImag[1] = fxp_mac32_Q31(tmp2, Qfmt31(0.09026515280366f), pQmfReal[ 5]);
-
- /*
- * 8*ifft
- */
-
- ps_fft_rx8(mHybridReal, mHybridImag, scratch_mem);
-
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_channel_filtering.h b/media/libstagefright/codecs/aacdec/ps_channel_filtering.h
deleted file mode 100644
index 19cda79..0000000
--- a/media/libstagefright/codecs/aacdec/ps_channel_filtering.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_channel_filtering.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions two_ch_filtering()
- and eight_ch_filtering()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_CHANNEL_FILTERING_H
-#define PS_CHANNEL_FILTERING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void two_ch_filtering(const Int32 *pQmf_r,
- const Int32 *pQmf_i,
- Int32 *mHybrid_r,
- Int32 *mHybrid_i);
-
-
- void eight_ch_filtering(const Int32 *pQmfReal,
- const Int32 *pQmfImag,
- Int32 *mHybridReal,
- Int32 *mHybridImag,
- Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_CHANNEL_FILTERING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_constants.h b/media/libstagefright/codecs/aacdec/ps_constants.h
deleted file mode 100644
index d5b2ad4..0000000
--- a/media/libstagefright/codecs/aacdec/ps_constants.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/****************************************************************************
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-*******************************************************************************/
-/*
-*/
-#ifndef PS_CONSTANTS_H
-#define PS_CONSTANTS_H
-
-
-#define NO_SUB_QMF_CHANNELS 12
-#define NO_QMF_CHANNELS_IN_HYBRID 3
-#define NO_QMF_CHANNELS 64
-#define NO_ALLPASS_CHANNELS 23
-#define NO_DELAY_CHANNELS (NO_QMF_CHANNELS-NO_ALLPASS_CHANNELS)
-#define DELAY_ALLPASS 2
-#define SHORT_DELAY_START 12
-#define SHORT_DELAY 1
-#define LONG_DELAY 14
-#define NO_QMF_ALLPASS_CHANNELS (NO_ALLPASS_CHANNELS-NO_QMF_CHANNELS_IN_HYBRID)
-#define NO_QMF_ICC_CHANNELS (NO_QMF_ALLPASS_CHANNELS+NO_DELAY_CHANNELS)
-#define HYBRIDGROUPS 8
-#define DECAY_CUTOFF 3
-#define NO_SERIAL_ALLPASS_LINKS 3
-#define MAX_NO_PS_ENV 5
-#define NEGATE_IPD_MASK ( 0x00001000 )
-#define NO_BINS ( 20 )
-#define NO_HI_RES_BINS ( 34 )
-#define NO_LOW_RES_BINS ( NO_IID_BINS / 2 )
-#define NO_IID_BINS ( NO_BINS )
-#define NO_ICC_BINS ( NO_BINS )
-#define NO_LOW_RES_IID_BINS ( NO_LOW_RES_BINS )
-#define NO_LOW_RES_ICC_BINS ( NO_LOW_RES_BINS )
-#define SUBQMF_GROUPS ( 10 )
-#define QMF_GROUPS ( 12 )
-#define NO_IID_GROUPS ( SUBQMF_GROUPS + QMF_GROUPS )
-#define NO_IID_STEPS ( 7 )
-#define NO_IID_STEPS_FINE ( 15 )
-#define NO_ICC_STEPS ( 8 )
-#define NO_IID_LEVELS ( 2 * NO_IID_STEPS + 1 )
-#define NO_IID_LEVELS_FINE ( 2 * NO_IID_STEPS_FINE + 1 )
-#define NO_ICC_LEVELS ( NO_ICC_STEPS )
-
-
-
-#endif /* PS_CONSTANTS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp b/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp
deleted file mode 100644
index 241da34..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_decode_bs_utils.c
-
- Functions:
- GetNrBitsAvailable
- differential_Decoding
- map34IndexTo20
- limitMinMax
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decode bitstream parametric stereo's utilities
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "aac_mem_funcs.h"
-#include "s_ps_dec.h"
-#include "ps_decode_bs_utils.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf)
-{
-
- return (hBitBuf->bufferLen - hBitBuf->nrBitsRead);
-}
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-;
-; Differential Decoding of parameters over time/frequency
-----------------------------------------------------------------------------*/
-
-void differential_Decoding(Int32 enable,
- Int32 *aIndex,
- Int32 *aPrevFrameIndex,
- Int32 DtDf,
- Int32 nrElements,
- Int32 stride,
- Int32 minIdx,
- Int32 maxIdx)
-{
- Int32 i;
- Int32 *ptr_aIndex;
-
- if (enable == 1)
- {
- ptr_aIndex = aIndex;
-
- if (DtDf == 0)
- {
- *(ptr_aIndex) = limitMinMax(*ptr_aIndex, minIdx, maxIdx);
- ptr_aIndex++;
-
- for (i = 1; i < nrElements; i++)
- {
- *(ptr_aIndex) = limitMinMax(aIndex[i-1] + *ptr_aIndex, minIdx, maxIdx);
- ptr_aIndex++;
- }
- }
- else
- {
- if (stride == 1)
- {
- for (i = 0; i < nrElements; i++)
- {
- *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[i] + *ptr_aIndex, minIdx, maxIdx);
- ptr_aIndex++;
- }
- }
- else
- {
- for (i = 0; i < nrElements; i++)
- {
- *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[(i<<1)] + *ptr_aIndex, minIdx, maxIdx);
- ptr_aIndex++;
- }
- }
- }
- }
- else
- {
- pv_memset((void *)aIndex, 0, nrElements*sizeof(*aIndex));
- }
- if (stride == 2)
- {
- for (i = (nrElements << 1) - 1; i > 0; i--)
- {
- aIndex[i] = aIndex[(i>>1)];
- }
- }
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
- map34IndexTo20
-----------------------------------------------------------------------------*/
-
-void map34IndexTo20(Int32 *aIndex)
-{
-
- aIndex[ 0] = ((aIndex[0] << 1) + aIndex[1]) / 3;
- aIndex[ 1] = (aIndex[1] + (aIndex[2] << 1)) / 3;
- aIndex[ 2] = ((aIndex[3] << 1) + aIndex[4]) / 3;
- aIndex[ 3] = (aIndex[4] + (aIndex[5] << 1)) / 3;
- aIndex[ 4] = (aIndex[ 6] + aIndex[7]) >> 1;
- aIndex[ 5] = (aIndex[ 8] + aIndex[9]) >> 1;
- aIndex[ 6] = aIndex[10];
- aIndex[ 7] = aIndex[11];
- aIndex[ 8] = (aIndex[12] + aIndex[13]) >> 1;
- aIndex[ 9] = (aIndex[14] + aIndex[15]) >> 1;
- aIndex[10] = aIndex[16];
- aIndex[11] = aIndex[17];
- aIndex[12] = aIndex[18];
- aIndex[13] = aIndex[19];
- aIndex[14] = (aIndex[20] + aIndex[21]) >> 1;
- aIndex[15] = (aIndex[22] + aIndex[23]) >> 1;
- aIndex[16] = (aIndex[24] + aIndex[25]) >> 1;
- aIndex[17] = (aIndex[26] + aIndex[27]) >> 1;
- aIndex[18] = (aIndex[28] + aIndex[29] + aIndex[30] + aIndex[31]) >> 2;
- aIndex[19] = (aIndex[32] + aIndex[33]) >> 1;
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
- limitMinMax
-----------------------------------------------------------------------------*/
-
-
-Int32 limitMinMax(Int32 i,
- Int32 min,
- Int32 max)
-{
- if (i < max)
- {
- if (i > min)
- {
- return i;
- }
- else
- {
- return min;
- }
- }
- else
- {
- return max;
- }
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h b/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h
deleted file mode 100644
index a672d94..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_decode_bs_utils.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions differential_Decoding(), limitMinMax(),
- GetNrBitsAvailable(), map34IndexTo20()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_DECODE_BS_UTILS_H
-#define PS_DECODE_BS_UTILS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-#include "s_bit_buffer.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void differential_Decoding(Int32 enable,
- Int32 *aIndex,
- Int32 *aPrevFrameIndex,
- Int32 DtDf,
- Int32 nrElements,
- Int32 stride,
- Int32 minIdx,
- Int32 maxIdx);
-
- Int32 limitMinMax(Int32 i,
- Int32 min,
- Int32 max);
-
- Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf);
-
- void map34IndexTo20(Int32 *aIndex);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_DECODE_BS_UTILS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp b/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp
deleted file mode 100644
index 6776d6e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_decorrelate.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decorrelation
- Decorrelation is achieved by means of all-pass filtering and delaying
- Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
- d_k(n). k index for frequency, n time index
-
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
- Delay is introduced to compensate QMF bands not passed through Hybrid
- Analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include "pv_audio_type_defs.h"
-#include "ps_decorrelate.h"
-#include "aac_mem_funcs.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_pwr_transient_detection.h"
-#include "ps_all_pass_fract_delay_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec,
- Int32 *rIntBufferLeft,
- Int32 *iIntBufferLeft,
- Int32 *rIntBufferRight,
- Int32 *iIntBufferRight,
- Int32 scratch_mem[])
-{
- Int32 sb;
- Int32 maxsb;
- Int32 gr;
- Int32 sb_delay;
- Int32 bin;
-
-
-
-
- Int32 *aLeftReal;
- Int32 *aLeftImag;
- Int32 *aRightReal;
- Int32 *aRightImag;
-
- Int32 *aTransRatio = scratch_mem; /* use NO_BINS == 20 */
-
-
- Int32 ***pppRealDelayRBufferSer;
- Int32 ***pppImagDelayRBufferSer;
-
- Int32 **ppRealDelayBuffer;
- Int32 **ppImagDelayBuffer;
-
- const Int32(*ppFractDelayPhaseFactorSer)[3];
- /*
- * Power transient estimation and detection
- */
-
-
- ps_pwr_transient_detection(h_ps_dec,
- rIntBufferLeft,
- iIntBufferLeft,
- aTransRatio);
-
-
- aLeftReal = h_ps_dec->mHybridRealLeft;
- aLeftImag = h_ps_dec->mHybridImagLeft;
- aRightReal = h_ps_dec->mHybridRealRight;
- aRightImag = h_ps_dec->mHybridImagRight;
-
- pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerSubQmf;
- pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerSubQmf;
-
- ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferSubQmf;
- ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferSubQmf;
-
-
-
- ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerSubQmf;
-
-
- /*
- * NO_IID_GROUPS (SUBQMF_GROUPS (12) + QMF_GROUPS (10)) == 22
- */
-
- for (gr = 0; gr < SUBQMF_GROUPS; gr++) /* 0 to 9 */
- {
- Int32 rIn;
- Int32 iIn;
- Int32 *pt_rTmp;
- Int32 *pt_iTmp;
- Int32 rTmp;
- Int32 cmplx;
- Int32 tmp1, tmp2;
-
- /* sb = subQMF/QMF subband */
-
- sb = groupBorders[gr];
-
- /*
- * For lower subbands
- * Apply all-pass filtering
- *
- */
- pt_rTmp = &ppRealDelayBuffer[sb][h_ps_dec->delayBufIndex];
- pt_iTmp = &ppImagDelayBuffer[sb][h_ps_dec->delayBufIndex];
-
- tmp1 = aLeftReal[sb];
- tmp2 = aLeftImag[sb];
- rIn = *pt_rTmp >> 1;
- iIn = *pt_iTmp >> 1;
-
-
- *pt_rTmp = tmp1;
- *pt_iTmp = tmp2;
-
- /*
- * Fractional delay vector
- *
- * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS
- *
- * q_phi = 0.39
- * f_center(k) frequency vector
- */
-
- cmplx = aFractDelayPhaseFactorSubQmf[sb];
-
- aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx);
- aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx);
-
- ps_all_pass_fract_delay_filter_type_I(h_ps_dec->aDelayRBufIndexSer,
- sb,
- ppFractDelayPhaseFactorSer[sb],
- pppRealDelayRBufferSer,
- pppImagDelayRBufferSer,
- &aRightReal[sb],
- &aRightImag[sb]);
-
- bin = bins2groupMap[gr];
- rTmp = aTransRatio[bin];
-
- if (rTmp != 0x7FFFFFFF)
- {
- aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1;
- aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1;
- }
-
-
- } /* gr */
-
- aLeftReal = rIntBufferLeft;
- aLeftImag = iIntBufferLeft;
- aRightReal = rIntBufferRight;
- aRightImag = iIntBufferRight;
-
- pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerQmf;
- pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerQmf;
-
- ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferQmf;
- ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferQmf;
-
-
-
- ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerQmf;
-
-
- for (gr = SUBQMF_GROUPS; gr < NO_BINS; gr++) /* 10 to 20 */
- {
-
- maxsb = min(h_ps_dec->usb, groupBorders[gr+1]);
-
- /* sb = subQMF/QMF subband */
-
- for (sb = groupBorders[gr]; sb < maxsb; sb++)
- {
-
- Int32 rIn, iIn;
- Int32 *pt_rTmp, *pt_iTmp;
- Int32 cmplx;
- Int32 tmp1, tmp2;
- Int32 rTmp;
-
-
- sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* NO_QMF_CHANNELS_IN_HYBRID == 3 */
-
- /*
- * For lower subbands
- * Apply all-pass filtering
- *
- */
- pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->delayBufIndex];
- pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->delayBufIndex];
-
- rIn = *pt_rTmp >> 1;
- iIn = *pt_iTmp >> 1;
-
- tmp1 = aLeftReal[sb];
- tmp2 = aLeftImag[sb];
- *pt_rTmp = tmp1;
- *pt_iTmp = tmp2;
-
- /*
- * Fractional delay vector
- *
- * phi_fract(k) = exp(-j*pi*q_phi*f_center(k)) 0<= k <= SUBQMF_GROUPS
- *
- * q_phi = 0.39
- * f_center(k) frequency vector
- */
-
- cmplx = aFractDelayPhaseFactor[sb_delay];
- aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx);
- aRightImag[sb] = cmplx_mul32_by_16(iIn, rIn, cmplx);
-
- ps_all_pass_fract_delay_filter_type_II(h_ps_dec->aDelayRBufIndexSer,
- sb_delay,
- ppFractDelayPhaseFactorSer[sb_delay],
- pppRealDelayRBufferSer,
- pppImagDelayRBufferSer,
- &aRightReal[sb],
- &aRightImag[sb],
- sb);
-
- rTmp = aTransRatio[gr-2];
- if (rTmp != 0x7FFFFFFF)
- {
- aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1;
- aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1;
- }
-
-
- } /* sb */
-
- }
-
-
- maxsb = min(h_ps_dec->usb, 35); /* 35 == groupBorders[NO_BINS + 1] */
-
- /* sb = subQMF/QMF subband */
- {
- Int32 factor = aTransRatio[NO_BINS-2];
-
- for (sb = 23; sb < maxsb; sb++) /* 23 == groupBorders[NO_BINS] */
- {
-
- Int32 tmp, tmp2;
- Int32 *pt_rTmp, *pt_iTmp;
-
- sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */
-
- /*
- * For the Upper Bands apply delay only
- * -D(k)
- * Apply Delay H_k(z) = z , D(k) == 1 or 14
- *
- */
- Int32 k = sb - NO_ALLPASS_CHANNELS; /* == 23 */
-
-
- pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]];
- pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]];
-
- if (++h_ps_dec->aDelayBufIndex[ k] >= LONG_DELAY) /* == 14 */
- {
- h_ps_dec->aDelayBufIndex[ k] = 0;
- }
-
-
- tmp = *pt_rTmp;
- tmp2 = *pt_iTmp;
-
- if (aTransRatio[NO_BINS-2] < 0x7FFFFFFF)
- {
- aRightReal[sb] = fxp_mul32_Q31(factor, tmp) << 1;
- aRightImag[sb] = fxp_mul32_Q31(factor, tmp2) << 1;
- }
- else
- {
- aRightReal[sb] = tmp;
- aRightImag[sb] = tmp2;
- }
-
-
- tmp = aLeftReal[sb];
- tmp2 = aLeftImag[sb];
- *pt_rTmp = tmp;
- *pt_iTmp = tmp2;
-
-
- } /* sb */
- }
-
-
- maxsb = min(h_ps_dec->usb, 64); /* 64 == groupBorders[NO_BINS+2] */
-
- /* sb = subQMF/QMF subband */
-
- {
-
- for (sb = 35; sb < maxsb; sb++) /* 35 == groupBorders[NO_BINS+1] */
- {
-
- Int32 *pt_rTmp, *pt_iTmp;
-
- sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID; /* == 3 */
-
- /*
- * For the Upper Bands apply delay only
- * -D(k)
- * Apply Delay H_k(z) = z , D(k) == 1 or 14
- *
- */
-
- pt_rTmp = &ppRealDelayBuffer[sb_delay][0];
- pt_iTmp = &ppImagDelayBuffer[sb_delay][0];
-
- aRightReal[sb] = *pt_rTmp;
- aRightImag[sb] = *pt_iTmp;
-
-
- if (aTransRatio[NO_BINS-1] < 0x7FFFFFFF)
- {
- aRightReal[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightReal[sb]) << 1;
- aRightImag[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightImag[sb]) << 1;
- }
-
- *pt_rTmp = aLeftReal[sb];
- *pt_iTmp = aLeftImag[sb];
-
-
- } /* sb */
- }
-
-
- if (++h_ps_dec->delayBufIndex >= DELAY_ALLPASS)
- {
- h_ps_dec->delayBufIndex = 0;
- }
-
- if (++h_ps_dec->aDelayRBufIndexSer[0] >= 3)
- {
- h_ps_dec->aDelayRBufIndexSer[0] = 0;
- }
- if (++h_ps_dec->aDelayRBufIndexSer[1] >= 4)
- {
- h_ps_dec->aDelayRBufIndexSer[1] = 0;
- }
- if (++h_ps_dec->aDelayRBufIndexSer[2] >= 5)
- {
- h_ps_dec->aDelayRBufIndexSer[2] = 0;
- }
-
-
-} /* END deCorrelate */
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_decorrelate.h b/media/libstagefright/codecs/aacdec/ps_decorrelate.h
deleted file mode 100644
index c2a025a..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decorrelate.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_decorrelate.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_decorrelate()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_DECORRELATE_H
-#define PS_DECORRELATE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec,
- Int32 *rIntBufferLeft,
- Int32 *iIntBufferLeft,
- Int32 *rIntBufferRight,
- Int32 *iIntBufferRight,
- Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_DECORRELATE_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp b/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp
deleted file mode 100644
index 7669be3..0000000
--- a/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fft_rx8.c
- Funtions: ps_fft_rx8
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Real Vector of Real components size 8
-
- Imag Vector of Imag components size 8
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- scratch_mem size 32
-
- Outputs:
- In-place calculation of a 8-point FFT (radix-8)
-
- Pointers and Buffers Modified:
- calculation are done in-place and returned in Data
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- 8-point DFT, radix 8 with Decimation in Frequency
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should provide a fixed point FFT for any input array
- of size power of 8.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
- C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
- MODIFY( x[] )
- RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#ifdef PARAMETRICSTEREO
-
-
-#include "pv_audio_type_defs.h"
-#include "ps_fft_rx8.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT 29
-#define Q29_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[])
-
-/* scratch_mem size 32 */
-{
-
- Int i;
- Int32 *Q = &scratch_mem[0];
- Int32 *Z = &scratch_mem[16];
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp4;
- Int32 aux_r[2];
- Int32 aux_i[2];
- Int32 *pt_r1 = &Re[0];
- Int32 *pt_r2 = &Re[4];
- Int32 *pt_i1 = &Im[0];
- Int32 *pt_i2 = &Im[4];
-
- Int32 *pt_Q = Q;
- Int32 *pt_Z = Z;
-
-
- temp1 = *(pt_r1++); /* Real */
- temp2 = *(pt_r2++); /* Real */
- temp3 = *(pt_i1++); /* Imag */
- temp4 = *(pt_i2++); /* Imag */
- /*
- * Vector Q stores data as Real, Imag, Real, Imag,....
- */
-
- *(pt_Q++) = temp1 + temp2; /* Q(0) = v(0) + v(4) */
- *(pt_Q++) = temp3 + temp4;
- *(pt_Q++) = temp1 - temp2; /* Q(1) = v(0) - v(4) */
- *(pt_Q++) = temp3 - temp4;
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_i1++);
- temp4 = *(pt_i2++);
-
- *(pt_Q++) = temp1 + temp2; /* Q(2) = v(1) + v(5) */
- *(pt_Q++) = temp3 + temp4;
- aux_r[0] = temp1 - temp2; /* aux[0] = v(1) - v(5) */
- aux_i[0] = temp3 - temp4;
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_i1++);
- temp4 = *(pt_i2++);
-
- *(pt_Q++) = temp1 + temp2; /* Q(3) = v(2) + v(6) */
- *(pt_Q++) = temp3 + temp4;
- *(pt_Q++) = temp4 - temp3; /* Q(4) = (v(2) - v(6))*j */
- *(pt_Q++) = temp1 - temp2;
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_i1++);
- temp4 = *(pt_i2++);
-
-
- *(pt_Q++) = temp1 + temp2; /* Q(5) = v(3) + v(7) */
- *(pt_Q++) = temp3 + temp4;
- aux_r[1] = temp1 - temp2; /* aux[1] = v(3) - v(7) */
- aux_i[1] = temp3 - temp4;
- /* Q(6) = (aux[0] - aux[1])/sqrt(2); */
- *(pt_Q++) = fxp_mul32_Q29((aux_r[0] - aux_r[1]), Q29_fmt(0.70710678118655f));
- *(pt_Q++) = fxp_mul32_Q29((aux_i[0] - aux_i[1]), Q29_fmt(0.70710678118655f));
-
- /* Q(7) = (aux[0] + aux[1])*j/sqrt(2); */
- *(pt_Q++) = fxp_mul32_Q29((aux_i[0] + aux_i[1]), Q29_fmt(-0.70710678118655f));
- *(pt_Q) = fxp_mul32_Q29((aux_r[0] + aux_r[1]), Q29_fmt(0.70710678118655f));
-
- pt_r1 = &Q[0]; /* reset pointer */
- pt_r2 = &Q[6]; /* reset pointer */
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_r1++);
- temp4 = *(pt_r2++);
-
- /*
- * Vector Z stores data as Real, Imag, Real, Imag,....
- */
-
- *(pt_Z++) = temp1 + temp2; /* Q(0) + Q(3) */
- *(pt_Z++) = temp3 + temp4;
- aux_r[0] = temp1 - temp2;
- aux_i[0] = temp3 - temp4;
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_r1++);
- temp4 = *(pt_r2++);
-
- *(pt_Z++) = temp1 + temp2; /* Q(1) + Q(4) */
- *(pt_Z++) = temp3 + temp4;
- *(pt_Z++) = aux_r[0]; /* Q(0) - Q(3) */
- *(pt_Z++) = aux_i[0];
- *(pt_Z++) = temp1 - temp2; /* Q(1) - Q(4) */
- *(pt_Z++) = temp3 - temp4;
-
- temp1 = *(pt_r1++);
- temp2 = *(pt_r2++);
- temp3 = *(pt_r1);
- temp4 = *(pt_r2++);
-
- *(pt_Z++) = temp1 + temp2; /* Q(2) + Q(5) */
- *(pt_Z++) = temp3 + temp4;
- aux_r[0] = temp1 - temp2;
- aux_i[0] = temp3 - temp4;
-
- temp1 = *(pt_r2++);
- temp3 = *(pt_r2++);
- temp2 = *(pt_r2++);
- temp4 = *(pt_r2);
-
- *(pt_Z++) = temp1 + temp2; /* Q(6) + Q(7) */
- *(pt_Z++) = temp3 + temp4;
-
- *(pt_Z++) = -aux_i[0]; /* (Q(2) - Q(5))*j */
- *(pt_Z++) = aux_r[0];
-
- *(pt_Z++) = temp2 - temp1; /* -Q(6) + Q(7) */
- *(pt_Z) = temp4 - temp3;
-
- pt_Z = &Z[0]; /* reset pointer */
- pt_Q = &Z[8]; /* reset pointer */
-
- pt_r1 = &Re[0];
- pt_r2 = &Re[4];
- pt_i1 = &Im[0];
- pt_i2 = &Im[4];
-
-
- for (i = 4; i != 0; i--)
- {
- temp1 = *(pt_Z++);
- temp2 = *(pt_Q++);
- temp3 = *(pt_Z++);
- temp4 = *(pt_Q++);
-
- *(pt_r1++) = temp1 + temp2; /* Z(n) + Z(n+4) */
- *(pt_i1++) = temp3 + temp4;
- *(pt_r2++) = temp1 - temp2; /* Z(n) - Z(n+4) */
- *(pt_i2++) = temp3 - temp4;
- }
-
-}
-
-#endif /* PARAMETRICSTEREO */
-
-
-#endif /* AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/ps_fft_rx8.h b/media/libstagefright/codecs/aacdec/ps_fft_rx8.h
deleted file mode 100644
index 6c3482e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_fft_rx8.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_fft_rx8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_fft_rx8()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_FFT_RX8_H
-#define PS_FFT_RX8_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_FFT_RX4_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp
deleted file mode 100644
index 933b07e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_analysis.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Does Hybrid analysis:
-
- Get higher frequency resolution in the lower QMF subbands
- creating sub-subbands. This is done by low frequency filtering.
- Lower QMF subbands are further split in order to obtain a higher
- frequency resolution, enabling a proper stereo analysis and synthesis
- for the lower frequencies.
- Two hybrid are defined. Both filters have length 13 and a delay of 6.
- In this implementation, the symmetry of the filters helps to simplify
- the design.
-
-
- Increase Freq. Resolution
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
-
- subband k QMF channel
- 0 ................. 0 -----------
- 1 ................. 0
- 2 ................. 0
- 3 ................. 0
- 4 ................. 0
- 5 ................. 0 Sub-QMF ( Increase Freq. Resolution)
- 6 ................. 1
- 7 ................. 1
- 8 ................. 2
- 9 ................. 2
- 10 ................. 3 -----------
- 11 ................. 4
- 12 ................. 5
- 13 ................. 6
- 14 ................. 7
- 15 ................. 8 QMF
- 16-17 ................. 9-10
- 18-20 ................. 11-13
- 21-24 ................. 14-17
- 25-29 ................. 18-22
- 30-41 ................. 23-34
- 42-70 ................. 35-63 -----------
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "s_hybrid.h"
-#include "aac_mem_funcs.h"
-#include "ps_channel_filtering.h"
-#include "ps_hybrid_analysis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_hybrid_analysis(const Int32 mQmfReal[][64],
- const Int32 mQmfImag[][64],
- Int32 *mHybridReal,
- Int32 *mHybridImag,
- HYBRID *pHybrid,
- Int32 scratch_mem[],
- Int32 i)
-
-{
-
- Int32 band;
- HYBRID_RES hybridRes;
- Int32 chOffset = 0;
-
- Int32 *ptr_mHybrid_Re;
- Int32 *ptr_mHybrid_Im;
-
- Int32 *pt_mQmfBufferReal;
- Int32 *pt_mQmfBufferImag;
-
- pt_mQmfBufferReal = &scratch_mem[32 + i];
-
- for (band = 0; band < pHybrid->nQmfBands; band++)
- {
- pt_mQmfBufferImag = pt_mQmfBufferReal + 44;
-
-
- pt_mQmfBufferReal[HYBRID_FILTER_LENGTH_m_1] = mQmfReal[HYBRID_FILTER_DELAY][band];
- pt_mQmfBufferImag[HYBRID_FILTER_LENGTH_m_1] = mQmfImag[HYBRID_FILTER_DELAY][band];
-
-
- ptr_mHybrid_Re = &mHybridReal[ chOffset];
- ptr_mHybrid_Im = &mHybridImag[ chOffset];
-
- hybridRes = (HYBRID_RES)pHybrid->pResolution[band];
- switch (hybridRes)
- {
- /*
- * For QMF band = 1 and 2
- */
-
- case HYBRID_2_REAL:
-
- two_ch_filtering(pt_mQmfBufferReal,
- pt_mQmfBufferImag,
- ptr_mHybrid_Re,
- ptr_mHybrid_Im);
- chOffset += 2;
-
- break;
-
- /*
- * For QMF band = 0
- */
-
- case HYBRID_8_CPLX:
-
- eight_ch_filtering(pt_mQmfBufferReal,
- pt_mQmfBufferImag,
- pHybrid->mTempReal,
- pHybrid->mTempImag,
- scratch_mem);
-
- pv_memmove(ptr_mHybrid_Re, pHybrid->mTempReal, 4*sizeof(*pHybrid->mTempReal));
-
- ptr_mHybrid_Re += 2;
-
- *(ptr_mHybrid_Re++) += pHybrid->mTempReal[5];
- *(ptr_mHybrid_Re++) += pHybrid->mTempReal[4];
- *(ptr_mHybrid_Re++) = pHybrid->mTempReal[6];
- *(ptr_mHybrid_Re) = pHybrid->mTempReal[7];
-
- pv_memmove(ptr_mHybrid_Im, pHybrid->mTempImag, 4*sizeof(*pHybrid->mTempImag));
- ptr_mHybrid_Im += 2;
-
- *(ptr_mHybrid_Im++) += pHybrid->mTempImag[5];
- *(ptr_mHybrid_Im++) += pHybrid->mTempImag[4];
- *(ptr_mHybrid_Im++) = pHybrid->mTempImag[6];
- *(ptr_mHybrid_Im) = pHybrid->mTempImag[7];
-
- chOffset += 6;
-
- break;
-
- default:
- ;
- }
-
- pt_mQmfBufferReal = pt_mQmfBufferImag + 44;
-
- }
-
-
-}
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h b/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h
deleted file mode 100644
index 0140a1f..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_analysis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_hybrid_analysis()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_ANALYSIS_H
-#define PS_HYBRID_ANALYSIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_hybrid_analysis(const Int32 mQmfReal[][64],
- const Int32 mQmfImag[][64],
- Int32 *mHybridReal,
- Int32 *mHybridImag,
- HYBRID *pHybrid,
- Int32 scratch_mem[],
- Int32 band);
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_HYBRID_ANALYSIS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp
deleted file mode 100644
index 4ff2385..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_filter_bank_allocation.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Does Hybrid filter bank memory allocation
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include "aac_mem_funcs.h"
-#include "ps_hybrid_filter_bank_allocation.h"
-#include "ps_all_pass_filter_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid,
- Int32 noBands,
- const Int32 *pResolution,
- Int32 **pPtr)
-{
- Int32 i;
- Int32 tmp;
- Int32 maxNoChannels = 0;
- HYBRID *hs;
- Int32 *ptr = *pPtr;
-
-
- *phHybrid = (HYBRID *)NULL;
-
- hs = (HYBRID *)ptr;
-
- ptr += sizeof(HYBRID) / sizeof(*ptr);
-
- hs->pResolution = (Int32*)ptr;
-
- ptr += noBands * sizeof(Int32) / sizeof(*ptr);
-
- for (i = 0; i < noBands; i++)
- {
-
- hs->pResolution[i] = pResolution[i];
-
- if (pResolution[i] != HYBRID_8_CPLX &&
- pResolution[i] != HYBRID_2_REAL &&
- pResolution[i] != HYBRID_4_CPLX)
- {
- return 1;
- }
-
- if (pResolution[i] > maxNoChannels)
- {
- maxNoChannels = pResolution[i];
- }
- }
-
- hs->nQmfBands = noBands;
- hs->qmfBufferMove = HYBRID_FILTER_LENGTH - 1;
-
- hs->mQmfBufferReal = (Int32 **)ptr;
- ptr += noBands * sizeof(ptr) / sizeof(*ptr);
-
- hs->mQmfBufferImag = (Int32 **)ptr;
- ptr += noBands * sizeof(ptr) / sizeof(*ptr);
-
- tmp = hs->qmfBufferMove; /* HYBRID_FILTER_LENGTH == 13 */
-
- for (i = 0; i < noBands; i++)
- {
- hs->mQmfBufferReal[i] = ptr;
- ptr += tmp;
-
- hs->mQmfBufferImag[i] = ptr;
- ptr += tmp;
-
- }
-
- hs->mTempReal = ptr;
- ptr += maxNoChannels;
-
-
- hs->mTempImag = ptr;
- ptr += maxNoChannels;
-
-
- *phHybrid = hs;
- *pPtr = ptr;
-
- return 0;
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h b/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h
deleted file mode 100644
index fbc0d80..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_filter_bank_allocation.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for ps_hybrid_filter_bank_allocation
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_FILTER_BANK_ALLOCATION_H
-#define PS_HYBRID_FILTER_BANK_ALLOCATION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid,
- Int32 noBands,
- const Int32 *pResolution,
- Int32 **pPtr);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_HYBRID_FILTER_BANK_ALLOCATION_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp
deleted file mode 100644
index 4fbd016..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_synthesis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Hybrid synthesis
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "s_hybrid.h"
-#include "ps_hybrid_synthesis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void ps_hybrid_synthesis(const Int32 *mHybridReal,
- const Int32 *mHybridImag,
- Int32 *mQmfReal,
- Int32 *mQmfImag,
- HYBRID *hHybrid)
-{
- Int32 k;
- Int32 band;
- HYBRID_RES hybridRes;
-
- Int32 real;
- Int32 imag;
- Int32 *ptr_mQmfReal = mQmfReal;
- Int32 *ptr_mQmfImag = mQmfImag;
- const Int32 *ptr_mHybrid_Re = mHybridReal;
- const Int32 *ptr_mHybrid_Im = mHybridImag;
-
- for (band = 0; band < hHybrid->nQmfBands; band++)
- {
- hybridRes = (HYBRID_RES)(min(hHybrid->pResolution[band], 6) - 2);
-
- real = *(ptr_mHybrid_Re++);
- real += *(ptr_mHybrid_Re++);
- imag = *(ptr_mHybrid_Im++);
- imag += *(ptr_mHybrid_Im++);
-
- for (k = (hybridRes >> 1); k != 0; k--) /* hybridRes = { 2,4,6 } */
- {
- real += *(ptr_mHybrid_Re++);
- real += *(ptr_mHybrid_Re++);
- imag += *(ptr_mHybrid_Im++);
- imag += *(ptr_mHybrid_Im++);
- }
-
- *(ptr_mQmfReal++) = real;
- *(ptr_mQmfImag++) = imag;
- }
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h b/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h
deleted file mode 100644
index d7242dd..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_synthesis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_hybrid_synthesis()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_SYNTHESIS_H
-#define PS_HYBRID_SYNTHESIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_hybrid_synthesis(const Int32 *mHybridReal,
- const Int32 *mHybridImag,
- Int32 *mQmfReal,
- Int32 *mQmfImag,
- HYBRID *hHybrid);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_HYBRID_SYNTHESIS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp b/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp
deleted file mode 100644
index 7027b5c..0000000
--- a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_init_stereo_mixing.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- initialize mixing procedure type Ra, type Rb is not supported
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-
-#include "aac_mem_funcs.h"
-#include "pv_sine.h"
-#include "s_ps_dec.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_init_stereo_mixing.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*
-;
-; c(b) = 10^(iid(b)/20)
-;
-; Intensity differences
-;
-; sqrt(2)
-; c_1(b) = ----------------
-; sqrt( 1 + c^2(b))
-;
-; sqrt(2)*c(b)
-; c_2(b) = ----------------
-; sqrt( 1 + c^2(b))
-;
-*/
-
-
-
-#define R_SHIFT 30
-#define Q30_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 scaleFactors[NO_IID_LEVELS] =
-{
- Q30_fmt(1.411983f), Q30_fmt(1.403138f), Q30_fmt(1.386877f),
- Q30_fmt(1.348400f), Q30_fmt(1.291249f), Q30_fmt(1.196037f),
- Q30_fmt(1.107372f), Q30_fmt(1.000000f), Q30_fmt(0.879617f),
- Q30_fmt(0.754649f), Q30_fmt(0.576780f), Q30_fmt(0.426401f),
- Q30_fmt(0.276718f), Q30_fmt(0.176645f), Q30_fmt(0.079402f)
-};
-
-const Int32 scaleFactorsFine[NO_IID_LEVELS_FINE] =
-{
- Q30_fmt(1.414207f), Q30_fmt(1.414191f), Q30_fmt(1.414143f),
- Q30_fmt(1.413990f), Q30_fmt(1.413507f), Q30_fmt(1.411983f),
- Q30_fmt(1.409773f), Q30_fmt(1.405395f), Q30_fmt(1.396780f),
- Q30_fmt(1.380053f), Q30_fmt(1.348400f), Q30_fmt(1.313920f),
- Q30_fmt(1.264310f), Q30_fmt(1.196037f), Q30_fmt(1.107372f),
- Q30_fmt(1.000000f), Q30_fmt(0.879617f), Q30_fmt(0.754649f),
- Q30_fmt(0.633656f), Q30_fmt(0.523081f), Q30_fmt(0.426401f),
- Q30_fmt(0.308955f), Q30_fmt(0.221375f), Q30_fmt(0.157688f),
- Q30_fmt(0.111982f), Q30_fmt(0.079402f), Q30_fmt(0.044699f),
- Q30_fmt(0.025145f), Q30_fmt(0.014141f), Q30_fmt(0.007953f),
- Q30_fmt(0.004472f)
-};
-
-
-/*
- * alphas ranged between 0 and pi/2
- * alpha(b) = (1/2)*arccos( gamma(b))
- *
- * b 0 1 2 3 4 5 6 7
- * gamma 1 0.937 0.84118 0.60092 0.36764 0 -0.589 -1
- *
- */
-
-
-
-const Int32 scaled_alphas[NO_ICC_LEVELS] =
-{
- Q30_fmt(0.00000000000000f), Q30_fmt(0.12616764875355f),
- Q30_fmt(0.20199707286122f), Q30_fmt(0.32744135137762f),
- Q30_fmt(0.42225800677370f), Q30_fmt(0.55536025173035f),
- Q30_fmt(0.77803595530059f), Q30_fmt(1.11072050346071f)
-};
-
-const Int32 cos_alphas[NO_ICC_LEVELS] =
-{
- Q30_fmt(1.00000000000000f), Q30_fmt(0.98412391153249f),
- Q30_fmt(0.95947390717984f), Q30_fmt(0.89468446298319f),
- Q30_fmt(0.82693418207478f), Q30_fmt(0.70710689672598f),
- Q30_fmt(0.45332071670080f), Q30_fmt(0.00000032679490f)
-};
-
-const Int32 sin_alphas[NO_ICC_LEVELS] =
-{
- Q30_fmt(0.00000000000000f), Q30_fmt(0.17748275057029f),
- Q30_fmt(0.28179748302823f), Q30_fmt(0.44669868110000f),
- Q30_fmt(0.56229872711603f), Q30_fmt(0.70710666564709f),
- Q30_fmt(0.89134747871404f), Q30_fmt(1.00000000000000f)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms,
- Int32 env,
- Int32 usb)
-{
- Int32 group;
- Int32 bin;
- Int32 noIidSteps;
- Int32 tmp;
-
- Int32 invEnvLength;
- const Int32 *pScaleFactors;
- Int32 scaleR;
- Int32 scaleL;
- Int32 cos_alpha;
- Int32 sin_alpha;
- Int32 beta;
- Int32 cos_beta;
- Int32 sin_beta;
- Int32 temp1;
- Int32 temp2;
- Int32 *ptr_tmp;
- Int32 h11;
- Int32 h12;
- Int32 h21;
- Int32 h22;
-
- if (pms->bFineIidQ)
- {
- noIidSteps = NO_IID_STEPS_FINE; /* NO_IID_STEPS_FINE == 15 */
- pScaleFactors = scaleFactorsFine;
- }
- else
- {
- noIidSteps = NO_IID_STEPS; /* NO_IID_STEPS == 7 */
- pScaleFactors = scaleFactors;
- }
-
- if (env == 0)
- {
- pms->lastUsb = pms->usb;
- pms->usb = usb;
- if (usb != pms->lastUsb && pms->lastUsb != 0)
- {
- return(-1);
-
- }
- }
-
- invEnvLength = pms->aEnvStartStop[env + 1] - pms->aEnvStartStop[env];
-
- if (invEnvLength == (Int32) pms->noSubSamples)
- {
- invEnvLength = pms->invNoSubSamples;
- }
- else
- {
- invEnvLength = Q30_fmt(1.0f) / invEnvLength;
- }
-
- if (invEnvLength == 32) /* more likely value */
- {
- for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */
- {
- bin = bins2groupMap[group];
-
- /*
- * c(b) = 10^(iid(b)/20)
- */
-
- tmp = pms->aaIidIndex[env][bin];
-
- /*
- * Intensity differences
- *
- * sqrt(2)
- * c_1(b) = ----------------
- * sqrt( 1 + c^2(b))
- *
- */
- scaleR = pScaleFactors[noIidSteps + tmp];
-
- /*
- * sqrt(2)*c(b)
- * c_2(b) = ----------------
- * sqrt( 1 + c^2(b))
- *
- */
-
- scaleL = pScaleFactors[noIidSteps - tmp];
-
-
- /*
- * alpha(b) = (1/2)*arccos( gamma(b))
- */
- tmp = pms->aaIccIndex[env][bin];
-
- cos_alpha = cos_alphas[ tmp];
- sin_alpha = sin_alphas[ tmp];
-
- /*
- * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b))
- */
-
- beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL));
-
- cos_beta = pv_cosine(beta);
- sin_beta = pv_sine(beta);
-
- temp1 = fxp_mul32_Q30(cos_beta, cos_alpha);
- temp2 = fxp_mul32_Q30(sin_beta, sin_alpha);
-
-
- /*
- * h11(b) = cos( alpha(b) + beta(b))* c_2(b)
- * h12(b) = cos( beta(b) - alpha(b))* c_1(b)
- */
-
- h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2));
- h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2));
-
- temp1 = fxp_mul32_Q30(sin_beta, cos_alpha);
- temp2 = fxp_mul32_Q30(cos_beta, sin_alpha);
-
- /*
- * h21(b) = sin( alpha(b) + beta(b))* c_2(b)
- * h22(b) = sin( beta(b) - alpha(b))* c_1(b)
- */
-
- h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2));
- h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2));
-
-
- /*
- * Linear interpolation
- *
- * Hij(k, n_e+1) - Hij(k, n_e)
- * Hij(k,n) = Hij(k, n_e) + (n - n_e)*---------------------------
- * n_e+1 - n_e
- */
-
- ptr_tmp = &pms->h11Prev[group];
- pms->H11[group] = *ptr_tmp;
- pms->deltaH11[group] = (h11 - *ptr_tmp) >> 5;
- *ptr_tmp = h11;
-
- ptr_tmp = &pms->h12Prev[group];
- pms->H12[group] = *ptr_tmp;
- pms->deltaH12[group] = (h12 - *ptr_tmp) >> 5;
- *ptr_tmp = h12;
-
- ptr_tmp = &pms->h21Prev[group];
- pms->H21[group] = *ptr_tmp;
- pms->deltaH21[group] = (h21 - *ptr_tmp) >> 5;
- *ptr_tmp = h21;
-
- ptr_tmp = &pms->h22Prev[group];
- pms->H22[group] = *ptr_tmp;
- pms->deltaH22[group] = (h22 - *ptr_tmp) >> 5;
- *ptr_tmp = h22;
-
-
- } /* groups loop */
- }
- else
- {
-
- for (group = 0; group < NO_IID_GROUPS; group++) /* == 22 */
- {
- bin = bins2groupMap[group];
-
- /*
- * c(b) = 10^(iid(b)/20)
- */
-
- tmp = pms->aaIidIndex[env][bin];
-
- /*
- * Intensity differences
- *
- * sqrt(2)
- * c_1(b) = ----------------
- * sqrt( 1 + c^2(b))
- *
- */
- scaleR = pScaleFactors[noIidSteps + tmp];
-
- /*
- * sqrt(2)*c(b)
- * c_2(b) = ----------------
- * sqrt( 1 + c^2(b))
- *
- */
-
- scaleL = pScaleFactors[noIidSteps - tmp];
-
-
- /*
- * alpha(b) = (1/2)*arccos( gamma(b))
- */
- tmp = pms->aaIccIndex[env][bin];
-
- cos_alpha = cos_alphas[ tmp];
- sin_alpha = sin_alphas[ tmp];
-
- /*
- * beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b))
- */
-
- beta = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL));
-
- cos_beta = pv_cosine(beta);
- sin_beta = pv_sine(beta);
-
- temp1 = fxp_mul32_Q30(cos_beta, cos_alpha);
- temp2 = fxp_mul32_Q30(sin_beta, sin_alpha);
-
-
- /*
- * h11(b) = cos( alpha(b) + beta(b))* c_2(b)
- * h12(b) = cos( beta(b) - alpha(b))* c_1(b)
- */
-
- h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2));
- h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2));
-
- temp1 = fxp_mul32_Q30(sin_beta, cos_alpha);
- temp2 = fxp_mul32_Q30(cos_beta, sin_alpha);
-
- /*
- * h21(b) = sin( alpha(b) + beta(b))* c_2(b)
- * h22(b) = sin( beta(b) - alpha(b))* c_1(b)
- */
-
- h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2));
- h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2));
-
-
- /*
- * Linear interpolation
- *
- * Hij(k, n_e+1) - Hij(k, n_e)
- * Hij(k,n) = Hij(k, n_e) + (n - n_e)*---------------------------
- * n_e+1 - n_e
- */
-
- ptr_tmp = &pms->h11Prev[group];
- pms->deltaH11[group] = fxp_mul32_Q30((h11 - *ptr_tmp), invEnvLength);
- pms->H11[group] = *ptr_tmp;
- *ptr_tmp = h11;
-
- ptr_tmp = &pms->h12Prev[group];
- pms->deltaH12[group] = fxp_mul32_Q30((h12 - *ptr_tmp), invEnvLength);
- pms->H12[group] = *ptr_tmp;
- *ptr_tmp = h12;
-
- ptr_tmp = &pms->h21Prev[group];
- pms->deltaH21[group] = fxp_mul32_Q30((h21 - *ptr_tmp), invEnvLength);
- pms->H21[group] = *ptr_tmp;
- *ptr_tmp = h21;
-
- ptr_tmp = &pms->h22Prev[group];
- pms->deltaH22[group] = fxp_mul32_Q30((h22 - *ptr_tmp), invEnvLength);
- pms->H22[group] = *ptr_tmp;
- *ptr_tmp = h22;
-
-
- } /* groups loop */
- }
-
-
- return (0);
-
-} /* END ps_init_stereo_mixing */
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h b/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h
deleted file mode 100644
index 6c30781..0000000
--- a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_init_stereo_mixing.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_init_stereo_mixing()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_INIT_STEREO_MIXING_H
-#define PS_INIT_STEREO_MIXING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms,
- Int32 env,
- Int32 usb);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_INIT_STEREO_MIXING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp b/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp
deleted file mode 100644
index a0e8c38..0000000
--- a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_pwr_transient_detection.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decorrelation
- Decorrelation is achieved by means of all-pass filtering and delaying
- Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
- d_k(n). k index for frequency, n time index
-
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
- To handle transients and other fast time-envelopes, the output of the all
- pass filters has to be attenuated at those signals.
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-#include "aac_mem_funcs.h"
-#include "ps_all_pass_filter_coeff.h"
-#include "ps_pwr_transient_detection.h"
-
-#include "fxp_mul32.h"
-#include "pv_div.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 29
-#define Q29_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(a) (Int32)(-a*((Int32)1<<31) - 1 + (a>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec,
- Int32 *rIntBufferLeft,
- Int32 *iIntBufferLeft,
- Int32 aTransRatio[])
-{
-
- Int32 sb;
- Int32 maxsb;
- Int32 gr;
- Int32 bin;
-
-
-
- Int32 *aLeftReal;
- Int32 *aLeftImag;
- Int32 temp_r;
- Int32 temp_i;
- Int32 accu;
- Int32 *aPower = aTransRatio;
- Quotient result;
-
- Int32 nrg;
- Int32 *ptr_aPrevNrg;
- Int32 peakDiff;
- Int32 *ptr_PrevPeakDiff;
-
-
- aLeftReal = rIntBufferLeft;
- aLeftImag = iIntBufferLeft;
-
- /*
- * Input Power Matrix
- * 2
- * Power(i,n) = SUM | s_k(n)|
- * i
- */
-
- for (gr = SUBQMF_GROUPS; gr < NO_IID_GROUPS; gr++) /* 10 to 22 */
- {
- maxsb = min(h_ps_dec->usb, groupBorders[ gr+1]);
-
- accu = 0;
-
- for (sb = groupBorders[gr]; sb < maxsb; sb++)
- {
-
- temp_r = aLeftReal[sb];
- temp_i = aLeftImag[sb];
- accu = fxp_mac32_Q31(accu, temp_r, temp_r);
- accu = fxp_mac32_Q31(accu, temp_i, temp_i);
-
- } /* sb */
- aPower[gr - 2] = accu >> 1;
- } /* gr */
-
- aLeftReal = h_ps_dec->mHybridRealLeft;
- aLeftImag = h_ps_dec->mHybridImagLeft;
-
-
- temp_r = aLeftReal[0];
- temp_i = aLeftImag[0];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- accu = fxp_mac32_Q31(accu, temp_i, temp_i);
- temp_r = aLeftReal[5];
- temp_i = aLeftImag[5];
- accu = fxp_mac32_Q31(accu, temp_r, temp_r);
- aPower[0] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[1];
- temp_i = aLeftImag[1];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- accu = fxp_mac32_Q31(accu, temp_i, temp_i);
- temp_r = aLeftReal[4];
- temp_i = aLeftImag[4];
- accu = fxp_mac32_Q31(accu, temp_r, temp_r);
- aPower[1] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[2];
- temp_i = aLeftImag[2];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[2] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[3];
- temp_i = aLeftImag[3];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[3] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-
-
- temp_r = aLeftReal[6];
- temp_i = aLeftImag[6];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[5] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[7];
- temp_i = aLeftImag[7];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[4] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[8];
- temp_i = aLeftImag[8];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[6] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
- temp_r = aLeftReal[9];
- temp_i = aLeftImag[9];
- accu = fxp_mul32_Q31(temp_r, temp_r);
- aPower[7] = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-
- /*
- * Power transient detection
- */
-
- ptr_aPrevNrg = h_ps_dec->aPrevNrg;
-
- ptr_PrevPeakDiff = h_ps_dec->aPrevPeakDiff;
-
- for (bin = 0; bin < NO_BINS; bin++) /* NO_BINS = 20 */
- {
-
- peakDiff = *ptr_PrevPeakDiff;
-
-
- /* PEAK_DECAY_FACTOR 0.765928338364649f @ 48 KHz for Fs > 32 Khz */
- accu = h_ps_dec->aPeakDecayFast[bin];
- peakDiff -= peakDiff >> 2;
-
- accu = fxp_mul32_Q31(accu, Qfmt31(0.765928338364649f)) << 1;
-
- if (accu < *aPower)
- {
- accu = *aPower;
- }
- else
- {
- peakDiff += ((accu - *aPower) >> 2);
- }
-
- h_ps_dec->aPeakDecayFast[bin] = accu;
-
- *(ptr_PrevPeakDiff++) = peakDiff;
-
- nrg = *ptr_aPrevNrg + ((*aPower - *ptr_aPrevNrg) >> 2);
-
- *(ptr_aPrevNrg++) = nrg;
-
- peakDiff += peakDiff >> 1; /* transient impact factor == 1.5 */
-
- if (peakDiff <= nrg)
- {
- *(aPower++) = 0x7FFFFFFF; /* in Q31 */
- }
- else
- {
- pv_div(nrg, peakDiff, &result);
- *(aPower++) = (result.quotient >> (result.shift_factor)) << 1; /* in Q31 */
- }
-
- } /* bin */
-
-}
-
-
-#endif
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h b/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h
deleted file mode 100644
index 80a73a8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_pwr_transient_detection.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_pwr_transient_detection()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_PWR_TRANSIENT_DETECTION_H
-#define PS_PWR_TRANSIENT_DETECTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec,
- Int32 *rIntBufferLeft,
- Int32 *iIntBufferLeft,
- Int32 aTransRatio[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_PWR_TRANSIENT_DETECTION_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_read_data.cpp b/media/libstagefright/codecs/aacdec/ps_read_data.cpp
deleted file mode 100644
index c49eb3d..0000000
--- a/media/libstagefright/codecs/aacdec/ps_read_data.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_read_data.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decodes parametric stereo
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "buf_getbits.h"
-#include "s_bit_buffer.h"
-#include "s_huffman.h"
-#include "aac_mem_funcs.h"
-#include "s_ps_dec.h"
-#include "sbr_decode_huff_cw.h"
-#include "ps_decode_bs_utils.h"
-#include "ps_bstr_decoding.h"
-#include "ps_read_data.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/* IID & ICC Huffman codebooks */
-const Char aBookPsIidTimeDecode[28][2] =
-{
- { -64, 1 }, { -65, 2 }, { -63, 3 }, { -66, 4 },
- { -62, 5 }, { -67, 6 }, { -61, 7 }, { -68, 8 },
- { -60, 9 }, { -69, 10 }, { -59, 11 }, { -70, 12 },
- { -58, 13 }, { -57, 14 }, { -71, 15 }, { 16, 17 },
- { -56, -72 }, { 18, 21 }, { 19, 20 }, { -55, -78 },
- { -77, -76 }, { 22, 25 }, { 23, 24 }, { -75, -74 },
- { -73, -54 }, { 26, 27 }, { -53, -52 }, { -51, -50 }
-};
-
-const Char aBookPsIidFreqDecode[28][2] =
-{
- { -64, 1 }, { 2, 3 }, { -63, -65 }, { 4, 5 },
- { -62, -66 }, { 6, 7 }, { -61, -67 }, { 8, 9 },
- { -68, -60 }, { -59, 10 }, { -69, 11 }, { -58, 12 },
- { -70, 13 }, { -71, 14 }, { -57, 15 }, { 16, 17 },
- { -56, -72 }, { 18, 19 }, { -55, -54 }, { 20, 21 },
- { -73, -53 }, { 22, 24 }, { -74, 23 }, { -75, -78 },
- { 25, 26 }, { -77, -76 }, { -52, 27 }, { -51, -50 }
-};
-
-const Char aBookPsIccTimeDecode[14][2] =
-{
- { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 },
- { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 },
- { -68, 9 }, { -59, 10 }, { -69, 11 }, { -58, 12 },
- { -70, 13 }, { -71, -57 }
-};
-
-const Char aBookPsIccFreqDecode[14][2] =
-{
- { -64, 1 }, { -63, 2 }, { -65, 3 }, { -62, 4 },
- { -66, 5 }, { -61, 6 }, { -67, 7 }, { -60, 8 },
- { -59, 9 }, { -68, 10 }, { -58, 11 }, { -69, 12 },
- { -57, 13 }, { -70, -71 }
-};
-
-const Char aBookPsIidFineTimeDecode[60][2] =
-{
- { 1, -64 }, { -63, 2 }, { 3, -65 }, { 4, 59 },
- { 5, 7 }, { 6, -67 }, { -68, -60 }, { -61, 8 },
- { 9, 11 }, { -59, 10 }, { -70, -58 }, { 12, 41 },
- { 13, 20 }, { 14, -71 }, { -55, 15 }, { -53, 16 },
- { 17, -77 }, { 18, 19 }, { -85, -84 }, { -46, -45 },
- { -57, 21 }, { 22, 40 }, { 23, 29 }, { -51, 24 },
- { 25, 26 }, { -83, -82 }, { 27, 28 }, { -90, -38 },
- { -92, -91 }, { 30, 37 }, { 31, 34 }, { 32, 33 },
- { -35, -34 }, { -37, -36 }, { 35, 36 }, { -94, -93 },
- { -89, -39 }, { 38, -79 }, { 39, -81 }, { -88, -40 },
- { -74, -54 }, { 42, -69 }, { 43, 44 }, { -72, -56 },
- { 45, 52 }, { 46, 50 }, { 47, -76 }, { -49, 48 },
- { -47, 49 }, { -87, -41 }, { -52, 51 }, { -78, -50 },
- { 53, -73 }, { 54, -75 }, { 55, 57 }, { 56, -80 },
- { -86, -42 }, { -48, 58 }, { -44, -43 }, { -66, -62 }
-};
-
-const Char aBookPsIidFineFreqDecode[60][2] =
-{
- { 1, -64 }, { 2, 4 }, { 3, -65 }, { -66, -62 },
- { -63, 5 }, { 6, 7 }, { -67, -61 }, { 8, 9 },
- { -68, -60 }, { 10, 11 }, { -69, -59 }, { 12, 13 },
- { -70, -58 }, { 14, 18 }, { -57, 15 }, { 16, -72 },
- { -54, 17 }, { -75, -53 }, { 19, 37 }, { -56, 20 },
- { 21, -73 }, { 22, 29 }, { 23, -76 }, { 24, -78 },
- { 25, 28 }, { 26, 27 }, { -85, -43 }, { -83, -45 },
- { -81, -47 }, { -52, 30 }, { -50, 31 }, { 32, -79 },
- { 33, 34 }, { -82, -46 }, { 35, 36 }, { -90, -89 },
- { -92, -91 }, { 38, -71 }, { -55, 39 }, { 40, -74 },
- { 41, 50 }, { 42, -77 }, { -49, 43 }, { 44, 47 },
- { 45, 46 }, { -86, -42 }, { -88, -87 }, { 48, 49 },
- { -39, -38 }, { -41, -40 }, { -51, 51 }, { 52, 59 },
- { 53, 56 }, { 54, 55 }, { -35, -34 }, { -37, -36 },
- { 57, 58 }, { -94, -93 }, { -84, -44 }, { -80, -48 }
-};
-
-
-
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_read_data(STRUCT_PS_DEC *ps_dec,
- BIT_BUFFER * hBitBuf,
- Int32 nBitsLeft)
-
-{
- Int gr;
- UInt32 env;
- UInt32 dtFlag;
- Int32 startbits;
- SbrHuffman CurrentTable;
-
- if (!ps_dec)
- {
- return 0;
- }
-
- startbits = GetNrBitsAvailable(hBitBuf);
-
- if (buf_get_1bit(hBitBuf)) /* Enable Header */
- {
- ps_dec->bEnableIid = buf_get_1bit(hBitBuf);
-
- if (ps_dec->bEnableIid)
- {
- ps_dec->freqResIid = buf_getbits(hBitBuf, 3);
-
- if (ps_dec->freqResIid > 2)
- {
- ps_dec->bFineIidQ = 1;
- ps_dec->freqResIid -= 3;
- }
- else
- {
- ps_dec->bFineIidQ = 0;
- }
- }
-
- ps_dec->bEnableIcc = buf_get_1bit(hBitBuf);
- if (ps_dec->bEnableIcc)
- {
- ps_dec->freqResIcc = buf_getbits(hBitBuf, 3);
-
- if (ps_dec->freqResIcc > 2)
- {
- ps_dec->freqResIcc -= 3;
- }
- }
- ps_dec->bEnableExt = buf_get_1bit(hBitBuf);
- }
-
- ps_dec->bFrameClass = buf_get_1bit(hBitBuf);
- if (ps_dec->bFrameClass == 0)
- {
- ps_dec->noEnv = aFixNoEnvDecode[ buf_getbits(hBitBuf, 2)];
- }
- else
- {
- ps_dec->noEnv = 1 + buf_getbits(hBitBuf, 2);
- for (env = 1; env < ps_dec->noEnv + 1; env++)
- {
- ps_dec->aEnvStartStop[env] = (buf_getbits(hBitBuf, 5)) + 1;
- }
- }
-
- if ((ps_dec->freqResIid > 2) || (ps_dec->freqResIcc > 2))
- {
-
- ps_dec->bPsDataAvail = 0;
-
- nBitsLeft -= startbits - GetNrBitsAvailable(hBitBuf);
- while (nBitsLeft)
- {
- int i = nBitsLeft;
- if (i > 8)
- {
- i = 8;
- }
- buf_getbits(hBitBuf, i);
- nBitsLeft -= i;
- }
- return (startbits - GetNrBitsAvailable(hBitBuf));
- }
-
- if (ps_dec->bEnableIid)
- {
- for (env = 0; env < ps_dec->noEnv; env++)
- {
- dtFlag = buf_get_1bit(hBitBuf);
-
- if (!dtFlag)
- {
- if (ps_dec->bFineIidQ)
- {
- CurrentTable = aBookPsIidFineFreqDecode;
- }
- else
- {
- CurrentTable = aBookPsIidFreqDecode;
- }
- }
- else
- {
- if (ps_dec->bFineIidQ)
- {
- CurrentTable = aBookPsIidFineTimeDecode;
- }
- else
- {
- CurrentTable = aBookPsIidTimeDecode;
- }
- }
-
- for (gr = 0; gr < aNoIidBins[ps_dec->freqResIid]; gr++)
- {
- ps_dec->aaIidIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf);
- }
-
- ps_dec->abIidDtFlag[env] = dtFlag;
- }
- }
-
- if (ps_dec->bEnableIcc)
- {
- for (env = 0; env < ps_dec->noEnv; env++)
- {
- dtFlag = buf_get_1bit(hBitBuf);
- if (!dtFlag)
- {
- CurrentTable = aBookPsIccFreqDecode;
- }
- else
- {
- CurrentTable = aBookPsIccTimeDecode;
- }
- for (gr = 0; gr < aNoIccBins[ps_dec->freqResIcc]; gr++)
- {
- ps_dec->aaIccIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf);
- }
-
- ps_dec->abIccDtFlag[env] = dtFlag;
- }
- }
-
- if (ps_dec->bEnableExt)
- {
-
- int cnt;
-
- cnt = (int)buf_getbits(hBitBuf, 4);
-
- if (cnt == 15)
- {
- cnt += (int)buf_getbits(hBitBuf, 8);
- }
-
- hBitBuf->nrBitsRead += (cnt << 3);
- }
-
- ps_dec->bPsDataAvail = 1;
-
- return (startbits - GetNrBitsAvailable(hBitBuf));
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_read_data.h b/media/libstagefright/codecs/aacdec/ps_read_data.h
deleted file mode 100644
index e2fec53..0000000
--- a/media/libstagefright/codecs/aacdec/ps_read_data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_read_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_read_data()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_READ_DATA_H
-#define PS_READ_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define EXTENSION_ID_PS_CODING 2
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int32 ps_read_data(STRUCT_PS_DEC *ps_dec,
- BIT_BUFFER * hBitBuf,
- Int32 nBitsLeft);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_READ_DATA_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp b/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp
deleted file mode 100644
index 813b55d..0000000
--- a/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_stereo_processing.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Stereo Process or reconstruction
-
- l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
-
- r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
-
- _______ ________
- | | _______ | |
- ->|Hybrid | LF ---- | |->| Hybrid |-->
- | Anal. | | | | | Synth | QMF -> L
- ------- o----------------------->| | -------- Synth
-QMF | s_k(n) |Stereo |-------------->
-Anal. -------------------------->| |
- _______ | | | | ________
- | | HF --o | ----------- |Process| | |
- ->| Delay | | ->| |-------->| |->| Hybrid |-->
- ------- | |decorrelate| d_k(n) | | | Synth | QMF -> R
- ---->| |-------->| | -------- Synth
- ----------- |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include "pv_audio_type_defs.h"
-#include "ps_stereo_processing.h"
-#include "fxp_mul32.h"
-#include "ps_all_pass_filter_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_stereo_processing(STRUCT_PS_DEC *pms,
- Int32 *qmfLeftReal,
- Int32 *qmfLeftImag,
- Int32 *qmfRightReal,
- Int32 *qmfRightImag)
-{
- Int32 group;
- Int32 subband;
- Int32 maxSubband;
- Int32 usb;
- Char index;
-
-
- Int32 *hybrLeftReal;
- Int32 *hybrLeftImag;
- Int32 *hybrRightReal;
- Int32 *hybrRightImag;
- Int32 *ptr_hybrLeftReal;
- Int32 *ptr_hybrLeftImag;
- Int32 *ptr_hybrRightReal;
- Int32 *ptr_hybrRightImag;
-
-
- Int16 h11;
- Int16 h12;
- Int16 h21;
- Int16 h22;
-
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
-
- usb = pms->usb;
-
- /*
- * Complete Linear interpolation
- */
-
- hybrLeftReal = pms->mHybridRealLeft;
- hybrLeftImag = pms->mHybridImagLeft;
- hybrRightReal = pms->mHybridRealRight;
- hybrRightImag = pms->mHybridImagRight;
-
- for (group = 0; group < SUBQMF_GROUPS; group++) /* SUBQMF_GROUPS == 10 */
- {
-
- temp1 = pms->deltaH11[group];
- temp2 = pms->deltaH12[group];
-
- pms->H11[group] += temp1;
- h11 = (Int16)(pms->H11[group] >> 16);
- pms->H12[group] += temp2;
- h12 = (Int16)(pms->H12[group] >> 16);
-
- temp1 = pms->deltaH21[group];
- temp2 = pms->deltaH22[group];
-
- pms->H21[group] += temp1;
- h21 = (Int16)(pms->H21[group] >> 16);
- pms->H22[group] += temp2;
- h22 = (Int16)(pms->H22[group] >> 16);
-
- index = groupBorders[group];
-
- /*
- * Reconstruction of Stereo sub-band signal
- *
- * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
- *
- * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
- */
- ptr_hybrLeftReal = &hybrLeftReal[ index];
- ptr_hybrRightReal = &hybrRightReal[ index];
-
- temp1 = *(ptr_hybrLeftReal) << 1;
- temp2 = *(ptr_hybrRightReal) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
- ptr_hybrLeftImag = &hybrLeftImag[ index];
- ptr_hybrRightImag = &hybrRightImag[ index];
-
- temp1 = *(ptr_hybrLeftImag) << 1;
- temp2 = *(ptr_hybrRightImag) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
- } /* groups loop */
-
- temp1 = pms->deltaH11[SUBQMF_GROUPS];
- temp2 = pms->deltaH12[SUBQMF_GROUPS];
-
- pms->H11[SUBQMF_GROUPS] += temp1;
- h11 = (Int16)(pms->H11[SUBQMF_GROUPS] >> 16);
- pms->H12[SUBQMF_GROUPS] += temp2;
- h12 = (Int16)(pms->H12[SUBQMF_GROUPS] >> 16);
-
- temp1 = pms->deltaH21[SUBQMF_GROUPS];
- temp2 = pms->deltaH22[SUBQMF_GROUPS];
-
- pms->H21[SUBQMF_GROUPS] += temp1;
- h21 = (Int16)(pms->H21[SUBQMF_GROUPS] >> 16);
- pms->H22[SUBQMF_GROUPS] += temp2;
- h22 = (Int16)(pms->H22[SUBQMF_GROUPS] >> 16);
-
-
- ptr_hybrLeftReal = &qmfLeftReal[ 3];
- ptr_hybrRightReal = &qmfRightReal[ 3];
-
- /*
- * Reconstruction of Stereo sub-band signal
- *
- * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
- *
- * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
- */
- temp1 = *(ptr_hybrLeftReal) << 1;
- temp2 = *(ptr_hybrRightReal) << 1;
-
-
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftReal) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
- ptr_hybrLeftImag = &qmfLeftImag[ 3];
- ptr_hybrRightImag = &qmfRightImag[ 3];
-
-
- temp1 = *(ptr_hybrLeftImag) << 1;
- temp2 = *(ptr_hybrRightImag) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftImag) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
- for (group = SUBQMF_GROUPS + 1; group < NO_IID_GROUPS; group++) /* 11 to NO_IID_GROUPS == 22 */
- {
- temp1 = pms->deltaH11[group];
- temp2 = pms->deltaH12[group];
-
- pms->H11[group] += temp1;
- h11 = (Int16)(pms->H11[group] >> 16);
- pms->H12[group] += temp2;
- h12 = (Int16)(pms->H12[group] >> 16);
-
- temp1 = pms->deltaH21[group];
- temp2 = pms->deltaH22[group];
-
- pms->H21[group] += temp1;
- h21 = (Int16)(pms->H21[group] >> 16);
- pms->H22[group] += temp2;
- h22 = (Int16)(pms->H22[group] >> 16);
-
- index = groupBorders[group];
- maxSubband = groupBorders[group + 1];
- maxSubband = min(usb, maxSubband);
-
- /*
- * Reconstruction of Stereo sub-band signal
- *
- * l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
- *
- * r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
- */
-
- ptr_hybrLeftReal = &qmfLeftReal[ index];
- ptr_hybrRightReal = &qmfRightReal[ index];
-
- for (subband = index; subband < maxSubband; subband++)
- {
- temp1 = *(ptr_hybrLeftReal) << 1;
- temp2 = *(ptr_hybrRightReal) << 1;
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftReal++) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightReal++) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
- }
-
- ptr_hybrLeftImag = &qmfLeftImag[ index];
- ptr_hybrRightImag = &qmfRightImag[ index];
-
- for (subband = index; subband < maxSubband; subband++)
- {
- temp1 = *(ptr_hybrLeftImag) << 1;
- temp2 = *(ptr_hybrRightImag) << 1;
- temp3 = fxp_mul32_by_16(temp1, h11);
- *(ptr_hybrLeftImag++) = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
- temp3 = fxp_mul32_by_16(temp1, h12);
- *(ptr_hybrRightImag++) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
- } /* subband loop */
-
- } /* groups loop */
-
-} /* END ps_stereo_processing */
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_stereo_processing.h b/media/libstagefright/codecs/aacdec/ps_stereo_processing.h
deleted file mode 100644
index 58b025a..0000000
--- a/media/libstagefright/codecs/aacdec/ps_stereo_processing.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_stereo_processing.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_stereo_processing()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_STEREO_PROCESSING_H
-#define PS_STEREO_PROCESSING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void ps_stereo_processing(STRUCT_PS_DEC *pms,
- Int32 *qmfLeftReal,
- Int32 *qmfLeftImag,
- Int32 *qmfRightReal,
- Int32 *qmfRightImag);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* PS_STEREO_PROCESSING_H */
diff --git a/media/libstagefright/codecs/aacdec/pulse_nc.cpp b/media/libstagefright/codecs/aacdec/pulse_nc.cpp
deleted file mode 100644
index 87b264d..0000000
--- a/media/libstagefright/codecs/aacdec/pulse_nc.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pulse_nc.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Modified to pass variables by reference to eliminate use
- of global variables.
-
- Description: Modified to bring code in-line with PV standards.
-
- Description: Pass in max as input argument.
-
- Description: Went back to the if-statement to check for max.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- coef[] = Array of quantized spectral coefficents.
- (Int [])
-
- pPulseInfo = Pointer to structure which contains noiseless
- encoding info, includes information about the pulse data,
- pulse amplitude, etc.
- (const PulseInfo *)
-
- pLongFrameInfo = Pointer to structure that holds information about
- each group. (long block flag, number of windows,
- scalefactor bands per group, etc.)
-
- Variable is named (pLongFrameInfo) because this function
- is only used for LONG windows.
- (FrameInfo *)
- max = Pointer to the maximum value of coef[]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coef[] = coefficient contents are modified by the encoded pulse
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function adds pulses to defined ranges of coefficients in the window,
- for the case of LONG windows. The pulses are unsigned, so
- negative coefficients subtract the pulse, and positive coefficients add it.
- (The ampltiude of the coefficient is always increased by the pulse)
-
- A maximum of 4 coefficients may be modified by a pulse, and these
- coefficients must all occur in the same scalefactor band.
-
- The number of pulse-encoded coefficients to be processed by this function
- is communicated to this function via pPulseInfo->number_pulse
-
- This value is equal to the actual number of pulses - 1.
- (e.g if pPulseInfo->number_pulse == 0, one pulse is assumed)
- This function must not be called if no pulse encoded data exists.
- The function assumes that at least one pulse exists.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall correctly add transmitted pulse(s) to the correct
- coefficients in a LONG window.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.3.3 Decoding Process
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb];
-
- pPulseOffset = &(pPulseInfo->pulse_offset[0]);
-
- pPulseAmp = &(pPulseInfo->pulse_amp[0]);
-
- pCoef = &(Coef[index]);
-
- FOR (index = pPulseInfo->number_pulse; index >= 0; index--)
-
- pCoef = pCoef + *(pPulseOffset);
- pPulseOffset = pPulseOffset + 1;
-
- IF (*pCoef > 0)
- *(pCoef) = *(pCoef) + *(pPulseAmp);
- pPulseAmp = pPulseAmp + 1;
- ELSE
- *(pCoef) = *(pCoef) - *(pPulseAmp);
- pPulseAmp = pPulseAmp + 1;
- ENDIF
-
- ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_pulseinfo.h"
-#include "pulse_nc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pulse_nc(
- Int16 coef[],
- const PulseInfo *pPulseInfo,
- const FrameInfo *pLongFrameInfo,
- Int *max)
-{
- Int index;
-
- Int16 *pCoef;
- Int temp;
-
- const Int *pPulseOffset;
- const Int *pPulseAmp;
-
- /*--- Find the scalefactor band where pulse-encoded data starts ---*/
-
- if (pPulseInfo->pulse_start_sfb > 0)
- {
- index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb - 1];
- }
- else
- {
- index = 0;
- }
-
- /*-------------------------------------------------------------------------
- Each pulse index is stored as an offset from the previous pulse
-
- Example - here we have a sfb that is 20 coefficients in length:
-
- [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19]
- [ ][ ][ ][ ][ ][P][P][ ][ ][ ][ ][ ][ ][ ][ ][ P][ ][ ][ ][ P]
-
- The array pointed to by pPulseOffset == [5][1][9][4]
-
- pPulseAmp is of the same length as pPulseOffset, and contains
- an individual pulse amplitude for each coefficient.
- --------------------------------------------------------------------------*/
-
- pCoef = &(coef[index]);
-
- pPulseOffset = &(pPulseInfo->pulse_offset[0]);
-
- pPulseAmp = &(pPulseInfo->pulse_amp[0]);
-
- for (index = pPulseInfo->number_pulse; index > 0; index--)
- {
- pCoef += *pPulseOffset++;
-
- temp = *pCoef;
-
- if (temp > 0)
- {
- temp += *(pPulseAmp++);
- *pCoef = (Int16)temp;
- if (temp > *max)
- {
- *max = temp;
- }
- }
- else
- {
- temp -= *(pPulseAmp++);
- *pCoef = (Int16)temp;
- if (-temp > *max)
- {
- *max = -temp;
- }
- }
-
- } /* for() */
-
- return;
-
-} /* pulse_nc */
diff --git a/media/libstagefright/codecs/aacdec/pulse_nc.h b/media/libstagefright/codecs/aacdec/pulse_nc.h
deleted file mode 100644
index 8181dd0..0000000
--- a/media/libstagefright/codecs/aacdec/pulse_nc.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pulse_nc.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Pass in max as input argument.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the global function declaration for pulse_nc
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PULSE_NC_H
-#define PULSE_NC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_pulseinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void pulse_nc(
- Int16 coef[],
- const PulseInfo *pPulseInfo,
- const FrameInfo *pLongFrameInfo,
- Int *max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h b/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h
deleted file mode 100644
index dee66bc..0000000
--- a/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- Pathname: ./c/include/pv_audio_type_defs.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Removed errant semicolons from #define statements
-
- Description:
- 1. Modified ifndef STD_TYPE_DEFS_H with
- #ifndef PV_AUDIO_TYPE_DEFS_H to avoid double definition
- if file was already included
- 2. Merged cai if-def structures and C++ definition
- 3. Updated copyright notice
-
- Description: Added dependency on OSCL libraries
-
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file was derived from a number of standards bodies. The type
- definitions below were created from some of the best practices observed
- in the standards bodies.
-
- This file is dependent on limits.h for defining the bit widths. In an
- ANSI C environment limits.h is expected to always be present and contain
- the following definitions:
-
- SCHAR_MIN
- SCHAR_MAX
- UCHAR_MAX
-
- INT_MAX
- INT_MIN
- UINT_MAX
-
- SHRT_MIN
- SHRT_MAX
- USHRT_MAX
-
- LONG_MIN
- LONG_MAX
- ULONG_MAX
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_AUDIO_TYPE_DEFS_H
-#define PV_AUDIO_TYPE_DEFS_H
-
-#include <stdint.h>
-
-typedef int8_t Char;
-
-typedef uint8_t UChar;
-
-
-
-/*----------------------------------------------------------------------------
-; Define generic signed and unsigned int
-----------------------------------------------------------------------------*/
-#ifndef Int
-typedef signed int Int;
-#endif
-
-#ifndef UInt
-typedef unsigned int UInt;
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 16 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-#ifndef Int16
-typedef int16_t Int16;
-#endif
-
-#ifndef INT16_MIN
-#define INT16_MIN (-32768)
-#endif
-
-#ifndef INT16_MAX
-#define INT16_MAX 32767
-#endif
-
-#ifndef UInt16
-typedef uint16_t UInt16;
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 32 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-#ifndef Int32
-typedef int32_t Int32;
-#endif
-
-#ifndef INT32_MIN
-#define INT32_MIN (-2147483647 - 1)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX 2147483647
-#endif
-
-#ifndef UInt32
-typedef uint32_t UInt32;
-#endif
-
-#ifndef UINT32_MIN
-#define UINT32_MIN 0
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX 0xffffffff
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 64 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; Define boolean type
-----------------------------------------------------------------------------*/
-#ifndef Bool
-typedef Int Bool;
-#endif
-#ifndef FALSE
-#define FALSE 0
-#endif
-
-#ifndef TRUE
-#define TRUE 1
-#endif
-
-#ifndef OFF
-#define OFF 0
-#endif
-#ifndef ON
-#define ON 1
-#endif
-
-#ifndef NO
-#define NO 0
-#endif
-#ifndef YES
-#define YES 1
-#endif
-
-#ifndef SUCCESS
-#define SUCCESS 0
-#endif
-
-#ifndef NULL
-#define NULL 0
-#endif
-
-
-#endif /* PV_AUDIO_TYPE_DEFS_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_div.cpp b/media/libstagefright/codecs/aacdec/pv_div.cpp
deleted file mode 100644
index 86d2487..0000000
--- a/media/libstagefright/codecs/aacdec/pv_div.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_div.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer numerator
- Int32 y 32-bit integer denominator
- Quotient *result structure that hold result and shift factor
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement division of two Int32 numbers, provides back quotient and a
- shift factor
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "pv_div.h"
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void pv_div(Int32 x, Int32 y, Quotient *result)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- Int32 quotient;
- Int32 i;
- Int32 j;
- Int32 y_ov_y_hi;
- Int32 flag = 0; /* carries negative sign, if any */
-
-
- result->shift_factor = 0; /* default */
-
- if (y == 0)
- {
- x = 0; /* this will return 0 for any div/0 */
- }
- /*
- * make sure x and y are both positive
- */
-
- if (y < 0)
- {
- y = -y;
- flag ^= 1;
- }
-
-
- if (x < 0)
- {
- x = -x;
- flag ^= 1;
- }
-
- if (x != 0)
- {
- /*----------------------------------------------------------------------------
- ; Scale the input to get maximum precision for x
- ----------------------------------------------------------------------------*/
-
- i = pv_normalize(x);
-
- x <<= i;
-
-
- /*----------------------------------------------------------------------------
- ; Scale the input to get maximum precision for y
- ----------------------------------------------------------------------------*/
-
- j = pv_normalize(y);
-
- y <<= j;
-
- result->shift_factor = i - j;
-
- /*----------------------------------------------------------------------------
- ; Function body here
- ----------------------------------------------------------------------------*/
- /*---------------------------------------------------------------
- ; take the inverse of the 16 MSB of y
- ---------------------------------------------------------------*/
-
- quotient = (0x40000000 / (y >> 15));
-
- y_ov_y_hi = fxp_mul32_Q15(y, quotient); /* y*(1/y_hi) */
-
- y_ov_y_hi = 0x7FFFFFFF - y_ov_y_hi; /* 2 - y*(1/y_hi) */
- y_ov_y_hi = fxp_mul32_Q14(quotient, y_ov_y_hi);
- i = fxp_mul32_Q31(y_ov_y_hi, x) << 1;
-
- result->quotient = flag ? -i : i;
- }
- else
- {
- result->quotient = 0;
- }
-
-
-
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_div.h b/media/libstagefright/codecs/aacdec/pv_div.h
deleted file mode 100644
index 2dfa8a0..0000000
--- a/media/libstagefright/codecs/aacdec/pv_div.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_div.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_DIV_H
-#define PV_DIV_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- struct intg_div
- {
- Int32 quotient;
- Int32 shift_factor;
- };
- typedef struct intg_div Quotient;
-
-
- void pv_div(Int32 x, Int32 y, Quotient *quotient);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PV_DIV_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_log2.cpp b/media/libstagefright/codecs/aacdec/pv_log2.cpp
deleted file mode 100644
index 69cbe91..0000000
--- a/media/libstagefright/codecs/aacdec/pv_log2.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_log2.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer input
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement the logarithm base 2 of a number
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_log2.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 20
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 log_table[9] =
-{
- Q_fmt(-0.00879832091331F), Q_fmt(0.12022974263833F),
- Q_fmt(-0.72883958314294F), Q_fmt(2.57909824242332F),
- Q_fmt(-5.90041216630330F), Q_fmt(9.15023342527264F),
- Q_fmt(-9.90616619500413F), Q_fmt(8.11228968755409F),
- Q_fmt(-3.41763474309898F)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-Int32 pv_log2(Int32 z)
-{
- const Int32 *pt_table = log_table;
- Int32 y;
- Int32 i;
-
- Int32 int_log2 = 0;
-
- if (z > Q_fmt(2.0f))
- {
- while (z > Q_fmt(2.0f))
- {
- z >>= 1;
- int_log2++;
- }
- }
- else if (z < Q_fmt(1.0f))
- {
- {
- while (z < Q_fmt(1.0f))
- {
- z <<= 1;
- int_log2--;
- }
- }
- }
-
- /*
- * at this point, input limited to 1<x<2
- */
-
- if (z != Q_fmt(1.0f))
- {
- y = fxp_mul32_Q20(*(pt_table++), z);
-
- for (i = 7; i != 0; i--)
- {
- y += *(pt_table++);
- y = fxp_mul32_Q20(y, z);
- }
-
- y += *(pt_table++);
- }
- else
- {
- y = 0;
- }
-
-
- return (y + (int_log2 << 20)); /* Q20 */
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/pv_log2.h b/media/libstagefright/codecs/aacdec/pv_log2.h
deleted file mode 100644
index 4834e82..0000000
--- a/media/libstagefright/codecs/aacdec/pv_log2.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_log2.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_LOG2_H
-#define PV_LOG2_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- Int32 pv_log2(Int32 z);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PV_LOG2_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_normalize.cpp b/media/libstagefright/codecs/aacdec/pv_normalize.cpp
deleted file mode 100644
index 365b5ad..0000000
--- a/media/libstagefright/codecs/aacdec/pv_normalize.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_normalize.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-Input
- Int32 x 32-bit integer non-zero input
-Returns
- Int32 i number of leading zeros on x
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Returns number of leading zeros on the non-zero input
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#if defined(_ARM)
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-/* function is inlined in header file */
-
-
-#else
-
-Int pv_normalize(Int32 x)
-{
- /*----------------------------------------------------------------------------
- ; Define all local variables
- ----------------------------------------------------------------------------*/
- Int i;
-
-
- if (x > 0x0FFFFFFF)
- {
- i = 0; /* most likely case */
- }
- else if (x > 0x00FFFFFF)
- {
- i = 3; /* second most likely case */
- }
- else if (x > 0x0000FFFF)
- {
- i = x > 0x000FFFFF ? 7 : 11;
- }
- else
- {
- if (x > 0x000000FF)
- {
- i = x > 0x00000FFF ? 15 : 19;
- }
- else
- {
- i = x > 0x0000000F ? 23 : 27;
- }
- }
-
-
- x <<= i;
-
- switch (x & 0x78000000)
- {
- case 0x08000000:
- i += 3;
- break;
-
- case 0x18000000:
- case 0x10000000:
- i += 2;
- break;
- case 0x28000000:
- case 0x20000000:
- case 0x38000000:
- case 0x30000000:
- i++;
-
- default:
- ;
- }
-
- return i;
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/pv_normalize.h b/media/libstagefright/codecs/aacdec/pv_normalize.h
deleted file mode 100644
index dce080e..0000000
--- a/media/libstagefright/codecs/aacdec/pv_normalize.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_normalize.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_NORMALIZE_H
-#define PV_NORMALIZE_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES AND SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-#if defined(_ARM)
-
-__inline Int pv_normalize(Int32 x)
-{
- Int32 y;
- __asm
- {
- clz y, x;
- sub y, y, #1
- }
- return (y);
-}
-
-
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-
-__inline Int pv_normalize(Int32 x)
-{
- register Int32 y;
- register Int32 ra = x;
-
-
- asm volatile(
- "clz %0, %1\n\t"
- "sub %0, %0, #1"
- : "=&r*i"(y)
- : "r"(ra));
- return (y);
-
-}
-
-#else
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int pv_normalize(Int32 x);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
-
-#endif /* PV_NORMALIZE_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_pow2.cpp b/media/libstagefright/codecs/aacdec/pv_pow2.cpp
deleted file mode 100644
index 8dfca23..0000000
--- a/media/libstagefright/codecs/aacdec/pv_pow2.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_pow2.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-Input
- Int32 x 32-bit integer input Q27
-
-Output
- Int32 32-bit integer in Q25
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement the power base 2 for positive numbers lesser than 5.999999
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_pow2.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#define POW_2_TABLE_LENGTH 6
-#define POW_2_TABLE_LENGTH_m_2 (POW_2_TABLE_LENGTH - 2)
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 29
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Q27fmt(x) (Int32)(x*((Int32)1<<27) + (x>=0?0.5F:-0.5F))
-
-const Int32 pow2_table[6] =
-{
- Q_fmt(0.00224510927441F), Q_fmt(0.00777943379416F),
- Q_fmt(0.05737929218747F), Q_fmt(0.23918017179889F),
- Q_fmt(0.69345251849351F), Q_fmt(0.99996347120248F)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-/*
- * z in Q27 format
- */
-
-Int32 pv_pow2(Int32 z)
-{
- const Int32 *pt_table = pow2_table;
- Int32 multiplier = 0;
- Int32 shift_factor;
- Int32 i;
- Int32 v_q;
- Int32 y;
-
-
- if (z > Q27fmt(1.0f))
- {
- v_q = z - (z & 0xF8000000);
- shift_factor = z >> 27;
- }
- else
- {
- v_q = z;
- shift_factor = 0;
- }
-
- if (v_q < Q27fmt(0.5f))
- {
- v_q += Q27fmt(0.5f);
- multiplier = Q_fmt(0.70710678118655F);
- }
-
- v_q = v_q << 2;
-
- y = fxp_mul32_Q29(*(pt_table++), v_q);
-
- for (i = POW_2_TABLE_LENGTH_m_2; i != 0; i--)
- {
- y += *(pt_table++);
- y = fxp_mul32_Q29(y, v_q);
- }
- y += *(pt_table++);
-
- if (multiplier)
- {
- y = fxp_mul32_Q29(y, multiplier);
- }
-
- /*
- * returns number on Q25
- */
- return (y >> (4 - shift_factor));
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/pv_pow2.h b/media/libstagefright/codecs/aacdec/pv_pow2.h
deleted file mode 100644
index 04bfe93..0000000
--- a/media/libstagefright/codecs/aacdec/pv_pow2.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_pow2.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_POW2_H
-#define PV_POW2_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- Int32 pv_pow2(Int32 z);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PV_POW2_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_sine.cpp b/media/libstagefright/codecs/aacdec/pv_sine.cpp
deleted file mode 100644
index 54319b1..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sine.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_sine.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer angle (in Q30) between 0 and pi/2
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Find the sine of a number between 0 and pi/2
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "pv_sine.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 30
-
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 sin_table[9] =
-{
- Q_fmt(0.00001724684028), Q_fmt(-0.00024606242846),
- Q_fmt(0.00007297328923), Q_fmt(0.00826706596417),
- Q_fmt(0.00003585160465), Q_fmt(-0.16667772526248),
- Q_fmt(0.00000174197440), Q_fmt(0.99999989138797),
- Q_fmt(0.00000000110513)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int32 pv_sine(Int32 z)
-{
- Int32 sine;
- Int32 i;
- const Int32 *pt_table = sin_table;
- Int32 sign = 0;
-
- if (z < 0)
- {
- z = -z;
- sign = 1;
- }
-
- if (z > Q_fmt(0.0015))
- {
- sine = fxp_mul32_Q30(*(pt_table++), z);
-
- for (i = 7; i != 0; i--)
- {
- sine += *(pt_table++);
- sine = fxp_mul32_Q30(sine, z);
- }
-
- }
- else
- {
- sine = z; /* better approximation in this range */
- }
-
- if (sign)
- {
- sine = -sine;
- }
-
- return sine;
-}
-
-
-
-Int32 pv_cosine(Int32 z)
-{
- Int32 cosine;
-
- if (z < 0)
- {
- z = -z; /* sign does not play a role in cosine */
- }
-
- if (z > Q_fmt(0.0015))
- {
- z = Q_fmt(1.57079632679490) - z; /* pi/2 - z */
-
- cosine = pv_sine(z);
- }
- else
- { /* better approximation in this range */
- cosine = Q_fmt(0.99999999906868) - (fxp_mul32_Q30(z, z) >> 1);
- }
-
- return cosine;
-}
-
-#endif
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_sine.h b/media/libstagefright/codecs/aacdec/pv_sine.h
deleted file mode 100644
index 145013a..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sine.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_sine.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_SINE_H
-#define PV_SINE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- Int32 pv_sine(Int32 x);
- Int32 pv_cosine(Int32 x);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PV_SINE_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_sqrt.cpp b/media/libstagefright/codecs/aacdec/pv_sqrt.cpp
deleted file mode 100644
index 065fa38..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sqrt.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_sqrt.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 x 32-bit integer
-
- Int32 y 32-bit integer
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-
-#include "fxp_mul32.h"
-#include "pv_sqrt.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#define R_SHIFT 28
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-
-const Int32 sqrt_table[9] =
-{
- Q_fmt(-0.13829740941110F), Q_fmt(0.95383399963991F),
- Q_fmt(-2.92784603873353F), Q_fmt(5.27429191920042F),
- Q_fmt(-6.20272445821478F), Q_fmt(5.04717433019620F),
- Q_fmt(-3.03362807640415F), Q_fmt(1.86178814410910F),
- Q_fmt(0.16540758699193F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache)
-{
-
- Int32 y;
- Int32 xx;
- Int32 nn;
- Int32 i;
- const Int32 *pt_table = sqrt_table;
-
-
- if (sqrt_cache[0] == man && sqrt_cache[1] == exp)
- {
- result->root = sqrt_cache[2];
- result->shift_factor = (Int16)sqrt_cache[3];
- }
- else
- {
-
- sqrt_cache[0] = man;
- sqrt_cache[1] = exp;
-
-
- if (man > 0)
- {
- xx = man;
- if (man >= Q_fmt(1.0f))
- {
- nn = exp + 1;
- while ((xx >>= 1) > Q_fmt(1.0f))
- {
- nn++;
- }
- }
- else if (man < Q_fmt(0.5f))
- {
- nn = exp - 1;
- while ((xx <<= 1) < Q_fmt(0.5f))
- {
- nn--;
- }
- }
- else
- {
- nn = exp;
- }
-
-
- y = fxp_mul32_Q28(*(pt_table++), xx);
-
- for (i = 3; i != 0; i--)
- {
- y += *(pt_table++);
- y = fxp_mul32_Q28(y, xx);
- y += *(pt_table++);
- y = fxp_mul32_Q28(y, xx);
- }
- y += *(pt_table++);
- y = fxp_mul32_Q28(y, xx) + *(pt_table++);
-
- if (nn >= 0)
- {
- if (nn&1)
- {
- y = fxp_mul32_Q29(y, Q_fmt(1.41421356237310F));
- result->shift_factor = (nn >> 1) - 28;
- }
- else
- {
- result->shift_factor = (nn >> 1) - 29;
- }
- }
- else
- {
- if (nn&1)
- {
- y = fxp_mul32_Q28(y, Q_fmt(0.70710678118655F));
- }
-
- result->shift_factor = -((-nn) >> 1) - 29;
- }
-
- result->root = y;
-
- }
- else
- {
- result->root = 0;
- result->shift_factor = 0;
- }
-
- }
-
- sqrt_cache[2] = result->root;
- sqrt_cache[3] = result->shift_factor;
-
-}
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_sqrt.h b/media/libstagefright/codecs/aacdec/pv_sqrt.h
deleted file mode 100644
index 45d6f52..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sqrt.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_sqrt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_SQRT_H
-#define PV_SQRT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- struct intg_sqrt
- {
- Int32 root;
- Int32 shift_factor;
- };
- typedef struct intg_sqrt Root_sq;
-
- void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PV_SQRT_H */
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h b/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h
deleted file mode 100644
index 7806f88..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Name: PVMP4AudioDecoder_API.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change buffer type to UChar
-
- Description: Update comments
-
- Description: Updated a comment that MT did not get around to
- before the end of his contract.
-
- Description: add a new API to decode audioSpecificConfig separately, the same
- change has been made on 32-bits version (element \main\2)
-
- Description: add a new API to reset history buffer, the same change has been
- made on a 32-bits version(element \nd.e0352.wjin\1)
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Main header file for the Packet Video MP4/AAC audio decoder library. The
- constants, structures, and functions defined within this file, along with
- a basic data types header file, is all that is needed to use and communicate
- with the library. The internal data structures within the library are
- purposely hidden.
-
- ---* Need description of the input buffering. *-------
-
- ---* Need an example of calling the library here *----
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (Normally header files do not have a reference section)
-
- ISO/EIC 14496-3:(1999) Document titled
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PVMP4AUDIODECODER_API_H
-#define PVMP4AUDIODECODER_API_H
-
-#include "pv_audio_type_defs.h" /* Basic data types used within the lib */
-
-#include "e_tmp4audioobjecttype.h"
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*
- * This constant is the guaranteed-to-work buffer size, specified in bytes,
- * for the input buffer for 2 audio channels to decode one frame of data,
- * as specified by the MPEG-2 or MPEG-4 standard.
- * The standard, and this constant, do not take into account that lower
- * bitrates will use less data per frame. Note that the number of bits
- * used per frame is variable, and only that the average value will be the
- * bit rate specified during encoding. The standard does not specify
- * over how many frames the average must be maintained.
- *
- * The constant value is 6144 * 2 channels / 8 bits per byte
- */
-
-
-#define PVMP4AUDIODECODER_INBUFSIZE 1536
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
- /*
- * This enumeration is used for the structure element outputFormat. It
- * specifies how the output data is to be formatted. Presently only 16-bit
- * PCM data is supported, and this enum informs how the single output
- * buffer should be for two-channel stereo data.
- * Grouped format stores all the left channel values, then right:
- * "LLLL...LLRRRR...RR"
- * Interleave format store left, then right audio samples:
- * "LRLRLRLR...."
- */
- typedef enum ePVMP4AudioDecoderOutputFormat
- {
- OUTPUTFORMAT_16PCM_GROUPED = 0,
- OUTPUTFORMAT_16PCM_INTERLEAVED = 1
-
- } tPVMP4AudioDecoderOutputFormat;
-
- /*
- * This enumeration holds the possible return values for the main decoder
- * function, PVMP4AudioDecodeFrame. The plan was to easily distinguish
- * whether an error was recoverable (streaming mode) or not. Presently no
- * errors are recoverable, which is a result of not supporting ADTS in
- * this release.
- */
- typedef enum ePVMP4AudioDecoderErrorCode
- {
- MP4AUDEC_SUCCESS = 0,
- MP4AUDEC_INVALID_FRAME = 10,
- MP4AUDEC_INCOMPLETE_FRAME = 20,
- MP4AUDEC_LOST_FRAME_SYNC = 30 /* Cannot happen since no ADTS */
- } tPVMP4AudioDecoderErrorCode;
-
-
- /*
- * This enumeration holds the possible return values for stream type
- * being decoded
- */
- typedef enum
- {
- AAC = 0,
- AACPLUS,
- ENH_AACPLUS
- } STREAMTYPE;
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
- /*
- * This structure is used to communicate information in to and out of the
- * AAC decoder.
- */
-
- typedef struct
-#ifdef __cplusplus
- tPVMP4AudioDecoderExternal // To allow forward declaration of this struct in C++
-#endif
- {
- /*
- * INPUT:
- * Pointer to the input buffer that contains the encoded bistream data.
- * The data is filled in such that the first bit transmitted is
- * the most-significant bit (MSB) of the first array element.
- * The buffer is accessed in a linear fashion for speed, and the number of
- * bytes consumed varies frame to frame.
- * The calling environment can change what is pointed to between calls to
- * the decode function, library, as long as the inputBufferCurrentLength,
- * and inputBufferUsedLength are updated too. Also, any remaining bits in
- * the old buffer must be put at the beginning of the new buffer.
- */
- UChar *pInputBuffer;
-
- /*
- * INPUT:
- * Number of valid bytes in the input buffer, set by the calling
- * function. After decoding the bitstream the library checks to
- * see if it when past this value; it would be to prohibitive to
- * check after every read operation. This value is not modified by
- * the AAC library.
- */
- Int inputBufferCurrentLength;
-
- /*
- * INPUT:
- * The actual size of the buffer.
- * This variable is not used by the library, but is used by the
- * console test application. This parameter could be deleted
- * if this value was passed into these function. The helper functions are
- * not part of the library and are not used by the Common Audio Decoder
- * Interface.
- */
- Int inputBufferMaxLength;
-
- /*
- * INPUT:
- * Enumerated value the output is to be interleaved left-right-left-right.
- * For further information look at the comments for the enumeration.
- */
- tPVMP4AudioDecoderOutputFormat outputFormat;
-
- /*
- * INPUT: (but what is pointed to is an output)
- * Pointer to the output buffer to hold the 16-bit PCM audio samples.
- * If the output is stereo, both left and right channels will be stored
- * in this one buffer. Presently it must be of length of 2048 points.
- * The format of the buffer is set by the parameter outputFormat.
- */
- Int16 *pOutputBuffer;
-
- /*
- * INPUT: (but what is pointed to is an output)
- * Pointer to the output buffer to hold the 16-bit PCM AAC-plus audio samples.
- * If the output is stereo, both left and right channels will be stored
- * in this one buffer. Presently it must be of length of 2048 points.
- * The format of the buffer is set by the parameter outputFormat.
- */
- Int16 *pOutputBuffer_plus; /* Used in AAC+ and enhanced AAC+ */
-
- /*
- * INPUT:
- * AAC Plus Upsampling Factor. Normally set to 2 when Spectrum Band
- * Replication (SBR) is used
- */
- Int32 aacPlusUpsamplingFactor; /* Used in AAC+ and enhanced AAC+ */
-
- /*
- * INPUT:
- * AAC Plus enabler. Deafaults to be ON, unless run time conditions
- * require the SBR and PS tools disabled
- */
- bool aacPlusEnabled;
- /*
- * INPUT:
- * (Currently not being used inside the AAC library.)
- * This flag is set to TRUE when the playback position has been changed,
- * for example, rewind or fast forward. This informs the AAC library to
- * take an appropriate action, which has yet to be determined.
- */
- Bool repositionFlag;
-
- /*
- * INPUT:
- * Number of requested output audio channels. This relieves the calling
- * environment from having to perform stereo-to-mono or mono-to-stereo
- * conversions.
- */
- Int desiredChannels;
-
- /*
- * INPUT/OUTPUT:
- * Number of elements used by the library, initially set to zero by
- * the function PVMP4AudioDecoderInitLibrary, and modified by each
- * call to PVMP4AudioDecodeFrame.
- */
- Int inputBufferUsedLength;
-
- /*
- * INPUT/OUTPUT:
- * Number of bits left over in the next buffer element,
- * This value will always be zero, unless support for ADTS is added.
- */
- Int32 remainderBits;
-
- /*
- * OUTPUT:
- * The sampling rate decoded from the bitstream, in units of
- * samples/second. For this release of the library this value does
- * not change from frame to frame, but future versions will.
- */
- Int32 samplingRate;
-
- /*
- * OUTPUT:
- * This value is the bitrate in units of bits/second. IT
- * is calculated using the number of bits consumed for the current frame,
- * and then multiplying by the sampling_rate, divided by points in a frame.
- * This value can changes frame to frame.
- */
- Int32 bitRate;
-
- /*
- * OUTPUT:
- * The number of channels decoded from the bitstream. The output data
- * will have be the amount specified in the variable desiredChannels,
- * this output is informative only, and can be ignored.
- */
- Int encodedChannels;
-
- /*
- * OUTPUT:
- * This value is the number of output PCM samples per channel.
- * It is presently hard-coded to 1024, but may change in the future.
- * It will not change frame to frame, and would take on
- * one of these four values: 1024, 960, 512, or 480. If an error occurs
- * do not rely on this value.
- */
- Int frameLength;
-
- /*
- * This value is audio object type as defined in struct tMP4AudioObjectType
- * in file e_tMP4AudioObjectType.h
- */
- Int audioObjectType;
-
- /*
- * This value is extended audio object type as defined in struct tMP4AudioObjectType
- * in file e_tMP4AudioObjectType.h. It carries the output Audio Object Type
- */
- Int extendedAudioObjectType;
-
-
- } tPVMP4AudioDecoderExternal;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- OSCL_IMPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void);
-
- OSCL_IMPORT_REF Int PVMP4AudioDecoderInitLibrary(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem);
-
- OSCL_IMPORT_REF Int PVMP4AudioDecodeFrame(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem);
-
- OSCL_IMPORT_REF Int PVMP4AudioDecoderConfig(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem);
-
- OSCL_IMPORT_REF void PVMP4AudioDecoderResetBuffer(
- void *pMem);
-
- OSCL_IMPORT_REF void PVMP4AudioDecoderDisableAacPlus(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem);
-
- Int PVMP4SetAudioConfig(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem,
- Int upsamplingFactor,
- Int samp_rate,
- int num_ch,
- tMP4AudioObjectType audioObjectType);
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* PVMP4AUDIODECODER_API_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp
deleted file mode 100644
index 9208fa8..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderConfig
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) Modified to decode AudioSpecificConfig for any frame number
- pVars->bno
- (2) Update the input and output descriptions
-
- Description: Eliminated search for ADIF header
-
- Description: Added support for AAC+
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pExt = pointer to the external interface structure. See the file
- PVMP4AudioDecoder_API.h for a description of each field.
- Data type of pointer to a tPVMP4AudioDecoderExternal
- structure.
-
- pExt->pInputBuffer: pointer to input buffer containing input
- bitstream
-
- pExt->inputBufferCurrentLength: number of bytes in the input buffer
-
- pExt->inputBufferUsedLength: number of bytes already consumed in
- input buffer
-
- pExt->remainderBits: number of bits consumed in addition to
- pExt->inputBufferUsedLength
-
- pMem = void pointer to hide the internal implementation of the library
- It is cast back to a tDec_Int_File structure. This structure
- contains information that needs to persist between calls to
- this function, or is too big to be placed on the stack, even
- though the data is only needed during execution of this function
- Data type void pointer, internally pointer to a tDec_Int_File
- structure.
-
- Local Stores/Buffers/Pointers Needed: None
- (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = 0 if no error occurred
- MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
- MP4AUDEC_RECOVERABLE if a recoverable error occurred.
- Presently a recoverable error does not exist, but this
- was a requirement.
-
-
- Pointers and Buffers Modified:
- pMem contents are modified.
- pExt: (more detail in the file PVMP4AudioDecoder_API.h)
- inputBufferUsedLength - number of array elements used up by the stream.
- remainderBits - remaining bits in the next UInt32 buffer
- samplingRate - sampling rate in samples per sec
- encodedChannels - channels found on the file (informative)
- frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- subclause 1.6
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */
-#include "sfb.h" /* Where samp_rate_info[] is declared */
-
-#include "get_audio_specific_config.h"
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-OSCL_EXPORT_REF Int PVMP4AudioDecoderConfig(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem)
-{
-
- UInt initialUsedBits; /* Unsigned for C55x */
- tDec_Int_File *pVars; /* Helper pointer */
-
- Int status = MP4AUDEC_INCOMPLETE_FRAME;
-
- /*
- * Initialize "helper" pointers to existing memory.
- */
- pVars = (tDec_Int_File *)pMem;
- /*
- * Translate input buffer variables.
- */
- pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
- pVars->inputStream.inputBufferCurrentLength =
- (UInt)pExt->inputBufferCurrentLength;
-
- pVars->inputStream.availableBits =
- (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);
-
- initialUsedBits =
- (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
- pExt->remainderBits);
-
- pVars->inputStream.usedBits = initialUsedBits;
-
- if (initialUsedBits <= pVars->inputStream.availableBits)
- {
-
- /*
- * Buffer is not overrun, then
- * decode the AudioSpecificConfig() structure
- */
-
- pVars->aacConfigUtilityEnabled = false; /* set aac dec mode */
-
- status = get_audio_specific_config(pVars);
-
- }
-
- byte_align(&pVars->inputStream);
-
-
- if (status == SUCCESS)
- {
-
- pVars->bno++;
-
- /*
- * A possible improvement would be to set these values only
- * when they change.
- */
- pExt->samplingRate =
- samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate;
-
- /*
- * we default to 2 channel, even for mono files, (where channels have same content)
- * this is done to ensure support for enhanced aac+ with implicit signalling
- */
- pExt->aacPlusEnabled = pVars->aacPlusEnabled;
-
-// pExt->encodedChannels = pVars->mc_info.nch;
-
- pExt->encodedChannels = 2;
-
- pExt->frameLength = pVars->frameLength;
-#ifdef AAC_PLUS
- pExt->aacPlusUpsamplingFactor = pVars->mc_info.upsamplingFactor;
-#endif
-
- }
- else
- {
- /*
- * Default to nonrecoverable error status unless there is a Buffer overrun
- */
- status = MP4AUDEC_INVALID_FRAME;
-
- if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
- {
- /* all bits were used but were not enough to complete parsing */
- pVars->inputStream.usedBits = pVars->inputStream.availableBits;
-
- status = MP4AUDEC_INCOMPLETE_FRAME; /* audio config too small */
- }
-
- }
-
- /*
- * Translate from units of bits back into units of words.
- */
-
- pExt->inputBufferUsedLength =
- pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
- pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
- pVars->status = status;
-
- return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp
deleted file mode 100644
index 7a279dc..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp
+++ /dev/null
@@ -1,1458 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pvmp4audiodecodeframe
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Pulled in loop structure from console.c, so that this function
- now decodes all frames in the file.
-
- Original program used several global variables. These have been
- eliminated, except for situations in which the global variables
- could be converted into const types. Otherwise, they are passed
- by reference through the functions.
-
- Description: Begin mods for file I/O removal
-
- Description: Merged trans4m_freq_2_time, trans4m_time_2_freq, etc.
-
- Description: Removing commented out sections of code. This includes the
- removal of unneeded functions init_lt_pred, reset_mc_info,
-
- Description: Copied from aac_decode_frame.c and renamed file,
- Made many changes.
-
- Description: Prepare for code review
-
- Description: Update per review comments:
- 1) Add comment about leaveGetLoop
- 2) Remove inverseTNSCoef array
- 3) fix wnd_shape_this_bk to wnd_shape_prev_bk in F to T
- 4) Clean up comments
- 5) Change call to long_term_synthesis
-
- Description: Remove division for calculation of bitrate.
-
- Description: Remove update of LTP buffers if not LTP audio object type.
-
- Description: Add hasmask to call to right_ch_sfb_tools_ms
-
- Description:
- Modified to call ltp related routines on the left channel
- before intensity is called on the right channel. The previous version
- was causing a problem when IS was used on the right channel and LTP
- on the left channel for the same scalefactor band.
-
- This fix required creating a new function, apply_ms_synt, deleting another
- function (right_ch_sfb_tools_noms.c), and modifying the calling order of
- the other functions.
-
- Description: Made changes per review comments.
-
- Description: Changed name of right_ch_sfb_tools_ms to pns_intensity_right
-
- Description: Added cast, since pVars->inputStream.usedBits is UInt, and
- pExt->remainderBits is Int.
-
- pExt->remainderBits =
- (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK);
-
- Description: Modified to pass a pointer to scratch memory into
- tns_setup_filter.c
-
- Description: Removed include of "s_TNSInfo.h"
-
- Description: Removed call to "tns_setup_filter" which has been eliminated
- by merging its functionality into "get_tns"
-
- Description: Passing in a pointer to a q-format array, rather than
- the address of a single q-format, for the inverse filter case for
- apply_tns.
-
- Description:
- (1) Added #include of "e_ElementId.h"
- Previously, this function was relying on another include file
- to include "e_ElementId.h"
-
- (2) Updated the copyright header.
-
- Description:
- Per review comments, declared two temporary variables
-
- pChLeftShare = pChVars[LEFT]->pShareWfxpCoef;
- pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
-
- Description:
- long_term_synthesis should have been invoked with max_sfb
- as the 2nd parameter, rather than pFrameInfo->sfb_per_win[0].
-
- Old
- long_term_synthesis(
- pChVars[ch]->wnd,
- pFrameInfo->sfb_per_win[0] ...
-
- Correction
- long_term_synthesis(
- pChVars[ch]->wnd,
- pChVars[ch]->pShareWfxpCoef->max_sfb ...
-
- This problem caused long_term_synthesis to read memory which
- was not initialized in get_ics_info.c
-
- Description:
- (1) Utilize scratch memory for the scratch Prog_Config.
-
- Description: (1) Modified to decode ID_END syntactic element after header
-
- Description:
- (1) Reconfigured LTP buffer as a circular buffer. This saves
- 2048 Int16->Int16 copies per frame.
-
- Description: Updated so ltp buffers are not used as a wasteful
- intermediate buffer for LC streams. Data is transferred directly
- from the filterbank to the output stream.
-
- Description: Decode ADIF header if frame count is zero.
- The AudioSpecificConfig is decoded by a separate API.
-
- Description: Added comments explaining how the ltp_buffer_state
- variable is updated.
-
-
- Description: Modified code to take advantage of new trans4m_freq_2_time_fxp,
- which writes the output directly into a 16-bit output buffer. This
- improvement allows faster operation by reducing the amount of memory
- transfers. Speed can be further improved on most platforms via use of a
- DMA transfer in the function write_output.c
-
- Description: perChan[] is an array of structures in tDec_Int_File. Made
- corresponding changes.
-
- Description: Included changes in interface for q_normalize() and
- trans4m_freq_2_time_fxp.
-
- Description: Included changes in interface for long_term_prediction.
-
- Description: Added support for DSE (Data Streaming Channel). Added
- function get_dse() and included file get_dse.h
-
- Description: Added support for the ill-case when a raw data block contains
- only a terminator <ID_END>. This is illegal but is added
- for convinience
-
- Description: Added support for empty audio frames, such the one containing
- only DSE or FILL elements. A trap was added to stop processing
- when no audio information was sent.
-
- Description: Added support for adts format files. Added saturation to
- floating point version of aac+ decoding
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pExt = pointer to the external interface structure. See the file
- PVMP4AudioDecoder_API.h for a description of each field.
- Data type of pointer to a tPVMP4AudioDecoderExternal
- structure.
-
- pMem = void pointer to hide the internal implementation of the library
- It is cast back to a tDec_Int_File structure. This structure
- contains information that needs to persist between calls to
- this function, or is too big to be placed on the stack, even
- though the data is only needed during execution of this function
- Data type void pointer, internally pointer to a tDec_Int_File
- structure.
-
- Local Stores/Buffers/Pointers Needed: None
- (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = 0 if no error occurred
- MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
- MP4AUDEC_RECOVERABLE if a recoverable error occurred.
- Presently a recoverable error does not exist, but this
- was a requirement.
-
-
- Pointers and Buffers Modified:
- pMem contents are modified.
- pExt: (more detail in the file PVMP4AudioDecoder_API.h)
- inputBufferUsedLength - number of array elements used up by the stream.
- remainderBits - remaining bits in the next UInt32 buffer
- samplingRate - sampling rate in samples per sec
- bitRate - bit rate in bits per second, varies frame to frame.
- encodedChannels - channels found on the file (informative)
- frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decodes one frame of an MPEG-2/MPEG-4 encoded audio bitstream.
-
- This function calls the various components of the decoder in the proper order.
-
-
- Left Channel Right Channel
- | |
- | |
- | |
- \|/ \|/
- #1 ____________________ #2 ____________________
- | | | |
- | Huffman Decoding | | Huffman Decoding |
- |__________________| |__________________|
- | |
- | |
- | |
- \|/ |
- #3 ____________________ |
- | | |
- | PNS LEFT | |
- |__________________| |
- | |
- | |
- | |
- \|/ \|/
- #4 ______________________________________________________________________
- | |
- | Apply MS_Synt |
- |____________________________________________________________________|
- | |
- | |
- \|/ |
- #5 ____________________ |
- | | W
- | LTP | A
- |__________________| I
- | T
- | |
- | F
- \|/ O
- #6 ____________________ R
- | | |
- | Time -> Freq | L
- |__________________| E
- | F
- | T
- | |
- \|/ C
- #7 ____________________ H
- | | A
- | TNS Inverse | N
- |__________________| N
- | E
- | L
- | |
- \|/ |
- #8 ____________________ |
- | | |
- | Long Term Synth | |
- |__________________| |
- | |
- | \|/
- | #9 ____________________
- | | |
- |--DATA ON LEFT CHANNEL MAY BE USED----->| PNS/Intensity Rt |
- | |__________________|
- | |
- | |
- | \|/
- | #10 ____________________
- W | |
- A | LTP |
- I |__________________|
- T |
- | |
- F |
- O \|/
- R #11 ____________________
- | | |
- R | Time -> Freq |
- I |__________________|
- G |
- H |
- T |
- | \|/
- C #12 ____________________
- H | |
- A | TNS Inverse |
- N |__________________|
- N |
- E |
- L |
- | \|/
- | #13 ____________________
- | | |
- | | Long Term Synth |
- | |__________________|
- | |
- | |
- | |
- \|/ \|/
-#14 ____________________ #18 ____________________
- | | | |
- | TNS | | TNS |
- |__________________| |__________________|
- | |
- | |
- | |
- \|/ \|/
-#15 ____________________ #19 ____________________
- | | | |
- | qFormatNorm | | qFormatNorm |
- |__________________| |__________________|
- | |
- | |
- | |
- \|/ \|/
-#16 ____________________ #20 ____________________
- | | | |
- | Freq / Time | | Freq / Time |
- |__________________| |__________________|
- | |
- | |
- | |
- \|/ \|/
-#17 ____________________ #21 ____________________
- | | | |
- | Limit Buffer | | Limit Buffer |
- |__________________| |__________________|
- | |
- | |
- | |
- \|/ \|/
-#22 ______________________________________________________________________
- | |
- | Write Output |
- |____________________________________________________________________|
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#include "s_tdec_int_chan.h"
-#include "s_tdec_int_file.h"
-#include "aac_mem_funcs.h"
-#include "sfb.h" /* Where samp_rate_info[] is declared */
-#include "e_tmp4audioobjecttype.h"
-#include "e_elementid.h"
-
-
-#include "get_adif_header.h"
-#include "get_adts_header.h"
-#include "get_audio_specific_config.h"
-#include "ibstream.h" /* where getbits is declared */
-
-#include "huffman.h" /* where huffdecode is declared */
-#include "get_prog_config.h"
-#include "getfill.h"
-#include "pns_left.h"
-
-#include "apply_ms_synt.h"
-#include "pns_intensity_right.h"
-#include "q_normalize.h"
-#include "long_term_prediction.h"
-#include "long_term_synthesis.h"
-#include "ltp_common_internal.h"
-#include "apply_tns.h"
-
-#include "window_block_fxp.h"
-
-#include "write_output.h"
-
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-#include "get_dse.h"
-
-#include "sbr_applied.h"
-#include "sbr_open.h"
-#include "get_sbr_bitstream.h"
-#include "e_sbr_element_id.h"
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define LEFT (0)
-#define RIGHT (1)
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-void InitSbrSynFilterbank(bool bDownSampleSBR);
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-OSCL_EXPORT_REF Int PVMP4AudioDecodeFrame(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem)
-{
- Int frameLength; /* Helper variable */
- Int ch;
- Int id_syn_ele;
- UInt initialUsedBits; /* Unsigned for C55x */
- Int qFormatNorm;
- Int qPredictedSamples;
- Bool leaveGetLoop;
- MC_Info *pMC_Info; /* Helper pointer */
- FrameInfo *pFrameInfo; /* Helper pointer */
- tDec_Int_File *pVars; /* Helper pointer */
- tDec_Int_Chan *pChVars[Chans]; /* Helper pointer */
-
- per_chan_share_w_fxpCoef *pChLeftShare; /* Helper pointer */
- per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */
-
- Int status = MP4AUDEC_SUCCESS;
-
-
- Bool empty_frame;
-
-#ifdef AAC_PLUS
-
- SBRDECODER_DATA *sbrDecoderData;
- SBR_DEC *sbrDec;
- SBRBITSTREAM *sbrBitStream;
-
-#endif
- /*
- * Initialize "helper" pointers to existing memory.
- */
- pVars = (tDec_Int_File *)pMem;
-
- pMC_Info = &pVars->mc_info;
-
- pChVars[LEFT] = &pVars->perChan[LEFT];
- pChVars[RIGHT] = &pVars->perChan[RIGHT];
-
- pChLeftShare = pChVars[LEFT]->pShareWfxpCoef;
- pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
-
-
-#ifdef AAC_PLUS
-
- sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData;
- sbrDec = (SBR_DEC *) & pVars->sbrDec;
- sbrBitStream = (SBRBITSTREAM *) & pVars->sbrBitStr;
-
-#ifdef PARAMETRICSTEREO
- sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec;
-#endif
-
-#endif
- /*
- * Translate input buffer variables.
- */
- pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
- pVars->inputStream.inputBufferCurrentLength = (UInt)pExt->inputBufferCurrentLength;
-
- pVars->inputStream.availableBits =
- (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);
-
- initialUsedBits =
- (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
- pExt->remainderBits);
-
- pVars->inputStream.usedBits = initialUsedBits;
-
- if (initialUsedBits > pVars->inputStream.availableBits)
- {
- status = MP4AUDEC_INVALID_FRAME;
- }
- else if (pVars->bno == 0)
- {
- /*
- * Attempt to read in ADIF format first because it is easily identified.
- * If its not an ADIF bitstream, get_adif_header rewinds the "pointer"
- * (actually usedBits).
- */
- status =
- get_adif_header(
- pVars,
- &(pVars->scratch.scratch_prog_config));
-
- byte_align(&pVars->inputStream);
-
- if (status == SUCCESS)
- {
- pVars->prog_config.file_is_adts = FALSE;
- }
- else /* we've tried simple audio config, adif, then it should be adts */
- {
- pVars->prog_config.file_is_adts = TRUE;
- }
- }
- else if ((pVars->bno == 1) && (pVars->prog_config.file_is_adts == FALSE))
- {
-
- /*
- * There might be an ID_END element following immediately after the
- * AudioSpecificConfig header. This syntactic element should be read
- * and byte_aligned before proceeds to decode "real" AAC raw data.
- */
- id_syn_ele = (Int)getbits(LEN_SE_ID, &pVars->inputStream) ;
-
- if (id_syn_ele == ID_END)
- {
-
- byte_align(&pVars->inputStream);
-
- pExt->inputBufferUsedLength =
- pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
- pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
- pVars->bno++;
-
- return(status);
- }
- else
- {
- /*
- * Rewind bitstream pointer so that the syntactic element can be
- * read when decoding raw bitstream
- */
- pVars->inputStream.usedBits -= LEN_SE_ID;
- }
-
- }
-
- if (pVars->prog_config.file_is_adts == TRUE)
- {
- /*
- * If file is adts format, let the decoder handle only on data raw
- * block at the time, once the last (or only) data block has been
- * processed, then synch on the next header
- */
- if (pVars->prog_config.headerless_frames)
- {
- pVars->prog_config.headerless_frames--; /* raw data block counter */
- }
- else
- {
- status = get_adts_header(pVars,
- &(pVars->syncword),
- &(pVars->invoke),
- 3); /* CorrectlyReadFramesCount */
-
- if (status != SUCCESS)
- {
- status = MP4AUDEC_LOST_FRAME_SYNC; /* we lost track of header */
- }
- }
- }
- else
- {
- byte_align(&pVars->inputStream);
- }
-
-#ifdef AAC_PLUS
- sbrBitStream->NrElements = 0;
- sbrBitStream->NrElementsCore = 0;
-
-#endif
-
- /*
- * The variable leaveGetLoop is used to signal that the following
- * loop can be left, which retrieves audio syntatic elements until
- * an ID_END is found, or an error occurs.
- */
- leaveGetLoop = FALSE;
- empty_frame = TRUE;
-
- while ((leaveGetLoop == FALSE) && (status == SUCCESS))
- {
- /* get audio syntactic element */
- id_syn_ele = (Int)get9_n_lessbits(LEN_SE_ID, &pVars->inputStream);
-
- /*
- * As fractional frames are a possible input, check that parsing does not
- * go beyond the available bits before parsing the syntax.
- */
- if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
- {
- status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */
- id_syn_ele = ID_END; /* quit while-loop */
- }
-
- switch (id_syn_ele)
- {
- case ID_END: /* terminator field */
- leaveGetLoop = TRUE;
- break;
-
- case ID_SCE: /* single channel */
- case ID_CPE: /* channel pair */
- empty_frame = FALSE;
- status =
- huffdecode(
- id_syn_ele,
- &(pVars->inputStream),
- pVars,
- pChVars);
-
-#ifdef AAC_PLUS
- if (id_syn_ele == ID_SCE)
- {
- sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_SCE;
- }
- else if (id_syn_ele == ID_CPE)
- {
- sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_CPE;
- }
- sbrBitStream->NrElementsCore++;
-
-
-#endif
-
- break;
-
- case ID_PCE: /* program config element */
- /*
- * PCE are not accepted in the middle of a
- * raw_data_block. If found, a possible error may happen
- * If a PCE is encountered during the first 2 frames,
- * it will be read and accepted
- * if its tag matches the first, with no error checking
- * (inside of get_prog_config)
- */
-
- if (pVars->bno <= 1)
- {
- status = get_prog_config(pVars,
- &(pVars->scratch.scratch_prog_config));
- }
- else
- {
- status = MP4AUDEC_INVALID_FRAME;
- }
- break;
-
- case ID_FIL: /* fill element */
-#ifdef AAC_PLUS
- get_sbr_bitstream(sbrBitStream, &pVars->inputStream);
-
-#else
- getfill(&pVars->inputStream);
-#endif
-
- break;
-
- case ID_DSE: /* Data Streaming element */
- get_dse(pVars->share.data_stream_bytes,
- &pVars->inputStream);
- break;
-
- default: /* Unsupported element, including ID_LFE */
- status = -1; /* ERROR CODE needs to be updated */
- break;
-
- } /* end switch() */
-
- } /* end while() */
-
- byte_align(&pVars->inputStream);
-
- /*
- * After parsing the first frame ( bno=0 (adif), bno=1 (raw))
- * verify if implicit signalling is forcing to upsample AAC with
- * no AAC+/eAAC+ content. If so, disable upsampling
- */
-
-#ifdef AAC_PLUS
- if (pVars->bno <= 1)
- {
- if ((pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC) &&
- (!sbrBitStream->NrElements))
- {
- PVMP4AudioDecoderDisableAacPlus(pExt, pMem);
- }
- }
-#endif
-
- /*
- * There might be an empty raw data block with only a
- * ID_END element or non audio ID_DSE, ID_FIL
- * This is an "illegal" condition but this trap
- * avoids any further processing
- */
-
- if (empty_frame == TRUE)
- {
- pExt->inputBufferUsedLength =
- pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
- pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
- pVars->bno++;
-
- return(status);
-
- }
-
-#ifdef AAC_PLUS
-
- if (sbrBitStream->NrElements)
- {
- /* for every core SCE or CPE there must be an SBR element, otherwise sths. wrong */
- if (sbrBitStream->NrElements != sbrBitStream->NrElementsCore)
- {
- status = MP4AUDEC_INVALID_FRAME;
- }
-
- if (pExt->aacPlusEnabled == false)
- {
- sbrBitStream->NrElements = 0; /* disable aac processing */
- }
- }
- else
- {
- /*
- * This is AAC, but if aac+/eaac+ was declared in the stream, and there is not sbr content
- * something is wrong
- */
- if (pMC_Info->sbrPresentFlag || pMC_Info->psPresentFlag)
- {
- status = MP4AUDEC_INVALID_FRAME;
- }
- }
-#endif
-
-
-
-
- /*
- * Signal processing section.
- */
- frameLength = pVars->frameLength;
-
- if (status == SUCCESS)
- {
- /*
- * PNS and INTENSITY STEREO and MS
- */
-
- pFrameInfo = pVars->winmap[pChVars[LEFT]->wnd];
-
- pns_left(
- pFrameInfo,
- pChLeftShare->group,
- pChLeftShare->cb_map,
- pChLeftShare->factors,
- pChLeftShare->lt_status.sfb_prediction_used,
- pChLeftShare->lt_status.ltp_data_present,
- pChVars[LEFT]->fxpCoef,
- pChLeftShare->qFormat,
- &(pVars->pns_cur_noise_state));
-
- /*
- * apply_ms_synt can only be ran for common windows.
- * (where both the left and right channel share the
- * same grouping, window length, etc.
- *
- * pVars->hasmask will be > 0 only if
- * common windows are enabled for this frame.
- */
-
- if (pVars->hasmask > 0)
- {
- apply_ms_synt(
- pFrameInfo,
- pChLeftShare->group,
- pVars->mask,
- pChLeftShare->cb_map,
- pChVars[LEFT]->fxpCoef,
- pChVars[RIGHT]->fxpCoef,
- pChLeftShare->qFormat,
- pChRightShare->qFormat);
- }
-
- for (ch = 0; (ch < pMC_Info->nch); ch++)
- {
- pFrameInfo = pVars->winmap[pChVars[ch]->wnd];
-
- /*
- * Note: This MP4 library assumes that if there are two channels,
- * then the second channel is right AND it was a coupled channel,
- * therefore there is no need to check the "is_cpe" flag.
- */
-
- if (ch > 0)
- {
- pns_intensity_right(
- pVars->hasmask,
- pFrameInfo,
- pChRightShare->group,
- pVars->mask,
- pChRightShare->cb_map,
- pChLeftShare->factors,
- pChRightShare->factors,
- pChRightShare->lt_status.sfb_prediction_used,
- pChRightShare->lt_status.ltp_data_present,
- pChVars[LEFT]->fxpCoef,
- pChVars[RIGHT]->fxpCoef,
- pChLeftShare->qFormat,
- pChRightShare->qFormat,
- &(pVars->pns_cur_noise_state));
- }
-
- if (pChVars[ch]->pShareWfxpCoef->lt_status.ltp_data_present != FALSE)
- {
- /*
- * LTP - Long Term Prediction
- */
-
- qPredictedSamples = long_term_prediction(
- pChVars[ch]->wnd,
- pChVars[ch]->pShareWfxpCoef->lt_status.
- weight_index,
- pChVars[ch]->pShareWfxpCoef->lt_status.
- delay,
- pChVars[ch]->ltp_buffer,
- pVars->ltp_buffer_state,
- pChVars[ch]->time_quant,
- pVars->share.predictedSamples, /* Scratch */
- frameLength);
-
- trans4m_time_2_freq_fxp(
- pVars->share.predictedSamples,
- pChVars[ch]->wnd,
- pChVars[ch]->wnd_shape_prev_bk,
- pChVars[ch]->wnd_shape_this_bk,
- &qPredictedSamples,
- pVars->scratch.fft); /* scratch memory for FFT */
-
-
- /*
- * To solve a potential problem where a pointer tied to
- * the qFormat was being incremented, a pointer to
- * pChVars[ch]->qFormat is passed in here rather than
- * the address of qPredictedSamples.
- *
- * Neither values are actually needed in the case of
- * inverse filtering, but the pointer was being
- * passed (and incremented) regardless.
- *
- * So, the solution is to pass a space of memory
- * that a pointer can happily point to.
- */
-
- /* This is the inverse filter */
- apply_tns(
- pVars->share.predictedSamples, /* scratch re-used for each ch */
- pChVars[ch]->pShareWfxpCoef->qFormat, /* Not used by the inv_filter */
- pFrameInfo,
- &(pChVars[ch]->pShareWfxpCoef->tns),
- TRUE, /* TRUE is FIR */
- pVars->scratch.tns_inv_filter);
-
- /*
- * For the next function long_term_synthesis,
- * the third param win_sfb_top[], and
- * the tenth param coef_per_win,
- * are used differently that in the rest of the project. This
- * is because originally the ISO code was going to have
- * these parameters change as the "short window" changed.
- * These are all now the same value for each of the eight
- * windows. This is why there is a [0] at the
- * end of each of theses parameters.
- * Note in particular that win_sfb_top was originally an
- * array of pointers to arrays, but inside long_term_synthesis
- * it is now a simple array.
- * When the rest of the project functions are changed, the
- * structure FrameInfo changes, and the [0]'s are removed,
- * this comment could go away.
- */
- long_term_synthesis(
- pChVars[ch]->wnd,
- pChVars[ch]->pShareWfxpCoef->max_sfb,
- pFrameInfo->win_sfb_top[0], /* Look above */
- pChVars[ch]->pShareWfxpCoef->lt_status.win_prediction_used,
- pChVars[ch]->pShareWfxpCoef->lt_status.sfb_prediction_used,
- pChVars[ch]->fxpCoef, /* input and output */
- pChVars[ch]->pShareWfxpCoef->qFormat, /* input and output */
- pVars->share.predictedSamples,
- qPredictedSamples, /* q format for previous aray */
- pFrameInfo->coef_per_win[0], /* Look above */
- NUM_SHORT_WINDOWS,
- NUM_RECONSTRUCTED_SFB);
-
- } /* end if (pChVars[ch]->lt_status.ltp_data_present != FALSE) */
-
- } /* for(ch) */
-
- for (ch = 0; (ch < pMC_Info->nch); ch++)
- {
-
- pFrameInfo = pVars->winmap[pChVars[ch]->wnd];
-
- /*
- * TNS - Temporal Noise Shaping
- */
-
- /* This is the forward filter
- *
- * A special note: Scratch memory is not used by
- * the forward filter, but is passed in to maintain
- * common interface for inverse and forward filter
- */
- apply_tns(
- pChVars[ch]->fxpCoef,
- pChVars[ch]->pShareWfxpCoef->qFormat,
- pFrameInfo,
- &(pChVars[ch]->pShareWfxpCoef->tns),
- FALSE, /* FALSE is IIR */
- pVars->scratch.tns_inv_filter);
-
- /*
- * Normalize the q format across all scale factor bands
- * to one value.
- */
- qFormatNorm =
- q_normalize(
- pChVars[ch]->pShareWfxpCoef->qFormat,
- pFrameInfo,
- pChVars[ch]->abs_max_per_window,
- pChVars[ch]->fxpCoef);
-
- /*
- * filterbank - converts frequency coeficients to time domain.
- */
-
-#ifdef AAC_PLUS
- if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1)
- {
- trans4m_freq_2_time_fxp_2(
- pChVars[ch]->fxpCoef,
- pChVars[ch]->time_quant,
- pChVars[ch]->wnd, /* window sequence */
- pChVars[ch]->wnd_shape_prev_bk,
- pChVars[ch]->wnd_shape_this_bk,
- qFormatNorm,
- pChVars[ch]->abs_max_per_window,
- pVars->scratch.fft,
- &pExt->pOutputBuffer[ch]);
- /*
- * Update LTP buffers if needed
- */
-
- if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP)
- {
- Int16 * pt = &pExt->pOutputBuffer[ch];
- Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]);
- Int16 x, y;
- for (Int32 i = HALF_LONG_WINDOW; i != 0; i--)
- {
- x = *pt;
- pt += 2;
- y = *pt;
- pt += 2;
- *(ptr++) = x;
- *(ptr++) = y;
- }
- }
- }
- else
- {
- trans4m_freq_2_time_fxp_1(
- pChVars[ch]->fxpCoef,
- pChVars[ch]->time_quant,
- &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state + 288]),
- pChVars[ch]->wnd, /* window sequence */
- pChVars[ch]->wnd_shape_prev_bk,
- pChVars[ch]->wnd_shape_this_bk,
- qFormatNorm,
- pChVars[ch]->abs_max_per_window,
- pVars->scratch.fft);
-
- }
-#else
-
- trans4m_freq_2_time_fxp_2(
- pChVars[ch]->fxpCoef,
- pChVars[ch]->time_quant,
- pChVars[ch]->wnd, /* window sequence */
- pChVars[ch]->wnd_shape_prev_bk,
- pChVars[ch]->wnd_shape_this_bk,
- qFormatNorm,
- pChVars[ch]->abs_max_per_window,
- pVars->scratch.fft,
- &pExt->pOutputBuffer[ch]);
- /*
- * Update LTP buffers only if needed
- */
-
- if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP)
- {
- Int16 * pt = &pExt->pOutputBuffer[ch];
- Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]);
- Int16 x, y;
- for (Int32 i = HALF_LONG_WINDOW; i != 0; i--)
- {
- x = *pt;
- pt += 2;
- y = *pt;
- pt += 2;
- *(ptr++) = x;
- *(ptr++) = y;
- }
-
- }
-
-
-#endif
-
-
- /* Update the window shape */
- pChVars[ch]->wnd_shape_prev_bk = pChVars[ch]->wnd_shape_this_bk;
-
- } /* end for() */
-
-
- /*
- * Copy to the final output buffer, taking into account the desired
- * channels from the calling environment, the actual channels, and
- * whether the data should be interleaved or not.
- *
- * If the stream had only one channel, write_output will not use
- * the right channel data.
- *
- */
-
-
- /* CONSIDER USE OF DMA OPTIMIZATIONS WITHIN THE write_output FUNCTION.
- *
- * It is presumed that the ltp_buffer will reside in internal (fast)
- * memory, while the pExt->pOutputBuffer will reside in external
- * (slow) memory.
- *
- */
-
-
-#ifdef AAC_PLUS
-
- if (sbrBitStream->NrElements || pMC_Info->upsamplingFactor == 2)
- {
-
- if (pVars->bno <= 1) /* allows console to operate with ADIF and audio config */
- {
- if (sbrDec->outSampleRate == 0) /* do it only once (disregarding of signaling type) */
- {
- sbr_open(samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate,
- sbrDec,
- sbrDecoderData,
- pVars->mc_info.bDownSampledSbr);
- }
-
- }
- pMC_Info->upsamplingFactor =
- sbrDecoderData->SbrChannel[0].frameData.sbr_header.sampleRateMode;
-
-
- /* reuse right aac spectrum channel */
- {
- Int16 *pt_left = &(pChVars[LEFT ]->ltp_buffer[pVars->ltp_buffer_state]);
- Int16 *pt_right = &(pChVars[RIGHT]->ltp_buffer[pVars->ltp_buffer_state]);
-
- if (sbr_applied(sbrDecoderData,
- sbrBitStream,
- pt_left,
- pt_right,
- pExt->pOutputBuffer,
- sbrDec,
- pVars,
- pMC_Info->nch) != SBRDEC_OK)
- {
- status = MP4AUDEC_INVALID_FRAME;
- }
- }
-
-
- } /* if( pExt->aacPlusEnabled == FALSE) */
-#endif
-
- /*
- * Copied mono data in both channels or just leave it as mono,
- * according with desiredChannels (default is 2)
- */
-
- if (pExt->desiredChannels == 2)
- {
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
- if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1)
-#else
- if (pMC_Info->nch != 2)
-#endif
-#else
- if (pMC_Info->nch != 2)
-#endif
- {
- /* mono */
-
-
- Int16 * pt = &pExt->pOutputBuffer[0];
- Int16 * pt2 = &pExt->pOutputBuffer[1];
- Int i;
- if (pMC_Info->upsamplingFactor == 2)
- {
- for (i = 0; i < 1024; i++)
- {
- *pt2 = *pt;
- pt += 2;
- pt2 += 2;
- }
- pt = &pExt->pOutputBuffer_plus[0];
- pt2 = &pExt->pOutputBuffer_plus[1];
-
- for (i = 0; i < 1024; i++)
- {
- *pt2 = *pt;
- pt += 2;
- pt2 += 2;
- }
- }
- else
- {
- for (i = 0; i < 1024; i++)
- {
- *pt2 = *pt;
- pt += 2;
- pt2 += 2;
- }
- }
-
- }
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
-
- else if (pMC_Info->psPresentFlag == 1)
- {
- Int32 frameSize = 0;
- if (pExt->aacPlusEnabled == false)
- {
- /*
- * Decoding eaac+ when only aac is enabled, copy L into R
- */
- frameSize = 1024;
- }
- else if (sbrDecoderData->SbrChannel[0].syncState != SBR_ACTIVE)
- {
- /*
- * Decoding eaac+ when no PS data was found, copy upsampled L into R
- */
- frameSize = 2048;
- }
-
- Int16 * pt = &pExt->pOutputBuffer[0];
- Int16 * pt2 = &pExt->pOutputBuffer[1];
- Int i;
- for (i = 0; i < frameSize; i++)
- {
- *pt2 = *pt;
- pt += 2;
- pt2 += 2;
- }
- }
-#endif
-#endif
-
- }
- else
- {
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
- if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1)
-#else
- if (pMC_Info->nch != 2)
-#endif
-#else
- if (pMC_Info->nch != 2)
-#endif
- {
- /* mono */
- Int16 * pt = &pExt->pOutputBuffer[0];
- Int16 * pt2 = &pExt->pOutputBuffer[0];
- Int i;
-
- if (pMC_Info->upsamplingFactor == 2)
- {
- for (i = 0; i < 1024; i++)
- {
- *pt2++ = *pt;
- pt += 2;
- }
-
- pt = &pExt->pOutputBuffer_plus[0];
- pt2 = &pExt->pOutputBuffer_plus[0];
-
- for (i = 0; i < 1024; i++)
- {
- *pt2++ = *pt;
- pt += 2;
- }
- }
- else
- {
- for (i = 0; i < 1024; i++)
- {
- *pt2++ = *pt;
- pt += 2;
- }
- }
-
- }
-
- }
-
-
-
-
- /* pVars->ltp_buffer_state cycles between 0 and 1024. The value
- * indicates the location of the data corresponding to t == -2.
- *
- * | t == -2 | t == -1 | pVars->ltp_buffer_state == 0
- *
- * | t == -1 | t == -2 | pVars->ltp_buffer_state == 1024
- *
- */
-
-#ifdef AAC_PLUS
- if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1)
- {
- pVars->ltp_buffer_state ^= frameLength;
- }
- else
- {
- pVars->ltp_buffer_state ^= (frameLength + 288);
- }
-#else
- pVars->ltp_buffer_state ^= frameLength;
-#endif
-
-
- if (pVars->bno <= 1)
- {
- /*
- * to set these values only during the second call
- * when they change.
- */
- pExt->samplingRate =
- samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate;
-
- pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed
- * only the first time
- */
-
-
-#ifdef AAC_PLUS
-
- if (pMC_Info->upsamplingFactor == 2)
- {
- pExt->samplingRate *= pMC_Info->upsamplingFactor;
- pExt->aacPlusUpsamplingFactor = pMC_Info->upsamplingFactor;
- }
-
-#endif
-
- pExt->extendedAudioObjectType = pMC_Info->ExtendedAudioObjectType;
- pExt->audioObjectType = pMC_Info->audioObjectType;
-
- pExt->encodedChannels = pMC_Info->nch;
- pExt->frameLength = pVars->frameLength;
- }
-
- pVars->bno++;
-
-
- /*
- * Using unit analysis, the bitrate is a function of the sampling rate, bits,
- * points in a frame
- *
- * bits samples frame
- * ---- = --------- * bits * -------
- * sec sec sample
- *
- * To save a divide, a shift is used. Presently only the value of
- * 1024 is used by this library, so make it the most accurate for that
- * value. This may need to be updated later.
- */
-
- pExt->bitRate = (pExt->samplingRate *
- (pVars->inputStream.usedBits - initialUsedBits)) >> 10; /* LONG_WINDOW 1024 */
-
- pExt->bitRate >>= (pMC_Info->upsamplingFactor - 1);
-
-
- } /* end if (status == SUCCESS) */
-
-
- if (status != MP4AUDEC_SUCCESS)
- {
- /*
- * A non-SUCCESS decoding could be due to an error on the bitstream or
- * an incomplete frame. As access to the bitstream beyond frame boundaries
- * are not allowed, in those cases the bitstream reading routine return a 0
- * Zero values guarantees that the data structures are filled in with values
- * that eventually will signal an error (like invalid parameters) or that allow
- * completion of the parsing routine. Either way, the partial frame condition
- * is verified at this time.
- */
- if (pVars->prog_config.file_is_adts == TRUE)
- {
- status = MP4AUDEC_LOST_FRAME_SYNC;
- pVars->prog_config.headerless_frames = 0; /* synchronization forced */
- }
- else
- {
- /*
- * Check if the decoding error was due to buffer overrun, if it was,
- * update status
- */
- if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
- {
- /* all bits were used but were not enough to complete decoding */
- pVars->inputStream.usedBits = pVars->inputStream.availableBits;
-
- status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */
- }
- }
- }
-
- /*
- * Translate from units of bits back into units of words.
- */
-
- pExt->inputBufferUsedLength =
- pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
- pExt->remainderBits = (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK);
-
-
-
- return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp
deleted file mode 100644
index 7cdecd0..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderGetMemRequirements.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Copied from aac_decode_frame
-
- Description: Cleaned up.
-
- Description: (1) use UInt32 to replace size_t type
- (2) memory of tDec_Int_File is splitted into 3 pieces,
- sizeof(tDec_Int_File) is only part of the total memory
- required. The additional memory required to decode per
- channel information is allocated by a DPI call outside this
- API
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs: None
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- size = amount of memory needed to be allocated by the calling
- environment.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function returns the amount of internal memory needed by the library.
- Presently this is a constant value, but could later be more sophisticated
- by taking into account mono or stereo, and whether LTP is to be used.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- size = sizeof(tDec_Int_File);
-
- RETURN (size)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void)
-{
- UInt32 size;
-
- size = (UInt32) sizeof(tDec_Int_File);
-
- return (size);
-
-} /* PVMP4AudioDecoderGetMemRequirements() */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp
deleted file mode 100644
index 146ba0f..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderInitLibrary.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Copied from aac_decode_frame
-
- Description: Clean up.
-
- Description: Update per review comments
-
- Description: Add frame_length, fix mistake in pseudo-code.
- Change frame_length to frameLength, to matcht the API,
- look more professional, etc.
-
- Description:
- (1) Added #include of "e_ProgConfigConst.h"
- Previously, this function was relying on another include file
- to include "e_ProgConfigConst.h"
-
- (2) Updated the copyright header.
-
- Description:
- (1) Modified to initialize pointers for shared memory techniques.
-
- Description: Since memory will be allocated continuously, it is initialized
- in one spot
-
- Description: Added field aacPlusUpsamplingFactor (default == 1) to have a
- common interface for all AAC variations
-
- Description: Added PVMP4AudioDecoderDisableAacPlus to disable sbr decoding
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pExt = pointer to the external application-program interface (API)
- structure that a client program uses to communicate information
- with this library. Among the items in this structure is a pointer
- to the input and output buffers, data for handling the input buffer
- and output information. Look in PVMP4AudioDecoder_API.h for all the
- fields to this structure. Data type pointer to a
- tPVMP4AudioDecoderExternal structure.
-
- pMem = pointer to allocated memory, of the size returned by the function
- PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
- two reasons:
- 1) So the external program does not need all of the header files
- for all of the fields in the structure tDec_Int_File
- 2) To hide data and the implementation of the program. Even knowing
- how data is stored can help in reverse engineering software.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = 0 (SUCCESS). Presently there is no error checking in this
- function.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Initializes the internal memory for the MP4 Audio Decoder library.
- Also sets relevant values for the external interface structure, clears
- the bit rate, channel count, sampling rate, and number of used buffer
- elements.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pVars = pMem;
-
- CALL pv_memset(
- to = pVars,
- c = 0,
- n = sizeof(tDec_Int_File))
- MODIFYING(*pVars = 0)
- RETURNING(nothing)
-
- pVars->current_program = -1
- pVars->mc_info.sampling_rate_idx = Fs_44
- pVars->frameLength = LONG_WINDOW
-
-
- pVars->winmap[ONLY_LONG_SEQUENCE] = &pVars->longFrameInfo;
- pVars->winmap[LONG_START_SEQUENCE] = &pVars->longFrameInfo;
- pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo;
- pVars->winmap[LONG_STOP_SEQUENCE] = &pVars->longFrameInfo;
-
- CALL infoinit(
- samp_rate_indx = pVars->mc_info.sampling_rate_idx,
- ppWin_seq_info = pVars->winmap,
- pSfbwidth128 = pVars->SFBWidth128)
- MODIFYING(ppWinSeq_info)
- MODIFYING(pSfbwidth128)
- RETURNING(nothing)
-
- pExt->bitRate = 0;
- pExt->encodedChannels = 0;
- pExt->samplingRate = 0;
- pExt->inputBufferUsedLength = 0;
-
- MODIFY(pExt)
- MODIFY(pMem)
- RETURN(SUCCESS)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "e_progconfigconst.h"
-
-#include "huffman.h" /* For the definition of infoinit */
-#include "aac_mem_funcs.h" /* For pv_memset */
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-#include "s_tdec_int_chan.h"
-#include "sfb.h" /* samp_rate_info[] is declared here */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem)
-{
- tDec_Int_File *pVars;
-
- pVars = (tDec_Int_File *)pMem;
-
- /*
- * Initialize all memory. The pointers to channel memory will be
- * set to zero also.
- */
- pv_memset(
- pVars,
- 0,
- sizeof(tDec_Int_File));
-
- /*
- * Pick default values for the library.
- */
- pVars->perChan[0].fxpCoef = pVars->fxpCoef[0];
- pVars->perChan[1].fxpCoef = pVars->fxpCoef[1];
-
- /* Here, the "shared memory" pointer is set to point
- * at the 1024th element of fxpCoef, because those spaces
- * in memory are not used until the filterbank is called.
- *
- * Therefore, any variables that are only used before
- * the filterbank can occupy this same space in memory.
- */
-
- pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
- & (pVars->perChan[0].fxpCoef[1024]);
-
- pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
- & (pVars->perChan[1].fxpCoef[1024]);
-
- /*
- * This next line informs the function get_prog_config that no
- * configuration has been found thus far, so it is a default
- * configuration.
- */
-
- pVars->current_program = -1;
- pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */
-
- /*
- * In the future, the frame length will change with MP4 file format.
- * Presently this variable is used to simply the unit test for
- * the function PVMP4AudioDecodeFrame() .. otherwise the test would
- * have to pass around 1024 length arrays.
- */
- pVars->frameLength = LONG_WINDOW; /* 1024*/
-
- /*
- * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and
- * LONG_STOP_SEQUENCE share the same information. The only difference
- * between the windows is accounted for in the "filterbank", in
- * the function trans4m_freq_2_time_fxp()
- */
-
- pVars->winmap[ONLY_LONG_SEQUENCE] /* 0 */ = &pVars->longFrameInfo;
- pVars->winmap[LONG_START_SEQUENCE] /* 1 */ = &pVars->longFrameInfo;
- pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo;
- pVars->winmap[LONG_STOP_SEQUENCE] /* 3 */ = &pVars->longFrameInfo;
-
- infoinit(
- pVars->mc_info.sampling_rate_idx,
- (FrameInfo **)pVars->winmap,
- pVars->SFBWidth128);
-
-
- /*
- * Clear out external output values. These values are set later at the end
- * of PVMP4AudioDecodeFrames()
- */
- pExt->bitRate = 0;
- pExt->encodedChannels = 0;
- pExt->samplingRate = 0;
- pExt->aacPlusUpsamplingFactor = 1; /* Default for regular AAC */
- pVars->aacPlusEnabled = pExt->aacPlusEnabled;
-
-
-#if defined(AAC_PLUS)
- pVars->sbrDecoderData.setStreamType = 1; /* Enable Lock for AAC stream type setting */
-#endif
-
- /*
- * Initialize input buffer variable.
- */
-
- pExt->inputBufferUsedLength = 0;
-
- return (MP4AUDEC_SUCCESS);
-
-} /* PVMP4AudioDecoderInitLibrary */
-
-
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pExt = pointer to the external application-program interface (API)
- structure that a client program uses to communicate information
- with this library. Among the items in this structure is a pointer
- to the input and output buffers, data for handling the input buffer
- and output information. Look in PVMP4AudioDecoder_API.h for all the
- fields to this structure. Data type pointer to a
- tPVMP4AudioDecoderExternal structure.
-
- pMem = pointer to allocated memory, of the size returned by the function
- PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
- two reasons:
- 1) So the external program does not need all of the header files
- for all of the fields in the structure tDec_Int_File
- 2) To hide data and the implementation of the program. Even knowing
- how data is stored can help in reverse engineering software.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = 0 (SUCCESS). Presently there is no error checking in this
- function.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Disable SBR decoding functionality and set parameters accordingly
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem)
-{
- tDec_Int_File *pVars;
-
- pVars = (tDec_Int_File *)pMem;
-
- if ((pVars->aacPlusEnabled == true) && (pExt->aacPlusEnabled == true))
- {
- // disable only when makes sense
- pVars->aacPlusEnabled = false;
- pExt->aacPlusEnabled = false;
-
-#if defined(AAC_PLUS)
- pVars->mc_info.upsamplingFactor = 1;
- pVars->mc_info.psPresentFlag = 0;
- pVars->mc_info.sbrPresentFlag = 0;
- pVars->prog_config.sampling_rate_idx += 3;
- pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
- pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
-
-
- pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate;
- pExt->aacPlusUpsamplingFactor = 1;
-#endif
- }
-} /* PVMP4AudioDecoderDisableAacPlus */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp
deleted file mode 100644
index c10423b..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderResetBuffer.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) add more comments (2) set pVars->bno = 1
-
- Description: perChan[] is an array of structures in tDec_Int_File. Made
- corresponding changes.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- pMem = void pointer to hide the internal implementation of the library
- It is cast back to a tDec_Int_File structure. This structure
- contains information that needs to persist between calls to
- PVMP4AudioDecodeFrame
- Data type void pointer, internally pointer to a tDec_Int_File
- structure.
-
- Local Stores/Buffers/Pointers Needed: None
- (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified:
- pMem contents are modified.
- pMem->perChan[0].time_quant[0-1023]: contents are set to zero
- pMem->perChan[1].time_quant[0-1023]: contents are set to zero
- pMem->bno = 1
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function is called when the same audio clip will be played again from
- the begining. This situation happens when the "stop" button is pressed or
- the "loop-mode" is selected on PVPlayer. Since it is the same audio clip to
- be played again, the decoder does not need to reset the audioSpecificInfo.
- However, the overlap-and-add buffer of the filterbank output needs to be
- cleared, so that the decoder can re-start properly from the begining of
- the audio. The frame number counter, pVars->bno, is set to 1 because the
- audioSpecificInfo is decoded on pVars->bno==0
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- subclause 1.6
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-#include "aac_mem_funcs.h"
-
-#ifdef AAC_PLUS
-#include "s_sbr_frame_data.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT (0)
-#define RIGHT (1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-OSCL_EXPORT_REF void PVMP4AudioDecoderResetBuffer(void *pMem)
-{
-
- tDec_Int_File *pVars; /* Helper pointer */
-
-#ifdef AAC_PLUS
- SBR_FRAME_DATA * hFrameData_1;
- SBR_FRAME_DATA * hFrameData_2;
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- SBRDECODER_DATA *sbrDecoderData;
-#endif
-#endif
-
-#endif
- /*
- * Initialize "helper" pointers to existing memory.
- */
- pVars = (tDec_Int_File *)pMem;
-
- /*
- * Clear the overlap-and-add buffer of filterbank output. The audio
- * clip will be played again from the beginning.
- */
- pv_memset(pVars->perChan[LEFT].time_quant,
- 0,
- LONG_WINDOW*sizeof(pVars->perChan[LEFT].time_quant[0]));
-
- pv_memset(pVars->perChan[RIGHT].time_quant,
- 0,
- LONG_WINDOW*sizeof(pVars->perChan[RIGHT].time_quant[0]));
-
-
-#ifdef AAC_PLUS
-
- if (!pVars->sbrDecoderData.setStreamType) /* reset only when stream type is defined */
- {
- if (pVars->aacPlusEnabled == true) /* clear buffer only if they were used */
- {
-
- hFrameData_1 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[LEFT].frameData;
- hFrameData_2 = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[RIGHT].frameData;
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData;
- sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec;
-#endif
-#endif
-
-
- pv_memset(&pVars->perChan[LEFT].ltp_buffer[0],
- 0,
- 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0]));
- pv_memset(&pVars->perChan[LEFT].ltp_buffer[1024 + 288],
- 0,
- 288*sizeof(pVars->perChan[LEFT].ltp_buffer[0]));
- pv_memset(hFrameData_1->V,
- 0,
- 1152*sizeof(hFrameData_1->V[0]));
- pv_memset(hFrameData_1->prevNoiseLevel_man,
- 0,
- MAX_NUM_NOISE_VALUES*sizeof(hFrameData_1->prevNoiseLevel_man[0]));
-
-
- pv_memset(&pVars->perChan[RIGHT].ltp_buffer[0],
- 0,
- 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0]));
- pv_memset(&pVars->perChan[RIGHT].ltp_buffer[1024 + 288],
- 0,
- 288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0]));
- pv_memset(hFrameData_2->V,
- 0,
- 1152*sizeof(hFrameData_2->V[0]));
-
- pv_memset(hFrameData_2->prevNoiseLevel_man,
- 0,
- MAX_NUM_NOISE_VALUES*sizeof(hFrameData_2->prevNoiseLevel_man[0]));
-
-
- int i;
- for (i = 0; i < 8; i++)
- {
- pv_memset((void *)&hFrameData_1->codecQmfBufferReal[i],
- 0,
- sizeof(**hFrameData_1->codecQmfBufferReal) << 5);
- }
-
-
- /* ---- */
- pv_memset((void *)hFrameData_1->BwVectorOld,
- 0,
- sizeof(*hFrameData_1->BwVectorOld)*MAX_NUM_PATCHES);
-
-#ifdef HQ_SBR
-
- for (i = 0; i < 5; i++)
- {
- pv_memset((void *)&hFrameData_1->fBuffer_man[i],
- 0,
- sizeof(**hFrameData_1->fBuffer_man)*64);
- pv_memset((void *)&hFrameData_1->fBufferN_man[i],
- 0,
- sizeof(**hFrameData_1->fBufferN_man)*64);
- }
-#endif
-
-
- /* ---- */
-
-
-
- pv_memset((void *)hFrameData_1->HistsbrQmfBufferReal,
- 0,
- sizeof(*hFrameData_1->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS);
-
-#ifdef HQ_SBR
- pv_memset((void *)hFrameData_1->HistsbrQmfBufferImag,
- 0,
- sizeof(*hFrameData_1->HistsbrQmfBufferImag)*6*SBR_NUM_BANDS);
-#endif
-
- if (pVars->sbrDec.LC_aacP_DecoderFlag == 1) /* clear buffer only for LC decoding */
- {
-
- for (i = 0; i < 8; i++)
- {
- pv_memset((void *)&hFrameData_2->codecQmfBufferReal[i],
- 0,
- sizeof(**hFrameData_1->codecQmfBufferReal) << 5);
- }
-
- pv_memset((void *)hFrameData_2->HistsbrQmfBufferReal,
- 0,
- sizeof(*hFrameData_2->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS);
-
-
- pv_memset((void *)hFrameData_2->BwVectorOld,
- 0,
- sizeof(*hFrameData_2->BwVectorOld)*MAX_NUM_PATCHES);
-
-#ifdef HQ_SBR
-
- for (i = 0; i < 5; i++)
- {
- pv_memset((void *)&hFrameData_2->fBuffer_man[i],
- 0,
- sizeof(**hFrameData_2->fBuffer_man)*64);
- pv_memset((void *)&hFrameData_2->fBufferN_man[i],
- 0,
- sizeof(**hFrameData_2->fBufferN_man)*64);
- }
-#endif
-
- }
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- else if (pVars->mc_info.psPresentFlag == 1)
- {
- for (i = 0; i < 3; i++)
- {
- pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal[i],
- 0,
- HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal));
- pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag[i],
- 0,
- HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag));
- }
- }
-#endif
-#endif
-
- /*
- * default to UPSAMPLING, as if the file is SBR_ACTIVE, this will be fine and will be
- * fixed onced the new sbr header is found
- * SBR headers contain SBT freq. range as well as control signals that do not require
- * frequent changes.
- * For streaming, the SBR header is sent twice per second. Also, an SBR header can be
- * inserted at any time, if a change of parameters is needed.
- */
-
- pVars->sbrDecoderData.SbrChannel[LEFT].syncState = UPSAMPLING;
- pVars->sbrDecoderData.SbrChannel[RIGHT].syncState = UPSAMPLING;
-
- }
- }
-#endif /* #ifdef AAC_PLUS */
-
- /* reset frame count to 1 */
- pVars->bno = 1;
-
- return ;
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp b/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp
deleted file mode 100644
index d183d84..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pvmp4setaudioconfigg
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pExt = pointer to the external interface structure. See the file
- PVMP4AudioDecoder_API.h for a description of each field.
- Data type of pointer to a tPVMP4AudioDecoderExternal
- structure.
-
- pExt->pInputBuffer: pointer to input buffer containing input
- bitstream
-
- pExt->inputBufferCurrentLength: number of bytes in the input buffer
-
- pExt->inputBufferUsedLength: number of bytes already consumed in
- input buffer
-
- pExt->remainderBits: number of bits consumed in addition to
- pExt->inputBufferUsedLength
-
- pMem = void pointer to hide the internal implementation of the library
- It is cast back to a tDec_Int_File structure. This structure
- contains information that needs to persist between calls to
- this function, or is too big to be placed on the stack, even
- though the data is only needed during execution of this function
- Data type void pointer, internally pointer to a tDec_Int_File
- structure.
-
- Local Stores/Buffers/Pointers Needed: None
- (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
- status = 0 if no error occurred
- MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
- MP4AUDEC_RECOVERABLE if a recoverable error occurred.
- Presently a recoverable error does not exist, but this
- was a requirement.
-
-
- Pointers and Buffers Modified:
- pMem contents are modified.
- pExt: (more detail in the file PVMP4AudioDecoder_API.h)
- inputBufferUsedLength - number of array elements used up by the stream.
- remainderBits - remaining bits in the next UInt32 buffer
- samplingRate - sampling rate in samples per sec
- encodedChannels - channels found on the file (informative)
- frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h" /* where #define INBUF_ARRAY_INDEX_SHIFT */
-#include "sfb.h" /* Where samp_rate_info[] is declared */
-
-#include "get_audio_specific_config.h"
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-#include "set_mc_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int PVMP4SetAudioConfig(
- tPVMP4AudioDecoderExternal *pExt,
- void *pMem,
- Int upsamplingFactor,
- Int samp_rate,
- Int num_ch,
- tMP4AudioObjectType audioObjectType)
-
-{
-
- tDec_Int_File *pVars; /* Helper pointer */
-
- Int status = MP4AUDEC_INCOMPLETE_FRAME;
-
- /*
- * Initialize "helper" pointers to existing memory.
- */
- pVars = (tDec_Int_File *)pMem;
- /*
- * Translate input buffer variables.
- */
- pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
- pVars->inputStream.availableBits = 0;
-
- pVars->inputStream.usedBits = 0;
-
-
-
- /*
- * get sampling rate index
- */
-
- switch (samp_rate)
- {
- case 96000:
- pVars->prog_config.sampling_rate_idx = 0;
- break;
- case 88200:
- pVars->prog_config.sampling_rate_idx = 1;
- break;
- case 64000:
- pVars->prog_config.sampling_rate_idx = 2;
- break;
- case 48000:
- pVars->prog_config.sampling_rate_idx = 3;
- break;
- case 44100:
- pVars->prog_config.sampling_rate_idx = 4;
- break;
- case 32000:
- pVars->prog_config.sampling_rate_idx = 5;
- break;
- case 24000:
- pVars->prog_config.sampling_rate_idx = 6;
- break;
- case 22050:
- pVars->prog_config.sampling_rate_idx = 7;
- break;
- case 16000:
- pVars->prog_config.sampling_rate_idx = 8;
- break;
- case 12000:
- pVars->prog_config.sampling_rate_idx = 9;
- break;
- case 11025:
- pVars->prog_config.sampling_rate_idx = 10;
- break;
- case 8000:
- pVars->prog_config.sampling_rate_idx = 11;
- break;
- case 7350:
- pVars->prog_config.sampling_rate_idx = 12;
- break;
- default:
- status = -1;
-
- break;
- }
-
- pVars->mc_info.sbrPresentFlag = 0;
- pVars->mc_info.psPresentFlag = 0;
-#ifdef AAC_PLUS
- pVars->mc_info.bDownSampledSbr = 0;
-#endif
- pVars->mc_info.implicit_channeling = 0;
- pVars->mc_info.nch = num_ch;
- pVars->mc_info.upsamplingFactor = upsamplingFactor;
-
-
- /*
- * Set number of channels
- */
-
- if (num_ch == 2)
- {
- pVars->prog_config.front.ele_is_cpe[0] = 1;
- }
- else if (num_ch == 1)
- {
- pVars->prog_config.front.ele_is_cpe[0] = 0;
- }
- else
- {
- status = -1; /* do not support more than two channels */
- pVars->status = status;
- return (status);
- }
-
-
- /*
- * Set AAC bitstream
- */
-
- if ((audioObjectType == MP4AUDIO_AAC_LC) ||
- (audioObjectType == MP4AUDIO_LTP))
- {
- pVars->aacPlusEnabled = false;
-
- status = set_mc_info(&(pVars->mc_info),
- audioObjectType, /* previously profile */
- pVars->prog_config.sampling_rate_idx,
- pVars->prog_config.front.ele_tag[0],
- pVars->prog_config.front.ele_is_cpe[0],
- pVars->winmap, /*pVars->pWinSeqInfo,*/
- pVars->SFBWidth128);
- }
- else if ((audioObjectType == MP4AUDIO_SBR) ||
- (audioObjectType == MP4AUDIO_PS))
- {
- pVars->aacPlusEnabled = true;
-
-
- status = set_mc_info(&(pVars->mc_info),
- MP4AUDIO_AAC_LC,
- pVars->prog_config.sampling_rate_idx,
- pVars->prog_config.front.ele_tag[0],
- pVars->prog_config.front.ele_is_cpe[0],
- pVars->winmap, /*pVars->pWinSeqInfo,*/
- pVars->SFBWidth128);
-
- pVars->mc_info.sbrPresentFlag = 1;
- if (audioObjectType == MP4AUDIO_PS)
- {
- pVars->mc_info.psPresentFlag = 1;
- }
-
- if (upsamplingFactor == 1)
- {
-#ifdef AAC_PLUS
- pVars->mc_info.bDownSampledSbr = 1;
-#endif
-
- /*
- * Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
- */
- if (pVars->prog_config.sampling_rate_idx < 6)
- {
- pVars->aacPlusEnabled = false;
- }
- }
-
- }
- else
- {
- status = -1;
- }
-
-
- /*
- * Translate from units of bits back into units of words.
- */
- pExt->inputBufferUsedLength = 0;
-
- pExt->remainderBits = 0;
-
- pVars->bno++;
-
- pExt->samplingRate = samp_rate * upsamplingFactor;
-
- pExt->aacPlusEnabled = pVars->aacPlusEnabled;
-
- /*
- * we default to 2 channel, even for mono files, (where channels have same content)
- * this is done to ensure support for enhanced aac+ with implicit signalling
- */
-
- pExt->encodedChannels = 2;
-
- pExt->frameLength = 1024;
-#ifdef AAC_PLUS
- pExt->aacPlusUpsamplingFactor = upsamplingFactor;
-#endif
-
- pVars->status = status;
-
- return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
diff --git a/media/libstagefright/codecs/aacdec/q_normalize.cpp b/media/libstagefright/codecs/aacdec/q_normalize.cpp
deleted file mode 100644
index 5266966..0000000
--- a/media/libstagefright/codecs/aacdec/q_normalize.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: q_normalize.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modify to include search over the scalefactor bands to insure
- that the data is using all 31 data-bits.
-
- Description:
- (1) Modify to remove search over the scalefactor bands to insure
- that the data is using all 31 data-bits.
- (Pushed out into separate function)
- (2) Change variable "k" to more descriptive "shift_amt"
- (3) Update pseudocode to reflect removed code.
- (4) Add PV Copyright notice.
-
- Description:
- (1) Modified to protect q-normalize from shifting by amounts >= 32.
-
- Description:
- (1) Delete local variable idx_count.
-
- Description:
- (1) Included search for max in each frame, modified interface.
-
- Description:
- (1) unrolled loop based on the fact that the size of each scale band
- is always an even number.
-
- Description:Check shift, if zero, do not shift.
-
- Description: Eliminated warning: non use variable "i" and memset function
- definition
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- qFormat[] = Array of qFormats, one per scalefactor band. [ Int ]
-
- pFrameInfo = Pointer to structure that holds information about each group.
- (long block flag, number of windows, scalefactor bands, etc.)
- [const FrameInfo]
-
- coef[] = Array of the spectral coefficients for one channel. [ Int32 ]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- min_q = The common q-format for the entire frame. [Int]
-
- Pointers and Buffers Modified:
- coef[] = Array of spectral data, now normalized to one q-format.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module first scans every scalefactor band for the frame, insuring that
- at least one element in that scalefactor band is using all available bits.
- If not, the elements in the scalefactor band are shifted up to use all 31
- data bits. The q-format is adjusted accordingly.
-
- This module then scans the q-formats for each scalefactor band.
- Upon finding the minimum q-format in the frame, the coefficients in each
- scalefactor band are normalized to the minimum q-format.
- The minimum q-format is then returned to the calling function, which is now
- the q-format for the entire frame.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- nwin = pFrameInfo->num_win;
-
- pQformat = &(qFormat[0]);
- pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
- pCoef = &(coef[0]);
-
- FOR (win = nwin; win > 0; win--)
-
- nsfb = *(pSfbPerWin++);
-
- FOR (sfb = nsfb; sfb > 0; sfb--)
-
- IF ( *(pQformat) < min_q)
- min_q = *(pQformat);
- ENDIF
-
- pQformat++;
-
- ENDFOR
-
- ENDFOR
-
- pQformat = &(qFormat[0]);
- pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
- pCoef = &(coef[0]);
-
- FOR (win = 0; win < nwin; win++)
-
- stop_idx = 0;
-
- nsfb = *(pSfbPerWin++);
-
- pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]);
-
- FOR (sfb = nsfb; sfb > 0; sfb--)
-
- sfbWidth = *(pWinSfbTop++) - stop_idx;
-
- stop_idx += sfbWidth;
-
- k = *(pQformat++) - min_q;
-
- IF (k < 32)
- THEN
- FOR (; sfbWidth > 0; sfbWidth--)
- *(pCoef++) >>= k;
- ENDFOR
- ELSE
- FOR (; sfbWidth > 0; sfbWidth--)
- *(pCoef++) = 0;
- ENDFOR
- ENDIF
-
- ENDFOR
-
- ENDFOR
-
- return min_q;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "q_normalize.h"
-#include "aac_mem_funcs.h" /* For pv_memset */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int q_normalize(
- Int qFormat[],
- const FrameInfo *pFrameInfo,
- Int32 abs_max_per_window[],
- Int32 coef[])
-{
- Int sfb;
- Int nsfb;
- Int win;
- Int nwin;
- Int sfbWidth;
-
- Int shift_amt;
-
- /* Initialize min_q to a very large value */
- Int min_q = 1000;
-
- Int stop_idx = 0;
-
- const Int *pSfbPerWin;
- const Int16 *pWinSfbTop;
-
- Int *pQformat;
- Int32 *pCoef;
-
- nwin = pFrameInfo->num_win;
-
- /* Find the minimum q format */
- pQformat = &(qFormat[0]);
- pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
-
- for (win = nwin; win != 0; win--)
- {
-
- nsfb = *(pSfbPerWin++);
-
- if (nsfb < 0 || nsfb > MAXBANDS)
- {
- break; /* avoid any processing on error condition */
- }
-
- for (sfb = nsfb; sfb != 0; sfb--)
- {
- Int qformat = *(pQformat++);
- if (qformat < min_q)
- {
- min_q = qformat;
- }
- }
-
- } /* for(win) */
-
- /* Normalize the coefs in each scalefactor band to one q-format */
- pQformat = &(qFormat[0]);
- pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
- pCoef = &(coef[0]);
-
- for (win = 0; win < nwin; win++)
- {
-
- Int32 max = 0;
- stop_idx = 0;
-
- nsfb = *(pSfbPerWin++);
-
- if (nsfb < 0 || nsfb > MAXBANDS)
- {
- break; /* avoid any processing on error condition */
- }
-
- pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]);
-
- for (sfb = nsfb; sfb != 0; sfb--)
- {
- Int tmp1, tmp2;
- tmp1 = *(pWinSfbTop++);
- tmp2 = *(pQformat++);
- sfbWidth = tmp1 - stop_idx;
-
- if (sfbWidth < 2)
- {
- break; /* will lead to error condition */
- }
-
- stop_idx += sfbWidth;
-
- shift_amt = tmp2 - min_q;
-
- if (shift_amt == 0)
- {
- Int32 tmp1, tmp2;
- tmp1 = *(pCoef++);
- tmp2 = *(pCoef++);
- /*
- * sfbWidth is always an even number
- * (check tables in pg.66 IS0 14496-3)
- */
- for (Int i = (sfbWidth >> 1) - 1; i != 0; i--)
- {
- max |= (tmp1 >> 31) ^ tmp1;
- max |= (tmp2 >> 31) ^ tmp2;
- tmp1 = *(pCoef++);
- tmp2 = *(pCoef++);
- }
- max |= (tmp1 >> 31) ^ tmp1;
- max |= (tmp2 >> 31) ^ tmp2;
-
- }
- else
- {
- if (shift_amt < 31)
- {
- Int32 tmp1, tmp2;
- tmp1 = *(pCoef++) >> shift_amt;
- tmp2 = *(pCoef--) >> shift_amt;
- /*
- * sfbWidth is always an even number
- * (check tables in pg.66 IS0 14496-3)
- */
- for (Int i = (sfbWidth >> 1) - 1; i != 0; i--)
- {
- *(pCoef++) = tmp1;
- *(pCoef++) = tmp2;
-
- max |= (tmp1 >> 31) ^ tmp1;
- max |= (tmp2 >> 31) ^ tmp2;
- tmp1 = *(pCoef++) >> shift_amt;
- tmp2 = *(pCoef--) >> shift_amt;
-
- }
- *(pCoef++) = tmp1;
- *(pCoef++) = tmp2;
- max |= (tmp1 >> 31) ^ tmp1;
- max |= (tmp2 >> 31) ^ tmp2;
-
- }
- else
- {
- pv_memset(pCoef, 0, sizeof(Int32)*sfbWidth);
- pCoef += sfbWidth;
- }
- }
-
- abs_max_per_window[win] = max;
-
- }
-
- } /* for (win) */
-
- return min_q;
-
-} /* normalize() */
diff --git a/media/libstagefright/codecs/aacdec/q_normalize.h b/media/libstagefright/codecs/aacdec/q_normalize.h
deleted file mode 100644
index 63a9d53..0000000
--- a/media/libstagefright/codecs/aacdec/q_normalize.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: q_normalize.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Added PV Copyright notice.
- (2) Removed embedded TABS
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function definition for q_normalize.h
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef Q_NORMALIZE_H
-#define Q_NORMALIZE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int q_normalize(
- Int qFormat[],
- const FrameInfo *pFrameInfo,
- Int32 abs_max_per_window[],
- Int32 coef[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp b/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp
deleted file mode 100644
index 1164129..0000000
--- a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: qmf_filterbank_coeff.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function defines the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "qmf_filterbank_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-const Int32 sbrDecoderFilterbankCoefficients[155] =
-{
- /* 10/9*table */
-
- 0xFFEA0066, 0x020C09CF, 0x34F67965, 0xCE380A2F, 0xFE43005A,
- 0xFFEA006C, 0x02360998, 0x36907954, 0xCFCD0A57, 0xFE690054,
- 0xFFEC0072, 0x0262095B, 0x382B7937, 0xD1600A7A, 0xFE8E004F,
- 0xFFED0078, 0x028E0919, 0x39C6790F, 0xD2F00A98, 0xFEB20049,
- 0xFFED007E, 0x02BB08D0, 0x3B6378DB, 0xD47D0AB1, 0xFED50043,
- 0xFFEC0084, 0x02E90882, 0x3D00789B, 0xD6080AC6, 0xFEF6003E,
- 0xFFEB0089, 0x0318082F, 0x3E9D7851, 0xD78F0AD6, 0xFF160039,
- 0xFFEB008F, 0x034807D5, 0x403A77FB, 0xD9130AE2, 0xFF350033,
- 0xFFEA0095, 0x03790775, 0x41D7779A, 0xDA930AEA, 0xFF53002E,
- 0xFFE9009A, 0x03AB070E, 0x4373772D, 0xDC100AED, 0xFF6F0029,
- 0xFFE800A0, 0x03DE06A2, 0x450D76B6, 0xDD890AED, 0xFF8A0024,
- 0xFFE800A5, 0x0412062F, 0x46A77633, 0xDEFD0AE9, 0xFFA40020,
- 0xFFE700AA, 0x044705B6, 0x483F75A6, 0xE06D0AE2, 0xFFBD001C,
- 0xFFE600AF, 0x047B0537, 0x49D5750E, 0xE1D90AD7, 0xFFD40017,
- 0xFFE500B3, 0x04B104B0, 0x4B69746B, 0xE3400AC8, 0xFFEB0013,
- 0xFFE400B8, 0x04E70423, 0x4CFA73BE, 0xE4A20AB7, 0x0002000F,
- 0xFFE400BC, 0x051E0390, 0x4E897306, 0xE5FF0AA2, 0x0016000B,
- 0xFFE300BF, 0x055502F6, 0x50157244, 0xE7560A8A, 0x00280008,
- 0xFFE300C3, 0x058D0254, 0x519D7178, 0xE8A80A6F, 0x003A0004,
- 0xFFE300C6, 0x05C401AD, 0x532270A2, 0xE9F50A53, 0x004A0001,
- 0xFFE200C8, 0x05FC00FE, 0x54A36FC3, 0xEB3C0A33, 0x005AFFFC,
- 0xFFE200CA, 0x06340048, 0x56206EDA, 0xEC7D0A11, 0x0068FFF9,
- 0xFFE200CC, 0x066CFF8A, 0x57986DE8, 0xEDB809EC, 0x0075FFF7,
- 0xFFE200CD, 0x06A4FEC6, 0x590C6CEC, 0xEEED09C6, 0x0081FFF4,
- 0xFFE200CE, 0x06DCFDFC, 0x5A7B6BE7, 0xF01C099E, 0x008DFFF2,
- 0xFFE200CE, 0x0713FD2B, 0x5BE56ADA, 0xF1450973, 0x0097FFF0,
- 0xFFE300CD, 0x074BFC52, 0x5D4869C4, 0xF2680947, 0x00A0FFEE,
- 0xFFE300CC, 0x0781FB73, 0x5EA668A6, 0xF384091A, 0x00A8FFEC,
- 0xFFE400CA, 0x07B7FA8D, 0x5FFF6780, 0xF49908EB, 0x00B0FFEA,
- 0xFFE400C8, 0x07EDF9A0, 0x61506652, 0xF5A808BA, 0x00B6FFE9,
- 0xFFE500C5, 0x0822F8AC, 0x629B651C, 0xF6B00888, 0x00BCFFE7
-};
-
-
-const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160] =
-{
- 0x0000FFEE, 0xFFF0FFEF, 0xFFEEFFED, 0xFFEBFFEA,
- 0xFFE9FFE8, 0xFFE7FFE6, 0xFFE6FFE7, 0xFFE7FFE8,
- 0xFFEAFFED, 0xFFEFFFF3, 0xFFF7FFFB, 0x00000007,
- 0x000D0014, 0x001C0025, 0x002E0037, 0x0041004B,
- 0x00560061, 0x006B0076, 0x0080008A, 0x0094009D,
- 0x00A500AC, 0x00B200B6, 0x00B800B9, 0x00B700B3,
- 0x00AD00A3, 0x00970087, 0x0074005D, 0x00420024,
- 0x0001FFDA, 0xFFAFFF7F, 0xFF4BFF12, 0xFED5FE93,
- 0x01B301FD, 0x024C029E, 0x02F4034D, 0x03A90408,
- 0x046904CC, 0x05300595, 0x05FA065E, 0x06C10722,
- 0x078007DA, 0x08300881, 0x08CB090F, 0x094A097C,
- 0x09A409C1, 0x09D209D5, 0x09CB09B2, 0x0988094D,
- 0x090108A2, 0x082F07A8, 0x070C0659, 0x059104B1,
- 0x03B902AA, 0x01810041, 0xFEE7FD74, 0xFBE9FA45,
- 0xF887F6B2, 0xF4C4F2BF, 0xF0A4EE72, 0xEC2AE9CF,
- 0xE760E4DE, 0xE24CDFA9, 0xDCF9DA3B, 0xD772D4A0,
- 0x2E3A311B, 0x33FF36E7, 0x39CE3CB4, 0x3F964273,
- 0x45484813, 0x4AD24D84, 0x502552B4, 0x55305795,
- 0x59E35C17, 0x5E2F602B, 0x620863C4, 0x655F66D7,
- 0x682B6959, 0x6A626B43, 0x6BFC6C8C, 0x6CF46D32,
- 0x6D476D32, 0x6CF46C8C, 0x6BFC6B43, 0x6A626959,
- 0x682B66D7, 0x655F63C4, 0x6208602B, 0x5E2F5C17,
- 0x59E35795, 0x553052B4, 0x50254D84, 0x4AD24813,
- 0x45484273, 0x3F963CB4, 0x39CE36E7, 0x33FF311B,
- 0xD1C6D4A0, 0xD772DA3B, 0xDCF9DFA9, 0xE24CE4DE,
- 0xE760E9CF, 0xEC2AEE72, 0xF0A4F2BF, 0xF4C4F6B2,
- 0xF887FA45, 0xFBE9FD74, 0xFEE70041, 0x018102AA,
- 0x03B904B1, 0x05910659, 0x070C07A8, 0x082F08A2,
- 0x0901094D, 0x098809B2, 0x09CB09D5, 0x09D209C1,
- 0x09A4097C, 0x094A090F, 0x08CB0881, 0x083007DA,
- 0x07800722, 0x06C1065E, 0x05FA0595, 0x053004CC,
- 0x04690408, 0x03A9034D, 0x02F4029E, 0x024C01FD,
- 0xFE4DFE93, 0xFED5FF12, 0xFF4BFF7F, 0xFFAFFFDA,
- 0x00010024, 0x0042005D, 0x00740087, 0x009700A3,
- 0x00AD00B3, 0x00B700B9, 0x00B800B6, 0x00B200AC,
- 0x00A5009D, 0x0094008A, 0x00800076, 0x006B0061,
- 0x0056004B, 0x00410037, 0x002E0025, 0x001C0014,
- 0x000D0007, 0x0000FFFB, 0xFFF7FFF3, 0xFFEFFFED,
- 0xFFEAFFE8, 0xFFE7FFE7, 0xFFE6FFE6, 0xFFE7FFE8,
- 0xFFE9FFEA, 0xFFEBFFED, 0xFFEEFFEF, 0xFFF0FFEE
-};
-
-const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155] =
-{
-
- Qfmt27(-0.00079446133872F), Qfmt27(0.02197766364781F), Qfmt27(0.54254182141522F), Qfmt27(-0.47923775873194F),
- Qfmt27(-0.01574239605130F), Qfmt27(-0.00068946163857F), Qfmt27(0.02537571195384F), Qfmt27(0.57449847577240F),
- Qfmt27(-0.44806230039026F), Qfmt27(-0.01291535202742F), Qfmt27(-0.00071286404460F), Qfmt27(0.02892516313544F),
- Qfmt27(0.60657315615086F), Qfmt27(-0.41729436041451F), Qfmt27(-0.01026942774868F), Qfmt27(-0.00077308974337F),
- Qfmt27(0.03262310249845F), Qfmt27(0.63865835544980F), Qfmt27(-0.38701849746199F), Qfmt27(-0.00782586328859F),
- Qfmt27(-0.00083027488297F), Qfmt27(0.03646915244785F), Qfmt27(0.67068416485018F), Qfmt27(-0.35729827194706F),
- Qfmt27(-0.00557215982767F), Qfmt27(-0.00089272089703F), Qfmt27(0.04045671426315F), Qfmt27(0.70254003810627F),
- Qfmt27(-0.32819525024294F), Qfmt27(-0.00351102841332F), Qfmt27(-0.00095851011196F), Qfmt27(0.04455021764484F),
- Qfmt27(0.73415149000395F), Qfmt27(-0.29977591877185F), Qfmt27(-0.00163598204794F), Qfmt27(-0.00101225729839F),
- Qfmt27(0.04873676213679F), Qfmt27(0.76545064960593F), Qfmt27(-0.27208998714049F), Qfmt27(0.00003903936539F),
- Qfmt27(-0.00105230782648F), Qfmt27(0.05300654158217F), Qfmt27(0.79631383686511F), Qfmt27(-0.24519750285673F),
- Qfmt27(0.00154182229475F), Qfmt27(-0.00108630976316F), Qfmt27(0.05732502937107F), Qfmt27(0.82666485395476F),
- Qfmt27(-0.21914753347432F), Qfmt27(0.00286720203220F), Qfmt27(-0.00110794157381F), Qfmt27(0.06167350555855F),
- Qfmt27(0.85641712130638F), Qfmt27(-0.19396671004887F), Qfmt27(0.00402297937976F), Qfmt27(-0.00110360418081F),
- Qfmt27(0.06602157445253F), Qfmt27(0.88547343436495F), Qfmt27(-0.16971665552213F), Qfmt27(0.00500649278750F),
- Qfmt27(-0.00109714405326F), Qfmt27(0.07034096875232F), Qfmt27(0.91376152398903F), Qfmt27(-0.14641770628514F),
- Qfmt27(0.00583386287581F), Qfmt27(-0.00106490281247F), Qfmt27(0.07461825625751F), Qfmt27(0.94117890777861F),
- Qfmt27(-0.12410396326951F), Qfmt27(0.00651097277313F), Qfmt27(-0.00102041023958F), Qfmt27(0.07879625324269F),
- Qfmt27(0.96765488212662F), Qfmt27(-0.10280530739363F), Qfmt27(0.00704839655425F), Qfmt27(-0.00094051141595F),
- Qfmt27(0.08286099010631F), Qfmt27(0.99311573680798F), Qfmt27(-0.08254839941155F), Qfmt27(0.00745513427428F),
- Qfmt27(-0.00084090835475F), Qfmt27(0.08675566213219F), Qfmt27(1.01745066253324F), Qfmt27(-0.06332944781672F),
- Qfmt27(0.00774335382672F), Qfmt27(-0.00072769348801F), Qfmt27(0.09046949018457F), Qfmt27(1.04060828658052F),
- Qfmt27(-0.04518854556363F), Qfmt27(0.00790787636150F), Qfmt27(-0.00057913742435F), Qfmt27(0.09395575430420F),
- Qfmt27(1.06251808919053F), Qfmt27(-0.02811939233087F), Qfmt27(0.00797463714114F), Qfmt27(-0.00040969484059F),
- Qfmt27(0.09716267023308F), Qfmt27(1.08310018709600F), Qfmt27(-0.01212147193047F), Qfmt27(0.00795079915733F),
- Qfmt27(-0.00020454902123F), Qfmt27(0.10007381188066F), Qfmt27(1.10227871198194F), Qfmt27(0.00279527795884F),
- Qfmt27(0.00784545014643F), Qfmt27(0.00001908481202F), Qfmt27(0.10262701466139F), Qfmt27(1.12001978353403F),
- Qfmt27(0.01663452156443F), Qfmt27(0.00766458213130F), Qfmt27(0.00028892665922F), Qfmt27(0.10479373974558F),
- Qfmt27(1.13624787143434F), Qfmt27(0.02941522773279F), Qfmt27(0.00741912981120F), Qfmt27(0.00056943874774F),
- Qfmt27(0.10650970405576F), Qfmt27(1.15091404672203F), Qfmt27(0.04112872592057F), Qfmt27(0.00712664923329F),
- Qfmt27(0.00088238158168F), Qfmt27(0.10776200996423F), Qfmt27(1.16395714324633F), Qfmt27(0.05181934748033F),
- Qfmt27(0.00677868764313F), Qfmt27(0.00121741725989F), Qfmt27(0.10848340171661F), Qfmt27(1.17535833075364F),
- Qfmt27(0.06148559051724F), Qfmt27(0.00639363830229F), Qfmt27(0.00159101288509F), Qfmt27(0.10864412991640F),
- Qfmt27(1.18507099110810F), Qfmt27(0.07014197759039F), Qfmt27(0.00597707038378F), Qfmt27(0.00196610899088F),
- Qfmt27(0.10819451041273F), Qfmt27(1.19306425909871F), Qfmt27(0.07784680399703F), Qfmt27(0.00554476792518F),
- Qfmt27(0.00238550675072F), Qfmt27(0.10709920766553F), Qfmt27(1.19929775892826F), Qfmt27(0.08459352758522F),
- Qfmt27(0.00509233837916F), Qfmt27(0.00280596092809F), Qfmt27(0.10531144797543F), Qfmt27(1.20377455661175F),
- Qfmt27(0.09043115226911F), Qfmt27(0.00463008004888F), Qfmt27(0.00325513071185F), Qfmt27(0.10278145526768F),
- Qfmt27(1.20646855283790F), Qfmt27(0.09539224314440F), Qfmt27(0.00416760958657F)
-};
-
-
-
-#ifdef HQ_SBR
-
-
-const Int32 sbrDecoderFilterbankCoefficients_an_filt[155] =
-{
- Qfmt27(-0.000561769F), Qfmt27(+ 0.015540555F), Qfmt27(+ 0.383635001F), Qfmt27(-0.338872269F), Qfmt27(-0.011131555F),
- Qfmt27(-0.000487523F), Qfmt27(+ 0.017943338F), Qfmt27(+ 0.406231768F), Qfmt27(-0.316827891F), Qfmt27(-0.009132533F),
- Qfmt27(-0.000504071F), Qfmt27(+ 0.020453179F), Qfmt27(+ 0.428911992F), Qfmt27(-0.295071672F), Qfmt27(-0.007261582F),
- Qfmt27(-0.000546657F), Qfmt27(+ 0.023068017F), Qfmt27(+ 0.451599654F), Qfmt27(-0.273663404F), Qfmt27(-0.005533721F),
- Qfmt27(-0.000587093F), Qfmt27(+ 0.025787585F), Qfmt27(+ 0.474245321F), Qfmt27(-0.252648031F), Qfmt27(-0.003940112F),
- Qfmt27(-0.000631249F), Qfmt27(+ 0.028607217F), Qfmt27(+ 0.496770825F), Qfmt27(-0.232069087F), Qfmt27(-0.002482672F),
- Qfmt27(-0.000677769F), Qfmt27(+ 0.031501761F), Qfmt27(+ 0.519123497F), Qfmt27(-0.211973585F), Qfmt27(-0.001156814F),
- Qfmt27(-0.000715774F), Qfmt27(+ 0.034462095F), Qfmt27(+ 0.541255345F), Qfmt27(-0.192396675F), Qfmt27(+ 0.000027605F),
- Qfmt27(-0.000744094F), Qfmt27(+ 0.037481285F), Qfmt27(+ 0.563078914F), Qfmt27(-0.173380817F), Qfmt27(+ 0.001090233F),
- Qfmt27(-0.000768137F), Qfmt27(+ 0.040534917F), Qfmt27(+ 0.584540324F), Qfmt27(-0.154960707F), Qfmt27(+ 0.002027418F),
- Qfmt27(-0.000783433F), Qfmt27(+ 0.043609754F), Qfmt27(+ 0.605578354F), Qfmt27(-0.137155176F), Qfmt27(+ 0.002844676F),
- Qfmt27(-0.000780366F), Qfmt27(+ 0.046684303F), Qfmt27(+ 0.626124270F), Qfmt27(-0.120007798F), Qfmt27(+ 0.003540125F),
- Qfmt27(-0.000775798F), Qfmt27(+ 0.049738576F), Qfmt27(+ 0.646126970F), Qfmt27(-0.103532953F), Qfmt27(+ 0.004125164F),
- Qfmt27(-0.000753000F), Qfmt27(+ 0.052763075F), Qfmt27(+ 0.665513988F), Qfmt27(-0.087754754F), Qfmt27(+ 0.004603953F),
- Qfmt27(-0.000721539F), Qfmt27(+ 0.055717365F), Qfmt27(+ 0.684235329F), Qfmt27(-0.072694330F), Qfmt27(+ 0.004983969F),
- Qfmt27(-0.000665042F), Qfmt27(+ 0.058591568F), Qfmt27(+ 0.702238872F), Qfmt27(-0.058370533F), Qfmt27(+ 0.005271576F),
- Qfmt27(-0.000594612F), Qfmt27(+ 0.061345517F), Qfmt27(+ 0.719446263F), Qfmt27(-0.044780682F), Qfmt27(+ 0.005475378F),
- Qfmt27(-0.000514557F), Qfmt27(+ 0.063971590F), Qfmt27(+ 0.735821176F), Qfmt27(-0.031953127F), Qfmt27(+ 0.005591713F),
- Qfmt27(-0.000409512F), Qfmt27(+ 0.066436751F), Qfmt27(+ 0.751313746F), Qfmt27(-0.019883413F), Qfmt27(+ 0.005638920F),
- Qfmt27(-0.000289698F), Qfmt27(+ 0.068704383F), Qfmt27(+ 0.765867487F), Qfmt27(-0.008571175F), Qfmt27(+ 0.005622064F),
- Qfmt27(-0.000144638F), Qfmt27(+ 0.070762871F), Qfmt27(+ 0.779428752F), Qfmt27(+ 0.001976560F), Qfmt27(+ 0.005547571F),
- Qfmt27(+ 0.000013495F), Qfmt27(+ 0.072568258F), Qfmt27(+ 0.791973584F), Qfmt27(+ 0.011762383F), Qfmt27(+ 0.005419678F),
- Qfmt27(+ 0.000204302F), Qfmt27(+ 0.074100364F), Qfmt27(+ 0.803448575F), Qfmt27(+ 0.020799707F), Qfmt27(+ 0.005246117F),
- Qfmt27(+ 0.000402654F), Qfmt27(+ 0.075313734F), Qfmt27(+ 0.813819127F), Qfmt27(+ 0.029082401F), Qfmt27(+ 0.005039302F),
- Qfmt27(+ 0.000623938F), Qfmt27(+ 0.076199248F), Qfmt27(+ 0.823041989F), Qfmt27(+ 0.036641812F), Qfmt27(+ 0.004793256F),
- Qfmt27(+ 0.000860844F), Qfmt27(+ 0.076709349F), Qfmt27(+ 0.831103846F), Qfmt27(+ 0.043476878F), Qfmt27(+ 0.004520985F),
- Qfmt27(+ 0.001125016F), Qfmt27(+ 0.076823001F), Qfmt27(+ 0.837971734F), Qfmt27(+ 0.049597868F), Qfmt27(+ 0.004226427F),
- Qfmt27(+ 0.001390249F), Qfmt27(+ 0.076505072F), Qfmt27(+ 0.843623828F), Qfmt27(+ 0.055046003F), Qfmt27(+ 0.003920743F),
- Qfmt27(+ 0.001686808F), Qfmt27(+ 0.075730576F), Qfmt27(+ 0.848031578F), Qfmt27(+ 0.059816657F), Qfmt27(+ 0.003600827F),
- Qfmt27(+ 0.001984114F), Qfmt27(+ 0.074466439F), Qfmt27(+ 0.851197152F), Qfmt27(+ 0.063944481F), Qfmt27(+ 0.003273961F),
- Qfmt27(+ 0.002301725F), Qfmt27(+ 0.072677464F), Qfmt27(+ 0.853102095F), Qfmt27(+ 0.067452502F), Qfmt27(+ 0.002946945F)
-};
-
-
-
-#endif /* HQ_SBR */
-
-
-#endif /* AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h b/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h
deleted file mode 100644
index c8968cb..0000000
--- a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: qmf_filterbank_coeff.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef QMF_FILTERBANK_COEFF_H
-#define QMF_FILTERBANK_COEFF_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-#define Qfmt(x) (Int16)(x*(((Int32)1<<15)*1.11111111111111111F) + (x>=0?0.5F:-0.5F))
-
-
-#define Qfmt30(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Qfmt27(x) (Int32)(x*(((Int32)1<<27)) + (x>=0?0.5F:-0.5F))
-
-extern const Int32 sbrDecoderFilterbankCoefficients[155];
-
-
-extern const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160];
-extern const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155];
-
-#ifdef HQ_SBR
-extern const Int32 sbrDecoderFilterbankCoefficients_an_filt[155];
-#endif
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_adif_header.h b/media/libstagefright/codecs/aacdec/s_adif_header.h
deleted file mode 100644
index 7fd49d3..0000000
--- a/media/libstagefright/codecs/aacdec/s_adif_header.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_ADIF_Header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, ADIF_Header
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_ADIF_HEADER_H
-#define S_ADIF_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_adif_const.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
- Char adif_id[LEN_ADIF_ID+1];
- Int copy_id_present;
- Char copy_id[LEN_COPYRT_ID+1];
- Int original_copy;
- Int home;
- Int bitstream_type;
- Int32 bitrate;
- Int num_pce;
- Int prog_tags[(1<<LEN_TAG)];
-} ADIF_Header;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_bit_buffer.h b/media/libstagefright/codecs/aacdec/s_bit_buffer.h
deleted file mode 100644
index 9f0dbda..0000000
--- a/media/libstagefright/codecs/aacdec/s_bit_buffer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_bit_buffer.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_BIT_BUFFER_H
-#define S_BIT_BUFFER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- UChar *char_ptr;
- UInt32 buffered_bits;
- UInt32 buffer_word;
- UInt32 nrBitsRead;
- UInt32 bufferLen;
-}
-BIT_BUFFER;
-
-typedef BIT_BUFFER *HANDLE_BIT_BUFFER;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_bits.h b/media/libstagefright/codecs/aacdec/s_bits.h
deleted file mode 100644
index cae69ad..0000000
--- a/media/libstagefright/codecs/aacdec/s_bits.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_BITS.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove unused field.
-
- Description: Change buffer type from UInt to UInt32, makes API much easier
- to understand and describe, and getbits is faster on TI C55X
- if the buffer is 32 bits instead of 16.
-
- Description: Change buffer type from UInt32 to UChar.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, BITS
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_BITS_H
-#define S_BITS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-/*
- * Name: BITS
- * Description: Holds information for processing the input data buffer
- * as a "stream". The data is in packed format.
- * Fields:
- * pBuffer - pointer to the beginning of the buffer. If the data type of
- * this changes, make sure to update the constants in ibstream.h
- * usedBits - number of bits read thus far from the buffer. Bit 0 is
- * the LSB of pBuffer[0].
- * availableBits - number of bits available in the buffer.
- * byteAlignOffset - used with ADTS in case sync word is not aligned
- on a boundary.
- */
-typedef struct
-{
- UChar *pBuffer;
- UInt usedBits; /* Keep this unsigned so can go to 65536 */
- UInt availableBits; /* Ditto */
- UInt inputBufferCurrentLength; /* Ditto */
- Int byteAlignOffset; /* Used in ADTS. See find_adts_syncword() */
-} BITS;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_ch_info.h b/media/libstagefright/codecs/aacdec/s_ch_info.h
deleted file mode 100644
index 9fd259c..0000000
--- a/media/libstagefright/codecs/aacdec/s_ch_info.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Ch_Info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Ch_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_CH_INFO_H
-#define S_CH_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-// Int present; /* channel present */
- Int tag; /* element tag */
- Int cpe; /* 0 if single channel, 1 if channel pair */
-// Int common_window; /* 1 if common window for cpe */
-// Int ch_is_left; /* 1 if left channel of cpe */
-// Int paired_ch; /* index of paired channel in cpe */
-// Int widx; /* window element index for this channel */
- Int is_present; /* intensity stereo is used */
- Int ncch; /* number of coupling channels for this ch */
- /* #if (CChans > 0) */
- /* int cch[CChans];*/ /* coupling channel idx */
- /* int cc_dom[CChans];*/ /* coupling channel domain */
- /* int cc_ind[CChans];*/ /* independently switched coupling channel flag */
- /* #endif */
- Char *fext; /* filename extension */
-
-} Ch_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_crc_buffer.h b/media/libstagefright/codecs/aacdec/s_crc_buffer.h
deleted file mode 100644
index 69250e7..0000000
--- a/media/libstagefright/codecs/aacdec/s_crc_buffer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_crc_buffer.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_CRC_BUFFER_H
-#define S_CRC_BUFFER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- unsigned short crcState;
- unsigned short crcMask;
- unsigned short crcPoly;
-}
-CRC_BUFFER;
-
-typedef CRC_BUFFER *HANDLE_CRC;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_elelist.h b/media/libstagefright/codecs/aacdec/s_elelist.h
deleted file mode 100644
index 40b2f13..0000000
--- a/media/libstagefright/codecs/aacdec/s_elelist.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_EleList.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, EleList
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_ELELIST_H
-#define S_ELELIST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
- Int num_ele;
- Int ele_is_cpe[(1<<LEN_TAG)];
- Int ele_tag[(1<<LEN_TAG)];
-} EleList;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_frameinfo.h b/media/libstagefright/codecs/aacdec/s_frameinfo.h
deleted file mode 100644
index 871ae83..0000000
--- a/media/libstagefright/codecs/aacdec/s_frameinfo.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_frameinfo.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed name of bk_sfb_top to frame_sfb_top.
- Included "interface.h" for defintion of MAX_WIN. This
- will hopefully be simplified when interface.h is broken up into smaller
- include files.
-
- Description: Eliminated the never used array, group_offs[8]
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, FrameInfo
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_FRAMEINFO_H
-#define S_FRAMEINFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_blockswitching.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
- typedef struct
- {
- Int islong; /* true if long block */
- Int num_win; /* sub-blocks (SB) per block */
- Int coef_per_frame; /* coef's per block */
- Int sfb_per_frame; /* sfb per block */
- Int coef_per_win[MAX_WIN]; /* coef's per SB */
- Int sfb_per_win[MAX_WIN]; /* sfb per SB */
- Int sectbits[MAX_WIN];
- Int16 *win_sfb_top[MAX_WIN]; /* top coef per sfb per SB */
- Int *sfb_width_128; /* sfb width for short blocks */
-
- Int frame_sfb_top[MAXBANDS]; /* Only used in calc_gsfb_table() -
- it is simply a cum version of
- the above information */
- Int num_groups;
- Int group_len[8];
-
- } FrameInfo;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_FRAMEINFO_H */
diff --git a/media/libstagefright/codecs/aacdec/s_hcb.h b/media/libstagefright/codecs/aacdec/s_hcb.h
deleted file mode 100644
index 6a64c27..0000000
--- a/media/libstagefright/codecs/aacdec/s_hcb.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Hcb.h
-
- Date: 05/07/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) LAV removed from structure definition, since it was never used.
-
- Description: Huffman tables are stored as UInt16
-
- Description: Modified the declaration of the structure so no pointers are
- used in the structure.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define the structure Hcb to store Huffman codebook information,
- this structure was originally defined in all.h
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HCB_H
-#define S_HCB_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_huffman.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
- typedef struct
- {
- Int n;
- Int dim;
- Int mod;
- Int off;
- Int signed_cb;
- } Hcb;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_HCB_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_huffman.h b/media/libstagefright/codecs/aacdec/s_huffman.h
deleted file mode 100644
index 2db3dd9..0000000
--- a/media/libstagefright/codecs/aacdec/s_huffman.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Huffman.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed "ulong" to "UInt32"
-
- Description: add helper structure to speed up decode_huff_cw
-
- Description: Remove the structure definition of Huffman
-
- Description: Added definition for SBR Huffman, used for AAC plus
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Huffman
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HUFFMAN_H
-#define S_HUFFMAN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef const Char(*SbrHuffman)[2];
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_hybrid.h b/media/libstagefright/codecs/aacdec/s_hybrid.h
deleted file mode 100644
index 3880d30..0000000
--- a/media/libstagefright/codecs/aacdec/s_hybrid.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_hybrid.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HYBRID_H
-#define S_HYBRID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "ps_constants.h"
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define HYBRID_FILTER_LENGTH 13
-#define HYBRID_FILTER_LENGTH_m_1 12
-#define HYBRID_FILTER_DELAY 6
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-
- HYBRID_2_REAL = 2,
- HYBRID_4_CPLX = 4,
- HYBRID_8_CPLX = 8
-
-} HYBRID_RES;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int32 nQmfBands;
- Int32 *pResolution;
- Int32 qmfBufferMove;
-
- Int32 **mQmfBufferReal;
- Int32 **mQmfBufferImag;
- Int32 *mTempReal;
- Int32 *mTempImag;
-
-
-} HYBRID;
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-
-#endif /* S_HYBRID_H */
diff --git a/media/libstagefright/codecs/aacdec/s_lt_pred_status.h b/media/libstagefright/codecs/aacdec/s_lt_pred_status.h
deleted file mode 100644
index 4b5b56e..0000000
--- a/media/libstagefright/codecs/aacdec/s_lt_pred_status.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: LT_PRED_STATUS.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Merged in #defines from ltp_common.h, thereby eliminating that file.
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description: Moved large ltp_buffer up to s_tDec_Int_Chan.h, since this
- move allowed for other elements in this structure to be shared with
- the fxpCoef array.
-
- Description: Decreased size of LTP buffers from 4096 to 3072. The upper 1024
- elements in the LTP buffers were never touched in the code. This saves
- 4 kilobytes in memory.
-
- Description: Decreased size of LTP buffers again from 3072 to 2048. This
- time, I realized that 1024 elements were duplicated in the 32-bit array
- pVars->pChVars[]->time_quant. Rather than copy this data EVERY frame
- from a 32-bit to a 16-bit LTP buffer, the data is accessed only
- when it is needed. This saves both MIPS and memory.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define LT_PRED_STATUS structure for pulse data decoding.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_LT_PRED_STATUS_H
-#define S_LT_PRED_STATUS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_blockswitching.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
- /*
- Macro: MAX_SHORT_WINDOWS
- Purpose: Number of short windows in one long window.
- Explanation: - */
-#ifndef MAX_SHORT_WINDOWS
-#define MAX_SHORT_WINDOWS NSHORT
-#endif
-
- /*
- Macro: MAX_SCFAC_BANDS
- Purpose: Maximum number of scalefactor bands in one frame.
- Explanation: - */
-#ifndef MAX_SCFAC_BANDS
-#define MAX_SCFAC_BANDS MAXBANDS
-#endif
-
- /*
- Macro: BLOCK_LEN_LONG
- Purpose: Length of one long window
- Explanation: - */
-#ifndef BLOCK_LEN_LONG
-#define BLOCK_LEN_LONG LN2
-#endif
-
-
- /*
- Macro: LTP_MAX_BLOCK_LEN_LONG
- Purpose: Informs the routine of the maximum block size used.
- Explanation: This is needed since the TwinVQ long window
- is different from the AAC long window. */
-#define LTP_MAX_BLOCK_LEN_LONG BLOCK_LEN_LONG //(2 * BLOCK_LEN_LONG)
-
- /*
- Macro: LT_BLEN
- Purpose: Length of the history buffer.
- Explanation: Has to hold 2 long windows of time domain data. */
-#ifndef LT_BLEN
-#define LT_BLEN (2 * LTP_MAX_BLOCK_LEN_LONG)
-#endif
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
- /*
- Type: LT_PRED_STATUS
- Purpose: Type of the struct holding the LTP encoding parameters.
- Explanation: - */
- typedef struct
- {
- Int weight_index;
- Int win_prediction_used[MAX_SHORT_WINDOWS];
- Int sfb_prediction_used[MAX_SCFAC_BANDS];
- Bool ltp_data_present;
-
- Int delay[MAX_SHORT_WINDOWS];
- }
- LT_PRED_STATUS;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_LT_PRED_STATUS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_mc_info.h b/media/libstagefright/codecs/aacdec/s_mc_info.h
deleted file mode 100644
index 9006119..0000000
--- a/media/libstagefright/codecs/aacdec/s_mc_info.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_MC_Info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, MC_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_MC_INFO_H
-#define S_MC_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-#include "s_ch_info.h"
-#include "chans.h"
-#include "e_tmp4audioobjecttype.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
- Int nch; /* total number of audio channels */
- Int nfsce; /* number of front SCE's pror to first front CPE */
- Int nfch; /* number of front channels */
- Int nsch; /* number of side channels */
- Int nbch; /* number of back channels */
- Int nlch; /* number of lfe channels */
- Int ncch; /* number of valid coupling channels */
- tMP4AudioObjectType audioObjectType; /* Should eventually be called object */
- Int sampling_rate_idx;
-
- Int implicit_channeling;
- Int upsamplingFactor;
-#ifdef AAC_PLUS
- bool bDownSampledSbr;
- Int HE_AAC_level;
-#endif
- /* All AAC content should be aware of these flag */
- /* AAC+ content Flag */
- Int sbrPresentFlag;
- /* Enhanced AAC+ content Flag */
- Int psPresentFlag;
- tMP4AudioObjectType ExtendedAudioObjectType; /* Should eventually be called object */
-
- Ch_Info ch_info[Chans];
-} MC_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_mixdown.h b/media/libstagefright/codecs/aacdec/s_mixdown.h
deleted file mode 100644
index 7f456d5..0000000
--- a/media/libstagefright/codecs/aacdec/s_mixdown.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_MIXdown.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, MIXdown
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_MIXDOWN_H
-#define S_MIXDOWN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int present;
- Int ele_tag;
- Int pseudo_enab;
-} MIXdown;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_patch.h b/media/libstagefright/codecs/aacdec/s_patch.h
deleted file mode 100644
index 554fc2d..0000000
--- a/media/libstagefright/codecs/aacdec/s_patch.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_patch.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PATCH_H
-#define S_PATCH_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_NUM_PATCHES 6
-
-#define SBR_NUM_COLUMNS 38
-#define SBR_NUM_BANDS 48
-#define SBR_NUM_BANDS_OVR_4 (SBR_NUM_BANDS>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-struct PATCH
-{
- Int32 noOfPatches;
- Int32 targetStartBand[MAX_NUM_PATCHES];
-};
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_progconfig.h b/media/libstagefright/codecs/aacdec/s_progconfig.h
deleted file mode 100644
index e58e5fc..0000000
--- a/media/libstagefright/codecs/aacdec/s_progconfig.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_ProgConfig.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, ProgConfig
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PROGCONFIG_H
-#define S_PROGCONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_mixdown.h"
-#include "s_elelist.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int profile;
- Int sampling_rate_idx;
- EleList front;
- EleList side;
- EleList back;
- EleList lfe;
- EleList data;
- EleList coupling;
- MIXdown mono_mix;
- MIXdown stereo_mix;
- MIXdown matrix_mix;
-
- Char comments[(1<<LEN_PC_COMM)+1]; /* TO BE DELETED */
-
- Int32 buffer_fullness; /* put this transport level info here */
- Bool file_is_adts; /* For ADTS use only */
- Int32 headerless_frames; /* For ADTS use only */
- Int32 frame_length; /* For use by ADTS only */
- Int32 CRC_absent; /* For use by ADTS only */
- UInt32 CRC_check; /* For use by ADTS only */
-
-} ProgConfig;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_ps_dec.h b/media/libstagefright/codecs/aacdec/s_ps_dec.h
deleted file mode 100644
index 8b4391c..0000000
--- a/media/libstagefright/codecs/aacdec/s_ps_dec.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/****************************************************************************
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-*******************************************************************************/
-
-#ifndef S_PS_DEC_H
-#define S_PS_DEC_H
-
-
-#include "s_hybrid.h"
-#include "s_patch.h"
-
-/****************************************************************
- Type definitions
- ****************************************************************/
-struct PS_DEC
-{
-
- Int psDetected;
- Int32 *R_ch_qmf_filter_history;
- Int32 invNoSubSamples;
-
- Int32 bForceMono;
- UInt32 noSubSamples;
- Int32 usb;
- Int32 lastUsb;
-
- Int32 bPsDataAvail;
-
- UInt32 bEnableIid;
- UInt32 bEnableIcc;
-
- UInt32 bEnableExt;
- Int32 bFineIidQ;
-
- Int32 aIidPrevFrameIndex[NO_HI_RES_BINS];
- Int32 aIccPrevFrameIndex[NO_HI_RES_BINS];
-
- UInt32 freqResIid;
- UInt32 freqResIcc;
-
- UInt32 bFrameClass;
- UInt32 noEnv;
- UInt32 aEnvStartStop[MAX_NO_PS_ENV+1];
-
- UInt32 abIidDtFlag[MAX_NO_PS_ENV];
- UInt32 abIccDtFlag[MAX_NO_PS_ENV];
-
- Int32 delayBufIndex;
-
- UInt32 aDelayRBufIndexSer[NO_SERIAL_ALLPASS_LINKS];
-
- Int32 **aaaRealDelayRBufferSerQmf[NO_SERIAL_ALLPASS_LINKS];
- Int32 **aaaImagDelayRBufferSerQmf[NO_SERIAL_ALLPASS_LINKS];
-
- Int32 **aaaRealDelayRBufferSerSubQmf[NO_SERIAL_ALLPASS_LINKS];
- Int32 **aaaImagDelayRBufferSerSubQmf[NO_SERIAL_ALLPASS_LINKS];
-
- Int32 **aaRealDelayBufferQmf;
- Int32 **aaImagDelayBufferQmf;
- Int32 **aaRealDelayBufferSubQmf;
- Int32 **aaImagDelayBufferSubQmf;
-
- Int32 *aPeakDecayFast;
- Int32 *aPrevNrg;
- Int32 *aPrevPeakDiff;
-
- Int32 *mHybridRealLeft;
- Int32 *mHybridImagLeft;
- Int32 *mHybridRealRight;
- Int32 *mHybridImagRight;
-
-
- HYBRID *hHybrid;
-
-
-
- Int32 h11Prev[NO_IID_GROUPS];
- Int32 h12Prev[NO_IID_GROUPS];
- Int32 h21Prev[NO_IID_GROUPS];
- Int32 h22Prev[NO_IID_GROUPS];
-
- Int32 H11[NO_IID_GROUPS];
- Int32 H12[NO_IID_GROUPS];
- Int32 H21[NO_IID_GROUPS];
- Int32 H22[NO_IID_GROUPS];
-
- Int32 deltaH11[NO_IID_GROUPS];
- Int32 deltaH12[NO_IID_GROUPS];
- Int32 deltaH21[NO_IID_GROUPS];
- Int32 deltaH22[NO_IID_GROUPS];
-
- Int32(*qmfBufferReal)[64];
- Int32(*qmfBufferImag)[64];
-
- Int32 aDelayBufIndex[NO_DELAY_CHANNELS];
- Int32 aNoSampleDelay[NO_DELAY_CHANNELS]; /////
- Int32 aaIidIndex[MAX_NO_PS_ENV+1][NO_HI_RES_BINS];
- Int32 aaIccIndex[MAX_NO_PS_ENV+1][NO_HI_RES_BINS];
-
-};
-
-typedef struct PS_DEC STRUCT_PS_DEC;
-typedef struct PS_DEC * HANDLE_PS_DEC;
-
-
-
-#endif /* E_PS_DEC_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_pulseinfo.h b/media/libstagefright/codecs/aacdec/s_pulseinfo.h
deleted file mode 100644
index a7ced04..0000000
--- a/media/libstagefright/codecs/aacdec/s_pulseinfo.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_PulseInfo.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Comment out unused field.
-
- Description: Fix ARM warnings, update copyright.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define PulseInfo structure for pulse data decoding.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PULSEINFO_H
-#define S_PULSEINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int pulse_data_present;
- Int number_pulse;
- Int pulse_start_sfb;
- Int pulse_offset[NUM_PULSE_LINES];
- Int pulse_amp[NUM_PULSE_LINES];
-} PulseInfo;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_channel.h b/media/libstagefright/codecs/aacdec/s_sbr_channel.h
deleted file mode 100644
index 99e28dd..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_channel.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_channel.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_CHANNEL_H
-#define S_SBR_CHANNEL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "s_sbr_frame_data.h"
-#include "e_sbr_sync_state.h"
-
-#ifdef PARAMETRICSTEREO
-#include "s_ps_dec.h"
-
-#endif
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAXNRELEMENTS 1
-#define MAXNRSBRCHANNELS (MAXNRELEMENTS*2)
-
-#ifdef PARAMETRICSTEREO
-#define MAXNRQMFCHANNELS MAXNRSBRCHANNELS
-#else
-#define MAXNRQMFCHANNELS MAXNRSBRCHANNELS
-#endif
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int32 outFrameSize;
- SBR_SYNC_STATE syncState;
- SBR_FRAME_DATA frameData;
-
-} SBR_CHANNEL;
-
-typedef struct
-{
- SBR_CHANNEL SbrChannel[MAXNRSBRCHANNELS];
- Int32 setStreamType;
-#ifdef PARAMETRICSTEREO
- HANDLE_PS_DEC hParametricStereoDec;
- STRUCT_PS_DEC ParametricStereoDec;
-#endif
-
-} SBRDECODER_DATA;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_dec.h b/media/libstagefright/codecs/aacdec/s_sbr_dec.h
deleted file mode 100644
index 810479c..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_dec.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_dec.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_DEC_H
-#define S_SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "s_sbr_frame_data.h"
-#include "pv_audio_type_defs.h"
-#include "s_patch.h"
-#include "e_blockswitching.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int32 outSampleRate;
- Int32 LC_aacP_DecoderFlag; /* Low Complexity decoder flag */
-
- Int32 startIndexCodecQmf;
- Int32 lowBandAddSamples;
- Int32 noCols;
- Int32 qmfBufLen;
- Int32 bufWriteOffs;
- Int32 bufReadOffs;
-
- Int32 sbStopCodec;
- Int lowSubband;
- Int prevLowSubband;
- Int32 highSubband;
- Int32 noSubbands;
-
- Int FreqBandTable[2][MAX_FREQ_COEFFS + 1];
- Int32 FreqBandTableNoise[MAX_NOISE_COEFFS + 1];
- Int32 V_k_master[MAX_FREQ_COEFFS + 1]; /* Master BandTable which freqBandTable is derived from*/
- Int32 NSfb[2];
- Int32 NoNoiseBands; /* Number of noisebands */
- Int32 Num_Master; /* Number of bands in V_k_master*/
-
- struct PATCH Patch; /* Used by sbr_generate_high_freq */
- /* Used by calc_sbr_envelope */
- Int32 gateMode[4];
- Int32 limSbc[4][12 + 1]; /* Limiting bands */
-
- Int32 sqrt_cache[8][4]; /* cache memory for repeated sqrt() calculations */
-
-} SBR_DEC;
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h b/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h
deleted file mode 100644
index e9b6780..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_element_stream.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_ELEMENT_STREAM_H
-#define S_SBR_ELEMENT_STREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define MAXSBRBYTES 1024
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
- Int32 ElementID;
- Int32 ExtensionType;
- Int32 Payload;
- UChar Data[MAXSBRBYTES];
-}
-SBR_ELEMENT_STREAM;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h b/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h
deleted file mode 100644
index 89d1bb1..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_frame_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_FRAME_DATA_H
-#define S_SBR_FRAME_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sbr_header_data.h"
-#include "e_invf_mode.h"
-#include "e_coupling_mode.h"
-#include "sbr_constants.h"
-#include "s_patch.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int32 nScaleFactors; /* total number of scalefactors in frame */
- Int32 nNoiseFactors;
- Int32 crcCheckSum;
- Int32 frameClass;
- Int32 frameInfo[LENGTH_FRAME_INFO];
- Int32 nSfb[2];
- Int32 nNfb;
- Int32 offset;
- Int32 ampRes;
- Int32 nNoiseFloorEnvelopes;
- Int32 p;
- Int32 prevEnvIsShort;
-
- Int32 reset_flag;
-
-
- SBR_HEADER_DATA sbr_header;
-
-
- /* dynamic control signals */
- Int32 domain_vec1[MAX_ENVELOPES];
- Int32 domain_vec2[MAX_ENVELOPES];
-
-
- INVF_MODE sbr_invf_mode[MAX_NUM_NOISE_VALUES];
- INVF_MODE sbr_invf_mode_prev[MAX_NUM_NOISE_VALUES];
-
- COUPLING_MODE coupling; /* 3 possibilities: off, level, pan */
-
-
- Int32 addHarmonics[MAX_NUM_ENVELOPE_VALUES];
-
- /* Used by calc_sbr_envelope */
- Int32 hFp[64];
- Int32 harm_index;
- Int32 phase_index;
- Int32 sUp;
-
- /*
- * envelope data
- */
-
- Int32 iEnvelope_man[MAX_NUM_ENVELOPE_VALUES]; /* mantissa */
- Int32 iEnvelope_exp[MAX_NUM_ENVELOPE_VALUES]; /* exponent */
- Int32 sfb_nrg_prev_man[MAX_FREQ_COEFFS]; /* mantissa */
-
-
- /*
- * noise data
- */
-
- Int32 sbrNoiseFloorLevel_man[MAX_NUM_NOISE_VALUES]; /* mantissa */
- Int32 sbrNoiseFloorLevel_exp[MAX_NUM_NOISE_VALUES]; /* exponent */
- Int32 prevNoiseLevel_man[MAX_NUM_NOISE_VALUES]; /* mantissa */
-
- Int32 BwVector[MAX_NUM_PATCHES];
- Int32 BwVectorOld[MAX_NUM_PATCHES];
- /* Both implement a pseudo circular buffer */
-
- /*
- * 40 == Biggest of autoCorrLength(38) + sbrDec->bufReadOffs (2) and
- * sbrDec->noCols (32) + sbrDec->bufWriteOffs (6)
- */
- Int32 codecQmfBufferReal[40][32];
- Int32 *sbrQmfBufferReal;
- Int32 HistsbrQmfBufferReal[6*SBR_NUM_BANDS];
-#ifdef HQ_SBR
- Int32 codecQmfBufferImag[40][32];
- Int32 *sbrQmfBufferImag;
- Int32 HistsbrQmfBufferImag[6*SBR_NUM_BANDS];
-#endif
- Int16 V[1152]; /* Used by calc_sbr_synfilterbank as freq. history buffer */
-
-
- Int32 degreeAlias[64];
-
-
-#ifdef HQ_SBR
-
- Int32 fBuffer_man[5][64]; /* smoothing history buffers */
- Int32 fBufferN_man[5][64];
- Int32 fBuffer_exp[5][64]; /* smoothing history buffers */
- Int32 fBufferN_exp[5][64];
-
- Int32 *fBuf_man[64]; /* pointer to smoothing history buffers */
- Int32 *fBuf_exp[64]; /* pointer to smoothing history buffers */
- Int32 *fBufN_man[64];
- Int32 *fBufN_exp[64];
-
-
-#endif
-
-}
-SBR_FRAME_DATA;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_header_data.h b/media/libstagefright/codecs/aacdec/s_sbr_header_data.h
deleted file mode 100644
index 7d7d746..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_header_data.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_header_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_HEADER_DATA_H
-#define S_SBR_HEADER_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_sbr_header_status.h"
-#include "e_sbr_master_status.h"
-#include "e_sr_mode.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- SBR_HEADER_STATUS status; /* the current status of the header */
- SBR_MASTER_STATUS masterStatus;/* status of v_k_master freq table */
-
- /* Changes in these variables indicates an error */
- Int32 crcEnable;
- SR_MODE sampleRateMode;
- Int32 ampResolution;
-
- /* Changes in these variables causes a reset of the decoder */
- Int32 startFreq;
- Int32 stopFreq;
- Int32 xover_band;
- Int32 freqScale;
- Int32 alterScale;
- Int32 noise_bands; /* noise bands per octave, read from bitstream */
-
- /* Helper variable*/
- Int32 noNoiseBands; /* actual number of noise bands to read from the bitstream */
-
- Int32 limiterBands;
- Int32 limiterGains;
- Int32 interpolFreq;
- Int32 smoothingLength;
-}
-SBR_HEADER_DATA;
-
-typedef SBR_HEADER_DATA *HANDLE_SBR_HEADER_DATA;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbrbitstream.h b/media/libstagefright/codecs/aacdec/s_sbrbitstream.h
deleted file mode 100644
index 609463a..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbrbitstream.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbrbitstream.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBRBITSTREAM_H
-#define S_SBRBITSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "s_sbr_element_stream.h"
-#include "s_sbr_channel.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
- Int32 NrElements;
- Int32 NrElementsCore;
- SBR_ELEMENT_STREAM sbrElement[MAXNRELEMENTS];
-}
-SBRBITSTREAM;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sectinfo.h b/media/libstagefright/codecs/aacdec/s_sectinfo.h
deleted file mode 100644
index 83dcc31..0000000
--- a/media/libstagefright/codecs/aacdec/s_sectinfo.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/s_SectInfo.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- defines a structre that holds the Huffman codebook index and section
- boundary information for each Frame.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SECTINFO_H
-#define S_SECTINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int sect_cb;
- Int sect_end;
-} SectInfo;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sr_info.h b/media/libstagefright/codecs/aacdec/s_sr_info.h
deleted file mode 100644
index 9b71003..0000000
--- a/media/libstagefright/codecs/aacdec/s_sr_info.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_SR_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified the declaration of the structure so no pointers are
- used in the structure.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, SR_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SR_INFO_H
-#define S_SR_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int32 samp_rate;
- Int nsfb1024;
- Int nsfb128;
-} SR_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h b/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h
deleted file mode 100644
index f7a3602..0000000
--- a/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_tDec_Int_Chan.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change data types of win
-
- Description: Remove wnd_shape structure.
-
- Description: Remove dependency on window_block.h, Fix header too.
-
- Description:
- Modified to utilize memory in the last 1024 elements in fxpCoef.
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) Move temporary FrameInfo structure into the shared region with fxpCoef.
- (2) Add more comments detailing the size of the shared structure.
-
- Description:
- (1) Changed time_quant from 2048 Int32 buffer to 1024 Int32 buffer.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, tDec_Int_Chan
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TDEC_INT_CHAN_H
-#define S_TDEC_INT_CHAN_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-#include "s_tns_frame_info.h"
-#include "s_wnd_shape.h"
-#include "s_lt_pred_status.h"
-#include "s_sectinfo.h"
-#include "s_frameinfo.h"
-#include "e_window_shape.h"
-#include "e_window_sequence.h"
-#include "window_block_fxp.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /* This structure was created with the specific goal in mind of sharing memory
- * with the last 1024 data elements in fxpCoef.
- *
- * The size of this structure must NOT exceed 4 kilobytes
- * Also, the size of the fxpCoef array cannot be less than 8 kilobytes
- *
- * The fxpCoef array is declared as an Int32, so its size should not vary
- * from platform to platform.
- *
- * The shared structure is 3,640 bytes (3.55 KB), on a 32-bit platform,
- * which represents the worst case.
- */
- typedef struct
- {
- TNS_frame_info tns;
-
- FrameInfo frameInfo;
-
- Int factors[MAXBANDS];
- Int cb_map[MAXBANDS];
- Int group[NSHORT];
- Int qFormat[MAXBANDS];
-
- Int max_sfb;
- LT_PRED_STATUS lt_status;
-
- } per_chan_share_w_fxpCoef;
-
- /*
- * This structure contains one per channel.
- */
- typedef struct
- {
-#ifdef AAC_PLUS
- Int16 ltp_buffer[LT_BLEN + 2*288]; /* LT_BLEN = 2048 + 2*288 */
-#else
- Int16 ltp_buffer[LT_BLEN]; /* LT_BLEN = 2048 */
-#endif
-
-
- Int32 time_quant[LONG_WINDOW]; /* 1024 holds overlap&add */
-
- Int32 *fxpCoef; /* Spectrum coeff.*/
-
- per_chan_share_w_fxpCoef * pShareWfxpCoef;
-
- Int32 abs_max_per_window[NUM_SHORT_WINDOWS];
-
- WINDOW_SEQUENCE wnd;
-
-
- WINDOW_SHAPE wnd_shape_prev_bk;
- WINDOW_SHAPE wnd_shape_this_bk;
-
- } tDec_Int_Chan;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TDEC_INT_CHAN_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_tdec_int_file.h b/media/libstagefright/codecs/aacdec/s_tdec_int_file.h
deleted file mode 100644
index d0ffb0b..0000000
--- a/media/libstagefright/codecs/aacdec/s_tdec_int_file.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_tDec_Int_File.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove unneeded structure elements, clean up.
-
- Description: Remove block.h, not needed, chains in other not needed files.
-
- Description: Added declaration of scratch memory, scratchTnsDecCoefMem,
- which will be utilized by tns_decode_coef().
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description: Per review comments...
- (1) Removed declaration of unused variable, savedMCInfo
- (2) Commented out ADTS related variables.
- (3) Slight re-wording of comment for clarity.
-
- Description:
- (1) Moved scratch_prog_config into the scratch union.
-
- Description:
- (1) Added ltp state variable.
-
- Description: Make tDec_Int_perChan an array of structures.
- In the user applications, the malloc command will allocate a
- continuous chunk of memory.
-
- Description:
- (1) Added the array data_stream_bytes[] to structure tDec_Int_File.
- This to support Data Streaming Elements (DSE).
- (2) Updated the copyright header.
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, tDec_Int_Chan
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TDEC_INT_FILE_H
-#define S_TDEC_INT_FILE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_progconfig.h"
-#include "s_frameinfo.h"
-#include "s_mc_info.h"
-#include "s_adif_header.h"
-#include "s_tdec_int_chan.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-#include "s_hcb.h"
-#include "e_infoinitconst.h"
-
-#include "s_sbr_channel.h"
-#include "s_sbr_dec.h"
-#include "s_sbrbitstream.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
-
-
-
- /*
- * Note: most of the names of the variables put into this structure were kept
- * the same because the name is also used in called functions.
- *
- * bno - block number
- *
- */
- typedef struct
- {
- UInt32 bno;
- Int status; /* save the status */
-
- bool aacPlusEnabled;
- bool aacConfigUtilityEnabled;
-
- Int current_program;
- Int frameLength;
- Int adif_test;
-
- BITS inputStream;
-
- ProgConfig prog_config;
-
- Int SFBWidth128[(1<<LEN_MAX_SFBS)];
-
- /*
- * One of the two arrays should be deleted in the final version.
- */
- FrameInfo longFrameInfo;
- FrameInfo shortFrameInfo;
- FrameInfo *winmap[NUM_WIN_SEQ];
-
- /*
- * Pns variables.
- */
- Int32 pns_cur_noise_state;
-
- /*
- *
- */
- MC_Info mc_info;
-
- Int ltp_buffer_state;
-
- /*
- * For eaac+, a scratch matrix is created with the rigth element ( perChan[1] is not used)
- * and the fxpCoef matrix. These 2 matrices are [2][38][64] == 4864 Int32
- * 2349 coming from the perChan[1] plus 4096 coming from fxpCoef
- */
- tDec_Int_Chan perChan[Chans];
-
- Int32 fxpCoef[2][LN]; /* LN = 2048 */
-
-
-
-#ifdef AAC_PLUS
-
- SBRDECODER_DATA sbrDecoderData;/* allocates 2 SBR_CHANNEL, each has a SBR_FRAME_DATA */
- SBR_DEC sbrDec;
- SBRBITSTREAM sbrBitStr;
-
-#endif
-
-
- /*
- * If ADTS support is needed, the following variables will
- * be required.
- */
- UInt32 syncword;
- Int invoke;
-
- Int mask[MAXBANDS];
- Int hasmask;
-
-
- /* SBR usage
- * These two unions are used for the SBR tool and used
- * as a single 2560 int32 continuous memory for circular
- * buffering the synthesis QMF's bank history
- */
-
- /* This union specifies memory for arrays which are used
- * by only one function. This is the simplest type of scratch
- * memory to implement, since there are no worries about
- * function interaction.
- */
- union scratch_memory
- {
- Int32 fft[LONG_WINDOW]; /* 1024, as needed by the FFT */
- Int32 tns_inv_filter[TNS_MAX_ORDER];
- Int32 tns_decode_coef[2*TNS_MAX_ORDER];
- Int huffbook_used[248];
- Int16 tmp_spec[LN2]; /* Used in conjunction with quant_spec */
-
- ADIF_Header adif_header;
-
- ProgConfig scratch_prog_config;
-
-
- Int32 scratch_mem[16][64];
- } scratch;
-
- /* This union tries to take advantage of the fact that
- * some variables are only used before LTP, and
- * the long array, predictedSamples, is only used after LTP.
- */
-
- /*
- * also used by the circular buffer scheme on aac+ (needs 4096 + 1152)
- * from scratch_mem[2] + 5248 (uses most of shared_memory).
- * For eaac+, shared memory is used by sbrQmfBufferReal which needs
- * 1824 bytes
- */
- union shared_memory
- {
- Int32 predictedSamples[LONG_BLOCK1]; /* 2048 Int32 */
-
- Char data_stream_bytes[(1<<LEN_D_CNT)+1];
-
- struct
- {
- Int16 quantSpec[LN2];
- SectInfo sect[MAXBANDS + 1];
- PulseInfo pulseInfo;
- } a;
-
- } share;
-
-
- } tDec_Int_File;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TDEC_INT_FILE_H */
diff --git a/media/libstagefright/codecs/aacdec/s_tns_frame_info.h b/media/libstagefright/codecs/aacdec/s_tns_frame_info.h
deleted file mode 100644
index 61af0ac..0000000
--- a/media/libstagefright/codecs/aacdec/s_tns_frame_info.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_TNS_frame_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified to eliminate triple-nested structure, which wasted
- 2 KB of memory.
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) Changed hard coded size of arrays from "8" to "TNS_MAX_WIN"
- (2) Moved elements from s_TNSinfo.h up to the level of TNS_frame_info
- (3) Added Bool "tns_data_present" for future use.
- (4) Moved lpc_coef up from s_TNSfilt.h (allowed for use of smaller array.)
-
- Description:
- (1) Removed the array "coef_res", which is now a local variable on the
- stack inside get_tns.c
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, s_TNS_frame_info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TNS_FRAME_INFO_H
-#define S_TNS_FRAME_INFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "s_tnsfilt.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
- typedef struct
- {
- Bool tns_data_present;
-
- /* Information about the number of filters for each window. */
- Int n_filt[TNS_MAX_WIN];
-
- /*
- * Filter Information
- *
- * For short windows, there is a maximum of
- * 1 filter per window (8 total)
- *
- * For long windows, there is a maximum of 3 filters
- *
- */
- TNSfilt filt[TNS_MAX_WIN];
-
- /*
- * For short windows, there is a maximum of 8 filters,
- * each of order 7 (requring 56 Ints)
- *
- * For long windows, there is a maximum of 3 filters,
- * each of order 20 (requiring 60 Ints)
- *
- * So, 3*TNS_MAX_ORDER declares an array of sufficient
- * size (60) for both cases.
- */
- Int32 lpc_coef[3*TNS_MAX_ORDER];
-
- } TNS_frame_info;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TNS_FRAME_INFO_H */
diff --git a/media/libstagefright/codecs/aacdec/s_tnsfilt.h b/media/libstagefright/codecs/aacdec/s_tnsfilt.h
deleted file mode 100644
index c1d78af..0000000
--- a/media/libstagefright/codecs/aacdec/s_tnsfilt.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_TNSfilt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Added lpc, start, & size, so the data from
- tns_inv_subblock can be shared with tns_decode_subblock.
-
- Description: Removed lpc to save 2KB of memory (on 32-bit machines.)
- This change requires tns_decode_coef.c to perform calculations in place.
-
- Description: Removed start & size. start_band and stop_band can simply
- take on a new meaning after this function. (coef index, rather than
- scalefactor band index.)
-
- Description: Had to add "start_coef" and "stop_coef" in order to preserve
- values "start_band" and "stop_band." This required a change to
- tns_setup_filter.c also.
-
- Description: Had to add element "q_lpc" to store the q-format of the lpc
- coefficients passed via "coef."
-
- Description: Moved lpc_coef array up to the s_TNS_frame_info.h structure.
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, s_TNSfilt
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TNSFILT_H
-#define S_TNSFILT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- typedef struct
- {
- Int start_band;
- Int stop_band;
- Int start_coef;
- Int stop_coef;
- UInt order;
- Int direction;
- Int q_lpc;
-
- } TNSfilt;
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TNSFILT_H */
diff --git a/media/libstagefright/codecs/aacdec/s_wnd_shape.h b/media/libstagefright/codecs/aacdec/s_wnd_shape.h
deleted file mode 100644
index c8a05c8..0000000
--- a/media/libstagefright/codecs/aacdec/s_wnd_shape.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Wnd_Shape.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change data type to Int
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Wnd_Shape
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_WND_SHAPE_H
-#define S_WND_SHAPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
- Int this_bk;
- Int prev_bk;
-} Wnd_Shape;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp b/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp
deleted file mode 100644
index efbab7d..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_aliasing_reduction.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-
-#include "sbr_aliasing_reduction.h"
-#include "pv_sqrt.h"
-
-#include "aac_mem_funcs.h"
-
-#include "pv_div.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Q30fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#include "pv_normalize.h"
-#include "sbr_constants.h"
-
-/*******************************************************************************
- Functionname: sbr_aliasing_reduction
- *******************************************************************************
- Description:
- Arguments:
-
- Return: none
-*******************************************************************************/
-void sbr_aliasing_reduction(Int32 *degreeAlias,
- Int32 * nrg_gain_man,
- Int32 * nrg_gain_exp,
- Int32 * nrg_est_man,
- Int32 * nrg_est_exp,
- Int32 * dontUseTheseGainValues,
- Int32 noSubbands,
- Int32 lowSubband,
- Int32 sqrt_cache[][4],
- Int32 * groupVector)
-{
-
- Int32 temp1;
- Int32 est_total;
- Int32 ref_total_man;
- Int32 ref_total_exp;
- Int32 tmp_q1;
- Int32 tmp_q2;
- Int32 tmp_q3;
- Int32 tmp_q4;
- Int32 bst_man;
- Int32 bst_exp;
- struct intg_div quotient;
- struct intg_sqrt root_sq;
- Int32 group;
- Int32 grouping = 0;
- Int32 index = 0;
- Int32 noGroups;
- Int32 k;
-
-
- /* Calculate grouping*/
- for (k = 0; k < noSubbands - 1; k++)
- {
- if (degreeAlias[k + lowSubband + 1] && dontUseTheseGainValues[k] == 0)
- {
- if (grouping == 0)
- {
- groupVector[index] = k + lowSubband;
- grouping = 1;
- index++;
- }
- }
- else
- {
- if (grouping)
- {
- groupVector[index] = k + lowSubband;
-
- if (! dontUseTheseGainValues[k])
- {
- (groupVector[index])++;
- }
- grouping = 0;
- index++;
- }
- }
- }
-
- if (grouping)
- {
- groupVector[index] = noSubbands + lowSubband;
- index++;
- }
- noGroups = (index >> 1);
-
-
-
- /*Calculate new gain*/
- for (group = 0; group < noGroups; group ++)
- {
-
- int startGroup = groupVector[(group<<1)] - lowSubband;
- int stopGroup = groupVector[(group<<1)+1] - lowSubband;
-
-
- est_total = 0;
- ref_total_man = 0;
-
- tmp_q1 = -100;
- tmp_q2 = -100;
-
- for (k = startGroup; k < stopGroup; k++)
- {
- if (tmp_q1 < nrg_est_exp[k])
- {
- tmp_q1 = nrg_est_exp[k]; /* max */
- }
- if (tmp_q2 < (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)))
- {
- tmp_q2 = (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)); /* max */
- }
- }
-
-
- k -= startGroup; /* number of element used in the addition */
- /* adjust Q format */
- tmp_q2 += 59 - pv_normalize(k);
-
- for (k = startGroup; k < stopGroup; k++)
- {
- /*
- * est_total += nrg_est[k]
- * ref_total += nrg_est[k]*nrg_gain[k]*nrg_gain[k
- */
- est_total += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]);
-
- if (tmp_q2 - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 60)
- {
- nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]);
- nrg_gain_exp[k] = (nrg_gain_exp[k] << 1) + 28;
- tmp_q3 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]);
- ref_total_man += tmp_q3 >> (tmp_q2 - (nrg_est_exp[k] + nrg_gain_exp[k]));
- }
- }
-
- ref_total_exp = tmp_q2 + 28;
-
- pv_div(ref_total_man, est_total, &quotient);
-
- tmp_q2 += - tmp_q1 - quotient.shift_factor - 2;
-
-
-
- for (k = startGroup; k < stopGroup; k++)
- {
- Int32 alpha;
- temp1 = k + lowSubband;
- if (k < noSubbands - 1)
- {
- alpha = degreeAlias[temp1 + 1] > degreeAlias[temp1 ] ?
- degreeAlias[temp1 + 1] : degreeAlias[temp1 ];
- }
- else
- {
- alpha = degreeAlias[temp1];
- }
-
- /*
- * nrg_gain[k] = alpha*newGain + (1.0f-alpha)*nrg_gain[k]*nrg_gain[k];
- */
-
- tmp_q1 = tmp_q2 > nrg_gain_exp[k] ? tmp_q2 : nrg_gain_exp[k];
- tmp_q1++;
-
- tmp_q3 = fxp_mul32_Q30(alpha, quotient.quotient);
- tmp_q4 = fxp_mul32_Q30(Q30fmt(1.0f) - alpha, nrg_gain_man[k]);
-
- nrg_gain_man[k] = (tmp_q3 >> (tmp_q1 - tmp_q2)) +
- (tmp_q4 >> (tmp_q1 - nrg_gain_exp[k]));
-
- nrg_gain_exp[k] = tmp_q1;
- }
-
-
- bst_exp = -100;
-
- for (k = startGroup; k < stopGroup; k++)
- {
- if (bst_exp < nrg_gain_exp[k] + nrg_est_exp[k])
- {
- bst_exp = nrg_gain_exp[k] + nrg_est_exp[k]; /* max */
- }
- }
-
- k -= startGroup; /* number of element used in the addition */
-
- while (k != 0) /* bit guard protection depends on log2(k) */
- {
- k >>= 1;
- bst_exp++; /* add extra bit-overflow-guard */
- }
-
- bst_man = 0;
-
- for (k = startGroup; k < stopGroup; k++)
- {
- tmp_q2 = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]);
- bst_man += tmp_q2 >> (bst_exp - nrg_gain_exp[k] - nrg_est_exp[k]);
- }
-
- bst_exp += 28; /* compensate for shift down */
-
- if (bst_man)
- {
- /*
- * bst = ref_total / bst
- */
-
- pv_div(ref_total_man, bst_man, &quotient);
- bst_exp = ref_total_exp - bst_exp - quotient.shift_factor - 30;
- bst_man = quotient.quotient; /* Q30 */
-
- for (k = startGroup; k < stopGroup; k++)
- {
- tmp_q1 = fxp_mul32_Q30(bst_man, nrg_gain_man[k]);
- pv_sqrt(tmp_q1, (bst_exp + nrg_gain_exp[k] + 60), &root_sq, sqrt_cache[0]);
- nrg_gain_man[k] = root_sq.root;
- nrg_gain_exp[k] = root_sq.shift_factor;
- }
- }
- else
- {
- pv_memset((void *)&nrg_gain_man[startGroup],
- 0,
- (stopGroup - startGroup)*sizeof(nrg_gain_man[0]));
-
- pv_memset((void *)&nrg_gain_exp[startGroup],
- 0,
- (stopGroup - startGroup)*sizeof(nrg_gain_exp[0]));
-
- }
-
- }
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h b/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h
deleted file mode 100644
index 2ce99ec..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_aliasing_reduction.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ALIASING_REDUCTION_H
-#define SBR_ALIASING_REDUCTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_aliasing_reduction(Int32 *degreeAlias,
- Int32 * nrg_gain_man,
- Int32 * nrg_gain_exp,
- Int32 * nrg_est_man,
- Int32 * nrg_est_exp,
- Int32 * dontUseTheseGainValues,
- Int32 noSubbands,
- Int32 lowSubband,
- Int32 sqrt_cache[][4],
- Int32 * groupVector);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_applied.cpp b/media/libstagefright/codecs/aacdec/sbr_applied.cpp
deleted file mode 100644
index c8b81b2..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_applied.cpp
+++ /dev/null
@@ -1,435 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_applied.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- INPUT
-
- SBRDECODER self,
- SBRBITSTREAM * stream,
- float *timeData,
- int numChannels
-
- OUTPUT
-
- errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- sbr decoder processing, set up SBR decoder phase 2 in case of
- different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include "sbr_applied.h"
-#include "sbr_read_data.h"
-
-#include "sbr_decode_envelope.h"
-#include "decode_noise_floorlevels.h"
-#include "sbr_requantize_envelope_data.h"
-#include "sbr_envelope_unmapping.h"
-#include "sbr_dec.h"
-#include "e_sbr_element_id.h"
-#include "aac_mem_funcs.h"
-
-#ifdef PARAMETRICSTEREO
-#include "ps_bstr_decoding.h"
-#include "ps_allocate_decoder.h"
-
-#endif
-
-#include "init_sbr_dec.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT (0)
-#define RIGHT (1)
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_applied(SBRDECODER_DATA * self,
- SBRBITSTREAM * stream,
- Int16 *ch_left,
- Int16 *ch_right,
- Int16 *timeData,
- SBR_DEC *sbrDec,
- tDec_Int_File *pVars,
- Int32 numChannels)
-{
- SBR_ERROR err = SBRDEC_OK ;
-
- Int32 eleChannels = 0;
-
- SBR_CHANNEL *SbrChannel = self->SbrChannel;
-
- /* Get SBR or PS Data only when available */
- if (stream->NrElements)
- {
- /* read frame data from bitstream */
-
- err = sbr_read_data(self,
- sbrDec,
- stream);
-
- if (err != SBRDEC_OK)
- {
- /*
- * This error condition disables any further SBR processing
- */
- self->SbrChannel[LEFT].syncState = UPSAMPLING;
- if (eleChannels == 2)
- {
- self->SbrChannel[RIGHT].syncState = UPSAMPLING;
- }
- }
-
- /*
- * Setting bistream and decoding type is only done once,
- */
- if (SbrChannel[LEFT].syncState == SBR_ACTIVE && self->setStreamType)
- {
- self->setStreamType = 0; /* Disable Lock for AAC stream type setting */
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
- Int sbrEnablePS = self->hParametricStereoDec->psDetected;
-
- pVars->mc_info.psPresentFlag = sbrEnablePS;
-
- if (sbrEnablePS) /* Initialize PS arrays */
- {
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
- ps_allocate_decoder(self, 32);
-
- /* Disable LC (or Enable HQ) if PS is detected */
- sbrDec->LC_aacP_DecoderFlag = OFF;
- }
- else
- {
- /*
- * Do not downgrade stream type from eaac+, if it has been explicitly declared
- */
- if (pVars->mc_info.ExtendedAudioObjectType != MP4AUDIO_PS)
- {
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
- if (pVars->mc_info.nch > 1)
- {
- sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */
- }
- else
- {
- sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */
- }
- }
- else
- {
- sbrEnablePS = 1; /* Force this condition as it was explicititly declared */
- pVars->mc_info.psPresentFlag = sbrEnablePS;
-
- }
- }
-#else
-
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
- if (pVars->mc_info.nch > 1)
- {
- sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */
- }
- else
- {
- sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */
- }
-#endif
-
-#else
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
- sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */
-
-#endif
-
- } /* (SbrChannel[LEFT].syncState == SBR_ACTIVE && lock) */
- else
- {
- /*
- * Default setting for upsampler
- */
- if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC)
- {
- /*
- * Change only in implicit signalling, otherwise keep original declaration
- */
- pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
- }
-
-#ifdef HQ_SBR
- if (pVars->mc_info.nch > 1)
- {
- sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for stereo */
- }
- else
- {
- sbrDec->LC_aacP_DecoderFlag = OFF; /* Disable LC, Enable HQ for mono */
- }
-#else
- sbrDec->LC_aacP_DecoderFlag = ON; /* Enable LC for all sbr decoding */
-
-#endif
- /* mask error and let upsampler run */
- err = SBRDEC_OK;
-
- }
-
- /* decoding */
- eleChannels = (stream->sbrElement [LEFT].ElementID == SBR_ID_CPE) ? 2 : 1;
-
- if (SbrChannel[LEFT].syncState == SBR_ACTIVE)
- {
-
- sbr_decode_envelope(&(SbrChannel[LEFT].frameData));
-
- decode_noise_floorlevels(&(SbrChannel[LEFT].frameData));
-
- if (! SbrChannel[LEFT].frameData.coupling)
- {
- sbr_requantize_envelope_data(&(SbrChannel[LEFT].frameData));
- }
-
- if (eleChannels == 2)
- {
-
- sbr_decode_envelope(&(SbrChannel[RIGHT].frameData));
-
- decode_noise_floorlevels(&(SbrChannel[RIGHT].frameData));
-
- if (SbrChannel[RIGHT].frameData.coupling)
- {
- sbr_envelope_unmapping(&(SbrChannel[ LEFT].frameData),
- &(SbrChannel[RIGHT].frameData));
- }
- else
- {
- sbr_requantize_envelope_data(&(SbrChannel[RIGHT].frameData));
- }
- }
- }
- else /* enable upsampling until valid SBR is obtained */
- {
- /*
- * Incomplete sbr frame, or disabled SBR section
- * Set the decoder to act as a regular upsampler
- */
-
- init_sbr_dec((sbrDec->outSampleRate >> 1),
- pVars->mc_info.upsamplingFactor,
- sbrDec,
- &(self->SbrChannel[LEFT].frameData));
-
- if ((eleChannels == 2) && (SbrChannel[RIGHT].syncState != SBR_ACTIVE))
- {
- init_sbr_dec((sbrDec->outSampleRate >> 1),
- pVars->mc_info.upsamplingFactor,
- sbrDec,
- &(self->SbrChannel[RIGHT].frameData));
-
- }
-
- }
-
- }
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_PS)
- {
- ps_bstr_decoding(self->hParametricStereoDec);
- /* allocate pointer for rigth channel qmf filter history */
- Int16 *tempInt16Ptr = (Int16 *)SbrChannel[RIGHT].frameData.V;
- self->hParametricStereoDec->R_ch_qmf_filter_history = (Int32 *)tempInt16Ptr;
-
-
- /*
- * 1824 (48*38) Int32 needed by each matrix sbrQmfBufferReal, sbrQmfBufferImag
- * pVars->share.predictedSamples has 2048 available
- * pVars->fxpCoef[1] has 2048 available
- */
- SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->share.predictedSamples;
- SbrChannel[LEFT].frameData.sbrQmfBufferImag = &pVars->fxpCoef[0][920];
-
- sbr_dec(ch_left,
- timeData,
- &(SbrChannel[LEFT].frameData),
- (SbrChannel[LEFT].syncState == SBR_ACTIVE),
- sbrDec,
- &timeData[RIGHT],
- self->hParametricStereoDec,
- pVars);
- }
- else
- {
-#endif
-#endif
-
- SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT];
-#ifdef HQ_SBR
- SbrChannel[LEFT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT];
-#endif
-
- sbr_dec(ch_left,
- timeData,
- &(SbrChannel[LEFT].frameData),
- (SbrChannel[LEFT].syncState == SBR_ACTIVE),
- sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- NULL,
- NULL,
-#endif
-#endif
- pVars);
-
- if (numChannels == 2)
- {
- SbrChannel[RIGHT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT];
-#ifdef HQ_SBR
- SbrChannel[RIGHT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT];
-#endif
-
- sbr_dec(ch_right,
- &timeData[RIGHT],
- &(SbrChannel[RIGHT].frameData),
- (SbrChannel[RIGHT].syncState == SBR_ACTIVE),
- sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- NULL,
- NULL,
-#endif
-#endif
- pVars);
-
- }
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- }
-#endif
-#endif
-
- return err;
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_applied.h b/media/libstagefright/codecs/aacdec/sbr_applied.h
deleted file mode 100644
index 6878537..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_applied.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_applied.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_APPLIED_H
-#define SBR_APPLIED_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_sbr_error.h"
-#include "s_sbr_channel.h"
-#include "s_sbrbitstream.h"
-#include "sbr_dec.h"
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_FRAME_SIZE 1024
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- SBR_ERROR sbr_applied(SBRDECODER_DATA * self,
- SBRBITSTREAM * stream,
- Int16 *ch_left,
- Int16 *ch_right,
- Int16 *timeData,
- SBR_DEC *sbrDec,
- tDec_Int_File *pVars,
- Int32 numChannels);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp b/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp
deleted file mode 100644
index 9db3221..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_code_book_envlevel.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here. Include conditional
- ; compile variables also.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; LOCAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
- ; Variable declaration - defined here and used outside this module
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL FUNCTION REFERENCES
- ; Declare functions defined elsewhere and referenced in this module
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
- /*******************************************************************************/
- /* table : envelope level, 1.5 dB */
- /* theor range : [-58,58], CODE_BOOK_SCF_LAV = 58 */
- /* implem range: [-60,60], CODE_BOOK_SCF_LAV10 = 60 */
- /* raw stats : envelopeLevel_00 (yes, wrong suffix in name) KK 01-03-09 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode3C2FIX.m/envelopeLevel_00T_cF.mat/m_hALC_cF
- built by : FH 01-07-05 */
-
- extern const Char bookSbrEnvLevel10T[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 }
- };
-
- /* direction: freq
- raw table: HuffCode3C2FIX.m/envelopeLevel_00F_cF.mat/m_hALC_cF
- built by : FH 01-07-05 */
-
- extern const Char bookSbrEnvLevel10F[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 }
- };
-
- /*******************************************************************************/
- /* table : envelope balance, 1.5 dB */
- /* theor range : [-48,48], CODE_BOOK_SCF_LAV = 48 */
- /* implem range: same but mapped to [-24,24], CODE_BOOK_SCF_LAV_BALANCE10 = 24 */
- /* raw stats : envelopePan_00 (yes, wrong suffix in name) KK 01-03-09 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
- built by : FH 01-05-15 */
-
- extern const Char bookSbrEnvBalance10T[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 }
- };
-
- /* direction: freq
- raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
- built by : FH 01-05-15 */
-
- extern const Char bookSbrEnvBalance10F[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 }
- };
-
- /*******************************************************************************/
- /* table : envelope level, 3.0 dB */
- /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */
- /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */
- /* raw stats : envelopeLevel_11 KK 00-02-03 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode2.m
- built by : FH 00-02-04 */
-
- extern const Char bookSbrEnvLevel11T[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 }
- };
-
- /* direction: freq
- raw table: HuffCode2.m
- built by : FH 00-02-04 */
-
- extern const Char bookSbrEnvLevel11F[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 }
- };
-
- /*******************************************************************************/
- /* table : envelope balance, 3.0 dB */
- /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */
- /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
- /* raw stats : envelopeBalance_11 KK 00-02-03 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
- built by : FH 01-05-15 */
-
- extern const Char bookSbrEnvBalance11T[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 }
- };
-
- /* direction: time (?)
- raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
- built by : FH 01-05-15 */
-
- extern const Char bookSbrEnvBalance11F[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 }
- };
-
- /*******************************************************************************/
- /* table : noise level, 3.0 dB */
- /* theor range : [-29,29], CODE_BOOK_SCF_LAV = 29 */
- /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31 */
- /* raw stats : noiseLevel_11 KK 00-02-03 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode2.m
- built by : FH 00-02-04 */
-
- extern const Char bookSbrNoiseLevel11T[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 }
- };
-
- /*******************************************************************************/
- /* table : noise balance, 3.0 dB */
- /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24 */
- /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
- /* raw stats : noiseBalance_11 KK 00-02-03 */
- /*******************************************************************************/
-
- /* direction: time
- raw table: HuffCode3C.m/noiseBalance_11.mat/v_hALB
- built by : FH 01-05-15 */
-
- extern const Char bookSbrNoiseBalance11T[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 }
- };
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h b/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h
deleted file mode 100644
index 3df0531..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: sbr_code_book_envlevel.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CODE_BOOK_ENVLEVEL_H
-#define SBR_CODE_BOOK_ENVLEVEL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
- extern const Char bookSbrEnvLevel10T[120][2];
- extern const Char bookSbrEnvLevel10F[120][2];
- extern const Char bookSbrEnvBalance10T[48][2];
- extern const Char bookSbrEnvBalance10F[48][2];
- extern const Char bookSbrEnvLevel11T[62][2];
- extern const Char bookSbrEnvLevel11F[62][2];
- extern const Char bookSbrEnvBalance11T[24][2];
- extern const Char bookSbrEnvBalance11F[24][2];
- extern const Char bookSbrNoiseLevel11T[62][2];
- extern const Char bookSbrNoiseBalance11T[24][2];
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_constants.h b/media/libstagefright/codecs/aacdec/sbr_constants.h
deleted file mode 100644
index d54a699..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_constants.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_constants.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CONSTANTS_H
-#define SBR_CONSTANTS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-
-#define SBR_AMP_RES_1_5 0
-#define SBR_AMP_RES_3_0 1
-
-#define MAX_NOISE_ENVELOPES 2
-#define MAX_NOISE_COEFFS 5
-#define MAX_NUM_NOISE_VALUES (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS)
-
-#define MAX_ENVELOPES 5
-#define MAX_FREQ_COEFFS 58
-#define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS)
-
-#define MAX_NUM_CHANNELS 2
-#define NOISE_FLOOR_OFFSET 6
-#define NOISE_FLOOR_OFFSET_PLUS_1 7
-
-#define LOW_RES 0
-#define HIGH_RES 1
-
-#define LO 0
-#define HI 1
-
-#define TIME 1
-#define FREQ 0
-
-#define LENGTH_FRAME_INFO 35
-
-#define SI_SBR_CRC_BITS 10
-
-#define SBR_FREQ_SCALE_DEFAULT 2
-#define SBR_ALTER_SCALE_DEFAULT 1
-#define SBR_NOISE_BANDS_DEFAULT 2
-
-#define SBR_LIMITER_BANDS_DEFAULT 2
-#define SBR_LIMITER_GAINS_DEFAULT 2
-#define SBR_INTERPOL_FREQ_DEFAULT 1
-#define SBR_SMOOTHING_LENGTH_DEFAULT 1
-
-/* header */
-#define SI_SBR_AMP_RES_BITS 1
-#define SI_SBR_START_FREQ_BITS 4
-#define SI_SBR_STOP_FREQ_BITS 4
-#define SI_SBR_XOVER_BAND_BITS 3
-#define SI_SBR_RESERVED_BITS_HDR 2
-#define SI_SBR_DATA_EXTRA_BITS 1
-#define SI_SBR_HEADER_EXTRA_1_BITS 1
-#define SI_SBR_HEADER_EXTRA_2_BITS 1
-
-#define SI_SBR_FREQ_SCALE_BITS 2
-#define SI_SBR_ALTER_SCALE_BITS 1
-#define SI_SBR_NOISE_BANDS_BITS 2
-
-#define SI_SBR_LIMITER_BANDS_BITS 2
-#define SI_SBR_LIMITER_GAINS_BITS 2
-#define SI_SBR_INTERPOL_FREQ_BITS 1
-#define SI_SBR_SMOOTHING_LENGTH_BITS 1
-
-
-/* data */
-#define SI_SBR_RESERVED_PRESENT 1
-#define SI_SBR_RESERVED_BITS_DATA 4
-
-#define SI_SBR_COUPLING_BITS 1
-
-#define SI_SBR_INVF_MODE_BITS 2
-
-#define SI_SBR_EXTENDED_DATA_BITS 1
-#define SI_SBR_EXTENSION_SIZE_BITS 4
-#define SI_SBR_EXTENSION_ESC_COUNT_BITS 8
-#define SI_SBR_EXTENSION_ID_BITS 2
-
-#define SI_SBR_NOISE_MODE_BITS 1
-#define SI_SBR_DOMAIN_BITS 1
-
-#define SI_SBR_START_ENV_BITS_AMP_RES_3_0 6
-#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0 5
-#define SI_SBR_START_NOISE_BITS_AMP_RES_3_0 5
-#define SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0 5
-
-#define SI_SBR_START_ENV_BITS_AMP_RES_1_5 7
-#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5 6
-
-
-#define SBR_CLA_BITS 2
-#define SBR_ABS_BITS 2
-#define SBR_RES_BITS 1
-#define SBR_REL_BITS 2
-#define SBR_ENV_BITS 2
-#define SBR_NUM_BITS 2
-
-
-#define FIXFIX 0
-#define FIXVAR 1
-#define VARFIX 2
-#define VARVAR 3
-
-
-#define LEN_EX_TYPE (4)
-#define LEN_NIBBLE (4)
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp b/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp
deleted file mode 100644
index 3bb4398..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_crc_check.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_crc_check.h"
-#include "s_crc_buffer.h"
-#include "buf_getbits.h"
-#include "sbr_constants.h"
-#include "check_crc.h"
-
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const unsigned short MAXCRCSTEP = 16;
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, UInt32 NrBits)
-{
- Int32 crcResult = 1;
- BIT_BUFFER BitBufferCRC;
- UInt32 NrCrcBits;
-
- UInt32 crcCheckSum;
-
- Int32 i;
- CRC_BUFFER CrcBuf;
- UInt32 bValue;
- Int32 CrcStep;
- Int32 CrcNrBitsRest;
-
- crcCheckSum = buf_getbits(hBitBuf, SI_SBR_CRC_BITS);
-
-
- /*
- * Copy Bit buffer State
- */
-
- BitBufferCRC.char_ptr = hBitBuf->char_ptr;
- BitBufferCRC.buffer_word = hBitBuf->buffer_word;
- BitBufferCRC.buffered_bits = hBitBuf->buffered_bits;
- BitBufferCRC.nrBitsRead = hBitBuf->nrBitsRead;
- BitBufferCRC.bufferLen = hBitBuf->bufferLen;
-
-
- NrCrcBits = min(NrBits, BitBufferCRC.bufferLen - BitBufferCRC.nrBitsRead);
-
-
- CrcStep = NrCrcBits / MAXCRCSTEP;
- CrcNrBitsRest = (NrCrcBits - CrcStep * MAXCRCSTEP);
-
- CrcBuf.crcState = CRCSTART;
- CrcBuf.crcMask = CRCMASK;
- CrcBuf.crcPoly = CRCPOLY;
-
- for (i = 0; i < CrcStep; i++)
- {
- bValue = buf_getbits(&BitBufferCRC, MAXCRCSTEP);
- check_crc(&CrcBuf, bValue, MAXCRCSTEP);
- }
-
- bValue = buf_getbits(&BitBufferCRC, CrcNrBitsRest);
- check_crc(&CrcBuf, bValue, CrcNrBitsRest);
-
- if ((UInt32)(CrcBuf.crcState & CRCRANGE) != crcCheckSum)
- {
- crcResult = 0;
- }
-
- return (crcResult);
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_crc_check.h b/media/libstagefright/codecs/aacdec/sbr_crc_check.h
deleted file mode 100644
index 9e6b1be..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_crc_check.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_crc_check.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CRC_CHECK_H
-#define SBR_CRC_CHECK_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define CRCPOLY 0x0233
-#define CRCMASK 0x0200
-#define CRCSTART 0x0000
-#define CRCRANGE 0x03FF
-
-#define SBR_EXTENSION 13 /* 1101 */
-#define SBR_EXTENSION_CRC 14 /* 1110 */
-
-
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int32 sbr_crc_check(BIT_BUFFER * hBitBuf,
- UInt32 NrBits);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp b/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp
deleted file mode 100644
index 9472ffc..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_create_limiter_bands.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_create_limiter_bands.h"
-#include "shellsort.h"
-#include "s_patch.h"
-#include "pv_log2.h"
-
-#include "fxp_mul32.h"
-
-#define R_SHIFT 29
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_create_limiter_bands(Int32 limSbc[][13],
- Int32 *gateMode,
- Int *freqTable,
- struct PATCH Patch,
- const Int32 noBands)
-{
- Int32 i;
- Int32 j;
- Int32 k;
- Int isPatchBorder[2];
- Int32 patchBorders[MAX_NUM_PATCHES + 1];
- Int32 workLimiterBandTable[32 + MAX_NUM_PATCHES + 1];
-
- Int32 nOctaves;
- const Int32 limiterBandsPerOctave[4] =
- {Q_fmt(0.0F), Q_fmt(1.2F),
- Q_fmt(2.0F), Q_fmt(3.0F)
- };
-
- Int32 tmp_q1;
-
- Int32 noPatches = Patch.noOfPatches;
- Int32 lowSubband = freqTable[0];
- Int32 highSubband = freqTable[noBands];
-
-
- for (i = 0; i < noPatches; i++)
- {
- patchBorders[i] = Patch.targetStartBand[i] - lowSubband;
- }
- patchBorders[i] = highSubband - lowSubband;
-
- /* First band: 1 limiter band. */
- limSbc[0][0] = freqTable[0] - lowSubband;
- limSbc[0][1] = freqTable[noBands] - lowSubband;
- gateMode[0] = 1;
-
- /* Next three bands: 1.2, 2, 3 limiter bands/octave plus bandborders at patchborders. */
- for (i = 1; i < 4; i++)
- {
-
- for (k = 0; k <= noBands; k++)
- {
- workLimiterBandTable[k] = freqTable[k] - lowSubband;
- }
-
- for (k = 1; k < noPatches; k++)
- {
- workLimiterBandTable[noBands+k] = patchBorders[k];
- }
-
- gateMode[i] = noBands + noPatches - 1;
- shellsort(workLimiterBandTable, gateMode[i] + 1);
-
- for (j = 1; j <= gateMode[i]; j++)
- {
- tmp_q1 = ((workLimiterBandTable[j] + lowSubband) << 20) / (workLimiterBandTable[j-1] + lowSubband);
-
- nOctaves = pv_log2(tmp_q1);
-
- tmp_q1 = fxp_mul32_Q20(nOctaves, limiterBandsPerOctave[i]);
- if (tmp_q1 < Q_fmt(0.49))
- {
- if (workLimiterBandTable[j] == workLimiterBandTable[j-1])
- {
- workLimiterBandTable[j] = highSubband;
- shellsort(workLimiterBandTable, gateMode[i] + 1);
- gateMode[i]--;
- j--;
- continue;
- }
-
- isPatchBorder[0] = isPatchBorder[1] = 0;
-
- for (k = 0; k <= noPatches; k++)
- {
- if (workLimiterBandTable[j-1] == patchBorders[k])
- {
- isPatchBorder[0] = 1;
- break;
- }
- }
-
- for (k = 0; k <= noPatches; k++)
- {
- if (workLimiterBandTable[j] == patchBorders[k])
- {
- isPatchBorder[1] = 1;
- break;
- }
- }
-
- if (!isPatchBorder[1])
- {
- workLimiterBandTable[j] = highSubband;
- shellsort(workLimiterBandTable, gateMode[i] + 1);
- gateMode[i]--;
- j--;
- }
- else if (!isPatchBorder[0])
- {
- workLimiterBandTable[j-1] = highSubband;
- shellsort(workLimiterBandTable, gateMode[i] + 1);
- gateMode[i]--;
- j--;
- }
- }
- }
- for (k = 0; k <= gateMode[i]; k++)
- {
- limSbc[i][k] = workLimiterBandTable[k];
- }
- }
-}
-
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h b/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h
deleted file mode 100644
index 7a53944..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_create_limiter_bands.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CREATE_LIMITER_BANDS_H
-#define SBR_CREATE_LIMITER_BANDS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "sbr_generate_high_freq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void sbr_create_limiter_bands(Int32 limSbc[4][12 + 1],
- Int32 gateMode[4],
- Int *freqTable,
- struct PATCH Patch,
- const Int32 noBands);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_dec.cpp b/media/libstagefright/codecs/aacdec/sbr_dec.cpp
deleted file mode 100644
index 8519b17..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_dec.cpp
+++ /dev/null
@@ -1,960 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2010 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- sbr decoder core function
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include "s_sbr_frame_data.h"
-#include "calc_sbr_synfilterbank.h"
-#include "calc_sbr_anafilterbank.h"
-#include "calc_sbr_envelope.h"
-#include "sbr_generate_high_freq.h"
-#include "sbr_dec.h"
-#include "decode_noise_floorlevels.h"
-#include "aac_mem_funcs.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#ifdef PARAMETRICSTEREO
-
-#include "ps_applied.h"
-#include "ps_init_stereo_mixing.h"
-
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_dec(Int16 *inPcmData,
- Int16 *ftimeOutPtr,
- SBR_FRAME_DATA * hFrameData,
- int32_t applyProcessing,
- SBR_DEC *sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- Int16 * ftimeOutPtrPS,
- HANDLE_PS_DEC hParametricStereoDec,
-#endif
-#endif
- tDec_Int_File *pVars)
-{
- int32_t i;
- int32_t j;
- int32_t m;
-
- int32_t *frameInfo = hFrameData->frameInfo;
- Int num_qmf_bands;
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
- int32_t env;
-
- int32_t *qmf_PS_generated_Real;
- int32_t *qmf_PS_generated_Imag;
-
- int32_t *Sr_x;
- int32_t *Si_x;
-
-
-#endif
-#endif
-
- int32_t(*scratch_mem)[64];
- Int16 *circular_buffer_s;
-
- int32_t k;
- int32_t *Sr;
- int32_t *Si;
- int32_t *ptr_tmp1;
- int32_t *ptr_tmp2;
- scratch_mem = pVars->scratch.scratch_mem;
-
-
- if (applyProcessing)
- {
- num_qmf_bands = sbrDec->lowSubband;
- }
- else
- {
- num_qmf_bands = 32; /* becomes a resampler by 2 */
- }
-
- /* -------------------------------------------------- */
- /*
- * Re-Load Buffers
- */
- pv_memmove(&hFrameData->sbrQmfBufferReal[0],
- &hFrameData->HistsbrQmfBufferReal[0],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-#ifdef HQ_SBR
-
-
- if (sbrDec->LC_aacP_DecoderFlag == OFF)
- {
- pv_memmove(&hFrameData->sbrQmfBufferImag[0],
- &hFrameData->HistsbrQmfBufferImag[0],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
- }
-#endif
- /* -------------------------------------------------- */
-
-
- /*
- * low band codec signal subband filtering
- */
-
- for (i = 0; i < 32; i++)
- {
-
- if (sbrDec->LC_aacP_DecoderFlag == ON)
- {
-
- calc_sbr_anafilterbank_LC(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i],
- &inPcmData[319] + (i << 5),
- scratch_mem,
- num_qmf_bands);
-
- }
-#ifdef HQ_SBR
- else
- {
-
- calc_sbr_anafilterbank(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i],
- hFrameData->codecQmfBufferImag[sbrDec->bufWriteOffs + i],
- &inPcmData[319] + (i << 5),
- scratch_mem,
- num_qmf_bands);
- }
-#endif
-
- }
-
- if (pVars->ltp_buffer_state)
- {
- pv_memcpy(&inPcmData[-1024-288], &inPcmData[1024], 288*sizeof(*inPcmData));
- }
- else
- {
- pv_memcpy(&inPcmData[1024 + 288], &inPcmData[1024], 288*sizeof(*inPcmData));
- }
-
-
- if (applyProcessing)
- {
-
- /*
- * Inverse filtering of lowband + HF generation
- */
-
- if (sbrDec->LC_aacP_DecoderFlag == ON)
- {
-
- sbr_generate_high_freq((int32_t(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs),
- NULL,
- (int32_t *)(hFrameData->sbrQmfBufferReal),
- NULL,
- hFrameData->sbr_invf_mode,
- hFrameData->sbr_invf_mode_prev,
- &(sbrDec->FreqBandTableNoise[1]),
- sbrDec->NoNoiseBands,
- sbrDec->lowSubband,
- sbrDec->V_k_master,
- sbrDec->Num_Master,
- sbrDec->outSampleRate,
- frameInfo,
- hFrameData->degreeAlias,
- scratch_mem,
- hFrameData->BwVector,/* */
- hFrameData->BwVectorOld,
- &(sbrDec->Patch),
- sbrDec->LC_aacP_DecoderFlag,
- &(sbrDec->highSubband));
-
-
- /*
- * Adjust envelope of current frame.
- */
-
- calc_sbr_envelope(hFrameData,
- (int32_t *)(hFrameData->sbrQmfBufferReal),
- NULL,
- sbrDec->FreqBandTable,
- sbrDec->NSfb,
- sbrDec->FreqBandTableNoise,
- sbrDec->NoNoiseBands,
- hFrameData->reset_flag,
- hFrameData->degreeAlias,
- &(hFrameData->harm_index),
- &(hFrameData->phase_index),
- hFrameData->hFp,
- &(hFrameData->sUp),
- sbrDec->limSbc,
- sbrDec->gateMode,
-#ifdef HQ_SBR
- NULL,
- NULL,
- NULL,
- NULL,
-#endif
- scratch_mem,
- sbrDec->Patch,
- sbrDec->sqrt_cache,
- sbrDec->LC_aacP_DecoderFlag);
- }
-#ifdef HQ_SBR
- else
- {
-
- sbr_generate_high_freq((int32_t(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs),
- (int32_t(*)[32])(hFrameData->codecQmfBufferImag + sbrDec->bufReadOffs),
- (int32_t *)(hFrameData->sbrQmfBufferReal),
- (int32_t *)(hFrameData->sbrQmfBufferImag),
- hFrameData->sbr_invf_mode,
- hFrameData->sbr_invf_mode_prev,
- &(sbrDec->FreqBandTableNoise[1]),
- sbrDec->NoNoiseBands,
- sbrDec->lowSubband,
- sbrDec->V_k_master,
- sbrDec->Num_Master,
- sbrDec->outSampleRate,
- frameInfo,
- NULL,
- scratch_mem,
- hFrameData->BwVector,
- hFrameData->BwVectorOld,
- &(sbrDec->Patch),
- sbrDec->LC_aacP_DecoderFlag,
- &(sbrDec->highSubband));
-
- /*
- * Adjust envelope of current frame.
- */
-
- calc_sbr_envelope(hFrameData,
- (int32_t *)(hFrameData->sbrQmfBufferReal),
- (int32_t *)(hFrameData->sbrQmfBufferImag),
- sbrDec->FreqBandTable,
- sbrDec->NSfb,
- sbrDec->FreqBandTableNoise,
- sbrDec->NoNoiseBands,
- hFrameData->reset_flag,
- NULL,
- &(hFrameData->harm_index),
- &(hFrameData->phase_index),
- hFrameData->hFp,
- &(hFrameData->sUp),
- sbrDec->limSbc,
- sbrDec->gateMode,
- hFrameData->fBuf_man,
- hFrameData->fBuf_exp,
- hFrameData->fBufN_man,
- hFrameData->fBufN_exp,
- scratch_mem,
- sbrDec->Patch,
- sbrDec->sqrt_cache,
- sbrDec->LC_aacP_DecoderFlag);
-
- }
-#endif
-
-
- }
- else /* else for applyProcessing */
- {
- /* no sbr, set high band buffers to zero */
-
- for (i = 0; i < SBR_NUM_COLUMNS; i++)
- {
- pv_memset((void *)&hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS],
- 0,
- SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
-#ifdef HQ_SBR
- pv_memset((void *)&hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS],
- 0,
- SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-
-#endif
- }
-
- }
-
-
- /*
- * Synthesis subband filtering.
- */
-
-#ifdef HQ_SBR
-
-#ifdef PARAMETRICSTEREO
-
-
- /*
- * psPresentFlag set implies hParametricStereoDec !=NULL, second condition is
- * is just here to prevent CodeSonar warnings.
- */
- if ((pVars->mc_info.psPresentFlag) && (applyProcessing) &&
- (hParametricStereoDec != NULL))
- {
-
- /*
- * qmfBufferReal uses the rigth aac channel ( perChan[1] is not used)
- * followed by the buffer fxpCoef[2][2048] which makes a total of
- * 2349 + 2048*2 = 6445
- * These 2 matrices (qmfBufferReal & qmfBufferImag) are
- * [2][38][64] == 4864 int32_t
- */
-
-
- tDec_Int_Chan *tmpx = &pVars->perChan[1];
- /*
- * dereferencing type-punned pointer avoid
- * breaking strict-aliasing rules
- */
- int32_t *tmp = (int32_t *)tmpx;
- hParametricStereoDec->qmfBufferReal = (int32_t(*)[64]) tmp;
-
- tmp = (int32_t *) & hParametricStereoDec->qmfBufferReal[38][0];
- hParametricStereoDec->qmfBufferImag = (int32_t(*)[64]) tmp;
-
- for (i = 0; i < 32; i++)
- {
- Int xoverBand;
-
- if (i < ((hFrameData->frameInfo[1]) << 1))
- {
- xoverBand = sbrDec->prevLowSubband;
- }
- else
- {
- xoverBand = sbrDec->lowSubband;
- }
-
- if (xoverBand > sbrDec->highSubband)
- {
- /*
- * error condition, default to upsampling mode
- * and make sure that the number of bands for xover does
- * not exceed the number of high freq bands.
- */
- xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband;
- }
-
- m = sbrDec->bufReadOffs + i; /* 2 + i */
-
- Sr_x = hParametricStereoDec->qmfBufferReal[i];
- Si_x = hParametricStereoDec->qmfBufferImag[i];
-
-
-
- for (int32_t j = 0; j < xoverBand; j++)
- {
- Sr_x[j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]);
- Si_x[j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]);
- }
-
-
-
-
- pv_memcpy(&Sr_x[xoverBand],
- &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS],
- (sbrDec->highSubband - xoverBand)*sizeof(*Sr_x));
-
- pv_memcpy(&Si_x[xoverBand],
- &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS],
- (sbrDec->highSubband - xoverBand)*sizeof(*Si_x));
-
- pv_memset((void *)&Sr_x[sbrDec->highSubband],
- 0,
- (64 - sbrDec->highSubband)*sizeof(*Sr_x));
-
- pv_memset((void *)&Si_x[sbrDec->highSubband],
- 0,
- (64 - sbrDec->highSubband)*sizeof(*Si_x));
-
-
- }
-
- for (i = 32; i < 32 + 6; i++)
- {
- m = sbrDec->bufReadOffs + i; /* 2 + i */
-
- for (int32_t j = 0; j < 5; j++)
- {
- hParametricStereoDec->qmfBufferReal[i][j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]);
- hParametricStereoDec->qmfBufferImag[i][j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]);
- }
-
- }
-
-
- /*
- * Update Buffers
- */
- for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */
- {
- j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */
-
- pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */
- hFrameData->codecQmfBufferReal[j], /* from */
- sizeof(*hFrameData->codecQmfBufferReal[i]) << 5);
-
- pv_memmove(hFrameData->codecQmfBufferImag[i],
- hFrameData->codecQmfBufferImag[j],
- sizeof(*hFrameData->codecQmfBufferImag[i]) << 5);
- }
-
-
- pv_memmove(&hFrameData->HistsbrQmfBufferReal[0],
- &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
- pv_memmove(&hFrameData->HistsbrQmfBufferImag[0],
- &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-
-
- /*
- * Needs whole QMF matrix formed before applying
- * Parametric stereo processing.
- */
-
- qmf_PS_generated_Real = scratch_mem[0];
- qmf_PS_generated_Imag = scratch_mem[1];
- env = 0;
-
- /*
- * Set circular buffer for Left channel
- */
-
- circular_buffer_s = (Int16 *)scratch_mem[7];
-
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- pv_memmove(&circular_buffer_s[2048],
- hFrameData->V,
- 640*sizeof(*circular_buffer_s));
- }
- else
- {
- pv_memmove(&circular_buffer_s[4096],
- hFrameData->V,
- 1152*sizeof(*circular_buffer_s));
-
- }
-
-
- /*
- * Set Circular buffer for PS hybrid analysis
- */
-
- int32_t *pt_temp = &scratch_mem[2][32];
-
- for (i = 0, j = 0; i < 3; i++)
- {
-
- pv_memmove(&pt_temp[ j],
- hParametricStereoDec->hHybrid->mQmfBufferReal[i],
- HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal));
- pv_memmove(&pt_temp[ j + 44],
- hParametricStereoDec->hHybrid->mQmfBufferImag[i],
- HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag));
- j += 88;
- }
-
-
- pv_memset((void *)&qmf_PS_generated_Real[hParametricStereoDec->usb],
- 0,
- (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Real));
-
- pv_memset((void *)&qmf_PS_generated_Imag[hParametricStereoDec->usb],
- 0,
- (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Imag));
-
-
- for (i = 0; i < 32; i++)
- {
- if (i == (Int)hParametricStereoDec-> aEnvStartStop[env])
- {
- ps_init_stereo_mixing(hParametricStereoDec, env, sbrDec->highSubband);
- env++;
- }
-
-
- ps_applied(hParametricStereoDec,
- &hParametricStereoDec->qmfBufferReal[i],
- &hParametricStereoDec->qmfBufferImag[i],
- qmf_PS_generated_Real,
- qmf_PS_generated_Imag,
- scratch_mem[2],
- i);
-
- /* Create time samples for regular mono channel */
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */
- hParametricStereoDec->qmfBufferImag[i], /* imagSamples */
- ftimeOutPtr + (i << 6),
- &circular_buffer_s[1984 - (i<<6)],
- pVars->mc_info.bDownSampledSbr);
- }
- else
- {
- calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */
- hParametricStereoDec->qmfBufferImag[i], /* imagSamples */
- ftimeOutPtr + (i << 7),
- &circular_buffer_s[3968 - (i<<7)],
- pVars->mc_info.bDownSampledSbr);
-
- }
-
- pv_memmove(hParametricStereoDec->qmfBufferReal[i], qmf_PS_generated_Real, 64*sizeof(*qmf_PS_generated_Real));
- pv_memmove(hParametricStereoDec->qmfBufferImag[i], qmf_PS_generated_Imag, 64*sizeof(*qmf_PS_generated_Real));
-
- }
-
-
- /*
- * Save Circular buffer history used on PS hybrid analysis
- */
-
-
- pt_temp = &scratch_mem[2][64];
-
- for (i = 0, j = 0; i < 3; i++)
- {
- pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferReal[i],
- &pt_temp[ j],
- HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal));
-
- pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferImag[i],
- &pt_temp[ j + 44],
- HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag));
-
- j += 88;
- }
-
-
- pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
-
- /*
- * Set circular buffer for Right channel
- */
-
- circular_buffer_s = (Int16 *)scratch_mem[5];
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- pv_memmove(&circular_buffer_s[2048],
- (int32_t *)hParametricStereoDec->R_ch_qmf_filter_history,
- 640*sizeof(*circular_buffer_s));
- }
- else
- {
- pv_memmove(&circular_buffer_s[4096],
- (int32_t *)hParametricStereoDec->R_ch_qmf_filter_history,
- 1152*sizeof(*circular_buffer_s));
-
- }
-
-
- for (i = 0; i < 32; i++)
- {
- if (pVars->mc_info.bDownSampledSbr)
- {
-
- calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */
- hParametricStereoDec->qmfBufferImag[i], /* imagSamples */
- ftimeOutPtrPS + (i << 6),
- &circular_buffer_s[1984 - (i<<6)],
- pVars->mc_info.bDownSampledSbr);
- }
- else
- {
- calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i], /* realSamples */
- hParametricStereoDec->qmfBufferImag[i], /* imagSamples */
- ftimeOutPtrPS + (i << 7),
- &circular_buffer_s[3968 - (i<<7)],
- pVars->mc_info.bDownSampledSbr);
- }
-
- }
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- pv_memmove((int32_t *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s));
- }
- else
- {
- pv_memmove((int32_t *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
- }
-
-
-
-
-
- }
- else /* else -- sbrEnablePS */
- {
-
-#endif /* PARAMETRICSTEREO */
-#endif /* HQ_SBR */
-
- /*
- * Use shared aac memory as continuous buffer
- */
-
-
- Sr = scratch_mem[0];
- Si = scratch_mem[1];
-
- circular_buffer_s = (Int16*)scratch_mem[2];
-
- if (pVars->mc_info.bDownSampledSbr)
- {
-
- pv_memmove(&circular_buffer_s[2048],
- hFrameData->V,
- 640*sizeof(*circular_buffer_s));
- }
- else
- {
- pv_memmove(&circular_buffer_s[4096],
- hFrameData->V,
- 1152*sizeof(*circular_buffer_s));
- }
-
- for (i = 0; i < 32; i++)
- {
- Int xoverBand;
-
- if (applyProcessing)
- {
- if (i < ((hFrameData->frameInfo[1]) << 1))
- {
- xoverBand = sbrDec->prevLowSubband;
-
- }
- else
- {
- xoverBand = sbrDec->lowSubband;
- }
-
- if (xoverBand > sbrDec->highSubband)
- {
- /*
- * error condition, default to upsampling mode
- * and make sure that the number of bands for xover does
- * not exceed the number of high freq bands.
- */
- xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband;
- }
- }
- else
- {
- xoverBand = 32;
- sbrDec->highSubband = 32;
- }
-
-
- m = sbrDec->bufReadOffs + i; /* sbrDec->bufReadOffs == 2 */
-
-
- ptr_tmp1 = (hFrameData->codecQmfBufferReal[m]);
- ptr_tmp2 = Sr;
-
- if (sbrDec->LC_aacP_DecoderFlag == ON)
- {
-
- for (k = (xoverBand >> 1); k != 0; k--)
- {
- *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9;
- *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9;
- }
- if (xoverBand & 1)
- {
- *(ptr_tmp2++) = (*(ptr_tmp1)) >> 9;
- }
-
- ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS];
-
-
- for (k = xoverBand; k < sbrDec->highSubband; k++)
- {
- *(ptr_tmp2++) = (*(ptr_tmp1++)) << 1;
- }
-
- pv_memset((void *)ptr_tmp2,
- 0,
- (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- calc_sbr_synfilterbank_LC(Sr, /* realSamples */
- ftimeOutPtr + (i << 6),
- &circular_buffer_s[1984 - (i<<6)],
- pVars->mc_info.bDownSampledSbr);
- }
- else
- {
- calc_sbr_synfilterbank_LC(Sr, /* realSamples */
- ftimeOutPtr + (i << 7),
- &circular_buffer_s[3968 - (i<<7)],
- pVars->mc_info.bDownSampledSbr);
- }
- }
-#ifdef HQ_SBR
- else
- {
-
- for (k = xoverBand; k != 0; k--)
- {
- *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
- }
-
- ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS];
- ptr_tmp2 = &Sr[xoverBand];
-
-
- for (k = xoverBand; k < sbrDec->highSubband; k++)
- {
- *(ptr_tmp2++) = (*(ptr_tmp1++));
- }
-
- pv_memset((void *)ptr_tmp2,
- 0,
- (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
- ptr_tmp1 = (hFrameData->codecQmfBufferImag[m]);
- ptr_tmp2 = Si;
-
- for (k = (xoverBand >> 1); k != 0; k--)
- {
- *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
- *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
- }
- if (xoverBand & 1)
- {
- *(ptr_tmp2) = shft_lft_1(*(ptr_tmp1));
- }
-
- ptr_tmp1 = &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS];
- ptr_tmp2 = &Si[xoverBand];
-
- for (k = xoverBand; k < sbrDec->highSubband; k++)
- {
- *(ptr_tmp2++) = (*(ptr_tmp1++));
- }
-
- pv_memset((void *)ptr_tmp2,
- 0,
- (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- calc_sbr_synfilterbank(Sr, /* realSamples */
- Si, /* imagSamples */
- ftimeOutPtr + (i << 6),
- &circular_buffer_s[1984 - (i<<6)],
- pVars->mc_info.bDownSampledSbr);
- }
- else
- {
- calc_sbr_synfilterbank(Sr, /* realSamples */
- Si, /* imagSamples */
- ftimeOutPtr + (i << 7),
- &circular_buffer_s[3968 - (i<<7)],
- pVars->mc_info.bDownSampledSbr);
- }
- }
-#endif
-
- }
-
- if (pVars->mc_info.bDownSampledSbr)
- {
- pv_memmove(hFrameData->V, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s));
- }
- else
- {
- pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
- }
-
-
-
-
- /*
- * Update Buffers
- */
- for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 8 and unchanged */
- {
- j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */
-
- pv_memmove(hFrameData->codecQmfBufferReal[i], /* to */
- hFrameData->codecQmfBufferReal[j], /* from */
- sizeof(*hFrameData->codecQmfBufferReal[i]) << 5);
- }
-
-
- pv_memmove(&hFrameData->HistsbrQmfBufferReal[0],
- &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
-#ifdef HQ_SBR
- if (sbrDec->LC_aacP_DecoderFlag == OFF)
- {
- for (i = 0; i < sbrDec->bufWriteOffs; i++) /* sbrDec->bufWriteOffs set to 6 and unchanged */
- {
- j = sbrDec->noCols + i; /* sbrDec->noCols set to 32 and unchanged */
-
-
- pv_memmove(hFrameData->codecQmfBufferImag[i],
- hFrameData->codecQmfBufferImag[j],
- sizeof(*hFrameData->codecQmfBufferImag[i]) << 5);
-
- }
-
- pv_memmove(&hFrameData->HistsbrQmfBufferImag[0],
- &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS],
- 6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
- }
-#endif
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- }
-#endif
-#endif
-
-
- hFrameData->reset_flag = 0;
- if (applyProcessing)
- {
- sbrDec->prevLowSubband = sbrDec->lowSubband;
- }
-
-}
-
-
-#endif /* AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/sbr_dec.h b/media/libstagefright/codecs/aacdec/sbr_dec.h
deleted file mode 100644
index ba7c1f3..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_dec.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_dec.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DEC_H
-#define SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "s_sbr_frame_data.h"
-#include "pv_audio_type_defs.h"
-#include "s_patch.h"
-#include "e_blockswitching.h"
-#include "s_sbr_dec.h"
-#include "s_tdec_int_file.h"
-#ifdef PARAMETRICSTEREO
-#include "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
- void sbr_dec(Int16 *inPcmData,
- Int16 *ftimeOutPtr,
- SBR_FRAME_DATA * hFrameData,
- Int32 applyProcessing,
- SBR_DEC *sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
- Int16 * ftimeOutPtrPS,
- HANDLE_PS_DEC hParametricStereoDec,
-#endif
-#endif
- tDec_Int_File *pVars);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp b/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp
deleted file mode 100644
index 771bb32..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_decode_envelope.h"
-#include "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void mapLowResEnergyVal(
- Int32 currVal,
- Int32 *prevData,
- Int32 offset,
- Int32 index,
- Int32 res);
-
-Int32 indexLow2High(Int32 offset,
- Int32 index,
- Int32 res);
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData)
-
-{
- Int32 i;
- Int32 no_of_bands;
- Int32 band;
- Int32 freqRes;
- Int32 *iEnvelope = hFrameData->iEnvelope_man;
- Int32 *sfb_nrg_prev = hFrameData->sfb_nrg_prev_man;
-
- Int32 offset = hFrameData->offset;
- Int32 *nSfb = hFrameData->nSfb;
- Int32 *domain_vec = hFrameData->domain_vec1;
- Int32 *frameInfo = hFrameData->frameInfo;
-
-
-
- for (i = 0; i < frameInfo[0]; i++)
- {
- freqRes = frameInfo[frameInfo[0] + i + 2];
- no_of_bands = nSfb[freqRes];
-
- if (domain_vec[i] == 0)
- {
- mapLowResEnergyVal(*iEnvelope,
- sfb_nrg_prev,
- offset,
- 0,
- freqRes);
- iEnvelope++;
-
- for (band = 1; band < no_of_bands; band++)
- {
- *iEnvelope += *(iEnvelope - 1);
-
- mapLowResEnergyVal(*iEnvelope,
- sfb_nrg_prev,
- offset,
- band,
- freqRes);
- iEnvelope++;
- }
- }
- else
- {
- for (band = 0; band < no_of_bands; band++)
- {
- *iEnvelope += sfb_nrg_prev[ indexLow2High(offset, band, freqRes)];
-
- mapLowResEnergyVal(*iEnvelope,
- sfb_nrg_prev,
- offset,
- band,
- freqRes);
- iEnvelope++;
- }
- }
- }
-}
-
-
-
-void mapLowResEnergyVal(
- Int32 currVal,
- Int32 *prevData,
- Int32 offset,
- Int32 index,
- Int32 res)
-{
- Int32 tmp;
-
- if (res == LO)
- {
- if (offset >= 0)
- {
- if (index < offset)
- {
- prevData[index] = currVal;
- }
- else
- {
- tmp = (index << 1) - offset;
- prevData[tmp ] = currVal;
- prevData[tmp +1 ] = currVal;
- }
- }
- else
- {
- offset = -offset;
- if (index < offset)
- {
- tmp = (index << 1) + index;
- prevData[tmp ] = currVal;
- prevData[tmp + 1] = currVal;
- prevData[tmp + 2] = currVal;
- }
- else
- {
- tmp = (index << 1) + offset;
- prevData[tmp ] = currVal;
- prevData[tmp + 1] = currVal;
- }
- }
- }
- else
- {
- prevData[index] = currVal;
- }
-}
-
-
-Int32 indexLow2High(Int32 offset,
- Int32 index,
- Int32 res)
-{
- if (res == LO)
- {
- if (offset >= 0)
- {
- if (index < offset)
- {
- return(index);
- }
- else
- {
- return((index << 1) - offset);
- }
- }
- else
- {
- offset = -offset;
- if (index < offset)
- {
- return((index << 1) + index);
- }
- else
- {
- return((index << 1) + offset);
- }
- }
- }
- else
- {
- return(index);
- }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h b/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h
deleted file mode 100644
index 19c04a9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_envelope.h
- Funtions:
- decodeEnvelope
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DECODE_ENVELOPE_H
-#define SBR_DECODE_ENVELOPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp b/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp
deleted file mode 100644
index 290fd18..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_huff_cw.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- SbrHuffman h, pointer to huffman codebook table
- BIT_BUFFER * hBitBuf pointer to Bitbuffer
-
- return decoded value
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decodes one huffman code word
-
- Reads bits from the bitstream until a valid codeword is found.
- The table entries are interpreted either as index to the next entry
- or - if negative - as the codeword.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_decode_huff_cw.h"
-#include "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 sbr_decode_huff_cw(SbrHuffman h,
- BIT_BUFFER * hBitBuf)
-{
- Int32 bits;
- Char index = 0;
-
- while (index >= 0)
- {
- bits = buf_get_1bit(hBitBuf);
- index = h[index][bits];
- }
-
- return((Int32)index + 64); /* Add offset */
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h b/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h
deleted file mode 100644
index bfbdb67..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_huff_cw.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DECODE_HUFF_CW_H
-#define SBR_DECODE_HUFF_CW_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int32 sbr_decode_huff_cw(SbrHuffman h,
- BIT_BUFFER * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp b/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp
deleted file mode 100644
index c2b007a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_downsample_lo_res.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_downsample_lo_res.h"
-#include "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_downsample_lo_res(Int32 v_result[],
- Int32 num_result,
- Int freqBandTableRef[],
- Int32 num_Ref)
-{
- Int32 step;
- Int32 i, j;
- Int32 org_length;
- Int32 result_length;
- Int32 v_index[MAX_FREQ_COEFFS/2];
-
- /* init */
- org_length = num_Ref;
- result_length = num_result;
-
- v_index[0] = 0; /* Always use left border */
- i = 0;
- while (org_length > 0) /* Create downsample vector */
- {
- i++;
- step = org_length / result_length; /* floor; */
- org_length = org_length - step;
- result_length--;
- v_index[i] = v_index[i-1] + step;
- }
-
- for (j = 0; j <= i; j++) /* Use downsample vector to index LoResolution vector. */
- {
- v_result[j] = freqBandTableRef[ v_index[j]];
- }
-
-} /* End downSampleLoRes */
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h b/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h
deleted file mode 100644
index 2f49aea..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_downsample_lo_res.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DOWNSAMPLE_LO_RES_H
-#define SBR_DOWNSAMPLE_LO_RES_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void sbr_downsample_lo_res(Int32 v_result[],
- Int32 num_result,
- Int freqBandTableRef[],
- Int32 num_Ref);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp b/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp
deleted file mode 100644
index 2ed76dd..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_calc_tbl.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_envelope_calc_tbl.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-#define Q30_fmt(x) (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Qfmt15(x) (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-const Int32 limGains[5] = { Q30_fmt(0.70795f), Q30_fmt(1.0f),
- Q30_fmt(1.41254f), Q30_fmt(1.16415321826935f), 33
- };
-
-const Int32 smoothLengths[2] = { 4, 0 };
-
-const Int16 rP_LCx[512] =
-{
- Qfmt15(-0.99948153278296f), Qfmt15(0.97113454393991f), Qfmt15(0.14130051758487f), Qfmt15(-0.47005496701697f),
- Qfmt15(0.80705063769351f), Qfmt15(-0.38981478896926f), Qfmt15(-0.01053049862020f), Qfmt15(-0.91266367957293f),
- Qfmt15(0.54840422910309f), Qfmt15(0.40009252867955f), Qfmt15(-0.99867974711855f), Qfmt15(-0.95531076805040f),
- Qfmt15(-0.45725933317144f), Qfmt15(-0.72929675029275f), Qfmt15(0.75622801399036f), Qfmt15(0.07069442601050f),
- Qfmt15(0.74496252926055f), Qfmt15(-0.96440182703856f), Qfmt15(0.30424629369539f), Qfmt15(0.66565033746925f),
- Qfmt15(0.91697008020594f), Qfmt15(-0.70774918760427f), Qfmt15(-0.70051415345560f), Qfmt15(-0.99496513054797f),
- Qfmt15(0.98164490790123f), Qfmt15(-0.54671580548181f), Qfmt15(-0.01689629065389f), Qfmt15(-0.86110349531986f),
- Qfmt15(-0.98892980586032f), Qfmt15(0.51756627678691f), Qfmt15(-0.99635026409640f), Qfmt15(-0.99969370862163f),
- Qfmt15(0.55266258627194f), Qfmt15(0.34581177741673f), Qfmt15(0.62664209577999f), Qfmt15(-0.77149701404973f),
- Qfmt15(-0.91592244254432f), Qfmt15(-0.76285492357887f), Qfmt15(0.79788337195331f), Qfmt15(0.54473080610200f),
- Qfmt15(-0.85639281671058f), Qfmt15(-0.92882402971423f), Qfmt15(-0.11708371046774f), Qfmt15(0.21356749817493f),
- Qfmt15(-0.76191692573909f), Qfmt15(0.98111043100884f), Qfmt15(-0.85913269895572f), Qfmt15(-0.93307242253692f),
- Qfmt15(0.30485754879632f), Qfmt15(0.85289650925190f), Qfmt15(0.91328082618125f), Qfmt15(-0.05890199924154f),
- Qfmt15(0.28398686150148f), Qfmt15(0.95258164539612f), Qfmt15(-0.78566324168507f), Qfmt15(-0.95789495447877f),
- Qfmt15(0.82411158711197f), Qfmt15(-0.65185446735885f), Qfmt15(-0.93643603134666f), Qfmt15(0.91427159529618f),
- Qfmt15(-0.70395684036886f), Qfmt15(0.00563771969365f), Qfmt15(0.89065051931895f), Qfmt15(-0.68683707712762f),
- Qfmt15(0.72165342518718f), Qfmt15(-0.62928247730667f), Qfmt15(0.29938434065514f), Qfmt15(-0.91781958879280f),
- Qfmt15(0.99298717043688f), Qfmt15(0.82368298622748f), Qfmt15(-0.98512833386833f), Qfmt15(-0.95915368242257f),
- Qfmt15(-0.21411126572790f), Qfmt15(-0.68821476106884f), Qfmt15(0.91851997982317f), Qfmt15(-0.96062769559127f),
- Qfmt15(0.51646184922287f), Qfmt15(0.61130721139669f), Qfmt15(0.47336129371299f), Qfmt15(0.90998308703519f),
- Qfmt15(0.44844799194357f), Qfmt15(0.66614891079092f), Qfmt15(0.74922239129237f), Qfmt15(-0.99571588506485f),
- Qfmt15(0.97401082477563f), Qfmt15(0.72683747733879f), Qfmt15(0.95432193457128f), Qfmt15(-0.72962208425191f),
- Qfmt15(-0.85359479233537f), Qfmt15(-0.81412430338535f), Qfmt15(-0.87930772356786f), Qfmt15(-0.71573331064977f),
- Qfmt15(0.83524300028228f), Qfmt15(-0.48086065601423f), Qfmt15(0.97139128574778f), Qfmt15(0.51992825347895f),
- Qfmt15(-0.00848591195325f), Qfmt15(-0.70294374303036f), Qfmt15(-0.95894428168140f), Qfmt15(0.97079252950321f),
- Qfmt15(-0.92404293670797f), Qfmt15(-0.69506469500450f), Qfmt15(0.26559203620024f), Qfmt15(0.28038443336943f),
- Qfmt15(-0.74138124825523f), Qfmt15(-0.01752795995444f), Qfmt15(-0.55126773094930f), Qfmt15(0.97960898850996f),
- Qfmt15(-0.99196309146936f), Qfmt15(-0.67684928085260f), Qfmt15(0.09140039465500f), Qfmt15(-0.71658965751996f),
- Qfmt15(0.81014640078925f), Qfmt15(0.40616991671205f), Qfmt15(-0.67680188682972f), Qfmt15(0.86849774348749f),
- Qfmt15(-0.99500381284851f), Qfmt15(0.84329189340667f), Qfmt15(-0.09215968531446f), Qfmt15(0.99956173327206f),
- Qfmt15(-0.79732779473535f), Qfmt15(0.96349973642406f), Qfmt15(-0.79942778496547f), Qfmt15(-0.11566039853896f),
- Qfmt15(-0.39922954514662f), Qfmt15(0.99089197565987f), Qfmt15(0.28631285179909f), Qfmt15(-0.83302725605608f),
- Qfmt15(0.95404443402072f), Qfmt15(-0.06449863579434f), Qfmt15(-0.99575054486311f), Qfmt15(-0.65501142790847f),
- Qfmt15(-0.81254441908887f), Qfmt15(-0.99646369485481f), Qfmt15(0.00287840603348f), Qfmt15(0.70176989408455f),
- Qfmt15(0.96361882270190f), Qfmt15(-0.68883758192426f), Qfmt15(-0.34875585502238f), Qfmt15(0.91980081243087f),
- Qfmt15(-0.99009048343881f), Qfmt15(0.68865791458395f), Qfmt15(-0.99484402129368f), Qfmt15(0.94214511408023f),
- Qfmt15(-0.67414626793544f), Qfmt15(-0.47339353684664f), Qfmt15(0.14323651387360f), Qfmt15(-0.29268293575672f),
- Qfmt15(0.43793861458754f), Qfmt15(-0.36345126374441f), Qfmt15(-0.08750604656825f), Qfmt15(-0.96495267812511f),
- Qfmt15(0.55526940659947f), Qfmt15(0.73538215752630f), Qfmt15(-0.30889773919437f), Qfmt15(0.03574995626194f),
- Qfmt15(0.98720684660488f), Qfmt15(-0.81689296271203f), Qfmt15(0.67866860118215f), Qfmt15(-0.15808569732583f),
- Qfmt15(0.80723395114371f), Qfmt15(0.47788757329038f), Qfmt15(0.96367554763201f), Qfmt15(-0.99143875716818f),
- Qfmt15(0.83081876925833f), Qfmt15(-0.58753191905341f), Qfmt15(0.95538108220960f), Qfmt15(-0.96490920476211f),
- Qfmt15(-0.97327101028521f), Qfmt15(0.91400366022124f), Qfmt15(-0.99925837363824f), Qfmt15(-0.86875903507313f),
- Qfmt15(-0.26240034795124f), Qfmt15(-0.24664412953388f), Qfmt15(0.02416275806869f), Qfmt15(0.82068619590515f),
- Qfmt15(0.88547373760759f), Qfmt15(-0.18173078152226f), Qfmt15(0.09355476558534f), Qfmt15(-0.54668414224090f),
- Qfmt15(0.37050990604091f), Qfmt15(-0.70373594262891f), Qfmt15(-0.34600785879594f), Qfmt15(-0.68774481731008f),
- Qfmt15(-0.26843291251234f), Qfmt15(0.49072334613242f), Qfmt15(0.38975993093975f), Qfmt15(-0.97757125224150f),
- Qfmt15(-0.17325552859616f), Qfmt15(0.99948035025744f), Qfmt15(-0.64946246527458f), Qfmt15(-0.12016920576437f),
- Qfmt15(-0.58947456517751f), Qfmt15(-0.41815140454465f), Qfmt15(0.99885650204884f), Qfmt15(-0.56649614128386f),
- Qfmt15(0.94138021032330f), Qfmt15(-0.75725076534641f), Qfmt15(0.20541973692630f), Qfmt15(0.99980371023351f),
- Qfmt15(0.29078277605775f), Qfmt15(-0.62858772103030f), Qfmt15(0.43440904467688f), Qfmt15(-0.98298583762390f),
- Qfmt15(0.19513029146934f), Qfmt15(-0.95476662400101f), Qfmt15(0.93379635304810f), Qfmt15(-0.85235410573336f),
- Qfmt15(-0.86425093011245f), Qfmt15(0.38879779059045f), Qfmt15(0.92045124735495f), Qfmt15(0.89162532251878f),
- Qfmt15(-0.36834336949252f), Qfmt15(0.93891760988045f), Qfmt15(0.99267657565094f), Qfmt15(-0.94063471614176f),
- Qfmt15(0.99740224117019f), Qfmt15(-0.35899413170555f), Qfmt15(0.05237237274947f), Qfmt15(0.36703583957424f),
- Qfmt15(0.91653180367913f), Qfmt15(0.69000803499316f), Qfmt15(-0.38658751133527f), Qfmt15(-0.29250814029851f),
- Qfmt15(-0.60182204677608f), Qfmt15(-0.97418588163217f), Qfmt15(0.88461574003963f), Qfmt15(0.05198933055162f),
- Qfmt15(-0.53499621979720f), Qfmt15(-0.49429560226497f), Qfmt15(-0.98935142339139f), Qfmt15(-0.98081380091130f),
- Qfmt15(-0.27338148835532f), Qfmt15(0.06310802338302f), Qfmt15(-0.20461677199539f), Qfmt15(0.66223843141647f),
- Qfmt15(-0.84764345483665f), Qfmt15(-0.89039863483811f), Qfmt15(0.95903308477986f), Qfmt15(0.73504123909879f),
- Qfmt15(-0.31744434966056f), Qfmt15(-0.34110827591623f), Qfmt15(0.47803883714199f), Qfmt15(0.98299195879514f),
- Qfmt15(-0.30963073129751f), Qfmt15(0.99992588229018f), Qfmt15(-0.93149731080767f), Qfmt15(0.99923472302773f),
- Qfmt15(-0.26024169633417f), Qfmt15(-0.35712514743563f), Qfmt15(-0.99899084509530f), Qfmt15(0.86557171579452f),
- Qfmt15(0.33408042438752f), Qfmt15(0.99010736374716f), Qfmt15(-0.66694269691195f), Qfmt15(0.64016792079480f),
- Qfmt15(0.99570534804836f), Qfmt15(-0.63431466947340f), Qfmt15(-0.07706847005931f), Qfmt15(0.98590090577724f),
- Qfmt15(0.80099335254678f), Qfmt15(0.78368131392666f), Qfmt15(0.08707806671691f), Qfmt15(-0.86811883080712f),
- Qfmt15(-0.39466529740375f), Qfmt15(0.97875325649683f), Qfmt15(-0.95038560288864f), Qfmt15(0.17005239424212f),
- Qfmt15(-0.76910792026848f), Qfmt15(0.99743281016846f), Qfmt15(0.95437383549973f), Qfmt15(0.99578905365569f),
- Qfmt15(0.28058259829990f), Qfmt15(0.85256524470573f), Qfmt15(-0.50608540105128f), Qfmt15(-0.97210735183243f),
- Qfmt15(0.95424048234441f), Qfmt15(-0.96926570524023f), Qfmt15(0.30872163214726f), Qfmt15(-0.24523839572639f),
- Qfmt15(-0.33813265086024f), Qfmt15(-0.05826828420146f), Qfmt15(-0.22898461455054f), Qfmt15(-0.18509915019881f),
- Qfmt15(-0.10488238045009f), Qfmt15(-0.71886586182037f), Qfmt15(0.99793873738654f), Qfmt15(0.57563307626120f),
- Qfmt15(0.28909646383717f), Qfmt15(0.42188998312520f), Qfmt15(0.93335049681047f), Qfmt15(-0.97087374418267f),
- Qfmt15(0.36722871286923f), Qfmt15(-0.81093025665696f), Qfmt15(-0.26240603062237f), Qfmt15(0.83996497984604f),
- Qfmt15(-0.99909615720225f), Qfmt15(0.74649464155061f), Qfmt15(-0.74774595569805f), Qfmt15(0.95781667469567f),
- Qfmt15(0.95472308713099f), Qfmt15(0.48708332746299f), Qfmt15(0.46332038247497f), Qfmt15(-0.76497004940162f),
- Qfmt15(0.57397389364339f), Qfmt15(0.75374316974495f), Qfmt15(-0.59174397685714f), Qfmt15(0.75087906691890f),
- Qfmt15(-0.98607857336230f), Qfmt15(-0.40761056640505f), Qfmt15(0.66929266740477f), Qfmt15(-0.97463695257310f),
- Qfmt15(0.90145509409859f), Qfmt15(-0.87259289048043f), Qfmt15(-0.91529461447692f), Qfmt15(-0.03305738840705f),
- Qfmt15(0.07223051368337f), Qfmt15(0.99498012188353f), Qfmt15(-0.74904939500519f), Qfmt15(0.04585228574211f),
- Qfmt15(-0.89054954257993f), Qfmt15(-0.83782144651251f), Qfmt15(0.33454804933804f), Qfmt15(-0.99707579362824f),
- Qfmt15(-0.22827527843994f), Qfmt15(0.67248046289143f), Qfmt15(-0.05146538187944f), Qfmt15(0.99947295749905f),
- Qfmt15(0.66951124390363f), Qfmt15(-0.99602956559179f), Qfmt15(0.82104905483590f), Qfmt15(0.99186510988782f),
- Qfmt15(-0.65284592392918f), Qfmt15(0.93885443798188f), Qfmt15(0.96735248738388f), Qfmt15(-0.22225968841114f),
- Qfmt15(-0.44132783753414f), Qfmt15(-0.85694974219574f), Qfmt15(0.91783042091762f), Qfmt15(0.72556974415690f),
- Qfmt15(-0.99711581834508f), Qfmt15(0.77638976371966f), Qfmt15(0.07717324253925f), Qfmt15(-0.56049829194163f),
- Qfmt15(0.98398893639988f), Qfmt15(0.47546946844938f), Qfmt15(0.65675089314631f), Qfmt15(0.03273375457980f),
- Qfmt15(-0.38684144784738f), Qfmt15(-0.97346267944545f), Qfmt15(-0.53282156061942f), Qfmt15(0.99817310731176f),
- Qfmt15(-0.50254500772635f), Qfmt15(0.01995873238855f), Qfmt15(0.99930381973804f), Qfmt15(0.82907767600783f),
- Qfmt15(-0.58660709669728f), Qfmt15(-0.17573736667267f), Qfmt15(0.83434292401346f), Qfmt15(0.05946491307025f),
- Qfmt15(0.81505484574602f), Qfmt15(-0.44976380954860f), Qfmt15(-0.89746474625671f), Qfmt15(0.39677256130792f),
- Qfmt15(-0.07588948563079f), Qfmt15(0.76343198951445f), Qfmt15(-0.74490104699626f), Qfmt15(0.64880119792759f),
- Qfmt15(0.62319537462542f), Qfmt15(0.42215817594807f), Qfmt15(0.02704554141885f), Qfmt15(0.80001773566818f),
- Qfmt15(-0.79351832348816f), Qfmt15(0.63872359151636f), Qfmt15(0.52890520960295f), Qfmt15(0.74238552914587f),
- Qfmt15(0.99096131449250f), Qfmt15(-0.80412329643109f), Qfmt15(-0.64612616129736f), Qfmt15(0.11657770663191f),
- Qfmt15(-0.95053182488101f), Qfmt15(-0.62228872928622f), Qfmt15(0.03004475787316f), Qfmt15(-0.97987214341034f),
- Qfmt15(-0.99986980746200f), Qfmt15(0.89110648599879f), Qfmt15(0.10407960510582f), Qfmt15(0.95964737821728f),
- Qfmt15(0.50843233159162f), Qfmt15(0.17006334670615f), Qfmt15(0.25872675063360f), Qfmt15(-0.01115998681937f),
- Qfmt15(-0.79598702973261f), Qfmt15(-0.99264708948101f), Qfmt15(-0.99829663752818f), Qfmt15(-0.70801016548184f),
- Qfmt15(-0.70467057786826f), Qfmt15(0.99846021905254f), Qfmt15(-0.63364968534650f), Qfmt15(-0.16258217500792f),
- Qfmt15(-0.43645594360633f), Qfmt15(-0.99848471702976f), Qfmt15(-0.16796458968998f), Qfmt15(-0.87979225745213f),
- Qfmt15(0.44183099021786f), Qfmt15(0.93310180125532f), Qfmt15(-0.93941931782002f), Qfmt15(-0.88590003188677f),
- Qfmt15(0.99971463703691f), Qfmt15(-0.75376385639978f), Qfmt15(0.93887685615875f), Qfmt15(0.85126435782309f),
- Qfmt15(0.39701421446381f), Qfmt15(-0.37024464187437f), Qfmt15(-0.36024828242896f), Qfmt15(-0.93388812549209f),
- Qfmt15(-0.65298804552119f), Qfmt15(0.11960319006843f), Qfmt15(0.94292565553160f), Qfmt15(0.75081145286948f),
- Qfmt15(0.56721979748394f), Qfmt15(0.46857766746029f), Qfmt15(0.97312313923635f), Qfmt15(-0.38299976567017f),
- Qfmt15(0.41025800019463f), Qfmt15(0.09638062008048f), Qfmt15(-0.85283249275397f), Qfmt15(0.88866808958124f),
- Qfmt15(-0.48202429536989f), Qfmt15(0.27572582416567f), Qfmt15(-0.65889129659168f), Qfmt15(0.98838086953732f),
- Qfmt15(-0.20651349620689f), Qfmt15(-0.62126416356920f), Qfmt15(0.20320105410437f), Qfmt15(-0.97790548600584f),
- Qfmt15(0.11112534735126f), Qfmt15(-0.41368337314182f), Qfmt15(0.24133038992960f), Qfmt15(-0.66393410674885f),
- Qfmt15(-0.53697829178752f), Qfmt15(-0.97224737889348f), Qfmt15(0.87392477144549f), Qfmt15(0.19050361015753f),
- Qfmt15(-0.46353441212724f), Qfmt15(-0.07064096339021f), Qfmt15(-0.92444085484466f), Qfmt15(-0.83822593578728f),
- Qfmt15(0.75214681811150f), Qfmt15(-0.42102998829339f), Qfmt15(-0.72094786237696f), Qfmt15(0.78843311019251f),
- Qfmt15(0.97394027897442f), Qfmt15(0.99206463477946f), Qfmt15(0.76789609461795f), Qfmt15(-0.82002421836409f),
- Qfmt15(0.81924990025724f), Qfmt15(-0.26719850873357f), Qfmt15(-0.43311260380975f), Qfmt15(0.99194979673836f),
- Qfmt15(-0.80692001248487f), Qfmt15(0.43080003649976f), Qfmt15(0.67709491937357f), Qfmt15(0.56151770568316f),
- Qfmt15(0.10831862810749f), Qfmt15(0.91229417540436f), Qfmt15(-0.48972893932274f), Qfmt15(-0.89033658689697f),
- Qfmt15(0.65269447475094f), Qfmt15(0.67439478141121f), Qfmt15(-0.47770832416973f), Qfmt15(-0.99715979260878f),
- Qfmt15(-0.90889593602546f), Qfmt15(-0.06618622548177f), Qfmt15(0.99430266919728f), Qfmt15(0.97686402381843f),
- Qfmt15(0.94813650221268f), Qfmt15(-0.95434497492853f), Qfmt15(-0.49104783137150f), Qfmt15(0.99881175120751f),
- Qfmt15(0.50449166760303f), Qfmt15(0.47162891065108f), Qfmt15(-0.62081581361840f), Qfmt15(-0.43867015250812f),
- Qfmt15(0.98630563232075f), Qfmt15(-0.61510362277374f), Qfmt15(-0.03841517601843f), Qfmt15(-0.30102157304644f),
- Qfmt15(0.41881284182683f), Qfmt15(-0.86135454941237f), Qfmt15(0.67226861393788f), Qfmt15(-0.70737398842068f),
- Qfmt15(0.94044946687963f), Qfmt15(-0.82386352534327f), Qfmt15(-0.32070666698656f), Qfmt15(0.57593163224487f),
- Qfmt15(-0.36326018419965f), Qfmt15(0.99979044674350f), Qfmt15(-0.92366023326932f), Qfmt15(-0.44607178518598f),
- Qfmt15(0.44226800932956f), Qfmt15(0.03671907158312f), Qfmt15(0.52175424682195f), Qfmt15(-0.94701139690956f),
- Qfmt15(-0.98759606946049f), Qfmt15(0.87434794743625f), Qfmt15(-0.93412041758744f), Qfmt15(0.96063943315511f),
- Qfmt15(0.97534253457837f), Qfmt15(0.99642466504163f), Qfmt15(-0.94705089665984f), Qfmt15(0.91599807087376f)
-};
-
-
-#ifdef HQ_SBR
-
-
-const Int32 fir_table[5][5] =
-{
- { Q30_fmt(1.0f)},
- { Q30_fmt(0.33333333333333f), Q30_fmt(0.66666666666666f)},
- { Q30_fmt(0.12500000000000f), Q30_fmt(0.37500000000000f),
- Q30_fmt(0.50000000000000f)},
- { Q30_fmt(0.05857864376269f), Q30_fmt(0.20000000000000f),
- Q30_fmt(0.34142135623731f), Q30_fmt(0.40000000000000f)},
- { Q30_fmt(0.03183050093751f), Q30_fmt(0.11516383427084f),
- Q30_fmt(0.21816949906249f), Q30_fmt(0.30150283239582f),
- Q30_fmt(0.33333333333333f)}
-};
-
-
-
-const Int32 rPxx[512] =
-{
-
- 0x8010B3DB, 0x7C4DA98F, 0x12168648, 0xC3D4D033,
- 0x674D25F5, 0xCE1972A6, 0xFEA5AA4A, 0x8B2DF13E,
- 0x46326048, 0x3336815E, 0x802A8F2B, 0x85B7745C,
- 0xC577B766, 0xA2A5828C, 0x60CB1AD1, 0x090C9BD7,
- 0x5F5A8B4D, 0x848D86BB, 0x26F1C0B7, 0x553352C1,
- 0x755E166B, 0xA5674343, 0xA654C5F5, 0x80A48CB4,
- 0x7DA69CD8, 0xBA04FCB4, 0xFDD4005E, 0x91C63676,
- 0x816A8F82, 0x423F55AA, 0x8077B59E, 0x80097DE9,
- 0x46BD4C18, 0x2C437971, 0x5035A0C2, 0x9D3ED49F,
- 0x8AC204B8, 0x9E5A8B0A, 0x662088B9, 0x45B9F0BC,
- 0x9261364F, 0x891B23AD, 0xF1028040, 0x1B568BE1,
- 0x9E787FB3, 0x7D94854D, 0x92077A94, 0x88903F45,
- 0x2705A5B4, 0x6D2B3BDC, 0x74E58034, 0xF8745A8C,
- 0x24592C54, 0x79EDB9BB, 0x9B6E9F44, 0x8563E5DA,
- 0x697C7BB7, 0xAC8F8E6A, 0x88227FD5, 0x7506822F,
- 0xA5E34B42, 0x00B94F10, 0x72004390, 0xA814676E,
- 0x5C5EA758, 0xAF721171, 0x2652C50C, 0x8A84A142,
- 0x7F19343E, 0x696EA13B, 0x81E68008, 0x853980F9,
- 0xE4968869, 0xA7E7DD92, 0x75910BFA, 0x85092E35,
- 0x421BA4A3, 0x4E3F3C18, 0x3C97DD02, 0x74797BCB,
- 0x39667EFD, 0x55447BA2, 0x5FE68CF3, 0x808B4390,
- 0x7CABEA6B, 0x5D08C27A, 0x7A265820, 0xA29A9DF0,
- 0x92BC7195, 0x97CA8338, 0x8F725FAD, 0xA46281D3,
- 0x6AE86B23, 0xC2728178, 0x7C566684, 0x428C66B7,
- 0xFEE89DDB, 0xA60546DC, 0x8540C89D, 0x7C420BF0,
- 0x89B86D72, 0xA7077E3F, 0x21FF5DD7, 0x23E3129C,
- 0xA1197F1D, 0xFDC0963F, 0xB96F8168, 0x7D6387A6,
- 0x810655C8, 0xA95C102B, 0x0BB3E5B4, 0xA44682D4,
- 0x67B244C3, 0x33FDDE1D, 0xA95D78F5, 0x6F2AE887,
- 0x80A3FC9F, 0x6BF00D52, 0xF4325902, 0x7FF1F02C,
- 0x99F08AC5, 0x7B537BB2, 0x99AB5255, 0xF1302497,
- 0xCCE4787B, 0x7ED58A28, 0x24A68B79, 0x955EA9D0,
- 0x7A1D3EED, 0xF7BD0429, 0x808A3642, 0xAC2769A8,
- 0x97FDBDE9, 0x80736C25, 0x005E52E7, 0x59D3E5D0,
- 0x7B57341A, 0xA7D374E9, 0xD35A5B7B, 0x75BB5520,
- 0x81446DE8, 0x5825473E, 0x80A8E653, 0x78978062,
- 0xA9B43F6B, 0xC366920A, 0x1255877D, 0xDA88075F,
- 0x380E9AFF, 0xD1795309, 0xF4CB7D09, 0x847BBAED,
- 0x471364FA, 0x5E207B74, 0xD87498BF, 0x0493836B,
- 0x7E5C3DF6, 0x976F8BBC, 0x56DE680A, 0xEBC26D28,
- 0x6753E05B, 0x3D2BC4B0, 0x7B593143, 0x8118E010,
- 0x6A5786AD, 0xB4CA01A7, 0x7A49927C, 0x847DAE0C,
- 0x836B0FD8, 0x74FD4A34, 0x80175AFC, 0x90CBE605,
- 0xDE68A89E, 0xE06C8FD0, 0x031822CE, 0x690B9315,
- 0x71568D43, 0xE8BBDE85, 0x0BFA4633, 0xBA057ADA,
- 0x2F6CB34F, 0xA5EB74C5, 0xD3B480B6, 0xA7F7D94A,
- 0xDDA26A63, 0x3ED0C5EF, 0x31E37A42, 0x82DE06CB,
- 0xE9D18940, 0x7FEE4A9A, 0xACDD57DD, 0xF09CB6D9,
- 0xB48BD364, 0xCA7814D5, 0x7FDA0E41, 0xB77C8C2A,
- 0x787E2D29, 0x9F1144AC, 0x1A4B871E, 0x7FF96630,
- 0x25382D4D, 0xAF89319E, 0x379A81DB, 0x822D1AE8,
- 0x18FA875E, 0x85C97DE7, 0x7786A544, 0x92E5F550,
- 0x915FC560, 0x31C47C82, 0x75D0B014, 0x72204656,
- 0xD0D87B76, 0x782E8CD6, 0x7F0FFB2F, 0x879834E7,
- 0x7FAAEA73, 0xD20BC44E, 0x06B4DF2C, 0x2EFBCE84,
- 0x7550D8D7, 0x5851746A, 0xCE837F5C, 0xDA8D2FEE,
- 0xB2F66F13, 0x834D7B7A, 0x713A499C, 0x06A81B39,
- 0xBB847C77, 0xC0B97DAC, 0x815CCC7A, 0x8274A2BD,
- 0xDD007FEF, 0x0814BA2F, 0xE5CDEDCE, 0x54C45CD5,
- 0x937F0309, 0x8E0671BF, 0x7AC1623B, 0x5E15FB32,
- 0xD75CD0D9, 0xD4553378, 0x3D30CD88, 0x7DD2028C,
- 0xD85CE8DB, 0x7FFDDE5A, 0x88C48228, 0x7FE6996A,
- 0xDEAF9EB7, 0xD24818B4, 0x80205F8B, 0x6ECA4728,
- 0x2AC36E51, 0x7EBB05E4, 0xAAA08AB1, 0x51F01408,
- 0x7F723AAE, 0xAECD1AFB, 0xF6218D55, 0x7E3170F2,
- 0x6686D0D3, 0x644F3A3F, 0x0B256799, 0x90E0325D,
- 0xCD7AAA7B, 0x7D47A33C, 0x865972A3, 0x15C445FE,
- 0x9D8D84D3, 0x7FAB36A7, 0x7A287C29, 0x7F75BABD,
- 0x23EA92BC, 0x6D20AD59, 0xBF37ABB6, 0x8391E26E,
- 0x7A2480F8, 0x83EE5E6E, 0x27843523, 0xE09A50E7,
- 0xD4B6CE82, 0xF889F71C, 0xE2AF7C3A, 0xE84D3CE2,
- 0xF2918FA6, 0xA3FB63E0, 0x7FBB7340, 0x49AE8B79,
- 0x25017B45, 0x36003DA1, 0x7777C844, 0x83B96EE4,
- 0x2F015392, 0x98320B3C, 0xDE68893F, 0x6B834779,
- 0x801D8516, 0x5F8C0F8C, 0xA049DD90, 0x7A999AD0,
- 0x7A33F500, 0x3E587FFF, 0x3B4E0E09, 0x9E147230,
- 0x49772D2B, 0x607A7BC7, 0xB4408D8F, 0x601CDA17,
- 0x81C7200B, 0xCBD28CBD, 0x55AB7E3E, 0x833EFFC0,
- 0x73627FB7, 0x904E7F04, 0x8AD7EBE6, 0xFBC3D05F,
- 0x093F8E53, 0x7F5B7C47, 0xA01E7FFA, 0x05DE7FC2,
- 0x8E01D74D, 0x94C17CF9, 0x2AD2919F, 0x805F7757,
- 0xE2C61829, 0x5613FB53, 0xF9688978, 0x7FEE77D6,
- 0x55B27E98, 0x8081C6D6, 0x69177F69, 0x7EF45C30,
- 0xAC6E42CC, 0x782BA021, 0x7BD17457, 0xE38B491E,
- 0xC781895B, 0x924E71B8, 0x757BC4A8, 0x5CDF8020,
- 0x805E4A82, 0x636078BA, 0x09E14B0E, 0xB84069A0,
- 0x7DF23284, 0x3CDC57D2, 0x54101777, 0x0431A015,
- 0xCE7A41B6, 0x8365846A, 0xBBCB8AF9, 0x7FC34E40,
- 0xBFAB8E4B, 0x028E6D15, 0x7FE8790F, 0x6A1EF7E6,
- 0xB4E97BF4, 0xE980C257, 0x6ACBEF53, 0x079C1A41,
- 0x685386CC, 0xC66D3458, 0x8D1F7FCD, 0x32C9A02E,
- 0xF6475ED7, 0x61B7356F, 0xA0A6793F, 0x530B34E9,
- 0x4FC488D4, 0x3609F61F, 0x0376F90F, 0x6666752C,
- 0x9A6DD1A5, 0x51C10A67, 0x43B34CDC, 0x5F0605C0,
- 0x7ED7E718, 0x99118EB3, 0xAD4A5C69, 0x0EEC94E8,
- 0x865483EA, 0xB05769F0, 0x03D88055, 0x82932EC1,
- 0x8003D1E3, 0x720F82B1, 0x0D526304, 0x7AD5D2A3,
- 0x41147B04, 0x15C49D9F, 0x211E7FDC, 0xFE907E12,
- 0x9A1C7C55, 0x80F08095, 0x80370267, 0xA55F2B1C,
- 0xA5CC7763, 0x7FCD81A1, 0xAEE3EAE8, 0xEB2F8532,
- 0xC82186A5, 0x80317B31, 0xEA7E814B, 0x8F62A430,
- 0x388D883A, 0x776F801B, 0x87C0B7CA, 0x8E9A3CF5,
- 0x7FF6949E, 0x9F83010B, 0x782CF18C, 0x6CF54301,
- 0x32D168AD, 0xD09A908B, 0xD1E22C5C, 0x887593DE,
- 0xAC6AE864, 0x0F4F7FDE, 0x78B16A72, 0x601AD283,
- 0x489AE12D, 0x3BFAD96A, 0x7C8E8093, 0xCEF87E19,
- 0x348302B6, 0x0C5605A6, 0x92D57516, 0x71BF8056,
- 0xC24C8416, 0x234B4B0D, 0xABA84B4F, 0x7E827FFD,
- 0xE58F45E1, 0xB079B355, 0x1A0290CA, 0x82D37B40,
- 0x0E391B80, 0xCB0B241E, 0x1EE441A8, 0xAB03F56F,
- 0xBB438301, 0x838C1C43, 0x6FDCEF9D, 0x1862020D,
- 0xC4A98614, 0xF6F38710, 0x89ABF29B, 0x94B4FDD3,
- 0x6046800E, 0xCA1A7FA4, 0xA3B7D32F, 0x64EB43A6,
- 0x7CA9DDD3, 0x7EFBB705, 0x624A9E0D, 0x9708A1E0,
- 0x68DC7F9C, 0xDDCB5832, 0xC88E6D35, 0x7EF77599,
- 0x98B6D63B, 0x3724E3F0, 0x56AA85C9, 0x47DFA582,
- 0x0DDDF4F3, 0x74C5AB88, 0xC14F480C, 0x8E08A446,
- 0x538B545F, 0x56529770, 0xC2D9EA81, 0x805C883B,
- 0x8BA84F67, 0xF785E183, 0x7F441814, 0x7D09DB4D,
- 0x795C8330, 0x85D79A19, 0xC1242A1B, 0x7FD871E9,
- 0x409391EC, 0x3C5EE815, 0xB0885FFF, 0xC7D87FFE,
- 0x7E3EBB6A, 0xB1438D6B, 0xFB13A68A, 0xD976F62D,
- 0x359B02CD, 0x91BE7EA6, 0x560CEEB8, 0xA5739E04,
- 0x78600B8E, 0x968A0B6C, 0xD6F1402E, 0x49B88152,
- 0xD17F0986, 0x7FF8EDE8, 0x89C48295, 0xC6E6BA93,
- 0x389C5B4C, 0x04B3516A, 0x42C892B0, 0x86C7FDA8,
- 0x81956954, 0x6FEA726E, 0x886E34F5, 0x7AF57730,
- 0x7CD76E45, 0x7F8A59D7, 0x86C6DA22, 0x753F825E
-};
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h b/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h
deleted file mode 100644
index 60e806d..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_calc_tbl.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ENVELOPE_CALC_TBL_H
-#define SBR_ENVELOPE_CALC_TBL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-extern const Int32 limGains[5];
-
-extern const Int32 smoothLengths[2];
-
-extern const Int16 rP_LCx[512];
-
-#ifdef HQ_SBR
-
-
-extern const Int32 fir_table[5][5];
-
-extern const Int32 rPxx[512];
-
-#endif
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp b/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp
deleted file mode 100644
index 7fce46b..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp
+++ /dev/null
@@ -1,427 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_unmapping.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_envelope_unmapping.h"
-#include "sbr_constants.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT 30
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*
- * 1./(1+2.^-[0:10])
- */
-const Int32 one_over_one_plus_two_to_n[11] =
-{
- Qfmt(0.50000000000000F), Qfmt(0.66666666666667F), Qfmt(0.80000000000000F),
- Qfmt(0.88888888888889F), Qfmt(0.94117647058824F), Qfmt(0.96969696969697F),
- Qfmt(0.98461538461538F), Qfmt(0.99224806201550F), Qfmt(0.99610894941634F),
- Qfmt(0.99805068226121F), Qfmt(0.99902439024390F)
-};
-
-/*
- * 1./(1+2.^[0.5:-1:-10.5])
- */
-const Int32 one_over_one_plus_sq_2_by_two_to_n[12] =
-{
- Qfmt(0.41421356237310F), Qfmt(0.58578643762690F), Qfmt(0.73879612503626F),
- Qfmt(0.84977889517767F), Qfmt(0.91878969685839F), Qfmt(0.95767628767521F),
- Qfmt(0.97838063800882F), Qfmt(0.98907219289563F), Qfmt(0.99450607818892F),
- Qfmt(0.99724547251514F), Qfmt(0.99862083678608F), Qfmt(0.99930994254211F)
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1,
- SBR_FRAME_DATA * hFrameData2)
-
-{
- Int32 i;
- Int32 tempLeft;
- Int32 tempRight;
-
- Int32 tmp;
- Int32 *iEnvelopeLeft_man = hFrameData1->iEnvelope_man;
- Int32 *iEnvelopeLeft_exp = hFrameData1->iEnvelope_exp;
- Int32 *noiseFloorLeft_man = hFrameData1->sbrNoiseFloorLevel_man;
- Int32 *noiseFloorLeft_exp = hFrameData1->sbrNoiseFloorLevel_exp;
-
- Int32 *iEnvelopeRight_man = hFrameData2->iEnvelope_man;
- Int32 *iEnvelopeRight_exp = hFrameData2->iEnvelope_exp;
- Int32 *noiseFloorRight_man = hFrameData2->sbrNoiseFloorLevel_man;
- Int32 *noiseFloorRight_exp = hFrameData2->sbrNoiseFloorLevel_exp;
-
-
- if (hFrameData2->ampRes)
- {
- for (i = 0; i < hFrameData1->nScaleFactors; i++)
- {
- tempRight = iEnvelopeRight_man[i];
- tempLeft = iEnvelopeLeft_man[i];
- /* iEnvelope[i] always positive 6 bits max */
-
- iEnvelopeLeft_exp[i] = tempLeft + 7;
-
- iEnvelopeRight_exp[i] = tempRight - 12;
- iEnvelopeRight_man[i] = Qfmt(1.000F);
-
- /*
- * iEnvelopeRight[i] = tempLeft / (1 + tempRight);
- * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i];
- *
- *
- * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m);
- * where k = 1 or sqrt(2)
- */
- if (iEnvelopeRight_exp[i] >= 0)
- {
- if (iEnvelopeRight_exp[i] < 11)
- {
- iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]];
- }
- else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */
- {
- iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
- }
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
- }
- else
- {
- if (iEnvelopeRight_exp[i] > -11)
- {
- iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]];
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
- }
- else /* 1/(1+2^m) == 2^-m ; for m >= 10 */
- {
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i];
- iEnvelopeLeft_exp[i] = 0;
- }
- }
-
- iEnvelopeLeft_man[i] = iEnvelopeRight_man[i];
- }
- }
- else
- {
- for (i = 0; i < hFrameData1->nScaleFactors; i++)
- {
- /* iEnvelope[i] always positive 7 bits max */
- tempRight = iEnvelopeRight_man[i];
- tempLeft = iEnvelopeLeft_man[i];
-
- iEnvelopeLeft_exp[i] = (tempLeft >> 1) + 7;
- if (tempLeft & 0x1) /* odd */
- {
- iEnvelopeLeft_man[i] = Qfmt(1.41421356237310F);
- }
- else
- {
- iEnvelopeLeft_man[i] = Qfmt(1.000F);
- }
-
- iEnvelopeRight_exp[i] = (tempRight >> 1) - 12;
- if (tempRight & 0x1) /* odd */
- {
- if (iEnvelopeRight_exp[i] > 0)
- {
- iEnvelopeRight_man[i] = Qfmt(1.41421356237310F);
- }
- else
- {
- iEnvelopeRight_man[i] = Qfmt(0.7071067811865F);
- }
- }
- else
- {
- iEnvelopeRight_man[i] = Qfmt(1.000F);
- }
-
- if (iEnvelopeRight_man[i] == Qfmt(1.000F))
- {
-
- /*
- * iEnvelopeRight[i] = tempLeft / (1 + tempRight);
- * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i];
- *
- *
- * iEnvelopeRight[i] = k*2^n/(1+2^m) = k*2^(n-m)/(1 + 2^-m);
- * where k = 1 or sqrt(2)
- */
- if (iEnvelopeRight_exp[i] >= 0)
- {
- if (iEnvelopeRight_exp[i] < 11)
- {
- iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]];
- }
- else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */
- {
- iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
- }
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
- }
- else
- {
- if (iEnvelopeRight_exp[i] > -11)
- {
- iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]];
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
- }
- else /* 1/(1+2^m) == 2^-m ; for m >= 10 */
- {
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i];
- iEnvelopeLeft_exp[i] = 0;
- }
- }
-
- /*
- * apply "k" factor 1 or sqrt(2)
- *
- * (2^m)*2*k*2^n/(1+2^m) = k*2^(n+1)/(1 + 2^-m);
- *
- */
- if (iEnvelopeLeft_man[i] != Qfmt(1.000F))
- {
- iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]);
- }
-
- iEnvelopeLeft_man[i] = iEnvelopeRight_man[i];
-
- }
- else
- {
-
- /*
- * iEnvelopeRight[i] = tempLeft / (1 + tempRight);
- * iEnvelopeLeft[i] = tempRight * iEnvelopeRight[i];
- *
- *
- * iEnvelopeRight[i] = k*2^n/(1+q2^m) = k*2^(n-m)/(1 + q2^-m);
- * where k = 1 or sqrt(2)
- * and q = sqrt(2)
- */
- if (iEnvelopeRight_exp[i] >= 0)
- {
- if (iEnvelopeRight_exp[i] < 12)
- {
- iEnvelopeRight_man[i] = one_over_one_plus_sq_2_by_two_to_n[ iEnvelopeRight_exp[i]];
- }
- else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 11 */
- {
- iEnvelopeRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
- }
- }
- else
- {
- if (iEnvelopeRight_exp[i] > -12)
- {
- iEnvelopeRight_man[i] = Qfmt(1.000F) - one_over_one_plus_sq_2_by_two_to_n[ -iEnvelopeRight_exp[i]];
- }
- else /* 1/(1+2^m) == 2^-m ; for m >= 11 */
- {
- iEnvelopeRight_man[i] = Qfmt(1.000F);
- iEnvelopeRight_exp[i] = 0;
- }
- }
-
- iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
- /*
- * apply "k" factor 1 or sqrt(2)
- *
- * Right == k*2^(n-m)/(1 + q2^-m)
- * Left == (q2^m)*k*2^n/(1 + q2^m) = qk*2^n/(1 + q2^-m);
- */
- if (iEnvelopeLeft_man[i] != Qfmt(1.000F))
- {
- /*
- * k/(1 + q2^-m);
- */
- tmp = iEnvelopeRight_man[i];
- iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]);
- iEnvelopeLeft_man[i] = tmp;
- iEnvelopeLeft_exp[i] += 1; /* extra one due to sqrt(2)^2 */
- }
- else
- {
- iEnvelopeLeft_man[i] = fxp_mul32_Q30(iEnvelopeRight_man[i], Qfmt(1.41421356237310F));
- }
-
- } /* end of if (iEnvelopeRight_man[i] == Qfmt( 1.000F) ) */
- } /* end of for loop */
- } /* end if (hFrameData2->ampRes) */
-
-
- for (i = 0; i < hFrameData1->nNoiseFactors; i++)
- {
-
- noiseFloorLeft_exp[i] = NOISE_FLOOR_OFFSET_PLUS_1 - noiseFloorLeft_man[i];
- noiseFloorRight_exp[i] = noiseFloorRight_man[i] - SBR_ENERGY_PAN_OFFSET_INT;
-
-
- /*
- * noiseFloorRight[i] = tempLeft / (1.0f + tempRight);
- * noiseFloorLeft[i] = tempRight*noiseFloorRight[i];
- *
- *
- * noiseFloorRight[i] = 2^n/(1+2^m) = 2^(n-m)/(1 + 2^-m);
- */
- if (noiseFloorRight_exp[i] >= 0)
- {
- if (noiseFloorRight_exp[i] < 11)
- {
- noiseFloorRight_man[i] = one_over_one_plus_two_to_n[ noiseFloorRight_exp[i]];
- }
- else /* 1/(1+2^-m) == 1 - 2^-m ; for m >= 10 */
- {
- noiseFloorRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> noiseFloorRight_exp[i]);
- }
- }
- else
- {
- if (noiseFloorRight_exp[i] > -11)
- {
- noiseFloorRight_man[i] = Qfmt(1.000F) - one_over_one_plus_two_to_n[ -noiseFloorRight_exp[i]];
- }
- else /* 1/(1+2^m) == 2^-m ; for m >= 10 */
- {
- noiseFloorRight_man[i] = Qfmt(1.000F);
- noiseFloorRight_exp[i] = 0;
- }
- }
-
- noiseFloorRight_exp[i] = noiseFloorLeft_exp[i] - noiseFloorRight_exp[i];
-
- /*
- * (2^m)*2^n/(1+2^m) = 2^n/(1 + 2^-m);
- */
-
- noiseFloorLeft_man[i] = noiseFloorRight_man[i];
- noiseFloorLeft_exp[i] = noiseFloorLeft_exp[i];
-
- }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h b/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h
deleted file mode 100644
index b949830..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_unmapping.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ENVELOPE_UNMAPPING_H
-#define SBR_ENVELOPE_UNMAPPING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define UNMAPPING_SCALE_INT (-18) /* factor's 2-exponent */
-#define SBR_ENERGY_PAN_OFFSET_INT 12
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1,
- SBR_FRAME_DATA * hFrameData2);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp b/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp
deleted file mode 100644
index 92b22f7..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_extract_extended_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- SBR_FRAME_DATA *hFrameData, Destination for extracted data of left channel
- SBR_FRAME_DATA *hFrameDataRight Destination for extracted data of right channel
- BIT_BUFFER hBitBuf pointer to bit buffer
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads extension data from the bitstream
-
- The bitstream format allows up to 4 kinds of extended data element.
- Extended data may contain several elements, each identified by a 2-bit-ID.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_extract_extended_data.h"
-#include "buf_getbits.h"
-
-#ifdef PARAMETRICSTEREO
-#include "ps_read_data.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_extract_extended_data(BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */
- , HANDLE_PS_DEC hParametricStereoDec
-#endif
- )
-{
- Int32 extended_data;
- Int32 i;
- Int32 nBitsLeft;
- Int32 extension_id;
-
- extended_data = buf_get_1bit(hBitBuf); /* SI_SBR_EXTENDED_DATA_BITS */
-
- if (extended_data)
- {
- Int32 cnt;
-
- cnt = buf_getbits(hBitBuf, SI_SBR_EXTENSION_SIZE_BITS);
- if (cnt == (1 << SI_SBR_EXTENSION_SIZE_BITS) - 1)
- {
- cnt += buf_getbits(hBitBuf, SI_SBR_EXTENSION_ESC_COUNT_BITS);
- }
-
- nBitsLeft = (cnt << 3);
- while (nBitsLeft > 7)
- {
- extension_id = buf_getbits(hBitBuf, SI_SBR_EXTENSION_ID_BITS);
- nBitsLeft -= SI_SBR_EXTENSION_ID_BITS;
-
- switch (extension_id)
- {
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
- /*
- * Parametric Coding supports the Transient, Sinusoidal, Noise, and
- * Parametric Stereo tools (MPEG4).
- * 3GPP use aac+ hq along with ps for enhanced aac+
- * The PS tool uses complex-value QMF data, therefore can not be used
- * with low power version of aac+
- */
- case EXTENSION_ID_PS_CODING:
-
- if (hParametricStereoDec != NULL)
- {
- if (!hParametricStereoDec->psDetected)
- {
- /* parametric stereo detected */
- hParametricStereoDec->psDetected = 1;
- }
-
- nBitsLeft -= ps_read_data(hParametricStereoDec,
- hBitBuf,
- nBitsLeft);
-
- }
-
- break;
-#endif
-#endif
- case 0:
-
- default:
- /* An unknown extension id causes the remaining extension data
- * to be skipped
- */
- cnt = nBitsLeft >> 3; /* number of remaining bytes */
-
- for (i = 0; i < cnt; i++)
- {
- buf_getbits(hBitBuf, 8);
- }
-
- nBitsLeft -= (cnt << 3);
- }
- }
- /* read fill bits for byte alignment */
- buf_getbits(hBitBuf, nBitsLeft);
- }
-}
-
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h b/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h
deleted file mode 100644
index bbca3b9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_extract_extended_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_EXTRACT_EXTENDED_DATA_H
-#define SBR_EXTRACT_EXTENDED_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-
-#ifdef PARAMETRICSTEREO
-#include "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_extract_extended_data(BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO /* Parametric Stereo Decoder */
- , HANDLE_PS_DEC hParametricStereoDec
-#endif
- );
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp b/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp
deleted file mode 100644
index fc3d38f..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_find_start_andstop_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_find_start_andstop_band.h"
-#include "get_sbr_startfreq.h"
-#include "get_sbr_stopfreq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq,
- const Int32 startFreq,
- const Int32 stopFreq,
- Int *lsbM,
- Int *usb)
-{
- /* Update startFreq struct */
- *lsbM = get_sbr_startfreq(samplingFreq, startFreq);
-
- if (*lsbM == 0)
- {
- return(SBRDEC_ILLEGAL_SCFACTORS);
- }
-
- /*Update stopFreq struct */
- if (stopFreq < 13)
- {
- *usb = get_sbr_stopfreq(samplingFreq, stopFreq);
- }
- else if (stopFreq == 13)
- {
- *usb = 64;
- }
- else if (stopFreq == 14)
- {
- *usb = (*lsbM) << 1;
- }
- else
- {
- *usb = 3 * *lsbM;
- }
-
- /* limit to Nyqvist */
- if (*usb > 64)
- {
- *usb = 64;
- }
-
- /* test for invalid lsb, usb combinations */
- if ((*usb - *lsbM) > 48)
- {
- /*
- * invalid SBR bitstream ?
- */
- return(SBRDEC_INVALID_BITSTREAM);
- }
-
- if ((samplingFreq == 44100) && ((*usb - *lsbM) > 35))
- {
- /*
- * invalid SBR bitstream ?
- */
- return(SBRDEC_INVALID_BITSTREAM);
- }
-
- if ((samplingFreq >= 48000) && ((*usb - *lsbM) > 32))
- {
- /*
- * invalid SBR bitstream ?
- */
- return(SBRDEC_INVALID_BITSTREAM);
- }
-
- return(SBRDEC_OK);
-
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h b/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h
deleted file mode 100644
index 88283c6..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: sbr_find_start_andstop_band.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_FIND_START_ANDSTOP_BAND_H
-#define SBR_FIND_START_ANDSTOP_BAND_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq,
- const Int32 startFreq,
- const Int32 stopFreq,
- Int *lsbM,
- Int *usb);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp b/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp
deleted file mode 100644
index 2126e47..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp
+++ /dev/null
@@ -1,1040 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_generate_high_freq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- HF generator with built-in QMF bank inverse filtering function
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-
-#include "sbr_generate_high_freq.h"
-#include "calc_auto_corr.h"
-#include "sbr_inv_filt_levelemphasis.h"
-#include "pv_div.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-#include "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void high_freq_coeff_LC(Int32 sourceBufferReal[][32],
- Int32 *alphar[2],
- Int32 *degreeAlias,
- Int32 *v_k_master,
- Int32 *scratch_mem);
-
-
- void high_freq_generation_LC(Int32 sourceBufferReal[][32],
- Int32 *targetBufferReal,
- Int32 *alphar[2],
- Int32 *degreeAlias,
- Int32 *invFiltBandTable,
- Int32 targetStopBand,
- Int32 patchDistance,
- Int32 numBandsInPatch,
- Int32 startSample,
- Int32 slopeLength,
- Int32 stopSample,
- Int32 *BwVector,
- Int32 sbrStartFreqOffset);
-
-
-#ifdef HQ_SBR
-
- void high_freq_coeff(Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *alphar[2],
- Int32 *alphai[2],
- Int32 *v_k_master);
-
- void high_freq_generation(Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *targetBufferReal,
- Int32 *targetBufferImag,
- Int32 *alphar[2],
- Int32 *alphai[2],
- Int32 *invFiltBandTable,
- Int32 targetStopBand,
- Int32 patchDistance,
- Int32 numBandsInPatch,
- Int32 startSample,
- Int32 slopeLength,
- Int32 stopSample,
- Int32 *BwVector,
- Int32 sbrStartFreqOffset);
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_generate_high_freq(Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *targetBufferReal,
- Int32 *targetBufferImag,
- INVF_MODE *invFiltMode,
- INVF_MODE *prevInvFiltMode,
- Int32 *invFiltBandTable,
- Int32 noInvFiltBands,
- Int32 highBandStartSb,
- Int32 *v_k_master,
- Int32 numMaster,
- Int32 fs,
- Int32 *frameInfo,
- Int32 *degreeAlias,
- Int32 scratch_mem[][64],
- Int32 BwVector[MAX_NUM_PATCHES],
- Int32 BwVectorOld[MAX_NUM_PATCHES],
- struct PATCH *Patch,
- Int32 LC_flag,
- Int32 *highBandStopSb)
-{
- Int32 i;
- Int32 patch;
- Int32 startSample;
- Int32 stopSample;
- Int32 goalSb;
- Int32 targetStopBand;
- Int32 sourceStartBand;
- Int32 patchDistance;
- Int32 numBandsInPatch;
- Int32 sbrStartFreqOffset;
-
- Int32 *alphar[2];
- Int32 *alphai[2];
-
- Int32 lsb = v_k_master[0]; /* Lowest subband related to the synthesis filterbank */
- Int32 usb = v_k_master[numMaster]; /* Stop subband related to the synthesis filterbank */
- Int32 xoverOffset = highBandStartSb - v_k_master[0]; /* Calculate distance in subbands between k0 and kx */
-
-
-
- Int slopeLength = 0;
-
- Int32 firstSlotOffs = frameInfo[1];
- Int32 lastSlotOffs = frameInfo[frameInfo[0] + 1] - 16;
-
-
- alphar[0] = scratch_mem[0];
- alphar[1] = scratch_mem[1];
- alphai[0] = scratch_mem[2];
- alphai[1] = scratch_mem[3];
-
-
- startSample = (firstSlotOffs << 1);
- stopSample = (lastSlotOffs << 1) + 32;
-
-
- sbr_inv_filt_levelemphasis(invFiltMode,
- prevInvFiltMode,
- noInvFiltBands,
- BwVector,
- BwVectorOld);
-
-
- if (LC_flag == ON)
- {
- /* Set subbands to zero */
-
- pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS],
- 0,
- (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0]));
-
- high_freq_coeff_LC(sourceBufferReal,
- alphar,
- degreeAlias,
- v_k_master,
- scratch_mem[4]);
- }
-#ifdef HQ_SBR
- else
- {
- /* Set subbands to zero */
-
- pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS],
- 0,
- (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0]));
- pv_memset((void *)&targetBufferImag[startSample*SBR_NUM_BANDS],
- 0,
- (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferImag[0]));
-
- high_freq_coeff(sourceBufferReal,
- sourceBufferImag,
- alphar,
- alphai,
- v_k_master);
-
- }
-#endif /* #ifdef HQ_SBR */
-
-
-
-
- /*
- * Initialize the patching parameter
- */
- switch (fs)
-
- {
- /*
- * goalSb = (int)( 2.048e6f / fs + 0.5f );
- */
- case 48000:
- goalSb = 43; /* 16 kHz band */
- break;
- case 32000:
- goalSb = 64; /* 16 kHz band */
- break;
- case 24000:
- goalSb = 85; /* 16 kHz band */
- break;
- case 22050:
- goalSb = 93; /* 16 kHz band */
- break;
- case 16000:
- goalSb = 128; /* 16 kHz band */
- break;
- case 44100:
- default:
- goalSb = 46; /* 16 kHz band */
- break;
- }
-
- i = 0;
-
- if (goalSb > v_k_master[0])
- {
- if (goalSb < v_k_master[numMaster])
- {
- while (v_k_master[i] < goalSb)
- {
- i++;
- }
- }
- else
- {
- i = numMaster;
- }
- }
-
- goalSb = v_k_master[i];
-
- /* First patch */
- sourceStartBand = xoverOffset + 1;
- targetStopBand = lsb + xoverOffset;
-
- /* even (odd) numbered channel must be patched to even (odd) numbered channel */
- patch = 0;
-
-
- sbrStartFreqOffset = targetStopBand;
-
- while (targetStopBand < usb)
- {
- Patch->targetStartBand[patch] = targetStopBand;
-
- numBandsInPatch = goalSb - targetStopBand; /* get the desired range of the patch */
-
- if (numBandsInPatch >= lsb - sourceStartBand)
- {
- /* desired number bands are not available -> patch whole source range */
- patchDistance = targetStopBand - sourceStartBand; /* get the targetOffset */
- patchDistance = patchDistance & ~1; /* rounding off odd numbers and make all even */
- numBandsInPatch = lsb - (targetStopBand - patchDistance);
-
- if (targetStopBand + numBandsInPatch > v_k_master[0])
- {
- i = numMaster;
- if (targetStopBand + numBandsInPatch < v_k_master[numMaster])
- {
- while (v_k_master[i] > targetStopBand + numBandsInPatch)
- {
- i--;
- }
- }
- }
- else
- {
- i = 0;
- }
- numBandsInPatch = v_k_master[i] - targetStopBand;
- }
-
- /* desired number bands are available -> get the minimal even patching distance */
- patchDistance = numBandsInPatch + targetStopBand - lsb; /* get minimal distance */
- patchDistance = (patchDistance + 1) & ~1; /* rounding up odd numbers and make all even */
-
- /* All patches but first */
- sourceStartBand = 1;
-
- /* Check if we are close to goalSb */
- if (goalSb - (targetStopBand + numBandsInPatch) < 3)
- { /* MPEG doc */
- goalSb = usb;
- }
-
-
- if ((numBandsInPatch < 3) && (patch > 0))
- {
- if (LC_flag == ON)
- {
-
- pv_memset((void *) &degreeAlias[targetStopBand], 0, numBandsInPatch*sizeof(*degreeAlias));
- }
- break;
- }
-
- if (numBandsInPatch <= 0)
- {
- continue;
- }
-
-
- /*
- * High Frequency generation
- */
-
- if (LC_flag == ON)
- {
-
- high_freq_generation_LC(sourceBufferReal,
- (Int32 *)targetBufferReal,
- alphar,
- degreeAlias,
- invFiltBandTable,
- targetStopBand,
- patchDistance,
- numBandsInPatch,
- startSample,
- slopeLength,
- stopSample,
- BwVector,
- sbrStartFreqOffset);
-
- }
-#ifdef HQ_SBR
- else
- {
-
- high_freq_generation(sourceBufferReal,
- sourceBufferImag,
- (Int32 *)targetBufferReal,
- (Int32 *)targetBufferImag,
- alphar,
- alphai,
- invFiltBandTable,
- targetStopBand,
- patchDistance,
- numBandsInPatch,
- startSample,
- slopeLength,
- stopSample,
- BwVector,
- sbrStartFreqOffset);
-
- }
-#endif
-
- targetStopBand += numBandsInPatch;
-
- patch++;
-
- } /* targetStopBand */
-
- Patch->noOfPatches = patch;
-
- pv_memmove(BwVectorOld, BwVector, noInvFiltBands*sizeof(BwVector[0]));
-
- *highBandStopSb = goalSb;
-
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void high_freq_coeff_LC(Int32 sourceBufferReal[][32],
- Int32 *alphar[2],
- Int32 *degreeAlias,
- Int32 *v_k_master,
- Int32 *scratch_mem)
-{
-
- Int32 fac;
- Int32 *k1;
- struct ACORR_COEFS ac;
- struct intg_div quotient;
-
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 autoCorrLength;
- Int32 loBand;
-
- k1 = scratch_mem;
-
-
- autoCorrLength = 38;
-
- for (loBand = 1; loBand < v_k_master[0]; loBand++)
- {
-
- calc_auto_corr_LC(&ac,
- sourceBufferReal,
- loBand,
- autoCorrLength);
-
- if (ac.r11r && ac.det)
- {
-
- pv_div(ac.r01r, ac.r11r, &quotient);
-
- fac = -(quotient.quotient >> 2); /* Q28 */
-
- if (quotient.shift_factor > 0)
- {
- fac >>= quotient.shift_factor; /* Q28 */
- }
- else if (quotient.shift_factor < 0)
- {
- if (quotient.shift_factor > -4) /* |fac| < 8 */
- {
- fac <<= (-quotient.shift_factor); /* Q28 */
- }
- else
- {
- fac = 0x80000000; /* overshoot possible fac = -8 */
- }
- }
-
- /*
- * prevent for overflow of reflection coefficients
- */
- if (quotient.shift_factor > 0)
- {
- k1[loBand] = - quotient.quotient >> quotient.shift_factor;
- }
- else if (quotient.shift_factor == 0)
- {
- if (quotient.quotient >= 0x40000000)
- {
- k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */
- }
- else if (quotient.quotient <= (Int32)0xC0000000)
- {
- k1[loBand] = 0x40000000; /* 1.0 in Q30 */
- }
- else
- {
- k1[loBand] = -quotient.quotient;
- }
- }
- else
- {
- if (quotient.quotient > 0)
- {
- k1[loBand] = (Int32)0xC0000000; /* -1.0 in Q30 */
- }
- else
- {
- k1[loBand] = 0x40000000; /* 1.0 in Q30 */
- }
- }
- /*
- * alphar[1][loBand] = ( ac.r01r * ac.r12r - ac.r02r * ac.r11r ) / ac.det;
- */
-
- temp1 = -fxp_mul32_Q30(ac.r02r, ac.r11r);
- temp1 = fxp_mac32_Q30(ac.r01r, ac.r12r, temp1);
-
- temp2 = ac.det;
- temp3 = temp1 > 0 ? temp1 : -temp1;
- temp2 = temp2 > 0 ? temp2 : -temp2;
-
- /* prevent for shootovers */
- if ((temp3 >> 2) >= temp2 || fac == (Int32)0x80000000)
- {
- alphar[0][loBand] = 0;
- alphar[1][loBand] = 0;
- }
- else
- {
- pv_div(temp1, ac.det, &quotient);
- /*
- * alphar[1][loBand] is lesser than 4.0
- */
- alphar[1][loBand] = quotient.quotient;
- quotient.shift_factor += 2; /* Q28 */
-
- if (quotient.shift_factor > 0)
- {
- alphar[1][loBand] >>= quotient.shift_factor; /* Q28 */
- }
- else if (quotient.shift_factor < 0) /* at this point can only be -1 */
- {
- alphar[1][loBand] <<= (-quotient.shift_factor); /* Q28 */
- }
-
- /*
- * alphar[0][loBand] = - ( ac.r01r + alphar[1][loBand] * ac.r12r ) / ac.r11r;
- */
-
- pv_div(ac.r12r, ac.r11r, &quotient);
-
- temp3 = (quotient.quotient >> 2); /* Q28 */
-
- if (quotient.shift_factor > 0)
- {
- temp3 >>= quotient.shift_factor; /* Q28 */
- }
- else if (quotient.shift_factor < 0)
- {
- temp3 <<= (-quotient.shift_factor); /* Q28 */
- }
-
- alphar[0][loBand] = fac - fxp_mul32_Q28(alphar[1][loBand], temp3) ; /* Q28 */
-
- if ((alphar[0][loBand] >= 0x40000000) || (alphar[0][loBand] <= (Int32)0xC0000000))
- {
- alphar[0][loBand] = 0;
- alphar[1][loBand] = 0;
- }
-
- }
-
- }
- else
- {
- alphar[0][loBand] = 0;
- alphar[1][loBand] = 0;
-
- k1[loBand] = 0;
- }
-
- }
-
- k1[0] = 0;
- degreeAlias[1] = 0;
- for (loBand = 2; loBand < v_k_master[0]; loBand++)
- {
- degreeAlias[loBand] = 0;
- if ((!(loBand & 1)) && (k1[loBand] < 0))
- {
- if (k1[loBand-1] < 0)
- { // 2-CH Aliasing Detection
- degreeAlias[loBand] = 0x40000000;
- if (k1[loBand-2] > 0)
- { // 3-CH Aliasing Detection
- degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
-
- }
- }
- else if (k1[loBand-2] > 0)
- { // 3-CH Aliasing Detection
- degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
- }
- }
- if ((loBand & 1) && (k1[loBand] > 0))
- {
- if (k1[loBand-1] > 0)
- { // 2-CH Aliasing Detection
- degreeAlias[loBand] = 0x40000000;
- if (k1[loBand-2] < 0)
- { // 3-CH Aliasing Detection
- degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
- }
- }
- else if (k1[loBand-2] < 0)
- { // 3-CH Aliasing Detection
- degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
- }
- }
- }
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void high_freq_generation_LC(Int32 sourceBufferReal[][32],
- Int32 *targetBufferReal,
- Int32 *alphar[2],
- Int32 *degreeAlias,
- Int32 *invFiltBandTable,
- Int32 targetStopBand,
- Int32 patchDistance,
- Int32 numBandsInPatch,
- Int32 startSample,
- Int32 slopeLength,
- Int32 stopSample,
- Int32 *BwVector,
- Int32 sbrStartFreqOffset)
-{
-
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
-
-
- Int32 a0r;
- Int32 a1r;
- Int32 i;
- Int32 bw;
- Int32 hiBand;
- Int32 bwIndex;
- Int32 loBand;
- Int32 j;
-
- bwIndex = 0;
-
- for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++)
- {
- loBand = hiBand - patchDistance;
-
- if (hiBand != targetStopBand)
- {
- degreeAlias[hiBand] = degreeAlias[loBand];
- }
- else
- {
- degreeAlias[hiBand] = 0;
- }
-
- while (hiBand >= invFiltBandTable[bwIndex])
- {
- bwIndex++;
- }
-
- bw = BwVector[bwIndex];
-
- /*
- * Inverse Filtering
- */
-
-
- j = hiBand - sbrStartFreqOffset;
-
- if (bw > 0 && (alphar[0][loBand] | alphar[1][loBand]))
- {
- /* Apply current bandwidth expansion factor */
- a0r = fxp_mul32_Q29(bw, alphar[0][loBand]);
-
- bw = fxp_mul32_Q31(bw, bw) << 2;
-
- a1r = fxp_mul32_Q28(bw, alphar[1][loBand]);
-
- i = startSample + slopeLength;
-
- temp1 = sourceBufferReal[i ][loBand];
- temp2 = sourceBufferReal[i - 1][loBand];
- temp3 = sourceBufferReal[i - 2][loBand];
-
- for (; i < stopSample + slopeLength - 1; i++)
- {
-
-
- targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) +
- fxp_mul32_Q28(a1r, temp3);
-
-
- temp3 = temp2;
- temp2 = temp1;
- temp1 = sourceBufferReal[i + 1][loBand];
- }
- targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2) +
- fxp_mul32_Q28(a1r, temp3);
-
- }
- else
- {
-
- for (i = startSample + slopeLength; i < stopSample + slopeLength; i++)
- {
- targetBufferReal[i*SBR_NUM_BANDS + j] = sourceBufferReal[i][loBand];
- }
- }
-
-
- } /* hiBand */
-
-}
-
-
-#ifdef HQ_SBR
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void high_freq_coeff(Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *alphar[2],
- Int32 *alphai[2],
- Int32 *v_k_master)
-{
-
- Int32 overflow_flag;
-
- Int32 temp1r;
- Int32 temp1i;
- Int32 temp0r;
- Int32 temp0i;
- Int32 loBand;
-
- struct ACORR_COEFS ac;
- struct intg_div quotient;
-
- Int32 autoCorrLength;
-
- autoCorrLength = 38;
-
- for (loBand = 1; loBand < v_k_master[0]; loBand++)
- {
-
- calc_auto_corr(&ac,
- sourceBufferReal,
- sourceBufferImag,
- loBand,
- autoCorrLength);
-
-
- overflow_flag = 0;
-
- if (ac.det < 1)
- {
- /* --- */
- temp1r = 0;
- temp1i = 0;
- alphar[1][loBand] = 0;
- alphai[1][loBand] = 0;
-
- }
- else
- {
-
- temp1r = fxp_mul32_Q29(ac.r01r, ac.r12r);
- temp1r = fxp_msu32_Q29(ac.r01i, ac.r12i, temp1r);
- temp1r = fxp_msu32_Q29(ac.r02r, ac.r11r, temp1r);
-
- temp1i = fxp_mul32_Q29(ac.r01r, ac.r12i);
- temp1i = fxp_msu32_Q29(ac.r02i, ac.r11r, temp1i);
- temp1i = fxp_mac32_Q29(ac.r01i, ac.r12r, temp1i);
-
- pv_div(temp1r, ac.det, &quotient);
- overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
- temp1r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */
- pv_div(temp1i, ac.det, &quotient);
- overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
- temp1i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */
-
- alphar[1][loBand] = temp1r;
- alphai[1][loBand] = temp1i;
-
- }
-
- if (ac.r11r == 0)
- {
- temp0r = 0;
- temp0i = 0;
- alphar[0][loBand] = 0;
- alphai[0][loBand] = 0;
-
- }
- else
- {
- temp0r = - (ac.r01r + fxp_mul32_Q28(temp1r, ac.r12r) + fxp_mul32_Q28(temp1i, ac.r12i));
- temp0i = - (ac.r01i + fxp_mul32_Q28(temp1i, ac.r12r) - fxp_mul32_Q28(temp1r, ac.r12i));
-
- pv_div(temp0r, ac.r11r, &quotient);
- overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
- temp0r = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */
- pv_div(temp0i, ac.r11r, &quotient);
- overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
- temp0i = quotient.quotient >> (2 + quotient.shift_factor); /* Q28 */
-
- alphar[0][loBand] = temp0r;
- alphai[0][loBand] = temp0i;
-
- }
-
- /* prevent for shootovers */
-
- if (fxp_mul32_Q28((temp0r >> 2), (temp0r >> 2)) + fxp_mul32_Q28((temp0i >> 2), (temp0i >> 2)) >= 0x10000000 ||
- fxp_mul32_Q28((temp1r >> 2), (temp1r >> 2)) + fxp_mul32_Q28((temp1i >> 2), (temp1i >> 2)) >= 0x10000000 ||
- overflow_flag) /* 0x10000000 == 1 in Q28 */
-
- {
- alphar[0][loBand] = 0;
- alphar[1][loBand] = 0;
- alphai[0][loBand] = 0;
- alphai[1][loBand] = 0;
-
- }
- }
-}
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void high_freq_generation(Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *targetBufferReal,
- Int32 *targetBufferImag,
- Int32 *alphar[2],
- Int32 *alphai[2],
- Int32 *invFiltBandTable,
- Int32 targetStopBand,
- Int32 patchDistance,
- Int32 numBandsInPatch,
- Int32 startSample,
- Int32 slopeLength,
- Int32 stopSample,
- Int32 *BwVector,
- Int32 sbrStartFreqOffset)
-{
- Int32 temp1_r;
- Int32 temp2_r;
- Int32 temp3_r;
- Int32 temp1_i;
- Int32 temp2_i;
- Int32 temp3_i;
-
-
- Int32 a0i;
- Int32 a1i;
- Int32 a0r;
- Int32 a1r;
- Int32 i;
- Int32 bw;
- Int32 hiBand;
- Int32 bwIndex;
- Int32 loBand;
- Int32 j;
-
-
-
- int64_t tmp;
-
- bwIndex = 0;
-
- for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++)
- {
-
- loBand = hiBand - patchDistance;
-
- while (hiBand >= invFiltBandTable[bwIndex])
- {
- bwIndex++;
- }
-
- bw = BwVector[bwIndex];
-
- /*
- * Inverse Filtering
- */
-
-
- j = hiBand - sbrStartFreqOffset;
-
- if (bw >= 0 && (alphar[0][loBand] | alphar[1][loBand] |
- alphai[0][loBand] | alphai[1][loBand]))
- {
- /* Apply current bandwidth expansion factor */
- a0r = fxp_mul32_Q29(bw, alphar[0][loBand]);
- a0i = fxp_mul32_Q29(bw, alphai[0][loBand]);
-
-
- bw = fxp_mul32_Q30(bw, bw);
-
-
- a1r = fxp_mul32_Q28(bw, alphar[1][loBand]);
- a1i = fxp_mul32_Q28(bw, alphai[1][loBand]);
-
-
- i = startSample + slopeLength;
- j += i * SBR_NUM_BANDS;
-
- temp1_r = sourceBufferReal[i ][loBand];
- temp2_r = sourceBufferReal[i - 1][loBand];
- temp3_r = sourceBufferReal[i - 2][loBand];
-
- temp1_i = sourceBufferImag[i ][loBand];
- temp2_i = sourceBufferImag[i - 1][loBand];
- temp3_i = sourceBufferImag[i - 2][loBand];
-
- while (i < stopSample + slopeLength)
- {
- tmp = fxp_mac64_Q31(((int64_t)temp1_r << 28), a0r, temp2_r);
- tmp = fxp_mac64_Q31(tmp, -a0i, temp2_i);
- tmp = fxp_mac64_Q31(tmp, a1r, temp3_r);
- targetBufferReal[j] = (Int32)(fxp_mac64_Q31(tmp, -a1i, temp3_i) >> 28);
-
- tmp = fxp_mac64_Q31(((int64_t)temp1_i << 28), a0i, temp2_r);
- tmp = fxp_mac64_Q31(tmp, a0r, temp2_i);
- tmp = fxp_mac64_Q31(tmp, a1i, temp3_r);
- targetBufferImag[j] = (Int32)(fxp_mac64_Q31(tmp, a1r, temp3_i) >> 28);
-
- i++;
- j += SBR_NUM_BANDS;
-
- temp3_r = temp2_r;
- temp2_r = temp1_r;
- temp1_r = sourceBufferReal[i ][loBand];
-
- temp3_i = temp2_i;
- temp2_i = temp1_i;
- temp1_i = sourceBufferImag[i ][loBand];
-
- }
-
- }
-
-
-
- else
- {
- i = startSample + slopeLength;
- j += i * SBR_NUM_BANDS;
-
- for (; i < stopSample + slopeLength; i++)
- {
- targetBufferReal[j] = sourceBufferReal[i][loBand];
- targetBufferImag[j] = sourceBufferImag[i][loBand];
- j += SBR_NUM_BANDS;
- }
- }
- }
-}
-
-#endif
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h b/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h
deleted file mode 100644
index 0e9c928..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_generate_high_freq.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GENERATE_HIGH_FREQ_H
-#define SBR_GENERATE_HIGH_FREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "e_invf_mode.h"
-#include "s_patch.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-
-
-
- void sbr_generate_high_freq(
- Int32 sourceBufferReal[][32],
- Int32 sourceBufferImag[][32],
- Int32 *targetBufferReal,
- Int32 *targetBufferImag,
- INVF_MODE *invFiltMode,
- INVF_MODE *prevInvFiltMode,
- Int32 *invFiltBandTable,
- Int32 noInvFiltBands,
- Int32 highBandStartSb,
- Int32 *v_k_master,
- Int32 numMaster,
- Int32 fs,
- Int32 *frameInfo,
- Int32 *degreeAlias,
- Int32 scratch_mem[][64],
- Int32 BwVector[MAX_NUM_PATCHES],
- Int32 BwVectorOld[MAX_NUM_PATCHES],
- struct PATCH * Patch,
- Int32 LC_flag,
- Int32 *highBandStopSb);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp
deleted file mode 100644
index 60072dd..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_additional_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_additional_data.h"
-#include "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData,
- BIT_BUFFER * hBitBuf)
-{
- Int32 i;
-
- Int32 flag = buf_getbits(hBitBuf, 1);
-
- if (flag)
- {
- for (i = 0; i < hFrameData->nSfb[HI]; i++)
- {
- hFrameData->addHarmonics[i] = buf_getbits(hBitBuf, 1);
- }
- }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h b/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h
deleted file mode 100644
index 51285c5..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_additional_data.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_ADDITIONAL_DATA_H
-#define SBR_GET_ADDITIONAL_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_header_data.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData,
- BIT_BUFFER * hBitBuf);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp b/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp
deleted file mode 100644
index 657d032..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_cpe.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: hFrameDataLeft - handle to struct SBR_FRAME_DATA for first channel
- hFrameDataRight - handle to struct SBR_FRAME_DATA for first channel
- hBitBuf - handle to struct BIT_BUF
-
- Return: SbrFrameOK
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_cpe.h"
-#include "buf_getbits.h"
-#include "extractframeinfo.h"
-#include "sbr_get_dir_control_data.h"
-#include "sbr_get_envelope.h"
-#include "sbr_get_noise_floor_data.h"
-#include "sbr_get_additional_data.h"
-#include "sbr_extract_extended_data.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft,
- SBR_FRAME_DATA * hFrameDataRight,
- BIT_BUFFER * hBitBuf)
-{
- Int32 i;
- Int32 bits;
- SBR_ERROR err = SBRDEC_OK;
-
- /* reserved bits */
- bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT);
-
- if (bits)
- {
- buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
- buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
- }
-
- /* Read coupling flag */
- bits = buf_getbits(hBitBuf, SI_SBR_COUPLING_BITS);
-
- if (bits)
- {
- hFrameDataLeft->coupling = COUPLING_LEVEL;
- hFrameDataRight->coupling = COUPLING_BAL;
- }
- else
- {
- hFrameDataLeft->coupling = COUPLING_OFF;
- hFrameDataRight->coupling = COUPLING_OFF;
- }
-
-
- err = extractFrameInfo(hBitBuf, hFrameDataLeft);
-
- if (err != SBRDEC_OK)
- {
- return err;
- }
-
- if (hFrameDataLeft->coupling)
- {
-
- pv_memcpy(hFrameDataRight->frameInfo,
- hFrameDataLeft->frameInfo,
- LENGTH_FRAME_INFO * sizeof(Int32));
-
- hFrameDataRight->nNoiseFloorEnvelopes = hFrameDataLeft->nNoiseFloorEnvelopes;
- hFrameDataRight->frameClass = hFrameDataLeft->frameClass;
-
-
- sbr_get_dir_control_data(hFrameDataLeft, hBitBuf);
- sbr_get_dir_control_data(hFrameDataRight, hBitBuf);
-
- for (i = 0; i < hFrameDataLeft->nNfb; i++)
- {
- hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i];
- hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i];
-
- hFrameDataLeft->sbr_invf_mode[i] = (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
- hFrameDataRight->sbr_invf_mode[i] = hFrameDataLeft->sbr_invf_mode[i];
- }
-
- sbr_get_envelope(hFrameDataLeft, hBitBuf);
- sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf);
- sbr_get_envelope(hFrameDataRight, hBitBuf);
-
- }
- else
- {
- err = extractFrameInfo(hBitBuf, hFrameDataRight);
-
- if (err != SBRDEC_OK)
- {
- return err;
- }
-
-
- sbr_get_dir_control_data(hFrameDataLeft, hBitBuf);
- sbr_get_dir_control_data(hFrameDataRight, hBitBuf);
-
- for (i = 0; i < hFrameDataLeft->nNfb; i++)
- {
- hFrameDataLeft->sbr_invf_mode_prev[i] = hFrameDataLeft->sbr_invf_mode[i];
- hFrameDataLeft->sbr_invf_mode[i] =
- (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
- }
-
- for (i = 0; i < hFrameDataRight->nNfb; i++)
- {
- hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i];
-
- hFrameDataRight->sbr_invf_mode[i] =
- (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
- }
- sbr_get_envelope(hFrameDataLeft, hBitBuf);
- sbr_get_envelope(hFrameDataRight, hBitBuf);
-
- sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf);
-
- }
-
- sbr_get_noise_floor_data(hFrameDataRight, hBitBuf);
-
- pv_memset((void *)hFrameDataLeft->addHarmonics,
- 0,
- hFrameDataLeft->nSfb[HI]*sizeof(Int32));
-
- pv_memset((void *)hFrameDataRight->addHarmonics,
- 0,
- hFrameDataRight->nSfb[HI]*sizeof(Int32));
-
- sbr_get_additional_data(hFrameDataLeft, hBitBuf);
- sbr_get_additional_data(hFrameDataRight, hBitBuf);
-
- sbr_extract_extended_data(hBitBuf
-#ifdef PARAMETRICSTEREO
- , NULL
-#endif
- );
-
- return SBRDEC_OK;
-
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_cpe.h b/media/libstagefright/codecs/aacdec/sbr_get_cpe.h
deleted file mode 100644
index b6f99f8..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_cpe.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_cpe.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_CPE_H
-#define SBR_GET_CPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-#include "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft,
- SBR_FRAME_DATA * hFrameDataRight,
- BIT_BUFFER * hBitBuf);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp
deleted file mode 100644
index 3d7ad8c..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_dir_control_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: h_frame_data - handle to struct SBR_FRAME_DATA
- hBitBuf - handle to struct BIT_BUF
-
- Return: void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads direction control data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_dir_control_data.h"
-#include "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf)
-{
- Int32 i;
-
- h_frame_data->nNoiseFloorEnvelopes = h_frame_data->frameInfo[0] > 1 ? 2 : 1;
-
-
- for (i = 0; i < h_frame_data->frameInfo[0]; i++)
- {
- h_frame_data->domain_vec1[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS);
- }
-
- for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++)
- {
- h_frame_data->domain_vec2[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS);
- }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h b/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h
deleted file mode 100644
index 3b587dc..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_dir_control_data.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_DIR_CONTROL_DATA_H
-#define SBR_GET_DIR_CONTROL_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp b/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp
deleted file mode 100644
index e92abb1..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: h_frame_data - handle to struct SBR_FRAME_DATA
- hBitBuf - handle to struct BIT_BUF
- channel - channel number
-
- Return: void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads envelope data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_envelope.h"
-#include "s_huffman.h"
-#include "e_coupling_mode.h"
-#include "sbr_code_book_envlevel.h"
-#include "buf_getbits.h"
-#include "sbr_decode_huff_cw.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf)
-{
- Int32 i;
- Int32 j;
- Int32 tmp;
- Int32 no_band[MAX_ENVELOPES];
- Int32 delta = 0;
- Int32 offset = 0;
- Int32 ampRes;
- Int32 envDataTableCompFactor;
- Int32 start_bits;
- Int32 start_bits_balance;
- SbrHuffman hcb_t;
- SbrHuffman hcb_f;
- COUPLING_MODE coupling = h_frame_data->coupling;
-
- h_frame_data->nScaleFactors = 0;
-
- if ((h_frame_data->frameClass == FIXFIX) &&
- (h_frame_data->frameInfo[0] == 1))
- {
- h_frame_data->ampRes = SBR_AMP_RES_1_5;
- }
- else
- {
- h_frame_data->ampRes = h_frame_data->sbr_header.ampResolution;
- }
-
- ampRes = h_frame_data->ampRes;
-
- /*
- * Set number of bits for first value depending on amplitude resolution
- */
- if (ampRes == SBR_AMP_RES_3_0)
- {
- start_bits = SI_SBR_START_ENV_BITS_AMP_RES_3_0;
- start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0;
- }
- else
- {
- start_bits = SI_SBR_START_ENV_BITS_AMP_RES_1_5;
- start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5;
- }
-
- /*
- * Calculate number of values for each envelope and alltogether
- */
- for (i = 0; i < h_frame_data->frameInfo[0]; i++)
- {
- no_band[i] =
- h_frame_data->nSfb[h_frame_data->frameInfo[h_frame_data->frameInfo[0] + 2 + i]];
- h_frame_data->nScaleFactors += no_band[i];
- }
-
-
- /*
- * Select huffman codebook depending on coupling mode and amplitude resolution
- */
- if (coupling == COUPLING_BAL)
- {
- envDataTableCompFactor = 1;
- if (ampRes == SBR_AMP_RES_1_5)
- {
- hcb_t = bookSbrEnvBalance10T;
- hcb_f = bookSbrEnvBalance10F;
- }
- else
- {
- hcb_t = bookSbrEnvBalance11T;
- hcb_f = bookSbrEnvBalance11F;
- }
- }
- else
- {
- envDataTableCompFactor = 0;
- if (ampRes == SBR_AMP_RES_1_5)
- {
- hcb_t = bookSbrEnvLevel10T;
- hcb_f = bookSbrEnvLevel10F;
- }
- else
- {
- hcb_t = bookSbrEnvLevel11T;
- hcb_f = bookSbrEnvLevel11F;
- }
- }
-
- /*
- * Now read raw envelope data
- */
- for (j = 0; j < h_frame_data->frameInfo[0]; j++)
- {
- if (h_frame_data->domain_vec1[j] == FREQ)
- {
- if (coupling == COUPLING_BAL)
- {
- tmp = buf_getbits(hBitBuf, start_bits_balance);
- h_frame_data->iEnvelope_man[offset] = tmp << envDataTableCompFactor;
- }
- else
- {
- tmp = buf_getbits(hBitBuf, start_bits);
- h_frame_data->iEnvelope_man[offset] = tmp;
- }
- }
-
- for (i = (1 - h_frame_data->domain_vec1[j]); i < no_band[j]; i++)
- {
-
- if (h_frame_data->domain_vec1[j] == FREQ)
- {
- delta = sbr_decode_huff_cw(hcb_f, hBitBuf);
- }
- else
- {
- delta = sbr_decode_huff_cw(hcb_t, hBitBuf);
- }
-
- h_frame_data->iEnvelope_man[offset + i] = delta << envDataTableCompFactor;
- }
- offset += no_band[j];
- }
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_envelope.h b/media/libstagefright/codecs/aacdec/sbr_get_envelope.h
deleted file mode 100644
index b7a266a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_envelope.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_envelope.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_ENVELOPE_H
-#define SBR_GET_ENVELOPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp
deleted file mode 100644
index 42789ae..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_header_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: h_sbr_header - handle to struct SBR_HEADER_DATA
- hBitBuf - handle to struct BIT_BUFFER
- id_sbr - SBR_ELEMENT_ID
-
- Return: error status - 0 if ok
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads header data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_header_data.h"
-#include "sbr_constants.h"
-#include "buf_getbits.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA * h_sbr_header,
- BIT_BUFFER * hBitBuf,
- SBR_SYNC_STATE syncState)
-{
- SBR_HEADER_DATA lastHeader;
- Int32 headerExtra1, headerExtra2;
-
-
- /* Copy header to temporary header */
- if (syncState == SBR_ACTIVE)
- {
- pv_memcpy(&lastHeader, h_sbr_header, sizeof(SBR_HEADER_DATA));
- }
- else
- {
- pv_memset((void *)&lastHeader, 0, sizeof(SBR_HEADER_DATA));
- }
-
-
- /* Read new header from bitstream */
- h_sbr_header->ampResolution = buf_getbits(hBitBuf, SI_SBR_AMP_RES_BITS);
- h_sbr_header->startFreq = buf_getbits(hBitBuf, SI_SBR_START_FREQ_BITS);
- h_sbr_header->stopFreq = buf_getbits(hBitBuf, SI_SBR_STOP_FREQ_BITS);
- h_sbr_header->xover_band = buf_getbits(hBitBuf, SI_SBR_XOVER_BAND_BITS);
-
- buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_HDR);
-
- headerExtra1 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_1_BITS);
- headerExtra2 = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_2_BITS);
-
- /* handle extra header information */
- if (headerExtra1)
- {
- h_sbr_header->freqScale = buf_getbits(hBitBuf, SI_SBR_FREQ_SCALE_BITS);
- h_sbr_header->alterScale = buf_getbits(hBitBuf, SI_SBR_ALTER_SCALE_BITS);
- h_sbr_header->noise_bands = buf_getbits(hBitBuf, SI_SBR_NOISE_BANDS_BITS);
- }
- else
- { /* Set default values.*/
- h_sbr_header->freqScale = SBR_FREQ_SCALE_DEFAULT;
- h_sbr_header->alterScale = SBR_ALTER_SCALE_DEFAULT;
- h_sbr_header->noise_bands = SBR_NOISE_BANDS_DEFAULT;
- }
-
-
- if (headerExtra2)
- {
- h_sbr_header->limiterBands = buf_getbits(hBitBuf, SI_SBR_LIMITER_BANDS_BITS);
- h_sbr_header->limiterGains = buf_getbits(hBitBuf, SI_SBR_LIMITER_GAINS_BITS);
- h_sbr_header->interpolFreq = buf_getbits(hBitBuf, SI_SBR_INTERPOL_FREQ_BITS);
- h_sbr_header->smoothingLength = buf_getbits(hBitBuf, SI_SBR_SMOOTHING_LENGTH_BITS);
- }
- else
- { /* Set default values.*/
- h_sbr_header->limiterBands = SBR_LIMITER_BANDS_DEFAULT;
- h_sbr_header->limiterGains = SBR_LIMITER_GAINS_DEFAULT;
- h_sbr_header->interpolFreq = SBR_INTERPOL_FREQ_DEFAULT;
- h_sbr_header->smoothingLength = SBR_SMOOTHING_LENGTH_DEFAULT;
- }
-
- if (syncState == SBR_ACTIVE)
- {
- h_sbr_header->status = HEADER_OK;
-
- /* look for new settings */
- if (lastHeader.startFreq != h_sbr_header->startFreq ||
- lastHeader.stopFreq != h_sbr_header->stopFreq ||
- lastHeader.xover_band != h_sbr_header->xover_band ||
- lastHeader.freqScale != h_sbr_header->freqScale ||
- lastHeader.alterScale != h_sbr_header->alterScale ||
- lastHeader.noise_bands != h_sbr_header->noise_bands)
- {
- h_sbr_header->status = HEADER_RESET;
- }
- }
- else
- {
- h_sbr_header->status = HEADER_RESET;
- }
-
- return h_sbr_header->status;
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_header_data.h b/media/libstagefright/codecs/aacdec/sbr_get_header_data.h
deleted file mode 100644
index 7bfb272..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_header_data.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_header_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_HEADER_DATA_H
-#define SBR_GET_HEADER_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_header_data.h"
-#include "e_sbr_element_id.h"
-#include "e_sbr_sync_state.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA *h_sbr_header,
- BIT_BUFFER * hBitBuf,
- SBR_SYNC_STATE syncState);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp
deleted file mode 100644
index 8d86158..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_noise_floor_data.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: h_frame_data - handle to struct SBR_FRAME_DATA
- hBitBuf - handle to struct BIT_BUF
-
- Return: void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Reads noise-floor-level data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_get_noise_floor_data.h"
-#include "e_coupling_mode.h"
-#include "buf_getbits.h"
-#include "sbr_code_book_envlevel.h"
-#include "s_huffman.h"
-#include "sbr_decode_huff_cw.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf)
-{
- Int32 i;
- Int32 j;
- Int32 k;
- Int32 tmp;
- Int32 delta;
- Int32 noNoiseBands = h_frame_data->nNfb;
- Int32 envDataTableCompFactor;
-
- COUPLING_MODE coupling = h_frame_data->coupling;
-
- SbrHuffman hcb_noiseF;
- SbrHuffman hcb_noise;
-
-
- if (coupling == COUPLING_BAL)
- {
- hcb_noise = bookSbrNoiseBalance11T;
- hcb_noiseF = bookSbrEnvBalance11F; /* "bookSbrNoiseBalance11F" */
- envDataTableCompFactor = 1;
- }
- else
- {
- hcb_noise = bookSbrNoiseLevel11T;
- hcb_noiseF = bookSbrEnvLevel11F; /* "bookSbrNoiseLevel11F" */
- envDataTableCompFactor = 0;
- }
-
- /*
- * Calculate number of values alltogether
- */
- h_frame_data->nNoiseFactors = h_frame_data->frameInfo[((h_frame_data->frameInfo[0]) << 1) + 3] * noNoiseBands;
-
-
- for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++)
- {
- k = i * noNoiseBands;
- if (h_frame_data->domain_vec2[i] == FREQ)
- {
- if (coupling == COUPLING_BAL)
- {
- tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0) << 1; /* max. 62 */
- h_frame_data->sbrNoiseFloorLevel_man[k] = tmp;
- h_frame_data->sbrNoiseFloorLevel_exp[k] = 0;
- }
- else
- {
- tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_AMP_RES_3_0); /* max. 31 */
- h_frame_data->sbrNoiseFloorLevel_man[k] = tmp;
- h_frame_data->sbrNoiseFloorLevel_exp[k] = 0;
- }
-
- for (j = 1; j < noNoiseBands; j++)
- {
- delta = sbr_decode_huff_cw(hcb_noiseF, hBitBuf); /*
- * -31 < delta < 31
- * -24 < delta < 24 COUPLING_BAL (incl. <<1)
- */
- h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor;
- h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0;
- }
- }
- else
- {
- for (j = 0; j < noNoiseBands; j++)
- {
- delta = sbr_decode_huff_cw(hcb_noise, hBitBuf); /*
- * -31 < delta < 31
- * -24 < delta < 24 COUPLING_BAL (incl. <<1)
- */
- h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor;
- h_frame_data->sbrNoiseFloorLevel_exp[k+j] = 0;
- }
- }
- }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h b/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h
deleted file mode 100644
index e61abda..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_noise_floor_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_NOISE_FLOOR_DATA_H
-#define SBR_GET_NOISE_FLOOR_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data,
- BIT_BUFFER * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp b/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp
deleted file mode 100644
index ba514f4..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_sce.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments: hFrameData - handle to struct SBR_FRAME_DATA
- hBitBuf - handle to struct BIT_BUF
-
- Return: SbrFrameOK
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-
-#include "sbr_get_sce.h"
-#include "sbr_get_additional_data.h"
-#include "sbr_extract_extended_data.h"
-#include "buf_getbits.h"
-#include "sbr_get_envelope.h"
-#include "sbr_get_noise_floor_data.h"
-#include "extractframeinfo.h"
-#include "sbr_get_dir_control_data.h"
-#include "e_invf_mode.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData,
- BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO
- , HANDLE_PS_DEC hParametricStereoDec
-#endif
- )
-{
- Int32 i;
- Int32 bits;
- SBR_ERROR err = SBRDEC_OK;
-
- /* reserved bits */
- bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT);
-
- if (bits)
- {
- buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
- }
-
- /* side info */
- err = extractFrameInfo(hBitBuf, hFrameData);
-
- if (err != SBRDEC_OK)
- {
- return err;
- }
-
-
- sbr_get_dir_control_data(hFrameData, hBitBuf);
-
- for (i = 0; i < hFrameData->nNfb; i++)
- {
- hFrameData->sbr_invf_mode_prev[i] = hFrameData->sbr_invf_mode[i];
- hFrameData->sbr_invf_mode[i] =
- (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
- }
-
-
- /* raw data */
- sbr_get_envelope(hFrameData, hBitBuf);
-
- sbr_get_noise_floor_data(hFrameData, hBitBuf);
-
- pv_memset((void *)hFrameData->addHarmonics,
- 0,
- hFrameData->nSfb[HI]*sizeof(Int32));
-
- sbr_get_additional_data(hFrameData, hBitBuf);
-
- sbr_extract_extended_data(hBitBuf
-#ifdef PARAMETRICSTEREO
- , hParametricStereoDec
-#endif
- );
-
- hFrameData->coupling = COUPLING_OFF;
-
- return SBRDEC_OK;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_sce.h b/media/libstagefright/codecs/aacdec/sbr_get_sce.h
deleted file mode 100644
index 36adb04..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_sce.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_sce.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_SCE_H
-#define SBR_GET_SCE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-#include "s_sbr_frame_data.h"
-#include "e_sbr_error.h"
-
-#ifdef PARAMETRICSTEREO
-#include "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData,
- BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO
- , HANDLE_PS_DEC hParametricStereoDec
-#endif
- );
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp b/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp
deleted file mode 100644
index 833ace3..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_inv_filt_levelemphasis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_inv_filt_levelemphasis.h"
-#include "sbr_generate_high_freq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-
-#define R_SHIFT 29
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 InvFiltFactors[5] = {Qfmt(0.00f), /* OFF_LEVEL */
- Qfmt(0.60f), /* TRANSITION_LEVEL */
- Qfmt(0.75f), /* LOW_LEVEL */
- Qfmt(0.90f), /* MID_LEVEL */
- Qfmt(0.98f)
- }; /* HIGH_LEVEL */
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode,
- INVF_MODE *prevInvFiltMode,
- Int32 nNfb,
- Int32 BwVector[MAX_NUM_PATCHES],
- Int32 BwVectorOld[MAX_NUM_PATCHES])
-{
- Int32 i;
- Int32 j;
- Int32 tmp;
-
- for (i = 0; i < nNfb; i++)
- {
- switch (invFiltMode[i])
- {
- case INVF_LOW_LEVEL:
- if (prevInvFiltMode[i] == INVF_OFF)
- {
- j = 1;
- }
- else
- {
- j = 2;
- }
- break;
-
- case INVF_MID_LEVEL:
- j = 3;
- break;
-
- case INVF_HIGH_LEVEL:
- j = 4;
- break;
-
- default:
- if (prevInvFiltMode[i] == INVF_LOW_LEVEL)
- {
- j = 1;
- }
- else
- {
- j = 0;
- }
- }
-
- tmp = InvFiltFactors[j];
-
- if (tmp < BwVectorOld[i])
- {
- tmp = ((tmp << 1) + tmp + BwVectorOld[i]) >> 2;
- }
- else
- {
- tmp = fxp_mul32_Q29(Qfmt(0.90625f), tmp);
- tmp = fxp_mac32_Q29(Qfmt(0.09375f), BwVectorOld[i], tmp);
- }
-
- if (tmp < Qfmt(0.015625F))
- {
- tmp = 0;
- }
-
- if (tmp >= Qfmt(0.99609375f))
- {
- tmp = Qfmt(0.99609375f);
- }
-
- BwVector[i] = tmp;
- }
-}
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h b/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h
deleted file mode 100644
index 586214c..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_inv_filt_levelemphasis.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_INV_FILT_LEVELEMPHASIS_H
-#define SBR_INV_FILT_LEVELEMPHASIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_invf_mode.h"
-#include "sbr_generate_high_freq.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode,
- INVF_MODE *prevInvFiltMode,
- Int32 nNfb,
- Int32 BwVector[MAX_NUM_PATCHES],
- Int32 BwVectorOld[MAX_NUM_PATCHES]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_open.cpp b/media/libstagefright/codecs/aacdec/sbr_open.cpp
deleted file mode 100644
index 868819a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_open.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_open.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_open.h"
-#include "s_sbr_header_data.h"
-#include "init_sbr_dec.h"
-#include "e_sbr_error.h"
-#include "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const SBR_HEADER_DATA defaultHeader =
-{
- HEADER_NOT_INITIALIZED, /* status */
- MASTER_RESET, /* masterStatus */
- 0, /* crcEnable */
- UP_BY_2, /* sampleRateMode */
- SBR_AMP_RES_3_0, /* ampResolution */
- 5, /* startFreq */
- 0, /* stopFreq */
- 0, /* xover_band */
- SBR_FREQ_SCALE_DEFAULT, /* freqScale */
- SBR_ALTER_SCALE_DEFAULT, /* alterScale */
- SBR_NOISE_BANDS_DEFAULT, /* noise_bands */
- 0, /* noNoiseBands */
- SBR_LIMITER_BANDS_DEFAULT,
- SBR_LIMITER_GAINS_DEFAULT,
- SBR_INTERPOL_FREQ_DEFAULT,
- SBR_SMOOTHING_LENGTH_DEFAULT
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_open(Int32 sampleRate,
- SBR_DEC *sbrDec,
- SBRDECODER_DATA * self,
- bool bDownSampledSbr)
-
-{
- Int16 i ;
-
- SBR_CHANNEL *SbrChannel;
-
-
- SbrChannel = self->SbrChannel;
-
- for (i = 0; i < MAX_NUM_CHANNELS; i++)
- {
- pv_memset((void *)&(SbrChannel[i]),
- 0,
- sizeof(SBR_CHANNEL));
-
- /* init a default header such that we can at least do upsampling later */
-
- pv_memcpy(&(SbrChannel[i].frameData.sbr_header),
- &defaultHeader,
- sizeof(SBR_HEADER_DATA));
-
- /* should be handled by sample rate mode bit */
- if (sampleRate > 24000 || bDownSampledSbr)
- {
- SbrChannel[i].frameData.sbr_header.sampleRateMode = SINGLE_RATE;
- }
-
-
- SbrChannel[i].outFrameSize =
- init_sbr_dec(sampleRate,
- self->SbrChannel[0].frameData.sbr_header.sampleRateMode,
- sbrDec,
- &(SbrChannel[i].frameData));
-
- SbrChannel[i].syncState = UPSAMPLING;
-
- SbrChannel[i].frameData.sUp = 1; /* reset mode */
- }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_open.h b/media/libstagefright/codecs/aacdec/sbr_open.h
deleted file mode 100644
index 8d17ffa..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_open.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_open.h
- Funtions:
- get_dse
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_OPEN_H
-#define SBR_OPEN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_sbr_channel.h"
-#include "sbr_dec.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void sbr_open(Int32 sampleRate,
- SBR_DEC *sbrDec,
- SBRDECODER_DATA * self,
- bool bDownSampledSbr);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_read_data.cpp b/media/libstagefright/codecs/aacdec/sbr_read_data.cpp
deleted file mode 100644
index 2220fce..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_read_data.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_read_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- INPUT
-
- SBRDECODER self,
- SBRBITSTREAM * stream,
- float *timeData,
- int numChannels
-
- OUTPUT
-
- errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- sbr decoder processing, set up SBR decoder phase 2 in case of
- different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_read_data.h"
-#include "s_bit_buffer.h"
-#include "buf_getbits.h"
-#include "sbr_get_sce.h"
-#include "sbr_get_cpe.h"
-#include "sbr_reset_dec.h"
-#include "sbr_get_header_data.h"
-#include "sbr_crc_check.h"
-#include "aac_mem_funcs.h"
-
-
-#include "init_sbr_dec.h" /* !!! */
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_read_data(SBRDECODER_DATA * self,
- SBR_DEC * sbrDec,
- SBRBITSTREAM *stream)
-{
- SBR_ERROR sbr_err = SBRDEC_OK;
- int32_t SbrFrameOK = 1;
- int32_t sbrCRCAlwaysOn = 0;
-
- UInt32 bs_header_flag = 0;
-
- SBR_HEADER_STATUS headerStatus = HEADER_OK;
-
- SBR_CHANNEL *SbrChannel = self->SbrChannel;
-
- int32_t zeropadding_bits;
-
- BIT_BUFFER bitBuf ;
-
- /*
- * evaluate Bitstream
- */
-
- bitBuf.buffer_word = 0;
- bitBuf.buffered_bits = 0;
- bitBuf.nrBitsRead = 0;
-
- bitBuf.char_ptr = stream->sbrElement[0].Data;
- bitBuf.bufferLen = (stream->sbrElement[0].Payload) << 3;
-
-
- /*
- * we have to skip a nibble because the first element of Data only
- * contains a nibble of data !
- */
- buf_getbits(&bitBuf, LEN_NIBBLE);
-
- if ((stream->sbrElement[0].ExtensionType == SBR_EXTENSION_CRC) ||
- sbrCRCAlwaysOn)
- {
- int32_t CRCLen = ((stream->sbrElement[0].Payload - 1) << 3) + 4 - SI_SBR_CRC_BITS;
- SbrFrameOK = sbr_crc_check(&bitBuf, CRCLen);
- }
-
-
- if (SbrFrameOK)
- {
- /*
- * The sbr data seems ok, if the header flag is set we read the header
- * and check if vital parameters have changed since the previous frame.
- * If the syncState equals UPSAMPLING, the SBR Tool has not been
- * initialised by SBR header data, and can only do upsampling
- */
-
- bs_header_flag = buf_getbits(&bitBuf, 1); /* read Header flag */
-
- if (bs_header_flag)
- {
- /*
- * If syncState == SBR_ACTIVE, it means that we've had a SBR header
- * before, and we will compare with the previous header to see if a
- * reset is required. If the syncState equals UPSAMPLING this means
- * that the SBR-Tool so far is only initialised to do upsampling
- * and hence we need to do a reset, and initialise the system
- * according to the present header.
- */
-
- headerStatus = sbr_get_header_data(&(SbrChannel[0].frameData.sbr_header),
- &bitBuf,
- SbrChannel[0].syncState);
- } /* if (bs_header_flag) */
-
-
- switch (stream->sbrElement[0].ElementID)
- {
- case SBR_ID_SCE :
-
- /* change of control data, reset decoder */
- if (headerStatus == HEADER_RESET)
- {
- sbr_err = sbr_reset_dec(&(SbrChannel[0].frameData),
- sbrDec,
- self->SbrChannel[0].frameData.sbr_header.sampleRateMode);
-
- if (sbr_err != SBRDEC_OK)
- {
- break;
- }
- /*
- * At this point we have a header and the system has been reset,
- * hence syncState from now on will be SBR_ACTIVE.
- */
- SbrChannel[0].syncState = SBR_ACTIVE;
- }
-
- if ((SbrChannel[0].syncState == SBR_ACTIVE))
- {
- sbr_err = sbr_get_sce(&(SbrChannel[0].frameData),
- &bitBuf
-#ifdef PARAMETRICSTEREO
- , self->hParametricStereoDec
-#endif
- );
-
- if (sbr_err != SBRDEC_OK)
- {
- break;
- }
- }
-
- break;
-
- case SBR_ID_CPE :
-
- if (bs_header_flag)
- {
- pv_memcpy(&(SbrChannel[1].frameData.sbr_header),
- &(SbrChannel[0].frameData.sbr_header),
- sizeof(SBR_HEADER_DATA));
- }
-
- /* change of control data, reset decoder */
- if (headerStatus == HEADER_RESET)
- {
- for (int32_t lr = 0 ; lr < 2 ; lr++)
- {
- sbr_err = sbr_reset_dec(&(SbrChannel[lr].frameData),
- sbrDec,
- self->SbrChannel[0].frameData.sbr_header.sampleRateMode);
-
- if (sbr_err != SBRDEC_OK)
- {
- break;
- }
-
- SbrChannel[lr].syncState = SBR_ACTIVE;
- }
- }
-
- if (SbrChannel[0].syncState == SBR_ACTIVE)
- {
- sbr_err = sbr_get_cpe(&(SbrChannel[0].frameData),
- &(SbrChannel[1].frameData),
- &bitBuf);
-
- if (sbr_err != SBRDEC_OK)
- {
- break;
- }
-
- }
- break;
-
- default:
- sbr_err = SBRDEC_ILLEGAL_PLUS_ELE_ID;
- break;
- }
-
- } /* if (SbrFrameOK) */
-
- /*
- * Check that the bits read did not go beyond SBR frame boundaries
- */
-
- zeropadding_bits = (8 - (bitBuf.nrBitsRead & 0x7)) & 0x7;
-
- if ((bitBuf.nrBitsRead + zeropadding_bits) > bitBuf.bufferLen)
- {
- sbr_err = SBRDEC_INVALID_BITSTREAM;
- }
-
- return sbr_err;
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_read_data.h b/media/libstagefright/codecs/aacdec/sbr_read_data.h
deleted file mode 100644
index 74cf5b9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_read_data.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_read_data.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_READ_DATA
-#define SBR_READ_DATA
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_sbr_error.h"
-#include "s_sbr_channel.h"
-#include "s_sbrbitstream.h"
-#include "sbr_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- SBR_ERROR sbr_read_data(SBRDECODER_DATA * self,
- SBR_DEC * sbrDec,
- SBRBITSTREAM *stream);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp b/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp
deleted file mode 100644
index 487496f..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_requantize_envelope_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_constants.h"
-#include "sbr_requantize_envelope_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT 30
-#define Qfmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData)
-
-{
- Int32 i;
-
-
- Int32 nScaleFactors = hFrameData->nScaleFactors;
- Int32 nNoiseFactors = hFrameData->nNoiseFactors;
- Int32 ampRes = hFrameData->ampRes;
- Int32 *iEnvelope_man = hFrameData->iEnvelope_man;
- Int32 *iEnvelope_exp = hFrameData->iEnvelope_exp;
- Int32 *sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
- Int32 *sbrNoiseFloorLevel_exp = hFrameData->sbrNoiseFloorLevel_exp;
-
- /*
- * ampRes could be 0 (resolution step = 1.5 dB) or
- * 1 (resolution step = 3 dB)
- */
- if (ampRes)
- {
- /* iEnvelope[i] always positive 6 bits max */
- for (i = 0; i < nScaleFactors; i++)
- {
-
- iEnvelope_exp[i] = iEnvelope_man[i] + 6;
- iEnvelope_man[i] = Qfmt(1.000F);
- }
- }
- else
- {
- /* iEnvelope[i] always positive 7 bits max */
- for (i = 0; i < nScaleFactors; i++)
- {
- iEnvelope_exp[i] = (iEnvelope_man[i] >> 1) + 6;
- if (iEnvelope_man[i] & 0x1) /* odd */
- {
- iEnvelope_man[i] = Qfmt(1.41421356237310F);
- }
- else
- {
- iEnvelope_man[i] = Qfmt(1.000F);
- }
- }
-
- }
- for (i = 0; i < nNoiseFactors; i++)
- {
- /* sbrNoiseFloorLevel[i] varies from -31 to 31 if no coupling is used */
-
- sbrNoiseFloorLevel_exp[i] = NOISE_FLOOR_OFFSET - sbrNoiseFloorLevel_man[i];
- sbrNoiseFloorLevel_man[i] = 0x40000000;
- }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h b/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h
deleted file mode 100644
index 2113586..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_requantize_envelope_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_REQUANTIZE_ENVELOPE_DATA_H
-#define SBR_REQUANTIZE_ENVELOPE_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp b/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp
deleted file mode 100644
index 810a34a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_reset_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- resets sbr decoder structure
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-#include "sbr_dec.h"
-
-#include "pv_log2.h"
-#include "fxp_mul32.h"
-
-
-#include "sbr_reset_dec.h"
-#include "sbr_find_start_andstop_band.h"
-#include "sbr_update_freq_scale.h"
-#include "sbr_downsample_lo_res.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData,
- SBR_DEC * sbrDec,
- Int32 upsampleFac)
-{
-
- SBR_ERROR err = SBRDEC_OK;
- Int lsbM;
- Int lsb;
- Int usb;
- Int32 i;
- Int32 tmp_q1;
-
- SBR_HEADER_DATA *headerData = &(hFrameData->sbr_header);
- Int32 samplingFreq = sbrDec->outSampleRate;
-
- hFrameData->reset_flag = 1;
-
- /*Calculate master frequency function */
- err = sbr_find_start_andstop_band(samplingFreq,
- headerData->startFreq,
- headerData->stopFreq,
- &lsbM,
- &usb);
-
- if (err != SBRDEC_OK)
- {
- return err;
- }
-
- /* Calculate new v_k_master if needed */
- if (headerData->masterStatus == MASTER_RESET)
- {
- sbr_update_freq_scale(sbrDec->V_k_master,
- &(sbrDec->Num_Master),
- lsbM,
- usb,
- headerData->freqScale,
- headerData->alterScale,
- 0);
-
- }
-
- /*Derive Hiresolution from master frequency function*/
-
- sbrDec->NSfb[HI] = sbrDec->Num_Master - headerData->xover_band;
-
- for (i = headerData->xover_band; i <= sbrDec->Num_Master; i++)
- {
- sbrDec->FreqBandTable[HI][i-headerData->xover_band] = (Int)sbrDec->V_k_master[i];
- }
-
-
- if ((sbrDec->NSfb[HI] & 0x01) == 0) /* if even number of hires bands */
- {
-
- sbrDec->NSfb[LO] = sbrDec->NSfb[HI] >> 1;
- /* Use every second lo-res=hi-res[0,2,4...] */
- for (i = 0; i <= sbrDec->NSfb[LO]; i++)
- {
- sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)];
- }
- }
- else
- { /* odd number of hi-res which means xover is odd */
-
- sbrDec->NSfb[LO] = (sbrDec->NSfb[HI] + 1) >> 1;
- /* Use lo-res=hi-res[0,1,3,5 ...] */
- sbrDec->FreqBandTable[LO][0] = sbrDec->FreqBandTable[HI][0];
- for (i = 1; i <= sbrDec->NSfb[LO]; i++)
- {
- sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)-1];
- }
-
- }
-
- lsb = sbrDec->FreqBandTable[LOW_RES][0];
- usb = sbrDec->FreqBandTable[LOW_RES][sbrDec->NSfb[LOW_RES]];
-
- sbrDec->lowSubband = lsb;
- sbrDec->highSubband = usb;
- sbrDec->noSubbands = usb - lsb;
-
- if ((lsb > 32) || (sbrDec->noSubbands <= 0))
- {
- return SBRDEC_ILLEGAL_SCFACTORS; /* invalid bands */
- }
-
- /* Calculate number of noise bands */
- if (headerData->noise_bands == 0)
- {
- sbrDec->NoNoiseBands = 1;
- }
- else /* Calculate number of noise bands 1,2 or 3 bands/octave */
- {
-
- if (! lsb)
- {
- return SBRDEC_ILLEGAL_SCFACTORS; /* avoid div by 0 */
- }
-
- tmp_q1 = pv_log2((usb << 20) / lsb);
-
- tmp_q1 = fxp_mul32_Q15(headerData->noise_bands, tmp_q1);
-
- sbrDec->NoNoiseBands = (tmp_q1 + 16) >> 5;
-
- if (sbrDec->NoNoiseBands == 0)
- {
- sbrDec->NoNoiseBands = 1;
- }
- }
-
- headerData->noNoiseBands = sbrDec->NoNoiseBands;
-
- /* Get noise bands */
- sbr_downsample_lo_res(sbrDec->FreqBandTableNoise,
- sbrDec->NoNoiseBands,
- sbrDec->FreqBandTable[LO],
- sbrDec->NSfb[LO]);
-
- sbrDec->sbStopCodec = sbrDec->lowSubband;
-
- if (sbrDec->sbStopCodec > (upsampleFac << 5))
- {
- sbrDec->sbStopCodec = (upsampleFac << 5);
- }
-
- hFrameData->nSfb[LO] = sbrDec->NSfb[LO];
- hFrameData->nSfb[HI] = sbrDec->NSfb[HI];
- hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands;
- hFrameData->offset = ((hFrameData->nSfb[LO]) << 1) - hFrameData->nSfb[HI];
-
- return (SBRDEC_OK);
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_reset_dec.h b/media/libstagefright/codecs/aacdec/sbr_reset_dec.h
deleted file mode 100644
index 0ff94a5..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_reset_dec.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_reset_dec.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_RESET_DEC_H
-#define SBR_RESET_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "s_sbr_frame_data.h"
-#include "sbr_dec.h"
-#include "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData,
- SBR_DEC * sbrDec,
- Int32 upsampleFac);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp b/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp
deleted file mode 100644
index 18bd5d9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_update_freq_scale.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
- Coding Technologies
-
-and edited by
- -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_update_freq_scale.h"
-#include "shellsort.h"
-
-#include "pv_pow2.h"
-#include "pv_log2.h"
-
-#include "fxp_mul32.h"
-#define R_SHIFT 30
-#define Q_fmt(x) (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-#define Q28fmt(x) (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void sbr_update_freq_scale(Int32 * v_k_master,
- Int32 *h_num_bands,
- const Int32 lsbM,
- const Int32 usb,
- const Int32 freqScale,
- const Int32 alterScale,
- const Int32 channelOffset)
-{
- Int32 i;
- Int32 numBands = 0;
- Int32 numBands2;
- Int32 tmp_q1;
-
- if (freqScale > 0) /*Bark mode*/
- {
- Int32 reg;
- Int32 regions;
- Int32 b_p_o;
- Int32 k[3];
- Int32 d[MAX_SECOND_REGION];
- Int32 d2[MAX_SECOND_REGION];
- Int32 w[2] = {Q_fmt(1.0F), Q_fmt(1.0F)};
-
-
- k[0] = lsbM;
- k[1] = usb;
- k[2] = usb;
-
- b_p_o = (freqScale == 1) ? 12 : 8;
- b_p_o = (freqScale == 2) ? 10 : b_p_o;
-
- w[1] = (alterScale == 0) ? Q_fmt(0.5f) : Q_fmt(0.384615384615386f);
-
- if (usb > fxp_mul32_Q28(lsbM, Q28fmt(2.2449)))
- {
- regions = 2;
- k[1] = (lsbM << 1);
- }
- else
- {
- regions = 1;
- }
-
- *h_num_bands = 0;
- for (reg = 0; reg < regions; reg++)
- {
- if (reg == 0)
- {
-
- tmp_q1 = pv_log2((k[1] << 20) / k[0]);
-
- tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o);
- tmp_q1 = (tmp_q1 + 32) >> 6;
-
- numBands = tmp_q1 << 1;
-
-
- CalcBands(d, k[0], k[1], numBands); /* CalcBands => d */
- shellsort(d, numBands); /* SortBands sort d */
- cumSum(k[0] - channelOffset,
- d,
- numBands,
- (v_k_master + *h_num_bands)); /* cumsum */
-
- *h_num_bands += numBands; /* Output nr of bands */
- }
- else
- {
- tmp_q1 = pv_log2((k[reg + 1] << 20) / k[reg]);
-
- tmp_q1 = fxp_mul32_Q30(tmp_q1, w[reg]);
- tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o);
- tmp_q1 = (tmp_q1 + 16) >> 5;
-
- numBands2 = tmp_q1 << 1;
-
- CalcBands(d2, k[reg], k[reg+1], numBands2); /* CalcBands => d */
- shellsort(d2, numBands2); /* SortBands sort d */
- if (d[numBands-1] > d2[0])
- {
-
- Int32 change = d[numBands-1] - d2[0];
- /* Limit the change so that the last band cannot get narrower than the first one */
- if (change > (d2[numBands2-1] - d2[0]) >> 1)
- {
- change = (d2[numBands2-1] - d2[0]) >> 1;
- }
-
- d2[0] += change;
- d2[numBands2-1] -= change;
- shellsort(d2, numBands2);
-
- }
- cumSum(k[reg] - channelOffset,
- d2,
- numBands2,
- v_k_master + *h_num_bands); /* cumsum */
-
- *h_num_bands += numBands2; /* Output nr of bands */
- }
- }
- }
- else
- { /* Linear mode */
- Int32 k2_achived;
- Int32 k2_diff;
- Int32 diff_tot[MAX_OCTAVE + MAX_SECOND_REGION];
- Int32 dk;
- Int32 incr = 0;
-
-
- if (alterScale)
- {
- numBands = (usb - lsbM) >> 1;
- dk = 1;
- k2_achived = lsbM + numBands;
- }
- else
- {
- numBands = usb - lsbM;
- if (numBands & 0x1) /* equivalent rounding */
- {
- numBands--;
- }
- dk = 2;
- k2_achived = lsbM + (numBands << 1);
- }
-
- k2_diff = usb - k2_achived;
-
- for (i = 0; i < numBands; i++)
- {
- diff_tot[i] = dk;
- }
-
- if (k2_diff < 0) /* If linear scale wasn't achived */
- {
- incr = 1; /* and we got too large SBR area */
- i = 0;
- }
-
- if (k2_diff > 0) /* If linear scale wasn't achived */
- {
- incr = -1; /* and we got too small SBR area */
- i = numBands - 1;
- }
-
- /* Adjust diff vector to get spec. SBR range */
- while (k2_diff != 0)
- {
- diff_tot[i] -= incr;
- i += incr;
- k2_diff += incr;
- }
-
- cumSum(lsbM,
- diff_tot,
- numBands,
- v_k_master); /* cumsum */
-
- *h_num_bands = numBands; /* Output nr of bands */
- }
-}
-
-
-void CalcBands(Int32 * diff,
- Int32 start,
- Int32 stop,
- Int32 num_bands)
-{
- Int32 i;
- Int32 previous;
- Int32 current;
- Int32 tmp_q1;
-
-
- previous = start;
-
- for (i = 1; i <= num_bands; i++)
- {
- /* float temp=(start * pow( (float)stop/start, (float)i/num_bands)); */
-
- tmp_q1 = pv_log2((stop << 20) / start);
-
- tmp_q1 = fxp_mul32_Q20(tmp_q1, (i << 27) / num_bands);
- tmp_q1 = pv_pow2(tmp_q1);
-
- tmp_q1 = fxp_mul32_Q20(tmp_q1, start);
-
- current = (tmp_q1 + 16) >> 5;
-
- diff[i-1] = current - previous;
- previous = current;
- }
-
-} /* End CalcBands */
-
-
-void cumSum(Int32 start_value,
- Int32 * diff,
- Int32 length,
- Int32 * start_adress)
-{
- Int32 i;
- Int32 *pt_start_adress = start_adress;
- Int32 *pt_start_adress_1 = start_adress;
- Int32 *pt_diff = diff;
-
- if (length > 0) /* avoid possible error on loop */
- {
- *(pt_start_adress_1++) = start_value;
-
- for (i = (length >> 1); i != 0; i--)
- {
- *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++);
- *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++);
- }
-
- if (length&1)
- {
- *(pt_start_adress_1) = *(pt_start_adress) + *(pt_diff);
- }
- }
-
-} /* End cumSum */
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h b/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h
deleted file mode 100644
index 4acf3aa..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_update_freq_scale.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_UPDATE_FREQ_SCALE_H
-#define SBR_UPDATE_FREQ_SCALE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_OCTAVE 29
-#define MAX_SECOND_REGION 50
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_update_freq_scale(Int32 * v_k_master,
- Int32 *h_num_bands,
- const Int32 lsbM,
- const Int32 usb,
- const Int32 freqScale,
- const Int32 alterScale,
- const Int32 channelOffset);
-
-
-void CalcBands(Int32 * diff,
- Int32 start,
- Int32 stop,
- Int32 num_bands);
-
-void cumSum(Int32 start_value,
- Int32 * diff,
- Int32 length,
- Int32 * start_adress);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/set_mc_info.cpp b/media/libstagefright/codecs/aacdec/set_mc_info.cpp
deleted file mode 100644
index 5a11941..0000000
--- a/media/libstagefright/codecs/aacdec/set_mc_info.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/set_mc_info.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Change audioObjectType from Int to enum types
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- pMC_Info = pointer to structure MC_Info that holds information of
- multiple channels' configurations
- Data type pointer to MC_Info
-
- objectType = variable that holds the Audio Object Type of current
- file/bitstream.
- Data type Int
-
- sampling_rate_idx = variable that indicates the sampling rate of the
- source file being encoded
- Data Type Int
-
- tag = variable that stores the element instance tag of the
- first (front) channel element.
- Data type Int
-
- is_cpe = variable that indicates if a Channel Pair Element (CPE)
- or a Single Channel Element (SCE) is used.
- Data type Int (maybe Boolean)
-
- pWinSeqInfo = array of pointers that points to structures holding
- frame information of long and short window sequences.
- Data type FrameInfo
-
- pSfbwidth128 = array that will store the scalefactor bandwidth of
- short window sequence frame.
- Data type Int array
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- return SUCCESS
-
- Pointers and Buffers Modified:
- pMC_Info->nch contains the number of channels depending
- upon if CPE or SCE is used
- pMC_Info->objectType contents updated with the decoded Audio
- Object Type
-
- pMC_Info->ch_info.tag contents updated with the value of decoded
- channel element tag
-
- PMC_Info->ch_info.cpe contents updated depending upon if CPE or
- SCE is used
-
- pWinSeqInfo contents updated by calling infoinit if
- sampling_rate_idx is different from
- previous value
-
- pSfbWidth128 contents updated by calling infoinit if
- sampling_rate_idx is different from
- previous value
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function initializes the channel configuration information. The
- structure MC_Info stores the number of channels, channel element tag.
- If sampling rate index is different from the previous value,
- The frame information will be updated by calling infoinit.c
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall update the relevant information on channel configs
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
- Subpart 1 p20 Table 1.6.3
- Subpart 4 p30 5.1.2.1
- Subpart 4 p31 4.5.2.1.1
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- pMC_Info->nch = 0;
-
- pMC_Info->profile = objectType;
-
- IF (pMC_Info->sampling_rate_idx != sampling_rate_idx)
- THEN
- pMC_Info->sampling_rate_idx = sampling_rate_idx;
-
- CALL infoinit(
- samp_rate_idx = sampling_rate_idx
- ppWin_seq_info= pWinSeqInfo
- pSfbwidth128 = pSfbwidth128)
- MODIFYING(pWinSeqInfo, pSfbwidth128)
- RETURNING(None)
- ENDIF
-
- pCh_Info = &pMC_Info->ch_info[0];
- pCh_Info->tag = tag;
-
- IF (is_cpe == FALSE)
- THEN
- pCh_Info->cpe = FALSE;
-
- pMC_Info->nch = 1;
-
- ELSE
- pCh_Info->cpe = TRUE;
- pCh_Info = &pMC_Info->ch_info[1];
- pCh_Info->tag = tag;
- pCh_Info->cpe = TRUE;
-
- pMC_Info->nch = 2;
-
- ENDIF
-
- RETURN(SUCCESS)
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "set_mc_info.h"
-#include "huffman.h"
-#include "s_ch_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int set_mc_info(
- MC_Info *pMC_Info,
- const tMP4AudioObjectType audioObjectType, /* used to be profile */
- const Int sampling_rate_idx,
- const Int tag, /* always pass-in last element's value */
- const Int is_cpe,
- FrameInfo *pWinSeqInfo[],
- Int sfbwidth128[]
-)
-{
- Ch_Info *pCh_Info; /*optional task: eliminate this structure */
-
- /*
- * audioObjectType and sampling rate
- * re-configure if new sampling rate
- *
- */
- pMC_Info->audioObjectType = audioObjectType;
-
- if (pMC_Info->sampling_rate_idx != sampling_rate_idx)
- {
- pMC_Info->sampling_rate_idx = sampling_rate_idx;
-
- Int status;
- status = infoinit(sampling_rate_idx,
- pWinSeqInfo,
- sfbwidth128);
- if (SUCCESS != status)
- {
- return 1;
- }
- }
-
- /*
- * first setup values for mono config, Single Channel Element (SCE)
- * then if stereo, go inside if(is_cpe != FALSE) branch to setup
- * values for stereo.
- * set the channel counts
- * save tag for left channel
- */
- pMC_Info->nch = 1 + is_cpe;
-
- pCh_Info = &pMC_Info->ch_info[0];
- pCh_Info->tag = tag;
- pCh_Info->cpe = is_cpe;
-
- /* This if branch maybe deleted in the future */
- if (is_cpe != FALSE)
- {
- /* Channel Pair Element (CPE) */
- /* right channel*/
- pCh_Info = &pMC_Info->ch_info[1];
- pCh_Info->cpe = TRUE;
-
- }
-
- return(SUCCESS); /* possible future error checkings */
-}
diff --git a/media/libstagefright/codecs/aacdec/set_mc_info.h b/media/libstagefright/codecs/aacdec/set_mc_info.h
deleted file mode 100644
index 8043b3b..0000000
--- a/media/libstagefright/codecs/aacdec/set_mc_info.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/set_mc_info.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function declaration for set_mc_info.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SET_MC_INFO_H
-#define SET_MC_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_mc_info.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int set_mc_info(
- MC_Info *pMC_Info,
- const tMP4AudioObjectType objectType, /* used to be profile */
- const Int sampling_rate_idx,
- const Int tag, /* always pass-in last element's value */
- const Int is_cpe,
- FrameInfo *pWinSeqInfo[],
- Int pSfbwidth128[]
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sfb.cpp b/media/libstagefright/codecs/aacdec/sfb.cpp
deleted file mode 100644
index f2d3a3e..0000000
--- a/media/libstagefright/codecs/aacdec/sfb.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/sfb.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: created to define the scalefactor bands for all sampling rates
-
- Description: Change short to Int16
-
- Description: Modified structure to avoid assigning addresses to constant
- tables. This solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers
- - Eliminated redundant vector sfb_96_128.
- - Eliminated references to contant vector addresses in
- samp_rate_info
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function defines the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- Subpart 4 p66 (sfb tables)
- p111 (4.6.10)
- p200 (Annex 4.B.5)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "sfb.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int16 sfb_96_1024[] =
-{
- 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
-}; /* 41 scfbands */
-
-const Int16 sfb_64_1024[] =
-{
- 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
-}; /* 41 scfbands 47 */
-
-const Int16 sfb_64_128[] =
-{
- 4, 8, 12, 16, 20, 24, 32,
- 40, 48, 64, 92, 128
-}; /* 12 scfbands */
-
-
-const Int16 sfb_48_1024[] =
-{
- 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
-};
-/* 49 scfbands*/
-
-const Int16 sfb_48_128[] =
-{
- 4, 8, 12, 16, 20, 28, 36,
- 44, 56, 68, 80, 96, 112, 128
-}; /* 14 scfbands */
-
-const Int16 sfb_32_1024[] =
-{
- 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
-}; /* 51 scfbands */
-
-const Int16 sfb_24_1024[] =
-{
- 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
-}; /* 47 scfbands */
-
-const Int16 sfb_24_128[] =
-{
- 4, 8, 12, 16, 20, 24, 28,
- 36, 44, 52, 64, 76, 92, 108,
- 128
-}; /* 15 scfbands */
-
-const Int16 sfb_16_1024[] =
-{
- 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
-}; /* 43 scfbands */
-
-const Int16 sfb_16_128[] =
-{
- 4, 8, 12, 16, 20, 24, 28,
- 32, 40, 48, 60, 72, 88, 108,
- 128
-}; /* 15 scfbands */
-
-const Int16 sfb_8_1024[] =
-{
- 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
-}; /* 40 scfbands */
-
-const Int16 sfb_8_128[] =
-{
- 4, 8, 12, 16, 20, 24, 28,
- 36, 44, 52, 60, 72, 88, 108,
- 128
-}; /* 15 scfbands */
-
-const SR_Info samp_rate_info[12] =
-{
- /* sampling_frequency, #long sfb, #short sfb */
- /* samp_rate, nsfb1024, nsfb128 */
- {96000, 41, 12}, /* 96000 */
- {88200, 41, 12}, /* 88200 */
- {64000, 47, 12}, /* 64000 */
- {48000, 49, 14}, /* 48000 */
- {44100, 49, 14}, /* 44100 */
- {32000, 51, 14}, /* 32000 */
- {24000, 47, 15}, /* 24000 */
- {22050, 47, 15}, /* 22050 */
- {16000, 43, 15}, /* 16000 */
- {12000, 43, 15}, /* 12000 */
- {11025, 43, 15}, /* 11025 */
- { 8000, 40, 15}, /* 8000 */
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
diff --git a/media/libstagefright/codecs/aacdec/sfb.h b/media/libstagefright/codecs/aacdec/sfb.h
deleted file mode 100644
index 0cc1707..0000000
--- a/media/libstagefright/codecs/aacdec/sfb.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: sfb.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: created to declare scalefactor bands for all sampling rates
-
- Description: Change short to Int16
-
- Description: Eliminated declaration of sfb_96_128 array, values are equal
- to array sfb_64_128
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SFB_H
-#define SFB_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_sr_info.h"
-#include "e_progconfigconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int16 sfb_96_1024[]; /* 41 scfbands */
-
-extern const Int16 sfb_64_1024[]; /* 41 scfbands 47 */
-
-extern const Int16 sfb_64_128[]; /* 12 scfbands */
-
-
-extern const Int16 sfb_48_1024[]; /* 49 scfbands */
-
-extern const Int16 sfb_48_128[]; /* 14 scfbands */
-
-extern const Int16 sfb_32_1024[]; /* 51 scfbands */
-
-extern const Int16 sfb_24_1024[]; /* 47 scfbands */
-
-extern const Int16 sfb_24_128[]; /* 15 scfbands */
-
-extern const Int16 sfb_16_1024[]; /* 43 scfbands */
-
-extern const Int16 sfb_16_128[]; /* 15 scfbands */
-
-extern const Int16 sfb_8_1024[]; /* 40 scfbands */
-
-extern const Int16 sfb_8_128[]; /* 15 scfbands */
-
-extern const SR_Info samp_rate_info[12];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/shellsort.cpp b/media/libstagefright/codecs/aacdec/shellsort.cpp
deleted file mode 100644
index 5feb803..0000000
--- a/media/libstagefright/codecs/aacdec/shellsort.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: shellsort.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Sorting routine
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "shellsort.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void shellsort(Int32 in[], Int32 n)
-{
-
- Int32 i;
- Int32 j;
- Int32 v;
- Int32 inc = 1;
-
- do
- {
- inc = 3 * inc + 1;
- }
- while (inc <= n);
-
- do
- {
- inc = inc / 3;
- for (i = inc + 1; i <= n; i++)
- {
- v = in[i-1];
- j = i;
- while (in[j-inc-1] > v)
- {
- in[j-1] = in[j-inc-1];
- j -= inc;
- if (j <= inc)
- {
- break;
- }
- }
- in[j-1] = v;
- }
- }
- while (inc > 1);
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/shellsort.h b/media/libstagefright/codecs/aacdec/shellsort.h
deleted file mode 100644
index a4658e3..0000000
--- a/media/libstagefright/codecs/aacdec/shellsort.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: shellsort.h
- Funtions:
- get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SHELLSORT_H
-#define SHELLSORT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void shellsort(Int32 in[], Int32 n);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/stereo_2_mono.h b/media/libstagefright/codecs/aacdec/stereo_2_mono.h
deleted file mode 100644
index 3e27c70..0000000
--- a/media/libstagefright/codecs/aacdec/stereo_2_mono.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: stereo_2_mono.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the declaration of the function stereo_2_mono()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef STEREO_2_MONO_H
-#define STEREO_2_MONO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- void stereo_2_mono(
- const Int16 sourceLeft[],
- const Int16 sourceRight[],
- Int16 outputBuffer[],
- const Int sourcePointsPerChannel);
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STEREO_2_MONO_H */
-
diff --git a/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp b/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp
deleted file mode 100644
index c1418e3..0000000
--- a/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: synthesis_sub_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who: Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Int32 vec[], Input vector, 32-bit
- const Int32 *cosTerms, Cosine Terms
- Int32 *scratch_mem Scratch memory
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "dct64.h"
-#include "synthesis_sub_band.h"
-#include "mdst.h"
-#include "dct16.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt_30(x) (Int32)(x*((Int32)(1<<30)) + (x>=0?0.5F:-0.5F))
-#define Qfmt_25(x) (Int32)(x*((Int32)(1<<25))*(1.5625F) + (x>=0?0.5F:-0.5F))
-
-#define SCALE_DOWN_LP Qfmt_30(0.075000F) /* 3/40 */
-#define SCALE_DOWN_HQ Qfmt_30(0.009375F*0.64F) /* 3/40 * 1/8 */
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const Int32 CosTable_64[64] =
-{
- Qfmt_25(0.50003765191555F), Qfmt_25(40.74468810335183F), Qfmt_25(0.50033903744282F), Qfmt_25(13.58429025728446F),
- Qfmt_25(0.50094271763809F), Qfmt_25(8.15384860246681F), Qfmt_25(0.50185051748424F), Qfmt_25(5.82768837784465F),
- Qfmt_25(0.50306519130137F), Qfmt_25(4.53629093696936F), Qfmt_25(0.50459044322165F), Qfmt_25(3.71524273832697F),
- Qfmt_25(0.50643095492855F), Qfmt_25(3.14746219178191F), Qfmt_25(0.50859242104981F), Qfmt_25(2.73164502877394F),
- Qfmt_25(0.51108159270668F), Qfmt_25(2.41416000025008F), Qfmt_25(0.51390632984754F), Qfmt_25(2.16395781875198F),
- Qfmt_25(0.51707566313349F), Qfmt_25(1.96181784857117F), Qfmt_25(0.52059986630189F), Qfmt_25(1.79520521907789F),
- Qfmt_25(0.52449054011472F), Qfmt_25(1.65559652426412F), Qfmt_25(0.52876070920749F), Qfmt_25(1.53699410085250F),
- Qfmt_25(0.53342493339713F), Qfmt_25(1.43505508844143F), Qfmt_25(0.53849943529198F), Qfmt_25(1.34655762820629F),
- Qfmt_25(0.54400224638178F), Qfmt_25(1.26906117169912F), Qfmt_25(0.54995337418324F), Qfmt_25(1.20068325572942F),
- Qfmt_25(0.55637499348989F), Qfmt_25(1.13994867510150F), Qfmt_25(0.56329166534170F), Qfmt_25(1.08568506425801F),
- Qfmt_25(0.57073058801215F), Qfmt_25(1.03694904091039F), Qfmt_25(0.57872188513482F), Qfmt_25(0.99297296126755F),
- Qfmt_25(0.58729893709379F), Qfmt_25(0.95312587439212F), Qfmt_25(0.59649876302446F), Qfmt_25(0.91688444618465F),
- Qfmt_25(0.60636246227215F), Qfmt_25(0.88381100455962F), Qfmt_25(0.61693572600507F), Qfmt_25(0.85353675100661F),
- Qfmt_25(0.62826943197077F), Qfmt_25(0.82574877386279F), Qfmt_25(0.64042033824166F), Qfmt_25(0.80017989562169F),
- Qfmt_25(0.65345189537513F), Qfmt_25(0.77660065823396F), Qfmt_25(0.66743520092634F), Qfmt_25(0.75481293911653F),
- Qfmt_25(0.68245012597642F), Qfmt_25(0.73464482364786F), Qfmt_25(0.69858665064723F), Qfmt_25(0.71594645497057F),
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void synthesis_sub_band_LC(Int32 Sr[], Int16 data[])
-{
-
- Int32 *temp_o1 = (Int32 *) & data[0];
-
- Int i;
- Int32 *pt_temp_e;
- Int32 *pt_temp_o = temp_o1;
- Int32 *pt_temp_x = &Sr[63];
- Int32 temp1;
- Int32 temp2;
- Int32 temp3;
- Int32 temp11;
-
- Int16 *pt_data_1;
- Int16 *pt_data_2;
-
- Int32 *pt_Sr_1 = Sr;
- Int16 tmp1;
- Int16 tmp2;
- Int16 tmp11;
- Int16 tmp22;
- const Int32 *pt_cosTerms = CosTable_48;
-
-
- temp2 = *(pt_temp_x--);
- for (i = 20; i != 0; i--)
- {
- temp1 = *(pt_Sr_1);
- temp3 = *(pt_cosTerms++);
- *(pt_Sr_1++) = temp1 + temp2;
- *(pt_temp_o++) = fxp_mul32_Q31((temp1 - temp2), temp3) << 1;
- temp2 = *(pt_temp_x--);
- }
-
- for (i = 12; i != 0; i--)
- {
- temp1 = *(pt_Sr_1);
- temp3 = *(pt_cosTerms++);
- *(pt_Sr_1++) = temp1 + temp2;
- *(pt_temp_o++) = fxp_mul32_Q26((temp1 - temp2), temp3);
- temp2 = *(pt_temp_x--);
- }
-
-
- pv_split_LC(temp_o1, &Sr[32]);
-
- dct_16(temp_o1, 1); // Even terms
- dct_16(&Sr[32], 1); // Odd terms
-
- /* merge */
-
-
- pt_Sr_1 = &temp_o1[31];
- pt_temp_e = &temp_o1[15];
- pt_temp_o = &Sr[47];
-
- temp1 = *(pt_temp_o--);
- *(pt_Sr_1--) = temp1;
- for (i = 5; i != 0; i--)
- {
- temp2 = *(pt_temp_o--);
- *(pt_Sr_1--) = *(pt_temp_e--);
- *(pt_Sr_1--) = temp1 + temp2;
- temp3 = *(pt_temp_o--);
- *(pt_Sr_1--) = *(pt_temp_e--);
- *(pt_Sr_1--) = temp2 + temp3;
- temp1 = *(pt_temp_o--);
- *(pt_Sr_1--) = *(pt_temp_e--);
- *(pt_Sr_1--) = temp1 + temp3;
- }
-
-
- pv_split_LC(Sr, &Sr[32]);
-
- dct_16(Sr, 1); // Even terms
- dct_16(&Sr[32], 1); // Odd terms
-
-
- pt_temp_x = &temp_o1[31];
- pt_temp_e = &Sr[15];
- pt_temp_o = &Sr[47];
-
- pt_data_1 = &data[95];
-
- temp2 = *(pt_temp_x--);
- temp11 = *(pt_temp_x--);
- temp1 = *(pt_temp_o--);
-
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp2, SCALE_DOWN_LP);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp1, SCALE_DOWN_LP);
-
- for (i = 5; i != 0; i--)
- {
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
- temp3 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
- temp2 = *(pt_temp_o--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP);
- temp11 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp2), SCALE_DOWN_LP);
-
-
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP);
- temp1 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
- temp3 = *(pt_temp_o--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP);
- temp11 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp2 + temp3), SCALE_DOWN_LP);
-
-
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP);
- temp2 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
- temp1 = *(pt_temp_o--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
- temp11 = *(pt_temp_x--);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp3), SCALE_DOWN_LP);
- }
-
- *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
- *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e), SCALE_DOWN_LP);
-
- /* ---- merge ends---- */
-
-
- pt_data_1 = &data[95];
- pt_data_2 = &data[96];
-
- *(pt_data_2++) = 0;
- tmp1 = *(pt_data_1--);
- tmp2 = *(pt_data_1--);
- tmp11 = *(pt_data_1--);
- tmp22 = *(pt_data_1--);
-
- for (i = 7; i != 0; i--)
- {
- *(pt_data_2++) = (-tmp1);
- *(pt_data_2++) = (-tmp2);
- *(pt_data_2++) = (-tmp11);
- *(pt_data_2++) = (-tmp22);
- tmp1 = *(pt_data_1--);
- tmp2 = *(pt_data_1--);
- tmp11 = *(pt_data_1--);
- tmp22 = *(pt_data_1--);
- }
-
-
- *(pt_data_2++) = (-tmp1);
- *(pt_data_2++) = (-tmp2);
- *(pt_data_2++) = (-tmp11);
-
- pt_data_2 = &data[0];
-
- *(pt_data_2++) = tmp22;
- tmp1 = *(pt_data_1--);
- tmp2 = *(pt_data_1--);
- tmp11 = *(pt_data_1--);
- tmp22 = *(pt_data_1--);
-
- for (i = 7; i != 0; i--)
- {
- *(pt_data_2++) = tmp1;
- *(pt_data_2++) = tmp2;
- *(pt_data_2++) = tmp11;
- *(pt_data_2++) = tmp22;
- tmp1 = *(pt_data_1--);
- tmp2 = *(pt_data_1--);
- tmp11 = *(pt_data_1--);
- tmp22 = *(pt_data_1--);
- }
-
- *(pt_data_2++) = tmp1;
- *(pt_data_2++) = tmp2;
- *(pt_data_2++) = tmp11;
- *(pt_data_2) = tmp22;
-
-}
-
-
-void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[])
-{
-
- Int i ;
- Int16 *pt_data_1;
-
- pt_data_1 = &data[0];
-
- dct_32(Sr);
-
- for (i = 0; i < 16; i++)
- {
- pt_data_1[ i] = (Int16)(Sr[16-i] >> 5);
- pt_data_1[16+i] = (Int16)(Sr[i] >> 5);
- pt_data_1[32+i] = (Int16)(Sr[16+i] >> 5);
- }
- for (i = 0; i < 15; i++)
- {
- pt_data_1[49+i] = (Int16)(-Sr[31-i] >> 5);
- }
- pt_data_1[48] = 0;
-}
-
-
-#ifdef HQ_SBR
-
-void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[])
-{
-
-
- Int32 i ;
- Int16 *pt_data_1;
- Int16 *pt_data_2;
- Int32 *pt_Sr_1;
- Int32 *pt_Sr_2;
- Int32 *pt_Si_1;
- Int32 *pt_Si_2;
-
- Int32 tmp1;
- Int32 tmp2;
- Int32 tmp3;
- Int32 tmp4;
-
- Int32 cosx;
- const Int32 *pt_CosTable = CosTable_64;
-
-
- pt_Sr_1 = &Sr[0];
- pt_Sr_2 = &Sr[63];
-
- pt_Si_1 = &Si[0];
- pt_Si_2 = &Si[63];
-
-
- tmp3 = *pt_Sr_1;
-
- for (i = 32; i != 0; i--)
- {
- tmp4 = *pt_Si_2;
- cosx = *(pt_CosTable++);
- *(pt_Sr_1++) = fxp_mul32_Q31(tmp3, cosx);
- tmp3 = *pt_Si_1;
- *(pt_Si_1++) = fxp_mul32_Q31(tmp4, cosx);
- tmp4 = *pt_Sr_2;
- cosx = *(pt_CosTable++);
- *(pt_Si_2--) = fxp_mul32_Q31(tmp3, cosx);
- *(pt_Sr_2--) = fxp_mul32_Q31(tmp4, cosx);
- tmp3 = *pt_Sr_1;
- }
-
-
- dct_64(Sr, (Int32 *)data);
- dct_64(Si, (Int32 *)data);
-
-
- pt_data_1 = &data[0];
- pt_data_2 = &data[127];
-
- pt_Sr_1 = &Sr[0];
- pt_Si_1 = &Si[0];
-
- tmp1 = *(pt_Sr_1++);
- tmp3 = *(pt_Sr_1++);
- tmp2 = *(pt_Si_1++);
- tmp4 = *(pt_Si_1++);
-
- for (i = 32; i != 0; i--)
- {
- *(pt_data_1++) = (Int16) fxp_mul32_Q31((tmp2 - tmp1), SCALE_DOWN_HQ);
- *(pt_data_1++) = (Int16) fxp_mul32_Q31(-(tmp3 + tmp4), SCALE_DOWN_HQ);
- *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp1 + tmp2), SCALE_DOWN_HQ);
- *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp3 - tmp4), SCALE_DOWN_HQ);
-
- tmp1 = *(pt_Sr_1++);
- tmp3 = *(pt_Sr_1++);
- tmp2 = *(pt_Si_1++);
- tmp4 = *(pt_Si_1++);
- }
-
-}
-
-
-const Int32 exp_m0_25_phi[32] =
-{
-
- 0x7FFEFE6E, 0x7FEAFB4A, 0x7FC2F827, 0x7F87F505,
- 0x7F38F1E4, 0x7ED6EEC6, 0x7E60EBAB, 0x7DD6E892,
- 0x7D3AE57D, 0x7C89E26D, 0x7BC6DF61, 0x7AEFDC59,
- 0x7A06D958, 0x790AD65C, 0x77FBD367, 0x76D9D079,
- 0x75A6CD92, 0x7460CAB2, 0x7308C7DB, 0x719EC50D,
- 0x7023C248, 0x6E97BF8C, 0x6CF9BCDA, 0x6B4BBA33,
- 0x698CB796, 0x67BDB505, 0x65DEB27F, 0x63EFB005,
- 0x61F1AD97, 0x5FE4AB36, 0x5DC8A8E2, 0x5B9DA69C
-};
-
-void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[])
-{
-
- Int16 k;
- Int16 *pt_data_1;
- Int32 exp_m0_25;
- const Int32 *pt_exp = exp_m0_25_phi;
-
- Int32 *XX = Sr;
- Int32 *YY = (Int32 *)data;
- Int32 tmp1;
- Int32 tmp2;
-
- for (k = 0; k < 32; k++)
- {
- exp_m0_25 = *(pt_exp++);
- tmp1 = Sr[k];
- tmp2 = Si[k];
- XX[k] = cmplx_mul32_by_16(-tmp1, tmp2, exp_m0_25);
- YY[31-k] = cmplx_mul32_by_16(tmp2, tmp1, exp_m0_25);
- }
-
- mdct_32(XX);
- mdct_32(YY);
-
- for (k = 0; k < 32; k++)
- {
- Si[k] = YY[k];
- }
-
- pt_data_1 = data;
-
- for (k = 0; k < 16; k++)
- {
- *(pt_data_1++) = (Int16)((XX[2*k ] + Si[2*k ]) >> 14);
- *(pt_data_1++) = (Int16)((XX[2*k+1] - Si[2*k+1]) >> 14);
- }
-
- for (k = 15; k > -1; k--)
- {
- *(pt_data_1++) = (Int16)(-(XX[2*k+1] + Si[2*k+1]) >> 14);
- *(pt_data_1++) = (Int16)(-(XX[2*k ] - Si[2*k ]) >> 14);
- }
-
-}
-
-
-#endif /* HQ_SBR */
-
-#endif /* AAC_PLUS */
-
-
diff --git a/media/libstagefright/codecs/aacdec/synthesis_sub_band.h b/media/libstagefright/codecs/aacdec/synthesis_sub_band.h
deleted file mode 100644
index 042c488..0000000
--- a/media/libstagefright/codecs/aacdec/synthesis_sub_band.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: synthesis_sub_band.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef SYNTHESIS_SUB_BAND_H
-#define SYNTHESIS_SUB_BAND_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES AND SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
- void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]);
- void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]);
-
-
-#ifdef HQ_SBR
-
- void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]);
- void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* SYNTHESIS_SUB_BAND_H */
-
diff --git a/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp b/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp
deleted file mode 100644
index db31a63..0000000
--- a/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp
+++ /dev/null
@@ -1,474 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_ar_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Implemented 24-bit fixed point version
- Optimized C code
-
- Description:
- - Added OVERFLOW_SHIFT_DOWN to avoid overflow.
- - Increased precision by using the Q format of the LPC coefficient.
- - Modified interface to add LPC Q format and scratch memory
- for the state variables.
- - Added pv_memset to clear state filter
- - Updated format for comments (to PV standard)
- - Updated copyright notice
-
- Description:
- - Changed multiplication scheme to increase precision. This
- works better than older version.
-
- Description:
- - Include log2(order) as a scaling down parameter.
-
- Description:
- Modified to reflect code review comments
- - misspelled words, extra comments and explicit requirements
-
- Description:
- deleted comment about fix Q format (L 107)
-
- Description: Implemented a more efficient version, which eliminated the use
- of "scratch memory" via introducing a pointer that references the actual
- output.
-
- Description: Removed the parameter "scratch_Int32_buffer" as this space
- in memory is no longer needed by this function.
-
- Description: Removed references to "scratch_Int32_buffer" in the Inputs
- section.
-
- Description:
- Modified casting to ensure proper operations for different platforms
-
- Description:
- Per code review comment:
- Eliminated casting to UInt and Int in b_low and b_high, they are
- redundant and may add unncessary extra cycles in some platforms
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Changed the order of the unsigned * signed multiply so the
- casting to Int32 is performed on the unsigned operand.
-
- Description:
- Modified 32 by 16 bit multiplications to avoid unnecessary moves to
- registers. Also split the code (based on flag direction) to simplify
- pointer's updates
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- spec = spectral input to be shaped by the filter.
- Fixed point format
- Int32[]
- length = spec_length
-
- spec_length = length of spec array.
- const Int
-
- direction = direction for application of tns filter.
- +1 filters spectrum from low to high frequencies
- (first input to filter is spec[0])
- -1 filters spectrum from high to low frequencies
- (first input to filter is spec[spec_length-1])
- const Int
-
- lpc = array of lpc coefficients, minus lpc[0] which is assumed to be "1"
- Fixed point format
- const Int[]
- length = TNS_MAX_ORDER
-
- Q_lpc = Q format for the lpc coeffcients (for max. precision, it assumes
- that all 16 bits are used)
- const Int
-
- order = order of the TNS filter (Range of 1 - TNS_MAX_ORDER)
- Int
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- spec = contains spectral data after application of TNS filter
- Int32 array
- length = spec_length
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- A block of spectral data (Int32 spec[]) of length (const Int spec_length)
- is processed by a simple all-pole filter defined by
- LPC coefficients passed via (const Int lpc[])
-
- TNS filter equation
- y(n) = x(n) - lpc(2)*y(n-1) - ... - lpc(order+1)*y(n-order)
-
- The filter calculation is performed in place, i.e. the output is passed
- back to the calling function via (Int32 spec[])
-
- The filter's order is defined by the variable (const Int order)
- The direction of the filter's application is defined by (const Int inc)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should match the functionality of the ISO code.
- The implementation does support filter orders bigger or equal to 1.
- The size of the spectral coeffcients has to be bigger or equal than 1.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
- FOR (i=0; i<order; i++)
- state[i] = 0;
- ENDFOR
-
- IF (inc == -1)
- THEN
- spec = spec + spec_length - 1;
- ENDIF
-
- FOR (i=0; i<spec_length; i++)
-
- y = *spec;
-
- FOR (j=0; j<order; j++)
-
- y -= lpc[j] * state[j];
-
- ENDFOR
-
- FOR (j=order-1; j>0; j--)
-
- state[j] = state[j-1];
-
- ENDFOR
-
- state[0] = y;
-
- *spec = y;
-
- spec = spec + inc;
-
- ENDFOR
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- When the code is written for a specific target processor
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "tns_ar_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define MASK_LOW16 0xFFFF
-#define UPPER16 16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int tns_ar_filter(
- Int32 spec[],
- const Int spec_length,
- const Int direction,
- const Int32 lpc[],
- const Int Q_lpc,
- const Int order)
-{
-
- Int i;
- Int j;
-
- /*
- * Multiplication related variables
- */
-
- Int32 temp;
-
- /*
- * Filter related variables
- */
- Int32 y0;
-
- /*
- * Circular buffer to hold the filter's state
- * (y[n-1],y[n-2],y[n-3],etc.)
- *
- * p_state and p_lpc should take advantage
- * of any special circular buffer instructions
- * if this code is hand-optimized in assembly.
- */
-
- Int32 *p_state = NULL;
-
- const Int32 *p_lpc;
-
-
- Int shift_up;
- Int shift_down_amount;
-
- /*
- * Pointer to the I/O memory space
- */
- Int32 *p_spec = spec;
-
-
- i = 0;
- j = order;
-
- /*
- * get the power of 2 that is bigger than the order
- * i is the bit counter and j is modified until exceed
- * the power of 2 corresponding to TNS_MAX_ORDER
- */
-
- while (j < 0x010)
- {
- j <<= 1;
- i++;
- }
-
- /*
- * 5 is the number of bits needed to represent 0x010
- * TNS_MAX_ORDER = 20, power of 2 that include 20 is 5
- */
- shift_down_amount = 4 - i;
-
- shift_up = UPPER16 - Q_lpc;
-
- /*
- * shift_down_amount == power of 2 that is bigger than the order - 1
- */
-
- shift_down_amount += shift_up;
-
- if (direction == -1)
- {
- p_spec += spec_length - 1;
-
- for (i = order; i != 0; i--)
- {
-
- y0 = *p_spec >> shift_down_amount;
-
- p_lpc = lpc;
-
- /* 32 by 32 bit multiplication */
- for (j = order; j > i; j--)
- {
- temp = *p_state++;
- y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up;
- }
-
- /*
- * Record the output in-place
- */
- p_state = p_spec;
- *(p_spec--) = y0;
-
- }
-
- if (spec_length > order)
- {
- for (i = (spec_length - order); i != 0; i--)
- {
- y0 = *p_spec >> shift_down_amount;
-
- p_lpc = &(lpc[0]);
-
- /* 32 by 32 bit multiplication */
- for (j = order; j != 0; j--)
- {
- temp = *p_state++;
- y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up;
- }
-
- /*
- * Record the output in-place
- */
- p_state = p_spec;
- *(p_spec--) = y0;
-
- } /* END for (i = (spec_length - order); i>0; i--) */
- }
-
- }
- else
- {
- for (i = order; i != 0; i--)
- {
-
- p_lpc = lpc;
-
- y0 = 0;
-
- /* 32 by 32 bit multiplication */
- for (j = order; j > i; j--)
- {
- y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++));
- }
-
- p_state = p_spec;
- /*
- * Record the output in-place
- */
- *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up);
- p_spec++;
- }
-
- if (spec_length > order)
- {
- for (i = (spec_length - order); i != 0; i--)
- {
- p_lpc = lpc;
-
- y0 = 0;
-
- /* 32 by 32 bit multiplication */
- for (j = order; j != 0; j--)
- {
- y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++));
- }
-
- p_state = p_spec;
- /*
- * Record the output in-place
- */
- *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up);
- p_spec++;
-
- } /* END for (i = (spec_length - order); i>0; i--) */
- }
- }
-
- return(shift_down_amount);
-
-
-} /* tns_ar_filter */
diff --git a/media/libstagefright/codecs/aacdec/tns_ar_filter.h b/media/libstagefright/codecs/aacdec/tns_ar_filter.h
deleted file mode 100644
index 2538b4d..0000000
--- a/media/libstagefright/codecs/aacdec/tns_ar_filter.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_ar_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Per request of JT, the lpc coefficients q-format will now
- be transmitted to the function.
-
- Description: Removed the parameter "scratch_Int32_buffer" as this space
- in memory is no longer needed by this function.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for tns_ar_filter()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_AR_FILTER_H
-#define TNS_AR_FILTER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_tns_const.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- Int tns_ar_filter(
- Int32 spec[],
- const Int spec_length,
- const Int inc,
- const Int32 lpc[],
- const Int lpc_qformat,
- const Int order);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp b/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp
deleted file mode 100644
index 366cce5..0000000
--- a/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_decode_coef.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Implemented in 16-bit Fixed Point
-
- Description: Implemented in 24-bit Fixed Point
-
- Description: Modified to return the calculated LPC coefficients "in place"
- This saves memory, cycles, etc. because it saves a large temporary
- array being declared on the stack in another function (tns_setup_filter)
-
- Description: Modified to return the q-format of the lpc coefficients.
-
- Description: Modified for more reliable overflow protection. tns_decode_coef
- no longer relies on "reasonable" outputs. This code should handle all
- possible inputs.
-
- Description: Modified per review comments.
-
- Description: Added check condition to avoid numbers with a Q bigger than
- 15 from being passed, otherwise in a 16-bit number the sign is lost.
-
- Description: Modified to utilize scratch memory techniques, thereby
- eliminating two arrays of size TNS_MAX_ORDER, which were previously declared
- on the stack.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description:
- (1) Changed the order of the unsigned * signed multiply so the
- casting to Int32 is performed on the unsigned operand.
-
- (2) Removed some unnecessary casting.
- (3) Fixed a problem where a 16-bit value was casted to 32-bits AFTER
- a shift. It should have been cast to 32-bits BEFORE the shifting.
-
-
- Description: modified precision of coefficients
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- The inputs and their range are defined in ISO/IEC 14496-3:1999(E)
- Part 3 MPEG-4 Audio
- Subpart 4
-
- Inputs: order = RANGE = 1-20
- const Int
-
- coef_res = RANGE = 0-1
- const Int
-
- lpc_coef = RANGE = -8 to 7 if coef_res = 1 compression OFF
- -4 to 3 if coef_res = 1 compression ON
- -4 to 3 if coef_res = 0 compression OFF
- -2 to 1 if coef_res = 0 compression ON
-
- [Int *, length TNS_MAX_ORDER]
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- q_lpc = q_format for the calculated LPC coefs.
- Int
-
- Pointers and Buffers Modified:
- lpc_coef = used to return the calculated LPC coefs in-place.
- Int *
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-This function calculates the LPC coefs from the encoded coefs...
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-This function should match the functionality of the ISO source code within
-a reasonable tolerance for fixed point errors.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.8 (Temporal Noise Shaping)
- (2) Markel & Gray Page 95
- As referenced in the ISO source code
-
- (3) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
- PSEUDOCODE: (ISO Reference Code)
-
- int i, m;
- Real iqfac, iqfac_m;
- Real lpc_fp[TNS_MAX_ORDER+1];
- Real sin_result_fp[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1];
-
- Inverse quantization
- iqfac = (Real)(((1 << (coef_res-1)) - 0.5) / (PI/2.0));
- iqfac_m = (Real)(((1 << (coef_res-1)) + 0.5) / (PI/2.0));
-
- for (i=0; i<order; i++)
- {
- sin_result[i+1] =
- (Real)sin( coef[i] / ((coef[i] >= 0) ? iqfac : iqfac_m) );
- }
-
- lpc[0] = 1;
- for (m=1; m<=order; m++)
- {
-
- b[0] = lpc[0];
- for (i=1; i<m; i++)
- {
- b[i] = sin_result[m] * lpc[m-i];
- b[i] += lpc[i];
- }
-
- b[m] = sin_result[m];
-
-
- for (i=0; i<=m; i++)
- {
- lpc[i] = b[i];
- }
-
- }
-
- return;
-
-}
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "tns_decode_coef.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define MASK_LOW16 0xffff
-#define UPPER16 16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*
- * Derivation of tns_tables and q_tns_tables
- *
- * As defined in the ISO source code
- * (with the modification that our coef_res has a range[0,1]
- * The ISO code has a range of [3,4])
- *
- * pi / 2 pi / 2
- * iqfac = -------------------- iqfac_m = --------------------
- * (coef_res + 2) - 1/ (coef_res + 2) + 1/
- * 2 /2 2 /2
- *
- *
- * ... Move 1/2 into denominator
- *
- * pi pi
- * iqfac = -------------------- iqfac_m = --------------------
- * (coef_res + 3) (coef_res + 3)
- * 2 - 1 2 + 1
- *
- *
- * if a coef is negative, it is multiplied by iqfac_m
- * if positive, " " " iqfac
- *
- * The range of coefs is limited to -4:3 if coef_res = 0
- * -8:7 if coef_res = 1
- *
- *
- *
- */
-
-
-const Int32 tns_table[2][16] =
-{
- {
- -2114858546, -1859775393, -1380375881, -734482665,
- 0, 931758235, 1678970324, 2093641749
- },
- {
- -2138322861, -2065504841, -1922348530, -1713728946,
- -1446750378, -1130504462, -775760571, -394599085,
- 0, 446486956, 873460290, 1262259218,
- 1595891361, 1859775393, 2042378317, 2135719508
- }
-};
-
-
-const Int neg_offset[2] = {4, 8};
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- FUNCTION NAME: tns_decode_coef
- Decoder transmitted coefficients for one TNS filter
-----------------------------------------------------------------------------*/
-
-Int tns_decode_coef(
- const Int order,
- const Int coef_res,
- Int32 lpc_coef[TNS_MAX_ORDER],
- Int32 scratchTnsDecCoefMem[2*TNS_MAX_ORDER])
-{
-
- /* Simple loop counters */
- Int i;
- Int m;
-
- /* Arrays for calculation of the LPC */
- Int32 *pB = &(scratchTnsDecCoefMem[TNS_MAX_ORDER]);
-
- Int32 *pA = scratchTnsDecCoefMem;
-
- Int32 *temp_ptr = NULL;
-
- /* Pointer for reading/storing the lpc_coef in place */
- Int32 *pLPC;
- Int q_lpc = Q_LPC;
-
- /* TNS table related variables */
- const Int32 *pTnsTable;
- Int coef_offset;
- Int32 table_index;
- Int shift_amount;
- Int32 sin_result;
-
- Int32 tempInt32;
-
- Int32 max;
- Int32 mask;
-
- Int32 mult_high;
-
- /* Conversion to LPC coefficients Ref. (2) */
- coef_offset = neg_offset[coef_res];
- pTnsTable = tns_table[coef_res];
-
- m = 0;
- pLPC = lpc_coef;
-
-
- /*
- * Conversion to LPC coefficients
- */
-
- do
- {
- table_index = coef_offset + *(pLPC++);
-
- /* Equiv. to sin_result = tns_table[coef_res][table_index]; */
- sin_result = *(pTnsTable + table_index);
-
- /* sin_result has a range of -0.999 to +0.999 in Q-31 */
-
- /*
- * It is important that this for loop is not entered on the first
- * iteration of the do-while( m < order ) loop.
- */
- for (i = m; i > 0; i--)
- {
-
- /*
- * temp_ptr used to optimize index into pA
- * mult = (Int32)( pA[m-i] * sin_result);
- */
-
- mult_high = fxp_mul32_Q31(*(temp_ptr--), sin_result);
-
- /*
- * pB[i] = pA[i] + sin_result * pA[m-i]
- *
- * (mult_high <<1) eliminates extra sign bit
- */
-
- *(pB++) = *(pA++) + (mult_high << 1);
-
- } /* END for (i=m; i > 0; i--) */
-
-
- /* Shift to place pB[m] in q_lpc format */
-
- *pB = sin_result >> 12;
-
- /*
- * Swapping the pointers here has the same effect
- * as specifically copying the data from b to a
- */
-
- temp_ptr = pA;
- pA = pB;
- pB = temp_ptr;
-
- /*
- * At this point, pA = pA[m]
- * and pB = pB[m]
- */
- temp_ptr = pA;
-
- tempInt32 = *(pA);
-
- mask = tempInt32 >> 31;
- tempInt32 ^= mask;
-
- max = tempInt32;
-
- /*
- * It is important that this for loop is not entered on the first
- * iteration of the do-while( m < order ) loop.
- */
- for (i = m; i > 0; i--)
- {
- tempInt32 = *(--pA);
-
- mask = tempInt32 >> 31;
- tempInt32 ^= mask;
-
- max |= tempInt32;
- }
-
- pB -= m;
-
- /*
- * Here, pA = &(pA[0])
- * and pB = &(pB[0])
- */
-
- if (max >= 0x40000000L)
- {
- max >>= 1;
-
- for (i = m; i > 0; i--)
- {
- *(pA++) >>= 1;
- *(pB++) >>= 1;
- }
-
- /* Shift the most recent entry down also */
- *(pA) >>= 1;
-
- q_lpc--;
-
- pA -= m;
- pB -= m;
- }
-
- m++;
-
- }
- while (m < order);
-
-
- /*
- * The following code compacts
- * 32-bit LPC coefficients into 16-bit numbers,
- * shifting by the minimum amount necessary.
- */
-
- shift_amount = 0;
-
- while (max > 32767)
- {
- max >>= 1;
- shift_amount++;
- }
-
- /*
- * This while loop is for protective purposes only.
- * I have not found data that causes it to be entered.
- *
- */
- if (max != 0)
- {
- while (max < 16384)
- {
- max <<= 1;
- shift_amount--;
- }
- }
-
-
- pLPC = lpc_coef;
-
- if (shift_amount >= 0)
- {
-
- for (m = order; m > 0; m--)
- {
- *(pLPC++) = *(pA++) << (16 - shift_amount);
- }
- }
-
-
- q_lpc -= shift_amount;
-
- /*
- * make sure that the numbers have some meaning, q_lpc can not be
- * bigger than 15 (15 bits + sign)
- */
-
- if (q_lpc > 15)
- {
- shift_amount = q_lpc - 15;
- pLPC = lpc_coef;
-
- for (m = order; m > 0; m--)
- {
- *(pLPC++) >>= shift_amount;
- }
-
- q_lpc -= shift_amount;
- }
-
- return (q_lpc);
-
-} /* tns_decode_coef */
diff --git a/media/libstagefright/codecs/aacdec/tns_decode_coef.h b/media/libstagefright/codecs/aacdec/tns_decode_coef.h
deleted file mode 100644
index a6bac6c..0000000
--- a/media/libstagefright/codecs/aacdec/tns_decode_coef.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_decode_coef.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified to return the LPC coefficients in-place, so the
- interface to tns_decode_coef is changed.
-
- Description: Modified to return the q-format of the LPC coefficients.
-
- Description: Modified so that only the function is declared here. extern
- references to constant tables removed. Also, new copyright header included.
-
- Description: Modified to include extra parameter, so tns_decode_coef can use
- scratch memory techniques.
-
- Description:
- (1) Modified to include the lines...
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- (2) Updated the copyright header.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for tns_decode_coef()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_DECODE_COEF_H
-#define TNS_DECODE_COEF_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
- Int tns_decode_coef(
- const Int order,
- const Int coef_res,
- Int32 lpc_coef[],
- Int32 scratchTnsDecCoefMem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TNS_DECODE_COEF */
diff --git a/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp b/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp
deleted file mode 100644
index 631f887..0000000
--- a/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_inv_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changes made per review comments.
-
- Description: As requested by JT, the q-format for the LPC coefficients is
- now passed via the parameter lpc_qformat.
-
- Description: For speed, the calculation of the shift amount was pulled
- outside of the loop.
-
- Description:
- Modified casting to ensure proper operations for different platforms
-
- Description:
- Simplified MAC operations for filter by eliminating extra variables
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- coef = spectral input to be shaped by the filter.
- Fixed point format
- [Int32[], length = num_coef]
-
- num_coef = length of spec array.
- [const Int]
-
- direction = direction for application of tns filter.
- +1 applies forward filter
- (first input to filter is coef[0])
- -1 applies reversed filter
- (first input to filter is coef[num_coef-1])
- [const Int]
-
- lpc = array of lpc coefficients.
- Fixed point format Q-11
- [const Int[], length = TNS_MAX_ORDER]
-
- lpc_qformat = The q-format of the lpc coefficients.
- [const Int]
-
- order = order of the TNS filter (Range of 1 : TNS_MAX_ORDER)
- [const Int]
-
- scratch_memory = scratch_memory needed for filter operation
- [Int[], length = TNS_MAX_ORDER]
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- coef = contains spectral data after application of TNS filter
- q-format is not modified.
- Int32 array
- length = num_coef
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- A block of spectral data (Int32 coef[]) of length (const Int num_coef)
- is processed by a simple all-zero filter defined by
- LPC coefficients passed via (const Int lpc[])
-
- TNS filter equation
- y(n) = x(n) + lpc(2)*x(n-1) + ... + lpc(order+1)*x(n-order)
-
- The filter calculation is performed in place, i.e. the output is passed
- back to the calling function via (Int32 coef[])
-
- In order to avoid overflow, the filter input (Int32 coef[]) must utilize
- only the lower 16-bits. The upper 16-bits must be available.
-
- The filter's order is defined by the variable (const Int order)
-
- The direction of the filter's application is defined by
- (const Int direction)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- [Int32 coef] must store no more than 16 bits of data.
-
- This is required to utilize methods that do not change the q-format of
- the input data [Int32 coef], and to make use of a fast
- 16 x 16 bit multiply.
-
- This function should not be called for order <= 0.
-
- This function must not be called with lpc_qformat < 5
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.6.4.1 (LTP with TNS)
- Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF (direction == -1)
- THEN
- pCoef = pCoef + (num_coef - 1);
- END IF
-
- FOR (i = order; i > 0; i--)
-
- *(pFilterInput) = 0;
- pFilterInput = pFilterInput + 1;
-
- END FOR
-
- wrap_point = 0;
-
- shift_amt = (lpc_qformat - 5);
-
- FOR (i = num_coef; i > 0; i--)
-
- pLPC = lpc;
-
- mult = 0;
-
- FOR (j = wrap_point; j>0; j--)
-
- tempInt32 = (Int32)(*(pLPC) * *(pFilterInput));
- tempInt32 = tempInt32 >> 5;
-
- mult = mult + tempInt32;
-
- pFilterInput = pFilterInput + 1;
- pLPC = pLPC + 1;
-
- ENDFOR
-
- pFilterInput = scratch_memory;
-
- FOR (j = (order - wrap_point); j>0; j--)
-
- tempInt32 = (Int32)(*(pLPC) * *(pFilterInput));
- tempInt32 = tempInt32 >> 5;
-
- mult = mult + tempInt32;
-
- pFilterInput = pFilterInput + 1;
- pLPC = pLPC + 1;
-
- ENDFOR
-
- pFilterInput = pFilterInput - 1;
- *(pFilterInput) = (Int)(*pCoef);
-
- mult = mult >> shift_amt;
-
- *(pCoef) = *(pCoef) + mult;
-
- pCoef = pCoef + direction;
-
- wrap_point = wrap_point + 1;
-
- IF (wrap_point == order)
- THEN
- wrap_point = 0;
- END IF
-
- END FOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- When the code is written for a specific target processor
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "tns_inv_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void tns_inv_filter(
- Int32 coef[],
- const Int num_coef,
- const Int direction,
- const Int32 lpc[],
- const Int lpc_qformat,
- const Int order,
- Int32 scratch_memory[])
-{
-
- Int i;
- Int j;
- Int shift_amt;
- Int wrap_point;
-
- Int32 mult;
-
- /*
- * Circular buffer to hold the filter's input
- *
- * (x[n-1],x[n-2],x[n-3],etc.)
- *
- * This scratch space is necessary, because
- * the filter's output is returned in-place.
- *
- * pFilterInput and pLPC should take advantage
- * of any special circular buffer instructions
- * if this code is hand-optimized in assembly.
- *
- */
- Int32 *pFilterInput = scratch_memory;
-
- const Int32 *pLPC;
-
- /*
- * Pointer to the I/O memory space
- */
- Int32 *pCoef = coef;
-
- if (direction == -1)
- {
- pCoef += (num_coef - 1);
- }
-
- /* Make sure the scratch memory is "clean" */
- for (i = order; i != 0; i--)
- {
- *(pFilterInput++) = 0;
- }
-
- wrap_point = 0;
-
- shift_amt = (lpc_qformat - 5);
-
- for (i = num_coef; i > 0; i--)
- {
- /*
- * Copy spectral input into special
- * filter input buffer.
- */
- pLPC = lpc;
-
- mult = 0;
-
- /*
- * wrap_point = 0 when this code is
- * entered for the first iteration of
- * for(i=num_coef; i>0; i--)
- *
- * So, this first for-loop will be
- * skipped when i == num_coef.
- */
-
- for (j = wrap_point; j > 0; j--)
- {
- mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5;
-
- } /* for (j = wrap_point; j>0; j--) */
-
- /*
- * pFilterInput has reached &scratch_memory[order-1]
- * Reset pointer to beginning of filter's state memory
- */
- pFilterInput = scratch_memory;
-
- for (j = (order - wrap_point); j > 0; j--)
- {
- mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5;
-
- } /* for (j = wrap_point; j>0; j--) */
-
-
- /*
- * Fill the filter's state buffer
- * avoid obvious casting
- */
- *(--pFilterInput) = (*pCoef);
-
-
- /* Scale the data down so the output q-format is not adjusted.
- *
- * Here is an equation, which shows how the spectral coefficients
- * and lpc coefficients are multiplied and the spectral
- * coefficient's q-format does not change.
- *
- * Q-(coef) * Q-(lpc_qformat) >> 5 = Q-(coef + lpc_q_format - 5)
- *
- * Q-(coef + lpc_q_format - 5) >> (lpc_qformat - 5) = Q-(coef)
- */
-
- /* Store output in place */
- *(pCoef) += (mult >> shift_amt);
-
- /* Adjust pointers and placeholders */
- pCoef += direction;
-
- wrap_point++;
-
- if (wrap_point == order)
- {
- wrap_point = 0;
- }
-
- } /* for (i = num_coef; i > 0; i--) */
-
-} /* tns_inv_filter */
diff --git a/media/libstagefright/codecs/aacdec/tns_inv_filter.h b/media/libstagefright/codecs/aacdec/tns_inv_filter.h
deleted file mode 100644
index 1b57fc1..0000000
--- a/media/libstagefright/codecs/aacdec/tns_inv_filter.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_inv_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Per request of JT, the lpc coefficients q-format will now
- be transmitted to the function.
-
- Description: The scratch memory was mistakenly declared here as type "Int32"
- It should have been "Int"
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- tns_inv_filter.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_INV_FILTER_H
-#define TNS_INV_FILTER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void tns_inv_filter(
- Int32 coef[],
- const Int num_coef,
- const Int inc,
- const Int32 lpc[],
- const Int lpc_qformat,
- const Int order,
- Int32 scratch_memory[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp b/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp
deleted file mode 100644
index 6ccc023..0000000
--- a/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp
+++ /dev/null
@@ -1,2604 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: trans4m_freq_2_time_fxp.c
- Function: trans4m_freq_2_time_fxp
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- changed to decrement loop
- change wnd_shape from structure to passing parameters
- modified window tables from UInt to UInt16 to assure proper operation
- without dubious typecast
- changed logic to hit most common states first.
- modified Time_data from Int to Int32 to hold
- possible overflow before saturation process.
-
- Description:
- Increase processing on some loop by using more pointers
- changed interface to avoid passing a pointer for wnd_shape_prev_bk, this
- element is not change in this function because of this function use
- in the LTP module
-
- Description:
- Added rounding to multiplication
-
- Description:
- Update input description and eliminate unneeded comments
-
- Description:
- LONG_START_WINDOW was using SHORT_WINDOW instead of
- HALF_SHORT_WINDOW, causing a for loop to exceed its count
-
- Description:
- Modified structure of code so exp is not tested before it
- is initialized. Also, new structure avoids double-testing
- of exp_freq = ALL_ZEROS_BUFFER.
-
- Description:
- The result of a shift is undefined if the right operand is greater than
- or equal to the number of bits in the left expression's type
- To avoid undefined shift by 32, a check of the shift has been
- added, so the function proceeds only when the exponent is less
- than 32. By design the shift up is related to the global gain,
- and controlled by the encoder, so saturation is not allowed.
- In both short and long window, processing is skip if an all zero
- input buffer or excessive down shift is detected.
-
- Description:
- Changes according to code review comments. Also, modified if-else
- structure so the imdct_fxp is not called with an all zero input buffer
-
- Description:
- Replaced function buffer_normalization by buffer_adaptation, to ease
- use of 16 bits. Function buffer_normalization becomes obsolete.
-
- Description:
- Modified call to imdct_fxp to reflect extended precision use. Added
- routine buffer_adaptation to extract 16 MSB and keep highest.
- precision. Modify casting to ensure proper operations for different
- platforms
-
- Description:
- Eliminate double access to memory by loading data directly to the
- time array. Also reduced cycle count and added precision by combining
- downshifting in only one operation. Added adaptive rounding factor.
- Change exponent threshold when operations are waived. It is use to be 32
- but by combining downshifting, this new threshold is now 16. This may
- avoid unneeded calculations for extremely small numbers.
-
- Description:
- Per review comments:
- - Added comments to clarify buffer_adaptation function
- - Deleted reference to include file "buffer_normalization.h"
- - Modified IF-ELSE so long_windows case is considered first
- - Eliminated extra IF when computing the rounding, so when exp ==0
- less cycles are used shifting than in an extra if-else
- - Corrected negative shift when computing rounding factor
- - Added condition when exp > 16 (for long windows)
-
- Description:
- Modified IF-ELSE structure so now ALL_ZEROS_BUFFER condition is share
- with exp > 16 condition. This avoid code duplication for both cases.
-
- Description:
- - Modified function interface to add output_buffer
- - Eliminated the 32 bit version of the current output, calculations
- are placed directly in output_buffer. In this way the buffer
- Time_data needs only to be 1024 Int32, instead of 2048 (per channel).
- Also, added the limit macro inside the function (this reduces access
- to memory).
- - Updated Pseudo - Code
-
- Description:
- Per review comments:
- Corrected line sizes and mispelling, added comments and swap
- order or switch statement for ONLY_LONG_SEQUENCE.
-
- Description:
- Eliminated adaptive rounding due to potential saturation.
-
- Description:
- Eliminated use of buffer adaptation by shifting this functionality inside
- the imdct_fxp() routine. Also modified the call to imdct_fxp to accomodate
- new function interface.
- Modified macro limit() to save cycles when testing the most common case:
- no saturation.
-
- Description:
- Changed new function interface for imdct_fxp().
-
- Description:
- Replaced for-loop with memset and memcopy.
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Frequency_data = vector with spectral information, size 2048
- type Int32
-
- Time_data = buffer with data from previous Frequency to Time
- conversion, used for overlap and add, size 1024
- type Int32
-
- Output_buffer = place holder for current output, size 1024
- type Int16
-
- wnd_seq = window sequence
- type WINDOW_SEQUENCE
-
- wnd_shape_prev_bk = previous window shape type
- type Int
-
- wnd_shape_this_bk = current window shape type
- type Int
-
- Q_format = Q format for the input frequency data
- type Int
-
- freq_2_time_buffer[] = scratch memory for computing FFT
- type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- Output_buffer
- Time_data
- Frequency_data
- pWnd_shape_prev_bk
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-The time/frequency representation of the signal is mapped onto the time
-domain by feeding it into the filterbank module. This module consists of
-an inverse modified discrete cosine transform (IMDCT), and a window and an
-overlap-add function. In order to adapt the time/frequency resolution of the
-filterbank to the characteristics of the input signal, a block switching tool
-is also adopted. N represents the window length, where N is a function of the
-window_sequence. For each channel, the N/2 time-frequency values are
-transformed into the N time domain values via the IMDCT. After applying the
-window function, for each channel, the first half of the sequence is added to
-the second half of the previous block windowed sequence to reconstruct the
-output samples for each channel outi,n.
-
-The adaptation of the time-frequency resolution of the filterbank to the
-characteristics of the input signal is done by shifting between transforms
-whose input lengths are either 2048 or 256 samples. By enabling the block
-switching tool, the following transitions are meaningful:
-
-from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE
- ONLY_LONG_SEQUENCE
-
-from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE
- EIGHT_SHORT_SEQUENCE
-
-from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE
- ONLY_LONG_SEQUENCE
-
-from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE
- EIGHT_SHORT_SEQUENCE
-
-Window shape decisions are made by the encoder on a frame-by-frame-basis.
-The window selected is applicable to the second half of the window function
-only, since the first half is constrained to use the appropriate window
-shape from the preceding frame.
-The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are
-the last 1024 values of the previous window_sequence concatenated with 1024
-values of the current block. The formula below shows this fact:
-
- | x(i-1)(n+1024) for 0 < n < 1024
- x'(i)(n) {
- | x(i)(n) for 1024 < n < 2048
-
-
-Buffer Time_data data from previous Frequency to Time conversion, used
-for overlap and add
-
-Once the window shape is selected, the window_shape syntax element is
-initialized. Together with the chosen window_sequence all information needed
-for windowing exist.
-With the window halves described below all window_sequences can be assembled.
-For window_shape == 1, the window coefficients are given by the Kaiser -
-Bessel derived (KBD) window.
-Otherwise, for window_shape == 0, a sine window is employed.
-
-The window length N can be 2048 or 256 for the KBD and the sine window.
-All four window_sequences explained below have a total length of 2048
-samples.
-For all kinds of window_sequences the window_shape of the left half of
-the first transform window is determined by the window shape of the previous
-block.
-
-In the case of EIGHT_SHORT_SEQUENCE the processing is done in-place and
-in descendent order to avoid using extra memory.
-The ordering is as follows:
-
- Pn: Previous data for window n
- Cn: Current data for window n
-
-
- 128 freq.
- samples
- FREQ ++++++
-IN ===========================
- \
- \
- -> 256 time
- samples
-
- P8 C8
- 8 #######++++++
- P7 C7
- 7 #######++++++
- : :
- : :
- P2 C2
- 2 #######++++++
- P1 C1
- 1 #######++++++
- TIME
-OUT ==============================================================
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall implement a scheme to switch between window types
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] ISO 14496-3:1999, pag 111
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-
- IF ( wnd_seq == EIGHT_SHORT_SEQUENCE)
- THEN
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Time_data[LONG_WINDOW + i] = 0;
- ENDFOR
-
- FOR ( wnd=NUM_SHORT_WINDOWS-1; wnd>=0; wnd--)
-
- pFreqInfo = &Frequency_data[ wnd*SHORT_WINDOW];
-
- CALL IMDCT( pFreqInfo, SHORT_BLOCK1);
- MODIFYING(pFreqInfo)
-
-
- IF (wnd == 0)
- THEN
- pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0];
- ELSE
- pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0];
- ENDIF
-
- pShort_Window_2 =
- &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1];
-
- FOR( i=0, j=SHORT_WINDOW; i<SHORT_WINDOW; i++, j--)
- pFreqInfo[ i] *= pShort_Window_1[i];
- pFreqInfo[SHORT_WINDOW+i] *= pShort_Window_2[j];
- ENDFOR
-
-
- FOR( i=0; i<SHORT_BLOCK1; i++)
- Time_data[W_L_STOP_1 + SHORT_WINDOW*wnd + i] += pFreqInfo[i];
- ENDFOR
-
- ENDFOR
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- temp = Time_data[i];
- Output_buffer[i] = Time_data[i];
- Time_data[i] = temp;
- ENDFOR
- ELSE
-
- CALL IMDCT( Frequency_data, LONG_BLOCK1)
- MODIFYING(Frequency_data)
-
- SWITCH ( wnd_seq)
-
- CASE ( ONLY_LONG_SEQUENCE)
-
- pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
- pLong_Window_2 =
- &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
- FOR (i=0; i<LONG_WINDOW; i++)
- Frequency_data[ i] *= *pLong_Window_1++;
- Frequency_data[LONG_WINDOW+i] *= *pLong_Window_2--;
- ENDFOR
-
- BREAK
-
- CASE ( LONG_START_SEQUENCE)
-
- pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Frequency_data[ i] *= *pLong_Window_1++;
- ENDFOR
-
- pShort_Window_1 =
- &Short_Window[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- FOR ( i=0; i<SHORT_WINDOW; i++)
- Frequency_data[W_L_START_1 + i] *= *pShort_Window_1--;
- ENDFOR
-
- FOR ( i=W_L_START_2; i<LONG_BLOCK1; i++)
- Frequency_data[W_L_START_2 + i] = 0;
- ENDFOR
-
- BREAK
-
-
- CASE ( LONG_STOP_SEQUENCE )
-
- FOR ( i=0; i<W_L_STOP_1; i++)
- Frequency_data[ i] = 0;
- ENDFOR
-
- pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0];
-
- FOR ( i=0; i<SHORT_WINDOW; i++)
- Frequency_data[W_L_STOP_1+ i] *= *pShort_Window_1++;
- ENDFOR
-
- pLong_Window_1 =
- &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Frequency_data[LONG_WINDOW + i] *= *pLong_Window_1--;
- ENDFOR
-
- BREAK
-
- }
-
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Output_buffer[i] = Frequency_data[i] + Time_data[i];
- Time_data[i] = Frequency_data[LONG_WINDOW+i];
- ENDFOR
-
- }
-
- ENDIF
-
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-#include "imdct_fxp.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; limit(x) saturates any number that exceeds a 16-bit representation into a
-; 16 bit number.
-----------------------------------------------------------------------------*/
-
-#define ROUNDING_SCALED (ROUNDING<<(16 - SCALING))
-
-
-#if defined(PV_ARM_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
- Int32 x;
- Int32 z;
- __asm
- {
- mov x, ROUNDING_SCALED
- mov y, y, lsl #(15-SCALING)
- qdadd z, x, y
- mov y, z, lsr #16
- }
- return((Int16)y);
-}
-
-#define limiter( y, x) y = sat(x);
-
-
-
-#elif defined(PV_ARM_GCC_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
- register Int32 x;
- register Int32 ra = (Int32)y;
- register Int32 z = ROUNDING_SCALED;
-
-
- asm volatile(
- "mov %0, %1, lsl #5\n\t" // (15-SCALING) assembler does not take symbols
- "qdadd %0, %2, %0\n\t"
- "mov %0, %0, lsr #16"
- : "=&r*i"(x)
- : "r"(ra),
- "r"(z));
-
- return ((Int16)x);
-}
-
-#define limiter( y, x) y = sat(x);
-
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-
-#define limiter( y, x) z = x<< (15-SCALING); \
- y = _DAddSatInt( ROUNDING_SCALED, z)>>16;
-
-
-#else
-
-#define limiter( y, x) z = ((x + ROUNDING )>>SCALING); \
- if ((z>>15) != (z>>31)) \
- { \
- z = (z >> 31) ^ INT16_MAX; \
- } \
- y = (Int16)(z);
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-void trans4m_freq_2_time_fxp_1(
- Int32 Frequency_data[],
- Int32 Time_data[],
- Int16 Output_buffer[],
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int Q_format,
- Int32 abs_max_per_window[],
- Int32 freq_2_time_buffer[])
-
-{
- Int exp;
- Int shift;
-
- Int i;
- Int wnd;
-#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
- Int32 z;
-#endif
-
- Int16 *pFreqInfo;
- Int32 temp;
- Int32 test;
-
- Int16 *pFreq_2_Time_data_1;
- Int16 *pFreq_2_Time_data_2;
-
- const Int16 *pLong_Window_1;
- const Int16 *pLong_Window_2;
- const Int16 *pShort_Window_1;
- const Int16 *pShort_Window_2;
-
- Int32 *pOverlap_and_Add_Buffer_1;
- Int32 *pOverlap_and_Add_Buffer_2;
-
- Int16 *pOutput_buffer;
- Int16 *pOutput_buffer_2;
-
- const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
- const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
- Long_Window_fxp[0] = Long_Window_sine_fxp;
- Long_Window_fxp[1] = Long_Window_KBD_fxp;
- Short_Window_fxp[0] = Short_Window_sine_fxp;
- Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
-
- if (wnd_seq != EIGHT_SHORT_SEQUENCE)
- {
-
- pFreqInfo = (Int16 *)Frequency_data;
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- LONG_BLOCK1,
- Q_format,
- abs_max_per_window[0]);
-
-
-
- /*
- * The C Programming Language, Second Edition, Kernighan & Ritchie,
- * page 206.
- * "The result [of a shift] is undefined if the right operand is
- * negative, or greater than or equal to the number of bits in the
- * left expression's type"
- * => avoid shift by 32 or 16
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = pFreqInfo;
-
- switch (wnd_seq)
- {
-
- case ONLY_LONG_SEQUENCE:
- default:
-
- pOutput_buffer = Output_buffer;
-
- pOverlap_and_Add_Buffer_1 = Time_data;
-
- {
- const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
- Int32 * pFreq2T = (Int32 *)pFreqInfo;
- Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0];
- Int shift = exp + 15 - SCALING;
-
-
- Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW];
-
-
- for (i = HALF_LONG_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int32 temp2, test2;
-
- Int32 winx;
-
- temp2 = *(pFreq2T++);
- winx = *(win++);
-
- test = *(pOverlap_and_Add_Buffer_1++);
- test2 = *(pOverlap_and_Add_Buffer_1--);
- temp = fxp_mul_16_by_16bb(temp2, winx) >> shift;
- temp2 = fxp_mul_16_by_16tt(temp2, winx) >> shift;
- limiter(*(pOutput_buffer++), (temp + test));
- limiter(*(pOutput_buffer++), (temp2 + test2));
-
- temp2 = *(pFreq2T_2++);
-
- win1 = *(pLong_Window_2--);
- win2 = *(pLong_Window_2--);
- temp = fxp_mul_16_by_16bb(temp2, win1) >> shift;
- test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp;
- *(pOverlap_and_Add_Buffer_1++) = test2;
-
- }
- }
-
- break;
-
- case LONG_START_SEQUENCE:
-
-
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[ HALF_LONG_WINDOW];
-
- pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
- pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
- pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW];
-
- pOutput_buffer = Output_buffer;
- pOutput_buffer_2 = pOutput_buffer + HALF_LONG_WINDOW;
-
-
- shift = exp + 15 - SCALING;
-
- for (i = HALF_LONG_WINDOW; i != 0; i--)
- {
-
- Int16 win1, win2;
- Int16 dat1, dat2;
- Int32 test1, test2;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pLong_Window_1++);
- test1 = *(pOverlap_and_Add_Buffer_1++);
-
- dat2 = *(pFreq_2_Time_data_2++);
- win2 = *(pLong_Window_2++);
- test2 = *(pOverlap_and_Add_Buffer_2++);
-
- limiter(*(pOutput_buffer++), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift)));
-
- limiter(*(pOutput_buffer_2++), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift)));
-
- }
-
- /*
- * data unchanged from LONG_WINDOW to W_L_START_1
- * only scaled accordingly
- */
-
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
- pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW];
-
- exp -= SCALING;
-
- if (exp >= 0)
- {
-
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++) >> exp;
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++) >> exp;
-
- }
-
- }
- else if (exp < 0)
- {
-
- Int shift = -exp;
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--)
- {
- Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- *(pOverlap_and_Add_Buffer_1++) = temp2;
- temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- *(pOverlap_and_Add_Buffer_1++) = temp2;
- }
-
- }
- else
- {
-
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++);
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++);
-
- }
-
- }
-
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1];
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
- pShort_Window_1 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW;
-
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 +
- HALF_SHORT_WINDOW;
-
-
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int16 dat1, dat2;
- Int32 temp2;
- dat1 = (*pFreq_2_Time_data_1++);
- dat2 = (*pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_1--);
- win2 = *(pShort_Window_2--);
-
- temp = fxp_mul_16_by_16(dat1, win1) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp;
-
- temp2 = fxp_mul_16_by_16(dat2, win2) >> shift;
- *(pOverlap_and_Add_Buffer_2++) = temp2;
-
-
- }
-
-
- pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW;
-
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- (LONG_BLOCK1 - W_L_START_2)
- *sizeof(*pOverlap_and_Add_Buffer_1));
-
-
- break;
-
-
- case LONG_STOP_SEQUENCE:
-
- pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2];
-
- pOutput_buffer = &Output_buffer[W_L_STOP_2];
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2];
-
- exp -= SCALING; /* !!!! */
-
- if (exp > 0)
- {
- Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pOutput_buffer++), (temp + tmp1));
-
- tmp1 = *(pFreq_2_Time_data_1++) >> exp;
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- }
- }
- else if (exp < 0)
- {
- shift = -exp;
- Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pOutput_buffer++), (temp + temp1));
-
- temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- }
- }
- else
- {
- Int16 tmp1 = *(pFreq_2_Time_data_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pOutput_buffer++), (temp + tmp1));
-
- tmp1 = *(pFreq_2_Time_data_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- }
- }
-
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
- pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW];
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1];
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1];
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
- + HALF_SHORT_WINDOW;
-
- pOutput_buffer = &Output_buffer[W_L_STOP_1];
- pOutput_buffer_2 = pOutput_buffer + HALF_SHORT_WINDOW;
-
- exp += SCALING; /* +8 back to what it was */
-
- shift = exp + 15 - SCALING;
-
-
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- Int16 win1;
- Int16 dat1;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- test = fxp_mul_16_by_16(dat1, win1);
-
- limiter(*(pOutput_buffer++), (temp + (test >> shift)));
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2++);
- temp = *(pOverlap_and_Add_Buffer_2++);
- test = fxp_mul_16_by_16(dat1, win1);
- limiter(*(pOutput_buffer_2++), (temp + (test >> shift)));
-
- }
-
-
- pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = Time_data;
-
- pOutput_buffer = Output_buffer;
-
- pLong_Window_2 =
- &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
- /*
- * Copy previous time in current buffer, also copy overlap
- * and add buffer
- */
-
- for (i = W_L_STOP_1; i != 0; i--)
- {
- Int16 win1;
- Int16 dat1;
-
- win1 = *(pLong_Window_2--);
- dat1 = *pFreq_2_Time_data_2++;
-
- limiter(*(pOutput_buffer++), *(pOverlap_and_Add_Buffer_1));
-
-
- temp = fxp_mul_16_by_16(dat1, win1) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp ;
-
- }
-
- for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--)
- {
- temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp ;
- }
-
-
- break;
-
-
-
- } /* switch (wnd_seq) */
-
- } /* if (exp < 16) */
-
- else
- {
- /* all zeros buffer or excessive down shift */
-
- /* Overlap and add, setup buffer for next iteration */
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
-
- pOutput_buffer = Output_buffer;
-
- temp = (*pOverlap_and_Add_Buffer_1++);
-
- for (i = LONG_WINDOW; i != 0; i--)
- {
-
- limiter(*(pOutput_buffer++), temp);
-
- temp = (*pOverlap_and_Add_Buffer_1++);
-
- }
-
- pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0]));
-
-
- }
-
- }
- else
- {
-
- Int32 *pScrath_mem;
- Int32 *pScrath_mem_entry;
- Int32 *pFrequency_data = Frequency_data;
-
- Int32 * pOverlap_and_Add_Buffer_1;
- Int32 * pOverlap_and_Add_Buffer_2;
- Int32 * pOverlap_and_Add_Buffer_1x;
- Int32 * pOverlap_and_Add_Buffer_2x;
-
- /*
- * Frequency_data is 2*LONG_WINDOW length but only
- * the first LONG_WINDOW elements are filled in,
- * then the second part can be used as scratch mem,
- * then grab data from one window at a time in
- * reverse order.
- * The upper LONG_WINDOW Int32 are used to hold the
- * computed overlap and add, used in the next call to
- * this function, and also as sctrach memory
- */
-
- /*
- * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE
-
- |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-|
- | | Store for next | | memory |
- | | call | | |
- | | | | |
- |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++|
- | | | | |
- 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW
- + | |
- W_L_STOP_2 | |
- |<-- -->|
- SHORT_WINDOW +
- HALF_SHORT_WINDOW
- *
- */
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[
- LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW];
-
- /*
- * Initialize to zero, only the firt short window used in overlap
- * and add
- */
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-
- /*
- * Showt windows are evaluated in decresing order. Windows from 7
- * to 0 are break down in four cases: window numbers 7 to 5, 4, 3,
- * and 2 to 0.
- * The data from short windows 3 and 4 is situated at the boundary
- * between the 'overlap and add' buffer and the output buffer.
- */
- for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--)
- {
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- pOverlap_and_Add_Buffer_1 =
- &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd];
-
-
- pOverlap_and_Add_Buffer_2 =
- pOverlap_and_Add_Buffer_1 + SHORT_WINDOW;
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * Each of the eight short blocks is windowed separately.
- * Window shape decisions are made on a frame-by-frame
- * basis.
- */
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-
-
- /*
- * For short windows from 7 to 5
- * | =========================
- * | | 5 6 7
- * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_
- * / \/ \/ \/ \|/ | \/ \/ \/ \
- * / /\ /\ /\ /|\ | /\ /\ /\ \
- * / / \ / \ / \ / | \ | / \ / \ / \ \
- * / / \/ \/ \/ | \|/ \/ \ \ \
- * --------------------------------|---[///////////////////////]--------
- *
- */
-
-
- shift = exp + 15 - SCALING;
-
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int16 dat1, dat2;
-
- dat2 = *(pFreq_2_Time_data_2++);
- win2 = *(pShort_Window_2--);
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
-
- *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift);
-
- *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- }
-
- } /* if (exp < 16) */
- else
- {
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
- }
-
-
- }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */
-
-
- wnd = NUM_SHORT_WINDOWS / 2;
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- /*
- * scratch memory is allocated in an unused part of memory
- */
-
-
- pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
- + HALF_SHORT_WINDOW;
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
- /*
- * For short window 4
- * ====|===========
- * | 4
- * | | | |
- * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_
- * / \/ \/ \/ | \|/ | \/ | \/ \/ \
- * / /\ /\ /\ | /|\ | /\ | /\ /\ \
- * / / \ / \ / \ | / | \ | / \ | / \ / \ \
- * / / \/ \/ \|/ | \|/ \|/ \/ \ \
- * ------------------------------[\\\|\\\|//////]-------------------
- * | | A | B | C |
- * |
- * W_L_STOP_1
- */
-
- shift = exp + 15 - SCALING;
- {
- Int16 win1;
- Int16 dat1;
- /* -------- segment A ---------------*/
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> (shift);
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- /* -------- segment B ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- /* -------- segment C ---------------*/
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift);
-
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- }
- }
-
- } /* if (exp < 16) */
- else
- {
- pv_memset(
- pScrath_mem,
- 0,
- HALF_SHORT_WINDOW*sizeof(*pScrath_mem));
-
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
- }
-
-
- wnd = NUM_SHORT_WINDOWS / 2 - 1;
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- pScrath_mem_entry =
- &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW];
- pScrath_mem = pScrath_mem_entry;
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
- /* point to end of buffer less HALF_SHORT_WINDOW */
-
- pOutput_buffer_2 = &Output_buffer[LONG_WINDOW - HALF_SHORT_WINDOW];
- pOutput_buffer = pOutput_buffer_2;
-
- pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)]; /* !!!! */
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * For short window 3
- * ===========|====
- * 3 |
- * | | | |
- * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_
- * / \/ \/ | \/ | \|/ | \/ \/ \/ \
- * / /\ /\ | /\ | /|\ | /\ /\ /\ \
- * / / \ / \ | / \ | / | \ | / \ / \ / \ \
- * / / \/ \|/ \|/ | \|/ \/ \ \ \
- * -----|------------------[\\\\\\|///|///]--------------------------
- * | | A | B | C |
- *
- * W_L_STOP_1
- */
-
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- shift = exp + 15 - SCALING;
-
-
- Int16 win1;
- Int16 dat1;
- /* -------- segment A ---------------*/
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
- /* -------- segment B ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- temp = *(pScrath_mem++) + test;
-
-
- test = *(pOverlap_and_Add_Buffer_1x++); /* !!!! */
-
- limiter(*(pOutput_buffer++), (temp + test));
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
- }
-
- /* -------- segment C ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- temp = fxp_mul_16_by_16(dat1, win1) >> (shift);
-
- *(pOverlap_and_Add_Buffer_1++) += temp;
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- }
-
- } /* if (exp < 16) */
- else
- {
-
- pv_memset(
- pScrath_mem,
- 0,
- SHORT_WINDOW*sizeof(*pScrath_mem));
-
- pScrath_mem += SHORT_WINDOW;
-
- temp = *(pScrath_mem++);
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pOutput_buffer++), temp);
- temp = *(pScrath_mem++);
-
-
- }
- }
-
-
- for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--)
- {
-
-
- pOutput_buffer_2 -= SHORT_WINDOW;
- pOutput_buffer = pOutput_buffer_2;
-
- /*
- * The same memory is used as scratch in every iteration
- */
- pScrath_mem = pScrath_mem_entry;
-
- pOverlap_and_Add_Buffer_2x =
- &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * Each of the eight short blocks is windowed separately.
- * Window shape decisions are made on a frame-by-frame
- * basis.
- */
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- if (wnd == 0)
- {
- pShort_Window_1 =
- &Short_Window_fxp[wnd_shape_prev_bk][0];
- }
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
- /*
- * For short windows from 2 to 0
- *
- * =========================
- * |
- * 0 1 2 | |
- * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_
- * / \/ \/ \/ | \|/ \/ \/ \/ \
- * / /\ /\ /\ | /|\ /\ /\ /\ \
- * / / \ / \ / \ | / | \ / \ / \ / \ \
- * / / \/ \/ \|/ | \/ \/ \ \ \
- * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|-----------------------------
- * |
- *
- * W_L_STOP_1
- */
-
- shift = exp + 15 - SCALING;
-
- Int16 dat1 = *(pFreq_2_Time_data_2++);
- Int16 win1 = *(pShort_Window_2--);
-
- temp = *(pScrath_mem);
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- temp += test;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
-
- limiter(*(pOutput_buffer++), (temp + *(pOverlap_and_Add_Buffer_2x++)));
-
-
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- temp = *(pScrath_mem);
-
- }
-
- } /* if (exp < 16) */
- else
- {
- test = *(pScrath_mem);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pOutput_buffer++), (temp + test));
-
- *(pScrath_mem++) = 0;
- test = *(pScrath_mem);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- }
- }
-
- } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */
-
- pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1];
-
- pScrath_mem = pScrath_mem_entry;
-
- pOutput_buffer_2 -= SHORT_WINDOW;
- pOutput_buffer = pOutput_buffer_2;
-
- test = *(pScrath_mem++);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pOutput_buffer++), (temp + test));
-
- test = *(pScrath_mem++);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- }
-
- pOverlap_and_Add_Buffer_1x = Time_data;
-
- pOutput_buffer = Output_buffer;
-
-
- temp = *(pOverlap_and_Add_Buffer_1x++);
-
- for (i = W_L_STOP_1; i != 0; i--)
- {
- limiter(*(pOutput_buffer++), temp);
-
- temp = *(pOverlap_and_Add_Buffer_1x++);
- }
-
- pOverlap_and_Add_Buffer_1x = &Time_data[0];
-
- pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW];
-
- /*
- * update overlap and add buffer,
- * so is ready for next iteration
- */
-
- for (int i = 0; i < W_L_STOP_2; i++)
- {
- temp = *(pOverlap_and_Add_Buffer_2++);
- *(pOverlap_and_Add_Buffer_1x++) = temp;
- }
-
- pv_memset(
- pOverlap_and_Add_Buffer_1x,
- 0,
- W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x));
-
- } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-}
-
-#endif
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void trans4m_freq_2_time_fxp_2(
- Int32 Frequency_data[],
- Int32 Time_data[],
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int Q_format,
- Int32 abs_max_per_window[],
- Int32 freq_2_time_buffer[],
- Int16 *Interleaved_output)
-
-{
-
- Int exp;
- Int shift;
-
- Int i;
- Int wnd;
-#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
- Int32 z;
-#endif
- Int16 *pFreqInfo;
- Int32 temp;
- Int32 test;
-
- Int16 *pFreq_2_Time_data_1;
- Int16 *pFreq_2_Time_data_2;
-
- const Int16 *pLong_Window_1;
- const Int16 *pLong_Window_2;
- const Int16 *pShort_Window_1;
- const Int16 *pShort_Window_2;
-
- Int32 *pOverlap_and_Add_Buffer_1;
- Int32 *pOverlap_and_Add_Buffer_2;
-
- Int16 *pInterleaved_output;
- Int16 *pInterleaved_output_2;
-
-
- const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
- const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
- Long_Window_fxp[0] = Long_Window_sine_fxp;
- Long_Window_fxp[1] = Long_Window_KBD_fxp;
- Short_Window_fxp[0] = Short_Window_sine_fxp;
- Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
- if (wnd_seq != EIGHT_SHORT_SEQUENCE)
- {
-
- pFreqInfo = (Int16 *)Frequency_data;
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- LONG_BLOCK1,
- Q_format,
- abs_max_per_window[0]);
-
-
- /*
- * The C Programming Language, Second Edition, Kernighan & Ritchie,
- * page 206.
- * "The result [of a shift] is undefined if the right operand is
- * negative, or greater than or equal to the number of bits in the
- * left expression's type"
- * => avoid shift by 32 or 16
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = pFreqInfo;
-
-
- switch (wnd_seq)
- {
-
- case ONLY_LONG_SEQUENCE:
- default:
-
- {
- pOverlap_and_Add_Buffer_1 = Time_data;
-
- pInterleaved_output = Interleaved_output;
-
- {
-
- const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
- Int32 * pFreq2T = (Int32 *)pFreqInfo;
- Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW];
- Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0];
-
- Int shift = exp + 15 - SCALING;
-
- for (i = HALF_LONG_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int32 temp2, test2;
-
- Int32 winx;
-
- temp2 = *(pFreq2T++);
- winx = *(win++);
-
- test = *(pOverlap_and_Add_Buffer_1++);
- test2 = *(pOverlap_and_Add_Buffer_1--);
- temp = fxp_mul_16_by_16bb(temp2, winx) >> shift;
- temp2 = fxp_mul_16_by_16tt(temp2, winx) >> shift;
-
- limiter(*(pInterleaved_output), (temp + test));
-
- limiter(*(pInterleaved_output + 2), (temp2 + test2));
- pInterleaved_output += 4;
-
- temp2 = *(pFreq2T_2++);
-
- win1 = *(pLong_Window_2--);
- win2 = *(pLong_Window_2--);
- temp = fxp_mul_16_by_16bb(temp2, win1) >> shift;
- test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift;
-
- *(pOverlap_and_Add_Buffer_1++) = temp;
- *(pOverlap_and_Add_Buffer_1++) = test2;
- }
-
- }
-
- }
-
- break;
-
- case LONG_START_SEQUENCE:
-
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[ HALF_LONG_WINDOW];
-
- pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
- pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
- pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW];
-
-
- pInterleaved_output = Interleaved_output;
- pInterleaved_output_2 = pInterleaved_output + (2 * HALF_LONG_WINDOW);
-
-
- /*
- * process first LONG_WINDOW elements
- */
-
- shift = exp + 15 - SCALING;
-
- for (i = HALF_LONG_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int16 dat1, dat2;
- Int32 test1, test2;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pLong_Window_1++);
- test1 = *(pOverlap_and_Add_Buffer_1++);
-
- dat2 = *(pFreq_2_Time_data_2++);
- win2 = *(pLong_Window_2++);
- test2 = *(pOverlap_and_Add_Buffer_2++);
-
- limiter(*(pInterleaved_output), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift)));
-
- pInterleaved_output += 2;
-
- limiter(*(pInterleaved_output_2), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift)));
-
- pInterleaved_output_2 += 2;
- }
-
-
- /*
- * data unchanged from LONG_WINDOW to W_L_START_1
- * only scaled accordingly
- */
-
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
- pFreq_2_Time_data_1 = &pFreqInfo[LONG_WINDOW];
-
- exp -= SCALING;
-
- if (exp >= 0)
- {
-
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++) >> exp;
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++) >> exp;
-
- }
-
- }
- else if (exp < 0)
- {
-
- Int shift = -exp;
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--)
- {
- Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- *(pOverlap_and_Add_Buffer_1++) = temp2;
- temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- *(pOverlap_and_Add_Buffer_1++) = temp2;
- }
-
- }
- else
- {
-
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++);
- *(pOverlap_and_Add_Buffer_1++) =
- *(pFreq_2_Time_data_1++);
-
- }
-
- }
-
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_START_1];
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
- pShort_Window_1 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW;
-
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 +
- HALF_SHORT_WINDOW;
-
- {
- Int16 win1, win2;
- Int16 dat1, dat2;
- Int32 temp2;
-
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
-
- dat1 = (*pFreq_2_Time_data_1++);
- dat2 = (*pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_1--);
- win2 = *(pShort_Window_2--);
-
- temp = fxp_mul_16_by_16(dat1, win1) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp;
-
- temp2 = fxp_mul_16_by_16(dat2, win2) >> shift;
- *(pOverlap_and_Add_Buffer_2++) = temp2;
-
- }
- }
-
- pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW;
-
-
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- (LONG_BLOCK1 - W_L_START_2)
- *sizeof(*pOverlap_and_Add_Buffer_1));
-
-
- break;
-
-
- case LONG_STOP_SEQUENCE:
-
- pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2];
-
- pInterleaved_output = &Interleaved_output[2*W_L_STOP_2];
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_2];
-
- exp -= SCALING;
-
-
- if (exp > 0)
- {
- Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp + tmp1));
-
- pInterleaved_output += 2;
- tmp1 = *(pFreq_2_Time_data_1++) >> exp;
- temp = *(pOverlap_and_Add_Buffer_1++);
- }
- }
- else if (exp < 0)
- {
- shift = -exp;
-
- Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp + temp1));
-
- pInterleaved_output += 2;
- temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
- temp = *(pOverlap_and_Add_Buffer_1++);
- }
- }
- else
- {
- Int16 tmp1 = *(pFreq_2_Time_data_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
- for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp + tmp1));
-
- pInterleaved_output += 2;
- tmp1 = *(pFreq_2_Time_data_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
- }
- }
-
-
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
- pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW];
-
- pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1];
- pFreq_2_Time_data_2 =
- &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1];
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
- + HALF_SHORT_WINDOW;
-
-
- pInterleaved_output = &Interleaved_output[2*W_L_STOP_1];
- pInterleaved_output_2 = pInterleaved_output + (2 * HALF_SHORT_WINDOW);
-
- exp += SCALING; /* +8 back to what it was */
- shift = exp + 15 - SCALING;
-
-
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
-
- Int16 win1;
- Int16 dat1;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- temp = *(pOverlap_and_Add_Buffer_1++);
-
- test = fxp_mul_16_by_16(dat1, win1);
-
- limiter(*(pInterleaved_output), (temp + (test >> shift)));
-
- pInterleaved_output += 2;
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2++);
- temp = *(pOverlap_and_Add_Buffer_2++);
- test = fxp_mul_16_by_16(dat1, win1);
-
- limiter(*(pInterleaved_output_2), (temp + (test >> shift)));
-
- pInterleaved_output_2 += 2;
-
- }
-
-
-
- pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = Time_data;
-
-
- pInterleaved_output = Interleaved_output;
-
- pLong_Window_2 =
- &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
- /*
- * Copy previous time in current buffer, also copy overlap
- * and add buffer
- */
-
- for (i = W_L_STOP_1; i != 0; i--)
- {
-
- Int16 win1;
- Int16 dat1;
-
- win1 = *(pLong_Window_2--);
- dat1 = *pFreq_2_Time_data_2++;
-
- limiter(*(pInterleaved_output), *(pOverlap_and_Add_Buffer_1));
-
- pInterleaved_output += 2;
-
- temp = fxp_mul_16_by_16(dat1, win1) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp ;
-
- }
-
- for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--)
- {
-
- temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift;
- *(pOverlap_and_Add_Buffer_1++) = temp ;
-
- }
-
- break;
-
-
-
- } /* switch (wnd_seq) */
-
- } /* if (exp < 16) */
-
- else
- {
- /* all zeros buffer or excessive down shift */
-
- /* Overlap and add, setup buffer for next iteration */
- pOverlap_and_Add_Buffer_1 = &Time_data[0];
-
- pInterleaved_output = Interleaved_output;
-
-
- temp = (*pOverlap_and_Add_Buffer_1++);
- for (i = LONG_WINDOW; i != 0; i--)
- {
-
- limiter(*(pInterleaved_output), temp);
-
- pInterleaved_output += 2;
- temp = (*pOverlap_and_Add_Buffer_1++);
- }
- pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0]));
- }
-
- }
- else
- {
-
- Int32 *pScrath_mem;
- Int32 *pScrath_mem_entry;
- Int32 *pFrequency_data = Frequency_data;
-
- Int32 * pOverlap_and_Add_Buffer_1;
- Int32 * pOverlap_and_Add_Buffer_2;
- Int32 * pOverlap_and_Add_Buffer_1x;
- Int32 * pOverlap_and_Add_Buffer_2x;
-
-
- /*
- * Frequency_data is 2*LONG_WINDOW length but only
- * the first LONG_WINDOW elements are filled in,
- * then the second part can be used as scratch mem,
- * then grab data from one window at a time in
- * reverse order.
- * The upper LONG_WINDOW Int32 are used to hold the
- * computed overlap and add, used in the next call to
- * this function, and also as sctrach memory
- */
-
- /*
- * Frequency_data usage for the case EIGHT_SHORT_SEQUENCE
-
- |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-|
- | | Store for next | | memory |
- | | call | | |
- | | | | |
- |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++|
- | | | | |
- 0 LONG_WINDOW LONG_WINDOW | 2*LONG_WINDOW
- + | |
- W_L_STOP_2 | |
- |<-- -->|
- SHORT_WINDOW +
- HALF_SHORT_WINDOW
- *
- */
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[
- LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW];
-
- /*
- * Initialize to zero, only the firt short window used in overlap
- * and add
- */
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-
- /*
- * Showt windows are evaluated in decresing order. Windows from 7
- * to 0 are break down in four cases: window numbers 7 to 5, 4, 3,
- * and 2 to 0.
- * The data from short windows 3 and 4 is situated at the boundary
- * between the 'overlap and add' buffer and the output buffer.
- */
- for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--)
- {
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /* W_L_STOP_1 == (LONG_WINDOW - SHORT_WINDOW)>>1 */
- pOverlap_and_Add_Buffer_1 =
- &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd];
-
-
- pOverlap_and_Add_Buffer_2 =
- pOverlap_and_Add_Buffer_1 + SHORT_WINDOW;
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * Each of the eight short blocks is windowed separately.
- * Window shape decisions are made on a frame-by-frame
- * basis.
- */
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-
-
- /*
- * For short windows from 7 to 5
- * | =========================
- * | | 5 6 7
- * _--_ _--_ _--_ _--_ | _-|-_ _--_ _--_ _--_
- * / \/ \/ \/ \|/ | \/ \/ \/ \
- * / /\ /\ /\ /|\ | /\ /\ /\ \
- * / / \ / \ / \ / | \ | / \ / \ / \ \
- * / / \/ \/ \/ | \|/ \/ \ \ \
- * --------------------------------|---[///////////////////////]--------
- *
- */
-
-
- shift = exp + 15 - SCALING;
-
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- Int16 win1, win2;
- Int16 dat1, dat2;
-
- dat2 = *(pFreq_2_Time_data_2++);
- win2 = *(pShort_Window_2--);
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
-
- *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat2, win2) >> shift);
-
- *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- }
-
- } /* if (exp < 16) */
- else
- {
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
- }
-
-
- }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */
-
-
- wnd = NUM_SHORT_WINDOWS / 2;
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- /*
- * scratch memory is allocated in an unused part of memory
- */
-
-
- pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW];
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
- pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
- + HALF_SHORT_WINDOW;
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
- /*
- * For short window 4
- * ====|===========
- * | 4
- * | | | |
- * _--_ _--_ _--_ _-|-_ | _-|-_ _-|-_ _--_ _--_
- * / \/ \/ \/ | \|/ | \/ | \/ \/ \
- * / /\ /\ /\ | /|\ | /\ | /\ /\ \
- * / / \ / \ / \ | / | \ | / \ | / \ / \ \
- * / / \/ \/ \|/ | \|/ \|/ \/ \ \
- * ------------------------------[\\\|\\\|//////]-------------------
- * | | A | B | C |
- * |
- * W_L_STOP_1
- */
-
- shift = exp + 15 - SCALING;
- {
- Int16 win1;
- Int16 dat1;
- /* -------- segment A ---------------*/
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- /* -------- segment B ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_1++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- /* -------- segment C ---------------*/
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- *(pOverlap_and_Add_Buffer_2++) = temp + (fxp_mul_16_by_16(dat1, win1) >> shift);
-
- temp = *pOverlap_and_Add_Buffer_2;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- }
- }
-
- } /* if (exp < 16) */
- else
- {
- pv_memset(
- pScrath_mem,
- 0,
- HALF_SHORT_WINDOW*sizeof(*pScrath_mem));
-
- pv_memset(
- pOverlap_and_Add_Buffer_1,
- 0,
- HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
- }
-
-
- wnd = NUM_SHORT_WINDOWS / 2 - 1;
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
- pScrath_mem_entry =
- &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW];
-
-
- pScrath_mem = pScrath_mem_entry;
-
- pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
- /* point to end of buffer less HALF_SHORT_WINDOW */
-
- pInterleaved_output_2 = &Interleaved_output[2*(LONG_WINDOW - HALF_SHORT_WINDOW)];
- pInterleaved_output = pInterleaved_output_2;
-
- pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * For short window 3
- * ===========|====
- * 3 |
- * | | | |
- * _--_ _--_ _-|-_ _-|-_ | _-|-_ _--_ _--_ _--_
- * / \/ \/ | \/ | \|/ | \/ \/ \/ \
- * / /\ /\ | /\ | /|\ | /\ /\ /\ \
- * / / \ / \ | / \ | / | \ | / \ / \ / \ \
- * / / \/ \|/ \|/ | \|/ \/ \ \ \
- * -----|------------------[\\\\\\|///|///]--------------------------
- * | | A | B | C |
- *
- * W_L_STOP_1
- */
-
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- shift = exp + 15 - SCALING;
-
- Int16 win1;
- Int16 dat1;
- /* -------- segment A ---------------*/
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
- }
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
-
- /* -------- segment B ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- temp = *(pScrath_mem++) + test;
-
- test = *(pOverlap_and_Add_Buffer_1x++);
- limiter(*(pInterleaved_output), (temp + test));
-
-
- pInterleaved_output += 2;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
-
- }
-
- /* -------- segment C ---------------*/
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
-
- temp = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- *(pOverlap_and_Add_Buffer_1++) += temp;
-
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- }
-
-
- } /* if (exp < 16) */
- else
- {
-
- pv_memset(
- pScrath_mem,
- 0,
- SHORT_WINDOW*sizeof(*pScrath_mem));
-
- pScrath_mem += SHORT_WINDOW;
-
- temp = *(pScrath_mem++);
- for (i = HALF_SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp));
-
- pInterleaved_output += 2;
- temp = *(pScrath_mem++);
-
- }
- }
-
-
- for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--)
- {
-
-
- pInterleaved_output_2 -= (SHORT_WINDOW * 2);
- pInterleaved_output = pInterleaved_output_2;
-
- /*
- * The same memory is used as scratch in every iteration
- */
- pScrath_mem = pScrath_mem_entry;
-
- pOverlap_and_Add_Buffer_2x =
- &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
- pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-
-
- exp = imdct_fxp(
- (Int32 *)pFreqInfo,
- freq_2_time_buffer,
- SHORT_BLOCK1,
- Q_format,
- abs_max_per_window[wnd]);
-
- /*
- * If all element are zero or if the exponent is bigger than
- * 16 ( it becomes an undefined shift) -> skip
- */
-
- if (exp < 16)
- {
-
- pFreq_2_Time_data_1 = &pFreqInfo[0];
- pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
- /*
- * Each of the eight short blocks is windowed separately.
- * Window shape decisions are made on a frame-by-frame
- * basis.
- */
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
- if (wnd == 0)
- {
- pShort_Window_1 =
- &Short_Window_fxp[wnd_shape_prev_bk][0];
- }
-
- pShort_Window_2 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
- /*
- * For short windows from 2 to 0
- *
- * =========================
- * |
- * 0 1 2 | |
- * _--_ _--_ _--_ _-|-_ | _--_ _--_ _--_ _--_
- * / \/ \/ \/ | \|/ \/ \/ \/ \
- * / /\ /\ /\ | /|\ /\ /\ /\ \
- * / / \ / \ / \ | / | \ / \ / \ / \ \
- * / / \/ \/ \|/ | \/ \/ \ \ \
- * ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|-----------------------------
- * |
- *
- * W_L_STOP_1
- */
-
- shift = exp + 15 - SCALING;
-
- Int16 dat1 = *(pFreq_2_Time_data_2++);
- Int16 win1 = *(pShort_Window_2--);
-
- temp = *(pScrath_mem);
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
- temp += test;
- dat1 = *(pFreq_2_Time_data_1++);
- win1 = *(pShort_Window_1++);
-
- limiter(*(pInterleaved_output), (temp + *(pOverlap_and_Add_Buffer_2x++)));
-
- pInterleaved_output += 2;
-
- *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
- dat1 = *(pFreq_2_Time_data_2++);
- win1 = *(pShort_Window_2--);
- temp = *(pScrath_mem);
-
- }
-
- } /* if (exp < 16) */
- else
- {
- test = *(pScrath_mem);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp + test));
-
- pInterleaved_output += 2;
-
- *(pScrath_mem++) = 0;
- test = *(pScrath_mem);
- temp = *(pOverlap_and_Add_Buffer_2x++);
- }
- }
-
- } /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */
-
- pOverlap_and_Add_Buffer_2x = &Time_data[W_L_STOP_1];
-
- pScrath_mem = pScrath_mem_entry;
-
- pInterleaved_output_2 -= (SHORT_WINDOW * 2);
- pInterleaved_output = pInterleaved_output_2;
-
- test = *(pScrath_mem++);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- for (i = SHORT_WINDOW; i != 0; i--)
- {
- limiter(*(pInterleaved_output), (temp + test));
-
- pInterleaved_output += 2;
- test = *(pScrath_mem++);
- temp = *(pOverlap_and_Add_Buffer_2x++);
-
- }
-
- pOverlap_and_Add_Buffer_1x = Time_data;
-
- pInterleaved_output = Interleaved_output;
-
-
- temp = *(pOverlap_and_Add_Buffer_1x++);
- for (i = W_L_STOP_1; i != 0; i--)
- {
- limiter(*(pInterleaved_output), temp);
-
- pInterleaved_output += 2;
- temp = *(pOverlap_and_Add_Buffer_1x++);
-
- }
-
- pOverlap_and_Add_Buffer_1x = &Time_data[0];
-
- pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW];
-
- /*
- * update overlap and add buffer,
- * so is ready for next iteration
- */
-
- for (int i = 0; i < W_L_STOP_2; i++)
- {
- temp = *(pOverlap_and_Add_Buffer_2++);
- *(pOverlap_and_Add_Buffer_1x++) = temp;
- }
-
- pv_memset(
- pOverlap_and_Add_Buffer_1x,
- 0,
- W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x));
-
- } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-
-
-
-} /* trans4m_freq_2_time_fxp */
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp b/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp
deleted file mode 100644
index b1b44f0..0000000
--- a/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp
+++ /dev/null
@@ -1,663 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: trans4m_time_2_freq_fxp.c
- Function: trans4m_time_2_freq_fxp
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- Modified normalization, so it now happen per window basis, eliminated
- shifts left or rigth to accomodate TNS inverse filtering. The output
- is 32 bits but only the lowest 16 are being used.
- Modified fuction interface
-
- Description: Modified variable names with leading "p" for pointers
-
- Description:
- Modified call to mdct_fxp to reflect extended precision use. Added routine
- buffer_adaptation to extract 16 MSB and keep highest precision.
- Modify casting to ensure proper operations for different platforms
-
- Description:
- Added comments according to code review
-
- Description:
- Removed include file "buffer_normalization.h"
-
- Description:
- Eliminated buffer_adaptation() and embedded its functionality in other
- functions. Commented out the short window section given that this is
- not supported by the standards
-
- Description:
- Added shift down operation for case when the window was equal to one.
- This was not needed previuosly because buffer_adaptation() was doing
- it.
-
- Description: Created local version of vectors Long_Window_fxp and
- Short_Window_fxp. This solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers.
-
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Time2Freq_data = buffer with data in the time domain, it holds 2048
- points of input time data
- Output holds frequency (first 1024 points )
- type Int32
-
- wnd_seq = window sequence
- type WINDOW_SEQUENCE
-
- wnd_shape_prev_bk = previous window shape type
- type Int
-
- wnd_shape_this_bk = current window shape type
- type Int
-
- pQ_format = Holds the Q format of the data in, and data out
- type Int *
-
- mem_4_in_place_FFT[] = scratch memory for computing FFT, 1024 point
- type Int32
-
-
-
- Local Stores/Buffers/Pointers Needed:
- None
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- Frequency information (1024 pts.) is returned in Time2Freq_data
- pQ_format content spectral coefficients Q format
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-The time/frequency representation of the signal is mapped onto the frequency
-domain by feeding it into the filterbank module. This module consists of
-a modified discrete cosine transform (MDCT), (windowing and DCT).
-In order to adapt the time/frequency resolution of the filterbank to the
- characteristics of the input signal, a block switching tool is also
-adopted. N represents the window length, where N is a function of the
-window_sequence. For each channel, the N time values are transformed into the
-N/2 frequency domain values via the MDCT.
-
-The adaptation of the time-frequency resolution of the filterbank to the
-characteristics of the input signal is done by shifting between transforms
-whose input lengths are either 2048 or 256 samples. By enabling the block
-switching tool, the following transitions are meaningful:
-
-from ONLY_LONG_SEQUENCE to { LONG_START_SEQUENCE
- ONLY_LONG_SEQUENCE
-
-from LONG_START_SEQUENCE to { LONG_STOP_SEQUENCE
- EIGHT_SHORT_SEQUENCE
-
-from LONG_STOP_SEQUENCE to { LONG_START_SEQUENCE
- ONLY_LONG_SEQUENCE
-
-from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE
- EIGHT_SHORT_SEQUENCE
-
-Window shape decisions are made by the encoder on a frame-by-frame-basis.
-The window selected is applicable to the second half of the window function
-only, since the first half is constrained to use the appropriate window
-shape from the preceding frame.
-The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are
-the last 1024 values of the previous window_sequence concatenated with 1024
-values of the current block. The formula below shows this fact:
-
- | x(i-1)(n+1024) for 0 < n < 1024
- x'(i)(n) {
- | x(i)(n) for 1024 < n < 2048
-
-
-
-Once the window shape is selected, the window_shape syntax element is
-initialized. Together with the chosen window_sequence all information needed
-for windowing exist.
-With the window halves described below all window_sequences can be assembled.
-For window_shape == 1, the window coefficients are given by the Kaiser -
-Bessel derived (KBD) window.
-Otherwise, for window_shape == 0, a sine window is employed.
-
-The window length N can be 2048 or 256 for the KBD and the sine window.
-All four window_sequences explained below have a total length of 2048
-samples.
-For all kinds of window_sequences the window_shape of the left half of
-the first transform window is determined by the window shape of the previous
-block.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall implement a scheme to switch between window types and
- in turn perform time to frequency transformations
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] ISO 14496-3:1999, pag 111
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF ( wnd_seq == EIGHT_SHORT_SEQUENCE)
- THEN
-
-
- FOR ( wnd=0; wnd<NUM_SHORT_WINDOWS; wnd++)
-
- time_info = &Time2Freq_data[ W_L_STOP_1 + wnd*SHORT_WINDOW]
-
- FOR( i=0; i<SHORT_BLOCK1; i++)
- aux_temp[i] = time_info[i]
- ENDFOR
-
-
- IF (wnd == 0)
- THEN
- pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0]
- ELSE
- pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0]
- ENDIF
-
-
- pShort_Window_2 =
- &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1]
-
- FOR( i=0, j=SHORT_WINDOW; i<SHORT_WINDOW; i++, j--)
- aux_temp[ i] *= pShort_Window_1[i]
- aux_temp[SHORT_WINDOW+i] *= pShort_Window_2[j]
- ENDFOR
-
-
- CALL MDCT( aux_temp, SHORT_BLOCK1)
- MODIFYING( aux_temp)
-
- FOR( i=0; i<SHORT_WINDOW; i++)
- Time2Freq_data[wnd*SHORT_WINDOW + i] = aux_temp[i];
- ENDFOR
-
- ENDFOR
-
- ELSE
-
- SWITCH ( wnd_seq)
-
- CASE ( ONLY_LONG_SEQUENCE)
-
- pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0]
- pLong_Window_2 =
- &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1]
-
- FOR (i=0; i<LONG_WINDOW; i++)
- Time2Freq_data[ i] *= *pLong_Window_1++
- Time2Freq_data[LONG_WINDOW+i] *= *pLong_Window_2--
- ENDFOR
-
- BREAK
-
-
- CASE ( LONG_START_SEQUENCE)
-
- pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Time2Freq_data[ i] *= *pLong_Window_1++;
- ENDFOR
-
-
- pShort_Window_1 =
- &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1];
-
- FOR ( i=0; i<SHORT_WINDOW; i++)
- Time2Freq_data[W_L_START_1 + i] *= *pShort_Window_1--;
- ENDFOR
-
-
- FOR ( i=W_L_START_2; i<LONG_BLOCK1; i++)
- Time2Freq_data[W_L_START_2 + i] = 0;
- ENDFOR
-
- BREAK
-
-
- CASE ( LONG_STOP_SEQUENCE )
-
- FOR ( i=0; i<W_L_STOP_1; i++)
- Time2Freq_data[ i] = 0;
- ENDFOR
-
-
- pShort_Window_1 = &Short_Window[wnd_shape->prev_bk][0];
-
- FOR ( i=0; i<SHORT_WINDOW; i++)
- Time2Freq_data[W_L_STOP_1+ i] *= *pShort_Window_1++;
- ENDFOR
-
-
- pLong_Window_1 =
- &Long_Window[wnd_shape->this_bk][LONG_WINDOW_m_1];
-
- FOR ( i=0; i<LONG_WINDOW; i++)
- Time2Freq_data[LONG_WINDOW + i] *= *pLong_Window_1--;
- ENDFOR
-
- BREAK
-
-
- }
-
- MDCT( Time2Freq_data, LONG_BLOCK1);
- MODIFYING( Time2Freq_data)
-
- ENDIF
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-#include "mdct_fxp.h"
-#include "long_term_prediction.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void trans4m_time_2_freq_fxp(
- Int32 Time2Freq_data[], /* time data size 2048 */
- WINDOW_SEQUENCE wnd_seq, /* window sequence */
- Int wnd_shape_prev_bk, /* window shape, current and previous */
- Int wnd_shape_this_bk,
- Int *pQ_format,
- Int32 mem_4_in_place_FFT[]) /* scratch memory for computing FFT */
-{
-
- Int i;
-
- Int32 *pAux_temp_1;
- Int32 *pAux_temp_2;
- Int32 *pAux_temp;
-// Int32 temp;
- const Int16 *pLong_Window_1;
- const Int16 *pLong_Window_2;
- const Int16 *pShort_Window_1;
- const Int16 *pShort_Window_2;
- Int shift = *pQ_format - 1;
-
- const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
- const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
- Long_Window_fxp[0] = Long_Window_sine_fxp;
- Long_Window_fxp[1] = Long_Window_KBD_fxp;
- Short_Window_fxp[0] = Short_Window_sine_fxp;
- Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
- if (wnd_seq != EIGHT_SHORT_SEQUENCE)
- {
-
- pAux_temp = Time2Freq_data;
-
- *pQ_format = LTP_Q_FORMAT - *pQ_format;
-
- pAux_temp_1 = pAux_temp;
-
- switch (wnd_seq)
- {
-
- case LONG_START_SEQUENCE:
-
- pAux_temp_2 = &pAux_temp_1[HALF_LONG_WINDOW];
-
- pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
- pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
-
-
-
- for (i = HALF_LONG_WINDOW; i > 0; i--)
- {
-
- *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift;
- pAux_temp_1++;
- *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2++) >> shift;
- pAux_temp_2++;
-
- }
-
-
- /* data unchanged from LONG_WINDOW to W_L_START_1 */
- pAux_temp_1 = &pAux_temp[LONG_WINDOW];
- if (shift)
- {
- for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
- {
- *(pAux_temp_1++) >>= shift;
- *(pAux_temp_1++) >>= shift;
- }
- }
-
-
- pAux_temp_1 = &pAux_temp[W_L_START_1];
- pAux_temp_2 = &pAux_temp_1[HALF_SHORT_WINDOW];
-
- pShort_Window_1 =
- &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
- pShort_Window_2 = pShort_Window_1 - HALF_SHORT_WINDOW;
-
- for (i = HALF_SHORT_WINDOW; i > 0; i--)
- {
-
- *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1--) >> shift;
- pAux_temp_1++;
- *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2--) >> shift;
- pAux_temp_2++;
-
- }
-
- pAux_temp_1 = &pAux_temp[W_L_START_2];
-
- pv_memset(
- pAux_temp_1,
- 0,
- (LONG_BLOCK1 - W_L_START_2)*sizeof(*pAux_temp_1));
-
- break;
-
-
- case LONG_STOP_SEQUENCE:
-
- pv_memset(
- pAux_temp_1,
- 0,
- (W_L_STOP_1)*sizeof(*pAux_temp_1));
-
- pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
- pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW];
-
- pAux_temp_1 = &pAux_temp_1[W_L_STOP_1];
- pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW;
-
- for (i = HALF_SHORT_WINDOW; i > 0; i--)
- {
-
- *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1++) >> shift;
- pAux_temp_1++;
- *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2++) >> shift;
- pAux_temp_2++;
-
-
- }
-
- /* data unchanged from W_L_STOP_2 to LONG_WINDOW */
- pAux_temp_1 = &pAux_temp[W_L_STOP_2];
-
- if (shift)
- {
- for (i = ((LONG_WINDOW - W_L_STOP_2) >> 1); i != 0; i--)
- {
- *(pAux_temp_1++) >>= shift;
- *(pAux_temp_1++) >>= shift;
- }
- }
-
-
-
- pAux_temp_1 = &pAux_temp[LONG_WINDOW];
- pAux_temp_2 = pAux_temp_1 + HALF_LONG_WINDOW;
-
- pLong_Window_1 =
- &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
- pLong_Window_2 = &pLong_Window_1[-HALF_LONG_WINDOW];
-
- for (i = HALF_LONG_WINDOW; i > 0; i--)
- {
- *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1--) >> shift;
- pAux_temp_1++;
- *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift;
- pAux_temp_2++;
-
- }
-
- break;
-
- case ONLY_LONG_SEQUENCE:
- default:
-
- pAux_temp_2 = &pAux_temp[LONG_WINDOW];
-
- pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
-
-
- pLong_Window_2 =
- &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
- for (i = LONG_WINDOW; i > 0; i--)
- {
-
- *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift;
- pAux_temp_1++;
- *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift;
- pAux_temp_2++;
- }
-
- break;
-
- } /* end switch ( wnd_seq) */
-
-
-
- *pQ_format += mdct_fxp(
- pAux_temp,
- mem_4_in_place_FFT,
- LONG_BLOCK1);
-
-
- } /* end if( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-
-
- /*****************************************/
- /* decoding process for short window */
- /*****************************************/
-
- /*
- * For short window the following code will be applied
- * in the future when short window is supported in the
- * standards
- */
- /*-------------------------------------------------------------------------
-
- * pAux_temp = &mem_4_in_place_FFT[(2*SHORT_BLOCK1)];
- *
- * for ( wnd=0; wnd<NUM_SHORT_WINDOWS; wnd++)
- * {
- *
- * pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
- *
- * if (wnd == 0)
- * {
- * pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
- * }
- *
- * pShort_Window_2 =
- * &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
- *
- * pAux_temp_1 = pAux_temp;
- * pAux_temp_2 = pAux_temp_1 + SHORT_WINDOW;
- *
- * Q_aux = 0;
- *
- * buffer_adaptation (
- * &Q_aux,
- * &Time2Freq_data[ W_L_STOP_1 + wnd*SHORT_WINDOW],
- * (void *) pAux_temp,
- * SHORT_BLOCK1,
- * USING_INT,
- * 16);
- *
- *
- * for ( i=SHORT_WINDOW; i>0; i--)
- * {
- * temp = (*pAux_temp_1) * *pShort_Window_1++;
- * *pAux_temp_1++ = (temp + 0x08000L) >> 16;
- *
- * temp = (*pAux_temp_2) * *pShort_Window_2--;
- * *pAux_temp_2++ = (temp + 0x08000L) >> 16;
- *
- * }
- *
- *
- * exp = mdct_fxp(
- * pAux_temp,
- * mem_4_in_place_FFT,
- * SHORT_BLOCK1);
- *
- *
- * exp += Q_aux;
- *
- * pAux_temp_1 = pAux_temp;
- * pAux_temp_2 = pAux_temp_1 + HALF_SHORT_WINDOW;
- * pTime_data_1 = &Time2Freq_data[wnd*SHORT_WINDOW];
- * pTime_data_2 = pTime_data_1 + HALF_SHORT_WINDOW;
- *
- *
- * if (exp > 0)
- * {
- * for ( i=HALF_SHORT_WINDOW; i>0; i--)
- * {
- * *pTime_data_1++ = (*pAux_temp_1++>>exp);
- * *pTime_data_2++ = (*pAux_temp_2++>>exp);
- * }
- * }
- * else if (exp < 0)
- * {
- * exp = -exp;
- * for ( i=HALF_SHORT_WINDOW; i>0; i--)
- * {
- * *pTime_data_1++ = (*pAux_temp_1++<<exp);
- * *pTime_data_2++ = (*pAux_temp_2++<<exp);
- * }
- * }
- * else
- * {
- * for ( i=HALF_SHORT_WINDOW; i>0; i--)
- * {
- * *pTime_data_1++ = (*pAux_temp_1++);
- * *pTime_data_2++ = (*pAux_temp_2++);
- * }
- * }
- *
- * }
- *
- * }
- *
- *--------------------------------------------------------------------------*/
-
-} /* trans4m_time_2_freq_fxp */
diff --git a/media/libstagefright/codecs/aacdec/unpack_idx.cpp b/media/libstagefright/codecs/aacdec/unpack_idx.cpp
deleted file mode 100644
index 9180994..0000000
--- a/media/libstagefright/codecs/aacdec/unpack_idx.cpp
+++ /dev/null
@@ -1,660 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/unpack_idx.c
- Function: unpack_idx
- unpack_idx_sgn
- unpack_idx_esc
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified from original shareware code
-
- Description: Eliminated 3 divisions and 1 multiplication through a table
- look-up method for calculating 1/mod and constant allocation of 1/mod^3
- and 1/mod^2.
- Eliminated 3 additions through simple optimizations in the code.
- Changed if/else statement to a switch/case utilizing fall-through.
-
- Description: Made changes per review comments. Main improvements were
- in change of switch/case to if statement, and use of temporary variable
- to hold value of *pQuantSpec.
-
- Description: (1) Typecast codeword_indx to Int32 before multiplication, this
- assures the shift operation happens on a 32-bit product on
- TI-C55x processor.
- (2) define temp_spec as Int32 to avoid overflow
-
- Description: Modified per review comments
- (1) remove the two typecastings of codeword_indx when
- pHuffCodebook->dim == DIMENSION_4
- (2) temp_spec is Int because the result never exceeds 16 bits
-
- Description: Break up and combine unpack index with sign bit reading and for
- special escape code. Parent function must know which one of the
- 3 functions should be called.
-
- Description: Put back if-statement to get the max.
-
- Description: When searching for the max, there was some instances where the
- max was compared against a negative number, so the max was never
- updated (defaulted to 0), leading to block processing in other
- magnitude sensitive stages.
-
- Who: Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
- Int quant_spec[] = Array for storage of the quantized
- spectral coefficients. Length is either 2 or 4.
- See Ref #1, Page 76 for a complete description.
-
- Int codeword_indx = The index into the Huffman table.
- Range is [1-288]
-
- const Hcb *pHuffCodebook = Pointer to HuffmanCodebook information.
-
- BITS *pInputStream = Pointer to the bitstream buffer.
- Int *max = Pointer to maximum coefficient value.
-
- Local Stores/Buffers/Pointers Needed:
- const UInt div_mod[18] = An array with the values for 1/mod
- stored in Q-formats 13.
-
- Global Stores/Buffers/Pointers Needed:
- None
-
- Outputs:
- None
-
- Pointers and Buffers Modified:
- Int quant_spec[] = Output (the quantized and signed spectral coefficients)
- returned via this pointer.
-
- Local Stores Modified:
- None
-
- Global Stores Modified:
- None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes quantized spectral coefficients and decode their signs
- from the input bitstream. Quantized spectral coefficients are transmitted as
- four-tuples or 2-tuples, and this information is conveyed to the function via
- the variable HuffCodebook->dim.
-
- See Reference #1 for a complete description
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall correctly calculate pQuantSpec[], given the inputs
-
- codeword_indx = {1-288};
- HuffCodebook->off = {0, 1, 4};
- HuffCodebook->mod = {3, 8, 9, 13, 17};
-
- mod = LAV + 1 if unsigned codebook
- mod = 2*LAV + 1 if signed codebook
-
- Range of values for LAV is {2,7,12,16} if unsigned
- {1,4} if signed
-
- Additionally,
- LAV <= 2 if dim == 4
-
- This restricts mod == 3 if dim == 4
- and mod == {3, 8, 9, 13, 17} if dim == 2
-
- This function will NOT function correctly if fed values that do not
- meet the requirements as stated above.
-
- This limitation on the range of values was determined by analysis
- of Reference #1 (see below.)
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
- Part 3
- Subpart 4.6.3.3 Decoding Process
- Subpart 4.6.4 Tables
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- IF (pHuffCodebook->dim == 4)
- *(pQuantSpec) = codeword_indx/(3^3);
- codeword_indx = codeword_indx - *(pQuantSpec)*(3^3);
- *(pQuantSpec) = *(pQuantSpec) - off;
-
- pQuantSpec = pQuantSpec + 1;
-
- *(pQuantSpec) = codeword_indx/(3^2);
- codeword_indx = codeword_indx - *(pQuantSpec)*(3^2);
- *(pQuantSpec) = *(pQuantSpec) - off;
-
- pQuantSpec = pQuantSpec + 1;
- ENDIF
-
- *(pQuantSpec) = codeword_indx/mod;
- codeword_indx = codeword_indx - (*pQuantSpec)*mod;
- *(pQuantSpec) = *(pQuantSpec) - off;
-
- pQuantSpec = pQuantSpec + 1;
-
- *(pQuantSpec) = codeword_indx - off;
-
-------------------------------------------------------------------------------
- RESOURCES USED
- When the code is written for a specific target processor the
- the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
- stack usage for each subroutine called]
-
- where: [stack usage variable] = stack usage for [subroutine
- name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
- used to represent cycle count for each subroutine
- called]
-
- where: [cycle count variable] = cycle count for [subroutine
- name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hcb.h"
-#include "ibstream.h"
-#include "unpack_idx.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define DIV_3_CUBED 19 /* 19 = 1/27 in Q-9 format */
-#define THREE_CUBED 27 /* 27 = 3^3 */
-
-#define DIV_3_SQUARED 57 /* 57 = 1/9 in Q-9 format */
-#define THREE_SQUARED 9 /* 9 = 3^2 */
-
-#define Q_FORMAT_MOD 13 /* Q-format for 1/mod table */
-#define Q_FORMAT_MOD2 9 /* Q-format for DIV_3_SQUARED */
-#define Q_FORMAT_MOD3 9 /* Q-format for DIV_3_CUBED */
-
-#define LOWER_5_BITS_MASK 0x1F
-
-
-#if ( defined(PV_ARM_V5) || defined(PV_ARM_V4))
-
-__inline Int32 abs1(Int32 x)
-{
- Int32 z;
- /*
- z = x - (x<0);
- x = z ^ sign(z)
- */
- __asm
- {
- sub z, x, x, lsr #31
- eor x, z, z, asr #31
- }
- return (x);
-}
-
-#define pv_abs(x) abs1(x)
-
-
-#else
-
-#define pv_abs(x) ((x) > 0)? (x) : (-x)
-
-#endif
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*--------------------------------------------------------------------------
- Possible values for mod = {3,8,9,13,17}
-
- There exists "empty" spaces in the table. These can potentially
- be utilized by other const tables, if available memory becomes an issue.
----------------------------------------------------------------------------*/
-
-const Int div_mod[18] = /* mod index Q-format */
-{
- /* ----------------------- */
- 0xCC, /* | | 0 | */
- 0xCC, /* | | 1 | */
- 0xCC, /* | | 2 | */
- 2731, /* | 3 | 3 | 13 */
- 0xCC, /* | | 4 | */
- 0xCC, /* | | 5 | */
- 0xCC, /* | | 6 | */
- 0xCC, /* | | 7 | */
- 1025, /* | 8 | 8 | 13 */
- 911, /* | 9 | 9 | 13 */
- 0xCC, /* | | 10 | */
- 0xCC, /* | | 11 | */
- 0xCC, /* | | 12 | */
- 631, /* | 13 | 13 | 13 */
- 0xCC, /* | | 14 | */
- 0xCC, /* | | 15 | */
- 0xCC, /* | | 16 | */
- 482, /* | 17 | 17 | 13 */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void unpack_idx(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max)
-{
- Int16 *pQuantSpec = &quant_spec[0];
- Int temp_spec;
-
- const Int mod = pHuffCodebook->mod;
- const Int off = pHuffCodebook->off;
-
- OSCL_UNUSED_ARG(pInputStream);
-
-
- if (pHuffCodebook->dim == DIMENSION_4)
- {
- /* Calculate pQuantSpec[0] */
-
- temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3;
-
- codeword_indx -= temp_spec * THREE_CUBED;
-
- temp_spec -= off;
- *pQuantSpec++ = (Int16)temp_spec;
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
-
- /* Calculate pQuantSpec[1] */
- temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2;
-
- codeword_indx -= temp_spec * THREE_SQUARED;
-
- temp_spec -= off;
- *pQuantSpec++ = (Int16)temp_spec;
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
- }
-
- /*
- * Calculate pQuantSpec[2] if dim == 4
- * Calculate pQuantSpec[0] if dim == 2
- */
-
- temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
- codeword_indx -= temp_spec * mod;
-
- temp_spec -= off;
- *pQuantSpec++ = (Int16)temp_spec;
-
- temp_spec = pv_abs(temp_spec);
-
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
-
- /*
- * Calculate pQuantSpec[3] if dim == 4
- * Calculate pQuantSpec[1] if dim == 2
- */
- codeword_indx -= off;
- *pQuantSpec = (Int16)codeword_indx ;
-
-
- codeword_indx = pv_abs(codeword_indx);
-
- if (codeword_indx > *max)
- {
- *max = codeword_indx;
- }
-
-
- return ;
-} /* unpack_idx */
-
-
-void unpack_idx_sgn(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max)
-{
- Int16 *pQuantSpec = &quant_spec[0];
- Int temp_spec;
- Int sgn;
-
- const Int mod = pHuffCodebook->mod;
- const Int off = pHuffCodebook->off;
-
-
-
- if (pHuffCodebook->dim == DIMENSION_4)
- {
- /* Calculate pQuantSpec[0] */
- preload_cache((Int32 *)pQuantSpec);
- temp_spec = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3;
-
- codeword_indx -= temp_spec * THREE_CUBED;
-
- temp_spec -= off;
- if (temp_spec)
- {
- sgn = get1bits(pInputStream);
-
-
- *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
-
- }
- else
- {
- *pQuantSpec++ = 0;
- }
-
- /* Calculate pQuantSpec[1] */
- temp_spec = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2;
-
- codeword_indx -= temp_spec * THREE_SQUARED;
-
- temp_spec -= off;
- if (temp_spec)
- {
-
- sgn = get1bits(pInputStream);
-
- *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
- }
- else
- {
- *pQuantSpec++ = 0;
- }
- }
-
- /*
- * Calculate pQuantSpec[2] if dim == 4
- * Calculate pQuantSpec[0] if dim == 2
- */
-
- temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
- codeword_indx -= temp_spec * mod;
-
- temp_spec -= off;
- if (temp_spec)
- {
-
- sgn = get1bits(pInputStream);
-
- *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
- }
- else
- {
- *pQuantSpec++ = 0;
- }
-
- /*
- * Calculate pQuantSpec[3] if dim == 4
- * Calculate pQuantSpec[1] if dim == 2
- */
- codeword_indx -= off;
- if (codeword_indx)
- {
-
- sgn = get1bits(pInputStream);
-
- *pQuantSpec = (Int16)((sgn) ? -codeword_indx : codeword_indx);
-
- codeword_indx = pv_abs(codeword_indx);
-
- if (codeword_indx > *max)
- {
- *max = codeword_indx;
- }
- }
- else
- {
- *pQuantSpec = 0;
- }
-
- return ;
-} /* unpack_idx_sgn */
-
-
-void unpack_idx_esc(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max)
-{
- Int temp_spec;
- Int sgn1 = 0, sgn2 = 0;
- Int N;
- Int32 esc_seq;
-
- const Int mod = pHuffCodebook->mod;
- const Int off = pHuffCodebook->off;
-
-
- temp_spec = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
- codeword_indx -= temp_spec * mod;
-
- temp_spec -= off;
- if (temp_spec)
- {
- sgn1 = get1bits(pInputStream);
- }
-
- codeword_indx -= off;
- if (codeword_indx)
- {
- sgn2 = get1bits(pInputStream);
- }
-
-
- if ((temp_spec & LOWER_5_BITS_MASK) == 16)
- {
- N = 3;
- do
- {
- N++;
-
- esc_seq = get1bits(pInputStream);
-
- }
- while (esc_seq != 0);
-
- esc_seq = getbits(N, pInputStream);
-
- esc_seq += (1 << N);
-
-
- temp_spec = (Int)((temp_spec * esc_seq) >> 4);
-
- }
-
-
- if (sgn1)
- {
- quant_spec[0] = (Int16)(-temp_spec);
- }
- else
- {
- quant_spec[0] = (Int16)temp_spec;
- }
-
- temp_spec = pv_abs(temp_spec);
-
- if (temp_spec > *max)
- {
- *max = temp_spec;
- }
-
- if ((codeword_indx & LOWER_5_BITS_MASK) == 16)
- {
- N = 3;
- do
- {
- N++;
-
- esc_seq = get1bits(pInputStream);
-
- }
- while (esc_seq != 0);
-
- esc_seq = getbits(N, pInputStream);
-
- esc_seq += (1 << N);
-
- codeword_indx = (Int)((codeword_indx * esc_seq) >> 4);
- }
-
-
-
-
- if (sgn2)
- {
- quant_spec[1] = (Int16)(-codeword_indx);
- }
- else
- {
- quant_spec[1] = (Int16)codeword_indx;
- }
-
-
- codeword_indx = pv_abs(codeword_indx);
-
- if (codeword_indx > *max)
- {
- *max = codeword_indx;
- }
-
-
- return ;
-} /* unpack_idx_esc */
diff --git a/media/libstagefright/codecs/aacdec/unpack_idx.h b/media/libstagefright/codecs/aacdec/unpack_idx.h
deleted file mode 100644
index a308c4a..0000000
--- a/media/libstagefright/codecs/aacdec/unpack_idx.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/unpack_idx.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This header file includes the function definition for unpack_idx()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef UNPACK_IDX_H
-#define UNPACK_IDX_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hcb.h"
-#include "s_bits.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define DIMENSION_4 4
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
- void unpack_idx(
- Int16 QuantSpec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max);
- void unpack_idx_sgn(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max);
- void unpack_idx_esc(
- Int16 quant_spec[],
- Int codeword_indx,
- const Hcb *pHuffCodebook,
- BITS *pInputStream,
- Int *max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/window_block_fxp.h b/media/libstagefright/codecs/aacdec/window_block_fxp.h
deleted file mode 100644
index f936199..0000000
--- a/media/libstagefright/codecs/aacdec/window_block_fxp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: window_block_fxp.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- modified function definition: Time_data from Int to Int32
- change wnd_shape from structure to passing parameters
- delete definition of wnd_shape1, not needed.
-
- Description: Modified based on unit test comments
-
- Description: Change copyright, add () around constants.
-
- Description:
- changed Long_Window_fxp and Short _Window_fxp tables definition, from
- "const UInt16 *" to "const UInt16 * const" to avoid global variable
- definition.
-
- Description: Updated function trans4m_freq_2_time_fxp definition
-
- Description: Modified function interface to add output_buffer
-
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for window and block switch
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7 Part 7: Advanced Audo Coding (AAC)
-
-
- (2) MPEG-2 NBC Audio Decoder
- "This software module was originally developed by AT&T, Dolby
- Laboratories, Fraunhofer Gesellschaft IIS in the course of development
- of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
- 3. This software module is an implementation of a part of one or more
- MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
- Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
- standards free license to this software module or modifications thereof
- for use in hardware or software products claiming conformance to the
- MPEG-2 NBC/MPEG-4 Audio standards. Those intending to use this software
- module in hardware or software products are advised that this use may
- infringe existing patents. The original developer of this software
- module and his/her company, the subsequent editors and their companies,
- and ISO/IEC have no liability for use of this software module or
- modifications thereof in an implementation. Copyright is not released
- for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
- developer retains full right to use the code for his/her own purpose,
- assign or donate the code to a third party and to inhibit third party
- from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
- This copyright notice must be included in all copies or derivative
- works."
- Copyright(c)1996.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef WINDOW_BLOCK_FXP_H
-#define WINDOW_BLOCK_FXP_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_shape.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-#define LONG_WINDOW (1024)
-#define SHORT_WINDOW (128)
-
-#define HALF_LONG_WINDOW (LONG_WINDOW>>1)
-#define HALF_SHORT_WINDOW (SHORT_WINDOW>>1)
-
-#define NUM_SHORT_WINDOWS (8)
-#define LONG_WINDOW_m_1 (LONG_WINDOW-1)
-#define SHORT_WINDOW_m_1 (SHORT_WINDOW-1)
-
- /*
- * Limits for window sequences, they are used to build
- * each long window, they are defined in the standards
- */
-#define W_L_START_1 ((3*LONG_WINDOW - SHORT_WINDOW)>>1)
-#define W_L_START_2 ((3*LONG_WINDOW + SHORT_WINDOW)>>1)
-#define W_L_STOP_1 ((LONG_WINDOW - SHORT_WINDOW)>>1)
-#define W_L_STOP_2 ((LONG_WINDOW + SHORT_WINDOW)>>1)
-
-
-#define LONG_BLOCK1 (2*LONG_WINDOW)
-#define SHORT_BLOCK1 (2*SHORT_WINDOW)
-
-
-#define SCALING 10
-#define ROUNDING (1<<(SCALING-1))
-
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
- extern const Int16 Short_Window_KBD_fxp[ SHORT_WINDOW];
- extern const Int16 Long_Window_KBD_fxp[ LONG_WINDOW];
- extern const Int16 Short_Window_sine_fxp[ SHORT_WINDOW];
- extern const Int16 Long_Window_sine_fxp[ LONG_WINDOW];
-
- extern const Int16 * const Long_Window_fxp[];
- extern const Int16 * const Short_Window_fxp[];
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
-
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
- void trans4m_freq_2_time_fxp(
- Int32 Frequency_data[],
- Int32 Time_data[],
-#ifdef AAC_PLUS
- Int32 Output_buffer[],
-#else
- Int16 Output_buffer[],
-#endif
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int Q_format,
- Int32 abs_max_per_window[],
- Int32 freq_2_time_buffer[] ,
- Int16 *Interleave_output
- );
-
-
-
- void trans4m_freq_2_time_fxp_1(
- Int32 Frequency_data[],
- Int32 Time_data[],
- Int16 Output_buffer[],
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int Q_format,
- Int32 abs_max_per_window[],
- Int32 freq_2_time_buffer[]
- );
-
-
- void trans4m_freq_2_time_fxp_2(
- Int32 Frequency_data[],
- Int32 Time_data[],
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int Q_format,
- Int32 abs_max_per_window[],
- Int32 freq_2_time_buffer[] ,
- Int16 *Interleave_output
- );
-
- void trans4m_time_2_freq_fxp(
- Int32 Time2Freq_data[],
- WINDOW_SEQUENCE wnd_seq,
- Int wnd_shape_prev_bk,
- Int wnd_shape_this_bk,
- Int *pQ_format,
- Int32 mem_4_in_place_FFT[]);
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WINDOW_BLOCK_FXP_H */
-
diff --git a/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp
deleted file mode 100644
index aa04225..0000000
--- a/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp
+++ /dev/null
@@ -1,730 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: window_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- changed table content definition from UInt to UInt16.
-
- Description:
- changed Long_Window_fxp and Short _Window_fxp tables definition, from
- "const UInt16 *" to "const UInt16 * const" to avoid global variable
- definition.
-
- Description:
- Improved rounding on table elements.
-
- Description: Eliminated structure to avoid assigning addresses to constant
- tables. This solve linking problem when using the
- /ropi option (Read-only position independent) for some
- compilers
- - Eliminated Long_Window_fxp and Short_Window_fxp as global
- contants vectors
-
- Who: Date:
- Description:
-
- ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
- Window tables
-
- For a sine table with N points:
-
- w_left = sin(pi/N (n + 1/2)) for 0 =< n < N/2
-
- w_rigth = sin(pi/N (n + 1/2)) for N/2 =< n < N
-
-
- For Kaiser-Bessel derived (KBD)
-
- n N/2
- w_left = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for 0 =< n < N/2
- p=0 p=0
-
-
- N-n-1 N/2
- w_rigth = sqrt(( SUM W(p,a) )/( SUM W(p,a) ) for N/2 =< n < N
- p=0 p=0
-
-
- W(p,a) see ISO 14496-3, pag 113
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall implement the fix point verwion of the windowing tables
-
-------------------------------------------------------------------------------
- REFERENCES
-
- [1] ISO 14496-3, pag 113
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-const Int16 Long_Window_sine_fxp[LONG_WINDOW] =
-{
-
-
- 0x0019, 0x004B, 0x007E, 0x00B0,
- 0x00E2, 0x0114, 0x0147, 0x0179,
- 0x01AB, 0x01DD, 0x0210, 0x0242,
- 0x0274, 0x02A7, 0x02D9, 0x030B,
- 0x033D, 0x0370, 0x03A2, 0x03D4,
- 0x0406, 0x0438, 0x046B, 0x049D,
- 0x04CF, 0x0501, 0x0534, 0x0566,
- 0x0598, 0x05CA, 0x05FC, 0x062F,
- 0x0661, 0x0693, 0x06C5, 0x06F7,
- 0x072A, 0x075C, 0x078E, 0x07C0,
- 0x07F2, 0x0825, 0x0857, 0x0889,
- 0x08BB, 0x08ED, 0x091F, 0x0951,
- 0x0984, 0x09B6, 0x09E8, 0x0A1A,
- 0x0A4C, 0x0A7E, 0x0AB0, 0x0AE2,
- 0x0B14, 0x0B46, 0x0B78, 0x0BAB,
- 0x0BDD, 0x0C0F, 0x0C41, 0x0C73,
- 0x0CA5, 0x0CD7, 0x0D09, 0x0D3B,
- 0x0D6D, 0x0D9F, 0x0DD1, 0x0E03,
- 0x0E35, 0x0E67, 0x0E99, 0x0ECA,
- 0x0EFC, 0x0F2E, 0x0F60, 0x0F92,
- 0x0FC4, 0x0FF6, 0x1028, 0x105A,
- 0x108B, 0x10BD, 0x10EF, 0x1121,
- 0x1153, 0x1185, 0x11B6, 0x11E8,
- 0x121A, 0x124C, 0x127D, 0x12AF,
- 0x12E1, 0x1312, 0x1344, 0x1376,
- 0x13A8, 0x13D9, 0x140B, 0x143C,
- 0x146E, 0x14A0, 0x14D1, 0x1503,
- 0x1534, 0x1566, 0x1598, 0x15C9,
- 0x15FB, 0x162C, 0x165E, 0x168F,
- 0x16C1, 0x16F2, 0x1724, 0x1755,
- 0x1786, 0x17B8, 0x17E9, 0x181B,
- 0x184C, 0x187D, 0x18AF, 0x18E0,
- 0x1911, 0x1942, 0x1974, 0x19A5,
- 0x19D6, 0x1A07, 0x1A39, 0x1A6A,
- 0x1A9B, 0x1ACC, 0x1AFD, 0x1B2E,
- 0x1B60, 0x1B91, 0x1BC2, 0x1BF3,
- 0x1C24, 0x1C55, 0x1C86, 0x1CB7,
- 0x1CE8, 0x1D19, 0x1D4A, 0x1D7B,
- 0x1DAC, 0x1DDC, 0x1E0D, 0x1E3E,
- 0x1E6F, 0x1EA0, 0x1ED1, 0x1F01,
- 0x1F32, 0x1F63, 0x1F94, 0x1FC4,
- 0x1FF5, 0x2026, 0x2056, 0x2087,
- 0x20B7, 0x20E8, 0x2119, 0x2149,
- 0x217A, 0x21AA, 0x21DB, 0x220B,
- 0x223C, 0x226C, 0x229C, 0x22CD,
- 0x22FD, 0x232E, 0x235E, 0x238E,
- 0x23BE, 0x23EF, 0x241F, 0x244F,
- 0x247F, 0x24AF, 0x24E0, 0x2510,
- 0x2540, 0x2570, 0x25A0, 0x25D0,
- 0x2600, 0x2630, 0x2660, 0x2690,
- 0x26C0, 0x26F0, 0x2720, 0x274F,
- 0x277F, 0x27AF, 0x27DF, 0x280F,
- 0x283E, 0x286E, 0x289E, 0x28CD,
- 0x28FD, 0x292D, 0x295C, 0x298C,
- 0x29BB, 0x29EB, 0x2A1A, 0x2A4A,
- 0x2A79, 0x2AA8, 0x2AD8, 0x2B07,
- 0x2B37, 0x2B66, 0x2B95, 0x2BC4,
- 0x2BF4, 0x2C23, 0x2C52, 0x2C81,
- 0x2CB0, 0x2CDF, 0x2D0E, 0x2D3D,
- 0x2D6C, 0x2D9B, 0x2DCA, 0x2DF9,
- 0x2E28, 0x2E57, 0x2E86, 0x2EB5,
- 0x2EE3, 0x2F12, 0x2F41, 0x2F70,
- 0x2F9E, 0x2FCD, 0x2FFC, 0x302A,
- 0x3059, 0x3087, 0x30B6, 0x30E4,
- 0x3113, 0x3141, 0x316F, 0x319E,
- 0x31CC, 0x31FA, 0x3229, 0x3257,
- 0x3285, 0x32B3, 0x32E1, 0x330F,
- 0x333E, 0x336C, 0x339A, 0x33C8,
- 0x33F6, 0x3423, 0x3451, 0x347F,
- 0x34AD, 0x34DB, 0x3509, 0x3536,
- 0x3564, 0x3592, 0x35BF, 0x35ED,
- 0x361A, 0x3648, 0x3676, 0x36A3,
- 0x36D0, 0x36FE, 0x372B, 0x3759,
- 0x3786, 0x37B3, 0x37E0, 0x380E,
- 0x383B, 0x3868, 0x3895, 0x38C2,
- 0x38EF, 0x391C, 0x3949, 0x3976,
- 0x39A3, 0x39D0, 0x39FD, 0x3A29,
- 0x3A56, 0x3A83, 0x3AB0, 0x3ADC,
- 0x3B09, 0x3B35, 0x3B62, 0x3B8E,
- 0x3BBB, 0x3BE7, 0x3C14, 0x3C40,
- 0x3C6C, 0x3C99, 0x3CC5, 0x3CF1,
- 0x3D1D, 0x3D4A, 0x3D76, 0x3DA2,
- 0x3DCE, 0x3DFA, 0x3E26, 0x3E52,
- 0x3E7D, 0x3EA9, 0x3ED5, 0x3F01,
- 0x3F2D, 0x3F58, 0x3F84, 0x3FB0,
- 0x3FDB, 0x4007, 0x4032, 0x405E,
- 0x4089, 0x40B5, 0x40E0, 0x410B,
- 0x4136, 0x4162, 0x418D, 0x41B8,
- 0x41E3, 0x420E, 0x4239, 0x4264,
- 0x428F, 0x42BA, 0x42E5, 0x4310,
- 0x433B, 0x4365, 0x4390, 0x43BB,
- 0x43E5, 0x4410, 0x443B, 0x4465,
- 0x448F, 0x44BA, 0x44E4, 0x450F,
- 0x4539, 0x4563, 0x458D, 0x45B8,
- 0x45E2, 0x460C, 0x4636, 0x4660,
- 0x468A, 0x46B4, 0x46DE, 0x4707,
- 0x4731, 0x475B, 0x4785, 0x47AE,
- 0x47D8, 0x4802, 0x482B, 0x4855,
- 0x487E, 0x48A7, 0x48D1, 0x48FA,
- 0x4923, 0x494D, 0x4976, 0x499F,
- 0x49C8, 0x49F1, 0x4A1A, 0x4A43,
- 0x4A6C, 0x4A95, 0x4ABE, 0x4AE6,
- 0x4B0F, 0x4B38, 0x4B61, 0x4B89,
- 0x4BB2, 0x4BDA, 0x4C03, 0x4C2B,
- 0x4C53, 0x4C7C, 0x4CA4, 0x4CCC,
- 0x4CF4, 0x4D1D, 0x4D45, 0x4D6D,
- 0x4D95, 0x4DBD, 0x4DE5, 0x4E0D,
- 0x4E34, 0x4E5C, 0x4E84, 0x4EAB,
- 0x4ED3, 0x4EFB, 0x4F22, 0x4F4A,
- 0x4F71, 0x4F99, 0x4FC0, 0x4FE7,
- 0x500E, 0x5036, 0x505D, 0x5084,
- 0x50AB, 0x50D2, 0x50F9, 0x5120,
- 0x5147, 0x516D, 0x5194, 0x51BB,
- 0x51E2, 0x5208, 0x522F, 0x5255,
- 0x527C, 0x52A2, 0x52C8, 0x52EF,
- 0x5315, 0x533B, 0x5361, 0x5387,
- 0x53AE, 0x53D4, 0x53FA, 0x541F,
- 0x5445, 0x546B, 0x5491, 0x54B7,
- 0x54DC, 0x5502, 0x5527, 0x554D,
- 0x5572, 0x5598, 0x55BD, 0x55E2,
- 0x5608, 0x562D, 0x5652, 0x5677,
- 0x569C, 0x56C1, 0x56E6, 0x570B,
- 0x5730, 0x5754, 0x5779, 0x579E,
- 0x57C2, 0x57E7, 0x580C, 0x5830,
- 0x5854, 0x5879, 0x589D, 0x58C1,
- 0x58E5, 0x590A, 0x592E, 0x5952,
- 0x5976, 0x599A, 0x59BD, 0x59E1,
- 0x5A05, 0x5A29, 0x5A4C, 0x5A70,
- 0x5A94, 0x5AB7, 0x5ADA, 0x5AFE,
- 0x5B21, 0x5B44, 0x5B68, 0x5B8B,
- 0x5BAE, 0x5BD1, 0x5BF4, 0x5C17,
- 0x5C3A, 0x5C5D, 0x5C7F, 0x5CA2,
- 0x5CC5, 0x5CE7, 0x5D0A, 0x5D2C,
- 0x5D4F, 0x5D71, 0x5D94, 0x5DB6,
- 0x5DD8, 0x5DFA, 0x5E1C, 0x5E3E,
- 0x5E60, 0x5E82, 0x5EA4, 0x5EC6,
- 0x5EE8, 0x5F09, 0x5F2B, 0x5F4D,
- 0x5F6E, 0x5F90, 0x5FB1, 0x5FD2,
- 0x5FF4, 0x6015, 0x6036, 0x6057,
- 0x6078, 0x6099, 0x60BA, 0x60DB,
- 0x60FC, 0x611D, 0x613D, 0x615E,
- 0x617F, 0x619F, 0x61C0, 0x61E0,
- 0x6200, 0x6221, 0x6241, 0x6261,
- 0x6281, 0x62A1, 0x62C1, 0x62E1,
- 0x6301, 0x6321, 0x6341, 0x6360,
- 0x6380, 0x63A0, 0x63BF, 0x63DF,
- 0x63FE, 0x641D, 0x643D, 0x645C,
- 0x647B, 0x649A, 0x64B9, 0x64D8,
- 0x64F7, 0x6516, 0x6535, 0x6554,
- 0x6572, 0x6591, 0x65AF, 0x65CE,
- 0x65EC, 0x660B, 0x6629, 0x6647,
- 0x6666, 0x6684, 0x66A2, 0x66C0,
- 0x66DE, 0x66FC, 0x6719, 0x6737,
- 0x6755, 0x6772, 0x6790, 0x67AE,
- 0x67CB, 0x67E8, 0x6806, 0x6823,
- 0x6840, 0x685D, 0x687A, 0x6897,
- 0x68B4, 0x68D1, 0x68EE, 0x690B,
- 0x6927, 0x6944, 0x6961, 0x697D,
- 0x699A, 0x69B6, 0x69D2, 0x69EE,
- 0x6A0B, 0x6A27, 0x6A43, 0x6A5F,
- 0x6A7B, 0x6A97, 0x6AB2, 0x6ACE,
- 0x6AEA, 0x6B05, 0x6B21, 0x6B3C,
- 0x6B58, 0x6B73, 0x6B8E, 0x6BAA,
- 0x6BC5, 0x6BE0, 0x6BFB, 0x6C16,
- 0x6C31, 0x6C4C, 0x6C66, 0x6C81,
- 0x6C9C, 0x6CB6, 0x6CD1, 0x6CEB,
- 0x6D06, 0x6D20, 0x6D3A, 0x6D54,
- 0x6D6E, 0x6D88, 0x6DA2, 0x6DBC,
- 0x6DD6, 0x6DF0, 0x6E0A, 0x6E23,
- 0x6E3D, 0x6E56, 0x6E70, 0x6E89,
- 0x6EA2, 0x6EBC, 0x6ED5, 0x6EEE,
- 0x6F07, 0x6F20, 0x6F39, 0x6F52,
- 0x6F6B, 0x6F83, 0x6F9C, 0x6FB4,
- 0x6FCD, 0x6FE5, 0x6FFE, 0x7016,
- 0x702E, 0x7046, 0x705F, 0x7077,
- 0x708F, 0x70A6, 0x70BE, 0x70D6,
- 0x70EE, 0x7105, 0x711D, 0x7134,
- 0x714C, 0x7163, 0x717A, 0x7192,
- 0x71A9, 0x71C0, 0x71D7, 0x71EE,
- 0x7205, 0x721C, 0x7232, 0x7249,
- 0x7260, 0x7276, 0x728D, 0x72A3,
- 0x72B9, 0x72D0, 0x72E6, 0x72FC,
- 0x7312, 0x7328, 0x733E, 0x7354,
- 0x7369, 0x737F, 0x7395, 0x73AA,
- 0x73C0, 0x73D5, 0x73EB, 0x7400,
- 0x7415, 0x742A, 0x743F, 0x7454,
- 0x7469, 0x747E, 0x7493, 0x74A8,
- 0x74BC, 0x74D1, 0x74E5, 0x74FA,
- 0x750E, 0x7522, 0x7537, 0x754B,
- 0x755F, 0x7573, 0x7587, 0x759B,
- 0x75AE, 0x75C2, 0x75D6, 0x75E9,
- 0x75FD, 0x7610, 0x7624, 0x7637,
- 0x764A, 0x765E, 0x7671, 0x7684,
- 0x7697, 0x76A9, 0x76BC, 0x76CF,
- 0x76E2, 0x76F4, 0x7707, 0x7719,
- 0x772C, 0x773E, 0x7750, 0x7762,
- 0x7774, 0x7786, 0x7798, 0x77AA,
- 0x77BC, 0x77CE, 0x77DF, 0x77F1,
- 0x7803, 0x7814, 0x7825, 0x7837,
- 0x7848, 0x7859, 0x786A, 0x787B,
- 0x788C, 0x789D, 0x78AE, 0x78BE,
- 0x78CF, 0x78E0, 0x78F0, 0x7901,
- 0x7911, 0x7921, 0x7931, 0x7941,
- 0x7952, 0x7962, 0x7971, 0x7981,
- 0x7991, 0x79A1, 0x79B0, 0x79C0,
- 0x79CF, 0x79DF, 0x79EE, 0x79FD,
- 0x7A0D, 0x7A1C, 0x7A2B, 0x7A3A,
- 0x7A49, 0x7A57, 0x7A66, 0x7A75,
- 0x7A83, 0x7A92, 0x7AA0, 0x7AAF,
- 0x7ABD, 0x7ACB, 0x7AD9, 0x7AE7,
- 0x7AF5, 0x7B03, 0x7B11, 0x7B1F,
- 0x7B2D, 0x7B3A, 0x7B48, 0x7B55,
- 0x7B63, 0x7B70, 0x7B7D, 0x7B8B,
- 0x7B98, 0x7BA5, 0x7BB2, 0x7BBF,
- 0x7BCB, 0x7BD8, 0x7BE5, 0x7BF1,
- 0x7BFE, 0x7C0A, 0x7C17, 0x7C23,
- 0x7C2F, 0x7C3B, 0x7C47, 0x7C53,
- 0x7C5F, 0x7C6B, 0x7C77, 0x7C83,
- 0x7C8E, 0x7C9A, 0x7CA5, 0x7CB1,
- 0x7CBC, 0x7CC7, 0x7CD2, 0x7CDD,
- 0x7CE8, 0x7CF3, 0x7CFE, 0x7D09,
- 0x7D14, 0x7D1E, 0x7D29, 0x7D33,
- 0x7D3E, 0x7D48, 0x7D52, 0x7D5C,
- 0x7D67, 0x7D71, 0x7D7B, 0x7D84,
- 0x7D8E, 0x7D98, 0x7DA2, 0x7DAB,
- 0x7DB5, 0x7DBE, 0x7DC8, 0x7DD1,
- 0x7DDA, 0x7DE3, 0x7DEC, 0x7DF5,
- 0x7DFE, 0x7E07, 0x7E10, 0x7E18,
- 0x7E21, 0x7E29, 0x7E32, 0x7E3A,
- 0x7E42, 0x7E4B, 0x7E53, 0x7E5B,
- 0x7E63, 0x7E6B, 0x7E73, 0x7E7A,
- 0x7E82, 0x7E8A, 0x7E91, 0x7E99,
- 0x7EA0, 0x7EA7, 0x7EAF, 0x7EB6,
- 0x7EBD, 0x7EC4, 0x7ECB, 0x7ED2,
- 0x7ED8, 0x7EDF, 0x7EE6, 0x7EEC,
- 0x7EF3, 0x7EF9, 0x7EFF, 0x7F05,
- 0x7F0C, 0x7F12, 0x7F18, 0x7F1E,
- 0x7F23, 0x7F29, 0x7F2F, 0x7F35,
- 0x7F3A, 0x7F40, 0x7F45, 0x7F4A,
- 0x7F50, 0x7F55, 0x7F5A, 0x7F5F,
- 0x7F64, 0x7F69, 0x7F6D, 0x7F72,
- 0x7F77, 0x7F7B, 0x7F80, 0x7F84,
- 0x7F88, 0x7F8D, 0x7F91, 0x7F95,
- 0x7F99, 0x7F9D, 0x7FA1, 0x7FA4,
- 0x7FA8, 0x7FAC, 0x7FAF, 0x7FB3,
- 0x7FB6, 0x7FB9, 0x7FBD, 0x7FC0,
- 0x7FC3, 0x7FC6, 0x7FC9, 0x7FCC,
- 0x7FCE, 0x7FD1, 0x7FD4, 0x7FD6,
- 0x7FD9, 0x7FDB, 0x7FDD, 0x7FE0,
- 0x7FE2, 0x7FE4, 0x7FE6, 0x7FE8,
- 0x7FEA, 0x7FEB, 0x7FED, 0x7FEF,
- 0x7FF0, 0x7FF2, 0x7FF3, 0x7FF5,
- 0x7FF6, 0x7FF7, 0x7FF8, 0x7FF9,
- 0x7FFA, 0x7FFB, 0x7FFC, 0x7FFC,
- 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF
-
-};
-
-
-const Int16 Short_Window_sine_fxp[SHORT_WINDOW] =
-{
-
- 0x00C9, 0x025B, 0x03ED, 0x057F,
- 0x0711, 0x08A2, 0x0A33, 0x0BC4,
- 0x0D54, 0x0EE3, 0x1072, 0x1201,
- 0x138F, 0x151C, 0x16A8, 0x1833,
- 0x19BE, 0x1B47, 0x1CCF, 0x1E57,
- 0x1FDD, 0x2161, 0x22E5, 0x2467,
- 0x25E8, 0x2767, 0x28E5, 0x2A61,
- 0x2BDC, 0x2D55, 0x2ECC, 0x3041,
- 0x31B5, 0x3326, 0x3496, 0x3604,
- 0x376F, 0x38D9, 0x3A40, 0x3BA5,
- 0x3D07, 0x3E68, 0x3FC5, 0x4121,
- 0x427A, 0x43D0, 0x4524, 0x4675,
- 0x47C3, 0x490F, 0x4A58, 0x4B9D,
- 0x4CE0, 0x4E20, 0x4F5D, 0x5097,
- 0x51CE, 0x5302, 0x5432, 0x5560,
- 0x568A, 0x57B0, 0x58D3, 0x59F3,
- 0x5B0F, 0x5C28, 0x5D3E, 0x5E4F,
- 0x5F5D, 0x6068, 0x616E, 0x6271,
- 0x6370, 0x646C, 0x6563, 0x6656,
- 0x6746, 0x6832, 0x6919, 0x69FD,
- 0x6ADC, 0x6BB7, 0x6C8E, 0x6D61,
- 0x6E30, 0x6EFB, 0x6FC1, 0x7083,
- 0x7140, 0x71F9, 0x72AE, 0x735E,
- 0x740A, 0x74B2, 0x7555, 0x75F3,
- 0x768D, 0x7722, 0x77B3, 0x783F,
- 0x78C7, 0x794A, 0x79C8, 0x7A41,
- 0x7AB6, 0x7B26, 0x7B91, 0x7BF8,
- 0x7C59, 0x7CB6, 0x7D0E, 0x7D62,
- 0x7DB0, 0x7DFA, 0x7E3E, 0x7E7E,
- 0x7EB9, 0x7EEF, 0x7F21, 0x7F4D,
- 0x7F74, 0x7F97, 0x7FB4, 0x7FCD,
- 0x7FE1, 0x7FF0, 0x7FF9, 0x7FFE
-};
-
-
-
-const Int16 Long_Window_KBD_fxp[LONG_WINDOW] =
-{
-
- 0x000A, 0x000E, 0x0012, 0x0015,
- 0x0019, 0x001C, 0x0020, 0x0023,
- 0x0026, 0x002A, 0x002D, 0x0030,
- 0x0034, 0x0038, 0x003B, 0x003F,
- 0x0043, 0x0047, 0x004B, 0x004F,
- 0x0053, 0x0057, 0x005B, 0x0060,
- 0x0064, 0x0069, 0x006D, 0x0072,
- 0x0077, 0x007C, 0x0081, 0x0086,
- 0x008B, 0x0091, 0x0096, 0x009C,
- 0x00A1, 0x00A7, 0x00AD, 0x00B3,
- 0x00B9, 0x00BF, 0x00C6, 0x00CC,
- 0x00D3, 0x00DA, 0x00E0, 0x00E7,
- 0x00EE, 0x00F5, 0x00FD, 0x0104,
- 0x010C, 0x0113, 0x011B, 0x0123,
- 0x012B, 0x0133, 0x013C, 0x0144,
- 0x014D, 0x0156, 0x015F, 0x0168,
- 0x0171, 0x017A, 0x0183, 0x018D,
- 0x0197, 0x01A1, 0x01AB, 0x01B5,
- 0x01BF, 0x01CA, 0x01D4, 0x01DF,
- 0x01EA, 0x01F5, 0x0200, 0x020C,
- 0x0217, 0x0223, 0x022F, 0x023B,
- 0x0247, 0x0253, 0x0260, 0x026D,
- 0x027A, 0x0287, 0x0294, 0x02A1,
- 0x02AF, 0x02BC, 0x02CA, 0x02D8,
- 0x02E7, 0x02F5, 0x0304, 0x0312,
- 0x0321, 0x0331, 0x0340, 0x034F,
- 0x035F, 0x036F, 0x037F, 0x038F,
- 0x03A0, 0x03B0, 0x03C1, 0x03D2,
- 0x03E3, 0x03F5, 0x0406, 0x0418,
- 0x042A, 0x043C, 0x044F, 0x0461,
- 0x0474, 0x0487, 0x049A, 0x04AE,
- 0x04C1, 0x04D5, 0x04E9, 0x04FD,
- 0x0512, 0x0526, 0x053B, 0x0550,
- 0x0566, 0x057B, 0x0591, 0x05A7,
- 0x05BD, 0x05D3, 0x05EA, 0x0601,
- 0x0618, 0x062F, 0x0646, 0x065E,
- 0x0676, 0x068E, 0x06A6, 0x06BF,
- 0x06D8, 0x06F1, 0x070A, 0x0723,
- 0x073D, 0x0757, 0x0771, 0x078C,
- 0x07A6, 0x07C1, 0x07DC, 0x07F7,
- 0x0813, 0x082F, 0x084B, 0x0867,
- 0x0884, 0x08A0, 0x08BD, 0x08DA,
- 0x08F8, 0x0916, 0x0933, 0x0952,
- 0x0970, 0x098F, 0x09AE, 0x09CD,
- 0x09EC, 0x0A0C, 0x0A2C, 0x0A4C,
- 0x0A6C, 0x0A8D, 0x0AAD, 0x0ACF,
- 0x0AF0, 0x0B11, 0x0B33, 0x0B55,
- 0x0B78, 0x0B9A, 0x0BBD, 0x0BE0,
- 0x0C03, 0x0C27, 0x0C4B, 0x0C6F,
- 0x0C93, 0x0CB8, 0x0CDD, 0x0D02,
- 0x0D27, 0x0D4D, 0x0D73, 0x0D99,
- 0x0DBF, 0x0DE6, 0x0E0C, 0x0E33,
- 0x0E5B, 0x0E82, 0x0EAA, 0x0ED2,
- 0x0EFB, 0x0F23, 0x0F4C, 0x0F75,
- 0x0F9F, 0x0FC8, 0x0FF2, 0x101C,
- 0x1047, 0x1071, 0x109C, 0x10C7,
- 0x10F3, 0x111E, 0x114A, 0x1176,
- 0x11A3, 0x11D0, 0x11FC, 0x122A,
- 0x1257, 0x1285, 0x12B3, 0x12E1,
- 0x130F, 0x133E, 0x136D, 0x139C,
- 0x13CB, 0x13FB, 0x142B, 0x145B,
- 0x148B, 0x14BC, 0x14ED, 0x151E,
- 0x1550, 0x1581, 0x15B3, 0x15E5,
- 0x1618, 0x164A, 0x167D, 0x16B0,
- 0x16E3, 0x1717, 0x174B, 0x177F,
- 0x17B3, 0x17E8, 0x181D, 0x1852,
- 0x1887, 0x18BC, 0x18F2, 0x1928,
- 0x195E, 0x1995, 0x19CB, 0x1A02,
- 0x1A39, 0x1A71, 0x1AA8, 0x1AE0,
- 0x1B18, 0x1B50, 0x1B89, 0x1BC1,
- 0x1BFA, 0x1C34, 0x1C6D, 0x1CA7,
- 0x1CE0, 0x1D1A, 0x1D55, 0x1D8F,
- 0x1DCA, 0x1E05, 0x1E40, 0x1E7B,
- 0x1EB7, 0x1EF2, 0x1F2E, 0x1F6B,
- 0x1FA7, 0x1FE4, 0x2020, 0x205D,
- 0x209B, 0x20D8, 0x2116, 0x2153,
- 0x2191, 0x21D0, 0x220E, 0x224D,
- 0x228B, 0x22CA, 0x2309, 0x2349,
- 0x2388, 0x23C8, 0x2408, 0x2448,
- 0x2488, 0x24C9, 0x2509, 0x254A,
- 0x258B, 0x25CC, 0x260E, 0x264F,
- 0x2691, 0x26D3, 0x2715, 0x2757,
- 0x2799, 0x27DC, 0x281F, 0x2861,
- 0x28A4, 0x28E8, 0x292B, 0x296E,
- 0x29B2, 0x29F6, 0x2A3A, 0x2A7E,
- 0x2AC2, 0x2B06, 0x2B4B, 0x2B8F,
- 0x2BD4, 0x2C19, 0x2C5E, 0x2CA3,
- 0x2CE9, 0x2D2E, 0x2D74, 0x2DB9,
- 0x2DFF, 0x2E45, 0x2E8B, 0x2ED1,
- 0x2F18, 0x2F5E, 0x2FA5, 0x2FEB,
- 0x3032, 0x3079, 0x30C0, 0x3107,
- 0x314E, 0x3195, 0x31DD, 0x3224,
- 0x326C, 0x32B4, 0x32FB, 0x3343,
- 0x338B, 0x33D3, 0x341B, 0x3463,
- 0x34AC, 0x34F4, 0x353D, 0x3585,
- 0x35CE, 0x3616, 0x365F, 0x36A8,
- 0x36F1, 0x373A, 0x3783, 0x37CC,
- 0x3815, 0x385E, 0x38A7, 0x38F0,
- 0x393A, 0x3983, 0x39CC, 0x3A16,
- 0x3A5F, 0x3AA9, 0x3AF2, 0x3B3C,
- 0x3B86, 0x3BCF, 0x3C19, 0x3C63,
- 0x3CAC, 0x3CF6, 0x3D40, 0x3D8A,
- 0x3DD3, 0x3E1D, 0x3E67, 0x3EB1,
- 0x3EFB, 0x3F45, 0x3F8E, 0x3FD8,
- 0x4022, 0x406C, 0x40B6, 0x4100,
- 0x414A, 0x4193, 0x41DD, 0x4227,
- 0x4271, 0x42BB, 0x4304, 0x434E,
- 0x4398, 0x43E1, 0x442B, 0x4475,
- 0x44BE, 0x4508, 0x4551, 0x459B,
- 0x45E4, 0x462E, 0x4677, 0x46C0,
- 0x4709, 0x4753, 0x479C, 0x47E5,
- 0x482E, 0x4877, 0x48C0, 0x4909,
- 0x4951, 0x499A, 0x49E3, 0x4A2B,
- 0x4A74, 0x4ABC, 0x4B04, 0x4B4D,
- 0x4B95, 0x4BDD, 0x4C25, 0x4C6D,
- 0x4CB5, 0x4CFC, 0x4D44, 0x4D8C,
- 0x4DD3, 0x4E1A, 0x4E62, 0x4EA9,
- 0x4EF0, 0x4F37, 0x4F7E, 0x4FC4,
- 0x500B, 0x5051, 0x5098, 0x50DE,
- 0x5124, 0x516A, 0x51B0, 0x51F6,
- 0x523B, 0x5281, 0x52C6, 0x530B,
- 0x5351, 0x5396, 0x53DA, 0x541F,
- 0x5464, 0x54A8, 0x54EC, 0x5530,
- 0x5574, 0x55B8, 0x55FC, 0x563F,
- 0x5683, 0x56C6, 0x5709, 0x574C,
- 0x578F, 0x57D1, 0x5814, 0x5856,
- 0x5898, 0x58DA, 0x591B, 0x595D,
- 0x599E, 0x59E0, 0x5A21, 0x5A61,
- 0x5AA2, 0x5AE3, 0x5B23, 0x5B63,
- 0x5BA3, 0x5BE3, 0x5C22, 0x5C62,
- 0x5CA1, 0x5CE0, 0x5D1F, 0x5D5D,
- 0x5D9C, 0x5DDA, 0x5E18, 0x5E56,
- 0x5E93, 0x5ED1, 0x5F0E, 0x5F4B,
- 0x5F87, 0x5FC4, 0x6000, 0x603D,
- 0x6079, 0x60B4, 0x60F0, 0x612B,
- 0x6166, 0x61A1, 0x61DC, 0x6216,
- 0x6250, 0x628A, 0x62C4, 0x62FE,
- 0x6337, 0x6370, 0x63A9, 0x63E2,
- 0x641A, 0x6452, 0x648A, 0x64C2,
- 0x64F9, 0x6531, 0x6568, 0x659E,
- 0x65D5, 0x660B, 0x6641, 0x6677,
- 0x66AD, 0x66E2, 0x6717, 0x674C,
- 0x6781, 0x67B5, 0x67E9, 0x681D,
- 0x6851, 0x6885, 0x68B8, 0x68EB,
- 0x691D, 0x6950, 0x6982, 0x69B4,
- 0x69E6, 0x6A17, 0x6A48, 0x6A79,
- 0x6AAA, 0x6ADB, 0x6B0B, 0x6B3B,
- 0x6B6A, 0x6B9A, 0x6BC9, 0x6BF8,
- 0x6C27, 0x6C55, 0x6C83, 0x6CB1,
- 0x6CDF, 0x6D0D, 0x6D3A, 0x6D67,
- 0x6D93, 0x6DC0, 0x6DEC, 0x6E18,
- 0x6E44, 0x6E6F, 0x6E9A, 0x6EC5,
- 0x6EF0, 0x6F1A, 0x6F44, 0x6F6E,
- 0x6F98, 0x6FC1, 0x6FEA, 0x7013,
- 0x703C, 0x7064, 0x708C, 0x70B4,
- 0x70DB, 0x7103, 0x712A, 0x7151,
- 0x7177, 0x719D, 0x71C3, 0x71E9,
- 0x720F, 0x7234, 0x7259, 0x727E,
- 0x72A2, 0x72C7, 0x72EB, 0x730E,
- 0x7332, 0x7355, 0x7378, 0x739B,
- 0x73BD, 0x73E0, 0x7402, 0x7424,
- 0x7445, 0x7466, 0x7487, 0x74A8,
- 0x74C9, 0x74E9, 0x7509, 0x7529,
- 0x7548, 0x7568, 0x7587, 0x75A5,
- 0x75C4, 0x75E2, 0x7601, 0x761E,
- 0x763C, 0x7659, 0x7676, 0x7693,
- 0x76B0, 0x76CC, 0x76E9, 0x7705,
- 0x7720, 0x773C, 0x7757, 0x7772,
- 0x778D, 0x77A8, 0x77C2, 0x77DC,
- 0x77F6, 0x780F, 0x7829, 0x7842,
- 0x785B, 0x7874, 0x788C, 0x78A5,
- 0x78BD, 0x78D5, 0x78EC, 0x7904,
- 0x791B, 0x7932, 0x7949, 0x795F,
- 0x7976, 0x798C, 0x79A2, 0x79B7,
- 0x79CD, 0x79E2, 0x79F7, 0x7A0C,
- 0x7A21, 0x7A35, 0x7A4A, 0x7A5E,
- 0x7A72, 0x7A85, 0x7A99, 0x7AAC,
- 0x7ABF, 0x7AD2, 0x7AE5, 0x7AF7,
- 0x7B09, 0x7B1B, 0x7B2D, 0x7B3F,
- 0x7B51, 0x7B62, 0x7B73, 0x7B84,
- 0x7B95, 0x7BA5, 0x7BB6, 0x7BC6,
- 0x7BD6, 0x7BE6, 0x7BF6, 0x7C05,
- 0x7C15, 0x7C24, 0x7C33, 0x7C42,
- 0x7C50, 0x7C5F, 0x7C6D, 0x7C7B,
- 0x7C89, 0x7C97, 0x7CA5, 0x7CB2,
- 0x7CC0, 0x7CCD, 0x7CDA, 0x7CE7,
- 0x7CF3, 0x7D00, 0x7D0C, 0x7D18,
- 0x7D25, 0x7D31, 0x7D3C, 0x7D48,
- 0x7D53, 0x7D5F, 0x7D6A, 0x7D75,
- 0x7D80, 0x7D8B, 0x7D95, 0x7DA0,
- 0x7DAA, 0x7DB4, 0x7DBE, 0x7DC8,
- 0x7DD2, 0x7DDC, 0x7DE5, 0x7DEF,
- 0x7DF8, 0x7E01, 0x7E0A, 0x7E13,
- 0x7E1C, 0x7E25, 0x7E2D, 0x7E36,
- 0x7E3E, 0x7E46, 0x7E4E, 0x7E56,
- 0x7E5E, 0x7E66, 0x7E6D, 0x7E75,
- 0x7E7C, 0x7E83, 0x7E8B, 0x7E92,
- 0x7E99, 0x7EA0, 0x7EA6, 0x7EAD,
- 0x7EB3, 0x7EBA, 0x7EC0, 0x7EC6,
- 0x7ECD, 0x7ED3, 0x7ED9, 0x7EDE,
- 0x7EE4, 0x7EEA, 0x7EF0, 0x7EF5,
- 0x7EFA, 0x7F00, 0x7F05, 0x7F0A,
- 0x7F0F, 0x7F14, 0x7F19, 0x7F1E,
- 0x7F23, 0x7F27, 0x7F2C, 0x7F30,
- 0x7F35, 0x7F39, 0x7F3D, 0x7F41,
- 0x7F46, 0x7F4A, 0x7F4E, 0x7F52,
- 0x7F55, 0x7F59, 0x7F5D, 0x7F60,
- 0x7F64, 0x7F68, 0x7F6B, 0x7F6E,
- 0x7F72, 0x7F75, 0x7F78, 0x7F7B,
- 0x7F7E, 0x7F81, 0x7F84, 0x7F87,
- 0x7F8A, 0x7F8D, 0x7F90, 0x7F92,
- 0x7F95, 0x7F97, 0x7F9A, 0x7F9C,
- 0x7F9F, 0x7FA1, 0x7FA4, 0x7FA6,
- 0x7FA8, 0x7FAA, 0x7FAC, 0x7FAE,
- 0x7FB1, 0x7FB3, 0x7FB5, 0x7FB6,
- 0x7FB8, 0x7FBA, 0x7FBC, 0x7FBE,
- 0x7FBF, 0x7FC1, 0x7FC3, 0x7FC4,
- 0x7FC6, 0x7FC8, 0x7FC9, 0x7FCB,
- 0x7FCC, 0x7FCD, 0x7FCF, 0x7FD0,
- 0x7FD1, 0x7FD3, 0x7FD4, 0x7FD5,
- 0x7FD6, 0x7FD8, 0x7FD9, 0x7FDA,
- 0x7FDB, 0x7FDC, 0x7FDD, 0x7FDE,
- 0x7FDF, 0x7FE0, 0x7FE1, 0x7FE2,
- 0x7FE3, 0x7FE4, 0x7FE4, 0x7FE5,
- 0x7FE6, 0x7FE7, 0x7FE8, 0x7FE8,
- 0x7FE9, 0x7FEA, 0x7FEA, 0x7FEB,
- 0x7FEC, 0x7FEC, 0x7FED, 0x7FEE,
- 0x7FEE, 0x7FEF, 0x7FEF, 0x7FF0,
- 0x7FF0, 0x7FF1, 0x7FF1, 0x7FF2,
- 0x7FF2, 0x7FF3, 0x7FF3, 0x7FF4,
- 0x7FF4, 0x7FF4, 0x7FF5, 0x7FF5,
- 0x7FF6, 0x7FF6, 0x7FF6, 0x7FF7,
- 0x7FF7, 0x7FF7, 0x7FF8, 0x7FF8,
- 0x7FF8, 0x7FF8, 0x7FF9, 0x7FF9,
- 0x7FF9, 0x7FF9, 0x7FFA, 0x7FFA,
- 0x7FFA, 0x7FFA, 0x7FFA, 0x7FFB,
- 0x7FFB, 0x7FFB, 0x7FFB, 0x7FFB,
- 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC,
- 0x7FFC, 0x7FFC, 0x7FFC, 0x7FFC,
- 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD,
- 0x7FFD, 0x7FFD, 0x7FFD, 0x7FFD,
- 0x7FFD, 0x7FFD, 0x7FFE, 0x7FFE,
- 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE,
- 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE,
- 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE,
- 0x7FFE, 0x7FFE, 0x7FFE, 0x7FFE,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF
-
-};
-
-
-
-
-const Int16 Short_Window_KBD_fxp[SHORT_WINDOW] =
-{
-
- 0x0001, 0x0004, 0x0008, 0x000D,
- 0x0014, 0x001D, 0x0029, 0x0039,
- 0x004C, 0x0063, 0x0080, 0x00A2,
- 0x00CB, 0x00FB, 0x0133, 0x0174,
- 0x01BE, 0x0214, 0x0275, 0x02E3,
- 0x035E, 0x03E8, 0x0481, 0x052B,
- 0x05E7, 0x06B4, 0x0795, 0x088A,
- 0x0993, 0x0AB2, 0x0BE7, 0x0D32,
- 0x0E94, 0x100E, 0x119F, 0x1347,
- 0x1507, 0x16DE, 0x18CC, 0x1AD0,
- 0x1CEB, 0x1F1A, 0x215F, 0x23B6,
- 0x2620, 0x289C, 0x2B27, 0x2DC0,
- 0x3066, 0x3317, 0x35D2, 0x3894,
- 0x3B5C, 0x3E28, 0x40F6, 0x43C4,
- 0x468F, 0x4956, 0x4C18, 0x4ED1,
- 0x5181, 0x5425, 0x56BC, 0x5944,
- 0x5BBB, 0x5E21, 0x6073, 0x62B1,
- 0x64DA, 0x66EC, 0x68E7, 0x6ACB,
- 0x6C96, 0x6E49, 0x6FE4, 0x7166,
- 0x72D0, 0x7421, 0x755B, 0x767E,
- 0x778A, 0x7881, 0x7962, 0x7A30,
- 0x7AEA, 0x7B92, 0x7C29, 0x7CB0,
- 0x7D28, 0x7D92, 0x7DF0, 0x7E42,
- 0x7E89, 0x7EC7, 0x7EFC, 0x7F2A,
- 0x7F50, 0x7F71, 0x7F8C, 0x7FA3,
- 0x7FB6, 0x7FC5, 0x7FD2, 0x7FDC,
- 0x7FE4, 0x7FEB, 0x7FF0, 0x7FF4,
- 0x7FF7, 0x7FF9, 0x7FFB, 0x7FFC,
- 0x7FFD, 0x7FFE, 0x7FFE, 0x7FFE,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF,
- 0x7FFF, 0x7FFF, 0x7FFF, 0x7FFF
-};
-
diff --git a/media/libstagefright/codecs/aacdec/write_output.h b/media/libstagefright/codecs/aacdec/write_output.h
deleted file mode 100644
index 0085a63..0000000
--- a/media/libstagefright/codecs/aacdec/write_output.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: write_output.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change function prototype.
-
- Description: Remove CR/LF from unknown editor
-
- Who: Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the declaration of the function write_output()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef WRITE_OUTPUT_H
-#define WRITE_OUTPUT_H
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
- /*----------------------------------------------------------------------------
- ; INCLUDES
- ----------------------------------------------------------------------------*/
-#include "pvmp4audiodecoder_api.h"
-
- /*----------------------------------------------------------------------------
- ; MACROS
- ; Define module specific macros here
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; DEFINES
- ; Include all pre-processor statements here.
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; EXTERNAL VARIABLES REFERENCES
- ; Declare variables used in this module but defined elsewhere
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; SIMPLE TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; ENUMERATED TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; STRUCTURES TYPEDEF'S
- ----------------------------------------------------------------------------*/
-
- /*----------------------------------------------------------------------------
- ; GLOBAL FUNCTION DEFINITIONS
- ; Function Prototype declaration
- ----------------------------------------------------------------------------*/
-
-#ifndef AAC_PLUS
-
- Int write_output(
- const Int16 sourceLeft[],
- const Int16 sourceRight[],
- Int16 outputBuffer[],
- const Int sourcePointsPerChannel,
- const Int sourceChannels,
- const Int requestedChannels,
- const tPVMP4AudioDecoderOutputFormat outputFormat);
-
-#else
-
- Int write_output(
- const Int16 sourceLeft[],
- const Int16 sourceRight[],
- Int16 outputBuffer[],
- const Int sourcePointsPerChannel,
- const Int sourceChannels,
- const Int requestedChannels,
-#ifdef PARAMETRICSTEREO
- Int32 sbrEnablePS,
-#endif
- const tPVMP4AudioDecoderOutputFormat outputFormat);
-
-#ifdef AAC_32_BIT_INTERFACE
-
- Int write_output_1(
- const Int32 sourceLeft[],
- const Int32 sourceRight[],
- Int16 outputBuffer[],
- const Int sourcePointsPerChannel,
- const Int sourceChannels,
- const Int requestedChannels,
- const tPVMP4AudioDecoderOutputFormat outputFormat);
-#endif
-
-#endif
-
- /*----------------------------------------------------------------------------
- ; END
- ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WRITE_OUTPUT_H */
-
-
diff --git a/media/libstagefright/codecs/avc/enc/Android.mk b/media/libstagefright/codecs/avc/enc/Android.mk
index 845d1d3..cffe469 100644
--- a/media/libstagefright/codecs/avc/enc/Android.mk
+++ b/media/libstagefright/codecs/avc/enc/Android.mk
@@ -41,6 +41,7 @@ LOCAL_SRC_FILES := \
LOCAL_C_INCLUDES := \
frameworks/av/media/libstagefright/include \
+ frameworks/native/include/media/hardware \
frameworks/native/include/media/openmax \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/include \
@@ -61,6 +62,7 @@ LOCAL_SHARED_LIBRARIES := \
libstagefright_foundation \
libstagefright_omx \
libutils \
+ libui
LOCAL_MODULE := libstagefright_soft_h264enc
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
index 4133bdf..1d66120 100644
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
+++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp
@@ -22,11 +22,15 @@
#include "avcenc_int.h"
#include "OMX_Video.h"
+#include <HardwareAPI.h>
+#include <MetadataBufferType.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
+#include <ui/Rect.h>
+#include <ui/GraphicBufferMapper.h>
#include "SoftAVCEncoder.h"
@@ -174,6 +178,7 @@ SoftAVCEncoder::SoftAVCEncoder(
mVideoFrameRate(30),
mVideoBitRate(192000),
mVideoColorFormat(OMX_COLOR_FormatYUV420Planar),
+ mStoreMetaDataInBuffers(false),
mIDRFrameRefreshIntervalInSec(1),
mAVCEncProfile(AVC_BASELINE),
mAVCEncLevel(AVC_LEVEL2),
@@ -451,7 +456,7 @@ OMX_ERRORTYPE SoftAVCEncoder::internalGetParameter(
return OMX_ErrorUndefined;
}
- if (formatParams->nIndex > 1) {
+ if (formatParams->nIndex > 2) {
return OMX_ErrorNoMore;
}
@@ -459,8 +464,10 @@ OMX_ERRORTYPE SoftAVCEncoder::internalGetParameter(
formatParams->eCompressionFormat = OMX_VIDEO_CodingUnused;
if (formatParams->nIndex == 0) {
formatParams->eColorFormat = OMX_COLOR_FormatYUV420Planar;
- } else {
+ } else if (formatParams->nIndex == 1) {
formatParams->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ } else {
+ formatParams->eColorFormat = OMX_COLOR_FormatAndroidOpaque;
}
} else {
formatParams->eCompressionFormat = OMX_VIDEO_CodingAVC;
@@ -532,7 +539,9 @@ OMX_ERRORTYPE SoftAVCEncoder::internalGetParameter(
OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
OMX_INDEXTYPE index, const OMX_PTR params) {
- switch (index) {
+ int32_t indexFull = index;
+
+ switch (indexFull) {
case OMX_IndexParamVideoErrorCorrection:
{
return OMX_ErrorNotImplemented;
@@ -563,7 +572,8 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
if (def->nPortIndex == 0) {
if (def->format.video.eCompressionFormat != OMX_VIDEO_CodingUnused ||
(def->format.video.eColorFormat != OMX_COLOR_FormatYUV420Planar &&
- def->format.video.eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar)) {
+ def->format.video.eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar &&
+ def->format.video.eColorFormat != OMX_COLOR_FormatAndroidOpaque)) {
return OMX_ErrorUndefined;
}
} else {
@@ -613,7 +623,7 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
return OMX_ErrorUndefined;
}
- if (formatParams->nIndex > 1) {
+ if (formatParams->nIndex > 2) {
return OMX_ErrorNoMore;
}
@@ -622,7 +632,9 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
((formatParams->nIndex == 0 &&
formatParams->eColorFormat != OMX_COLOR_FormatYUV420Planar) ||
(formatParams->nIndex == 1 &&
- formatParams->eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar))) {
+ formatParams->eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) ||
+ (formatParams->nIndex == 2 &&
+ formatParams->eColorFormat != OMX_COLOR_FormatAndroidOpaque) )) {
return OMX_ErrorUndefined;
}
mVideoColorFormat = formatParams->eColorFormat;
@@ -669,6 +681,31 @@ OMX_ERRORTYPE SoftAVCEncoder::internalSetParameter(
return OMX_ErrorNone;
}
+ case kStoreMetaDataExtensionIndex:
+ {
+ StoreMetaDataInBuffersParams *storeParams =
+ (StoreMetaDataInBuffersParams*)params;
+ if (storeParams->nPortIndex != 0) {
+ ALOGE("%s: StoreMetadataInBuffersParams.nPortIndex not zero!",
+ __FUNCTION__);
+ return OMX_ErrorUndefined;
+ }
+
+ mStoreMetaDataInBuffers = storeParams->bStoreMetaData;
+ ALOGV("StoreMetaDataInBuffers set to: %s",
+ mStoreMetaDataInBuffers ? " true" : "false");
+
+ if (mStoreMetaDataInBuffers) {
+ mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar;
+ if (mInputFrameData == NULL) {
+ mInputFrameData =
+ (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
+ }
+ }
+
+ return OMX_ErrorNone;
+ }
+
default:
return SimpleSoftOMXComponent::internalSetParameter(index, params);
}
@@ -747,6 +784,8 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
}
}
+ buffer_handle_t srcBuffer; // for MetaDataMode only
+
// Get next input video frame
if (mReadyForNextFrame) {
// Save the input buffer info so that it can be
@@ -767,8 +806,28 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
videoInput.height = ((mVideoHeight + 15) >> 4) << 4;
videoInput.pitch = ((mVideoWidth + 15) >> 4) << 4;
videoInput.coding_timestamp = (inHeader->nTimeStamp + 500) / 1000; // in ms
- const void *inData = inHeader->pBuffer + inHeader->nOffset;
- uint8_t *inputData = (uint8_t *) inData;
+ uint8_t *inputData = NULL;
+ if (mStoreMetaDataInBuffers) {
+ if (inHeader->nFilledLen != 8) {
+ ALOGE("MetaData buffer is wrong size! "
+ "(got %lu bytes, expected 8)", inHeader->nFilledLen);
+ mSignalledError = true;
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+ return;
+ }
+ inputData =
+ extractGrallocData(inHeader->pBuffer + inHeader->nOffset,
+ &srcBuffer);
+ if (inputData == NULL) {
+ ALOGE("Unable to extract gralloc buffer in metadata mode");
+ mSignalledError = true;
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+ return;
+ }
+ // TODO: Verify/convert pixel format enum
+ } else {
+ inputData = (uint8_t *)inHeader->pBuffer + inHeader->nOffset;
+ }
if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
ConvertYUV420SemiPlanarToYUV420Planar(
@@ -793,12 +852,14 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
if (encoderStatus < AVCENC_SUCCESS) {
ALOGE("encoderStatus = %d at line %d", encoderStatus, __LINE__);
mSignalledError = true;
+ releaseGrallocData(srcBuffer);
notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
return;
} else {
ALOGV("encoderStatus = %d at line %d", encoderStatus, __LINE__);
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
+ releaseGrallocData(srcBuffer);
notifyEmptyBufferDone(inHeader);
return;
}
@@ -832,6 +893,7 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
if (encoderStatus < AVCENC_SUCCESS) {
ALOGE("encoderStatus = %d at line %d", encoderStatus, __LINE__);
mSignalledError = true;
+ releaseGrallocData(srcBuffer);
notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
return;
}
@@ -841,6 +903,7 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
+ releaseGrallocData(srcBuffer);
notifyEmptyBufferDone(inHeader);
outQueue.erase(outQueue.begin());
@@ -887,6 +950,47 @@ void SoftAVCEncoder::signalBufferReturned(MediaBuffer *buffer) {
ALOGV("signalBufferReturned: %p", buffer);
}
+OMX_ERRORTYPE SoftAVCEncoder::getExtensionIndex(
+ const char *name, OMX_INDEXTYPE *index) {
+ if (!strcmp(name, "OMX.google.android.index.storeMetaDataInBuffers")) {
+ *(int32_t*)index = kStoreMetaDataExtensionIndex;
+ return OMX_ErrorNone;
+ }
+ return OMX_ErrorUndefined;
+}
+
+uint8_t *SoftAVCEncoder::extractGrallocData(void *data, buffer_handle_t *buffer) {
+ OMX_U32 type = *(OMX_U32*)data;
+ status_t res;
+ if (type != kMetadataBufferTypeGrallocSource) {
+ ALOGE("Data passed in with metadata mode does not have type "
+ "kMetadataBufferTypeGrallocSource (%d), has type %ld instead",
+ kMetadataBufferTypeGrallocSource, type);
+ return NULL;
+ }
+ buffer_handle_t imgBuffer = *(buffer_handle_t*)((uint8_t*)data + 4);
+
+ const Rect rect(mVideoWidth, mVideoHeight);
+ uint8_t *img;
+ res = GraphicBufferMapper::get().lock(imgBuffer,
+ GRALLOC_USAGE_HW_VIDEO_ENCODER,
+ rect, (void**)&img);
+ if (res != OK) {
+ ALOGE("%s: Unable to lock image buffer %p for access", __FUNCTION__,
+ imgBuffer);
+ return NULL;
+ }
+
+ *buffer = imgBuffer;
+ return img;
+}
+
+void SoftAVCEncoder::releaseGrallocData(buffer_handle_t buffer) {
+ if (mStoreMetaDataInBuffers) {
+ GraphicBufferMapper::get().unlock(buffer);
+ }
+}
+
} // namespace android
android::SoftOMXComponent *createSoftOMXComponent(
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
index a2587c6..23d5ff1 100644
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
+++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
@@ -45,6 +45,10 @@ struct SoftAVCEncoder : public MediaBufferObserver,
virtual void onQueueFilled(OMX_U32 portIndex);
+ // Override SoftOMXComponent methods
+
+ virtual OMX_ERRORTYPE getExtensionIndex(
+ const char *name, OMX_INDEXTYPE *index);
// Implement MediaBufferObserver
virtual void signalBufferReturned(MediaBuffer *buffer);
@@ -63,6 +67,10 @@ private:
kNumBuffers = 2,
};
+ enum {
+ kStoreMetaDataExtensionIndex = OMX_IndexVendorStartUnused + 1
+ };
+
// OMX input buffer's timestamp and flags
typedef struct {
int64_t mTimeUs;
@@ -74,6 +82,7 @@ private:
int32_t mVideoFrameRate;
int32_t mVideoBitRate;
int32_t mVideoColorFormat;
+ bool mStoreMetaDataInBuffers;
int32_t mIDRFrameRefreshIntervalInSec;
AVCProfile mAVCEncProfile;
AVCLevel mAVCEncLevel;
@@ -100,6 +109,9 @@ private:
OMX_ERRORTYPE releaseEncoder();
void releaseOutputBuffers();
+ uint8_t* extractGrallocData(void *data, buffer_handle_t *buffer);
+ void releaseGrallocData(buffer_handle_t buffer);
+
DISALLOW_EVIL_CONSTRUCTORS(SoftAVCEncoder);
};
diff --git a/media/libstagefright/codecs/m4v_h263/enc/Android.mk b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
index 484180d..865cc9c 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/Android.mk
+++ b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
@@ -45,6 +45,7 @@ LOCAL_SRC_FILES := \
LOCAL_C_INCLUDES := \
frameworks/av/media/libstagefright/include \
frameworks/native/include/media/openmax \
+ frameworks/native/include/media/hardware \
$(LOCAL_PATH)/src \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/../common/include \
@@ -64,6 +65,7 @@ LOCAL_SHARED_LIBRARIES := \
libstagefright_foundation \
libstagefright_omx \
libutils \
+ libui
LOCAL_MODULE := libstagefright_soft_mpeg4enc
diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
index a5a2332..8bc0275 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
@@ -21,11 +21,15 @@
#include "mp4enc_api.h"
#include "OMX_Video.h"
+#include <HardwareAPI.h>
+#include <MetadataBufferType.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/MediaErrors.h>
#include <media/stagefright/MetaData.h>
#include <media/stagefright/Utils.h>
+#include <ui/Rect.h>
+#include <ui/GraphicBufferMapper.h>
#include "SoftMPEG4Encoder.h"
@@ -82,6 +86,7 @@ SoftMPEG4Encoder::SoftMPEG4Encoder(
mVideoFrameRate(30),
mVideoBitRate(192000),
mVideoColorFormat(OMX_COLOR_FormatYUV420Planar),
+ mStoreMetaDataInBuffers(false),
mIDRFrameRefreshIntervalInSec(1),
mNumInputFrames(-1),
mStarted(false),
@@ -321,7 +326,7 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalGetParameter(
return OMX_ErrorUndefined;
}
- if (formatParams->nIndex > 1) {
+ if (formatParams->nIndex > 2) {
return OMX_ErrorNoMore;
}
@@ -329,8 +334,10 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalGetParameter(
formatParams->eCompressionFormat = OMX_VIDEO_CodingUnused;
if (formatParams->nIndex == 0) {
formatParams->eColorFormat = OMX_COLOR_FormatYUV420Planar;
- } else {
+ } else if (formatParams->nIndex == 1) {
formatParams->eColorFormat = OMX_COLOR_FormatYUV420SemiPlanar;
+ } else {
+ formatParams->eColorFormat = OMX_COLOR_FormatAndroidOpaque;
}
} else {
formatParams->eCompressionFormat =
@@ -420,7 +427,9 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalGetParameter(
OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
OMX_INDEXTYPE index, const OMX_PTR params) {
- switch (index) {
+ int32_t indexFull = index;
+
+ switch (indexFull) {
case OMX_IndexParamVideoErrorCorrection:
{
return OMX_ErrorNotImplemented;
@@ -451,7 +460,8 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
if (def->nPortIndex == 0) {
if (def->format.video.eCompressionFormat != OMX_VIDEO_CodingUnused ||
(def->format.video.eColorFormat != OMX_COLOR_FormatYUV420Planar &&
- def->format.video.eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar)) {
+ def->format.video.eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar &&
+ def->format.video.eColorFormat != OMX_COLOR_FormatAndroidOpaque)) {
return OMX_ErrorUndefined;
}
} else {
@@ -505,7 +515,7 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
return OMX_ErrorUndefined;
}
- if (formatParams->nIndex > 1) {
+ if (formatParams->nIndex > 2) {
return OMX_ErrorNoMore;
}
@@ -514,7 +524,9 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
((formatParams->nIndex == 0 &&
formatParams->eColorFormat != OMX_COLOR_FormatYUV420Planar) ||
(formatParams->nIndex == 1 &&
- formatParams->eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar))) {
+ formatParams->eColorFormat != OMX_COLOR_FormatYUV420SemiPlanar) ||
+ (formatParams->nIndex == 2 &&
+ formatParams->eColorFormat != OMX_COLOR_FormatAndroidOpaque) )) {
return OMX_ErrorUndefined;
}
mVideoColorFormat = formatParams->eColorFormat;
@@ -578,6 +590,31 @@ OMX_ERRORTYPE SoftMPEG4Encoder::internalSetParameter(
return OMX_ErrorNone;
}
+ case kStoreMetaDataExtensionIndex:
+ {
+ StoreMetaDataInBuffersParams *storeParams =
+ (StoreMetaDataInBuffersParams*)params;
+ if (storeParams->nPortIndex != 0) {
+ ALOGE("%s: StoreMetadataInBuffersParams.nPortIndex not zero!",
+ __FUNCTION__);
+ return OMX_ErrorUndefined;
+ }
+
+ mStoreMetaDataInBuffers = storeParams->bStoreMetaData;
+ ALOGV("StoreMetaDataInBuffers set to: %s",
+ mStoreMetaDataInBuffers ? " true" : "false");
+
+ if (mStoreMetaDataInBuffers) {
+ mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar;
+ if (mInputFrameData == NULL) {
+ mInputFrameData =
+ (uint8_t *) malloc((mVideoWidth * mVideoHeight * 3 ) >> 1);
+ }
+ }
+
+ return OMX_ErrorNone;
+ }
+
default:
return SimpleSoftOMXComponent::internalSetParameter(index, params);
}
@@ -640,9 +677,31 @@ void SoftMPEG4Encoder::onQueueFilled(OMX_U32 portIndex) {
mSawInputEOS = true;
}
+ buffer_handle_t srcBuffer; // for MetaDataMode only
if (inHeader->nFilledLen > 0) {
- const void *inData = inHeader->pBuffer + inHeader->nOffset;
- uint8_t *inputData = (uint8_t *) inData;
+ uint8_t *inputData = NULL;
+ if (mStoreMetaDataInBuffers) {
+ if (inHeader->nFilledLen != 8) {
+ ALOGE("MetaData buffer is wrong size! "
+ "(got %lu bytes, expected 8)", inHeader->nFilledLen);
+ mSignalledError = true;
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+ return;
+ }
+ inputData =
+ extractGrallocData(inHeader->pBuffer + inHeader->nOffset,
+ &srcBuffer);
+ if (inputData == NULL) {
+ ALOGE("Unable to extract gralloc buffer in metadata mode");
+ mSignalledError = true;
+ notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+ return;
+ }
+ // TODO: Verify/convert pixel format enum
+ } else {
+ inputData = (uint8_t *)inHeader->pBuffer + inHeader->nOffset;
+ }
+
if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
ConvertYUV420SemiPlanarToYUV420Planar(
inputData, mInputFrameData, mVideoWidth, mVideoHeight);
@@ -683,6 +742,7 @@ void SoftMPEG4Encoder::onQueueFilled(OMX_U32 portIndex) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
+ releaseGrallocData(srcBuffer);
notifyEmptyBufferDone(inHeader);
outQueue.erase(outQueue.begin());
@@ -697,6 +757,47 @@ void SoftMPEG4Encoder::onQueueFilled(OMX_U32 portIndex) {
}
}
+OMX_ERRORTYPE SoftMPEG4Encoder::getExtensionIndex(
+ const char *name, OMX_INDEXTYPE *index) {
+ if (!strcmp(name, "OMX.google.android.index.storeMetaDataInBuffers")) {
+ *(int32_t*)index = kStoreMetaDataExtensionIndex;
+ return OMX_ErrorNone;
+ }
+ return OMX_ErrorUndefined;
+}
+
+uint8_t *SoftMPEG4Encoder::extractGrallocData(void *data, buffer_handle_t *buffer) {
+ OMX_U32 type = *(OMX_U32*)data;
+ status_t res;
+ if (type != kMetadataBufferTypeGrallocSource) {
+ ALOGE("Data passed in with metadata mode does not have type "
+ "kMetadataBufferTypeGrallocSource (%d), has type %ld instead",
+ kMetadataBufferTypeGrallocSource, type);
+ return NULL;
+ }
+ buffer_handle_t imgBuffer = *(buffer_handle_t*)((uint8_t*)data + 4);
+
+ const Rect rect(mVideoWidth, mVideoHeight);
+ uint8_t *img;
+ res = GraphicBufferMapper::get().lock(imgBuffer,
+ GRALLOC_USAGE_HW_VIDEO_ENCODER,
+ rect, (void**)&img);
+ if (res != OK) {
+ ALOGE("%s: Unable to lock image buffer %p for access", __FUNCTION__,
+ imgBuffer);
+ return NULL;
+ }
+
+ *buffer = imgBuffer;
+ return img;
+}
+
+void SoftMPEG4Encoder::releaseGrallocData(buffer_handle_t buffer) {
+ if (mStoreMetaDataInBuffers) {
+ GraphicBufferMapper::get().unlock(buffer);
+ }
+}
+
} // namespace android
android::SoftOMXComponent *createSoftOMXComponent(
diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
index 3e90d54..cc4ea8f 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
@@ -43,6 +43,11 @@ struct SoftMPEG4Encoder : public SimpleSoftOMXComponent {
virtual void onQueueFilled(OMX_U32 portIndex);
+ // Override SoftOMXComponent methods
+
+ virtual OMX_ERRORTYPE getExtensionIndex(
+ const char *name, OMX_INDEXTYPE *index);
+
protected:
virtual ~SoftMPEG4Encoder();
@@ -51,6 +56,10 @@ private:
kNumBuffers = 2,
};
+ enum {
+ kStoreMetaDataExtensionIndex = OMX_IndexVendorStartUnused + 1
+ };
+
// OMX input buffer's timestamp and flags
typedef struct {
int64_t mTimeUs;
@@ -63,6 +72,7 @@ private:
int32_t mVideoFrameRate;
int32_t mVideoBitRate;
int32_t mVideoColorFormat;
+ bool mStoreMetaDataInBuffers;
int32_t mIDRFrameRefreshIntervalInSec;
int64_t mNumInputFrames;
@@ -80,6 +90,9 @@ private:
OMX_ERRORTYPE initEncoder();
OMX_ERRORTYPE releaseEncoder();
+ uint8_t* extractGrallocData(void *data, buffer_handle_t *buffer);
+ void releaseGrallocData(buffer_handle_t buffer);
+
DISALLOW_EVIL_CONSTRUCTORS(SoftMPEG4Encoder);
};
diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
index 8f2a3aa..fb1135c 100644
--- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
@@ -191,10 +191,19 @@ void SoftMP3::onQueueFilled(OMX_U32 portIndex) {
inInfo->mOwnedByUs = false;
notifyEmptyBufferDone(inHeader);
- // pad the end of the stream with 529 samples, since that many samples
- // were trimmed off the beginning when decoding started
- outHeader->nFilledLen = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t);
- memset(outHeader->pBuffer, 0, outHeader->nFilledLen);
+ if (!mIsFirst) {
+ // pad the end of the stream with 529 samples, since that many samples
+ // were trimmed off the beginning when decoding started
+ outHeader->nFilledLen =
+ kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t);
+
+ memset(outHeader->pBuffer, 0, outHeader->nFilledLen);
+ } else {
+ // Since we never discarded frames from the start, we won't have
+ // to add any padding at the end either.
+ outHeader->nFilledLen = 0;
+ }
+
outHeader->nFlags = OMX_BUFFERFLAG_EOS;
outQueue.erase(outQueue.begin());
@@ -260,8 +269,11 @@ void SoftMP3::onQueueFilled(OMX_U32 portIndex) {
// The decoder delay is 529 samples, so trim that many samples off
// the start of the first output buffer. This essentially makes this
// decoder have zero delay, which the rest of the pipeline assumes.
- outHeader->nOffset = kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t);
- outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset;
+ outHeader->nOffset =
+ kPVMP3DecoderDelay * mNumChannels * sizeof(int16_t);
+
+ outHeader->nFilledLen =
+ mConfig->outputFrameSize * sizeof(int16_t) - outHeader->nOffset;
} else {
outHeader->nOffset = 0;
outHeader->nFilledLen = mConfig->outputFrameSize * sizeof(int16_t);
diff --git a/media/libstagefright/codecs/on2/dec/Android.mk b/media/libstagefright/codecs/on2/dec/Android.mk
index 3223871..0082d7c 100644
--- a/media/libstagefright/codecs/on2/dec/Android.mk
+++ b/media/libstagefright/codecs/on2/dec/Android.mk
@@ -5,9 +5,9 @@ LOCAL_SRC_FILES := \
SoftVPX.cpp
LOCAL_C_INCLUDES := \
- $(TOP)/external/libvpx \
- $(TOP)/external/libvpx/vpx_codec \
- $(TOP)/external/libvpx/vpx_ports \
+ $(TOP)/external/libvpx/libvpx \
+ $(TOP)/external/libvpx/libvpx/vpx_codec \
+ $(TOP)/external/libvpx/libvpx/vpx_ports \
frameworks/av/media/libstagefright/include \
frameworks/native/include/media/openmax \
@@ -21,4 +21,3 @@ LOCAL_MODULE := libstagefright_soft_vpxdec
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
-
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 8673bad..2704a37 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -141,13 +141,12 @@ void SoftwareRenderer::render(
const void *data, size_t size, void *platformPrivate) {
ANativeWindowBuffer *buf;
int err;
- if ((err = mNativeWindow->dequeueBuffer(mNativeWindow.get(), &buf)) != 0) {
+ if ((err = native_window_dequeue_buffer_and_wait(mNativeWindow.get(),
+ &buf)) != 0) {
ALOGW("Surface::dequeueBuffer returned error %d", err);
return;
}
- CHECK_EQ(0, mNativeWindow->lockBuffer(mNativeWindow.get(), buf));
-
GraphicBufferMapper &mapper = GraphicBufferMapper::get();
Rect bounds(mCropWidth, mCropHeight);
@@ -231,7 +230,8 @@ void SoftwareRenderer::render(
CHECK_EQ(0, mapper.unlock(buf->handle));
- if ((err = mNativeWindow->queueBuffer(mNativeWindow.get(), buf)) != 0) {
+ if ((err = mNativeWindow->queueBuffer(mNativeWindow.get(), buf,
+ -1)) != 0) {
ALOGW("Surface::queueBuffer returned error %d", err);
}
buf = NULL;
diff --git a/media/libstagefright/foundation/ALooper.cpp b/media/libstagefright/foundation/ALooper.cpp
index a5b316d..22777a2 100644
--- a/media/libstagefright/foundation/ALooper.cpp
+++ b/media/libstagefright/foundation/ALooper.cpp
@@ -63,10 +63,7 @@ private:
// static
int64_t ALooper::GetNowUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_sec * 1000000ll + tv.tv_usec;
+ return systemTime(SYSTEM_TIME_MONOTONIC) / 1000ll;
}
ALooper::ALooper()
diff --git a/media/libstagefright/foundation/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp
index 8b01ac6..dc42f91 100644
--- a/media/libstagefright/foundation/AMessage.cpp
+++ b/media/libstagefright/foundation/AMessage.cpp
@@ -25,6 +25,7 @@
#include "AString.h"
#include <binder/Parcel.h>
+#include <media/stagefright/foundation/hexdump.h>
namespace android {
@@ -399,9 +400,20 @@ AString AMessage::debugString(int32_t indent) const {
"RefBase *%s = %p", item.mName, item.u.refValue);
break;
case kTypeBuffer:
- tmp = StringPrintf(
- "ABuffer *%s = %p", item.mName, item.u.refValue);
+ {
+ sp<ABuffer> buffer = static_cast<ABuffer *>(item.u.refValue);
+
+ if (buffer != NULL && buffer->size() <= 64) {
+ tmp = StringPrintf("Buffer %s = {\n", item.mName);
+ hexdump(buffer->data(), buffer->size(), indent + 4, &tmp);
+ appendIndent(&tmp, indent + 2);
+ tmp.append("}");
+ } else {
+ tmp = StringPrintf(
+ "Buffer *%s = %p", item.mName, buffer.get());
+ }
break;
+ }
case kTypeMessage:
tmp = StringPrintf(
"AMessage %s = %s",
diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp
index 16c1ca5..a44d832 100644
--- a/media/libstagefright/foundation/hexdump.cpp
+++ b/media/libstagefright/foundation/hexdump.cpp
@@ -29,13 +29,25 @@
namespace android {
-void hexdump(const void *_data, size_t size) {
+static void appendIndent(AString *s, int32_t indent) {
+ static const char kWhitespace[] =
+ " "
+ " ";
+
+ CHECK_LT((size_t)indent, sizeof(kWhitespace));
+
+ s->append(kWhitespace, indent);
+}
+
+void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) {
const uint8_t *data = (const uint8_t *)_data;
size_t offset = 0;
while (offset < size) {
AString line;
+ appendIndent(&line, indent);
+
char tmp[32];
sprintf(tmp, "%08lx: ", (unsigned long)offset);
@@ -67,7 +79,12 @@ void hexdump(const void *_data, size_t size) {
}
}
- ALOGI("%s", line.c_str());
+ if (appendTo != NULL) {
+ appendTo->append(line);
+ appendTo->append("\n");
+ } else {
+ ALOGI("%s", line.c_str());
+ }
offset += 16;
}
diff --git a/media/libstagefright/httplive/LiveSession.cpp b/media/libstagefright/httplive/LiveSession.cpp
index 0cddd2e..93d6429 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -167,11 +167,7 @@ void LiveSession::onConnect(const sp<AMessage> &msg) {
headers = NULL;
}
- if (!(mFlags & kFlagIncognito)) {
- ALOGI("onConnect '%s'", url.c_str());
- } else {
- ALOGI("onConnect <URL suppressed>");
- }
+ ALOGI("onConnect <URL suppressed>");
mMasterURL = url;
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 69274ca..22c2f5a 100644
--- a/media/libstagefright/id3/ID3.cpp
+++ b/media/libstagefright/id3/ID3.cpp
@@ -30,7 +30,7 @@ namespace android {
static const size_t kMaxMetadataSize = 3 * 1024 * 1024;
-ID3::ID3(const sp<DataSource> &source)
+ID3::ID3(const sp<DataSource> &source, bool ignoreV1)
: mIsValid(false),
mData(NULL),
mSize(0),
@@ -38,7 +38,7 @@ ID3::ID3(const sp<DataSource> &source)
mVersion(ID3_UNKNOWN) {
mIsValid = parseV2(source);
- if (!mIsValid) {
+ if (!mIsValid && !ignoreV1) {
mIsValid = parseV1(source);
}
}
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 68380a8..1422687 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -166,6 +166,7 @@ private:
sp<MediaSource> mVideoTrack;
sp<MediaSource> mVideoSource;
sp<AwesomeRenderer> mVideoRenderer;
+ bool mVideoRenderingStarted;
bool mVideoRendererIsPreview;
ssize_t mActiveAudioTrackIndex;
diff --git a/media/libstagefright/include/FragmentedMP4Extractor.h b/media/libstagefright/include/FragmentedMP4Extractor.h
new file mode 100644
index 0000000..763cd3a
--- /dev/null
+++ b/media/libstagefright/include/FragmentedMP4Extractor.h
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef FRAGMENTED_MP4_EXTRACTOR_H_
+
+#define FRAGMENTED_MP4_EXTRACTOR_H_
+
+#include "include/FragmentedMP4Parser.h"
+
+#include <media/stagefright/MediaExtractor.h>
+#include <utils/Vector.h>
+#include <utils/String8.h>
+
+namespace android {
+
+struct AMessage;
+class DataSource;
+class SampleTable;
+class String8;
+
+class FragmentedMP4Extractor : public MediaExtractor {
+public:
+ // Extractor assumes ownership of "source".
+ FragmentedMP4Extractor(const sp<DataSource> &source);
+
+ virtual size_t countTracks();
+ virtual sp<MediaSource> getTrack(size_t index);
+ virtual sp<MetaData> getTrackMetaData(size_t index, uint32_t flags);
+ virtual sp<MetaData> getMetaData();
+ virtual uint32_t flags() const;
+
+protected:
+ virtual ~FragmentedMP4Extractor();
+
+private:
+ sp<ALooper> mLooper;
+ sp<FragmentedMP4Parser> mParser;
+ sp<DataSource> mDataSource;
+ status_t mInitCheck;
+ size_t mAudioTrackIndex;
+ size_t mTrackCount;
+
+ sp<MetaData> mFileMetaData;
+
+ Vector<uint32_t> mPath;
+
+ FragmentedMP4Extractor(const FragmentedMP4Extractor &);
+ FragmentedMP4Extractor &operator=(const FragmentedMP4Extractor &);
+};
+
+bool SniffFragmentedMP4(
+ const sp<DataSource> &source, String8 *mimeType, float *confidence,
+ sp<AMessage> *);
+
+} // namespace android
+
+#endif // MPEG4_EXTRACTOR_H_
diff --git a/media/libstagefright/include/FragmentedMP4Parser.h b/media/libstagefright/include/FragmentedMP4Parser.h
new file mode 100644
index 0000000..0edafb9
--- /dev/null
+++ b/media/libstagefright/include/FragmentedMP4Parser.h
@@ -0,0 +1,274 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PARSER_H_
+
+#define PARSER_H_
+
+#include <media/stagefright/foundation/AHandler.h>
+#include <media/stagefright/DataSource.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct ABuffer;
+
+struct FragmentedMP4Parser : public AHandler {
+ struct Source : public RefBase {
+ Source() {}
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) = 0;
+ virtual bool isSeekable() = 0;
+
+ protected:
+ virtual ~Source() {}
+
+ private:
+ DISALLOW_EVIL_CONSTRUCTORS(Source);
+ };
+
+ FragmentedMP4Parser();
+
+ void start(const char *filename);
+ void start(const sp<Source> &source);
+ void start(sp<DataSource> &source);
+
+ sp<AMessage> getFormat(bool audio, bool synchronous = false);
+ status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit, bool synchronous = false);
+ status_t seekTo(bool audio, int64_t timeUs);
+ bool isSeekable() const;
+
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+protected:
+ virtual ~FragmentedMP4Parser();
+
+private:
+ enum {
+ kWhatStart,
+ kWhatProceed,
+ kWhatReadMore,
+ kWhatGetFormat,
+ kWhatDequeueAccessUnit,
+ kWhatSeekTo,
+ };
+
+ struct TrackFragment;
+ struct DynamicTrackFragment;
+ struct StaticTrackFragment;
+
+ struct DispatchEntry {
+ uint32_t mType;
+ uint32_t mParentType;
+ status_t (FragmentedMP4Parser::*mHandler)(uint32_t, size_t, uint64_t);
+ };
+
+ struct Container {
+ uint64_t mOffset;
+ uint64_t mBytesRemaining;
+ uint32_t mType;
+ bool mExtendsToEOF;
+ };
+
+ struct SampleDescription {
+ uint32_t mType;
+ uint16_t mDataRefIndex;
+
+ sp<AMessage> mFormat;
+ };
+
+ struct SampleInfo {
+ off64_t mOffset;
+ size_t mSize;
+ uint32_t mPresentationTime;
+ size_t mSampleDescIndex;
+ uint32_t mFlags;
+ };
+
+ struct MediaDataInfo {
+ sp<ABuffer> mBuffer;
+ off64_t mOffset;
+ };
+
+ struct SidxEntry {
+ size_t mSize;
+ uint32_t mDurationUs;
+ };
+
+ struct TrackInfo {
+ enum Flags {
+ kTrackEnabled = 0x01,
+ kTrackInMovie = 0x02,
+ kTrackInPreview = 0x04,
+ };
+
+ uint32_t mTrackID;
+ uint32_t mFlags;
+ uint32_t mDuration; // This is the duration in terms of movie timescale!
+ uint64_t mSidxDuration; // usec, from sidx box, which can use a different timescale
+
+ uint32_t mMediaTimeScale;
+
+ uint32_t mMediaHandlerType;
+ Vector<SampleDescription> mSampleDescs;
+
+ // from track extends:
+ uint32_t mDefaultSampleDescriptionIndex;
+ uint32_t mDefaultSampleDuration;
+ uint32_t mDefaultSampleSize;
+ uint32_t mDefaultSampleFlags;
+
+ uint32_t mDecodingTime;
+
+ Vector<SidxEntry> mSidx;
+ sp<StaticTrackFragment> mStaticFragment;
+ List<sp<TrackFragment> > mFragments;
+ };
+
+ struct TrackFragmentHeaderInfo {
+ enum Flags {
+ kBaseDataOffsetPresent = 0x01,
+ kSampleDescriptionIndexPresent = 0x02,
+ kDefaultSampleDurationPresent = 0x08,
+ kDefaultSampleSizePresent = 0x10,
+ kDefaultSampleFlagsPresent = 0x20,
+ kDurationIsEmpty = 0x10000,
+ };
+
+ uint32_t mTrackID;
+ uint32_t mFlags;
+ uint64_t mBaseDataOffset;
+ uint32_t mSampleDescriptionIndex;
+ uint32_t mDefaultSampleDuration;
+ uint32_t mDefaultSampleSize;
+ uint32_t mDefaultSampleFlags;
+
+ uint64_t mDataOffset;
+ };
+
+ static const DispatchEntry kDispatchTable[];
+
+ sp<Source> mSource;
+ off_t mBufferPos;
+ bool mSuspended;
+ bool mDoneWithMoov;
+ off_t mFirstMoofOffset; // used as the starting point for offsets calculated from the sidx box
+ sp<ABuffer> mBuffer;
+ Vector<Container> mStack;
+ KeyedVector<uint32_t, TrackInfo> mTracks; // TrackInfo by trackID
+ Vector<MediaDataInfo> mMediaData;
+
+ uint32_t mCurrentTrackID;
+
+ status_t mFinalResult;
+
+ TrackFragmentHeaderInfo mTrackFragmentHeaderInfo;
+
+ status_t onProceed();
+ status_t onDequeueAccessUnit(size_t trackIndex, sp<ABuffer> *accessUnit);
+ status_t onSeekTo(bool wantAudio, int64_t position);
+
+ void enter(off64_t offset, uint32_t type, uint64_t size);
+
+ uint16_t readU16(size_t offset);
+ uint32_t readU32(size_t offset);
+ uint64_t readU64(size_t offset);
+ void skip(off_t distance);
+ status_t need(size_t size);
+ bool fitsContainer(uint64_t size) const;
+
+ status_t parseTrackHeader(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseMediaHeader(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseMediaHandler(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseTrackExtends(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseTrackFragmentHeader(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseTrackFragmentRun(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseVisualSampleEntry(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseAudioSampleEntry(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseSampleSizes(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseCompactSampleSizes(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseSampleToChunk(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseChunkOffsets(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseChunkOffsets64(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseAVCCodecSpecificData(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseESDSCodecSpecificData(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseMediaData(
+ uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseSegmentIndex(
+ uint32_t type, size_t offset, uint64_t size);
+
+ TrackInfo *editTrack(uint32_t trackID, bool createIfNecessary = false);
+
+ ssize_t findTrack(bool wantAudio) const;
+
+ status_t makeAccessUnit(
+ TrackInfo *info,
+ const SampleInfo &sample,
+ const MediaDataInfo &mdatInfo,
+ sp<ABuffer> *accessUnit);
+
+ status_t getSample(
+ TrackInfo *info,
+ sp<TrackFragment> *fragment,
+ SampleInfo *sampleInfo);
+
+ static int CompareSampleLocation(
+ const SampleInfo &sample, const MediaDataInfo &mdatInfo);
+
+ void resumeIfNecessary();
+
+ void copyBuffer(
+ sp<ABuffer> *dst,
+ size_t offset, uint64_t size, size_t extra = 0) const;
+
+ DISALLOW_EVIL_CONSTRUCTORS(FragmentedMP4Parser);
+};
+
+} // namespace android
+
+#endif // PARSER_H_
+
diff --git a/media/libstagefright/include/ID3.h b/media/libstagefright/include/ID3.h
index 8714008..3028f56 100644
--- a/media/libstagefright/include/ID3.h
+++ b/media/libstagefright/include/ID3.h
@@ -35,7 +35,7 @@ struct ID3 {
ID3_V2_4,
};
- ID3(const sp<DataSource> &source);
+ ID3(const sp<DataSource> &source, bool ignoreV1 = false);
~ID3();
bool isValid() const;
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index 2b952e2..8e62946 100644
--- a/media/libstagefright/include/WVMExtractor.h
+++ b/media/libstagefright/include/WVMExtractor.h
@@ -33,8 +33,11 @@ public:
virtual ~WVMLoadableExtractor() {}
virtual int64_t getCachedDurationUs(status_t *finalStatus) = 0;
+ virtual status_t getError() = 0;
+ virtual status_t getEstimatedBandwidthKbps(int32_t *kbps) = 0;
virtual void setAdaptiveStreamingMode(bool adaptive) = 0;
virtual void setCryptoPluginMode(bool cryptoPluginMode) = 0;
+ virtual void setError(status_t err) = 0;
virtual void setUID(uid_t uid) = 0;
};
@@ -55,6 +58,9 @@ public:
// *finalStatus == ERROR_END_OF_STREAM
int64_t getCachedDurationUs(status_t *finalStatus);
+ // Return the current estimated bandwidth
+ status_t getEstimatedBandwidthKbps(int32_t *kbps);
+
// Set to use adaptive streaming mode by the WV component.
// If adaptive == true, adaptive streaming mode will be used.
// Default mode is non-adaptive streaming mode.
@@ -72,6 +78,10 @@ public:
static bool getVendorLibHandle();
+ status_t getError();
+
+ void setError(status_t err);
+
protected:
virtual ~WVMExtractor();
diff --git a/media/libstagefright/include/chromium_http_stub.h b/media/libstagefright/include/chromium_http_stub.h
new file mode 100644
index 0000000..869d4ac
--- /dev/null
+++ b/media/libstagefright/include/chromium_http_stub.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CHROMIUM_HTTP_STUB_H_
+#define CHROMIUM_HTTP_STUB_H_
+
+#include <include/HTTPBase.h>
+#include <media/stagefright/DataSource.h>
+
+namespace android {
+extern "C" {
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags);
+DataSource *createDataUriSource(const char *uri);
+}
+}
+
+#endif
diff --git a/media/libstagefright/matroska/Android.mk b/media/libstagefright/matroska/Android.mk
index 2cccb4f..2d8c1e1 100644
--- a/media/libstagefright/matroska/Android.mk
+++ b/media/libstagefright/matroska/Android.mk
@@ -5,7 +5,7 @@ LOCAL_SRC_FILES:= \
MatroskaExtractor.cpp
LOCAL_C_INCLUDES:= \
- $(TOP)/external/libvpx/mkvparser \
+ $(TOP)/external/libvpx/libwebm \
$(TOP)/frameworks/native/include/media/openmax \
LOCAL_CFLAGS += -Wno-multichar
diff --git a/media/libstagefright/mp4/FragmentedMP4Parser.cpp b/media/libstagefright/mp4/FragmentedMP4Parser.cpp
new file mode 100644
index 0000000..451c837
--- /dev/null
+++ b/media/libstagefright/mp4/FragmentedMP4Parser.cpp
@@ -0,0 +1,1985 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "FragmentedMP4Parser"
+#include <utils/Log.h>
+
+#include "include/ESDS.h"
+#include "include/FragmentedMP4Parser.h"
+#include "TrackFragment.h"
+
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/Utils.h>
+
+
+namespace android {
+
+static const char *Fourcc2String(uint32_t fourcc) {
+ static char buffer[5];
+ buffer[4] = '\0';
+ buffer[0] = fourcc >> 24;
+ buffer[1] = (fourcc >> 16) & 0xff;
+ buffer[2] = (fourcc >> 8) & 0xff;
+ buffer[3] = fourcc & 0xff;
+
+ return buffer;
+}
+
+static const char *IndentString(size_t n) {
+ static const char kSpace[] = " ";
+ return kSpace + sizeof(kSpace) - 2 * n - 1;
+}
+
+// static
+const FragmentedMP4Parser::DispatchEntry FragmentedMP4Parser::kDispatchTable[] = {
+ { FOURCC('m', 'o', 'o', 'v'), 0, NULL },
+ { FOURCC('t', 'r', 'a', 'k'), FOURCC('m', 'o', 'o', 'v'), NULL },
+ { FOURCC('u', 'd', 't', 'a'), FOURCC('t', 'r', 'a', 'k'), NULL },
+ { FOURCC('u', 'd', 't', 'a'), FOURCC('m', 'o', 'o', 'v'), NULL },
+ { FOURCC('m', 'e', 't', 'a'), FOURCC('u', 'd', 't', 'a'), NULL },
+ { FOURCC('i', 'l', 's', 't'), FOURCC('m', 'e', 't', 'a'), NULL },
+
+ { FOURCC('t', 'k', 'h', 'd'), FOURCC('t', 'r', 'a', 'k'),
+ &FragmentedMP4Parser::parseTrackHeader
+ },
+
+ { FOURCC('m', 'v', 'e', 'x'), FOURCC('m', 'o', 'o', 'v'), NULL },
+
+ { FOURCC('t', 'r', 'e', 'x'), FOURCC('m', 'v', 'e', 'x'),
+ &FragmentedMP4Parser::parseTrackExtends
+ },
+
+ { FOURCC('e', 'd', 't', 's'), FOURCC('t', 'r', 'a', 'k'), NULL },
+ { FOURCC('m', 'd', 'i', 'a'), FOURCC('t', 'r', 'a', 'k'), NULL },
+
+ { FOURCC('m', 'd', 'h', 'd'), FOURCC('m', 'd', 'i', 'a'),
+ &FragmentedMP4Parser::parseMediaHeader
+ },
+
+ { FOURCC('h', 'd', 'l', 'r'), FOURCC('m', 'd', 'i', 'a'),
+ &FragmentedMP4Parser::parseMediaHandler
+ },
+
+ { FOURCC('m', 'i', 'n', 'f'), FOURCC('m', 'd', 'i', 'a'), NULL },
+ { FOURCC('d', 'i', 'n', 'f'), FOURCC('m', 'i', 'n', 'f'), NULL },
+ { FOURCC('s', 't', 'b', 'l'), FOURCC('m', 'i', 'n', 'f'), NULL },
+ { FOURCC('s', 't', 's', 'd'), FOURCC('s', 't', 'b', 'l'), NULL },
+
+ { FOURCC('s', 't', 's', 'z'), FOURCC('s', 't', 'b', 'l'),
+ &FragmentedMP4Parser::parseSampleSizes },
+
+ { FOURCC('s', 't', 'z', '2'), FOURCC('s', 't', 'b', 'l'),
+ &FragmentedMP4Parser::parseCompactSampleSizes },
+
+ { FOURCC('s', 't', 's', 'c'), FOURCC('s', 't', 'b', 'l'),
+ &FragmentedMP4Parser::parseSampleToChunk },
+
+ { FOURCC('s', 't', 'c', 'o'), FOURCC('s', 't', 'b', 'l'),
+ &FragmentedMP4Parser::parseChunkOffsets },
+
+ { FOURCC('c', 'o', '6', '4'), FOURCC('s', 't', 'b', 'l'),
+ &FragmentedMP4Parser::parseChunkOffsets64 },
+
+ { FOURCC('a', 'v', 'c', 'C'), FOURCC('a', 'v', 'c', '1'),
+ &FragmentedMP4Parser::parseAVCCodecSpecificData },
+
+ { FOURCC('e', 's', 'd', 's'), FOURCC('m', 'p', '4', 'a'),
+ &FragmentedMP4Parser::parseESDSCodecSpecificData },
+
+ { FOURCC('e', 's', 'd', 's'), FOURCC('m', 'p', '4', 'v'),
+ &FragmentedMP4Parser::parseESDSCodecSpecificData },
+
+ { FOURCC('m', 'd', 'a', 't'), 0, &FragmentedMP4Parser::parseMediaData },
+
+ { FOURCC('m', 'o', 'o', 'f'), 0, NULL },
+ { FOURCC('t', 'r', 'a', 'f'), FOURCC('m', 'o', 'o', 'f'), NULL },
+
+ { FOURCC('t', 'f', 'h', 'd'), FOURCC('t', 'r', 'a', 'f'),
+ &FragmentedMP4Parser::parseTrackFragmentHeader
+ },
+ { FOURCC('t', 'r', 'u', 'n'), FOURCC('t', 'r', 'a', 'f'),
+ &FragmentedMP4Parser::parseTrackFragmentRun
+ },
+
+ { FOURCC('m', 'f', 'r', 'a'), 0, NULL },
+
+ { FOURCC('s', 'i', 'd', 'x'), 0, &FragmentedMP4Parser::parseSegmentIndex },
+};
+
+struct FileSource : public FragmentedMP4Parser::Source {
+ FileSource(const char *filename)
+ : mFile(fopen(filename, "rb")) {
+ CHECK(mFile != NULL);
+ }
+
+ virtual ~FileSource() {
+ fclose(mFile);
+ }
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+ fseek(mFile, offset, SEEK_SET);
+ return fread(data, 1, size, mFile);
+ }
+
+ virtual bool isSeekable() {
+ return true;
+ }
+
+ private:
+ FILE *mFile;
+
+ DISALLOW_EVIL_CONSTRUCTORS(FileSource);
+};
+
+struct ReadTracker : public RefBase {
+ ReadTracker(off64_t size) {
+ allocSize = 1 + size / 8192; // 1 bit per kilobyte
+ bitmap = (char*) calloc(1, allocSize);
+ }
+ virtual ~ReadTracker() {
+ dumpToLog();
+ free(bitmap);
+ }
+ void mark(off64_t offset, size_t size) {
+ int firstbit = offset / 1024;
+ int lastbit = (offset + size - 1) / 1024;
+ for (int i = firstbit; i <= lastbit; i++) {
+ bitmap[i/8] |= (0x80 >> (i & 7));
+ }
+ }
+
+ private:
+ void dumpToLog() {
+ // 96 chars per line, each char represents one kilobyte, 1 kb per bit
+ int numlines = allocSize / 12;
+ char buf[97];
+ char *cur = bitmap;
+ for (int i = 0; i < numlines; i++ && cur) {
+ for (int j = 0; j < 12; j++) {
+ for (int k = 0; k < 8; k++) {
+ buf[(j * 8) + k] = (*cur & (0x80 >> k)) ? 'X' : '.';
+ }
+ cur++;
+ }
+ buf[96] = '\0';
+ ALOGI("%5dk: %s", i * 96, buf);
+ }
+ }
+
+ size_t allocSize;
+ char *bitmap;
+};
+
+struct DataSourceSource : public FragmentedMP4Parser::Source {
+ DataSourceSource(sp<DataSource> &source)
+ : mDataSource(source) {
+ CHECK(mDataSource != NULL);
+#if 0
+ off64_t size;
+ if (source->getSize(&size) == OK) {
+ mReadTracker = new ReadTracker(size);
+ } else {
+ ALOGE("couldn't get data source size");
+ }
+#endif
+ }
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+ if (mReadTracker != NULL) {
+ mReadTracker->mark(offset, size);
+ }
+ return mDataSource->readAt(offset, data, size);
+ }
+
+ virtual bool isSeekable() {
+ return true;
+ }
+
+ private:
+ sp<DataSource> mDataSource;
+ sp<ReadTracker> mReadTracker;
+
+ DISALLOW_EVIL_CONSTRUCTORS(DataSourceSource);
+};
+
+FragmentedMP4Parser::FragmentedMP4Parser()
+ : mBufferPos(0),
+ mSuspended(false),
+ mDoneWithMoov(false),
+ mFirstMoofOffset(0),
+ mFinalResult(OK) {
+}
+
+FragmentedMP4Parser::~FragmentedMP4Parser() {
+}
+
+void FragmentedMP4Parser::start(const char *filename) {
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setObject("source", new FileSource(filename));
+ msg->post();
+ ALOGV("Parser::start(%s)", filename);
+}
+
+void FragmentedMP4Parser::start(const sp<Source> &source) {
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setObject("source", source);
+ msg->post();
+ ALOGV("Parser::start(Source)");
+}
+
+void FragmentedMP4Parser::start(sp<DataSource> &source) {
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setObject("source", new DataSourceSource(source));
+ msg->post();
+ ALOGV("Parser::start(DataSource)");
+}
+
+sp<AMessage> FragmentedMP4Parser::getFormat(bool audio, bool synchronous) {
+
+ while (true) {
+ bool moovDone = mDoneWithMoov;
+ sp<AMessage> msg = new AMessage(kWhatGetFormat, id());
+ msg->setInt32("audio", audio);
+
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+
+ if (err != OK) {
+ ALOGV("getFormat post failed: %d", err);
+ return NULL;
+ }
+
+ if (response->findInt32("err", &err) && err != OK) {
+ if (synchronous && err == -EWOULDBLOCK && !moovDone) {
+ resumeIfNecessary();
+ ALOGV("@getFormat parser not ready yet, retrying");
+ usleep(10000);
+ continue;
+ }
+ ALOGV("getFormat failed: %d", err);
+ return NULL;
+ }
+
+ sp<AMessage> format;
+ CHECK(response->findMessage("format", &format));
+
+ ALOGV("returning format %s", format->debugString().c_str());
+ return format;
+ }
+}
+
+status_t FragmentedMP4Parser::seekTo(bool wantAudio, int64_t timeUs) {
+ sp<AMessage> msg = new AMessage(kWhatSeekTo, id());
+ msg->setInt32("audio", wantAudio);
+ msg->setInt64("position", timeUs);
+
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+ return err;
+}
+
+bool FragmentedMP4Parser::isSeekable() const {
+ while (mFirstMoofOffset == 0 && mFinalResult == OK) {
+ usleep(10000);
+ }
+ bool seekable = mSource->isSeekable();
+ for (size_t i = 0; seekable && i < mTracks.size(); i++) {
+ const TrackInfo *info = &mTracks.valueAt(i);
+ seekable &= !info->mSidx.empty();
+ }
+ return seekable;
+}
+
+status_t FragmentedMP4Parser::onSeekTo(bool wantAudio, int64_t position) {
+ status_t err = -EINVAL;
+ ssize_t trackIndex = findTrack(wantAudio);
+ if (trackIndex < 0) {
+ err = trackIndex;
+ } else {
+ TrackInfo *info = &mTracks.editValueAt(trackIndex);
+
+ int numSidxEntries = info->mSidx.size();
+ int64_t totalTime = 0;
+ off_t totalOffset = mFirstMoofOffset;
+ for (int i = 0; i < numSidxEntries; i++) {
+ const SidxEntry *se = &info->mSidx[i];
+ totalTime += se->mDurationUs;
+ if (totalTime > position) {
+ mBuffer->setRange(0,0);
+ mBufferPos = totalOffset;
+ if (mFinalResult == ERROR_END_OF_STREAM) {
+ mFinalResult = OK;
+ mSuspended = true; // force resume
+ resumeIfNecessary();
+ }
+ info->mFragments.clear();
+ info->mDecodingTime = position * info->mMediaTimeScale / 1000000ll;
+ return OK;
+ }
+ totalOffset += se->mSize;
+ }
+ }
+ ALOGV("seekTo out of range");
+ return err;
+}
+
+status_t FragmentedMP4Parser::dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit,
+ bool synchronous) {
+
+ while (true) {
+ sp<AMessage> msg = new AMessage(kWhatDequeueAccessUnit, id());
+ msg->setInt32("audio", audio);
+
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+
+ if (err != OK) {
+ ALOGV("dequeue fail 1: %d", err);
+ return err;
+ }
+
+ if (response->findInt32("err", &err) && err != OK) {
+ if (synchronous && err == -EWOULDBLOCK) {
+ resumeIfNecessary();
+ ALOGV("Parser not ready yet, retrying");
+ usleep(10000);
+ continue;
+ }
+ ALOGV("dequeue fail 2: %d, %d", err, synchronous);
+ return err;
+ }
+
+ CHECK(response->findBuffer("accessUnit", accessUnit));
+
+ return OK;
+ }
+}
+
+ssize_t FragmentedMP4Parser::findTrack(bool wantAudio) const {
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ const TrackInfo *info = &mTracks.valueAt(i);
+
+ bool isAudio =
+ info->mMediaHandlerType == FOURCC('s', 'o', 'u', 'n');
+
+ bool isVideo =
+ info->mMediaHandlerType == FOURCC('v', 'i', 'd', 'e');
+
+ if ((wantAudio && isAudio) || (!wantAudio && !isAudio)) {
+ if (info->mSampleDescs.empty()) {
+ break;
+ }
+
+ return i;
+ }
+ }
+
+ return -EWOULDBLOCK;
+}
+
+void FragmentedMP4Parser::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatStart:
+ {
+ sp<RefBase> obj;
+ CHECK(msg->findObject("source", &obj));
+
+ mSource = static_cast<Source *>(obj.get());
+
+ mBuffer = new ABuffer(512 * 1024);
+ mBuffer->setRange(0, 0);
+
+ enter(0ll, 0, 0);
+
+ (new AMessage(kWhatProceed, id()))->post();
+ break;
+ }
+
+ case kWhatProceed:
+ {
+ CHECK(!mSuspended);
+
+ status_t err = onProceed();
+
+ if (err == OK) {
+ if (!mSuspended) {
+ msg->post();
+ }
+ } else if (err != -EAGAIN) {
+ ALOGE("onProceed returned error %d", err);
+ }
+
+ break;
+ }
+
+ case kWhatReadMore:
+ {
+ size_t needed;
+ CHECK(msg->findSize("needed", &needed));
+
+ memmove(mBuffer->base(), mBuffer->data(), mBuffer->size());
+ mBufferPos += mBuffer->offset();
+ mBuffer->setRange(0, mBuffer->size());
+
+ size_t maxBytesToRead = mBuffer->capacity() - mBuffer->size();
+
+ if (maxBytesToRead < needed) {
+ ALOGV("resizing buffer.");
+
+ sp<ABuffer> newBuffer =
+ new ABuffer((mBuffer->size() + needed + 1023) & ~1023);
+ memcpy(newBuffer->data(), mBuffer->data(), mBuffer->size());
+ newBuffer->setRange(0, mBuffer->size());
+
+ mBuffer = newBuffer;
+ maxBytesToRead = mBuffer->capacity() - mBuffer->size();
+ }
+
+ CHECK_GE(maxBytesToRead, needed);
+
+ ssize_t n = mSource->readAt(
+ mBufferPos + mBuffer->size(),
+ mBuffer->data() + mBuffer->size(), needed);
+
+ if (n < (ssize_t)needed) {
+ ALOGV("Reached EOF when reading %d @ %d + %d", needed, mBufferPos, mBuffer->size());
+ if (n < 0) {
+ mFinalResult = n;
+ } else if (n == 0) {
+ mFinalResult = ERROR_END_OF_STREAM;
+ } else {
+ mFinalResult = ERROR_IO;
+ }
+ } else {
+ mBuffer->setRange(0, mBuffer->size() + n);
+ (new AMessage(kWhatProceed, id()))->post();
+ }
+
+ break;
+ }
+
+ case kWhatGetFormat:
+ {
+ int32_t wantAudio;
+ CHECK(msg->findInt32("audio", &wantAudio));
+
+ status_t err = -EWOULDBLOCK;
+ sp<AMessage> response = new AMessage;
+
+ ssize_t trackIndex = findTrack(wantAudio);
+
+ if (trackIndex < 0) {
+ err = trackIndex;
+ } else {
+ TrackInfo *info = &mTracks.editValueAt(trackIndex);
+
+ sp<AMessage> format = info->mSampleDescs.itemAt(0).mFormat;
+ if (info->mSidxDuration) {
+ format->setInt64("durationUs", info->mSidxDuration);
+ } else {
+ // this is probably going to be zero. Oh well...
+ format->setInt64("durationUs",
+ 1000000ll * info->mDuration / info->mMediaTimeScale);
+ }
+ response->setMessage(
+ "format", format);
+
+ err = OK;
+ }
+
+ response->setInt32("err", err);
+
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ response->postReply(replyID);
+ break;
+ }
+
+ case kWhatDequeueAccessUnit:
+ {
+ int32_t wantAudio;
+ CHECK(msg->findInt32("audio", &wantAudio));
+
+ status_t err = -EWOULDBLOCK;
+ sp<AMessage> response = new AMessage;
+
+ ssize_t trackIndex = findTrack(wantAudio);
+
+ if (trackIndex < 0) {
+ err = trackIndex;
+ } else {
+ sp<ABuffer> accessUnit;
+ err = onDequeueAccessUnit(trackIndex, &accessUnit);
+
+ if (err == OK) {
+ response->setBuffer("accessUnit", accessUnit);
+ }
+ }
+
+ response->setInt32("err", err);
+
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ response->postReply(replyID);
+ break;
+ }
+
+ case kWhatSeekTo:
+ {
+ ALOGV("kWhatSeekTo");
+ int32_t wantAudio;
+ CHECK(msg->findInt32("audio", &wantAudio));
+ int64_t position;
+ CHECK(msg->findInt64("position", &position));
+
+ status_t err = -EWOULDBLOCK;
+ sp<AMessage> response = new AMessage;
+
+ ssize_t trackIndex = findTrack(wantAudio);
+
+ if (trackIndex < 0) {
+ err = trackIndex;
+ } else {
+ err = onSeekTo(wantAudio, position);
+ }
+ response->setInt32("err", err);
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+ response->postReply(replyID);
+ break;
+ }
+ default:
+ TRESPASS();
+ }
+}
+
+status_t FragmentedMP4Parser::onProceed() {
+ status_t err;
+
+ if ((err = need(8)) != OK) {
+ return err;
+ }
+
+ uint64_t size = readU32(0);
+ uint32_t type = readU32(4);
+
+ size_t offset = 8;
+
+ if (size == 1) {
+ if ((err = need(16)) != OK) {
+ return err;
+ }
+
+ size = readU64(offset);
+ offset += 8;
+ }
+
+ uint8_t userType[16];
+
+ if (type == FOURCC('u', 'u', 'i', 'd')) {
+ if ((err = need(offset + 16)) != OK) {
+ return err;
+ }
+
+ memcpy(userType, mBuffer->data() + offset, 16);
+ offset += 16;
+ }
+
+ CHECK(!mStack.isEmpty());
+ uint32_t ptype = mStack.itemAt(mStack.size() - 1).mType;
+
+ static const size_t kNumDispatchers =
+ sizeof(kDispatchTable) / sizeof(kDispatchTable[0]);
+
+ size_t i;
+ for (i = 0; i < kNumDispatchers; ++i) {
+ if (kDispatchTable[i].mType == type
+ && kDispatchTable[i].mParentType == ptype) {
+ break;
+ }
+ }
+
+ // SampleEntry boxes are container boxes that start with a variable
+ // amount of data depending on the media handler type.
+ // We don't look inside 'hint' type SampleEntry boxes.
+
+ bool isSampleEntryBox =
+ (ptype == FOURCC('s', 't', 's', 'd'))
+ && editTrack(mCurrentTrackID)->mMediaHandlerType
+ != FOURCC('h', 'i', 'n', 't');
+
+ if ((i < kNumDispatchers && kDispatchTable[i].mHandler == 0)
+ || isSampleEntryBox || ptype == FOURCC('i', 'l', 's', 't')) {
+ // This is a container box.
+ if (type == FOURCC('m', 'o', 'o', 'f')) {
+ if (mFirstMoofOffset == 0) {
+ ALOGV("first moof @ %08x", mBufferPos + offset);
+ mFirstMoofOffset = mBufferPos + offset - 8; // point at the size
+ }
+ }
+ if (type == FOURCC('m', 'e', 't', 'a')) {
+ if ((err = need(offset + 4)) < OK) {
+ return err;
+ }
+
+ if (readU32(offset) != 0) {
+ return -EINVAL;
+ }
+
+ offset += 4;
+ } else if (type == FOURCC('s', 't', 's', 'd')) {
+ if ((err = need(offset + 8)) < OK) {
+ return err;
+ }
+
+ if (readU32(offset) != 0) {
+ return -EINVAL;
+ }
+
+ if (readU32(offset + 4) == 0) {
+ // We need at least some entries.
+ return -EINVAL;
+ }
+
+ offset += 8;
+ } else if (isSampleEntryBox) {
+ size_t headerSize;
+
+ switch (editTrack(mCurrentTrackID)->mMediaHandlerType) {
+ case FOURCC('v', 'i', 'd', 'e'):
+ {
+ // 8 bytes SampleEntry + 70 bytes VisualSampleEntry
+ headerSize = 78;
+ break;
+ }
+
+ case FOURCC('s', 'o', 'u', 'n'):
+ {
+ // 8 bytes SampleEntry + 20 bytes AudioSampleEntry
+ headerSize = 28;
+ break;
+ }
+
+ case FOURCC('m', 'e', 't', 'a'):
+ {
+ headerSize = 8; // 8 bytes SampleEntry
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+
+ if (offset + headerSize > size) {
+ return -EINVAL;
+ }
+
+ if ((err = need(offset + headerSize)) != OK) {
+ return err;
+ }
+
+ switch (editTrack(mCurrentTrackID)->mMediaHandlerType) {
+ case FOURCC('v', 'i', 'd', 'e'):
+ {
+ err = parseVisualSampleEntry(
+ type, offset, offset + headerSize);
+ break;
+ }
+
+ case FOURCC('s', 'o', 'u', 'n'):
+ {
+ err = parseAudioSampleEntry(
+ type, offset, offset + headerSize);
+ break;
+ }
+
+ case FOURCC('m', 'e', 't', 'a'):
+ {
+ err = OK;
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+
+ if (err != OK) {
+ return err;
+ }
+
+ offset += headerSize;
+ }
+
+ skip(offset);
+
+ ALOGV("%sentering box of type '%s'",
+ IndentString(mStack.size()), Fourcc2String(type));
+
+ enter(mBufferPos - offset, type, size - offset);
+ } else {
+ if (!fitsContainer(size)) {
+ return -EINVAL;
+ }
+
+ if (i < kNumDispatchers && kDispatchTable[i].mHandler != 0) {
+ // We have a handler for this box type.
+
+ if ((err = need(size)) != OK) {
+ return err;
+ }
+
+ ALOGV("%sparsing box of type '%s'",
+ IndentString(mStack.size()), Fourcc2String(type));
+
+ if ((err = (this->*kDispatchTable[i].mHandler)(
+ type, offset, size)) != OK) {
+ return err;
+ }
+ } else {
+ // Unknown box type
+
+ ALOGV("%sskipping box of type '%s', size %llu",
+ IndentString(mStack.size()),
+ Fourcc2String(type), size);
+
+ }
+
+ skip(size);
+ }
+
+ return OK;
+}
+
+// static
+int FragmentedMP4Parser::CompareSampleLocation(
+ const SampleInfo &sample, const MediaDataInfo &mdatInfo) {
+ if (sample.mOffset + sample.mSize < mdatInfo.mOffset) {
+ return -1;
+ }
+
+ if (sample.mOffset >= mdatInfo.mOffset + mdatInfo.mBuffer->size()) {
+ return 1;
+ }
+
+ // Otherwise make sure the sample is completely contained within this
+ // media data block.
+
+ CHECK_GE(sample.mOffset, mdatInfo.mOffset);
+
+ CHECK_LE(sample.mOffset + sample.mSize,
+ mdatInfo.mOffset + mdatInfo.mBuffer->size());
+
+ return 0;
+}
+
+void FragmentedMP4Parser::resumeIfNecessary() {
+ if (!mSuspended) {
+ return;
+ }
+
+ ALOGV("resuming.");
+
+ mSuspended = false;
+ (new AMessage(kWhatProceed, id()))->post();
+}
+
+status_t FragmentedMP4Parser::getSample(
+ TrackInfo *info, sp<TrackFragment> *fragment, SampleInfo *sampleInfo) {
+ for (;;) {
+ if (info->mFragments.empty()) {
+ if (mFinalResult != OK) {
+ return mFinalResult;
+ }
+
+ resumeIfNecessary();
+ return -EWOULDBLOCK;
+ }
+
+ *fragment = *info->mFragments.begin();
+
+ status_t err = (*fragment)->getSample(sampleInfo);
+
+ if (err == OK) {
+ return OK;
+ } else if (err != ERROR_END_OF_STREAM) {
+ return err;
+ }
+
+ // Really, end of this fragment...
+
+ info->mFragments.erase(info->mFragments.begin());
+ }
+}
+
+status_t FragmentedMP4Parser::onDequeueAccessUnit(
+ size_t trackIndex, sp<ABuffer> *accessUnit) {
+ TrackInfo *info = &mTracks.editValueAt(trackIndex);
+
+ sp<TrackFragment> fragment;
+ SampleInfo sampleInfo;
+ status_t err = getSample(info, &fragment, &sampleInfo);
+
+ if (err == -EWOULDBLOCK) {
+ resumeIfNecessary();
+ return err;
+ } else if (err != OK) {
+ return err;
+ }
+
+ err = -EWOULDBLOCK;
+
+ bool checkDroppable = false;
+
+ for (size_t i = 0; i < mMediaData.size(); ++i) {
+ const MediaDataInfo &mdatInfo = mMediaData.itemAt(i);
+
+ int cmp = CompareSampleLocation(sampleInfo, mdatInfo);
+
+ if (cmp < 0 && !mSource->isSeekable()) {
+ return -EPIPE;
+ } else if (cmp == 0) {
+ if (i > 0) {
+ checkDroppable = true;
+ }
+
+ err = makeAccessUnit(info, sampleInfo, mdatInfo, accessUnit);
+ break;
+ }
+ }
+
+ if (err != OK) {
+ return err;
+ }
+
+ fragment->advance();
+
+ if (!mMediaData.empty() && checkDroppable) {
+ size_t numDroppable = 0;
+ bool done = false;
+
+ // XXX FIXME: if one of the tracks is not advanced (e.g. if you play an audio+video
+ // file with sf2), then mMediaData will not be pruned and keeps growing
+ for (size_t i = 0; !done && i < mMediaData.size(); ++i) {
+ const MediaDataInfo &mdatInfo = mMediaData.itemAt(i);
+
+ for (size_t j = 0; j < mTracks.size(); ++j) {
+ TrackInfo *info = &mTracks.editValueAt(j);
+
+ sp<TrackFragment> fragment;
+ SampleInfo sampleInfo;
+ err = getSample(info, &fragment, &sampleInfo);
+
+ if (err != OK) {
+ done = true;
+ break;
+ }
+
+ int cmp = CompareSampleLocation(sampleInfo, mdatInfo);
+
+ if (cmp <= 0) {
+ done = true;
+ break;
+ }
+ }
+
+ if (!done) {
+ ++numDroppable;
+ }
+ }
+
+ if (numDroppable > 0) {
+ mMediaData.removeItemsAt(0, numDroppable);
+
+ if (mMediaData.size() < 5) {
+ resumeIfNecessary();
+ }
+ }
+ }
+
+ return err;
+}
+
+static size_t parseNALSize(size_t nalLengthSize, const uint8_t *data) {
+ switch (nalLengthSize) {
+ case 1:
+ return *data;
+ case 2:
+ return U16_AT(data);
+ case 3:
+ return ((size_t)data[0] << 16) | U16_AT(&data[1]);
+ case 4:
+ return U32_AT(data);
+ }
+
+ // This cannot happen, mNALLengthSize springs to life by adding 1 to
+ // a 2-bit integer.
+ TRESPASS();
+
+ return 0;
+}
+
+status_t FragmentedMP4Parser::makeAccessUnit(
+ TrackInfo *info,
+ const SampleInfo &sample,
+ const MediaDataInfo &mdatInfo,
+ sp<ABuffer> *accessUnit) {
+ if (sample.mSampleDescIndex < 1
+ || sample.mSampleDescIndex > info->mSampleDescs.size()) {
+ return ERROR_MALFORMED;
+ }
+
+ int64_t presentationTimeUs =
+ 1000000ll * sample.mPresentationTime / info->mMediaTimeScale;
+
+ const SampleDescription &sampleDesc =
+ info->mSampleDescs.itemAt(sample.mSampleDescIndex - 1);
+
+ size_t nalLengthSize;
+ if (!sampleDesc.mFormat->findSize("nal-length-size", &nalLengthSize)) {
+ *accessUnit = new ABuffer(sample.mSize);
+
+ memcpy((*accessUnit)->data(),
+ mdatInfo.mBuffer->data() + (sample.mOffset - mdatInfo.mOffset),
+ sample.mSize);
+
+ (*accessUnit)->meta()->setInt64("timeUs", presentationTimeUs);
+ return OK;
+ }
+
+ const uint8_t *srcPtr =
+ mdatInfo.mBuffer->data() + (sample.mOffset - mdatInfo.mOffset);
+
+ for (int i = 0; i < 2 ; ++i) {
+ size_t srcOffset = 0;
+ size_t dstOffset = 0;
+
+ while (srcOffset < sample.mSize) {
+ if (srcOffset + nalLengthSize > sample.mSize) {
+ return ERROR_MALFORMED;
+ }
+
+ size_t nalSize = parseNALSize(nalLengthSize, &srcPtr[srcOffset]);
+ srcOffset += nalLengthSize;
+
+ if (srcOffset + nalSize > sample.mSize) {
+ return ERROR_MALFORMED;
+ }
+
+ if (i == 1) {
+ memcpy((*accessUnit)->data() + dstOffset,
+ "\x00\x00\x00\x01",
+ 4);
+
+ memcpy((*accessUnit)->data() + dstOffset + 4,
+ srcPtr + srcOffset,
+ nalSize);
+ }
+
+ srcOffset += nalSize;
+ dstOffset += nalSize + 4;
+ }
+
+ if (i == 0) {
+ (*accessUnit) = new ABuffer(dstOffset);
+ (*accessUnit)->meta()->setInt64(
+ "timeUs", presentationTimeUs);
+ }
+ }
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::need(size_t size) {
+ if (!fitsContainer(size)) {
+ return -EINVAL;
+ }
+
+ if (size <= mBuffer->size()) {
+ return OK;
+ }
+
+ sp<AMessage> msg = new AMessage(kWhatReadMore, id());
+ msg->setSize("needed", size - mBuffer->size());
+ msg->post();
+
+ // ALOGV("need(%d) returning -EAGAIN, only have %d", size, mBuffer->size());
+
+ return -EAGAIN;
+}
+
+void FragmentedMP4Parser::enter(off64_t offset, uint32_t type, uint64_t size) {
+ Container container;
+ container.mOffset = offset;
+ container.mType = type;
+ container.mExtendsToEOF = (size == 0);
+ container.mBytesRemaining = size;
+
+ mStack.push(container);
+}
+
+bool FragmentedMP4Parser::fitsContainer(uint64_t size) const {
+ CHECK(!mStack.isEmpty());
+ const Container &container = mStack.itemAt(mStack.size() - 1);
+
+ return container.mExtendsToEOF || size <= container.mBytesRemaining;
+}
+
+uint16_t FragmentedMP4Parser::readU16(size_t offset) {
+ CHECK_LE(offset + 2, mBuffer->size());
+
+ const uint8_t *ptr = mBuffer->data() + offset;
+ return (ptr[0] << 8) | ptr[1];
+}
+
+uint32_t FragmentedMP4Parser::readU32(size_t offset) {
+ CHECK_LE(offset + 4, mBuffer->size());
+
+ const uint8_t *ptr = mBuffer->data() + offset;
+ return (ptr[0] << 24) | (ptr[1] << 16) | (ptr[2] << 8) | ptr[3];
+}
+
+uint64_t FragmentedMP4Parser::readU64(size_t offset) {
+ return (((uint64_t)readU32(offset)) << 32) | readU32(offset + 4);
+}
+
+void FragmentedMP4Parser::skip(off_t distance) {
+ CHECK(!mStack.isEmpty());
+ for (size_t i = mStack.size(); i-- > 0;) {
+ Container *container = &mStack.editItemAt(i);
+ if (!container->mExtendsToEOF) {
+ CHECK_LE(distance, (off_t)container->mBytesRemaining);
+
+ container->mBytesRemaining -= distance;
+
+ if (container->mBytesRemaining == 0) {
+ ALOGV("%sleaving box of type '%s'",
+ IndentString(mStack.size() - 1),
+ Fourcc2String(container->mType));
+
+#if 0
+ if (container->mType == FOURCC('s', 't', 's', 'd')) {
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+ for (size_t i = 0;
+ i < trackInfo->mSampleDescs.size(); ++i) {
+ ALOGI("format #%d: %s",
+ i,
+ trackInfo->mSampleDescs.itemAt(i)
+ .mFormat->debugString().c_str());
+ }
+ }
+#endif
+
+ if (container->mType == FOURCC('s', 't', 'b', 'l')) {
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+
+ trackInfo->mStaticFragment->signalCompletion();
+
+ CHECK(trackInfo->mFragments.empty());
+ trackInfo->mFragments.push_back(trackInfo->mStaticFragment);
+ trackInfo->mStaticFragment.clear();
+ } else if (container->mType == FOURCC('t', 'r', 'a', 'f')) {
+ TrackInfo *trackInfo =
+ editTrack(mTrackFragmentHeaderInfo.mTrackID);
+
+ const sp<TrackFragment> &fragment =
+ *--trackInfo->mFragments.end();
+
+ static_cast<DynamicTrackFragment *>(
+ fragment.get())->signalCompletion();
+ } else if (container->mType == FOURCC('m', 'o', 'o', 'v')) {
+ mDoneWithMoov = true;
+ }
+
+ container = NULL;
+ mStack.removeItemsAt(i);
+ }
+ }
+ }
+
+ if (distance < (off_t)mBuffer->size()) {
+ mBuffer->setRange(mBuffer->offset() + distance, mBuffer->size() - distance);
+ mBufferPos += distance;
+ return;
+ }
+
+ mBuffer->setRange(0, 0);
+ mBufferPos += distance;
+}
+
+status_t FragmentedMP4Parser::parseTrackHeader(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ uint32_t flags = readU32(offset);
+
+ uint32_t version = flags >> 24;
+ flags &= 0xffffff;
+
+ uint32_t trackID;
+ uint64_t duration;
+
+ if (version == 1) {
+ if (offset + 36 > size) {
+ return -EINVAL;
+ }
+
+ trackID = readU32(offset + 20);
+ duration = readU64(offset + 28);
+
+ offset += 36;
+ } else if (version == 0) {
+ if (offset + 24 > size) {
+ return -EINVAL;
+ }
+
+ trackID = readU32(offset + 12);
+ duration = readU32(offset + 20);
+
+ offset += 24;
+ } else {
+ return -EINVAL;
+ }
+
+ TrackInfo *info = editTrack(trackID, true /* createIfNecessary */);
+ info->mFlags = flags;
+ info->mDuration = duration;
+ if (info->mDuration == 0xffffffff) {
+ // ffmpeg sets this to -1, which is incorrect.
+ info->mDuration = 0;
+ }
+
+ info->mStaticFragment = new StaticTrackFragment;
+
+ mCurrentTrackID = trackID;
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseMediaHeader(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ uint32_t versionAndFlags = readU32(offset);
+
+ if (versionAndFlags & 0xffffff) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t version = versionAndFlags >> 24;
+
+ TrackInfo *info = editTrack(mCurrentTrackID);
+
+ if (version == 1) {
+ if (offset + 4 + 32 > size) {
+ return -EINVAL;
+ }
+ info->mMediaTimeScale = U32_AT(mBuffer->data() + offset + 20);
+ } else if (version == 0) {
+ if (offset + 4 + 20 > size) {
+ return -EINVAL;
+ }
+ info->mMediaTimeScale = U32_AT(mBuffer->data() + offset + 12);
+ } else {
+ return ERROR_MALFORMED;
+ }
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseMediaHandler(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 12 > size) {
+ return -EINVAL;
+ }
+
+ if (readU32(offset) != 0) {
+ return -EINVAL;
+ }
+
+ uint32_t handlerType = readU32(offset + 8);
+
+ switch (handlerType) {
+ case FOURCC('v', 'i', 'd', 'e'):
+ case FOURCC('s', 'o', 'u', 'n'):
+ case FOURCC('h', 'i', 'n', 't'):
+ case FOURCC('m', 'e', 't', 'a'):
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ editTrack(mCurrentTrackID)->mMediaHandlerType = handlerType;
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseVisualSampleEntry(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 78 > size) {
+ return -EINVAL;
+ }
+
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+
+ trackInfo->mSampleDescs.push();
+ SampleDescription *sampleDesc =
+ &trackInfo->mSampleDescs.editItemAt(
+ trackInfo->mSampleDescs.size() - 1);
+
+ sampleDesc->mType = type;
+ sampleDesc->mDataRefIndex = readU16(offset + 6);
+
+ sp<AMessage> format = new AMessage;
+
+ switch (type) {
+ case FOURCC('a', 'v', 'c', '1'):
+ format->setString("mime", MEDIA_MIMETYPE_VIDEO_AVC);
+ break;
+ case FOURCC('m', 'p', '4', 'v'):
+ format->setString("mime", MEDIA_MIMETYPE_VIDEO_MPEG4);
+ break;
+ case FOURCC('s', '2', '6', '3'):
+ case FOURCC('h', '2', '6', '3'):
+ case FOURCC('H', '2', '6', '3'):
+ format->setString("mime", MEDIA_MIMETYPE_VIDEO_H263);
+ break;
+ default:
+ format->setString("mime", "application/octet-stream");
+ break;
+ }
+
+ format->setInt32("width", readU16(offset + 8 + 16));
+ format->setInt32("height", readU16(offset + 8 + 18));
+
+ sampleDesc->mFormat = format;
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseAudioSampleEntry(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 28 > size) {
+ return -EINVAL;
+ }
+
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+
+ trackInfo->mSampleDescs.push();
+ SampleDescription *sampleDesc =
+ &trackInfo->mSampleDescs.editItemAt(
+ trackInfo->mSampleDescs.size() - 1);
+
+ sampleDesc->mType = type;
+ sampleDesc->mDataRefIndex = readU16(offset + 6);
+
+ sp<AMessage> format = new AMessage;
+
+ format->setInt32("channel-count", readU16(offset + 8 + 8));
+ format->setInt32("sample-size", readU16(offset + 8 + 10));
+ format->setInt32("sample-rate", readU32(offset + 8 + 16) / 65536.0f);
+
+ switch (type) {
+ case FOURCC('m', 'p', '4', 'a'):
+ format->setString("mime", MEDIA_MIMETYPE_AUDIO_AAC);
+ break;
+
+ case FOURCC('s', 'a', 'm', 'r'):
+ format->setString("mime", MEDIA_MIMETYPE_AUDIO_AMR_NB);
+ format->setInt32("channel-count", 1);
+ format->setInt32("sample-rate", 8000);
+ break;
+
+ case FOURCC('s', 'a', 'w', 'b'):
+ format->setString("mime", MEDIA_MIMETYPE_AUDIO_AMR_WB);
+ format->setInt32("channel-count", 1);
+ format->setInt32("sample-rate", 16000);
+ break;
+ default:
+ format->setString("mime", "application/octet-stream");
+ break;
+ }
+
+ sampleDesc->mFormat = format;
+
+ return OK;
+}
+
+static void addCodecSpecificData(
+ const sp<AMessage> &format, int32_t index,
+ const void *data, size_t size,
+ bool insertStartCode = false) {
+ sp<ABuffer> csd = new ABuffer(insertStartCode ? size + 4 : size);
+
+ memcpy(csd->data() + (insertStartCode ? 4 : 0), data, size);
+
+ if (insertStartCode) {
+ memcpy(csd->data(), "\x00\x00\x00\x01", 4);
+ }
+
+ csd->meta()->setInt32("csd", true);
+ csd->meta()->setInt64("timeUs", 0ll);
+
+ format->setBuffer(StringPrintf("csd-%d", index).c_str(), csd);
+}
+
+status_t FragmentedMP4Parser::parseSampleSizes(
+ uint32_t type, size_t offset, uint64_t size) {
+ return editTrack(mCurrentTrackID)->mStaticFragment->parseSampleSizes(
+ this, type, offset, size);
+}
+
+status_t FragmentedMP4Parser::parseCompactSampleSizes(
+ uint32_t type, size_t offset, uint64_t size) {
+ return editTrack(mCurrentTrackID)->mStaticFragment->parseCompactSampleSizes(
+ this, type, offset, size);
+}
+
+status_t FragmentedMP4Parser::parseSampleToChunk(
+ uint32_t type, size_t offset, uint64_t size) {
+ return editTrack(mCurrentTrackID)->mStaticFragment->parseSampleToChunk(
+ this, type, offset, size);
+}
+
+status_t FragmentedMP4Parser::parseChunkOffsets(
+ uint32_t type, size_t offset, uint64_t size) {
+ return editTrack(mCurrentTrackID)->mStaticFragment->parseChunkOffsets(
+ this, type, offset, size);
+}
+
+status_t FragmentedMP4Parser::parseChunkOffsets64(
+ uint32_t type, size_t offset, uint64_t size) {
+ return editTrack(mCurrentTrackID)->mStaticFragment->parseChunkOffsets64(
+ this, type, offset, size);
+}
+
+status_t FragmentedMP4Parser::parseAVCCodecSpecificData(
+ uint32_t type, size_t offset, uint64_t size) {
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+
+ SampleDescription *sampleDesc =
+ &trackInfo->mSampleDescs.editItemAt(
+ trackInfo->mSampleDescs.size() - 1);
+
+ if (sampleDesc->mType != FOURCC('a', 'v', 'c', '1')) {
+ return -EINVAL;
+ }
+
+ const uint8_t *ptr = mBuffer->data() + offset;
+
+ size -= offset;
+ offset = 0;
+
+ if (size < 7 || ptr[0] != 0x01) {
+ return ERROR_MALFORMED;
+ }
+
+ sampleDesc->mFormat->setSize("nal-length-size", 1 + (ptr[4] & 3));
+
+ size_t numSPS = ptr[5] & 31;
+
+ ptr += 6;
+ size -= 6;
+
+ for (size_t i = 0; i < numSPS; ++i) {
+ if (size < 2) {
+ return ERROR_MALFORMED;
+ }
+
+ size_t length = U16_AT(ptr);
+
+ ptr += 2;
+ size -= 2;
+
+ if (size < length) {
+ return ERROR_MALFORMED;
+ }
+
+ addCodecSpecificData(
+ sampleDesc->mFormat, i, ptr, length,
+ true /* insertStartCode */);
+
+ ptr += length;
+ size -= length;
+ }
+
+ if (size < 1) {
+ return ERROR_MALFORMED;
+ }
+
+ size_t numPPS = *ptr;
+ ++ptr;
+ --size;
+
+ for (size_t i = 0; i < numPPS; ++i) {
+ if (size < 2) {
+ return ERROR_MALFORMED;
+ }
+
+ size_t length = U16_AT(ptr);
+
+ ptr += 2;
+ size -= 2;
+
+ if (size < length) {
+ return ERROR_MALFORMED;
+ }
+
+ addCodecSpecificData(
+ sampleDesc->mFormat, numSPS + i, ptr, length,
+ true /* insertStartCode */);
+
+ ptr += length;
+ size -= length;
+ }
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseESDSCodecSpecificData(
+ uint32_t type, size_t offset, uint64_t size) {
+ TrackInfo *trackInfo = editTrack(mCurrentTrackID);
+
+ SampleDescription *sampleDesc =
+ &trackInfo->mSampleDescs.editItemAt(
+ trackInfo->mSampleDescs.size() - 1);
+
+ if (sampleDesc->mType != FOURCC('m', 'p', '4', 'a')
+ && sampleDesc->mType != FOURCC('m', 'p', '4', 'v')) {
+ return -EINVAL;
+ }
+
+ const uint8_t *ptr = mBuffer->data() + offset;
+
+ size -= offset;
+ offset = 0;
+
+ if (size < 4) {
+ return -EINVAL;
+ }
+
+ if (U32_AT(ptr) != 0) {
+ return -EINVAL;
+ }
+
+ ptr += 4;
+ size -=4;
+
+ ESDS esds(ptr, size);
+
+ uint8_t objectTypeIndication;
+ if (esds.getObjectTypeIndication(&objectTypeIndication) != OK) {
+ return ERROR_MALFORMED;
+ }
+
+ const uint8_t *csd;
+ size_t csd_size;
+ if (esds.getCodecSpecificInfo(
+ (const void **)&csd, &csd_size) != OK) {
+ return ERROR_MALFORMED;
+ }
+
+ addCodecSpecificData(sampleDesc->mFormat, 0, csd, csd_size);
+
+ if (sampleDesc->mType != FOURCC('m', 'p', '4', 'a')) {
+ return OK;
+ }
+
+ if (csd_size == 0) {
+ // There's no further information, i.e. no codec specific data
+ // Let's assume that the information provided in the mpeg4 headers
+ // is accurate and hope for the best.
+
+ return OK;
+ }
+
+ if (csd_size < 2) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t objectType = csd[0] >> 3;
+
+ if (objectType == 31) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ uint32_t freqIndex = (csd[0] & 7) << 1 | (csd[1] >> 7);
+ int32_t sampleRate = 0;
+ int32_t numChannels = 0;
+ if (freqIndex == 15) {
+ if (csd_size < 5) {
+ return ERROR_MALFORMED;
+ }
+
+ sampleRate = (csd[1] & 0x7f) << 17
+ | csd[2] << 9
+ | csd[3] << 1
+ | (csd[4] >> 7);
+
+ numChannels = (csd[4] >> 3) & 15;
+ } else {
+ static uint32_t kSamplingRate[] = {
+ 96000, 88200, 64000, 48000, 44100, 32000, 24000, 22050,
+ 16000, 12000, 11025, 8000, 7350
+ };
+
+ if (freqIndex == 13 || freqIndex == 14) {
+ return ERROR_MALFORMED;
+ }
+
+ sampleRate = kSamplingRate[freqIndex];
+ numChannels = (csd[1] >> 3) & 15;
+ }
+
+ if (numChannels == 0) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ sampleDesc->mFormat->setInt32("sample-rate", sampleRate);
+ sampleDesc->mFormat->setInt32("channel-count", numChannels);
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseMediaData(
+ uint32_t type, size_t offset, uint64_t size) {
+ ALOGV("skipping 'mdat' chunk at offsets 0x%08lx-0x%08llx.",
+ mBufferPos + offset, mBufferPos + size);
+
+ sp<ABuffer> buffer = new ABuffer(size - offset);
+ memcpy(buffer->data(), mBuffer->data() + offset, size - offset);
+
+ mMediaData.push();
+ MediaDataInfo *info = &mMediaData.editItemAt(mMediaData.size() - 1);
+ info->mBuffer = buffer;
+ info->mOffset = mBufferPos + offset;
+
+ if (mMediaData.size() > 10) {
+ ALOGV("suspending for now.");
+ mSuspended = true;
+ }
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseSegmentIndex(
+ uint32_t type, size_t offset, uint64_t size) {
+ ALOGV("sidx box type %d, offset %d, size %d", type, int(offset), int(size));
+// AString sidxstr;
+// hexdump(mBuffer->data() + offset, size, 0 /* indent */, &sidxstr);
+// ALOGV("raw sidx:");
+// ALOGV("%s", sidxstr.c_str());
+ if (offset + 12 > size) {
+ return -EINVAL;
+ }
+
+ uint32_t flags = readU32(offset);
+
+ uint32_t version = flags >> 24;
+ flags &= 0xffffff;
+
+ ALOGV("sidx version %d", version);
+
+ uint32_t referenceId = readU32(offset + 4);
+ uint32_t timeScale = readU32(offset + 8);
+ ALOGV("sidx refid/timescale: %d/%d", referenceId, timeScale);
+
+ uint64_t earliestPresentationTime;
+ uint64_t firstOffset;
+
+ offset += 12;
+
+ if (version == 0) {
+ if (offset + 8 > size) {
+ return -EINVAL;
+ }
+ earliestPresentationTime = readU32(offset);
+ firstOffset = readU32(offset + 4);
+ offset += 8;
+ } else {
+ if (offset + 16 > size) {
+ return -EINVAL;
+ }
+ earliestPresentationTime = readU64(offset);
+ firstOffset = readU64(offset + 8);
+ offset += 16;
+ }
+ ALOGV("sidx pres/off: %Ld/%Ld", earliestPresentationTime, firstOffset);
+
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+ if (readU16(offset) != 0) { // reserved
+ return -EINVAL;
+ }
+ int32_t referenceCount = readU16(offset + 2);
+ offset += 4;
+ ALOGV("refcount: %d", referenceCount);
+
+ if (offset + referenceCount * 12 > size) {
+ return -EINVAL;
+ }
+
+ TrackInfo *info = editTrack(mCurrentTrackID);
+ uint64_t total_duration = 0;
+ for (int i = 0; i < referenceCount; i++) {
+ uint32_t d1 = readU32(offset);
+ uint32_t d2 = readU32(offset + 4);
+ uint32_t d3 = readU32(offset + 8);
+
+ if (d1 & 0x80000000) {
+ ALOGW("sub-sidx boxes not supported yet");
+ }
+ bool sap = d3 & 0x80000000;
+ bool saptype = d3 >> 28;
+ if (!sap || saptype > 2) {
+ ALOGW("not a stream access point, or unsupported type");
+ }
+ total_duration += d2;
+ offset += 12;
+ ALOGV(" item %d, %08x %08x %08x", i, d1, d2, d3);
+ SidxEntry se;
+ se.mSize = d1 & 0x7fffffff;
+ se.mDurationUs = 1000000LL * d2 / timeScale;
+ info->mSidx.add(se);
+ }
+
+ info->mSidxDuration = total_duration * 1000000 / timeScale;
+ ALOGV("duration: %lld", info->mSidxDuration);
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseTrackExtends(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 24 > size) {
+ return -EINVAL;
+ }
+
+ if (readU32(offset) != 0) {
+ return -EINVAL;
+ }
+
+ uint32_t trackID = readU32(offset + 4);
+
+ TrackInfo *info = editTrack(trackID, true /* createIfNecessary */);
+ info->mDefaultSampleDescriptionIndex = readU32(offset + 8);
+ info->mDefaultSampleDuration = readU32(offset + 12);
+ info->mDefaultSampleSize = readU32(offset + 16);
+ info->mDefaultSampleFlags = readU32(offset + 20);
+
+ return OK;
+}
+
+FragmentedMP4Parser::TrackInfo *FragmentedMP4Parser::editTrack(
+ uint32_t trackID, bool createIfNecessary) {
+ ssize_t i = mTracks.indexOfKey(trackID);
+
+ if (i >= 0) {
+ return &mTracks.editValueAt(i);
+ }
+
+ if (!createIfNecessary) {
+ return NULL;
+ }
+
+ TrackInfo info;
+ info.mTrackID = trackID;
+ info.mFlags = 0;
+ info.mDuration = 0xffffffff;
+ info.mSidxDuration = 0;
+ info.mMediaTimeScale = 0;
+ info.mMediaHandlerType = 0;
+ info.mDefaultSampleDescriptionIndex = 0;
+ info.mDefaultSampleDuration = 0;
+ info.mDefaultSampleSize = 0;
+ info.mDefaultSampleFlags = 0;
+
+ info.mDecodingTime = 0;
+
+ mTracks.add(trackID, info);
+ return &mTracks.editValueAt(mTracks.indexOfKey(trackID));
+}
+
+status_t FragmentedMP4Parser::parseTrackFragmentHeader(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 8 > size) {
+ return -EINVAL;
+ }
+
+ uint32_t flags = readU32(offset);
+
+ if (flags & 0xff000000) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mFlags = flags;
+
+ mTrackFragmentHeaderInfo.mTrackID = readU32(offset + 4);
+ offset += 8;
+
+ if (flags & TrackFragmentHeaderInfo::kBaseDataOffsetPresent) {
+ if (offset + 8 > size) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mBaseDataOffset = readU64(offset);
+ offset += 8;
+ }
+
+ if (flags & TrackFragmentHeaderInfo::kSampleDescriptionIndexPresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mSampleDescriptionIndex = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & TrackFragmentHeaderInfo::kDefaultSampleDurationPresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mDefaultSampleDuration = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & TrackFragmentHeaderInfo::kDefaultSampleSizePresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mDefaultSampleSize = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & TrackFragmentHeaderInfo::kDefaultSampleFlagsPresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ mTrackFragmentHeaderInfo.mDefaultSampleFlags = readU32(offset);
+ offset += 4;
+ }
+
+ if (!(flags & TrackFragmentHeaderInfo::kBaseDataOffsetPresent)) {
+ // This should point to the position of the first byte of the
+ // enclosing 'moof' container for the first track and
+ // the end of the data of the preceding fragment for subsequent
+ // tracks.
+
+ CHECK_GE(mStack.size(), 2u);
+
+ mTrackFragmentHeaderInfo.mBaseDataOffset =
+ mStack.itemAt(mStack.size() - 2).mOffset;
+
+ // XXX TODO: This does not do the right thing for the 2nd and
+ // subsequent tracks yet.
+ }
+
+ mTrackFragmentHeaderInfo.mDataOffset =
+ mTrackFragmentHeaderInfo.mBaseDataOffset;
+
+ TrackInfo *trackInfo = editTrack(mTrackFragmentHeaderInfo.mTrackID);
+
+ if (trackInfo->mFragments.empty()
+ || (*trackInfo->mFragments.begin())->complete()) {
+ trackInfo->mFragments.push_back(new DynamicTrackFragment);
+ }
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::parseTrackFragmentRun(
+ uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 8 > size) {
+ return -EINVAL;
+ }
+
+ enum {
+ kDataOffsetPresent = 0x01,
+ kFirstSampleFlagsPresent = 0x04,
+ kSampleDurationPresent = 0x100,
+ kSampleSizePresent = 0x200,
+ kSampleFlagsPresent = 0x400,
+ kSampleCompositionTimeOffsetPresent = 0x800,
+ };
+
+ uint32_t flags = readU32(offset);
+
+ if (flags & 0xff000000) {
+ return -EINVAL;
+ }
+
+ if ((flags & kFirstSampleFlagsPresent) && (flags & kSampleFlagsPresent)) {
+ // These two shall not be used together.
+ return -EINVAL;
+ }
+
+ uint32_t sampleCount = readU32(offset + 4);
+ offset += 8;
+
+ uint64_t dataOffset = mTrackFragmentHeaderInfo.mDataOffset;
+
+ uint32_t firstSampleFlags = 0;
+
+ if (flags & kDataOffsetPresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ int32_t dataOffsetDelta = (int32_t)readU32(offset);
+
+ dataOffset = mTrackFragmentHeaderInfo.mBaseDataOffset + dataOffsetDelta;
+
+ offset += 4;
+ }
+
+ if (flags & kFirstSampleFlagsPresent) {
+ if (offset + 4 > size) {
+ return -EINVAL;
+ }
+
+ firstSampleFlags = readU32(offset);
+ offset += 4;
+ }
+
+ TrackInfo *info = editTrack(mTrackFragmentHeaderInfo.mTrackID);
+
+ if (info == NULL) {
+ return -EINVAL;
+ }
+
+ uint32_t sampleDuration = 0, sampleSize = 0, sampleFlags = 0,
+ sampleCtsOffset = 0;
+
+ size_t bytesPerSample = 0;
+ if (flags & kSampleDurationPresent) {
+ bytesPerSample += 4;
+ } else if (mTrackFragmentHeaderInfo.mFlags
+ & TrackFragmentHeaderInfo::kDefaultSampleDurationPresent) {
+ sampleDuration = mTrackFragmentHeaderInfo.mDefaultSampleDuration;
+ } else {
+ sampleDuration = info->mDefaultSampleDuration;
+ }
+
+ if (flags & kSampleSizePresent) {
+ bytesPerSample += 4;
+ } else if (mTrackFragmentHeaderInfo.mFlags
+ & TrackFragmentHeaderInfo::kDefaultSampleSizePresent) {
+ sampleSize = mTrackFragmentHeaderInfo.mDefaultSampleSize;
+ } else {
+ sampleSize = info->mDefaultSampleSize;
+ }
+
+ if (flags & kSampleFlagsPresent) {
+ bytesPerSample += 4;
+ } else if (mTrackFragmentHeaderInfo.mFlags
+ & TrackFragmentHeaderInfo::kDefaultSampleFlagsPresent) {
+ sampleFlags = mTrackFragmentHeaderInfo.mDefaultSampleFlags;
+ } else {
+ sampleFlags = info->mDefaultSampleFlags;
+ }
+
+ if (flags & kSampleCompositionTimeOffsetPresent) {
+ bytesPerSample += 4;
+ } else {
+ sampleCtsOffset = 0;
+ }
+
+ if (offset + sampleCount * bytesPerSample > size) {
+ return -EINVAL;
+ }
+
+ uint32_t sampleDescIndex =
+ (mTrackFragmentHeaderInfo.mFlags
+ & TrackFragmentHeaderInfo::kSampleDescriptionIndexPresent)
+ ? mTrackFragmentHeaderInfo.mSampleDescriptionIndex
+ : info->mDefaultSampleDescriptionIndex;
+
+ for (uint32_t i = 0; i < sampleCount; ++i) {
+ if (flags & kSampleDurationPresent) {
+ sampleDuration = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & kSampleSizePresent) {
+ sampleSize = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & kSampleFlagsPresent) {
+ sampleFlags = readU32(offset);
+ offset += 4;
+ }
+
+ if (flags & kSampleCompositionTimeOffsetPresent) {
+ sampleCtsOffset = readU32(offset);
+ offset += 4;
+ }
+
+ ALOGV("adding sample at offset 0x%08llx, size %u, duration %u, "
+ "sampleDescIndex=%u, flags 0x%08x",
+ dataOffset, sampleSize, sampleDuration,
+ sampleDescIndex,
+ (flags & kFirstSampleFlagsPresent) && i == 0
+ ? firstSampleFlags : sampleFlags);
+
+ const sp<TrackFragment> &fragment = *--info->mFragments.end();
+
+ uint32_t decodingTime = info->mDecodingTime;
+ info->mDecodingTime += sampleDuration;
+ uint32_t presentationTime = decodingTime + sampleCtsOffset;
+
+ static_cast<DynamicTrackFragment *>(
+ fragment.get())->addSample(
+ dataOffset,
+ sampleSize,
+ presentationTime,
+ sampleDescIndex,
+ ((flags & kFirstSampleFlagsPresent) && i == 0)
+ ? firstSampleFlags : sampleFlags);
+
+ dataOffset += sampleSize;
+ }
+
+ mTrackFragmentHeaderInfo.mDataOffset = dataOffset;
+
+ return OK;
+}
+
+void FragmentedMP4Parser::copyBuffer(
+ sp<ABuffer> *dst, size_t offset, uint64_t size, size_t extra) const {
+ sp<ABuffer> buf = new ABuffer(size + extra);
+ memcpy(buf->data(), mBuffer->data() + offset, size);
+
+ *dst = buf;
+}
+
+} // namespace android
diff --git a/media/libstagefright/mp4/TrackFragment.cpp b/media/libstagefright/mp4/TrackFragment.cpp
new file mode 100644
index 0000000..3699038
--- /dev/null
+++ b/media/libstagefright/mp4/TrackFragment.cpp
@@ -0,0 +1,364 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "TrackFragment"
+#include <utils/Log.h>
+
+#include "TrackFragment.h"
+
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/Utils.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/hexdump.h>
+
+namespace android {
+
+FragmentedMP4Parser::DynamicTrackFragment::DynamicTrackFragment()
+ : mComplete(false),
+ mSampleIndex(0) {
+}
+
+FragmentedMP4Parser::DynamicTrackFragment::~DynamicTrackFragment() {
+}
+
+status_t FragmentedMP4Parser::DynamicTrackFragment::getSample(SampleInfo *info) {
+ if (mSampleIndex >= mSamples.size()) {
+ return mComplete ? ERROR_END_OF_STREAM : -EWOULDBLOCK;
+ }
+
+ *info = mSamples.itemAt(mSampleIndex);
+
+ return OK;
+}
+
+void FragmentedMP4Parser::DynamicTrackFragment::advance() {
+ ++mSampleIndex;
+}
+
+void FragmentedMP4Parser::DynamicTrackFragment::addSample(
+ off64_t dataOffset, size_t sampleSize,
+ uint32_t presentationTime,
+ size_t sampleDescIndex,
+ uint32_t flags) {
+ mSamples.push();
+ SampleInfo *sampleInfo = &mSamples.editItemAt(mSamples.size() - 1);
+
+ sampleInfo->mOffset = dataOffset;
+ sampleInfo->mSize = sampleSize;
+ sampleInfo->mPresentationTime = presentationTime;
+ sampleInfo->mSampleDescIndex = sampleDescIndex;
+ sampleInfo->mFlags = flags;
+}
+
+status_t FragmentedMP4Parser::DynamicTrackFragment::signalCompletion() {
+ mComplete = true;
+
+ return OK;
+}
+
+bool FragmentedMP4Parser::DynamicTrackFragment::complete() const {
+ return mComplete;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+FragmentedMP4Parser::StaticTrackFragment::StaticTrackFragment()
+ : mSampleIndex(0),
+ mSampleCount(0),
+ mChunkIndex(0),
+ mSampleToChunkIndex(-1),
+ mSampleToChunkRemaining(0),
+ mPrevChunkIndex(0xffffffff),
+ mNextSampleOffset(0) {
+}
+
+FragmentedMP4Parser::StaticTrackFragment::~StaticTrackFragment() {
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::getSample(SampleInfo *info) {
+ if (mSampleIndex >= mSampleCount) {
+ return ERROR_END_OF_STREAM;
+ }
+
+ *info = mSampleInfo;
+
+ ALOGV("returning sample %d at [0x%08llx, 0x%08llx)",
+ mSampleIndex,
+ info->mOffset, info->mOffset + info->mSize);
+
+ return OK;
+}
+
+void FragmentedMP4Parser::StaticTrackFragment::updateSampleInfo() {
+ if (mSampleIndex >= mSampleCount) {
+ return;
+ }
+
+ if (mSampleSizes != NULL) {
+ uint32_t defaultSampleSize = U32_AT(mSampleSizes->data() + 4);
+ if (defaultSampleSize > 0) {
+ mSampleInfo.mSize = defaultSampleSize;
+ } else {
+ mSampleInfo.mSize= U32_AT(mSampleSizes->data() + 12 + 4 * mSampleIndex);
+ }
+ } else {
+ CHECK(mCompactSampleSizes != NULL);
+
+ uint32_t fieldSize = U32_AT(mCompactSampleSizes->data() + 4);
+
+ switch (fieldSize) {
+ case 4:
+ {
+ unsigned byte = mCompactSampleSizes->data()[12 + mSampleIndex / 2];
+ mSampleInfo.mSize = (mSampleIndex & 1) ? byte & 0x0f : byte >> 4;
+ break;
+ }
+
+ case 8:
+ {
+ mSampleInfo.mSize = mCompactSampleSizes->data()[12 + mSampleIndex];
+ break;
+ }
+
+ default:
+ {
+ CHECK_EQ(fieldSize, 16);
+ mSampleInfo.mSize =
+ U16_AT(mCompactSampleSizes->data() + 12 + mSampleIndex * 2);
+ break;
+ }
+ }
+ }
+
+ CHECK_GT(mSampleToChunkRemaining, 0);
+
+ // The sample desc index is 1-based... XXX
+ mSampleInfo.mSampleDescIndex =
+ U32_AT(mSampleToChunk->data() + 8 + 12 * mSampleToChunkIndex + 8);
+
+ if (mChunkIndex != mPrevChunkIndex) {
+ mPrevChunkIndex = mChunkIndex;
+
+ if (mChunkOffsets != NULL) {
+ uint32_t entryCount = U32_AT(mChunkOffsets->data() + 4);
+
+ if (mChunkIndex >= entryCount) {
+ mSampleIndex = mSampleCount;
+ return;
+ }
+
+ mNextSampleOffset =
+ U32_AT(mChunkOffsets->data() + 8 + 4 * mChunkIndex);
+ } else {
+ CHECK(mChunkOffsets64 != NULL);
+
+ uint32_t entryCount = U32_AT(mChunkOffsets64->data() + 4);
+
+ if (mChunkIndex >= entryCount) {
+ mSampleIndex = mSampleCount;
+ return;
+ }
+
+ mNextSampleOffset =
+ U64_AT(mChunkOffsets64->data() + 8 + 8 * mChunkIndex);
+ }
+ }
+
+ mSampleInfo.mOffset = mNextSampleOffset;
+
+ mSampleInfo.mPresentationTime = 0;
+ mSampleInfo.mFlags = 0;
+}
+
+void FragmentedMP4Parser::StaticTrackFragment::advance() {
+ mNextSampleOffset += mSampleInfo.mSize;
+
+ ++mSampleIndex;
+ if (--mSampleToChunkRemaining == 0) {
+ ++mChunkIndex;
+
+ uint32_t entryCount = U32_AT(mSampleToChunk->data() + 4);
+
+ // If this is the last entry in the sample to chunk table, we will
+ // stay on this entry.
+ if ((uint32_t)(mSampleToChunkIndex + 1) < entryCount) {
+ uint32_t nextChunkIndex =
+ U32_AT(mSampleToChunk->data() + 8 + 12 * (mSampleToChunkIndex + 1));
+
+ CHECK_GE(nextChunkIndex, 1u);
+ --nextChunkIndex;
+
+ if (mChunkIndex >= nextChunkIndex) {
+ CHECK_EQ(mChunkIndex, nextChunkIndex);
+ ++mSampleToChunkIndex;
+ }
+ }
+
+ mSampleToChunkRemaining =
+ U32_AT(mSampleToChunk->data() + 8 + 12 * mSampleToChunkIndex + 4);
+ }
+
+ updateSampleInfo();
+}
+
+static void setU32At(uint8_t *ptr, uint32_t x) {
+ ptr[0] = x >> 24;
+ ptr[1] = (x >> 16) & 0xff;
+ ptr[2] = (x >> 8) & 0xff;
+ ptr[3] = x & 0xff;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::signalCompletion() {
+ mSampleToChunkIndex = 0;
+
+ mSampleToChunkRemaining =
+ (mSampleToChunk == NULL)
+ ? 0
+ : U32_AT(mSampleToChunk->data() + 8 + 12 * mSampleToChunkIndex + 4);
+
+ updateSampleInfo();
+
+ return OK;
+}
+
+bool FragmentedMP4Parser::StaticTrackFragment::complete() const {
+ return true;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::parseSampleSizes(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 12 > size) {
+ return ERROR_MALFORMED;
+ }
+
+ if (parser->readU32(offset) != 0) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t sampleSize = parser->readU32(offset + 4);
+ uint32_t sampleCount = parser->readU32(offset + 8);
+
+ if (sampleSize == 0 && offset + 12 + sampleCount * 4 != size) {
+ return ERROR_MALFORMED;
+ }
+
+ parser->copyBuffer(&mSampleSizes, offset, size);
+
+ mSampleCount = sampleCount;
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::parseCompactSampleSizes(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 12 > size) {
+ return ERROR_MALFORMED;
+ }
+
+ if (parser->readU32(offset) != 0) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t fieldSize = parser->readU32(offset + 4);
+
+ if (fieldSize != 4 && fieldSize != 8 && fieldSize != 16) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t sampleCount = parser->readU32(offset + 8);
+
+ if (offset + 12 + (sampleCount * fieldSize + 4) / 8 != size) {
+ return ERROR_MALFORMED;
+ }
+
+ parser->copyBuffer(&mCompactSampleSizes, offset, size);
+
+ mSampleCount = sampleCount;
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::parseSampleToChunk(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 8 > size) {
+ return ERROR_MALFORMED;
+ }
+
+ if (parser->readU32(offset) != 0) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t entryCount = parser->readU32(offset + 4);
+
+ if (entryCount == 0) {
+ return OK;
+ }
+
+ if (offset + 8 + entryCount * 12 != size) {
+ return ERROR_MALFORMED;
+ }
+
+ parser->copyBuffer(&mSampleToChunk, offset, size);
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::parseChunkOffsets(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 8 > size) {
+ return ERROR_MALFORMED;
+ }
+
+ if (parser->readU32(offset) != 0) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t entryCount = parser->readU32(offset + 4);
+
+ if (offset + 8 + entryCount * 4 != size) {
+ return ERROR_MALFORMED;
+ }
+
+ parser->copyBuffer(&mChunkOffsets, offset, size);
+
+ return OK;
+}
+
+status_t FragmentedMP4Parser::StaticTrackFragment::parseChunkOffsets64(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size) {
+ if (offset + 8 > size) {
+ return ERROR_MALFORMED;
+ }
+
+ if (parser->readU32(offset) != 0) {
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t entryCount = parser->readU32(offset + 4);
+
+ if (offset + 8 + entryCount * 8 != size) {
+ return ERROR_MALFORMED;
+ }
+
+ parser->copyBuffer(&mChunkOffsets64, offset, size);
+
+ return OK;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/mp4/TrackFragment.h b/media/libstagefright/mp4/TrackFragment.h
new file mode 100644
index 0000000..e1ad46e
--- /dev/null
+++ b/media/libstagefright/mp4/TrackFragment.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TRACK_FRAGMENT_H_
+
+#define TRACK_FRAGMENT_H_
+
+#include "include/FragmentedMP4Parser.h"
+
+namespace android {
+
+struct FragmentedMP4Parser::TrackFragment : public RefBase {
+ TrackFragment() {}
+
+ virtual status_t getSample(SampleInfo *info) = 0;
+ virtual void advance() = 0;
+
+ virtual status_t signalCompletion() = 0;
+ virtual bool complete() const = 0;
+
+protected:
+ virtual ~TrackFragment() {}
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(TrackFragment);
+};
+
+struct FragmentedMP4Parser::DynamicTrackFragment : public FragmentedMP4Parser::TrackFragment {
+ DynamicTrackFragment();
+
+ virtual status_t getSample(SampleInfo *info);
+ virtual void advance();
+
+ void addSample(
+ off64_t dataOffset, size_t sampleSize,
+ uint32_t presentationTime,
+ size_t sampleDescIndex,
+ uint32_t flags);
+
+ // No more samples will be added to this fragment.
+ virtual status_t signalCompletion();
+
+ virtual bool complete() const;
+
+protected:
+ virtual ~DynamicTrackFragment();
+
+private:
+ bool mComplete;
+ size_t mSampleIndex;
+ Vector<SampleInfo> mSamples;
+
+ DISALLOW_EVIL_CONSTRUCTORS(DynamicTrackFragment);
+};
+
+struct FragmentedMP4Parser::StaticTrackFragment : public FragmentedMP4Parser::TrackFragment {
+ StaticTrackFragment();
+
+ virtual status_t getSample(SampleInfo *info);
+ virtual void advance();
+
+ virtual status_t signalCompletion();
+ virtual bool complete() const;
+
+ status_t parseSampleSizes(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseCompactSampleSizes(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseSampleToChunk(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseChunkOffsets(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+ status_t parseChunkOffsets64(
+ FragmentedMP4Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+protected:
+ virtual ~StaticTrackFragment();
+
+private:
+ size_t mSampleIndex;
+ size_t mSampleCount;
+ uint32_t mChunkIndex;
+
+ SampleInfo mSampleInfo;
+
+ sp<ABuffer> mSampleSizes;
+ sp<ABuffer> mCompactSampleSizes;
+
+ sp<ABuffer> mSampleToChunk;
+ ssize_t mSampleToChunkIndex;
+ size_t mSampleToChunkRemaining;
+
+ sp<ABuffer> mChunkOffsets;
+ sp<ABuffer> mChunkOffsets64;
+ uint32_t mPrevChunkIndex;
+ uint64_t mNextSampleOffset;
+
+ void updateSampleInfo();
+
+ DISALLOW_EVIL_CONSTRUCTORS(StaticTrackFragment);
+};
+
+} // namespace android
+
+#endif // TRACK_FRAGMENT_H_
diff --git a/media/libstagefright/mpeg2ts/ATSParser.cpp b/media/libstagefright/mpeg2ts/ATSParser.cpp
index 5f3e300..9faa6bc 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.cpp
+++ b/media/libstagefright/mpeg2ts/ATSParser.cpp
@@ -51,7 +51,8 @@ struct ATSParser::Program : public RefBase {
unsigned pid, ABitReader *br, status_t *err);
bool parsePID(
- unsigned pid, unsigned payload_unit_start_indicator,
+ unsigned pid, unsigned continuity_counter,
+ unsigned payload_unit_start_indicator,
ABitReader *br, status_t *err);
void signalDiscontinuity(
@@ -77,6 +78,10 @@ struct ATSParser::Program : public RefBase {
return mProgramMapPID;
}
+ uint32_t parserFlags() const {
+ return mParser->mFlags;
+ }
+
private:
ATSParser *mParser;
unsigned mProgramNumber;
@@ -91,13 +96,17 @@ private:
};
struct ATSParser::Stream : public RefBase {
- Stream(Program *program, unsigned elementaryPID, unsigned streamType);
+ Stream(Program *program,
+ unsigned elementaryPID,
+ unsigned streamType,
+ unsigned PCR_PID);
unsigned type() const { return mStreamType; }
unsigned pid() const { return mElementaryPID; }
void setPID(unsigned pid) { mElementaryPID = pid; }
status_t parse(
+ unsigned continuity_counter,
unsigned payload_unit_start_indicator,
ABitReader *br);
@@ -115,11 +124,15 @@ private:
Program *mProgram;
unsigned mElementaryPID;
unsigned mStreamType;
+ unsigned mPCR_PID;
+ int32_t mExpectedContinuityCounter;
sp<ABuffer> mBuffer;
sp<AnotherPacketSource> mSource;
bool mPayloadStarted;
+ uint64_t mPrevPTS;
+
ElementaryStreamQueue *mQueue;
status_t flush();
@@ -184,7 +197,8 @@ bool ATSParser::Program::parsePSISection(
}
bool ATSParser::Program::parsePID(
- unsigned pid, unsigned payload_unit_start_indicator,
+ unsigned pid, unsigned continuity_counter,
+ unsigned payload_unit_start_indicator,
ABitReader *br, status_t *err) {
*err = OK;
@@ -194,7 +208,7 @@ bool ATSParser::Program::parsePID(
}
*err = mStreams.editValueAt(index)->parse(
- payload_unit_start_indicator, br);
+ continuity_counter, payload_unit_start_indicator, br);
return true;
}
@@ -241,7 +255,10 @@ status_t ATSParser::Program::parseProgramMap(ABitReader *br) {
MY_LOGV(" section_number = %u", br->getBits(8));
MY_LOGV(" last_section_number = %u", br->getBits(8));
MY_LOGV(" reserved = %u", br->getBits(3));
- MY_LOGV(" PCR_PID = 0x%04x", br->getBits(13));
+
+ unsigned PCR_PID = br->getBits(13);
+ ALOGV(" PCR_PID = 0x%04x", PCR_PID);
+
MY_LOGV(" reserved = %u", br->getBits(4));
unsigned program_info_length = br->getBits(12);
@@ -382,7 +399,9 @@ status_t ATSParser::Program::parseProgramMap(ABitReader *br) {
ssize_t index = mStreams.indexOfKey(info.mPID);
if (index < 0) {
- sp<Stream> stream = new Stream(this, info.mPID, info.mType);
+ sp<Stream> stream = new Stream(
+ this, info.mPID, info.mType, PCR_PID);
+
mStreams.add(info.mPID, stream);
}
}
@@ -419,21 +438,36 @@ int64_t ATSParser::Program::convertPTSToTimestamp(uint64_t PTS) {
}
}
- return (PTS * 100) / 9;
+ int64_t timeUs = (PTS * 100) / 9;
+
+ if (mParser->mAbsoluteTimeAnchorUs >= 0ll) {
+ timeUs += mParser->mAbsoluteTimeAnchorUs;
+ }
+
+ return timeUs;
}
////////////////////////////////////////////////////////////////////////////////
ATSParser::Stream::Stream(
- Program *program, unsigned elementaryPID, unsigned streamType)
+ Program *program,
+ unsigned elementaryPID,
+ unsigned streamType,
+ unsigned PCR_PID)
: mProgram(program),
mElementaryPID(elementaryPID),
mStreamType(streamType),
+ mPCR_PID(PCR_PID),
+ mExpectedContinuityCounter(-1),
mPayloadStarted(false),
+ mPrevPTS(0),
mQueue(NULL) {
switch (mStreamType) {
case STREAMTYPE_H264:
- mQueue = new ElementaryStreamQueue(ElementaryStreamQueue::H264);
+ mQueue = new ElementaryStreamQueue(
+ ElementaryStreamQueue::H264,
+ (mProgram->parserFlags() & ALIGNED_VIDEO_DATA)
+ ? ElementaryStreamQueue::kFlag_AlignedData : 0);
break;
case STREAMTYPE_MPEG2_AUDIO_ADTS:
mQueue = new ElementaryStreamQueue(ElementaryStreamQueue::AAC);
@@ -455,6 +489,11 @@ ATSParser::Stream::Stream(
ElementaryStreamQueue::MPEG4_VIDEO);
break;
+ case STREAMTYPE_PCM_AUDIO:
+ mQueue = new ElementaryStreamQueue(
+ ElementaryStreamQueue::PCM_AUDIO);
+ break;
+
default:
break;
}
@@ -473,11 +512,25 @@ ATSParser::Stream::~Stream() {
}
status_t ATSParser::Stream::parse(
+ unsigned continuity_counter,
unsigned payload_unit_start_indicator, ABitReader *br) {
if (mQueue == NULL) {
return OK;
}
+ if (mExpectedContinuityCounter >= 0
+ && (unsigned)mExpectedContinuityCounter != continuity_counter) {
+ ALOGI("discontinuity on stream pid 0x%04x", mElementaryPID);
+
+ mPayloadStarted = false;
+ mBuffer->setRange(0, 0);
+ mExpectedContinuityCounter = -1;
+
+ return OK;
+ }
+
+ mExpectedContinuityCounter = (continuity_counter + 1) & 0x0f;
+
if (payload_unit_start_indicator) {
if (mPayloadStarted) {
// Otherwise we run the danger of receiving the trailing bytes
@@ -538,6 +591,7 @@ bool ATSParser::Stream::isAudio() const {
case STREAMTYPE_MPEG1_AUDIO:
case STREAMTYPE_MPEG2_AUDIO:
case STREAMTYPE_MPEG2_AUDIO_ADTS:
+ case STREAMTYPE_PCM_AUDIO:
return true;
default:
@@ -547,6 +601,8 @@ bool ATSParser::Stream::isAudio() const {
void ATSParser::Stream::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ mExpectedContinuityCounter = -1;
+
if (mQueue == NULL) {
return;
}
@@ -664,8 +720,7 @@ status_t ATSParser::Stream::parsePES(ABitReader *br) {
PTS |= br->getBits(15);
CHECK_EQ(br->getBits(1), 1u);
- ALOGV("PTS = %llu", PTS);
- // ALOGI("PTS = %.2f secs", PTS / 90000.0f);
+ ALOGV("PTS = 0x%016llx (%.2f)", PTS, PTS / 90000.0);
optional_bytes_remaining -= 5;
@@ -781,6 +836,14 @@ status_t ATSParser::Stream::flush() {
void ATSParser::Stream::onPayloadData(
unsigned PTS_DTS_flags, uint64_t PTS, uint64_t DTS,
const uint8_t *data, size_t size) {
+#if 0
+ ALOGI("payload streamType 0x%02x, PTS = 0x%016llx, dPTS = %lld",
+ mStreamType,
+ PTS,
+ (int64_t)PTS - mPrevPTS);
+ mPrevPTS = PTS;
+#endif
+
ALOGV("onPayloadData mStreamType=0x%02x", mStreamType);
int64_t timeUs = 0ll; // no presentation timestamp available.
@@ -847,7 +910,10 @@ sp<MediaSource> ATSParser::Stream::getSource(SourceType type) {
////////////////////////////////////////////////////////////////////////////////
ATSParser::ATSParser(uint32_t flags)
- : mFlags(flags) {
+ : mFlags(flags),
+ mAbsoluteTimeAnchorUs(-1ll),
+ mNumTSPacketsParsed(0),
+ mNumPCRs(0) {
mPSISections.add(0 /* PID */, new PSISection);
}
@@ -863,6 +929,15 @@ status_t ATSParser::feedTSPacket(const void *data, size_t size) {
void ATSParser::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ if (type == DISCONTINUITY_ABSOLUTE_TIME) {
+ int64_t timeUs;
+ CHECK(extra->findInt64("timeUs", &timeUs));
+
+ CHECK(mPrograms.empty());
+ mAbsoluteTimeAnchorUs = timeUs;
+ return;
+ }
+
for (size_t i = 0; i < mPrograms.size(); ++i) {
mPrograms.editItemAt(i)->signalDiscontinuity(type, extra);
}
@@ -942,6 +1017,7 @@ void ATSParser::parseProgramAssociationTable(ABitReader *br) {
status_t ATSParser::parsePID(
ABitReader *br, unsigned PID,
+ unsigned continuity_counter,
unsigned payload_unit_start_indicator) {
ssize_t sectionIndex = mPSISections.indexOfKey(PID);
@@ -1002,7 +1078,8 @@ status_t ATSParser::parsePID(
for (size_t i = 0; i < mPrograms.size(); ++i) {
status_t err;
if (mPrograms.editItemAt(i)->parsePID(
- PID, payload_unit_start_indicator, br, &err)) {
+ PID, continuity_counter, payload_unit_start_indicator,
+ br, &err)) {
if (err != OK) {
return err;
}
@@ -1019,10 +1096,55 @@ status_t ATSParser::parsePID(
return OK;
}
-void ATSParser::parseAdaptationField(ABitReader *br) {
+void ATSParser::parseAdaptationField(ABitReader *br, unsigned PID) {
unsigned adaptation_field_length = br->getBits(8);
+
if (adaptation_field_length > 0) {
- br->skipBits(adaptation_field_length * 8); // XXX
+ unsigned discontinuity_indicator = br->getBits(1);
+
+ if (discontinuity_indicator) {
+ ALOGV("PID 0x%04x: discontinuity_indicator = 1 (!!!)", PID);
+ }
+
+ br->skipBits(2);
+ unsigned PCR_flag = br->getBits(1);
+
+ size_t numBitsRead = 4;
+
+ if (PCR_flag) {
+ br->skipBits(4);
+ uint64_t PCR_base = br->getBits(32);
+ PCR_base = (PCR_base << 1) | br->getBits(1);
+
+ br->skipBits(6);
+ unsigned PCR_ext = br->getBits(9);
+
+ // The number of bytes from the start of the current
+ // MPEG2 transport stream packet up and including
+ // the final byte of this PCR_ext field.
+ size_t byteOffsetFromStartOfTSPacket =
+ (188 - br->numBitsLeft() / 8);
+
+ uint64_t PCR = PCR_base * 300 + PCR_ext;
+
+ ALOGV("PID 0x%04x: PCR = 0x%016llx (%.2f)",
+ PID, PCR, PCR / 27E6);
+
+ // The number of bytes received by this parser up to and
+ // including the final byte of this PCR_ext field.
+ size_t byteOffsetFromStart =
+ mNumTSPacketsParsed * 188 + byteOffsetFromStartOfTSPacket;
+
+ for (size_t i = 0; i < mPrograms.size(); ++i) {
+ updatePCR(PID, PCR, byteOffsetFromStart);
+ }
+
+ numBitsRead += 52;
+ }
+
+ CHECK_GE(adaptation_field_length * 8, numBitsRead);
+
+ br->skipBits(adaptation_field_length * 8 - numBitsRead);
}
}
@@ -1048,19 +1170,24 @@ status_t ATSParser::parseTS(ABitReader *br) {
ALOGV("adaptation_field_control = %u", adaptation_field_control);
unsigned continuity_counter = br->getBits(4);
- ALOGV("continuity_counter = %u", continuity_counter);
+ ALOGV("PID = 0x%04x, continuity_counter = %u", PID, continuity_counter);
// ALOGI("PID = 0x%04x, continuity_counter = %u", PID, continuity_counter);
if (adaptation_field_control == 2 || adaptation_field_control == 3) {
- parseAdaptationField(br);
+ parseAdaptationField(br, PID);
}
+ status_t err = OK;
+
if (adaptation_field_control == 1 || adaptation_field_control == 3) {
- return parsePID(br, PID, payload_unit_start_indicator);
+ err = parsePID(
+ br, PID, continuity_counter, payload_unit_start_indicator);
}
- return OK;
+ ++mNumTSPacketsParsed;
+
+ return err;
}
sp<MediaSource> ATSParser::getSource(SourceType type) {
@@ -1091,6 +1218,31 @@ bool ATSParser::PTSTimeDeltaEstablished() {
return mPrograms.editItemAt(0)->PTSTimeDeltaEstablished();
}
+void ATSParser::updatePCR(
+ unsigned PID, uint64_t PCR, size_t byteOffsetFromStart) {
+ ALOGV("PCR 0x%016llx @ %d", PCR, byteOffsetFromStart);
+
+ if (mNumPCRs == 2) {
+ mPCR[0] = mPCR[1];
+ mPCRBytes[0] = mPCRBytes[1];
+ mSystemTimeUs[0] = mSystemTimeUs[1];
+ mNumPCRs = 1;
+ }
+
+ mPCR[mNumPCRs] = PCR;
+ mPCRBytes[mNumPCRs] = byteOffsetFromStart;
+ mSystemTimeUs[mNumPCRs] = ALooper::GetNowUs();
+
+ ++mNumPCRs;
+
+ if (mNumPCRs == 2) {
+ double transportRate =
+ (mPCRBytes[1] - mPCRBytes[0]) * 27E6 / (mPCR[1] - mPCR[0]);
+
+ ALOGV("transportRate = %.2f bytes/sec", transportRate);
+ }
+}
+
////////////////////////////////////////////////////////////////////////////////
ATSParser::PSISection::PSISection() {
diff --git a/media/libstagefright/mpeg2ts/ATSParser.h b/media/libstagefright/mpeg2ts/ATSParser.h
index 9ef2939..46edc45 100644
--- a/media/libstagefright/mpeg2ts/ATSParser.h
+++ b/media/libstagefright/mpeg2ts/ATSParser.h
@@ -38,6 +38,7 @@ struct ATSParser : public RefBase {
DISCONTINUITY_TIME = 1,
DISCONTINUITY_AUDIO_FORMAT = 2,
DISCONTINUITY_VIDEO_FORMAT = 4,
+ DISCONTINUITY_ABSOLUTE_TIME = 8,
DISCONTINUITY_SEEK = DISCONTINUITY_TIME,
@@ -54,7 +55,9 @@ struct ATSParser : public RefBase {
// If this flag is _not_ specified, the first PTS encountered in a
// program of this stream will be assumed to correspond to media time 0
// instead.
- TS_TIMESTAMPS_ARE_ABSOLUTE = 1
+ TS_TIMESTAMPS_ARE_ABSOLUTE = 1,
+ // Video PES packets contain exactly one (aligned) access unit.
+ ALIGNED_VIDEO_DATA = 2,
};
ATSParser(uint32_t flags = 0);
@@ -84,6 +87,7 @@ struct ATSParser : public RefBase {
STREAMTYPE_MPEG2_AUDIO_ADTS = 0x0f,
STREAMTYPE_MPEG4_VIDEO = 0x10,
STREAMTYPE_H264 = 0x1b,
+ STREAMTYPE_PCM_AUDIO = 0x83,
};
protected:
@@ -100,17 +104,29 @@ private:
// Keyed by PID
KeyedVector<unsigned, sp<PSISection> > mPSISections;
+ int64_t mAbsoluteTimeAnchorUs;
+
+ size_t mNumTSPacketsParsed;
+
void parseProgramAssociationTable(ABitReader *br);
void parseProgramMap(ABitReader *br);
void parsePES(ABitReader *br);
status_t parsePID(
ABitReader *br, unsigned PID,
+ unsigned continuity_counter,
unsigned payload_unit_start_indicator);
- void parseAdaptationField(ABitReader *br);
+ void parseAdaptationField(ABitReader *br, unsigned PID);
status_t parseTS(ABitReader *br);
+ void updatePCR(unsigned PID, uint64_t PCR, size_t byteOffsetFromStart);
+
+ uint64_t mPCR[2];
+ size_t mPCRBytes[2];
+ int64_t mSystemTimeUs[2];
+ size_t mNumPCRs;
+
DISALLOW_EVIL_CONSTRUCTORS(ATSParser);
};
diff --git a/media/libstagefright/mpeg2ts/ESQueue.cpp b/media/libstagefright/mpeg2ts/ESQueue.cpp
index 1cab077..82fb637 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.cpp
+++ b/media/libstagefright/mpeg2ts/ESQueue.cpp
@@ -31,10 +31,13 @@
#include "include/avc_utils.h"
+#include <netinet/in.h>
+
namespace android {
-ElementaryStreamQueue::ElementaryStreamQueue(Mode mode)
- : mMode(mode) {
+ElementaryStreamQueue::ElementaryStreamQueue(Mode mode, uint32_t flags)
+ : mMode(mode),
+ mFlags(flags) {
}
sp<MetaData> ElementaryStreamQueue::getFormat() {
@@ -247,6 +250,11 @@ status_t ElementaryStreamQueue::appendData(
break;
}
+ case PCM_AUDIO:
+ {
+ break;
+ }
+
default:
TRESPASS();
break;
@@ -289,6 +297,31 @@ status_t ElementaryStreamQueue::appendData(
}
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnit() {
+ if ((mFlags & kFlag_AlignedData) && mMode == H264) {
+ if (mRangeInfos.empty()) {
+ return NULL;
+ }
+
+ RangeInfo info = *mRangeInfos.begin();
+ mRangeInfos.erase(mRangeInfos.begin());
+
+ sp<ABuffer> accessUnit = new ABuffer(info.mLength);
+ memcpy(accessUnit->data(), mBuffer->data(), info.mLength);
+ accessUnit->meta()->setInt64("timeUs", info.mTimestampUs);
+
+ memmove(mBuffer->data(),
+ mBuffer->data() + info.mLength,
+ mBuffer->size() - info.mLength);
+
+ mBuffer->setRange(0, mBuffer->size() - info.mLength);
+
+ if (mFormat == NULL) {
+ mFormat = MakeAVCCodecSpecificData(accessUnit);
+ }
+
+ return accessUnit;
+ }
+
switch (mMode) {
case H264:
return dequeueAccessUnitH264();
@@ -298,12 +331,68 @@ sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnit() {
return dequeueAccessUnitMPEGVideo();
case MPEG4_VIDEO:
return dequeueAccessUnitMPEG4Video();
+ case PCM_AUDIO:
+ return dequeueAccessUnitPCMAudio();
default:
CHECK_EQ((unsigned)mMode, (unsigned)MPEG_AUDIO);
return dequeueAccessUnitMPEGAudio();
}
}
+sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitPCMAudio() {
+ if (mBuffer->size() < 4) {
+ return NULL;
+ }
+
+ ABitReader bits(mBuffer->data(), 4);
+ CHECK_EQ(bits.getBits(8), 0xa0);
+ unsigned numAUs = bits.getBits(8);
+ bits.skipBits(8);
+ unsigned quantization_word_length = bits.getBits(2);
+ unsigned audio_sampling_frequency = bits.getBits(3);
+ unsigned num_channels = bits.getBits(3);
+
+ CHECK_EQ(audio_sampling_frequency, 2); // 48kHz
+ CHECK_EQ(num_channels, 1u); // stereo!
+
+ if (mFormat == NULL) {
+ mFormat = new MetaData;
+ mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
+ mFormat->setInt32(kKeyChannelCount, 2);
+ mFormat->setInt32(kKeySampleRate, 48000);
+ }
+
+ static const size_t kFramesPerAU = 80;
+ size_t frameSize = 2 /* numChannels */ * sizeof(int16_t);
+
+ size_t payloadSize = numAUs * frameSize * kFramesPerAU;
+
+ if (mBuffer->size() < 4 + payloadSize) {
+ return NULL;
+ }
+
+ sp<ABuffer> accessUnit = new ABuffer(payloadSize);
+ memcpy(accessUnit->data(), mBuffer->data() + 4, payloadSize);
+
+ int64_t timeUs = fetchTimestamp(payloadSize + 4);
+ CHECK_GE(timeUs, 0ll);
+ accessUnit->meta()->setInt64("timeUs", timeUs);
+
+ int16_t *ptr = (int16_t *)accessUnit->data();
+ for (size_t i = 0; i < payloadSize / sizeof(int16_t); ++i) {
+ ptr[i] = ntohs(ptr[i]);
+ }
+
+ memmove(
+ mBuffer->data(),
+ mBuffer->data() + 4 + payloadSize,
+ mBuffer->size() - 4 - payloadSize);
+
+ mBuffer->setRange(0, mBuffer->size() - 4 - payloadSize);
+
+ return accessUnit;
+}
+
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitAAC() {
int64_t timeUs;
@@ -436,8 +525,8 @@ struct NALPosition {
sp<ABuffer> ElementaryStreamQueue::dequeueAccessUnitH264() {
const uint8_t *data = mBuffer->data();
- size_t size = mBuffer->size();
+ size_t size = mBuffer->size();
Vector<NALPosition> nals;
size_t totalSize = 0;
diff --git a/media/libstagefright/mpeg2ts/ESQueue.h b/media/libstagefright/mpeg2ts/ESQueue.h
index 4035ed3..66a8087 100644
--- a/media/libstagefright/mpeg2ts/ESQueue.h
+++ b/media/libstagefright/mpeg2ts/ESQueue.h
@@ -35,8 +35,14 @@ struct ElementaryStreamQueue {
MPEG_AUDIO,
MPEG_VIDEO,
MPEG4_VIDEO,
+ PCM_AUDIO,
};
- ElementaryStreamQueue(Mode mode);
+
+ enum Flags {
+ // Data appended to the queue is always at access unit boundaries.
+ kFlag_AlignedData = 1,
+ };
+ ElementaryStreamQueue(Mode mode, uint32_t flags = 0);
status_t appendData(const void *data, size_t size, int64_t timeUs);
void clear(bool clearFormat);
@@ -52,6 +58,7 @@ private:
};
Mode mMode;
+ uint32_t mFlags;
sp<ABuffer> mBuffer;
List<RangeInfo> mRangeInfos;
@@ -63,6 +70,7 @@ private:
sp<ABuffer> dequeueAccessUnitMPEGAudio();
sp<ABuffer> dequeueAccessUnitMPEGVideo();
sp<ABuffer> dequeueAccessUnitMPEG4Video();
+ sp<ABuffer> dequeueAccessUnitPCMAudio();
// consume a logical (compressed) access unit of size "size",
// returns its timestamp in us (or -1 if no time information).
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 681e321..29bc733 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -252,13 +252,16 @@ status_t OMX::allocateNode(
status_t OMX::freeNode(node_id node) {
OMXNodeInstance *instance = findInstance(node);
- ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder());
- if (index < 0) {
- // This could conceivably happen if the observer dies at roughly the
- // same time that a client attempts to free the node explicitly.
- return OK;
+ {
+ Mutex::Autolock autoLock(mLock);
+ ssize_t index = mLiveNodes.indexOfKey(instance->observer()->asBinder());
+ if (index < 0) {
+ // This could conceivably happen if the observer dies at roughly the
+ // same time that a client attempts to free the node explicitly.
+ return OK;
+ }
+ mLiveNodes.removeItemsAt(index);
}
- mLiveNodes.removeItemsAt(index);
instance->observer()->asBinder()->unlinkToDeath(this);
@@ -266,7 +269,7 @@ status_t OMX::freeNode(node_id node) {
{
Mutex::Autolock autoLock(mLock);
- index = mDispatchers.indexOfKey(node);
+ ssize_t index = mDispatchers.indexOfKey(node);
CHECK(index >= 0);
mDispatchers.removeItemsAt(index);
}
diff --git a/media/libstagefright/omx/tests/OMXHarness.cpp b/media/libstagefright/omx/tests/OMXHarness.cpp
index fab1771..6cca8da 100644
--- a/media/libstagefright/omx/tests/OMXHarness.cpp
+++ b/media/libstagefright/omx/tests/OMXHarness.cpp
@@ -27,6 +27,7 @@
#include <binder/MemoryDealer.h>
#include <media/IMediaPlayerService.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/DataSource.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MediaDefs.h>
@@ -40,13 +41,6 @@
namespace android {
-static int64_t getNowUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_usec + tv.tv_sec * 1000000;
-}
-
Harness::Harness()
: mInitCheck(NO_INIT) {
mInitCheck = initOMX();
@@ -126,7 +120,7 @@ status_t Harness::dequeueMessageForNodeIgnoringBuffers(
Vector<Buffer> *inputBuffers,
Vector<Buffer> *outputBuffers,
omx_message *msg, int64_t timeoutUs) {
- int64_t finishBy = getNowUs() + timeoutUs;
+ int64_t finishBy = ALooper::GetNowUs() + timeoutUs;
for (;;) {
Mutex::Autolock autoLock(mLock);
@@ -150,7 +144,7 @@ status_t Harness::dequeueMessageForNodeIgnoringBuffers(
status_t err = (timeoutUs < 0)
? mMessageAddedCondition.wait(mLock)
: mMessageAddedCondition.waitRelative(
- mLock, (finishBy - getNowUs()) * 1000);
+ mLock, (finishBy - ALooper::GetNowUs()) * 1000);
if (err == TIMED_OUT) {
return err;
@@ -515,7 +509,10 @@ static const char *GetURLForMime(const char *mime) {
static sp<MediaSource> CreateSourceForMime(const char *mime) {
const char *url = GetURLForMime(mime);
- CHECK(url != NULL);
+
+ if (url == NULL) {
+ return NULL;
+ }
sp<MediaExtractor> extractor = CreateExtractorFromURI(url);
@@ -571,14 +568,22 @@ status_t Harness::testSeek(
const char *mime = GetMimeFromComponentRole(componentRole);
if (!mime) {
- ALOGI("Cannot perform seek test with this componentRole (%s)",
- componentRole);
+ printf(" * Cannot perform seek test with this componentRole (%s)\n",
+ componentRole);
return OK;
}
sp<MediaSource> source = CreateSourceForMime(mime);
+ if (source == NULL) {
+ printf(" * Unable to open test content for type '%s', "
+ "skipping test of componentRole %s\n",
+ mime, componentRole);
+
+ return OK;
+ }
+
sp<MediaSource> seekSource = CreateSourceForMime(mime);
if (source == NULL || seekSource == NULL) {
return UNKNOWN_ERROR;
diff --git a/media/libstagefright/rtsp/AAMRAssembler.cpp b/media/libstagefright/rtsp/AAMRAssembler.cpp
index fb8abc5..9e8725a 100644
--- a/media/libstagefright/rtsp/AAMRAssembler.cpp
+++ b/media/libstagefright/rtsp/AAMRAssembler.cpp
@@ -145,7 +145,6 @@ ARTPAssembler::AssemblyStatus AAMRAssembler::addPacket(
unsigned payloadHeader = buffer->data()[0];
unsigned CMR = payloadHeader >> 4;
- CHECK_EQ(payloadHeader & 0x0f, 0u); // RR
Vector<uint8_t> tableOfContents;
diff --git a/media/libstagefright/rtsp/AH263Assembler.cpp b/media/libstagefright/rtsp/AH263Assembler.cpp
index d0313cc..75cd911 100644
--- a/media/libstagefright/rtsp/AH263Assembler.cpp
+++ b/media/libstagefright/rtsp/AH263Assembler.cpp
@@ -13,6 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+//#define LOG_NDEBUG 0
+#define LOG_TAG "AH263Assembler"
+#include <utils/Log.h>
#include "AH263Assembler.h"
@@ -100,11 +103,34 @@ ARTPAssembler::AssemblyStatus AH263Assembler::addPacket(
}
unsigned payloadHeader = U16_AT(buffer->data());
- CHECK_EQ(payloadHeader >> 11, 0u); // RR=0
unsigned P = (payloadHeader >> 10) & 1;
unsigned V = (payloadHeader >> 9) & 1;
unsigned PLEN = (payloadHeader >> 3) & 0x3f;
- // unsigned PEBIT = payloadHeader & 7;
+ unsigned PEBIT = payloadHeader & 7;
+
+ // V=0
+ if (V != 0u) {
+ queue->erase(queue->begin());
+ ++mNextExpectedSeqNo;
+ ALOGW("Packet discarded due to VRC (V != 0)");
+ return MALFORMED_PACKET;
+ }
+
+ // PLEN=0
+ if (PLEN != 0u) {
+ queue->erase(queue->begin());
+ ++mNextExpectedSeqNo;
+ ALOGW("Packet discarded (PLEN != 0)");
+ return MALFORMED_PACKET;
+ }
+
+ // PEBIT=0
+ if (PEBIT != 0u) {
+ queue->erase(queue->begin());
+ ++mNextExpectedSeqNo;
+ ALOGW("Packet discarded (PEBIT != 0)");
+ return MALFORMED_PACKET;
+ }
size_t skip = V + PLEN + (P ? 0 : 2);
diff --git a/media/libstagefright/rtsp/AMPEG2TSAssembler.cpp b/media/libstagefright/rtsp/AMPEG2TSAssembler.cpp
new file mode 100644
index 0000000..4c9bf5b
--- /dev/null
+++ b/media/libstagefright/rtsp/AMPEG2TSAssembler.cpp
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "AMPEG2TSAssembler"
+#include <utils/Log.h>
+
+#include "AMPEG2TSAssembler.h"
+
+#include "ARTPSource.h"
+#include "ASessionDescription.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MetaData.h>
+#include <media/stagefright/Utils.h>
+
+namespace android {
+
+AMPEG2TSAssembler::AMPEG2TSAssembler(
+ const sp<AMessage> &notify, const char *desc, const AString &params)
+ : mNotifyMsg(notify),
+ mNextExpectedSeqNoValid(false),
+ mNextExpectedSeqNo(0) {
+}
+
+AMPEG2TSAssembler::~AMPEG2TSAssembler() {
+}
+
+ARTPAssembler::AssemblyStatus AMPEG2TSAssembler::assembleMore(
+ const sp<ARTPSource> &source) {
+ return addPacket(source);
+}
+
+ARTPAssembler::AssemblyStatus AMPEG2TSAssembler::addPacket(
+ const sp<ARTPSource> &source) {
+ List<sp<ABuffer> > *queue = source->queue();
+
+ if (queue->empty()) {
+ return NOT_ENOUGH_DATA;
+ }
+
+ if (mNextExpectedSeqNoValid) {
+ List<sp<ABuffer> >::iterator it = queue->begin();
+ while (it != queue->end()) {
+ if ((uint32_t)(*it)->int32Data() >= mNextExpectedSeqNo) {
+ break;
+ }
+
+ it = queue->erase(it);
+ }
+
+ if (queue->empty()) {
+ return NOT_ENOUGH_DATA;
+ }
+ }
+
+ sp<ABuffer> buffer = *queue->begin();
+
+ if (!mNextExpectedSeqNoValid) {
+ mNextExpectedSeqNoValid = true;
+ mNextExpectedSeqNo = (uint32_t)buffer->int32Data();
+ } else if ((uint32_t)buffer->int32Data() != mNextExpectedSeqNo) {
+ ALOGV("Not the sequence number I expected");
+
+ return WRONG_SEQUENCE_NUMBER;
+ }
+
+ // hexdump(buffer->data(), buffer->size());
+
+ if ((buffer->size() % 188) > 0) {
+ queue->erase(queue->begin());
+ ++mNextExpectedSeqNo;
+
+ ALOGV("Not a multiple of transport packet size.");
+
+ return MALFORMED_PACKET;
+ }
+
+ sp<AMessage> msg = mNotifyMsg->dup();
+ msg->setBuffer("access-unit", buffer);
+ msg->post();
+
+ queue->erase(queue->begin());
+ ++mNextExpectedSeqNo;
+
+ return OK;
+}
+
+void AMPEG2TSAssembler::packetLost() {
+ CHECK(mNextExpectedSeqNoValid);
+ ++mNextExpectedSeqNo;
+}
+
+void AMPEG2TSAssembler::onByeReceived() {
+ sp<AMessage> msg = mNotifyMsg->dup();
+ msg->setInt32("eos", true);
+ msg->post();
+}
+
+} // namespace android
+
+
diff --git a/media/libstagefright/rtsp/AMPEG2TSAssembler.h b/media/libstagefright/rtsp/AMPEG2TSAssembler.h
new file mode 100644
index 0000000..712e18e
--- /dev/null
+++ b/media/libstagefright/rtsp/AMPEG2TSAssembler.h
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef A_MPEG2_TS_ASSEMBLER_H_
+
+#define A_MPEG2_TS_ASSEMBLER_H_
+
+#include "ARTPAssembler.h"
+
+namespace android {
+
+struct AMessage;
+struct AString;
+struct MetaData;
+
+struct AMPEG2TSAssembler : public ARTPAssembler {
+ AMPEG2TSAssembler(
+ const sp<AMessage> &notify,
+ const char *desc, const AString &params);
+
+protected:
+ virtual ~AMPEG2TSAssembler();
+
+ virtual AssemblyStatus assembleMore(const sp<ARTPSource> &source);
+ virtual void onByeReceived();
+ virtual void packetLost();
+
+private:
+ sp<AMessage> mNotifyMsg;
+ bool mNextExpectedSeqNoValid;
+ uint32_t mNextExpectedSeqNo;
+
+ AssemblyStatus addPacket(const sp<ARTPSource> &source);
+
+ DISALLOW_EVIL_CONSTRUCTORS(AMPEG2TSAssembler);
+};
+
+} // namespace android
+
+#endif // A_MPEG2_TS_ASSEMBLER_H_
+
diff --git a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
index f9a44f0..aa8ffc6 100644
--- a/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
+++ b/media/libstagefright/rtsp/AMPEG4AudioAssembler.cpp
@@ -311,9 +311,7 @@ static status_t parseStreamMuxConfig(
case 2:
{
- // reserved
- TRESPASS();
- break;
+ return ERROR_UNSUPPORTED;
}
case 3:
@@ -460,6 +458,15 @@ AMPEG4AudioAssembler::AMPEG4AudioAssembler(
&mFixedFrameLength,
&mOtherDataPresent, &mOtherDataLenBits);
+ if (err == ERROR_UNSUPPORTED) {
+ ALOGW("Failed to parse stream mux config, using default values for playback.");
+ mMuxConfigPresent = false;
+ mNumSubFrames = 0;
+ mFrameLengthType = 0;
+ mOtherDataPresent = false;
+ mOtherDataLenBits = 0;
+ return;
+ }
CHECK_EQ(err, (status_t)NO_ERROR);
}
diff --git a/media/libstagefright/rtsp/APacketSource.cpp b/media/libstagefright/rtsp/APacketSource.cpp
index ddd2f06..462c384 100644
--- a/media/libstagefright/rtsp/APacketSource.cpp
+++ b/media/libstagefright/rtsp/APacketSource.cpp
@@ -566,6 +566,8 @@ APacketSource::APacketSource(
codecSpecificData->data(), codecSpecificData->size());
} else if (ARawAudioAssembler::Supports(desc.c_str())) {
ARawAudioAssembler::MakeFormat(desc.c_str(), mFormat);
+ } else if (!strncasecmp("MP2T/", desc.c_str(), 5)) {
+ mFormat->setCString(kKeyMIMEType, MEDIA_MIMETYPE_CONTAINER_MPEG2TS);
} else {
mInitCheck = ERROR_UNSUPPORTED;
}
diff --git a/media/libstagefright/rtsp/ARTPAssembler.cpp b/media/libstagefright/rtsp/ARTPAssembler.cpp
index 1844bc5..c7a65c2 100644
--- a/media/libstagefright/rtsp/ARTPAssembler.cpp
+++ b/media/libstagefright/rtsp/ARTPAssembler.cpp
@@ -18,19 +18,13 @@
#include <media/stagefright/foundation/ABuffer.h>
#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
#include <media/stagefright/foundation/AMessage.h>
#include <stdint.h>
namespace android {
-static int64_t getNowUs() {
- struct timeval tv;
- gettimeofday(&tv, NULL);
-
- return (int64_t)tv.tv_usec + tv.tv_sec * 1000000ll;
-}
-
ARTPAssembler::ARTPAssembler()
: mFirstFailureTimeUs(-1) {
}
@@ -42,7 +36,7 @@ void ARTPAssembler::onPacketReceived(const sp<ARTPSource> &source) {
if (status == WRONG_SEQUENCE_NUMBER) {
if (mFirstFailureTimeUs >= 0) {
- if (getNowUs() - mFirstFailureTimeUs > 10000ll) {
+ if (ALooper::GetNowUs() - mFirstFailureTimeUs > 10000ll) {
mFirstFailureTimeUs = -1;
// LOG(VERBOSE) << "waited too long for packet.";
@@ -50,7 +44,7 @@ void ARTPAssembler::onPacketReceived(const sp<ARTPSource> &source) {
continue;
}
} else {
- mFirstFailureTimeUs = getNowUs();
+ mFirstFailureTimeUs = ALooper::GetNowUs();
}
break;
} else {
diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp
index ed68790..d7c3bd6 100644
--- a/media/libstagefright/rtsp/ARTPSource.cpp
+++ b/media/libstagefright/rtsp/ARTPSource.cpp
@@ -23,6 +23,7 @@
#include "AAMRAssembler.h"
#include "AAVCAssembler.h"
#include "AH263Assembler.h"
+#include "AMPEG2TSAssembler.h"
#include "AMPEG4AudioAssembler.h"
#include "AMPEG4ElementaryAssembler.h"
#include "ARawAudioAssembler.h"
@@ -73,6 +74,8 @@ ARTPSource::ARTPSource(
mIssueFIRRequests = true;
} else if (ARawAudioAssembler::Supports(desc.c_str())) {
mAssembler = new ARawAudioAssembler(notify, desc.c_str(), params);
+ } else if (!strncasecmp(desc.c_str(), "MP2T/", 5)) {
+ mAssembler = new AMPEG2TSAssembler(notify, desc.c_str(), params);
} else {
TRESPASS();
}
diff --git a/media/libstagefright/rtsp/ARTSPConnection.cpp b/media/libstagefright/rtsp/ARTSPConnection.cpp
index 539a888..161bd4f 100644
--- a/media/libstagefright/rtsp/ARTSPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTSPConnection.cpp
@@ -830,6 +830,7 @@ status_t ARTSPConnection::findPendingRequest(
if (i < 0) {
// This is an unsolicited server->client message.
+ *index = -1;
return OK;
}
diff --git a/media/libstagefright/rtsp/Android.mk b/media/libstagefright/rtsp/Android.mk
index d0f5259..49e2daf 100644
--- a/media/libstagefright/rtsp/Android.mk
+++ b/media/libstagefright/rtsp/Android.mk
@@ -6,6 +6,7 @@ LOCAL_SRC_FILES:= \
AAMRAssembler.cpp \
AAVCAssembler.cpp \
AH263Assembler.cpp \
+ AMPEG2TSAssembler.cpp \
AMPEG4AudioAssembler.cpp \
AMPEG4ElementaryAssembler.cpp \
APacketSource.cpp \
diff --git a/media/libstagefright/rtsp/MyHandler.h b/media/libstagefright/rtsp/MyHandler.h
index deee30f..96c7683 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -1091,6 +1091,10 @@ struct MyHandler : public AHandler {
void parsePlayResponse(const sp<ARTSPResponse> &response) {
mSeekable = false;
+ if (mTracks.size() == 0) {
+ ALOGV("parsePlayResponse: late packets ignored.");
+ return;
+ }
ssize_t i = response->mHeaders.indexOfKey("range");
if (i < 0) {
diff --git a/media/libstagefright/tests/Android.mk b/media/libstagefright/tests/Android.mk
index a1e6be7..57fff0b 100644
--- a/media/libstagefright/tests/Android.mk
+++ b/media/libstagefright/tests/Android.mk
@@ -20,9 +20,10 @@ LOCAL_SHARED_LIBRARIES := \
libgui \
libmedia \
libstagefright \
- libstagefright_omx \
libstagefright_foundation \
+ libstagefright_omx \
libstlport \
+ libsync \
libui \
libutils \
diff --git a/media/libstagefright/tests/SurfaceMediaSource_test.cpp b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
index 466f521..a61d6a2 100644
--- a/media/libstagefright/tests/SurfaceMediaSource_test.cpp
+++ b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
@@ -90,7 +90,7 @@ protected:
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
mSurfaceControl = mComposerClient->createSurface(
- String8("Test Surface"), 0,
+ String8("Test Surface"),
getSurfaceWidth(), getSurfaceHeight(),
PIXEL_FORMAT_RGB_888, 0);
@@ -509,31 +509,31 @@ void SurfaceMediaSourceGLTest::setUpEGLSurfaceFromMediaRecorder(sp<MediaRecorder
// cpu YV12 buffer
void SurfaceMediaSourceTest::oneBufferPass(int width, int height ) {
ANativeWindowBuffer* anb;
- ASSERT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
ASSERT_TRUE(anb != NULL);
- sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- ASSERT_EQ(NO_ERROR, mANW->lockBuffer(mANW.get(), buf->getNativeBuffer()));
// Fill the buffer with the a checkerboard pattern
uint8_t* img = NULL;
+ sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
SurfaceMediaSourceTest::fillYV12Buffer(img, width, height, buf->getStride());
buf->unlock();
- ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer()));
+ ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
+ -1));
}
// Dequeuing and queuing the buffer without really filling it in.
void SurfaceMediaSourceTest::oneBufferPassNoFill(int width, int height ) {
ANativeWindowBuffer* anb;
- ASSERT_EQ(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ ASSERT_EQ(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
ASSERT_TRUE(anb != NULL);
- sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- // ASSERT_EQ(NO_ERROR, mANW->lockBuffer(mANW.get(), buf->getNativeBuffer()));
// We do not fill the buffer in. Just queue it back.
- ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer()));
+ sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
+ ASSERT_EQ(NO_ERROR, mANW->queueBuffer(mANW.get(), buf->getNativeBuffer(),
+ -1));
}
// Fill a YV12 buffer with a multi-colored checkerboard pattern
@@ -652,7 +652,7 @@ TEST_F(SurfaceMediaSourceTest, DISABLED_DummyEncodingFromCpuFilledYV12BufferNpot
ANativeWindowBuffer* anb;
// Note: make sure we get an ERROR back when dequeuing!
- ASSERT_NE(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+ ASSERT_NE(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
}
// pass multiple buffers from the native_window the SurfaceMediaSource
diff --git a/media/libstagefright/timedtext/TimedTextDriver.cpp b/media/libstagefright/timedtext/TimedTextDriver.cpp
index 42ca1f5..12fd7f4 100644
--- a/media/libstagefright/timedtext/TimedTextDriver.cpp
+++ b/media/libstagefright/timedtext/TimedTextDriver.cpp
@@ -43,7 +43,8 @@ TimedTextDriver::TimedTextDriver(
const wp<MediaPlayerBase> &listener)
: mLooper(new ALooper),
mListener(listener),
- mState(UNINITIALIZED) {
+ mState(UNINITIALIZED),
+ mCurrentTrackIndex(UINT_MAX) {
mLooper->setName("TimedTextDriver");
mLooper->start();
mPlayer = new TimedTextPlayer(listener);
@@ -57,11 +58,14 @@ TimedTextDriver::~TimedTextDriver() {
}
status_t TimedTextDriver::selectTrack_l(size_t index) {
+ if (mCurrentTrackIndex == index) {
+ return OK;
+ }
sp<TimedTextSource> source;
source = mTextSourceVector.valueFor(index);
mPlayer->setDataSource(source);
if (mState == UNINITIALIZED) {
- mState = PAUSED;
+ mState = PREPARED;
}
mCurrentTrackIndex = index;
return OK;
@@ -74,42 +78,47 @@ status_t TimedTextDriver::start() {
return INVALID_OPERATION;
case PLAYING:
return OK;
- case PAUSED:
+ case PREPARED:
mPlayer->start();
- break;
+ mState = PLAYING;
+ return OK;
+ case PAUSED:
+ mPlayer->resume();
+ mState = PLAYING;
+ return OK;
default:
TRESPASS();
}
- mState = PLAYING;
- return OK;
+ return UNKNOWN_ERROR;
}
-// TODO: Test if pause() works properly.
-// Scenario 1: start - pause - resume
-// Scenario 2: start - seek
-// Scenario 3: start - pause - seek - resume
status_t TimedTextDriver::pause() {
Mutex::Autolock autoLock(mLock);
+ ALOGV("%s() is called", __FUNCTION__);
switch (mState) {
case UNINITIALIZED:
return INVALID_OPERATION;
case PLAYING:
mPlayer->pause();
- break;
+ mState = PAUSED;
+ return OK;
+ case PREPARED:
+ return INVALID_OPERATION;
case PAUSED:
return OK;
default:
TRESPASS();
}
- mState = PAUSED;
- return OK;
+ return UNKNOWN_ERROR;
}
status_t TimedTextDriver::selectTrack(size_t index) {
status_t ret = OK;
Mutex::Autolock autoLock(mLock);
+ ALOGV("%s() is called", __FUNCTION__);
switch (mState) {
case UNINITIALIZED:
+ case PREPARED:
case PAUSED:
ret = selectTrack_l(index);
break;
@@ -128,21 +137,51 @@ status_t TimedTextDriver::selectTrack(size_t index) {
}
status_t TimedTextDriver::unselectTrack(size_t index) {
+ Mutex::Autolock autoLock(mLock);
+ ALOGV("%s() is called", __FUNCTION__);
if (mCurrentTrackIndex != index) {
return INVALID_OPERATION;
}
- status_t err = pause();
- if (err != OK) {
- return err;
+ mCurrentTrackIndex = UINT_MAX;
+ switch (mState) {
+ case UNINITIALIZED:
+ return INVALID_OPERATION;
+ case PLAYING:
+ mPlayer->setDataSource(NULL);
+ mState = UNINITIALIZED;
+ return OK;
+ case PREPARED:
+ case PAUSED:
+ mState = UNINITIALIZED;
+ return OK;
+ default:
+ TRESPASS();
}
- Mutex::Autolock autoLock(mLock);
- mState = UNINITIALIZED;
- return OK;
+ return UNKNOWN_ERROR;
}
status_t TimedTextDriver::seekToAsync(int64_t timeUs) {
- mPlayer->seekToAsync(timeUs);
- return OK;
+ Mutex::Autolock autoLock(mLock);
+ ALOGV("%s() is called", __FUNCTION__);
+ switch (mState) {
+ case UNINITIALIZED:
+ return INVALID_OPERATION;
+ case PREPARED:
+ mPlayer->seekToAsync(timeUs);
+ mPlayer->pause();
+ mState = PAUSED;
+ return OK;
+ case PAUSED:
+ mPlayer->seekToAsync(timeUs);
+ mPlayer->pause();
+ return OK;
+ case PLAYING:
+ mPlayer->seekToAsync(timeUs);
+ return OK;
+ defaut:
+ TRESPASS();
+ }
+ return UNKNOWN_ERROR;
}
status_t TimedTextDriver::addInBandTextSource(
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.cpp b/media/libstagefright/timedtext/TimedTextPlayer.cpp
index 9b001cc..9fb0afe 100644
--- a/media/libstagefright/timedtext/TimedTextPlayer.cpp
+++ b/media/libstagefright/timedtext/TimedTextPlayer.cpp
@@ -18,6 +18,7 @@
#define LOG_TAG "TimedTextPlayer"
#include <utils/Log.h>
+#include <limits.h>
#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/foundation/AMessage.h>
#include <media/stagefright/timedtext/TimedTextDriver.h>
@@ -30,12 +31,18 @@
namespace android {
+// Event should be fired a bit earlier considering the processing time till
+// application actually gets the notification message.
static const int64_t kAdjustmentProcessingTimeUs = 100000ll;
+static const int64_t kMaxDelayUs = 5000000ll;
static const int64_t kWaitTimeUsToRetryRead = 100000ll;
+static const int64_t kInvalidTimeUs = INT_MIN;
TimedTextPlayer::TimedTextPlayer(const wp<MediaPlayerBase> &listener)
: mListener(listener),
mSource(NULL),
+ mPendingSeekTimeUs(kInvalidTimeUs),
+ mPaused(false),
mSendSubtitleGeneration(0) {
}
@@ -48,15 +55,17 @@ TimedTextPlayer::~TimedTextPlayer() {
}
void TimedTextPlayer::start() {
- sp<AMessage> msg = new AMessage(kWhatSeek, id());
- msg->setInt64("seekTimeUs", -1);
- msg->post();
+ (new AMessage(kWhatStart, id()))->post();
}
void TimedTextPlayer::pause() {
(new AMessage(kWhatPause, id()))->post();
}
+void TimedTextPlayer::resume() {
+ (new AMessage(kWhatResume, id()))->post();
+}
+
void TimedTextPlayer::seekToAsync(int64_t timeUs) {
sp<AMessage> msg = new AMessage(kWhatSeek, id());
msg->setInt64("seekTimeUs", timeUs);
@@ -72,10 +81,43 @@ void TimedTextPlayer::setDataSource(sp<TimedTextSource> source) {
void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
switch (msg->what()) {
case kWhatPause: {
+ mPaused = true;
+ break;
+ }
+ case kWhatResume: {
+ mPaused = false;
+ if (mPendingSeekTimeUs != kInvalidTimeUs) {
+ seekToAsync(mPendingSeekTimeUs);
+ mPendingSeekTimeUs = kInvalidTimeUs;
+ } else {
+ doRead();
+ }
+ break;
+ }
+ case kWhatStart: {
+ sp<MediaPlayerBase> listener = mListener.promote();
+ if (listener == NULL) {
+ ALOGE("Listener is NULL when kWhatStart is received.");
+ break;
+ }
+ mPaused = false;
+ mPendingSeekTimeUs = kInvalidTimeUs;
+ int32_t positionMs = 0;
+ listener->getCurrentPosition(&positionMs);
+ int64_t seekTimeUs = positionMs * 1000ll;
+
+ notifyListener();
mSendSubtitleGeneration++;
+ doSeekAndRead(seekTimeUs);
break;
}
case kWhatRetryRead: {
+ int32_t generation = -1;
+ CHECK(msg->findInt32("generation", &generation));
+ if (generation != mSendSubtitleGeneration) {
+ // Drop obsolete msg.
+ break;
+ }
int64_t seekTimeUs;
int seekMode;
if (msg->findInt64("seekTimeUs", &seekTimeUs) &&
@@ -91,9 +133,11 @@ void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
break;
}
case kWhatSeek: {
- int64_t seekTimeUs = 0;
+ int64_t seekTimeUs = kInvalidTimeUs;
+ // Clear a displayed timed text before seeking.
+ notifyListener();
msg->findInt64("seekTimeUs", &seekTimeUs);
- if (seekTimeUs < 0) {
+ if (seekTimeUs == kInvalidTimeUs) {
sp<MediaPlayerBase> listener = mListener.promote();
if (listener != NULL) {
int32_t positionMs = 0;
@@ -101,6 +145,11 @@ void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
seekTimeUs = positionMs * 1000ll;
}
}
+ if (mPaused) {
+ mPendingSeekTimeUs = seekTimeUs;
+ break;
+ }
+ mSendSubtitleGeneration++;
doSeekAndRead(seekTimeUs);
break;
}
@@ -108,8 +157,19 @@ void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
int32_t generation;
CHECK(msg->findInt32("generation", &generation));
if (generation != mSendSubtitleGeneration) {
- // Drop obsolete msg.
- break;
+ // Drop obsolete msg.
+ break;
+ }
+ // If current time doesn't reach to the fire time,
+ // re-post the message with the adjusted delay time.
+ int64_t fireTimeUs = kInvalidTimeUs;
+ if (msg->findInt64("fireTimeUs", &fireTimeUs)) {
+ // TODO: check if fireTimeUs is not kInvalidTimeUs.
+ int64_t delayUs = delayUsFromCurrentTime(fireTimeUs);
+ if (delayUs > 0) {
+ msg->post(delayUs);
+ break;
+ }
}
sp<RefBase> obj;
if (msg->findObject("subtitle", &obj)) {
@@ -123,11 +183,20 @@ void TimedTextPlayer::onMessageReceived(const sp<AMessage> &msg) {
break;
}
case kWhatSetSource: {
+ mSendSubtitleGeneration++;
sp<RefBase> obj;
msg->findObject("source", &obj);
- if (obj == NULL) break;
if (mSource != NULL) {
mSource->stop();
+ mSource.clear();
+ mSource = NULL;
+ }
+ // null source means deselect track.
+ if (obj == NULL) {
+ mPendingSeekTimeUs = kInvalidTimeUs;
+ mPaused = false;
+ notifyListener();
+ break;
}
mSource = static_cast<TimedTextSource*>(obj.get());
status_t err = mSource->start();
@@ -157,17 +226,20 @@ void TimedTextPlayer::doRead(MediaSource::ReadOptions* options) {
int64_t startTimeUs = 0;
int64_t endTimeUs = 0;
sp<ParcelEvent> parcelEvent = new ParcelEvent();
+ CHECK(mSource != NULL);
status_t err = mSource->read(&startTimeUs, &endTimeUs,
&(parcelEvent->parcel), options);
if (err == WOULD_BLOCK) {
sp<AMessage> msg = new AMessage(kWhatRetryRead, id());
if (options != NULL) {
- int64_t seekTimeUs;
- MediaSource::ReadOptions::SeekMode seekMode;
+ int64_t seekTimeUs = kInvalidTimeUs;
+ MediaSource::ReadOptions::SeekMode seekMode =
+ MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC;
CHECK(options->getSeekTo(&seekTimeUs, &seekMode));
msg->setInt64("seekTimeUs", seekTimeUs);
msg->setInt32("seekMode", seekMode);
}
+ msg->setInt32("generation", mSendSubtitleGeneration);
msg->post(kWaitTimeUsToRetryRead);
return;
} else if (err != OK) {
@@ -185,49 +257,58 @@ void TimedTextPlayer::doRead(MediaSource::ReadOptions* options) {
}
void TimedTextPlayer::postTextEvent(const sp<ParcelEvent>& parcel, int64_t timeUs) {
- sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL) {
- int64_t positionUs, delayUs;
- int32_t positionMs = 0;
- listener->getCurrentPosition(&positionMs);
- positionUs = positionMs * 1000ll;
-
- if (timeUs <= positionUs + kAdjustmentProcessingTimeUs) {
- delayUs = 0;
- } else {
- delayUs = timeUs - positionUs - kAdjustmentProcessingTimeUs;
- }
- postTextEventDelayUs(parcel, delayUs);
+ int64_t delayUs = delayUsFromCurrentTime(timeUs);
+ sp<AMessage> msg = new AMessage(kWhatSendSubtitle, id());
+ msg->setInt32("generation", mSendSubtitleGeneration);
+ if (parcel != NULL) {
+ msg->setObject("subtitle", parcel);
}
+ msg->setInt64("fireTimeUs", timeUs);
+ msg->post(delayUs);
}
-void TimedTextPlayer::postTextEventDelayUs(const sp<ParcelEvent>& parcel, int64_t delayUs) {
+int64_t TimedTextPlayer::delayUsFromCurrentTime(int64_t fireTimeUs) {
sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL) {
- sp<AMessage> msg = new AMessage(kWhatSendSubtitle, id());
- msg->setInt32("generation", mSendSubtitleGeneration);
- if (parcel != NULL) {
- msg->setObject("subtitle", parcel);
+ if (listener == NULL) {
+ // TODO: it may be better to return kInvalidTimeUs
+ ALOGE("%s: Listener is NULL. (fireTimeUs = %lld)",
+ __FUNCTION__, fireTimeUs);
+ return 0;
+ }
+ int32_t positionMs = 0;
+ listener->getCurrentPosition(&positionMs);
+ int64_t positionUs = positionMs * 1000ll;
+
+ if (fireTimeUs <= positionUs + kAdjustmentProcessingTimeUs) {
+ return 0;
+ } else {
+ int64_t delayUs = fireTimeUs - positionUs - kAdjustmentProcessingTimeUs;
+ if (delayUs > kMaxDelayUs) {
+ return kMaxDelayUs;
}
- msg->post(delayUs);
+ return delayUs;
}
}
void TimedTextPlayer::notifyError(int error) {
sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL) {
- listener->sendEvent(MEDIA_INFO, MEDIA_INFO_TIMED_TEXT_ERROR, error);
+ if (listener == NULL) {
+ ALOGE("%s(error=%d): Listener is NULL.", __FUNCTION__, error);
+ return;
}
+ listener->sendEvent(MEDIA_INFO, MEDIA_INFO_TIMED_TEXT_ERROR, error);
}
void TimedTextPlayer::notifyListener(const Parcel *parcel) {
sp<MediaPlayerBase> listener = mListener.promote();
- if (listener != NULL) {
- if (parcel != NULL && (parcel->dataSize() > 0)) {
- listener->sendEvent(MEDIA_TIMED_TEXT, 0, 0, parcel);
- } else { // send an empty timed text to clear the screen
- listener->sendEvent(MEDIA_TIMED_TEXT);
- }
+ if (listener == NULL) {
+ ALOGE("%s: Listener is NULL.", __FUNCTION__);
+ return;
+ }
+ if (parcel != NULL && (parcel->dataSize() > 0)) {
+ listener->sendEvent(MEDIA_TIMED_TEXT, 0, 0, parcel);
+ } else { // send an empty timed text to clear the screen
+ listener->sendEvent(MEDIA_TIMED_TEXT);
}
}
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.h b/media/libstagefright/timedtext/TimedTextPlayer.h
index b7e15f8..ec8ed25 100644
--- a/media/libstagefright/timedtext/TimedTextPlayer.h
+++ b/media/libstagefright/timedtext/TimedTextPlayer.h
@@ -40,6 +40,7 @@ public:
void start();
void pause();
+ void resume();
void seekToAsync(int64_t timeUs);
void setDataSource(sp<TimedTextSource> source);
@@ -49,6 +50,8 @@ protected:
private:
enum {
kWhatPause = 'paus',
+ kWhatResume = 'resm',
+ kWhatStart = 'strt',
kWhatSeek = 'seek',
kWhatRetryRead = 'read',
kWhatSendSubtitle = 'send',
@@ -62,13 +65,15 @@ private:
wp<MediaPlayerBase> mListener;
sp<TimedTextSource> mSource;
+ int64_t mPendingSeekTimeUs;
+ bool mPaused;
int32_t mSendSubtitleGeneration;
void doSeekAndRead(int64_t seekTimeUs);
void doRead(MediaSource::ReadOptions* options = NULL);
void onTextEvent();
void postTextEvent(const sp<ParcelEvent>& parcel = NULL, int64_t timeUs = -1);
- void postTextEventDelayUs(const sp<ParcelEvent>& parcel = NULL, int64_t delayUs = -1);
+ int64_t delayUsFromCurrentTime(int64_t fireTimeUs);
void notifyError(int error = 0);
void notifyListener(const Parcel *parcel = NULL);
diff --git a/media/libstagefright/timedtext/TimedTextSRTSource.cpp b/media/libstagefright/timedtext/TimedTextSRTSource.cpp
index 1f5d037..eac23ba 100644
--- a/media/libstagefright/timedtext/TimedTextSRTSource.cpp
+++ b/media/libstagefright/timedtext/TimedTextSRTSource.cpp
@@ -79,6 +79,10 @@ status_t TimedTextSRTSource::read(
return OK;
}
+sp<MetaData> TimedTextSRTSource::getFormat() {
+ return mMetaData;
+}
+
status_t TimedTextSRTSource::scanFile() {
off64_t offset = 0;
int64_t startTimeUs;
@@ -155,18 +159,16 @@ status_t TimedTextSRTSource::getNextSubtitleInfo(
while (needMoreData) {
if ((err = readNextLine(offset, &data)) != OK) {
if (err == ERROR_END_OF_STREAM) {
- needMoreData = false;
+ break;
} else {
return err;
}
}
- if (needMoreData) {
- data.trim();
- if (data.empty()) {
- // it's an empty line used to separate two subtitles
- needMoreData = false;
- }
+ data.trim();
+ if (data.empty()) {
+ // it's an empty line used to separate two subtitles
+ needMoreData = false;
}
}
info->textLen = *offset - info->offset;
@@ -221,35 +223,24 @@ status_t TimedTextSRTSource::getText(
if (options != NULL && options->getSeekTo(&seekTimeUs, &mode)) {
int64_t lastEndTimeUs =
mTextVector.valueAt(mTextVector.size() - 1).endTimeUs;
- int64_t firstStartTimeUs = mTextVector.keyAt(0);
- if (seekTimeUs < 0 || seekTimeUs > lastEndTimeUs) {
+ if (seekTimeUs < 0) {
return ERROR_OUT_OF_RANGE;
- } else if (seekTimeUs < firstStartTimeUs) {
- mIndex = 0;
+ } else if (seekTimeUs >= lastEndTimeUs) {
+ return ERROR_END_OF_STREAM;
} else {
// binary search
size_t low = 0;
size_t high = mTextVector.size() - 1;
size_t mid = 0;
- int64_t currTimeUs;
while (low <= high) {
mid = low + (high - low)/2;
- currTimeUs = mTextVector.keyAt(mid);
- const int64_t diffTime = currTimeUs - seekTimeUs;
-
- if (diffTime == 0) {
+ int diff = compareExtendedRangeAndTime(mid, seekTimeUs);
+ if (diff == 0) {
break;
- } else if (diffTime < 0) {
+ } else if (diff < 0) {
low = mid + 1;
} else {
- if ((high == mid + 1)
- && (seekTimeUs < mTextVector.keyAt(high))) {
- break;
- }
- if (mid < 1) {
- break;
- }
high = mid - 1;
}
}
@@ -260,6 +251,7 @@ status_t TimedTextSRTSource::getText(
if (mIndex >= mTextVector.size()) {
return ERROR_END_OF_STREAM;
}
+
const TextInfo &info = mTextVector.valueAt(mIndex);
*startTimeUs = mTextVector.keyAt(mIndex);
*endTimeUs = info.endTimeUs;
@@ -289,8 +281,18 @@ status_t TimedTextSRTSource::extractAndAppendLocalDescriptions(
return OK;
}
-sp<MetaData> TimedTextSRTSource::getFormat() {
- return mMetaData;
+int TimedTextSRTSource::compareExtendedRangeAndTime(size_t index, int64_t timeUs) {
+ CHECK_LT(index, mTextVector.size());
+ int64_t endTimeUs = mTextVector.valueAt(index).endTimeUs;
+ int64_t startTimeUs = (index > 0) ?
+ mTextVector.valueAt(index - 1).endTimeUs : 0;
+ if (timeUs >= startTimeUs && timeUs < endTimeUs) {
+ return 0;
+ } else if (endTimeUs <= timeUs) {
+ return -1;
+ } else {
+ return 1;
+ }
}
} // namespace android
diff --git a/media/libstagefright/timedtext/TimedTextSRTSource.h b/media/libstagefright/timedtext/TimedTextSRTSource.h
index 9eeab39..598c200 100644
--- a/media/libstagefright/timedtext/TimedTextSRTSource.h
+++ b/media/libstagefright/timedtext/TimedTextSRTSource.h
@@ -70,6 +70,25 @@ private:
status_t extractAndAppendLocalDescriptions(
int64_t timeUs, const AString &text, Parcel *parcel);
+ // Compares the time range of the subtitle at index to the given timeUs.
+ // The time range of the subtitle to match with given timeUs is extended to
+ // [endTimeUs of the previous subtitle, endTimeUs of current subtitle).
+ //
+ // This compare function is used to find a next subtitle when read() is
+ // called with seek options. Note that timeUs within gap ranges, such as
+ // [200, 300) in the below example, will be matched to the closest future
+ // subtitle, [300, 400).
+ //
+ // For instance, assuming there are 3 subtitles in mTextVector,
+ // 0: [100, 200) ----> [0, 200)
+ // 1: [300, 400) ----> [200, 400)
+ // 2: [500, 600) ----> [400, 600)
+ // If the 'index' parameter contains 1, this function
+ // returns 0, if timeUs is in [200, 400)
+ // returns -1, if timeUs >= 400,
+ // returns 1, if timeUs < 200.
+ int compareExtendedRangeAndTime(size_t index, int64_t timeUs);
+
DISALLOW_EVIL_CONSTRUCTORS(TimedTextSRTSource);
};
diff --git a/media/libstagefright/timedtext/test/Android.mk b/media/libstagefright/timedtext/test/Android.mk
new file mode 100644
index 0000000..a5e7ba2
--- /dev/null
+++ b/media/libstagefright/timedtext/test/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH:= $(call my-dir)
+
+# ================================================================
+# Unit tests for libstagefright_timedtext
+# See also /development/testrunner/test_defs.xml
+# ================================================================
+
+# ================================================================
+# A test for TimedTextSRTSource
+# ================================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := TimedTextSRTSource_test
+
+LOCAL_MODULE_TAGS := eng tests
+
+LOCAL_SRC_FILES := TimedTextSRTSource_test.cpp
+
+LOCAL_C_INCLUDES := \
+ $(TOP)/external/expat/lib \
+ $(TOP)/frameworks/base/media/libstagefright/timedtext
+
+LOCAL_SHARED_LIBRARIES := \
+ libexpat \
+ libstagefright
+
+include $(BUILD_NATIVE_TEST)
diff --git a/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp b/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp
new file mode 100644
index 0000000..40e93c7
--- /dev/null
+++ b/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TimedTextSRTSource_test"
+#include <utils/Log.h>
+
+#include <gtest/gtest.h>
+
+#include <binder/Parcel.h>
+#include <media/stagefright/foundation/AString.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaErrors.h>
+#include <utils/misc.h>
+
+#include <TimedTextSource.h>
+#include <TimedTextSRTSource.h>
+
+namespace android {
+namespace test {
+
+static const int kSecToUsec = 1000000;
+static const int kSecToMsec = 1000;
+static const int kMsecToUsec = 1000;
+
+/* SRT format (http://en.wikipedia.org/wiki/SubRip)
+ * Subtitle number
+ * Start time --> End time
+ * Text of subtitle (one or more lines)
+ * Blank lines
+ */
+static const char *kSRTString =
+ "1\n00:00:1,000 --> 00:00:1,500\n1\n\n"
+ "2\n00:00:2,000 --> 00:00:2,500\n2\n\n"
+ "3\n00:00:3,000 --> 00:00:3,500\n3\n\n"
+ "4\n00:00:4,000 --> 00:00:4,500\n4\n\n"
+ "5\n00:00:5,000 --> 00:00:5,500\n5\n\n"
+ // edge case : previos end time = next start time
+ "6\n00:00:5,500 --> 00:00:5,800\n6\n\n"
+ "7\n00:00:5,800 --> 00:00:6,000\n7\n\n"
+ "8\n00:00:6,000 --> 00:00:7,000\n8\n\n";
+
+class SRTDataSourceStub : public DataSource {
+public:
+ SRTDataSourceStub(const char *data, size_t size) :
+ mData(data), mSize(size) {}
+ virtual ~SRTDataSourceStub() {}
+
+ virtual status_t initCheck() const {
+ return OK;
+ }
+
+ virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+ if (offset >= mSize) return 0;
+
+ ssize_t avail = mSize - offset;
+ if (avail > size) {
+ avail = size;
+ }
+ memcpy(data, mData + offset, avail);
+ return avail;
+ }
+
+private:
+ const char *mData;
+ size_t mSize;
+};
+
+class TimedTextSRTSourceTest : public testing::Test {
+protected:
+ void SetUp() {
+ sp<DataSource> stub= new SRTDataSourceStub(
+ kSRTString,
+ strlen(kSRTString));
+ mSource = new TimedTextSRTSource(stub);
+ mSource->start();
+ }
+
+ void CheckStartTimeMs(const Parcel& parcel, int32_t timeMs) {
+ int32_t intval;
+ parcel.setDataPosition(8);
+ parcel.readInt32(&intval);
+ EXPECT_EQ(timeMs, intval);
+ }
+
+ void CheckDataEquals(const Parcel& parcel, const char* content) {
+ int32_t intval;
+ parcel.setDataPosition(16);
+ parcel.readInt32(&intval);
+ parcel.setDataPosition(24);
+ const char* data = (const char*) parcel.readInplace(intval);
+
+ int32_t content_len = strlen(content);
+ EXPECT_EQ(content_len, intval);
+ EXPECT_TRUE(strncmp(data, content, content_len) == 0);
+ }
+
+ sp<TimedTextSource> mSource;
+ int64_t startTimeUs;
+ int64_t endTimeUs;
+ Parcel parcel;
+ AString subtitle;
+ status_t err;
+};
+
+TEST_F(TimedTextSRTSourceTest, readAll) {
+ for (int i = 1; i <= 5; i++) {
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+ EXPECT_EQ(OK, err);
+ CheckStartTimeMs(parcel, i * kSecToMsec);
+ subtitle = StringPrintf("%d\n\n", i);
+ CheckDataEquals(parcel, subtitle.c_str());
+ }
+ // read edge cases
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+ EXPECT_EQ(OK, err);
+ CheckStartTimeMs(parcel, 5500);
+ subtitle = StringPrintf("6\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+ EXPECT_EQ(OK, err);
+ CheckStartTimeMs(parcel, 5800);
+ subtitle = StringPrintf("7\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+ EXPECT_EQ(OK, err);
+ CheckStartTimeMs(parcel, 6000);
+ subtitle = StringPrintf("8\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+ EXPECT_EQ(ERROR_END_OF_STREAM, err);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsEarlierThanFirst) {
+ MediaSource::ReadOptions options;
+ options.setSeekTo(500, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(1 * kSecToUsec, startTimeUs);
+ CheckStartTimeMs(parcel, 1 * kSecToMsec);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsLaterThanLast) {
+ MediaSource::ReadOptions options;
+ options.setSeekTo(7 * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(ERROR_END_OF_STREAM, err);
+
+ options.setSeekTo(8 * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(ERROR_END_OF_STREAM, err);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsMatched) {
+ for (int i = 1; i <= 5; i++) {
+ MediaSource::ReadOptions options;
+ options.setSeekTo(i * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(i * kSecToUsec, startTimeUs);
+
+ options.setSeekTo(i * kSecToUsec + 100, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(i * kSecToUsec, startTimeUs);
+ }
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeInBetweenTwo) {
+ for (int i = 1; i <= 4; i++) {
+ MediaSource::ReadOptions options;
+ options.setSeekTo(i * kSecToUsec + 500000, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ((i + 1) * kSecToUsec, startTimeUs);
+
+ options.setSeekTo(i * kSecToUsec + 600000, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ((i + 1) * kSecToUsec, startTimeUs);
+ }
+}
+
+TEST_F(TimedTextSRTSourceTest, checkEdgeCase) {
+ MediaSource::ReadOptions options;
+ options.setSeekTo(5500 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(5500 * kMsecToUsec, startTimeUs);
+ subtitle = StringPrintf("6\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+
+ options.setSeekTo(5800 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(5800 * kMsecToUsec, startTimeUs);
+ subtitle = StringPrintf("7\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+
+ options.setSeekTo(6000 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+ err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+ EXPECT_EQ(OK, err);
+ EXPECT_EQ(6000 * kMsecToUsec, startTimeUs);
+ subtitle = StringPrintf("8\n\n");
+ CheckDataEquals(parcel, subtitle.c_str());
+}
+
+} // namespace test
+} // namespace android
diff --git a/media/libstagefright/wifi-display/ANetworkSession.cpp b/media/libstagefright/wifi-display/ANetworkSession.cpp
new file mode 100644
index 0000000..819cd62
--- /dev/null
+++ b/media/libstagefright/wifi-display/ANetworkSession.cpp
@@ -0,0 +1,1119 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "NetworkSession"
+#include <utils/Log.h>
+
+#include "ANetworkSession.h"
+#include "ParsedMessage.h"
+
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <net/if.h>
+#include <netdb.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/Utils.h>
+
+namespace android {
+
+static const size_t kMaxUDPSize = 1500;
+
+struct ANetworkSession::NetworkThread : public Thread {
+ NetworkThread(ANetworkSession *session);
+
+protected:
+ virtual ~NetworkThread();
+
+private:
+ ANetworkSession *mSession;
+
+ virtual bool threadLoop();
+
+ DISALLOW_EVIL_CONSTRUCTORS(NetworkThread);
+};
+
+struct ANetworkSession::Session : public RefBase {
+ enum State {
+ CONNECTING,
+ CONNECTED,
+ LISTENING_RTSP,
+ LISTENING_TCP_DGRAMS,
+ DATAGRAM,
+ };
+
+ Session(int32_t sessionID,
+ State state,
+ int s,
+ const sp<AMessage> &notify);
+
+ int32_t sessionID() const;
+ int socket() const;
+ sp<AMessage> getNotificationMessage() const;
+
+ bool isRTSPServer() const;
+ bool isTCPDatagramServer() const;
+
+ bool wantsToRead();
+ bool wantsToWrite();
+
+ status_t readMore();
+ status_t writeMore();
+
+ status_t sendRequest(const void *data, ssize_t size);
+
+ void setIsRTSPConnection(bool yesno);
+
+protected:
+ virtual ~Session();
+
+private:
+ int32_t mSessionID;
+ State mState;
+ bool mIsRTSPConnection;
+ int mSocket;
+ sp<AMessage> mNotify;
+ bool mSawReceiveFailure, mSawSendFailure;
+
+ // for TCP / stream data
+ AString mOutBuffer;
+
+ // for UDP / datagrams
+ List<sp<ABuffer> > mOutDatagrams;
+
+ AString mInBuffer;
+
+ void notifyError(bool send, status_t err, const char *detail);
+ void notify(NotificationReason reason);
+
+ DISALLOW_EVIL_CONSTRUCTORS(Session);
+};
+////////////////////////////////////////////////////////////////////////////////
+
+ANetworkSession::NetworkThread::NetworkThread(ANetworkSession *session)
+ : mSession(session) {
+}
+
+ANetworkSession::NetworkThread::~NetworkThread() {
+}
+
+bool ANetworkSession::NetworkThread::threadLoop() {
+ mSession->threadLoop();
+
+ return true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+ANetworkSession::Session::Session(
+ int32_t sessionID,
+ State state,
+ int s,
+ const sp<AMessage> &notify)
+ : mSessionID(sessionID),
+ mState(state),
+ mIsRTSPConnection(false),
+ mSocket(s),
+ mNotify(notify),
+ mSawReceiveFailure(false),
+ mSawSendFailure(false) {
+ if (mState == CONNECTED) {
+ struct sockaddr_in localAddr;
+ socklen_t localAddrLen = sizeof(localAddr);
+
+ int res = getsockname(
+ mSocket, (struct sockaddr *)&localAddr, &localAddrLen);
+ CHECK_GE(res, 0);
+
+ struct sockaddr_in remoteAddr;
+ socklen_t remoteAddrLen = sizeof(remoteAddr);
+
+ res = getpeername(
+ mSocket, (struct sockaddr *)&remoteAddr, &remoteAddrLen);
+ CHECK_GE(res, 0);
+
+ in_addr_t addr = ntohl(localAddr.sin_addr.s_addr);
+ AString localAddrString = StringPrintf(
+ "%d.%d.%d.%d",
+ (addr >> 24),
+ (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff,
+ addr & 0xff);
+
+ addr = ntohl(remoteAddr.sin_addr.s_addr);
+ AString remoteAddrString = StringPrintf(
+ "%d.%d.%d.%d",
+ (addr >> 24),
+ (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff,
+ addr & 0xff);
+
+ sp<AMessage> msg = mNotify->dup();
+ msg->setInt32("sessionID", mSessionID);
+ msg->setInt32("reason", kWhatClientConnected);
+ msg->setString("server-ip", localAddrString.c_str());
+ msg->setInt32("server-port", ntohs(localAddr.sin_port));
+ msg->setString("client-ip", remoteAddrString.c_str());
+ msg->setInt32("client-port", ntohs(remoteAddr.sin_port));
+ msg->post();
+ }
+}
+
+ANetworkSession::Session::~Session() {
+ ALOGV("Session %d gone", mSessionID);
+
+ close(mSocket);
+ mSocket = -1;
+}
+
+int32_t ANetworkSession::Session::sessionID() const {
+ return mSessionID;
+}
+
+int ANetworkSession::Session::socket() const {
+ return mSocket;
+}
+
+void ANetworkSession::Session::setIsRTSPConnection(bool yesno) {
+ mIsRTSPConnection = yesno;
+}
+
+sp<AMessage> ANetworkSession::Session::getNotificationMessage() const {
+ return mNotify;
+}
+
+bool ANetworkSession::Session::isRTSPServer() const {
+ return mState == LISTENING_RTSP;
+}
+
+bool ANetworkSession::Session::isTCPDatagramServer() const {
+ return mState == LISTENING_TCP_DGRAMS;
+}
+
+bool ANetworkSession::Session::wantsToRead() {
+ return !mSawReceiveFailure && mState != CONNECTING;
+}
+
+bool ANetworkSession::Session::wantsToWrite() {
+ return !mSawSendFailure
+ && (mState == CONNECTING
+ || (mState == CONNECTED && !mOutBuffer.empty())
+ || (mState == DATAGRAM && !mOutDatagrams.empty()));
+}
+
+status_t ANetworkSession::Session::readMore() {
+ if (mState == DATAGRAM) {
+ status_t err;
+ do {
+ sp<ABuffer> buf = new ABuffer(kMaxUDPSize);
+
+ struct sockaddr_in remoteAddr;
+ socklen_t remoteAddrLen = sizeof(remoteAddr);
+
+ ssize_t n;
+ do {
+ n = recvfrom(
+ mSocket, buf->data(), buf->capacity(), 0,
+ (struct sockaddr *)&remoteAddr, &remoteAddrLen);
+ } while (n < 0 && errno == EINTR);
+
+ err = OK;
+ if (n < 0) {
+ err = -errno;
+ } else if (n == 0) {
+ err = -ECONNRESET;
+ } else {
+ buf->setRange(0, n);
+
+ int64_t nowUs = ALooper::GetNowUs();
+ buf->meta()->setInt64("arrivalTimeUs", nowUs);
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("sessionID", mSessionID);
+ notify->setInt32("reason", kWhatDatagram);
+
+ uint32_t ip = ntohl(remoteAddr.sin_addr.s_addr);
+ notify->setString(
+ "fromAddr",
+ StringPrintf(
+ "%u.%u.%u.%u",
+ ip >> 24,
+ (ip >> 16) & 0xff,
+ (ip >> 8) & 0xff,
+ ip & 0xff).c_str());
+
+ notify->setInt32("fromPort", ntohs(remoteAddr.sin_port));
+
+ notify->setBuffer("data", buf);
+ notify->post();
+ }
+ } while (err == OK);
+
+ if (err == -EAGAIN) {
+ err = OK;
+ }
+
+ if (err != OK) {
+ notifyError(false /* send */, err, "Recvfrom failed.");
+ mSawReceiveFailure = true;
+ }
+
+ return err;
+ }
+
+ char tmp[512];
+ ssize_t n;
+ do {
+ n = recv(mSocket, tmp, sizeof(tmp), 0);
+ } while (n < 0 && errno == EINTR);
+
+ status_t err = OK;
+
+ if (n > 0) {
+ mInBuffer.append(tmp, n);
+
+#if 0
+ ALOGI("in:");
+ hexdump(tmp, n);
+#endif
+ } else if (n < 0) {
+ err = -errno;
+ } else {
+ err = -ECONNRESET;
+ }
+
+ if (!mIsRTSPConnection) {
+ // TCP stream carrying 16-bit length-prefixed datagrams.
+
+ while (mInBuffer.size() >= 2) {
+ size_t packetSize = U16_AT((const uint8_t *)mInBuffer.c_str());
+
+ if (mInBuffer.size() < packetSize + 2) {
+ break;
+ }
+
+ sp<ABuffer> packet = new ABuffer(packetSize);
+ memcpy(packet->data(), mInBuffer.c_str() + 2, packetSize);
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("sessionID", mSessionID);
+ notify->setInt32("reason", kWhatDatagram);
+ notify->setBuffer("data", packet);
+ notify->post();
+
+ mInBuffer.erase(0, packetSize + 2);
+ }
+ } else {
+ for (;;) {
+ size_t length;
+
+ if (mInBuffer.size() > 0 && mInBuffer.c_str()[0] == '$') {
+ if (mInBuffer.size() < 4) {
+ break;
+ }
+
+ length = U16_AT((const uint8_t *)mInBuffer.c_str() + 2);
+
+ if (mInBuffer.size() < 4 + length) {
+ break;
+ }
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("sessionID", mSessionID);
+ notify->setInt32("reason", kWhatBinaryData);
+ notify->setInt32("channel", mInBuffer.c_str()[1]);
+
+ sp<ABuffer> data = new ABuffer(length);
+ memcpy(data->data(), mInBuffer.c_str() + 4, length);
+
+ int64_t nowUs = ALooper::GetNowUs();
+ data->meta()->setInt64("arrivalTimeUs", nowUs);
+
+ notify->setBuffer("data", data);
+ notify->post();
+
+ mInBuffer.erase(0, 4 + length);
+ continue;
+ }
+
+ sp<ParsedMessage> msg =
+ ParsedMessage::Parse(
+ mInBuffer.c_str(), mInBuffer.size(), err != OK, &length);
+
+ if (msg == NULL) {
+ break;
+ }
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("sessionID", mSessionID);
+ notify->setInt32("reason", kWhatData);
+ notify->setObject("data", msg);
+ notify->post();
+
+#if 1
+ // XXX The (old) dongle sends the wrong content length header on a
+ // SET_PARAMETER request that signals a "wfd_idr_request".
+ // (17 instead of 19).
+ const char *content = msg->getContent();
+ if (content
+ && !memcmp(content, "wfd_idr_request\r\n", 17)
+ && length >= 19
+ && mInBuffer.c_str()[length] == '\r'
+ && mInBuffer.c_str()[length + 1] == '\n') {
+ length += 2;
+ }
+#endif
+
+ mInBuffer.erase(0, length);
+
+ if (err != OK) {
+ break;
+ }
+ }
+ }
+
+ if (err != OK) {
+ notifyError(false /* send */, err, "Recv failed.");
+ mSawReceiveFailure = true;
+ }
+
+ return err;
+}
+
+status_t ANetworkSession::Session::writeMore() {
+ if (mState == DATAGRAM) {
+ CHECK(!mOutDatagrams.empty());
+
+ status_t err;
+ do {
+ const sp<ABuffer> &datagram = *mOutDatagrams.begin();
+
+ int n;
+ do {
+ n = send(mSocket, datagram->data(), datagram->size(), 0);
+ } while (n < 0 && errno == EINTR);
+
+ err = OK;
+
+ if (n > 0) {
+ mOutDatagrams.erase(mOutDatagrams.begin());
+ } else if (n < 0) {
+ err = -errno;
+ } else if (n == 0) {
+ err = -ECONNRESET;
+ }
+ } while (err == OK && !mOutDatagrams.empty());
+
+ if (err == -EAGAIN) {
+ err = OK;
+ }
+
+ if (err != OK) {
+ notifyError(true /* send */, err, "Send datagram failed.");
+ mSawSendFailure = true;
+ }
+
+ return err;
+ }
+
+ if (mState == CONNECTING) {
+ int err;
+ socklen_t optionLen = sizeof(err);
+ CHECK_EQ(getsockopt(mSocket, SOL_SOCKET, SO_ERROR, &err, &optionLen), 0);
+ CHECK_EQ(optionLen, (socklen_t)sizeof(err));
+
+ if (err != 0) {
+ notifyError(kWhatError, -err, "Connection failed");
+ mSawSendFailure = true;
+
+ return -err;
+ }
+
+ mState = CONNECTED;
+ notify(kWhatConnected);
+
+ return OK;
+ }
+
+ CHECK_EQ(mState, CONNECTED);
+ CHECK(!mOutBuffer.empty());
+
+ ssize_t n;
+ do {
+ n = send(mSocket, mOutBuffer.c_str(), mOutBuffer.size(), 0);
+ } while (n < 0 && errno == EINTR);
+
+ status_t err = OK;
+
+ if (n > 0) {
+#if 0
+ ALOGI("out:");
+ hexdump(mOutBuffer.c_str(), n);
+#endif
+
+ mOutBuffer.erase(0, n);
+ } else if (n < 0) {
+ err = -errno;
+ } else if (n == 0) {
+ err = -ECONNRESET;
+ }
+
+ if (err != OK) {
+ notifyError(true /* send */, err, "Send failed.");
+ mSawSendFailure = true;
+ }
+
+ return err;
+}
+
+status_t ANetworkSession::Session::sendRequest(const void *data, ssize_t size) {
+ CHECK(mState == CONNECTED || mState == DATAGRAM);
+
+ if (mState == DATAGRAM) {
+ CHECK_GE(size, 0);
+
+ sp<ABuffer> datagram = new ABuffer(size);
+ memcpy(datagram->data(), data, size);
+
+ mOutDatagrams.push_back(datagram);
+ return OK;
+ }
+
+ if (mState == CONNECTED && !mIsRTSPConnection) {
+ CHECK_LE(size, 65535);
+
+ uint8_t prefix[2];
+ prefix[0] = size >> 8;
+ prefix[1] = size & 0xff;
+
+ mOutBuffer.append((const char *)prefix, sizeof(prefix));
+ }
+
+ mOutBuffer.append(
+ (const char *)data,
+ (size >= 0) ? size : strlen((const char *)data));
+
+ return OK;
+}
+
+void ANetworkSession::Session::notifyError(
+ bool send, status_t err, const char *detail) {
+ sp<AMessage> msg = mNotify->dup();
+ msg->setInt32("sessionID", mSessionID);
+ msg->setInt32("reason", kWhatError);
+ msg->setInt32("send", send);
+ msg->setInt32("err", err);
+ msg->setString("detail", detail);
+ msg->post();
+}
+
+void ANetworkSession::Session::notify(NotificationReason reason) {
+ sp<AMessage> msg = mNotify->dup();
+ msg->setInt32("sessionID", mSessionID);
+ msg->setInt32("reason", reason);
+ msg->post();
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+ANetworkSession::ANetworkSession()
+ : mNextSessionID(1) {
+ mPipeFd[0] = mPipeFd[1] = -1;
+}
+
+ANetworkSession::~ANetworkSession() {
+ stop();
+}
+
+status_t ANetworkSession::start() {
+ if (mThread != NULL) {
+ return INVALID_OPERATION;
+ }
+
+ int res = pipe(mPipeFd);
+ if (res != 0) {
+ mPipeFd[0] = mPipeFd[1] = -1;
+ return -errno;
+ }
+
+ mThread = new NetworkThread(this);
+
+ status_t err = mThread->run("ANetworkSession", ANDROID_PRIORITY_AUDIO);
+
+ if (err != OK) {
+ mThread.clear();
+
+ close(mPipeFd[0]);
+ close(mPipeFd[1]);
+ mPipeFd[0] = mPipeFd[1] = -1;
+
+ return err;
+ }
+
+ return OK;
+}
+
+status_t ANetworkSession::stop() {
+ if (mThread == NULL) {
+ return INVALID_OPERATION;
+ }
+
+ mThread->requestExit();
+ interrupt();
+ mThread->requestExitAndWait();
+
+ mThread.clear();
+
+ close(mPipeFd[0]);
+ close(mPipeFd[1]);
+ mPipeFd[0] = mPipeFd[1] = -1;
+
+ return OK;
+}
+
+status_t ANetworkSession::createRTSPClient(
+ const char *host, unsigned port, const sp<AMessage> &notify,
+ int32_t *sessionID) {
+ return createClientOrServer(
+ kModeCreateRTSPClient,
+ NULL /* addr */,
+ 0 /* port */,
+ host,
+ port,
+ notify,
+ sessionID);
+}
+
+status_t ANetworkSession::createRTSPServer(
+ const struct in_addr &addr, unsigned port,
+ const sp<AMessage> &notify, int32_t *sessionID) {
+ return createClientOrServer(
+ kModeCreateRTSPServer,
+ &addr,
+ port,
+ NULL /* remoteHost */,
+ 0 /* remotePort */,
+ notify,
+ sessionID);
+}
+
+status_t ANetworkSession::createUDPSession(
+ unsigned localPort, const sp<AMessage> &notify, int32_t *sessionID) {
+ return createUDPSession(localPort, NULL, 0, notify, sessionID);
+}
+
+status_t ANetworkSession::createUDPSession(
+ unsigned localPort,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID) {
+ return createClientOrServer(
+ kModeCreateUDPSession,
+ NULL /* addr */,
+ localPort,
+ remoteHost,
+ remotePort,
+ notify,
+ sessionID);
+}
+
+status_t ANetworkSession::createTCPDatagramSession(
+ const struct in_addr &addr, unsigned port,
+ const sp<AMessage> &notify, int32_t *sessionID) {
+ return createClientOrServer(
+ kModeCreateTCPDatagramSessionPassive,
+ &addr,
+ port,
+ NULL /* remoteHost */,
+ 0 /* remotePort */,
+ notify,
+ sessionID);
+}
+
+status_t ANetworkSession::createTCPDatagramSession(
+ unsigned localPort,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID) {
+ return createClientOrServer(
+ kModeCreateTCPDatagramSessionActive,
+ NULL /* addr */,
+ localPort,
+ remoteHost,
+ remotePort,
+ notify,
+ sessionID);
+}
+
+status_t ANetworkSession::destroySession(int32_t sessionID) {
+ Mutex::Autolock autoLock(mLock);
+
+ ssize_t index = mSessions.indexOfKey(sessionID);
+
+ if (index < 0) {
+ return -ENOENT;
+ }
+
+ mSessions.removeItemsAt(index);
+
+ interrupt();
+
+ return OK;
+}
+
+// static
+status_t ANetworkSession::MakeSocketNonBlocking(int s) {
+ int flags = fcntl(s, F_GETFL, 0);
+ if (flags < 0) {
+ flags = 0;
+ }
+
+ int res = fcntl(s, F_SETFL, flags | O_NONBLOCK);
+ if (res < 0) {
+ return -errno;
+ }
+
+ return OK;
+}
+
+status_t ANetworkSession::createClientOrServer(
+ Mode mode,
+ const struct in_addr *localAddr,
+ unsigned port,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID) {
+ Mutex::Autolock autoLock(mLock);
+
+ *sessionID = 0;
+ status_t err = OK;
+ int s, res;
+ sp<Session> session;
+
+ s = socket(
+ AF_INET,
+ (mode == kModeCreateUDPSession) ? SOCK_DGRAM : SOCK_STREAM,
+ 0);
+
+ if (s < 0) {
+ err = -errno;
+ goto bail;
+ }
+
+ if (mode == kModeCreateRTSPServer
+ || mode == kModeCreateTCPDatagramSessionPassive) {
+ const int yes = 1;
+ res = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes));
+
+ if (res < 0) {
+ err = -errno;
+ goto bail2;
+ }
+ }
+
+ if (mode == kModeCreateUDPSession) {
+ int size = 256 * 1024;
+
+ res = setsockopt(s, SOL_SOCKET, SO_RCVBUF, &size, sizeof(size));
+
+ if (res < 0) {
+ err = -errno;
+ goto bail2;
+ }
+
+ res = setsockopt(s, SOL_SOCKET, SO_SNDBUF, &size, sizeof(size));
+
+ if (res < 0) {
+ err = -errno;
+ goto bail2;
+ }
+ }
+
+ err = MakeSocketNonBlocking(s);
+
+ if (err != OK) {
+ goto bail2;
+ }
+
+ struct sockaddr_in addr;
+ memset(addr.sin_zero, 0, sizeof(addr.sin_zero));
+ addr.sin_family = AF_INET;
+
+ if (mode == kModeCreateRTSPClient
+ || mode == kModeCreateTCPDatagramSessionActive) {
+ struct hostent *ent= gethostbyname(remoteHost);
+ if (ent == NULL) {
+ err = -h_errno;
+ goto bail2;
+ }
+
+ addr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr;
+ addr.sin_port = htons(remotePort);
+ } else if (localAddr != NULL) {
+ addr.sin_addr = *localAddr;
+ addr.sin_port = htons(port);
+ } else {
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ addr.sin_port = htons(port);
+ }
+
+ if (mode == kModeCreateRTSPClient
+ || mode == kModeCreateTCPDatagramSessionActive) {
+ in_addr_t x = ntohl(addr.sin_addr.s_addr);
+ ALOGI("connecting socket %d to %d.%d.%d.%d:%d",
+ s,
+ (x >> 24),
+ (x >> 16) & 0xff,
+ (x >> 8) & 0xff,
+ x & 0xff,
+ ntohs(addr.sin_port));
+
+ res = connect(s, (const struct sockaddr *)&addr, sizeof(addr));
+
+ CHECK_LT(res, 0);
+ if (errno == EINPROGRESS) {
+ res = 0;
+ }
+ } else {
+ res = bind(s, (const struct sockaddr *)&addr, sizeof(addr));
+
+ if (res == 0) {
+ if (mode == kModeCreateRTSPServer
+ || mode == kModeCreateTCPDatagramSessionPassive) {
+ res = listen(s, 4);
+ } else {
+ CHECK_EQ(mode, kModeCreateUDPSession);
+
+ if (remoteHost != NULL) {
+ struct sockaddr_in remoteAddr;
+ memset(remoteAddr.sin_zero, 0, sizeof(remoteAddr.sin_zero));
+ remoteAddr.sin_family = AF_INET;
+ remoteAddr.sin_port = htons(remotePort);
+
+ struct hostent *ent= gethostbyname(remoteHost);
+ if (ent == NULL) {
+ err = -h_errno;
+ goto bail2;
+ }
+
+ remoteAddr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr;
+
+ res = connect(
+ s,
+ (const struct sockaddr *)&remoteAddr,
+ sizeof(remoteAddr));
+ }
+ }
+ }
+ }
+
+ if (res < 0) {
+ err = -errno;
+ goto bail2;
+ }
+
+ Session::State state;
+ switch (mode) {
+ case kModeCreateRTSPClient:
+ state = Session::CONNECTING;
+ break;
+
+ case kModeCreateTCPDatagramSessionActive:
+ state = Session::CONNECTING;
+ break;
+
+ case kModeCreateTCPDatagramSessionPassive:
+ state = Session::LISTENING_TCP_DGRAMS;
+ break;
+
+ case kModeCreateRTSPServer:
+ state = Session::LISTENING_RTSP;
+ break;
+
+ default:
+ CHECK_EQ(mode, kModeCreateUDPSession);
+ state = Session::DATAGRAM;
+ break;
+ }
+
+ session = new Session(
+ mNextSessionID++,
+ state,
+ s,
+ notify);
+
+ if (mode == kModeCreateTCPDatagramSessionActive) {
+ session->setIsRTSPConnection(false);
+ } else if (mode == kModeCreateRTSPClient) {
+ session->setIsRTSPConnection(true);
+ }
+
+ mSessions.add(session->sessionID(), session);
+
+ interrupt();
+
+ *sessionID = session->sessionID();
+
+ goto bail;
+
+bail2:
+ close(s);
+ s = -1;
+
+bail:
+ return err;
+}
+
+status_t ANetworkSession::connectUDPSession(
+ int32_t sessionID, const char *remoteHost, unsigned remotePort) {
+ Mutex::Autolock autoLock(mLock);
+
+ ssize_t index = mSessions.indexOfKey(sessionID);
+
+ if (index < 0) {
+ return -ENOENT;
+ }
+
+ const sp<Session> session = mSessions.valueAt(index);
+ int s = session->socket();
+
+ struct sockaddr_in remoteAddr;
+ memset(remoteAddr.sin_zero, 0, sizeof(remoteAddr.sin_zero));
+ remoteAddr.sin_family = AF_INET;
+ remoteAddr.sin_port = htons(remotePort);
+
+ status_t err = OK;
+ struct hostent *ent = gethostbyname(remoteHost);
+ if (ent == NULL) {
+ err = -h_errno;
+ } else {
+ remoteAddr.sin_addr.s_addr = *(in_addr_t *)ent->h_addr;
+
+ int res = connect(
+ s,
+ (const struct sockaddr *)&remoteAddr,
+ sizeof(remoteAddr));
+
+ if (res < 0) {
+ err = -errno;
+ }
+ }
+
+ return err;
+}
+
+status_t ANetworkSession::sendRequest(
+ int32_t sessionID, const void *data, ssize_t size) {
+ Mutex::Autolock autoLock(mLock);
+
+ ssize_t index = mSessions.indexOfKey(sessionID);
+
+ if (index < 0) {
+ return -ENOENT;
+ }
+
+ const sp<Session> session = mSessions.valueAt(index);
+
+ status_t err = session->sendRequest(data, size);
+
+ interrupt();
+
+ return err;
+}
+
+void ANetworkSession::interrupt() {
+ static const char dummy = 0;
+
+ ssize_t n;
+ do {
+ n = write(mPipeFd[1], &dummy, 1);
+ } while (n < 0 && errno == EINTR);
+
+ if (n < 0) {
+ ALOGW("Error writing to pipe (%s)", strerror(errno));
+ }
+}
+
+void ANetworkSession::threadLoop() {
+ fd_set rs, ws;
+ FD_ZERO(&rs);
+ FD_ZERO(&ws);
+
+ FD_SET(mPipeFd[0], &rs);
+ int maxFd = mPipeFd[0];
+
+ {
+ Mutex::Autolock autoLock(mLock);
+
+ for (size_t i = 0; i < mSessions.size(); ++i) {
+ const sp<Session> &session = mSessions.valueAt(i);
+
+ int s = session->socket();
+
+ if (s < 0) {
+ continue;
+ }
+
+ if (session->wantsToRead()) {
+ FD_SET(s, &rs);
+ if (s > maxFd) {
+ maxFd = s;
+ }
+ }
+
+ if (session->wantsToWrite()) {
+ FD_SET(s, &ws);
+ if (s > maxFd) {
+ maxFd = s;
+ }
+ }
+ }
+ }
+
+ int res = select(maxFd + 1, &rs, &ws, NULL, NULL /* tv */);
+
+ if (res == 0) {
+ return;
+ }
+
+ if (res < 0) {
+ if (errno == EINTR) {
+ return;
+ }
+
+ ALOGE("select failed w/ error %d (%s)", errno, strerror(errno));
+ return;
+ }
+
+ if (FD_ISSET(mPipeFd[0], &rs)) {
+ char c;
+ ssize_t n;
+ do {
+ n = read(mPipeFd[0], &c, 1);
+ } while (n < 0 && errno == EINTR);
+
+ if (n < 0) {
+ ALOGW("Error reading from pipe (%s)", strerror(errno));
+ }
+
+ --res;
+ }
+
+ {
+ Mutex::Autolock autoLock(mLock);
+
+ List<sp<Session> > sessionsToAdd;
+
+ for (size_t i = mSessions.size(); res > 0 && i-- > 0;) {
+ const sp<Session> &session = mSessions.valueAt(i);
+
+ int s = session->socket();
+
+ if (s < 0) {
+ continue;
+ }
+
+ if (FD_ISSET(s, &rs) || FD_ISSET(s, &ws)) {
+ --res;
+ }
+
+ if (FD_ISSET(s, &rs)) {
+ if (session->isRTSPServer() || session->isTCPDatagramServer()) {
+ struct sockaddr_in remoteAddr;
+ socklen_t remoteAddrLen = sizeof(remoteAddr);
+
+ int clientSocket = accept(
+ s, (struct sockaddr *)&remoteAddr, &remoteAddrLen);
+
+ if (clientSocket >= 0) {
+ status_t err = MakeSocketNonBlocking(clientSocket);
+
+ if (err != OK) {
+ ALOGE("Unable to make client socket non blocking, "
+ "failed w/ error %d (%s)",
+ err, strerror(-err));
+
+ close(clientSocket);
+ clientSocket = -1;
+ } else {
+ in_addr_t addr = ntohl(remoteAddr.sin_addr.s_addr);
+
+ ALOGI("incoming connection from %d.%d.%d.%d:%d "
+ "(socket %d)",
+ (addr >> 24),
+ (addr >> 16) & 0xff,
+ (addr >> 8) & 0xff,
+ addr & 0xff,
+ ntohs(remoteAddr.sin_port),
+ clientSocket);
+
+ sp<Session> clientSession =
+ // using socket sd as sessionID
+ new Session(
+ mNextSessionID++,
+ Session::CONNECTED,
+ clientSocket,
+ session->getNotificationMessage());
+
+ clientSession->setIsRTSPConnection(
+ session->isRTSPServer());
+
+ sessionsToAdd.push_back(clientSession);
+ }
+ } else {
+ ALOGE("accept returned error %d (%s)",
+ errno, strerror(errno));
+ }
+ } else {
+ status_t err = session->readMore();
+ if (err != OK) {
+ ALOGE("readMore on socket %d failed w/ error %d (%s)",
+ s, err, strerror(-err));
+ }
+ }
+ }
+
+ if (FD_ISSET(s, &ws)) {
+ status_t err = session->writeMore();
+ if (err != OK) {
+ ALOGE("writeMore on socket %d failed w/ error %d (%s)",
+ s, err, strerror(-err));
+ }
+ }
+ }
+
+ while (!sessionsToAdd.empty()) {
+ sp<Session> session = *sessionsToAdd.begin();
+ sessionsToAdd.erase(sessionsToAdd.begin());
+
+ mSessions.add(session->sessionID(), session);
+
+ ALOGI("added clientSession %d", session->sessionID());
+ }
+ }
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/ANetworkSession.h b/media/libstagefright/wifi-display/ANetworkSession.h
new file mode 100644
index 0000000..c1acdcc
--- /dev/null
+++ b/media/libstagefright/wifi-display/ANetworkSession.h
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef A_NETWORK_SESSION_H_
+
+#define A_NETWORK_SESSION_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <utils/KeyedVector.h>
+#include <utils/RefBase.h>
+#include <utils/Thread.h>
+
+#include <netinet/in.h>
+
+namespace android {
+
+struct AMessage;
+
+// Helper class to manage a number of live sockets (datagram and stream-based)
+// on a single thread. Clients are notified about activity through AMessages.
+struct ANetworkSession : public RefBase {
+ ANetworkSession();
+
+ status_t start();
+ status_t stop();
+
+ status_t createRTSPClient(
+ const char *host, unsigned port, const sp<AMessage> &notify,
+ int32_t *sessionID);
+
+ status_t createRTSPServer(
+ const struct in_addr &addr, unsigned port,
+ const sp<AMessage> &notify, int32_t *sessionID);
+
+ status_t createUDPSession(
+ unsigned localPort, const sp<AMessage> &notify, int32_t *sessionID);
+
+ status_t createUDPSession(
+ unsigned localPort,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID);
+
+ status_t connectUDPSession(
+ int32_t sessionID, const char *remoteHost, unsigned remotePort);
+
+ // passive
+ status_t createTCPDatagramSession(
+ const struct in_addr &addr, unsigned port,
+ const sp<AMessage> &notify, int32_t *sessionID);
+
+ // active
+ status_t createTCPDatagramSession(
+ unsigned localPort,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID);
+
+ status_t destroySession(int32_t sessionID);
+
+ status_t sendRequest(
+ int32_t sessionID, const void *data, ssize_t size = -1);
+
+ enum NotificationReason {
+ kWhatError,
+ kWhatConnected,
+ kWhatClientConnected,
+ kWhatData,
+ kWhatDatagram,
+ kWhatBinaryData,
+ };
+
+protected:
+ virtual ~ANetworkSession();
+
+private:
+ struct NetworkThread;
+ struct Session;
+
+ Mutex mLock;
+ sp<Thread> mThread;
+
+ int32_t mNextSessionID;
+
+ int mPipeFd[2];
+
+ KeyedVector<int32_t, sp<Session> > mSessions;
+
+ enum Mode {
+ kModeCreateUDPSession,
+ kModeCreateTCPDatagramSessionPassive,
+ kModeCreateTCPDatagramSessionActive,
+ kModeCreateRTSPServer,
+ kModeCreateRTSPClient,
+ };
+ status_t createClientOrServer(
+ Mode mode,
+ const struct in_addr *addr,
+ unsigned port,
+ const char *remoteHost,
+ unsigned remotePort,
+ const sp<AMessage> &notify,
+ int32_t *sessionID);
+
+ void threadLoop();
+ void interrupt();
+
+ static status_t MakeSocketNonBlocking(int s);
+
+ DISALLOW_EVIL_CONSTRUCTORS(ANetworkSession);
+};
+
+} // namespace android
+
+#endif // A_NETWORK_SESSION_H_
diff --git a/media/libstagefright/wifi-display/Android.mk b/media/libstagefright/wifi-display/Android.mk
new file mode 100644
index 0000000..611bfff
--- /dev/null
+++ b/media/libstagefright/wifi-display/Android.mk
@@ -0,0 +1,84 @@
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ ANetworkSession.cpp \
+ Parameters.cpp \
+ ParsedMessage.cpp \
+ sink/LinearRegression.cpp \
+ sink/RTPSink.cpp \
+ sink/TunnelRenderer.cpp \
+ sink/WifiDisplaySink.cpp \
+ source/Converter.cpp \
+ source/MediaPuller.cpp \
+ source/PlaybackSession.cpp \
+ source/RepeaterSource.cpp \
+ source/Sender.cpp \
+ source/TSPacketizer.cpp \
+ source/WifiDisplaySource.cpp \
+
+LOCAL_C_INCLUDES:= \
+ $(TOP)/frameworks/av/media/libstagefright \
+ $(TOP)/frameworks/native/include/media/openmax \
+ $(TOP)/frameworks/av/media/libstagefright/mpeg2ts \
+
+LOCAL_SHARED_LIBRARIES:= \
+ libbinder \
+ libcutils \
+ libgui \
+ libmedia \
+ libstagefright \
+ libstagefright_foundation \
+ libui \
+ libutils \
+
+LOCAL_MODULE:= libstagefright_wfd
+
+LOCAL_MODULE_TAGS:= optional
+
+include $(BUILD_SHARED_LIBRARY)
+
+################################################################################
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ wfd.cpp \
+
+LOCAL_SHARED_LIBRARIES:= \
+ libbinder \
+ libgui \
+ libmedia \
+ libstagefright \
+ libstagefright_foundation \
+ libstagefright_wfd \
+ libutils \
+
+LOCAL_MODULE:= wfd
+
+LOCAL_MODULE_TAGS := debug
+
+include $(BUILD_EXECUTABLE)
+
+################################################################################
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ udptest.cpp \
+
+LOCAL_SHARED_LIBRARIES:= \
+ libbinder \
+ libgui \
+ libmedia \
+ libstagefright \
+ libstagefright_foundation \
+ libstagefright_wfd \
+ libutils \
+
+LOCAL_MODULE:= udptest
+
+LOCAL_MODULE_TAGS := debug
+
+include $(BUILD_EXECUTABLE)
diff --git a/media/libstagefright/wifi-display/Parameters.cpp b/media/libstagefright/wifi-display/Parameters.cpp
new file mode 100644
index 0000000..f7118b3
--- /dev/null
+++ b/media/libstagefright/wifi-display/Parameters.cpp
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "Parameters.h"
+
+#include <media/stagefright/MediaErrors.h>
+
+namespace android {
+
+// static
+sp<Parameters> Parameters::Parse(const char *data, size_t size) {
+ sp<Parameters> params = new Parameters;
+ status_t err = params->parse(data, size);
+
+ if (err != OK) {
+ return NULL;
+ }
+
+ return params;
+}
+
+Parameters::Parameters() {}
+
+Parameters::~Parameters() {}
+
+status_t Parameters::parse(const char *data, size_t size) {
+ size_t i = 0;
+ while (i < size) {
+ size_t nameStart = i;
+ while (i < size && data[i] != ':') {
+ ++i;
+ }
+
+ if (i == size || i == nameStart) {
+ return ERROR_MALFORMED;
+ }
+
+ AString name(&data[nameStart], i - nameStart);
+ name.trim();
+ name.tolower();
+
+ ++i;
+
+ size_t valueStart = i;
+
+ while (i + 1 < size && (data[i] != '\r' || data[i + 1] != '\n')) {
+ ++i;
+ }
+
+ AString value(&data[valueStart], i - valueStart);
+ value.trim();
+
+ mDict.add(name, value);
+
+ i += 2;
+ }
+
+ return OK;
+}
+
+bool Parameters::findParameter(const char *name, AString *value) const {
+ AString key = name;
+ key.tolower();
+
+ ssize_t index = mDict.indexOfKey(key);
+
+ if (index < 0) {
+ value->clear();
+
+ return false;
+ }
+
+ *value = mDict.valueAt(index);
+ return true;
+}
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/Parameters.h b/media/libstagefright/wifi-display/Parameters.h
new file mode 100644
index 0000000..a5e787e
--- /dev/null
+++ b/media/libstagefright/wifi-display/Parameters.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AString.h>
+#include <utils/KeyedVector.h>
+#include <utils/RefBase.h>
+
+namespace android {
+
+struct Parameters : public RefBase {
+ static sp<Parameters> Parse(const char *data, size_t size);
+
+ bool findParameter(const char *name, AString *value) const;
+
+protected:
+ virtual ~Parameters();
+
+private:
+ KeyedVector<AString, AString> mDict;
+
+ Parameters();
+ status_t parse(const char *data, size_t size);
+
+ DISALLOW_EVIL_CONSTRUCTORS(Parameters);
+};
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/ParsedMessage.cpp b/media/libstagefright/wifi-display/ParsedMessage.cpp
new file mode 100644
index 0000000..c0e60c3
--- /dev/null
+++ b/media/libstagefright/wifi-display/ParsedMessage.cpp
@@ -0,0 +1,284 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ParsedMessage.h"
+
+#include <ctype.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+namespace android {
+
+// static
+sp<ParsedMessage> ParsedMessage::Parse(
+ const char *data, size_t size, bool noMoreData, size_t *length) {
+ sp<ParsedMessage> msg = new ParsedMessage;
+ ssize_t res = msg->parse(data, size, noMoreData);
+
+ if (res < 0) {
+ *length = 0;
+ return NULL;
+ }
+
+ *length = res;
+ return msg;
+}
+
+ParsedMessage::ParsedMessage() {
+}
+
+ParsedMessage::~ParsedMessage() {
+}
+
+bool ParsedMessage::findString(const char *name, AString *value) const {
+ AString key = name;
+ key.tolower();
+
+ ssize_t index = mDict.indexOfKey(key);
+
+ if (index < 0) {
+ value->clear();
+
+ return false;
+ }
+
+ *value = mDict.valueAt(index);
+ return true;
+}
+
+bool ParsedMessage::findInt32(const char *name, int32_t *value) const {
+ AString stringValue;
+
+ if (!findString(name, &stringValue)) {
+ return false;
+ }
+
+ char *end;
+ *value = strtol(stringValue.c_str(), &end, 10);
+
+ if (end == stringValue.c_str() || *end != '\0') {
+ *value = 0;
+ return false;
+ }
+
+ return true;
+}
+
+const char *ParsedMessage::getContent() const {
+ return mContent.c_str();
+}
+
+ssize_t ParsedMessage::parse(const char *data, size_t size, bool noMoreData) {
+ if (size == 0) {
+ return -1;
+ }
+
+ ssize_t lastDictIndex = -1;
+
+ size_t offset = 0;
+ while (offset < size) {
+ size_t lineEndOffset = offset;
+ while (lineEndOffset + 1 < size
+ && (data[lineEndOffset] != '\r'
+ || data[lineEndOffset + 1] != '\n')) {
+ ++lineEndOffset;
+ }
+
+ if (lineEndOffset + 1 >= size) {
+ return -1;
+ }
+
+ AString line(&data[offset], lineEndOffset - offset);
+
+ if (offset == 0) {
+ // Special handling for the request/status line.
+
+ mDict.add(AString("_"), line);
+ offset = lineEndOffset + 2;
+
+ continue;
+ }
+
+ if (lineEndOffset == offset) {
+ offset += 2;
+ break;
+ }
+
+ if (line.c_str()[0] == ' ' || line.c_str()[0] == '\t') {
+ // Support for folded header values.
+
+ if (lastDictIndex >= 0) {
+ // Otherwise it's malformed since the first header line
+ // cannot continue anything...
+
+ AString &value = mDict.editValueAt(lastDictIndex);
+ value.append(line);
+ }
+
+ offset = lineEndOffset + 2;
+ continue;
+ }
+
+ ssize_t colonPos = line.find(":");
+ if (colonPos >= 0) {
+ AString key(line, 0, colonPos);
+ key.trim();
+ key.tolower();
+
+ line.erase(0, colonPos + 1);
+
+ lastDictIndex = mDict.add(key, line);
+ }
+
+ offset = lineEndOffset + 2;
+ }
+
+ for (size_t i = 0; i < mDict.size(); ++i) {
+ mDict.editValueAt(i).trim();
+ }
+
+ // Found the end of headers.
+
+ int32_t contentLength;
+ if (!findInt32("content-length", &contentLength) || contentLength < 0) {
+ contentLength = 0;
+ }
+
+ size_t totalLength = offset + contentLength;
+
+ if (size < totalLength) {
+ return -1;
+ }
+
+ mContent.setTo(&data[offset], contentLength);
+
+ return totalLength;
+}
+
+void ParsedMessage::getRequestField(size_t index, AString *field) const {
+ AString line;
+ CHECK(findString("_", &line));
+
+ size_t prevOffset = 0;
+ size_t offset = 0;
+ for (size_t i = 0; i <= index; ++i) {
+ ssize_t spacePos = line.find(" ", offset);
+
+ if (spacePos < 0) {
+ spacePos = line.size();
+ }
+
+ prevOffset = offset;
+ offset = spacePos + 1;
+ }
+
+ field->setTo(line, prevOffset, offset - prevOffset - 1);
+}
+
+bool ParsedMessage::getStatusCode(int32_t *statusCode) const {
+ AString statusCodeString;
+ getRequestField(1, &statusCodeString);
+
+ char *end;
+ *statusCode = strtol(statusCodeString.c_str(), &end, 10);
+
+ if (*end != '\0' || end == statusCodeString.c_str()
+ || (*statusCode) < 100 || (*statusCode) > 999) {
+ *statusCode = 0;
+ return false;
+ }
+
+ return true;
+}
+
+AString ParsedMessage::debugString() const {
+ AString line;
+ CHECK(findString("_", &line));
+
+ line.append("\n");
+
+ for (size_t i = 0; i < mDict.size(); ++i) {
+ const AString &key = mDict.keyAt(i);
+ const AString &value = mDict.valueAt(i);
+
+ if (key == AString("_")) {
+ continue;
+ }
+
+ line.append(key);
+ line.append(": ");
+ line.append(value);
+ line.append("\n");
+ }
+
+ line.append("\n");
+ line.append(mContent);
+
+ return line;
+}
+
+// static
+bool ParsedMessage::GetAttribute(
+ const char *s, const char *key, AString *value) {
+ value->clear();
+
+ size_t keyLen = strlen(key);
+
+ for (;;) {
+ while (isspace(*s)) {
+ ++s;
+ }
+
+ const char *colonPos = strchr(s, ';');
+
+ size_t len =
+ (colonPos == NULL) ? strlen(s) : colonPos - s;
+
+ if (len >= keyLen + 1 && s[keyLen] == '=' && !strncmp(s, key, keyLen)) {
+ value->setTo(&s[keyLen + 1], len - keyLen - 1);
+ return true;
+ }
+
+ if (colonPos == NULL) {
+ return false;
+ }
+
+ s = colonPos + 1;
+ }
+}
+
+// static
+bool ParsedMessage::GetInt32Attribute(
+ const char *s, const char *key, int32_t *value) {
+ AString stringValue;
+ if (!GetAttribute(s, key, &stringValue)) {
+ *value = 0;
+ return false;
+ }
+
+ char *end;
+ *value = strtol(stringValue.c_str(), &end, 10);
+
+ if (end == stringValue.c_str() || *end != '\0') {
+ *value = 0;
+ return false;
+ }
+
+ return true;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/ParsedMessage.h b/media/libstagefright/wifi-display/ParsedMessage.h
new file mode 100644
index 0000000..e9a1859
--- /dev/null
+++ b/media/libstagefright/wifi-display/ParsedMessage.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AString.h>
+#include <utils/KeyedVector.h>
+#include <utils/RefBase.h>
+
+namespace android {
+
+// Encapsulates an "HTTP/RTSP style" response, i.e. a status line,
+// key/value pairs making up the headers and an optional body/content.
+struct ParsedMessage : public RefBase {
+ static sp<ParsedMessage> Parse(
+ const char *data, size_t size, bool noMoreData, size_t *length);
+
+ bool findString(const char *name, AString *value) const;
+ bool findInt32(const char *name, int32_t *value) const;
+
+ const char *getContent() const;
+
+ void getRequestField(size_t index, AString *field) const;
+ bool getStatusCode(int32_t *statusCode) const;
+
+ AString debugString() const;
+
+ static bool GetAttribute(const char *s, const char *key, AString *value);
+
+ static bool GetInt32Attribute(
+ const char *s, const char *key, int32_t *value);
+
+
+protected:
+ virtual ~ParsedMessage();
+
+private:
+ KeyedVector<AString, AString> mDict;
+ AString mContent;
+
+ ParsedMessage();
+
+ ssize_t parse(const char *data, size_t size, bool noMoreData);
+
+ DISALLOW_EVIL_CONSTRUCTORS(ParsedMessage);
+};
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/sink/LinearRegression.cpp b/media/libstagefright/wifi-display/sink/LinearRegression.cpp
new file mode 100644
index 0000000..8cfce37
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/LinearRegression.cpp
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "LinearRegression"
+#include <utils/Log.h>
+
+#include "LinearRegression.h"
+
+#include <math.h>
+#include <string.h>
+
+namespace android {
+
+LinearRegression::LinearRegression(size_t historySize)
+ : mHistorySize(historySize),
+ mCount(0),
+ mHistory(new Point[mHistorySize]),
+ mSumX(0.0),
+ mSumY(0.0) {
+}
+
+LinearRegression::~LinearRegression() {
+ delete[] mHistory;
+ mHistory = NULL;
+}
+
+void LinearRegression::addPoint(float x, float y) {
+ if (mCount == mHistorySize) {
+ const Point &oldest = mHistory[0];
+
+ mSumX -= oldest.mX;
+ mSumY -= oldest.mY;
+
+ memmove(&mHistory[0], &mHistory[1], (mHistorySize - 1) * sizeof(Point));
+ --mCount;
+ }
+
+ Point *newest = &mHistory[mCount++];
+ newest->mX = x;
+ newest->mY = y;
+
+ mSumX += x;
+ mSumY += y;
+}
+
+bool LinearRegression::approxLine(float *n1, float *n2, float *b) const {
+ static const float kEpsilon = 1.0E-4;
+
+ if (mCount < 2) {
+ return false;
+ }
+
+ float sumX2 = 0.0f;
+ float sumY2 = 0.0f;
+ float sumXY = 0.0f;
+
+ float meanX = mSumX / (float)mCount;
+ float meanY = mSumY / (float)mCount;
+
+ for (size_t i = 0; i < mCount; ++i) {
+ const Point &p = mHistory[i];
+
+ float x = p.mX - meanX;
+ float y = p.mY - meanY;
+
+ sumX2 += x * x;
+ sumY2 += y * y;
+ sumXY += x * y;
+ }
+
+ float T = sumX2 + sumY2;
+ float D = sumX2 * sumY2 - sumXY * sumXY;
+ float root = sqrt(T * T * 0.25 - D);
+
+ float L1 = T * 0.5 - root;
+
+ if (fabs(sumXY) > kEpsilon) {
+ *n1 = 1.0;
+ *n2 = (2.0 * L1 - sumX2) / sumXY;
+
+ float mag = sqrt((*n1) * (*n1) + (*n2) * (*n2));
+
+ *n1 /= mag;
+ *n2 /= mag;
+ } else {
+ *n1 = 0.0;
+ *n2 = 1.0;
+ }
+
+ *b = (*n1) * meanX + (*n2) * meanY;
+
+ return true;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/sink/LinearRegression.h b/media/libstagefright/wifi-display/sink/LinearRegression.h
new file mode 100644
index 0000000..ca6f5a1
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/LinearRegression.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef LINEAR_REGRESSION_H_
+
+#define LINEAR_REGRESSION_H_
+
+#include <sys/types.h>
+#include <media/stagefright/foundation/ABase.h>
+
+namespace android {
+
+// Helper class to fit a line to a set of points minimizing the sum of
+// squared (orthogonal) distances from line to individual points.
+struct LinearRegression {
+ LinearRegression(size_t historySize);
+ ~LinearRegression();
+
+ void addPoint(float x, float y);
+
+ bool approxLine(float *n1, float *n2, float *b) const;
+
+private:
+ struct Point {
+ float mX, mY;
+ };
+
+ size_t mHistorySize;
+ size_t mCount;
+ Point *mHistory;
+
+ float mSumX, mSumY;
+
+ DISALLOW_EVIL_CONSTRUCTORS(LinearRegression);
+};
+
+} // namespace android
+
+#endif // LINEAR_REGRESSION_H_
diff --git a/media/libstagefright/wifi-display/sink/RTPSink.cpp b/media/libstagefright/wifi-display/sink/RTPSink.cpp
new file mode 100644
index 0000000..0918034
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/RTPSink.cpp
@@ -0,0 +1,806 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "RTPSink"
+#include <utils/Log.h>
+
+#include "RTPSink.h"
+
+#include "ANetworkSession.h"
+#include "TunnelRenderer.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/Utils.h>
+
+namespace android {
+
+struct RTPSink::Source : public RefBase {
+ Source(uint16_t seq, const sp<ABuffer> &buffer,
+ const sp<AMessage> queueBufferMsg);
+
+ bool updateSeq(uint16_t seq, const sp<ABuffer> &buffer);
+
+ void addReportBlock(uint32_t ssrc, const sp<ABuffer> &buf);
+
+protected:
+ virtual ~Source();
+
+private:
+ static const uint32_t kMinSequential = 2;
+ static const uint32_t kMaxDropout = 3000;
+ static const uint32_t kMaxMisorder = 100;
+ static const uint32_t kRTPSeqMod = 1u << 16;
+
+ sp<AMessage> mQueueBufferMsg;
+
+ uint16_t mMaxSeq;
+ uint32_t mCycles;
+ uint32_t mBaseSeq;
+ uint32_t mBadSeq;
+ uint32_t mProbation;
+ uint32_t mReceived;
+ uint32_t mExpectedPrior;
+ uint32_t mReceivedPrior;
+
+ void initSeq(uint16_t seq);
+ void queuePacket(const sp<ABuffer> &buffer);
+
+ DISALLOW_EVIL_CONSTRUCTORS(Source);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+RTPSink::Source::Source(
+ uint16_t seq, const sp<ABuffer> &buffer,
+ const sp<AMessage> queueBufferMsg)
+ : mQueueBufferMsg(queueBufferMsg),
+ mProbation(kMinSequential) {
+ initSeq(seq);
+ mMaxSeq = seq - 1;
+
+ buffer->setInt32Data(mCycles | seq);
+ queuePacket(buffer);
+}
+
+RTPSink::Source::~Source() {
+}
+
+void RTPSink::Source::initSeq(uint16_t seq) {
+ mMaxSeq = seq;
+ mCycles = 0;
+ mBaseSeq = seq;
+ mBadSeq = kRTPSeqMod + 1;
+ mReceived = 0;
+ mExpectedPrior = 0;
+ mReceivedPrior = 0;
+}
+
+bool RTPSink::Source::updateSeq(uint16_t seq, const sp<ABuffer> &buffer) {
+ uint16_t udelta = seq - mMaxSeq;
+
+ if (mProbation) {
+ // Startup phase
+
+ if (seq == mMaxSeq + 1) {
+ buffer->setInt32Data(mCycles | seq);
+ queuePacket(buffer);
+
+ --mProbation;
+ mMaxSeq = seq;
+ if (mProbation == 0) {
+ initSeq(seq);
+ ++mReceived;
+
+ return true;
+ }
+ } else {
+ // Packet out of sequence, restart startup phase
+
+ mProbation = kMinSequential - 1;
+ mMaxSeq = seq;
+
+#if 0
+ mPackets.clear();
+ mTotalBytesQueued = 0;
+ ALOGI("XXX cleared packets");
+#endif
+
+ buffer->setInt32Data(mCycles | seq);
+ queuePacket(buffer);
+ }
+
+ return false;
+ }
+
+ if (udelta < kMaxDropout) {
+ // In order, with permissible gap.
+
+ if (seq < mMaxSeq) {
+ // Sequence number wrapped - count another 64K cycle
+ mCycles += kRTPSeqMod;
+ }
+
+ mMaxSeq = seq;
+ } else if (udelta <= kRTPSeqMod - kMaxMisorder) {
+ // The sequence number made a very large jump
+
+ if (seq == mBadSeq) {
+ // Two sequential packets -- assume that the other side
+ // restarted without telling us so just re-sync
+ // (i.e. pretend this was the first packet)
+
+ initSeq(seq);
+ } else {
+ mBadSeq = (seq + 1) & (kRTPSeqMod - 1);
+
+ return false;
+ }
+ } else {
+ // Duplicate or reordered packet.
+ }
+
+ ++mReceived;
+
+ buffer->setInt32Data(mCycles | seq);
+ queuePacket(buffer);
+
+ return true;
+}
+
+void RTPSink::Source::queuePacket(const sp<ABuffer> &buffer) {
+ sp<AMessage> msg = mQueueBufferMsg->dup();
+ msg->setBuffer("buffer", buffer);
+ msg->post();
+}
+
+void RTPSink::Source::addReportBlock(
+ uint32_t ssrc, const sp<ABuffer> &buf) {
+ uint32_t extMaxSeq = mMaxSeq | mCycles;
+ uint32_t expected = extMaxSeq - mBaseSeq + 1;
+
+ int64_t lost = (int64_t)expected - (int64_t)mReceived;
+ if (lost > 0x7fffff) {
+ lost = 0x7fffff;
+ } else if (lost < -0x800000) {
+ lost = -0x800000;
+ }
+
+ uint32_t expectedInterval = expected - mExpectedPrior;
+ mExpectedPrior = expected;
+
+ uint32_t receivedInterval = mReceived - mReceivedPrior;
+ mReceivedPrior = mReceived;
+
+ int64_t lostInterval = expectedInterval - receivedInterval;
+
+ uint8_t fractionLost;
+ if (expectedInterval == 0 || lostInterval <=0) {
+ fractionLost = 0;
+ } else {
+ fractionLost = (lostInterval << 8) / expectedInterval;
+ }
+
+ uint8_t *ptr = buf->data() + buf->size();
+
+ ptr[0] = ssrc >> 24;
+ ptr[1] = (ssrc >> 16) & 0xff;
+ ptr[2] = (ssrc >> 8) & 0xff;
+ ptr[3] = ssrc & 0xff;
+
+ ptr[4] = fractionLost;
+
+ ptr[5] = (lost >> 16) & 0xff;
+ ptr[6] = (lost >> 8) & 0xff;
+ ptr[7] = lost & 0xff;
+
+ ptr[8] = extMaxSeq >> 24;
+ ptr[9] = (extMaxSeq >> 16) & 0xff;
+ ptr[10] = (extMaxSeq >> 8) & 0xff;
+ ptr[11] = extMaxSeq & 0xff;
+
+ // XXX TODO:
+
+ ptr[12] = 0x00; // interarrival jitter
+ ptr[13] = 0x00;
+ ptr[14] = 0x00;
+ ptr[15] = 0x00;
+
+ ptr[16] = 0x00; // last SR
+ ptr[17] = 0x00;
+ ptr[18] = 0x00;
+ ptr[19] = 0x00;
+
+ ptr[20] = 0x00; // delay since last SR
+ ptr[21] = 0x00;
+ ptr[22] = 0x00;
+ ptr[23] = 0x00;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+RTPSink::RTPSink(
+ const sp<ANetworkSession> &netSession,
+ const sp<ISurfaceTexture> &surfaceTex)
+ : mNetSession(netSession),
+ mSurfaceTex(surfaceTex),
+ mRTPPort(0),
+ mRTPSessionID(0),
+ mRTCPSessionID(0),
+ mFirstArrivalTimeUs(-1ll),
+ mNumPacketsReceived(0ll),
+ mRegression(1000),
+ mMaxDelayMs(-1ll) {
+}
+
+RTPSink::~RTPSink() {
+ if (mRTCPSessionID != 0) {
+ mNetSession->destroySession(mRTCPSessionID);
+ }
+
+ if (mRTPSessionID != 0) {
+ mNetSession->destroySession(mRTPSessionID);
+ }
+}
+
+status_t RTPSink::init(bool useTCPInterleaving) {
+ if (useTCPInterleaving) {
+ return OK;
+ }
+
+ int clientRtp;
+
+ sp<AMessage> rtpNotify = new AMessage(kWhatRTPNotify, id());
+ sp<AMessage> rtcpNotify = new AMessage(kWhatRTCPNotify, id());
+ for (clientRtp = 15550;; clientRtp += 2) {
+ int32_t rtpSession;
+ status_t err = mNetSession->createUDPSession(
+ clientRtp, rtpNotify, &rtpSession);
+
+ if (err != OK) {
+ ALOGI("failed to create RTP socket on port %d", clientRtp);
+ continue;
+ }
+
+ int32_t rtcpSession;
+ err = mNetSession->createUDPSession(
+ clientRtp + 1, rtcpNotify, &rtcpSession);
+
+ if (err == OK) {
+ mRTPPort = clientRtp;
+ mRTPSessionID = rtpSession;
+ mRTCPSessionID = rtcpSession;
+ break;
+ }
+
+ ALOGI("failed to create RTCP socket on port %d", clientRtp + 1);
+ mNetSession->destroySession(rtpSession);
+ }
+
+ if (mRTPPort == 0) {
+ return UNKNOWN_ERROR;
+ }
+
+ return OK;
+}
+
+int32_t RTPSink::getRTPPort() const {
+ return mRTPPort;
+}
+
+void RTPSink::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatRTPNotify:
+ case kWhatRTCPNotify:
+ {
+ int32_t reason;
+ CHECK(msg->findInt32("reason", &reason));
+
+ switch (reason) {
+ case ANetworkSession::kWhatError:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ int32_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ AString detail;
+ CHECK(msg->findString("detail", &detail));
+
+ ALOGE("An error occurred in session %d (%d, '%s/%s').",
+ sessionID,
+ err,
+ detail.c_str(),
+ strerror(-err));
+
+ mNetSession->destroySession(sessionID);
+
+ if (sessionID == mRTPSessionID) {
+ mRTPSessionID = 0;
+ } else if (sessionID == mRTCPSessionID) {
+ mRTCPSessionID = 0;
+ }
+ break;
+ }
+
+ case ANetworkSession::kWhatDatagram:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ sp<ABuffer> data;
+ CHECK(msg->findBuffer("data", &data));
+
+ status_t err;
+ if (msg->what() == kWhatRTPNotify) {
+ err = parseRTP(data);
+ } else {
+ err = parseRTCP(data);
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+ break;
+ }
+
+ case kWhatSendRR:
+ {
+ onSendRR();
+ break;
+ }
+
+ case kWhatPacketLost:
+ {
+ onPacketLost(msg);
+ break;
+ }
+
+ case kWhatInject:
+ {
+ int32_t isRTP;
+ CHECK(msg->findInt32("isRTP", &isRTP));
+
+ sp<ABuffer> buffer;
+ CHECK(msg->findBuffer("buffer", &buffer));
+
+ status_t err;
+ if (isRTP) {
+ err = parseRTP(buffer);
+ } else {
+ err = parseRTCP(buffer);
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+status_t RTPSink::injectPacket(bool isRTP, const sp<ABuffer> &buffer) {
+ sp<AMessage> msg = new AMessage(kWhatInject, id());
+ msg->setInt32("isRTP", isRTP);
+ msg->setBuffer("buffer", buffer);
+ msg->post();
+
+ return OK;
+}
+
+status_t RTPSink::parseRTP(const sp<ABuffer> &buffer) {
+ size_t size = buffer->size();
+ if (size < 12) {
+ // Too short to be a valid RTP header.
+ return ERROR_MALFORMED;
+ }
+
+ const uint8_t *data = buffer->data();
+
+ if ((data[0] >> 6) != 2) {
+ // Unsupported version.
+ return ERROR_UNSUPPORTED;
+ }
+
+ if (data[0] & 0x20) {
+ // Padding present.
+
+ size_t paddingLength = data[size - 1];
+
+ if (paddingLength + 12 > size) {
+ // If we removed this much padding we'd end up with something
+ // that's too short to be a valid RTP header.
+ return ERROR_MALFORMED;
+ }
+
+ size -= paddingLength;
+ }
+
+ int numCSRCs = data[0] & 0x0f;
+
+ size_t payloadOffset = 12 + 4 * numCSRCs;
+
+ if (size < payloadOffset) {
+ // Not enough data to fit the basic header and all the CSRC entries.
+ return ERROR_MALFORMED;
+ }
+
+ if (data[0] & 0x10) {
+ // Header eXtension present.
+
+ if (size < payloadOffset + 4) {
+ // Not enough data to fit the basic header, all CSRC entries
+ // and the first 4 bytes of the extension header.
+
+ return ERROR_MALFORMED;
+ }
+
+ const uint8_t *extensionData = &data[payloadOffset];
+
+ size_t extensionLength =
+ 4 * (extensionData[2] << 8 | extensionData[3]);
+
+ if (size < payloadOffset + 4 + extensionLength) {
+ return ERROR_MALFORMED;
+ }
+
+ payloadOffset += 4 + extensionLength;
+ }
+
+ uint32_t srcId = U32_AT(&data[8]);
+ uint32_t rtpTime = U32_AT(&data[4]);
+ uint16_t seqNo = U16_AT(&data[2]);
+
+ int64_t arrivalTimeUs;
+ CHECK(buffer->meta()->findInt64("arrivalTimeUs", &arrivalTimeUs));
+
+ if (mFirstArrivalTimeUs < 0ll) {
+ mFirstArrivalTimeUs = arrivalTimeUs;
+ }
+ arrivalTimeUs -= mFirstArrivalTimeUs;
+
+ int64_t arrivalTimeMedia = (arrivalTimeUs * 9ll) / 100ll;
+
+ ALOGV("seqNo: %d, SSRC 0x%08x, diff %lld",
+ seqNo, srcId, rtpTime - arrivalTimeMedia);
+
+ mRegression.addPoint((float)rtpTime, (float)arrivalTimeMedia);
+
+ ++mNumPacketsReceived;
+
+ float n1, n2, b;
+ if (mRegression.approxLine(&n1, &n2, &b)) {
+ ALOGV("Line %lld: %.2f %.2f %.2f, slope %.2f",
+ mNumPacketsReceived, n1, n2, b, -n1 / n2);
+
+ float expectedArrivalTimeMedia = (b - n1 * (float)rtpTime) / n2;
+ float latenessMs = (arrivalTimeMedia - expectedArrivalTimeMedia) / 90.0;
+
+ if (mMaxDelayMs < 0ll || latenessMs > mMaxDelayMs) {
+ mMaxDelayMs = latenessMs;
+ ALOGI("packet was %.2f ms late", latenessMs);
+ }
+ }
+
+ sp<AMessage> meta = buffer->meta();
+ meta->setInt32("ssrc", srcId);
+ meta->setInt32("rtp-time", rtpTime);
+ meta->setInt32("PT", data[1] & 0x7f);
+ meta->setInt32("M", data[1] >> 7);
+
+ buffer->setRange(payloadOffset, size - payloadOffset);
+
+ ssize_t index = mSources.indexOfKey(srcId);
+ if (index < 0) {
+ if (mRenderer == NULL) {
+ sp<AMessage> notifyLost = new AMessage(kWhatPacketLost, id());
+ notifyLost->setInt32("ssrc", srcId);
+
+ mRenderer = new TunnelRenderer(notifyLost, mSurfaceTex);
+ looper()->registerHandler(mRenderer);
+ }
+
+ sp<AMessage> queueBufferMsg =
+ new AMessage(TunnelRenderer::kWhatQueueBuffer, mRenderer->id());
+
+ sp<Source> source = new Source(seqNo, buffer, queueBufferMsg);
+ mSources.add(srcId, source);
+ } else {
+ mSources.valueAt(index)->updateSeq(seqNo, buffer);
+ }
+
+ return OK;
+}
+
+status_t RTPSink::parseRTCP(const sp<ABuffer> &buffer) {
+ const uint8_t *data = buffer->data();
+ size_t size = buffer->size();
+
+ while (size > 0) {
+ if (size < 8) {
+ // Too short to be a valid RTCP header
+ return ERROR_MALFORMED;
+ }
+
+ if ((data[0] >> 6) != 2) {
+ // Unsupported version.
+ return ERROR_UNSUPPORTED;
+ }
+
+ if (data[0] & 0x20) {
+ // Padding present.
+
+ size_t paddingLength = data[size - 1];
+
+ if (paddingLength + 12 > size) {
+ // If we removed this much padding we'd end up with something
+ // that's too short to be a valid RTP header.
+ return ERROR_MALFORMED;
+ }
+
+ size -= paddingLength;
+ }
+
+ size_t headerLength = 4 * (data[2] << 8 | data[3]) + 4;
+
+ if (size < headerLength) {
+ // Only received a partial packet?
+ return ERROR_MALFORMED;
+ }
+
+ switch (data[1]) {
+ case 200:
+ {
+ parseSR(data, headerLength);
+ break;
+ }
+
+ case 201: // RR
+ case 202: // SDES
+ case 204: // APP
+ break;
+
+ case 205: // TSFB (transport layer specific feedback)
+ case 206: // PSFB (payload specific feedback)
+ // hexdump(data, headerLength);
+ break;
+
+ case 203:
+ {
+ parseBYE(data, headerLength);
+ break;
+ }
+
+ default:
+ {
+ ALOGW("Unknown RTCP packet type %u of size %d",
+ (unsigned)data[1], headerLength);
+ break;
+ }
+ }
+
+ data += headerLength;
+ size -= headerLength;
+ }
+
+ return OK;
+}
+
+status_t RTPSink::parseBYE(const uint8_t *data, size_t size) {
+ size_t SC = data[0] & 0x3f;
+
+ if (SC == 0 || size < (4 + SC * 4)) {
+ // Packet too short for the minimal BYE header.
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t id = U32_AT(&data[4]);
+
+ return OK;
+}
+
+status_t RTPSink::parseSR(const uint8_t *data, size_t size) {
+ size_t RC = data[0] & 0x1f;
+
+ if (size < (7 + RC * 6) * 4) {
+ // Packet too short for the minimal SR header.
+ return ERROR_MALFORMED;
+ }
+
+ uint32_t id = U32_AT(&data[4]);
+ uint64_t ntpTime = U64_AT(&data[8]);
+ uint32_t rtpTime = U32_AT(&data[16]);
+
+ ALOGV("SR: ssrc 0x%08x, ntpTime 0x%016llx, rtpTime 0x%08x",
+ id, ntpTime, rtpTime);
+
+ return OK;
+}
+
+status_t RTPSink::connect(
+ const char *host, int32_t remoteRtpPort, int32_t remoteRtcpPort) {
+ ALOGI("connecting RTP/RTCP sockets to %s:{%d,%d}",
+ host, remoteRtpPort, remoteRtcpPort);
+
+ status_t err =
+ mNetSession->connectUDPSession(mRTPSessionID, host, remoteRtpPort);
+
+ if (err != OK) {
+ return err;
+ }
+
+ err = mNetSession->connectUDPSession(mRTCPSessionID, host, remoteRtcpPort);
+
+ if (err != OK) {
+ return err;
+ }
+
+#if 0
+ sp<ABuffer> buf = new ABuffer(1500);
+ memset(buf->data(), 0, buf->size());
+
+ mNetSession->sendRequest(
+ mRTPSessionID, buf->data(), buf->size());
+
+ mNetSession->sendRequest(
+ mRTCPSessionID, buf->data(), buf->size());
+#endif
+
+ scheduleSendRR();
+
+ return OK;
+}
+
+void RTPSink::scheduleSendRR() {
+ (new AMessage(kWhatSendRR, id()))->post(2000000ll);
+}
+
+void RTPSink::addSDES(const sp<ABuffer> &buffer) {
+ uint8_t *data = buffer->data() + buffer->size();
+ data[0] = 0x80 | 1;
+ data[1] = 202; // SDES
+ data[4] = 0xde; // SSRC
+ data[5] = 0xad;
+ data[6] = 0xbe;
+ data[7] = 0xef;
+
+ size_t offset = 8;
+
+ data[offset++] = 1; // CNAME
+
+ AString cname = "stagefright@somewhere";
+ data[offset++] = cname.size();
+
+ memcpy(&data[offset], cname.c_str(), cname.size());
+ offset += cname.size();
+
+ data[offset++] = 6; // TOOL
+
+ AString tool = "stagefright/1.0";
+ data[offset++] = tool.size();
+
+ memcpy(&data[offset], tool.c_str(), tool.size());
+ offset += tool.size();
+
+ data[offset++] = 0;
+
+ if ((offset % 4) > 0) {
+ size_t count = 4 - (offset % 4);
+ switch (count) {
+ case 3:
+ data[offset++] = 0;
+ case 2:
+ data[offset++] = 0;
+ case 1:
+ data[offset++] = 0;
+ }
+ }
+
+ size_t numWords = (offset / 4) - 1;
+ data[2] = numWords >> 8;
+ data[3] = numWords & 0xff;
+
+ buffer->setRange(buffer->offset(), buffer->size() + offset);
+}
+
+void RTPSink::onSendRR() {
+ sp<ABuffer> buf = new ABuffer(1500);
+ buf->setRange(0, 0);
+
+ uint8_t *ptr = buf->data();
+ ptr[0] = 0x80 | 0;
+ ptr[1] = 201; // RR
+ ptr[2] = 0;
+ ptr[3] = 1;
+ ptr[4] = 0xde; // SSRC
+ ptr[5] = 0xad;
+ ptr[6] = 0xbe;
+ ptr[7] = 0xef;
+
+ buf->setRange(0, 8);
+
+ size_t numReportBlocks = 0;
+ for (size_t i = 0; i < mSources.size(); ++i) {
+ uint32_t ssrc = mSources.keyAt(i);
+ sp<Source> source = mSources.valueAt(i);
+
+ if (numReportBlocks > 31 || buf->size() + 24 > buf->capacity()) {
+ // Cannot fit another report block.
+ break;
+ }
+
+ source->addReportBlock(ssrc, buf);
+ ++numReportBlocks;
+ }
+
+ ptr[0] |= numReportBlocks; // 5 bit
+
+ size_t sizeInWordsMinus1 = 1 + 6 * numReportBlocks;
+ ptr[2] = sizeInWordsMinus1 >> 8;
+ ptr[3] = sizeInWordsMinus1 & 0xff;
+
+ buf->setRange(0, (sizeInWordsMinus1 + 1) * 4);
+
+ addSDES(buf);
+
+ mNetSession->sendRequest(mRTCPSessionID, buf->data(), buf->size());
+
+ scheduleSendRR();
+}
+
+void RTPSink::onPacketLost(const sp<AMessage> &msg) {
+ uint32_t srcId;
+ CHECK(msg->findInt32("ssrc", (int32_t *)&srcId));
+
+ int32_t seqNo;
+ CHECK(msg->findInt32("seqNo", &seqNo));
+
+ int32_t blp = 0;
+
+ sp<ABuffer> buf = new ABuffer(1500);
+ buf->setRange(0, 0);
+
+ uint8_t *ptr = buf->data();
+ ptr[0] = 0x80 | 1; // generic NACK
+ ptr[1] = 205; // RTPFB
+ ptr[2] = 0;
+ ptr[3] = 3;
+ ptr[4] = 0xde; // sender SSRC
+ ptr[5] = 0xad;
+ ptr[6] = 0xbe;
+ ptr[7] = 0xef;
+ ptr[8] = (srcId >> 24) & 0xff;
+ ptr[9] = (srcId >> 16) & 0xff;
+ ptr[10] = (srcId >> 8) & 0xff;
+ ptr[11] = (srcId & 0xff);
+ ptr[12] = (seqNo >> 8) & 0xff;
+ ptr[13] = (seqNo & 0xff);
+ ptr[14] = (blp >> 8) & 0xff;
+ ptr[15] = (blp & 0xff);
+
+ buf->setRange(0, 16);
+
+ mNetSession->sendRequest(mRTCPSessionID, buf->data(), buf->size());
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/sink/RTPSink.h b/media/libstagefright/wifi-display/sink/RTPSink.h
new file mode 100644
index 0000000..a1d127d
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/RTPSink.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef RTP_SINK_H_
+
+#define RTP_SINK_H_
+
+#include <media/stagefright/foundation/AHandler.h>
+
+#include "LinearRegression.h"
+
+#include <gui/Surface.h>
+
+namespace android {
+
+struct ABuffer;
+struct ANetworkSession;
+struct TunnelRenderer;
+
+// Creates a pair of sockets for RTP/RTCP traffic, instantiates a renderer
+// for incoming transport stream data and occasionally sends statistics over
+// the RTCP channel.
+struct RTPSink : public AHandler {
+ RTPSink(const sp<ANetworkSession> &netSession,
+ const sp<ISurfaceTexture> &surfaceTex);
+
+ // If TCP interleaving is used, no UDP sockets are created, instead
+ // incoming RTP/RTCP packets (arriving on the RTSP control connection)
+ // are manually injected by WifiDisplaySink.
+ status_t init(bool useTCPInterleaving);
+
+ status_t connect(
+ const char *host, int32_t remoteRtpPort, int32_t remoteRtcpPort);
+
+ int32_t getRTPPort() const;
+
+ status_t injectPacket(bool isRTP, const sp<ABuffer> &buffer);
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~RTPSink();
+
+private:
+ enum {
+ kWhatRTPNotify,
+ kWhatRTCPNotify,
+ kWhatSendRR,
+ kWhatPacketLost,
+ kWhatInject,
+ };
+
+ struct Source;
+ struct StreamSource;
+
+ sp<ANetworkSession> mNetSession;
+ sp<ISurfaceTexture> mSurfaceTex;
+ KeyedVector<uint32_t, sp<Source> > mSources;
+
+ int32_t mRTPPort;
+ int32_t mRTPSessionID;
+ int32_t mRTCPSessionID;
+
+ int64_t mFirstArrivalTimeUs;
+ int64_t mNumPacketsReceived;
+ LinearRegression mRegression;
+ int64_t mMaxDelayMs;
+
+ sp<TunnelRenderer> mRenderer;
+
+ status_t parseRTP(const sp<ABuffer> &buffer);
+ status_t parseRTCP(const sp<ABuffer> &buffer);
+ status_t parseBYE(const uint8_t *data, size_t size);
+ status_t parseSR(const uint8_t *data, size_t size);
+
+ void addSDES(const sp<ABuffer> &buffer);
+ void onSendRR();
+ void onPacketLost(const sp<AMessage> &msg);
+ void scheduleSendRR();
+
+ DISALLOW_EVIL_CONSTRUCTORS(RTPSink);
+};
+
+} // namespace android
+
+#endif // RTP_SINK_H_
diff --git a/media/libstagefright/wifi-display/sink/TunnelRenderer.cpp b/media/libstagefright/wifi-display/sink/TunnelRenderer.cpp
new file mode 100644
index 0000000..bc35aef
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/TunnelRenderer.cpp
@@ -0,0 +1,396 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "TunnelRenderer"
+#include <utils/Log.h>
+
+#include "TunnelRenderer.h"
+
+#include "ATSParser.h"
+
+#include <binder/IMemory.h>
+#include <binder/IServiceManager.h>
+#include <gui/SurfaceComposerClient.h>
+#include <media/IMediaPlayerService.h>
+#include <media/IStreamSource.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <ui/DisplayInfo.h>
+
+namespace android {
+
+struct TunnelRenderer::PlayerClient : public BnMediaPlayerClient {
+ PlayerClient() {}
+
+ virtual void notify(int msg, int ext1, int ext2, const Parcel *obj) {
+ ALOGI("notify %d, %d, %d", msg, ext1, ext2);
+ }
+
+protected:
+ virtual ~PlayerClient() {}
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(PlayerClient);
+};
+
+struct TunnelRenderer::StreamSource : public BnStreamSource {
+ StreamSource(TunnelRenderer *owner);
+
+ virtual void setListener(const sp<IStreamListener> &listener);
+ virtual void setBuffers(const Vector<sp<IMemory> > &buffers);
+
+ virtual void onBufferAvailable(size_t index);
+
+ virtual uint32_t flags() const;
+
+ void doSomeWork();
+
+protected:
+ virtual ~StreamSource();
+
+private:
+ mutable Mutex mLock;
+
+ TunnelRenderer *mOwner;
+
+ sp<IStreamListener> mListener;
+
+ Vector<sp<IMemory> > mBuffers;
+ List<size_t> mIndicesAvailable;
+
+ size_t mNumDeqeued;
+
+ DISALLOW_EVIL_CONSTRUCTORS(StreamSource);
+};
+
+////////////////////////////////////////////////////////////////////////////////
+
+TunnelRenderer::StreamSource::StreamSource(TunnelRenderer *owner)
+ : mOwner(owner),
+ mNumDeqeued(0) {
+}
+
+TunnelRenderer::StreamSource::~StreamSource() {
+}
+
+void TunnelRenderer::StreamSource::setListener(
+ const sp<IStreamListener> &listener) {
+ mListener = listener;
+}
+
+void TunnelRenderer::StreamSource::setBuffers(
+ const Vector<sp<IMemory> > &buffers) {
+ mBuffers = buffers;
+}
+
+void TunnelRenderer::StreamSource::onBufferAvailable(size_t index) {
+ CHECK_LT(index, mBuffers.size());
+
+ {
+ Mutex::Autolock autoLock(mLock);
+ mIndicesAvailable.push_back(index);
+ }
+
+ doSomeWork();
+}
+
+uint32_t TunnelRenderer::StreamSource::flags() const {
+ return kFlagAlignedVideoData;
+}
+
+void TunnelRenderer::StreamSource::doSomeWork() {
+ Mutex::Autolock autoLock(mLock);
+
+ while (!mIndicesAvailable.empty()) {
+ sp<ABuffer> srcBuffer = mOwner->dequeueBuffer();
+ if (srcBuffer == NULL) {
+ break;
+ }
+
+ ++mNumDeqeued;
+
+ if (mNumDeqeued == 1) {
+ ALOGI("fixing real time now.");
+
+ sp<AMessage> extra = new AMessage;
+
+ extra->setInt32(
+ IStreamListener::kKeyDiscontinuityMask,
+ ATSParser::DISCONTINUITY_ABSOLUTE_TIME);
+
+ extra->setInt64("timeUs", ALooper::GetNowUs());
+
+ mListener->issueCommand(
+ IStreamListener::DISCONTINUITY,
+ false /* synchronous */,
+ extra);
+ }
+
+ ALOGV("dequeue TS packet of size %d", srcBuffer->size());
+
+ size_t index = *mIndicesAvailable.begin();
+ mIndicesAvailable.erase(mIndicesAvailable.begin());
+
+ sp<IMemory> mem = mBuffers.itemAt(index);
+ CHECK_LE(srcBuffer->size(), mem->size());
+ CHECK_EQ((srcBuffer->size() % 188), 0u);
+
+ memcpy(mem->pointer(), srcBuffer->data(), srcBuffer->size());
+ mListener->queueBuffer(index, srcBuffer->size());
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+TunnelRenderer::TunnelRenderer(
+ const sp<AMessage> &notifyLost,
+ const sp<ISurfaceTexture> &surfaceTex)
+ : mNotifyLost(notifyLost),
+ mSurfaceTex(surfaceTex),
+ mTotalBytesQueued(0ll),
+ mLastDequeuedExtSeqNo(-1),
+ mFirstFailedAttemptUs(-1ll),
+ mRequestedRetransmission(false) {
+}
+
+TunnelRenderer::~TunnelRenderer() {
+ destroyPlayer();
+}
+
+void TunnelRenderer::queueBuffer(const sp<ABuffer> &buffer) {
+ Mutex::Autolock autoLock(mLock);
+
+ mTotalBytesQueued += buffer->size();
+
+ if (mPackets.empty()) {
+ mPackets.push_back(buffer);
+ return;
+ }
+
+ int32_t newExtendedSeqNo = buffer->int32Data();
+
+ List<sp<ABuffer> >::iterator firstIt = mPackets.begin();
+ List<sp<ABuffer> >::iterator it = --mPackets.end();
+ for (;;) {
+ int32_t extendedSeqNo = (*it)->int32Data();
+
+ if (extendedSeqNo == newExtendedSeqNo) {
+ // Duplicate packet.
+ return;
+ }
+
+ if (extendedSeqNo < newExtendedSeqNo) {
+ // Insert new packet after the one at "it".
+ mPackets.insert(++it, buffer);
+ return;
+ }
+
+ if (it == firstIt) {
+ // Insert new packet before the first existing one.
+ mPackets.insert(it, buffer);
+ return;
+ }
+
+ --it;
+ }
+}
+
+sp<ABuffer> TunnelRenderer::dequeueBuffer() {
+ Mutex::Autolock autoLock(mLock);
+
+ sp<ABuffer> buffer;
+ int32_t extSeqNo;
+ while (!mPackets.empty()) {
+ buffer = *mPackets.begin();
+ extSeqNo = buffer->int32Data();
+
+ if (mLastDequeuedExtSeqNo < 0 || extSeqNo > mLastDequeuedExtSeqNo) {
+ break;
+ }
+
+ // This is a retransmission of a packet we've already returned.
+
+ mTotalBytesQueued -= buffer->size();
+ buffer.clear();
+ extSeqNo = -1;
+
+ mPackets.erase(mPackets.begin());
+ }
+
+ if (mPackets.empty()) {
+ if (mFirstFailedAttemptUs < 0ll) {
+ mFirstFailedAttemptUs = ALooper::GetNowUs();
+ mRequestedRetransmission = false;
+ } else {
+ ALOGV("no packets available for %.2f secs",
+ (ALooper::GetNowUs() - mFirstFailedAttemptUs) / 1E6);
+ }
+
+ return NULL;
+ }
+
+ if (mLastDequeuedExtSeqNo < 0 || extSeqNo == mLastDequeuedExtSeqNo + 1) {
+ if (mRequestedRetransmission) {
+ ALOGI("Recovered after requesting retransmission of %d",
+ extSeqNo);
+ }
+
+ mLastDequeuedExtSeqNo = extSeqNo;
+ mFirstFailedAttemptUs = -1ll;
+ mRequestedRetransmission = false;
+
+ mPackets.erase(mPackets.begin());
+
+ mTotalBytesQueued -= buffer->size();
+
+ return buffer;
+ }
+
+ if (mFirstFailedAttemptUs < 0ll) {
+ mFirstFailedAttemptUs = ALooper::GetNowUs();
+
+ ALOGI("failed to get the correct packet the first time.");
+ return NULL;
+ }
+
+ if (mFirstFailedAttemptUs + 50000ll > ALooper::GetNowUs()) {
+ // We're willing to wait a little while to get the right packet.
+
+ if (!mRequestedRetransmission) {
+ ALOGI("requesting retransmission of seqNo %d",
+ (mLastDequeuedExtSeqNo + 1) & 0xffff);
+
+ sp<AMessage> notify = mNotifyLost->dup();
+ notify->setInt32("seqNo", (mLastDequeuedExtSeqNo + 1) & 0xffff);
+ notify->post();
+
+ mRequestedRetransmission = true;
+ } else {
+ ALOGI("still waiting for the correct packet to arrive.");
+ }
+
+ return NULL;
+ }
+
+ ALOGI("dropping packet. extSeqNo %d didn't arrive in time",
+ mLastDequeuedExtSeqNo + 1);
+
+ // Permanent failure, we never received the packet.
+ mLastDequeuedExtSeqNo = extSeqNo;
+ mFirstFailedAttemptUs = -1ll;
+ mRequestedRetransmission = false;
+
+ mTotalBytesQueued -= buffer->size();
+
+ mPackets.erase(mPackets.begin());
+
+ return buffer;
+}
+
+void TunnelRenderer::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatQueueBuffer:
+ {
+ sp<ABuffer> buffer;
+ CHECK(msg->findBuffer("buffer", &buffer));
+
+ queueBuffer(buffer);
+
+ if (mStreamSource == NULL) {
+ if (mTotalBytesQueued > 0ll) {
+ initPlayer();
+ } else {
+ ALOGI("Have %lld bytes queued...", mTotalBytesQueued);
+ }
+ } else {
+ mStreamSource->doSomeWork();
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void TunnelRenderer::initPlayer() {
+ if (mSurfaceTex == NULL) {
+ mComposerClient = new SurfaceComposerClient;
+ CHECK_EQ(mComposerClient->initCheck(), (status_t)OK);
+
+ DisplayInfo info;
+ SurfaceComposerClient::getDisplayInfo(0, &info);
+ ssize_t displayWidth = info.w;
+ ssize_t displayHeight = info.h;
+
+ mSurfaceControl =
+ mComposerClient->createSurface(
+ String8("A Surface"),
+ displayWidth,
+ displayHeight,
+ PIXEL_FORMAT_RGB_565,
+ 0);
+
+ CHECK(mSurfaceControl != NULL);
+ CHECK(mSurfaceControl->isValid());
+
+ SurfaceComposerClient::openGlobalTransaction();
+ CHECK_EQ(mSurfaceControl->setLayer(INT_MAX), (status_t)OK);
+ CHECK_EQ(mSurfaceControl->show(), (status_t)OK);
+ SurfaceComposerClient::closeGlobalTransaction();
+
+ mSurface = mSurfaceControl->getSurface();
+ CHECK(mSurface != NULL);
+ }
+
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("media.player"));
+ sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
+ CHECK(service.get() != NULL);
+
+ mStreamSource = new StreamSource(this);
+
+ mPlayerClient = new PlayerClient;
+
+ mPlayer = service->create(getpid(), mPlayerClient, 0);
+ CHECK(mPlayer != NULL);
+ CHECK_EQ(mPlayer->setDataSource(mStreamSource), (status_t)OK);
+
+ mPlayer->setVideoSurfaceTexture(
+ mSurfaceTex != NULL ? mSurfaceTex : mSurface->getSurfaceTexture());
+
+ mPlayer->start();
+}
+
+void TunnelRenderer::destroyPlayer() {
+ mStreamSource.clear();
+
+ mPlayer->stop();
+ mPlayer.clear();
+
+ if (mSurfaceTex == NULL) {
+ mSurface.clear();
+ mSurfaceControl.clear();
+
+ mComposerClient->dispose();
+ mComposerClient.clear();
+ }
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/sink/TunnelRenderer.h b/media/libstagefright/wifi-display/sink/TunnelRenderer.h
new file mode 100644
index 0000000..c9597e0
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/TunnelRenderer.h
@@ -0,0 +1,84 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TUNNEL_RENDERER_H_
+
+#define TUNNEL_RENDERER_H_
+
+#include <gui/Surface.h>
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct ABuffer;
+struct SurfaceComposerClient;
+struct SurfaceControl;
+struct Surface;
+struct IMediaPlayer;
+struct IStreamListener;
+
+// This class reassembles incoming RTP packets into the correct order
+// and sends the resulting transport stream to a mediaplayer instance
+// for playback.
+struct TunnelRenderer : public AHandler {
+ TunnelRenderer(
+ const sp<AMessage> &notifyLost,
+ const sp<ISurfaceTexture> &surfaceTex);
+
+ sp<ABuffer> dequeueBuffer();
+
+ enum {
+ kWhatQueueBuffer,
+ };
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~TunnelRenderer();
+
+private:
+ struct PlayerClient;
+ struct StreamSource;
+
+ mutable Mutex mLock;
+
+ sp<AMessage> mNotifyLost;
+ sp<ISurfaceTexture> mSurfaceTex;
+
+ List<sp<ABuffer> > mPackets;
+ int64_t mTotalBytesQueued;
+
+ sp<SurfaceComposerClient> mComposerClient;
+ sp<SurfaceControl> mSurfaceControl;
+ sp<Surface> mSurface;
+ sp<PlayerClient> mPlayerClient;
+ sp<IMediaPlayer> mPlayer;
+ sp<StreamSource> mStreamSource;
+
+ int32_t mLastDequeuedExtSeqNo;
+ int64_t mFirstFailedAttemptUs;
+ bool mRequestedRetransmission;
+
+ void initPlayer();
+ void destroyPlayer();
+
+ void queueBuffer(const sp<ABuffer> &buffer);
+
+ DISALLOW_EVIL_CONSTRUCTORS(TunnelRenderer);
+};
+
+} // namespace android
+
+#endif // TUNNEL_RENDERER_H_
diff --git a/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp b/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
new file mode 100644
index 0000000..fcd20d4
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/WifiDisplaySink.cpp
@@ -0,0 +1,644 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "WifiDisplaySink"
+#include <utils/Log.h>
+
+#include "WifiDisplaySink.h"
+#include "ParsedMessage.h"
+#include "RTPSink.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaErrors.h>
+
+namespace android {
+
+WifiDisplaySink::WifiDisplaySink(
+ const sp<ANetworkSession> &netSession,
+ const sp<ISurfaceTexture> &surfaceTex)
+ : mState(UNDEFINED),
+ mNetSession(netSession),
+ mSurfaceTex(surfaceTex),
+ mSessionID(0),
+ mNextCSeq(1) {
+}
+
+WifiDisplaySink::~WifiDisplaySink() {
+}
+
+void WifiDisplaySink::start(const char *sourceHost, int32_t sourcePort) {
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setString("sourceHost", sourceHost);
+ msg->setInt32("sourcePort", sourcePort);
+ msg->post();
+}
+
+void WifiDisplaySink::start(const char *uri) {
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setString("setupURI", uri);
+ msg->post();
+}
+
+// static
+bool WifiDisplaySink::ParseURL(
+ const char *url, AString *host, int32_t *port, AString *path,
+ AString *user, AString *pass) {
+ host->clear();
+ *port = 0;
+ path->clear();
+ user->clear();
+ pass->clear();
+
+ if (strncasecmp("rtsp://", url, 7)) {
+ return false;
+ }
+
+ const char *slashPos = strchr(&url[7], '/');
+
+ if (slashPos == NULL) {
+ host->setTo(&url[7]);
+ path->setTo("/");
+ } else {
+ host->setTo(&url[7], slashPos - &url[7]);
+ path->setTo(slashPos);
+ }
+
+ ssize_t atPos = host->find("@");
+
+ if (atPos >= 0) {
+ // Split of user:pass@ from hostname.
+
+ AString userPass(*host, 0, atPos);
+ host->erase(0, atPos + 1);
+
+ ssize_t colonPos = userPass.find(":");
+
+ if (colonPos < 0) {
+ *user = userPass;
+ } else {
+ user->setTo(userPass, 0, colonPos);
+ pass->setTo(userPass, colonPos + 1, userPass.size() - colonPos - 1);
+ }
+ }
+
+ const char *colonPos = strchr(host->c_str(), ':');
+
+ if (colonPos != NULL) {
+ char *end;
+ unsigned long x = strtoul(colonPos + 1, &end, 10);
+
+ if (end == colonPos + 1 || *end != '\0' || x >= 65536) {
+ return false;
+ }
+
+ *port = x;
+
+ size_t colonOffset = colonPos - host->c_str();
+ size_t trailing = host->size() - colonOffset;
+ host->erase(colonOffset, trailing);
+ } else {
+ *port = 554;
+ }
+
+ return true;
+}
+
+void WifiDisplaySink::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatStart:
+ {
+ int32_t sourcePort;
+
+ if (msg->findString("setupURI", &mSetupURI)) {
+ AString path, user, pass;
+ CHECK(ParseURL(
+ mSetupURI.c_str(),
+ &mRTSPHost, &sourcePort, &path, &user, &pass)
+ && user.empty() && pass.empty());
+ } else {
+ CHECK(msg->findString("sourceHost", &mRTSPHost));
+ CHECK(msg->findInt32("sourcePort", &sourcePort));
+ }
+
+ sp<AMessage> notify = new AMessage(kWhatRTSPNotify, id());
+
+ status_t err = mNetSession->createRTSPClient(
+ mRTSPHost.c_str(), sourcePort, notify, &mSessionID);
+ CHECK_EQ(err, (status_t)OK);
+
+ mState = CONNECTING;
+ break;
+ }
+
+ case kWhatRTSPNotify:
+ {
+ int32_t reason;
+ CHECK(msg->findInt32("reason", &reason));
+
+ switch (reason) {
+ case ANetworkSession::kWhatError:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ int32_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ AString detail;
+ CHECK(msg->findString("detail", &detail));
+
+ ALOGE("An error occurred in session %d (%d, '%s/%s').",
+ sessionID,
+ err,
+ detail.c_str(),
+ strerror(-err));
+
+ if (sessionID == mSessionID) {
+ ALOGI("Lost control connection.");
+
+ // The control connection is dead now.
+ mNetSession->destroySession(mSessionID);
+ mSessionID = 0;
+
+ looper()->stop();
+ }
+ break;
+ }
+
+ case ANetworkSession::kWhatConnected:
+ {
+ ALOGI("We're now connected.");
+ mState = CONNECTED;
+
+ if (!mSetupURI.empty()) {
+ status_t err =
+ sendDescribe(mSessionID, mSetupURI.c_str());
+
+ CHECK_EQ(err, (status_t)OK);
+ }
+ break;
+ }
+
+ case ANetworkSession::kWhatData:
+ {
+ onReceiveClientData(msg);
+ break;
+ }
+
+ case ANetworkSession::kWhatBinaryData:
+ {
+ CHECK(sUseTCPInterleaving);
+
+ int32_t channel;
+ CHECK(msg->findInt32("channel", &channel));
+
+ sp<ABuffer> data;
+ CHECK(msg->findBuffer("data", &data));
+
+ mRTPSink->injectPacket(channel == 0 /* isRTP */, data);
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+ break;
+ }
+
+ case kWhatStop:
+ {
+ looper()->stop();
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void WifiDisplaySink::registerResponseHandler(
+ int32_t sessionID, int32_t cseq, HandleRTSPResponseFunc func) {
+ ResponseID id;
+ id.mSessionID = sessionID;
+ id.mCSeq = cseq;
+ mResponseHandlers.add(id, func);
+}
+
+status_t WifiDisplaySink::sendM2(int32_t sessionID) {
+ AString request = "OPTIONS * RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append(
+ "Require: org.wfa.wfd1.0\r\n"
+ "\r\n");
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySink::onReceiveM2Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySink::onReceiveM2Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ return OK;
+}
+
+status_t WifiDisplaySink::onReceiveDescribeResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ return sendSetup(sessionID, mSetupURI.c_str());
+}
+
+status_t WifiDisplaySink::onReceiveSetupResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ if (!msg->findString("session", &mPlaybackSessionID)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (!ParsedMessage::GetInt32Attribute(
+ mPlaybackSessionID.c_str(),
+ "timeout",
+ &mPlaybackSessionTimeoutSecs)) {
+ mPlaybackSessionTimeoutSecs = -1;
+ }
+
+ ssize_t colonPos = mPlaybackSessionID.find(";");
+ if (colonPos >= 0) {
+ // Strip any options from the returned session id.
+ mPlaybackSessionID.erase(
+ colonPos, mPlaybackSessionID.size() - colonPos);
+ }
+
+ status_t err = configureTransport(msg);
+
+ if (err != OK) {
+ return err;
+ }
+
+ mState = PAUSED;
+
+ return sendPlay(
+ sessionID,
+ !mSetupURI.empty()
+ ? mSetupURI.c_str() : "rtsp://x.x.x.x:x/wfd1.0/streamid=0");
+}
+
+status_t WifiDisplaySink::configureTransport(const sp<ParsedMessage> &msg) {
+ if (sUseTCPInterleaving) {
+ return OK;
+ }
+
+ AString transport;
+ if (!msg->findString("transport", &transport)) {
+ ALOGE("Missing 'transport' field in SETUP response.");
+ return ERROR_MALFORMED;
+ }
+
+ AString sourceHost;
+ if (!ParsedMessage::GetAttribute(
+ transport.c_str(), "source", &sourceHost)) {
+ sourceHost = mRTSPHost;
+ }
+
+ AString serverPortStr;
+ if (!ParsedMessage::GetAttribute(
+ transport.c_str(), "server_port", &serverPortStr)) {
+ ALOGE("Missing 'server_port' in Transport field.");
+ return ERROR_MALFORMED;
+ }
+
+ int rtpPort, rtcpPort;
+ if (sscanf(serverPortStr.c_str(), "%d-%d", &rtpPort, &rtcpPort) != 2
+ || rtpPort <= 0 || rtpPort > 65535
+ || rtcpPort <=0 || rtcpPort > 65535
+ || rtcpPort != rtpPort + 1) {
+ ALOGE("Invalid server_port description '%s'.",
+ serverPortStr.c_str());
+
+ return ERROR_MALFORMED;
+ }
+
+ if (rtpPort & 1) {
+ ALOGW("Server picked an odd numbered RTP port.");
+ }
+
+ return mRTPSink->connect(sourceHost.c_str(), rtpPort, rtcpPort);
+}
+
+status_t WifiDisplaySink::onReceivePlayResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ mState = PLAYING;
+
+ return OK;
+}
+
+void WifiDisplaySink::onReceiveClientData(const sp<AMessage> &msg) {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ sp<RefBase> obj;
+ CHECK(msg->findObject("data", &obj));
+
+ sp<ParsedMessage> data =
+ static_cast<ParsedMessage *>(obj.get());
+
+ ALOGV("session %d received '%s'",
+ sessionID, data->debugString().c_str());
+
+ AString method;
+ AString uri;
+ data->getRequestField(0, &method);
+
+ int32_t cseq;
+ if (!data->findInt32("cseq", &cseq)) {
+ sendErrorResponse(sessionID, "400 Bad Request", -1 /* cseq */);
+ return;
+ }
+
+ if (method.startsWith("RTSP/")) {
+ // This is a response.
+
+ ResponseID id;
+ id.mSessionID = sessionID;
+ id.mCSeq = cseq;
+
+ ssize_t index = mResponseHandlers.indexOfKey(id);
+
+ if (index < 0) {
+ ALOGW("Received unsolicited server response, cseq %d", cseq);
+ return;
+ }
+
+ HandleRTSPResponseFunc func = mResponseHandlers.valueAt(index);
+ mResponseHandlers.removeItemsAt(index);
+
+ status_t err = (this->*func)(sessionID, data);
+ CHECK_EQ(err, (status_t)OK);
+ } else {
+ AString version;
+ data->getRequestField(2, &version);
+ if (!(version == AString("RTSP/1.0"))) {
+ sendErrorResponse(sessionID, "505 RTSP Version not supported", cseq);
+ return;
+ }
+
+ if (method == "OPTIONS") {
+ onOptionsRequest(sessionID, cseq, data);
+ } else if (method == "GET_PARAMETER") {
+ onGetParameterRequest(sessionID, cseq, data);
+ } else if (method == "SET_PARAMETER") {
+ onSetParameterRequest(sessionID, cseq, data);
+ } else {
+ sendErrorResponse(sessionID, "405 Method Not Allowed", cseq);
+ }
+ }
+}
+
+void WifiDisplaySink::onOptionsRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq);
+ response.append("Public: org.wfa.wfd1.0, GET_PARAMETER, SET_PARAMETER\r\n");
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ CHECK_EQ(err, (status_t)OK);
+
+ err = sendM2(sessionID);
+ CHECK_EQ(err, (status_t)OK);
+}
+
+void WifiDisplaySink::onGetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ AString body =
+ "wfd_video_formats: xxx\r\n"
+ "wfd_audio_codecs: xxx\r\n"
+ "wfd_client_rtp_ports: RTP/AVP/UDP;unicast xxx 0 mode=play\r\n";
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq);
+ response.append("Content-Type: text/parameters\r\n");
+ response.append(StringPrintf("Content-Length: %d\r\n", body.size()));
+ response.append("\r\n");
+ response.append(body);
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ CHECK_EQ(err, (status_t)OK);
+}
+
+status_t WifiDisplaySink::sendDescribe(int32_t sessionID, const char *uri) {
+ uri = "rtsp://xwgntvx.is.livestream-api.com/livestreamiphone/wgntv";
+ uri = "rtsp://v2.cache6.c.youtube.com/video.3gp?cid=e101d4bf280055f9&fmt=18";
+
+ AString request = StringPrintf("DESCRIBE %s RTSP/1.0\r\n", uri);
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append("Accept: application/sdp\r\n");
+ request.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(
+ sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySink::onReceiveDescribeResponse);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySink::sendSetup(int32_t sessionID, const char *uri) {
+ mRTPSink = new RTPSink(mNetSession, mSurfaceTex);
+ looper()->registerHandler(mRTPSink);
+
+ status_t err = mRTPSink->init(sUseTCPInterleaving);
+
+ if (err != OK) {
+ looper()->unregisterHandler(mRTPSink->id());
+ mRTPSink.clear();
+ return err;
+ }
+
+ AString request = StringPrintf("SETUP %s RTSP/1.0\r\n", uri);
+
+ AppendCommonResponse(&request, mNextCSeq);
+
+ if (sUseTCPInterleaving) {
+ request.append("Transport: RTP/AVP/TCP;interleaved=0-1\r\n");
+ } else {
+ int32_t rtpPort = mRTPSink->getRTPPort();
+
+ request.append(
+ StringPrintf(
+ "Transport: RTP/AVP/UDP;unicast;client_port=%d-%d\r\n",
+ rtpPort, rtpPort + 1));
+ }
+
+ request.append("\r\n");
+
+ ALOGV("request = '%s'", request.c_str());
+
+ err = mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySink::onReceiveSetupResponse);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySink::sendPlay(int32_t sessionID, const char *uri) {
+ AString request = StringPrintf("PLAY %s RTSP/1.0\r\n", uri);
+
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append(StringPrintf("Session: %s\r\n", mPlaybackSessionID.c_str()));
+ request.append("\r\n");
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySink::onReceivePlayResponse);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+void WifiDisplaySink::onSetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ const char *content = data->getContent();
+
+ if (strstr(content, "wfd_trigger_method: SETUP\r\n") != NULL) {
+ status_t err =
+ sendSetup(
+ sessionID,
+ "rtsp://x.x.x.x:x/wfd1.0/streamid=0");
+
+ CHECK_EQ(err, (status_t)OK);
+ }
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq);
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ CHECK_EQ(err, (status_t)OK);
+}
+
+void WifiDisplaySink::sendErrorResponse(
+ int32_t sessionID,
+ const char *errorDetail,
+ int32_t cseq) {
+ AString response;
+ response.append("RTSP/1.0 ");
+ response.append(errorDetail);
+ response.append("\r\n");
+
+ AppendCommonResponse(&response, cseq);
+
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ CHECK_EQ(err, (status_t)OK);
+}
+
+// static
+void WifiDisplaySink::AppendCommonResponse(AString *response, int32_t cseq) {
+ time_t now = time(NULL);
+ struct tm *now2 = gmtime(&now);
+ char buf[128];
+ strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %z", now2);
+
+ response->append("Date: ");
+ response->append(buf);
+ response->append("\r\n");
+
+ response->append("User-Agent: stagefright/1.1 (Linux;Android 4.1)\r\n");
+
+ if (cseq >= 0) {
+ response->append(StringPrintf("CSeq: %d\r\n", cseq));
+ }
+}
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/sink/WifiDisplaySink.h b/media/libstagefright/wifi-display/sink/WifiDisplaySink.h
new file mode 100644
index 0000000..f886ee5
--- /dev/null
+++ b/media/libstagefright/wifi-display/sink/WifiDisplaySink.h
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_DISPLAY_SINK_H_
+
+#define WIFI_DISPLAY_SINK_H_
+
+#include "ANetworkSession.h"
+
+#include <gui/Surface.h>
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct ParsedMessage;
+struct RTPSink;
+
+// Represents the RTSP client acting as a wifi display sink.
+// Connects to a wifi display source and renders the incoming
+// transport stream using a MediaPlayer instance.
+struct WifiDisplaySink : public AHandler {
+ WifiDisplaySink(
+ const sp<ANetworkSession> &netSession,
+ const sp<ISurfaceTexture> &surfaceTex = NULL);
+
+ void start(const char *sourceHost, int32_t sourcePort);
+ void start(const char *uri);
+
+protected:
+ virtual ~WifiDisplaySink();
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ enum State {
+ UNDEFINED,
+ CONNECTING,
+ CONNECTED,
+ PAUSED,
+ PLAYING,
+ };
+
+ enum {
+ kWhatStart,
+ kWhatRTSPNotify,
+ kWhatStop,
+ };
+
+ struct ResponseID {
+ int32_t mSessionID;
+ int32_t mCSeq;
+
+ bool operator<(const ResponseID &other) const {
+ return mSessionID < other.mSessionID
+ || (mSessionID == other.mSessionID
+ && mCSeq < other.mCSeq);
+ }
+ };
+
+ typedef status_t (WifiDisplaySink::*HandleRTSPResponseFunc)(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ static const bool sUseTCPInterleaving = false;
+
+ State mState;
+ sp<ANetworkSession> mNetSession;
+ sp<ISurfaceTexture> mSurfaceTex;
+ AString mSetupURI;
+ AString mRTSPHost;
+ int32_t mSessionID;
+
+ int32_t mNextCSeq;
+
+ KeyedVector<ResponseID, HandleRTSPResponseFunc> mResponseHandlers;
+
+ sp<RTPSink> mRTPSink;
+ AString mPlaybackSessionID;
+ int32_t mPlaybackSessionTimeoutSecs;
+
+ status_t sendM2(int32_t sessionID);
+ status_t sendDescribe(int32_t sessionID, const char *uri);
+ status_t sendSetup(int32_t sessionID, const char *uri);
+ status_t sendPlay(int32_t sessionID, const char *uri);
+
+ status_t onReceiveM2Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveDescribeResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveSetupResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t configureTransport(const sp<ParsedMessage> &msg);
+
+ status_t onReceivePlayResponse(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ void registerResponseHandler(
+ int32_t sessionID, int32_t cseq, HandleRTSPResponseFunc func);
+
+ void onReceiveClientData(const sp<AMessage> &msg);
+
+ void onOptionsRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ void onGetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ void onSetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ void sendErrorResponse(
+ int32_t sessionID,
+ const char *errorDetail,
+ int32_t cseq);
+
+ static void AppendCommonResponse(AString *response, int32_t cseq);
+
+ bool ParseURL(
+ const char *url, AString *host, int32_t *port, AString *path,
+ AString *user, AString *pass);
+
+ DISALLOW_EVIL_CONSTRUCTORS(WifiDisplaySink);
+};
+
+} // namespace android
+
+#endif // WIFI_DISPLAY_SINK_H_
diff --git a/media/libstagefright/wifi-display/source/Converter.cpp b/media/libstagefright/wifi-display/source/Converter.cpp
new file mode 100644
index 0000000..01a394f
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Converter.cpp
@@ -0,0 +1,606 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "Converter"
+#include <utils/Log.h>
+
+#include "Converter.h"
+
+#include "MediaPuller.h"
+
+#include <cutils/properties.h>
+#include <gui/SurfaceTextureClient.h>
+#include <media/ICrypto.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaCodec.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+
+#include <OMX_Video.h>
+
+namespace android {
+
+Converter::Converter(
+ const sp<AMessage> &notify,
+ const sp<ALooper> &codecLooper,
+ const sp<AMessage> &format,
+ bool usePCMAudio)
+ : mInitCheck(NO_INIT),
+ mNotify(notify),
+ mCodecLooper(codecLooper),
+ mInputFormat(format),
+ mIsVideo(false),
+ mIsPCMAudio(usePCMAudio),
+ mDoMoreWorkPending(false)
+#if ENABLE_SILENCE_DETECTION
+ ,mFirstSilentFrameUs(-1ll)
+ ,mInSilentMode(false)
+#endif
+ {
+ AString mime;
+ CHECK(mInputFormat->findString("mime", &mime));
+
+ if (!strncasecmp("video/", mime.c_str(), 6)) {
+ mIsVideo = true;
+ }
+
+ CHECK(!usePCMAudio || !mIsVideo);
+
+ mInitCheck = initEncoder();
+
+ if (mInitCheck != OK) {
+ if (mEncoder != NULL) {
+ mEncoder->release();
+ mEncoder.clear();
+ }
+ }
+}
+
+Converter::~Converter() {
+ CHECK(mEncoder == NULL);
+}
+
+void Converter::shutdownAsync() {
+ ALOGV("shutdown");
+ (new AMessage(kWhatShutdown, id()))->post();
+}
+
+status_t Converter::initCheck() const {
+ return mInitCheck;
+}
+
+size_t Converter::getInputBufferCount() const {
+ return mEncoderInputBuffers.size();
+}
+
+sp<AMessage> Converter::getOutputFormat() const {
+ return mOutputFormat;
+}
+
+static int32_t getBitrate(const char *propName, int32_t defaultValue) {
+ char val[PROPERTY_VALUE_MAX];
+ if (property_get(propName, val, NULL)) {
+ char *end;
+ unsigned long x = strtoul(val, &end, 10);
+
+ if (*end == '\0' && end > val && x > 0) {
+ return x;
+ }
+ }
+
+ return defaultValue;
+}
+
+status_t Converter::initEncoder() {
+ AString inputMIME;
+ CHECK(mInputFormat->findString("mime", &inputMIME));
+
+ AString outputMIME;
+ bool isAudio = false;
+ if (!strcasecmp(inputMIME.c_str(), MEDIA_MIMETYPE_AUDIO_RAW)) {
+ if (mIsPCMAudio) {
+ outputMIME = MEDIA_MIMETYPE_AUDIO_RAW;
+ } else {
+ outputMIME = MEDIA_MIMETYPE_AUDIO_AAC;
+ }
+ isAudio = true;
+ } else if (!strcasecmp(inputMIME.c_str(), MEDIA_MIMETYPE_VIDEO_RAW)) {
+ outputMIME = MEDIA_MIMETYPE_VIDEO_AVC;
+ } else {
+ TRESPASS();
+ }
+
+ if (!mIsPCMAudio) {
+ mEncoder = MediaCodec::CreateByType(
+ mCodecLooper, outputMIME.c_str(), true /* encoder */);
+
+ if (mEncoder == NULL) {
+ return ERROR_UNSUPPORTED;
+ }
+ }
+
+ mOutputFormat = mInputFormat->dup();
+
+ if (mIsPCMAudio) {
+ return OK;
+ }
+
+ mOutputFormat->setString("mime", outputMIME.c_str());
+
+ int32_t audioBitrate = getBitrate("media.wfd.audio-bitrate", 128000);
+ int32_t videoBitrate = getBitrate("media.wfd.video-bitrate", 5000000);
+
+ ALOGI("using audio bitrate of %d bps, video bitrate of %d bps",
+ audioBitrate, videoBitrate);
+
+ if (isAudio) {
+ mOutputFormat->setInt32("bitrate", audioBitrate);
+ } else {
+ mOutputFormat->setInt32("bitrate", videoBitrate);
+ mOutputFormat->setInt32("bitrate-mode", OMX_Video_ControlRateConstant);
+ mOutputFormat->setInt32("frame-rate", 30);
+ mOutputFormat->setInt32("i-frame-interval", 1); // Iframes every 1 secs
+ mOutputFormat->setInt32("prepend-sps-pps-to-idr-frames", 1);
+ }
+
+ ALOGV("output format is '%s'", mOutputFormat->debugString(0).c_str());
+
+ status_t err = mEncoder->configure(
+ mOutputFormat,
+ NULL /* nativeWindow */,
+ NULL /* crypto */,
+ MediaCodec::CONFIGURE_FLAG_ENCODE);
+
+ if (err != OK) {
+ return err;
+ }
+
+ err = mEncoder->start();
+
+ if (err != OK) {
+ return err;
+ }
+
+ err = mEncoder->getInputBuffers(&mEncoderInputBuffers);
+
+ if (err != OK) {
+ return err;
+ }
+
+ return mEncoder->getOutputBuffers(&mEncoderOutputBuffers);
+}
+
+void Converter::notifyError(status_t err) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatError);
+ notify->setInt32("err", err);
+ notify->post();
+}
+
+// static
+bool Converter::IsSilence(const sp<ABuffer> &accessUnit) {
+ const uint8_t *ptr = accessUnit->data();
+ const uint8_t *end = ptr + accessUnit->size();
+ while (ptr < end) {
+ if (*ptr != 0) {
+ return false;
+ }
+ ++ptr;
+ }
+
+ return true;
+}
+
+void Converter::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatMediaPullerNotify:
+ {
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ if (!mIsPCMAudio && mEncoder == NULL) {
+ ALOGV("got msg '%s' after encoder shutdown.",
+ msg->debugString().c_str());
+
+ if (what == MediaPuller::kWhatAccessUnit) {
+ sp<ABuffer> accessUnit;
+ CHECK(msg->findBuffer("accessUnit", &accessUnit));
+
+ void *mbuf;
+ if (accessUnit->meta()->findPointer("mediaBuffer", &mbuf)
+ && mbuf != NULL) {
+ ALOGV("releasing mbuf %p", mbuf);
+
+ accessUnit->meta()->setPointer("mediaBuffer", NULL);
+
+ static_cast<MediaBuffer *>(mbuf)->release();
+ mbuf = NULL;
+ }
+ }
+ break;
+ }
+
+ if (what == MediaPuller::kWhatEOS) {
+ mInputBufferQueue.push_back(NULL);
+
+ feedEncoderInputBuffers();
+
+ scheduleDoMoreWork();
+ } else {
+ CHECK_EQ(what, MediaPuller::kWhatAccessUnit);
+
+ sp<ABuffer> accessUnit;
+ CHECK(msg->findBuffer("accessUnit", &accessUnit));
+
+#if 0
+ void *mbuf;
+ if (accessUnit->meta()->findPointer("mediaBuffer", &mbuf)
+ && mbuf != NULL) {
+ ALOGI("queueing mbuf %p", mbuf);
+ }
+#endif
+
+#if ENABLE_SILENCE_DETECTION
+ if (!mIsVideo) {
+ if (IsSilence(accessUnit)) {
+ if (mInSilentMode) {
+ break;
+ }
+
+ int64_t nowUs = ALooper::GetNowUs();
+
+ if (mFirstSilentFrameUs < 0ll) {
+ mFirstSilentFrameUs = nowUs;
+ } else if (nowUs >= mFirstSilentFrameUs + 10000000ll) {
+ mInSilentMode = true;
+ ALOGI("audio in silent mode now.");
+ break;
+ }
+ } else {
+ if (mInSilentMode) {
+ ALOGI("audio no longer in silent mode.");
+ }
+ mInSilentMode = false;
+ mFirstSilentFrameUs = -1ll;
+ }
+ }
+#endif
+
+ mInputBufferQueue.push_back(accessUnit);
+
+ feedEncoderInputBuffers();
+
+ scheduleDoMoreWork();
+ }
+ break;
+ }
+
+ case kWhatEncoderActivity:
+ {
+#if 0
+ int64_t whenUs;
+ if (msg->findInt64("whenUs", &whenUs)) {
+ int64_t nowUs = ALooper::GetNowUs();
+ ALOGI("[%s] kWhatEncoderActivity after %lld us",
+ mIsVideo ? "video" : "audio", nowUs - whenUs);
+ }
+#endif
+
+ mDoMoreWorkPending = false;
+
+ if (mEncoder == NULL) {
+ break;
+ }
+
+ status_t err = doMoreWork();
+
+ if (err != OK) {
+ notifyError(err);
+ } else {
+ scheduleDoMoreWork();
+ }
+ break;
+ }
+
+ case kWhatRequestIDRFrame:
+ {
+ if (mEncoder == NULL) {
+ break;
+ }
+
+ if (mIsVideo) {
+ ALOGI("requesting IDR frame");
+ mEncoder->requestIDRFrame();
+ }
+ break;
+ }
+
+ case kWhatShutdown:
+ {
+ ALOGI("shutting down encoder");
+
+ if (mEncoder != NULL) {
+ mEncoder->release();
+ mEncoder.clear();
+ }
+
+ AString mime;
+ CHECK(mInputFormat->findString("mime", &mime));
+ ALOGI("encoder (%s) shut down.", mime.c_str());
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void Converter::scheduleDoMoreWork() {
+ if (mIsPCMAudio) {
+ // There's no encoder involved in this case.
+ return;
+ }
+
+ if (mDoMoreWorkPending) {
+ return;
+ }
+
+ mDoMoreWorkPending = true;
+
+#if 1
+ if (mEncoderActivityNotify == NULL) {
+ mEncoderActivityNotify = new AMessage(kWhatEncoderActivity, id());
+ }
+ mEncoder->requestActivityNotification(mEncoderActivityNotify->dup());
+#else
+ sp<AMessage> notify = new AMessage(kWhatEncoderActivity, id());
+ notify->setInt64("whenUs", ALooper::GetNowUs());
+ mEncoder->requestActivityNotification(notify);
+#endif
+}
+
+status_t Converter::feedRawAudioInputBuffers() {
+ // Split incoming PCM audio into buffers of 6 AUs of 80 audio frames each
+ // and add a 4 byte header according to the wifi display specs.
+
+ while (!mInputBufferQueue.empty()) {
+ sp<ABuffer> buffer = *mInputBufferQueue.begin();
+ mInputBufferQueue.erase(mInputBufferQueue.begin());
+
+ int16_t *ptr = (int16_t *)buffer->data();
+ int16_t *stop = (int16_t *)(buffer->data() + buffer->size());
+ while (ptr < stop) {
+ *ptr = htons(*ptr);
+ ++ptr;
+ }
+
+ static const size_t kFrameSize = 2 * sizeof(int16_t); // stereo
+ static const size_t kFramesPerAU = 80;
+ static const size_t kNumAUsPerPESPacket = 6;
+
+ if (mPartialAudioAU != NULL) {
+ size_t bytesMissingForFullAU =
+ kNumAUsPerPESPacket * kFramesPerAU * kFrameSize
+ - mPartialAudioAU->size() + 4;
+
+ size_t copy = buffer->size();
+ if(copy > bytesMissingForFullAU) {
+ copy = bytesMissingForFullAU;
+ }
+
+ memcpy(mPartialAudioAU->data() + mPartialAudioAU->size(),
+ buffer->data(),
+ copy);
+
+ mPartialAudioAU->setRange(0, mPartialAudioAU->size() + copy);
+
+ buffer->setRange(buffer->offset() + copy, buffer->size() - copy);
+
+ int64_t timeUs;
+ CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
+
+ int64_t copyUs = (int64_t)((copy / kFrameSize) * 1E6 / 48000.0);
+ timeUs += copyUs;
+ buffer->meta()->setInt64("timeUs", timeUs);
+
+ if (bytesMissingForFullAU == copy) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatAccessUnit);
+ notify->setBuffer("accessUnit", mPartialAudioAU);
+ notify->post();
+
+ mPartialAudioAU.clear();
+ }
+ }
+
+ while (buffer->size() > 0) {
+ sp<ABuffer> partialAudioAU =
+ new ABuffer(
+ 4
+ + kNumAUsPerPESPacket * kFrameSize * kFramesPerAU);
+
+ uint8_t *ptr = partialAudioAU->data();
+ ptr[0] = 0xa0; // 10100000b
+ ptr[1] = kNumAUsPerPESPacket;
+ ptr[2] = 0; // reserved, audio _emphasis_flag = 0
+
+ static const unsigned kQuantizationWordLength = 0; // 16-bit
+ static const unsigned kAudioSamplingFrequency = 2; // 48Khz
+ static const unsigned kNumberOfAudioChannels = 1; // stereo
+
+ ptr[3] = (kQuantizationWordLength << 6)
+ | (kAudioSamplingFrequency << 3)
+ | kNumberOfAudioChannels;
+
+ size_t copy = buffer->size();
+ if (copy > partialAudioAU->size() - 4) {
+ copy = partialAudioAU->size() - 4;
+ }
+
+ memcpy(&ptr[4], buffer->data(), copy);
+
+ partialAudioAU->setRange(0, 4 + copy);
+ buffer->setRange(buffer->offset() + copy, buffer->size() - copy);
+
+ int64_t timeUs;
+ CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
+
+ partialAudioAU->meta()->setInt64("timeUs", timeUs);
+
+ int64_t copyUs = (int64_t)((copy / kFrameSize) * 1E6 / 48000.0);
+ timeUs += copyUs;
+ buffer->meta()->setInt64("timeUs", timeUs);
+
+ if (copy == partialAudioAU->capacity() - 4) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatAccessUnit);
+ notify->setBuffer("accessUnit", partialAudioAU);
+ notify->post();
+
+ partialAudioAU.clear();
+ continue;
+ }
+
+ mPartialAudioAU = partialAudioAU;
+ }
+ }
+
+ return OK;
+}
+
+status_t Converter::feedEncoderInputBuffers() {
+ if (mIsPCMAudio) {
+ return feedRawAudioInputBuffers();
+ }
+
+ while (!mInputBufferQueue.empty()
+ && !mAvailEncoderInputIndices.empty()) {
+ sp<ABuffer> buffer = *mInputBufferQueue.begin();
+ mInputBufferQueue.erase(mInputBufferQueue.begin());
+
+ size_t bufferIndex = *mAvailEncoderInputIndices.begin();
+ mAvailEncoderInputIndices.erase(mAvailEncoderInputIndices.begin());
+
+ int64_t timeUs = 0ll;
+ uint32_t flags = 0;
+
+ if (buffer != NULL) {
+ CHECK(buffer->meta()->findInt64("timeUs", &timeUs));
+
+ memcpy(mEncoderInputBuffers.itemAt(bufferIndex)->data(),
+ buffer->data(),
+ buffer->size());
+
+ void *mediaBuffer;
+ if (buffer->meta()->findPointer("mediaBuffer", &mediaBuffer)
+ && mediaBuffer != NULL) {
+ mEncoderInputBuffers.itemAt(bufferIndex)->meta()
+ ->setPointer("mediaBuffer", mediaBuffer);
+
+ buffer->meta()->setPointer("mediaBuffer", NULL);
+ }
+ } else {
+ flags = MediaCodec::BUFFER_FLAG_EOS;
+ }
+
+ status_t err = mEncoder->queueInputBuffer(
+ bufferIndex, 0, (buffer == NULL) ? 0 : buffer->size(),
+ timeUs, flags);
+
+ if (err != OK) {
+ return err;
+ }
+ }
+
+ return OK;
+}
+
+status_t Converter::doMoreWork() {
+ status_t err;
+
+ for (;;) {
+ size_t bufferIndex;
+ err = mEncoder->dequeueInputBuffer(&bufferIndex);
+
+ if (err != OK) {
+ break;
+ }
+
+ mAvailEncoderInputIndices.push_back(bufferIndex);
+ }
+
+ feedEncoderInputBuffers();
+
+ for (;;) {
+ size_t bufferIndex;
+ size_t offset;
+ size_t size;
+ int64_t timeUs;
+ uint32_t flags;
+ err = mEncoder->dequeueOutputBuffer(
+ &bufferIndex, &offset, &size, &timeUs, &flags);
+
+ if (err != OK) {
+ if (err == -EAGAIN) {
+ err = OK;
+ }
+ break;
+ }
+
+ if (flags & MediaCodec::BUFFER_FLAG_EOS) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatEOS);
+ notify->post();
+ } else {
+ sp<ABuffer> buffer = new ABuffer(size);
+ buffer->meta()->setInt64("timeUs", timeUs);
+
+ ALOGV("[%s] time %lld us (%.2f secs)",
+ mIsVideo ? "video" : "audio", timeUs, timeUs / 1E6);
+
+ memcpy(buffer->data(),
+ mEncoderOutputBuffers.itemAt(bufferIndex)->base() + offset,
+ size);
+
+ if (flags & MediaCodec::BUFFER_FLAG_CODECCONFIG) {
+ mOutputFormat->setBuffer("csd-0", buffer);
+ } else {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatAccessUnit);
+ notify->setBuffer("accessUnit", buffer);
+ notify->post();
+ }
+ }
+
+ mEncoder->releaseOutputBuffer(bufferIndex);
+
+ if (flags & MediaCodec::BUFFER_FLAG_EOS) {
+ break;
+ }
+ }
+
+ return err;
+}
+
+void Converter::requestIDRFrame() {
+ (new AMessage(kWhatRequestIDRFrame, id()))->post();
+}
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/source/Converter.h b/media/libstagefright/wifi-display/source/Converter.h
new file mode 100644
index 0000000..2cdeda3
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Converter.h
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CONVERTER_H_
+
+#define CONVERTER_H_
+
+#include "WifiDisplaySource.h"
+
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct ABuffer;
+struct MediaCodec;
+
+#define ENABLE_SILENCE_DETECTION 0
+
+// Utility class that receives media access units and converts them into
+// media access unit of a different format.
+// Right now this'll convert raw video into H.264 and raw audio into AAC.
+struct Converter : public AHandler {
+ Converter(
+ const sp<AMessage> &notify,
+ const sp<ALooper> &codecLooper,
+ const sp<AMessage> &format,
+ bool usePCMAudio);
+
+ status_t initCheck() const;
+
+ size_t getInputBufferCount() const;
+
+ sp<AMessage> getOutputFormat() const;
+
+ void feedAccessUnit(const sp<ABuffer> &accessUnit);
+ void signalEOS();
+
+ void requestIDRFrame();
+
+ enum {
+ kWhatAccessUnit,
+ kWhatEOS,
+ kWhatError,
+ };
+
+ enum {
+ kWhatDoMoreWork,
+ kWhatRequestIDRFrame,
+ kWhatShutdown,
+ kWhatMediaPullerNotify,
+ kWhatEncoderActivity,
+ };
+
+ void shutdownAsync();
+
+protected:
+ virtual ~Converter();
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ status_t mInitCheck;
+ sp<AMessage> mNotify;
+ sp<ALooper> mCodecLooper;
+ sp<AMessage> mInputFormat;
+ bool mIsVideo;
+ bool mIsPCMAudio;
+ sp<AMessage> mOutputFormat;
+
+ sp<MediaCodec> mEncoder;
+ sp<AMessage> mEncoderActivityNotify;
+
+ Vector<sp<ABuffer> > mEncoderInputBuffers;
+ Vector<sp<ABuffer> > mEncoderOutputBuffers;
+
+ List<size_t> mAvailEncoderInputIndices;
+
+ List<sp<ABuffer> > mInputBufferQueue;
+
+ bool mDoMoreWorkPending;
+
+#if ENABLE_SILENCE_DETECTION
+ int64_t mFirstSilentFrameUs;
+ bool mInSilentMode;
+#endif
+
+ sp<ABuffer> mPartialAudioAU;
+
+ status_t initEncoder();
+
+ status_t feedEncoderInputBuffers();
+
+ void scheduleDoMoreWork();
+ status_t doMoreWork();
+
+ void notifyError(status_t err);
+
+ // Packetizes raw PCM audio data available in mInputBufferQueue
+ // into a format suitable for transport stream inclusion and
+ // notifies the observer.
+ status_t feedRawAudioInputBuffers();
+
+ static bool IsSilence(const sp<ABuffer> &accessUnit);
+
+ DISALLOW_EVIL_CONSTRUCTORS(Converter);
+};
+
+} // namespace android
+
+#endif // CONVERTER_H_
diff --git a/media/libstagefright/wifi-display/source/MediaPuller.cpp b/media/libstagefright/wifi-display/source/MediaPuller.cpp
new file mode 100644
index 0000000..ab69c4a
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/MediaPuller.cpp
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "MediaPuller"
+#include <utils/Log.h>
+
+#include "MediaPuller.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+
+namespace android {
+
+MediaPuller::MediaPuller(
+ const sp<MediaSource> &source, const sp<AMessage> &notify)
+ : mSource(source),
+ mNotify(notify),
+ mPullGeneration(0),
+ mIsAudio(false) {
+ sp<MetaData> meta = source->getFormat();
+ const char *mime;
+ CHECK(meta->findCString(kKeyMIMEType, &mime));
+
+ mIsAudio = !strncasecmp(mime, "audio/", 6);
+}
+
+MediaPuller::~MediaPuller() {
+}
+
+status_t MediaPuller::postSynchronouslyAndReturnError(
+ const sp<AMessage> &msg) {
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (!response->findInt32("err", &err)) {
+ err = OK;
+ }
+
+ return err;
+}
+
+status_t MediaPuller::start() {
+ return postSynchronouslyAndReturnError(new AMessage(kWhatStart, id()));
+}
+
+void MediaPuller::stopAsync(const sp<AMessage> &notify) {
+ sp<AMessage> msg = new AMessage(kWhatStop, id());
+ msg->setMessage("notify", notify);
+ msg->post();
+}
+
+void MediaPuller::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatStart:
+ {
+ status_t err;
+ if (mIsAudio) {
+ // This atrocity causes AudioSource to deliver absolute
+ // systemTime() based timestamps (off by 1 us).
+ sp<MetaData> params = new MetaData;
+ params->setInt64(kKeyTime, 1ll);
+ err = mSource->start(params.get());
+ } else {
+ err = mSource->start();
+ }
+
+ if (err == OK) {
+ schedulePull();
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", err);
+
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ response->postReply(replyID);
+ break;
+ }
+
+ case kWhatStop:
+ {
+ sp<MetaData> meta = mSource->getFormat();
+ const char *tmp;
+ CHECK(meta->findCString(kKeyMIMEType, &tmp));
+ AString mime = tmp;
+
+ ALOGI("MediaPuller(%s) stopping.", mime.c_str());
+ mSource->stop();
+ ALOGI("MediaPuller(%s) stopped.", mime.c_str());
+ ++mPullGeneration;
+
+ sp<AMessage> notify;
+ CHECK(msg->findMessage("notify", &notify));
+ notify->post();
+ break;
+ }
+
+ case kWhatPull:
+ {
+ int32_t generation;
+ CHECK(msg->findInt32("generation", &generation));
+
+ if (generation != mPullGeneration) {
+ break;
+ }
+
+ MediaBuffer *mbuf;
+ status_t err = mSource->read(&mbuf);
+
+ if (err != OK) {
+ if (err == ERROR_END_OF_STREAM) {
+ ALOGI("stream ended.");
+ } else {
+ ALOGE("error %d reading stream.", err);
+ }
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatEOS);
+ notify->post();
+ } else {
+ int64_t timeUs;
+ CHECK(mbuf->meta_data()->findInt64(kKeyTime, &timeUs));
+
+ sp<ABuffer> accessUnit = new ABuffer(mbuf->range_length());
+
+ memcpy(accessUnit->data(),
+ (const uint8_t *)mbuf->data() + mbuf->range_offset(),
+ mbuf->range_length());
+
+ accessUnit->meta()->setInt64("timeUs", timeUs);
+
+ if (mIsAudio) {
+ mbuf->release();
+ mbuf = NULL;
+ } else {
+ // video encoder will release MediaBuffer when done
+ // with underlying data.
+ accessUnit->meta()->setPointer("mediaBuffer", mbuf);
+ }
+
+ sp<AMessage> notify = mNotify->dup();
+
+ notify->setInt32("what", kWhatAccessUnit);
+ notify->setBuffer("accessUnit", accessUnit);
+ notify->post();
+
+ if (mbuf != NULL) {
+ ALOGV("posted mbuf %p", mbuf);
+ }
+
+ schedulePull();
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void MediaPuller::schedulePull() {
+ sp<AMessage> msg = new AMessage(kWhatPull, id());
+ msg->setInt32("generation", mPullGeneration);
+ msg->post();
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/source/MediaPuller.h b/media/libstagefright/wifi-display/source/MediaPuller.h
new file mode 100644
index 0000000..728da7b
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/MediaPuller.h
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MEDIA_PULLER_H_
+
+#define MEDIA_PULLER_H_
+
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+struct MediaSource;
+
+struct MediaPuller : public AHandler {
+ enum {
+ kWhatEOS,
+ kWhatAccessUnit
+ };
+
+ MediaPuller(const sp<MediaSource> &source, const sp<AMessage> &notify);
+
+ status_t start();
+ void stopAsync(const sp<AMessage> &notify);
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~MediaPuller();
+
+private:
+ enum {
+ kWhatStart,
+ kWhatStop,
+ kWhatPull,
+ };
+
+ sp<MediaSource> mSource;
+ sp<AMessage> mNotify;
+ int32_t mPullGeneration;
+ bool mIsAudio;
+
+ status_t postSynchronouslyAndReturnError(const sp<AMessage> &msg);
+ void schedulePull();
+
+ DISALLOW_EVIL_CONSTRUCTORS(MediaPuller);
+};
+
+} // namespace android
+
+#endif // MEDIA_PULLER_H_
diff --git a/media/libstagefright/wifi-display/source/PlaybackSession.cpp b/media/libstagefright/wifi-display/source/PlaybackSession.cpp
new file mode 100644
index 0000000..f1e7140
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.cpp
@@ -0,0 +1,964 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "PlaybackSession"
+#include <utils/Log.h>
+
+#include "PlaybackSession.h"
+
+#include "Converter.h"
+#include "MediaPuller.h"
+#include "RepeaterSource.h"
+#include "Sender.h"
+#include "TSPacketizer.h"
+#include "include/avc_utils.h"
+
+#include <binder/IServiceManager.h>
+#include <gui/ISurfaceComposer.h>
+#include <gui/SurfaceComposerClient.h>
+#include <media/IHDCP.h>
+#include <media/stagefright/foundation/ABitReader.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/AudioSource.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/MediaExtractor.h>
+#include <media/stagefright/MediaSource.h>
+#include <media/stagefright/MetaData.h>
+#include <media/stagefright/MPEG2TSWriter.h>
+#include <media/stagefright/SurfaceMediaSource.h>
+#include <media/stagefright/Utils.h>
+
+#include <OMX_IVCommon.h>
+
+namespace android {
+
+struct WifiDisplaySource::PlaybackSession::Track : public AHandler {
+ enum {
+ kWhatStopped,
+ };
+
+ Track(const sp<AMessage> &notify,
+ const sp<ALooper> &pullLooper,
+ const sp<ALooper> &codecLooper,
+ const sp<MediaPuller> &mediaPuller,
+ const sp<Converter> &converter);
+
+ void setRepeaterSource(const sp<RepeaterSource> &source);
+
+ sp<AMessage> getFormat();
+ bool isAudio() const;
+
+ const sp<Converter> &converter() const;
+ ssize_t packetizerTrackIndex() const;
+
+ void setPacketizerTrackIndex(size_t index);
+
+ status_t start();
+ void stopAsync();
+
+ void queueAccessUnit(const sp<ABuffer> &accessUnit);
+ sp<ABuffer> dequeueAccessUnit();
+
+ bool hasOutputBuffer(int64_t *timeUs) const;
+ void queueOutputBuffer(const sp<ABuffer> &accessUnit);
+ sp<ABuffer> dequeueOutputBuffer();
+ bool isSuspended() const;
+
+ size_t countQueuedOutputBuffers() const {
+ return mQueuedOutputBuffers.size();
+ }
+
+ void requestIDRFrame();
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~Track();
+
+private:
+ enum {
+ kWhatMediaPullerStopped,
+ };
+
+ sp<AMessage> mNotify;
+ sp<ALooper> mPullLooper;
+ sp<ALooper> mCodecLooper;
+ sp<MediaPuller> mMediaPuller;
+ sp<Converter> mConverter;
+ bool mStarted;
+ ssize_t mPacketizerTrackIndex;
+ bool mIsAudio;
+ List<sp<ABuffer> > mQueuedAccessUnits;
+ sp<RepeaterSource> mRepeaterSource;
+ List<sp<ABuffer> > mQueuedOutputBuffers;
+ int64_t mLastOutputBufferQueuedTimeUs;
+
+ static bool IsAudioFormat(const sp<AMessage> &format);
+
+ DISALLOW_EVIL_CONSTRUCTORS(Track);
+};
+
+WifiDisplaySource::PlaybackSession::Track::Track(
+ const sp<AMessage> &notify,
+ const sp<ALooper> &pullLooper,
+ const sp<ALooper> &codecLooper,
+ const sp<MediaPuller> &mediaPuller,
+ const sp<Converter> &converter)
+ : mNotify(notify),
+ mPullLooper(pullLooper),
+ mCodecLooper(codecLooper),
+ mMediaPuller(mediaPuller),
+ mConverter(converter),
+ mStarted(false),
+ mPacketizerTrackIndex(-1),
+ mIsAudio(IsAudioFormat(mConverter->getOutputFormat())),
+ mLastOutputBufferQueuedTimeUs(-1ll) {
+}
+
+WifiDisplaySource::PlaybackSession::Track::~Track() {
+ CHECK(!mStarted);
+}
+
+// static
+bool WifiDisplaySource::PlaybackSession::Track::IsAudioFormat(
+ const sp<AMessage> &format) {
+ AString mime;
+ CHECK(format->findString("mime", &mime));
+
+ return !strncasecmp(mime.c_str(), "audio/", 6);
+}
+
+sp<AMessage> WifiDisplaySource::PlaybackSession::Track::getFormat() {
+ return mConverter->getOutputFormat();
+}
+
+bool WifiDisplaySource::PlaybackSession::Track::isAudio() const {
+ return mIsAudio;
+}
+
+const sp<Converter> &WifiDisplaySource::PlaybackSession::Track::converter() const {
+ return mConverter;
+}
+
+ssize_t WifiDisplaySource::PlaybackSession::Track::packetizerTrackIndex() const {
+ return mPacketizerTrackIndex;
+}
+
+void WifiDisplaySource::PlaybackSession::Track::setPacketizerTrackIndex(size_t index) {
+ CHECK_LT(mPacketizerTrackIndex, 0);
+ mPacketizerTrackIndex = index;
+}
+
+status_t WifiDisplaySource::PlaybackSession::Track::start() {
+ ALOGV("Track::start isAudio=%d", mIsAudio);
+
+ CHECK(!mStarted);
+
+ status_t err = OK;
+
+ if (mMediaPuller != NULL) {
+ err = mMediaPuller->start();
+ }
+
+ if (err == OK) {
+ mStarted = true;
+ }
+
+ return err;
+}
+
+void WifiDisplaySource::PlaybackSession::Track::stopAsync() {
+ ALOGV("Track::stopAsync isAudio=%d", mIsAudio);
+
+ mConverter->shutdownAsync();
+
+ sp<AMessage> msg = new AMessage(kWhatMediaPullerStopped, id());
+
+ if (mStarted && mMediaPuller != NULL) {
+ if (mRepeaterSource != NULL) {
+ // Let's unblock MediaPuller's MediaSource::read().
+ mRepeaterSource->wakeUp();
+ }
+
+ mMediaPuller->stopAsync(msg);
+ } else {
+ msg->post();
+ }
+}
+
+void WifiDisplaySource::PlaybackSession::Track::onMessageReceived(
+ const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatMediaPullerStopped:
+ {
+ mConverter.clear();
+
+ mStarted = false;
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatStopped);
+ notify->post();
+
+ ALOGI("kWhatStopped %s posted", mIsAudio ? "audio" : "video");
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void WifiDisplaySource::PlaybackSession::Track::queueAccessUnit(
+ const sp<ABuffer> &accessUnit) {
+ mQueuedAccessUnits.push_back(accessUnit);
+}
+
+sp<ABuffer> WifiDisplaySource::PlaybackSession::Track::dequeueAccessUnit() {
+ if (mQueuedAccessUnits.empty()) {
+ return NULL;
+ }
+
+ sp<ABuffer> accessUnit = *mQueuedAccessUnits.begin();
+ CHECK(accessUnit != NULL);
+
+ mQueuedAccessUnits.erase(mQueuedAccessUnits.begin());
+
+ return accessUnit;
+}
+
+void WifiDisplaySource::PlaybackSession::Track::setRepeaterSource(
+ const sp<RepeaterSource> &source) {
+ mRepeaterSource = source;
+}
+
+void WifiDisplaySource::PlaybackSession::Track::requestIDRFrame() {
+ if (mIsAudio) {
+ return;
+ }
+
+ if (mRepeaterSource != NULL) {
+ mRepeaterSource->wakeUp();
+ }
+
+ mConverter->requestIDRFrame();
+}
+
+bool WifiDisplaySource::PlaybackSession::Track::hasOutputBuffer(
+ int64_t *timeUs) const {
+ *timeUs = 0ll;
+
+ if (mQueuedOutputBuffers.empty()) {
+ return false;
+ }
+
+ const sp<ABuffer> &outputBuffer = *mQueuedOutputBuffers.begin();
+
+ CHECK(outputBuffer->meta()->findInt64("timeUs", timeUs));
+
+ return true;
+}
+
+void WifiDisplaySource::PlaybackSession::Track::queueOutputBuffer(
+ const sp<ABuffer> &accessUnit) {
+ mQueuedOutputBuffers.push_back(accessUnit);
+
+ mLastOutputBufferQueuedTimeUs = ALooper::GetNowUs();
+}
+
+sp<ABuffer> WifiDisplaySource::PlaybackSession::Track::dequeueOutputBuffer() {
+ CHECK(!mQueuedOutputBuffers.empty());
+
+ sp<ABuffer> outputBuffer = *mQueuedOutputBuffers.begin();
+ mQueuedOutputBuffers.erase(mQueuedOutputBuffers.begin());
+
+ return outputBuffer;
+}
+
+bool WifiDisplaySource::PlaybackSession::Track::isSuspended() const {
+ if (!mQueuedOutputBuffers.empty()) {
+ return false;
+ }
+
+ if (mLastOutputBufferQueuedTimeUs < 0ll) {
+ // We've never seen an output buffer queued, but tracks start
+ // out live, not suspended.
+ return false;
+ }
+
+ // If we've not seen new output data for 60ms or more, we consider
+ // this track suspended for the time being.
+ return (ALooper::GetNowUs() - mLastOutputBufferQueuedTimeUs) > 60000ll;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+WifiDisplaySource::PlaybackSession::PlaybackSession(
+ const sp<ANetworkSession> &netSession,
+ const sp<AMessage> &notify,
+ const in_addr &interfaceAddr,
+ const sp<IHDCP> &hdcp)
+ : mNetSession(netSession),
+ mNotify(notify),
+ mInterfaceAddr(interfaceAddr),
+ mHDCP(hdcp),
+ mWeAreDead(false),
+ mLastLifesignUs(),
+ mVideoTrackIndex(-1),
+ mPrevTimeUs(-1ll),
+ mAllTracksHavePacketizerIndex(false) {
+}
+
+status_t WifiDisplaySource::PlaybackSession::init(
+ const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
+ Sender::TransportMode transportMode,
+ bool usePCMAudio) {
+ status_t err = setupPacketizer(usePCMAudio);
+
+ if (err != OK) {
+ return err;
+ }
+
+ sp<AMessage> notify = new AMessage(kWhatSenderNotify, id());
+ mSender = new Sender(mNetSession, notify);
+
+ mSenderLooper = new ALooper;
+ mSenderLooper->setName("sender_looper");
+
+ mSenderLooper->start(
+ false /* runOnCallingThread */,
+ false /* canCallJava */,
+ PRIORITY_AUDIO);
+
+ mSenderLooper->registerHandler(mSender);
+
+ err = mSender->init(clientIP, clientRtp, clientRtcp, transportMode);
+
+ if (err != OK) {
+ return err;
+ }
+
+ updateLiveness();
+
+ return OK;
+}
+
+WifiDisplaySource::PlaybackSession::~PlaybackSession() {
+}
+
+int32_t WifiDisplaySource::PlaybackSession::getRTPPort() const {
+ return mSender->getRTPPort();
+}
+
+int64_t WifiDisplaySource::PlaybackSession::getLastLifesignUs() const {
+ return mLastLifesignUs;
+}
+
+void WifiDisplaySource::PlaybackSession::updateLiveness() {
+ mLastLifesignUs = ALooper::GetNowUs();
+}
+
+status_t WifiDisplaySource::PlaybackSession::play() {
+ updateLiveness();
+
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::finishPlay() {
+ // XXX Give the dongle a second to bind its sockets.
+ (new AMessage(kWhatFinishPlay, id()))->post(1000000ll);
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::onFinishPlay() {
+ return mSender->finishInit();
+}
+
+status_t WifiDisplaySource::PlaybackSession::onFinishPlay2() {
+ mSender->scheduleSendSR();
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ CHECK_EQ((status_t)OK, mTracks.editValueAt(i)->start());
+ }
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatSessionEstablished);
+ notify->post();
+
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::pause() {
+ updateLiveness();
+
+ return OK;
+}
+
+void WifiDisplaySource::PlaybackSession::destroyAsync() {
+ ALOGI("destroyAsync");
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ mTracks.valueAt(i)->stopAsync();
+ }
+}
+
+void WifiDisplaySource::PlaybackSession::onMessageReceived(
+ const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatConverterNotify:
+ {
+ if (mWeAreDead) {
+ ALOGV("dropping msg '%s' because we're dead",
+ msg->debugString().c_str());
+
+ break;
+ }
+
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ size_t trackIndex;
+ CHECK(msg->findSize("trackIndex", &trackIndex));
+
+ if (what == Converter::kWhatAccessUnit) {
+ const sp<Track> &track = mTracks.valueFor(trackIndex);
+
+ ssize_t packetizerTrackIndex = track->packetizerTrackIndex();
+
+ if (packetizerTrackIndex < 0) {
+ packetizerTrackIndex =
+ mPacketizer->addTrack(track->getFormat());
+
+ CHECK_GE(packetizerTrackIndex, 0);
+
+ track->setPacketizerTrackIndex(packetizerTrackIndex);
+
+ if (allTracksHavePacketizerIndex()) {
+ status_t err = packetizeQueuedAccessUnits();
+
+ if (err != OK) {
+ notifySessionDead();
+ break;
+ }
+ }
+ }
+
+ sp<ABuffer> accessUnit;
+ CHECK(msg->findBuffer("accessUnit", &accessUnit));
+
+ if (!allTracksHavePacketizerIndex()) {
+ track->queueAccessUnit(accessUnit);
+ break;
+ }
+
+ track->queueOutputBuffer(accessUnit);
+
+ drainAccessUnits();
+ break;
+ } else if (what == Converter::kWhatEOS) {
+ CHECK_EQ(what, Converter::kWhatEOS);
+
+ ALOGI("output EOS on track %d", trackIndex);
+
+ ssize_t index = mTracks.indexOfKey(trackIndex);
+ CHECK_GE(index, 0);
+
+ const sp<Converter> &converter =
+ mTracks.valueAt(index)->converter();
+ looper()->unregisterHandler(converter->id());
+
+ mTracks.removeItemsAt(index);
+
+ if (mTracks.isEmpty()) {
+ ALOGI("Reached EOS");
+ }
+ } else {
+ CHECK_EQ(what, Converter::kWhatError);
+
+ status_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ ALOGE("converter signaled error %d", err);
+
+ notifySessionDead();
+ }
+ break;
+ }
+
+ case kWhatSenderNotify:
+ {
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ if (what == Sender::kWhatInitDone) {
+ onFinishPlay2();
+ } else if (what == Sender::kWhatSessionDead) {
+ notifySessionDead();
+ } else {
+ TRESPASS();
+ }
+
+ break;
+ }
+
+ case kWhatFinishPlay:
+ {
+ onFinishPlay();
+ break;
+ }
+
+ case kWhatTrackNotify:
+ {
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ size_t trackIndex;
+ CHECK(msg->findSize("trackIndex", &trackIndex));
+
+ if (what == Track::kWhatStopped) {
+ ALOGI("Track %d stopped", trackIndex);
+
+ sp<Track> track = mTracks.valueFor(trackIndex);
+ looper()->unregisterHandler(track->id());
+ mTracks.removeItem(trackIndex);
+ track.clear();
+
+ if (!mTracks.isEmpty()) {
+ ALOGI("not all tracks are stopped yet");
+ break;
+ }
+
+ mSenderLooper->unregisterHandler(mSender->id());
+ mSender.clear();
+ mSenderLooper.clear();
+
+ mPacketizer.clear();
+
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatSessionDestroyed);
+ notify->post();
+ }
+ break;
+ }
+
+ case kWhatPacketize:
+ {
+ size_t trackIndex;
+ CHECK(msg->findSize("trackIndex", &trackIndex));
+
+ sp<ABuffer> accessUnit;
+ CHECK(msg->findBuffer("accessUnit", &accessUnit));
+
+#if 0
+ if ((ssize_t)trackIndex == mVideoTrackIndex) {
+ int64_t nowUs = ALooper::GetNowUs();
+ static int64_t prevNowUs = 0ll;
+
+ ALOGI("sending AU, dNowUs=%lld us", nowUs - prevNowUs);
+
+ prevNowUs = nowUs;
+ }
+#endif
+
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+status_t WifiDisplaySource::PlaybackSession::setupPacketizer(bool usePCMAudio) {
+ mPacketizer = new TSPacketizer;
+
+ status_t err = addVideoSource();
+
+ if (err != OK) {
+ return err;
+ }
+
+ return addAudioSource(usePCMAudio);
+}
+
+status_t WifiDisplaySource::PlaybackSession::addSource(
+ bool isVideo, const sp<MediaSource> &source, bool isRepeaterSource,
+ bool usePCMAudio, size_t *numInputBuffers) {
+ CHECK(!usePCMAudio || !isVideo);
+ CHECK(!isRepeaterSource || isVideo);
+
+ sp<ALooper> pullLooper = new ALooper;
+ pullLooper->setName("pull_looper");
+
+ pullLooper->start(
+ false /* runOnCallingThread */,
+ false /* canCallJava */,
+ PRIORITY_AUDIO);
+
+ sp<ALooper> codecLooper = new ALooper;
+ codecLooper->setName("codec_looper");
+
+ codecLooper->start(
+ false /* runOnCallingThread */,
+ false /* canCallJava */,
+ PRIORITY_AUDIO);
+
+ size_t trackIndex;
+
+ sp<AMessage> notify;
+
+ trackIndex = mTracks.size();
+
+ sp<AMessage> format;
+ status_t err = convertMetaDataToMessage(source->getFormat(), &format);
+ CHECK_EQ(err, (status_t)OK);
+
+ if (isVideo) {
+ format->setInt32("store-metadata-in-buffers", true);
+
+ format->setInt32(
+ "color-format", OMX_COLOR_FormatAndroidOpaque);
+ }
+
+ notify = new AMessage(kWhatConverterNotify, id());
+ notify->setSize("trackIndex", trackIndex);
+
+ sp<Converter> converter =
+ new Converter(notify, codecLooper, format, usePCMAudio);
+
+ if (converter->initCheck() != OK) {
+ return converter->initCheck();
+ }
+
+ looper()->registerHandler(converter);
+
+ notify = new AMessage(Converter::kWhatMediaPullerNotify, converter->id());
+ notify->setSize("trackIndex", trackIndex);
+
+ sp<MediaPuller> puller = new MediaPuller(source, notify);
+ pullLooper->registerHandler(puller);
+
+ if (numInputBuffers != NULL) {
+ *numInputBuffers = converter->getInputBufferCount();
+ }
+
+ notify = new AMessage(kWhatTrackNotify, id());
+ notify->setSize("trackIndex", trackIndex);
+
+ sp<Track> track = new Track(
+ notify, pullLooper, codecLooper, puller, converter);
+
+ if (isRepeaterSource) {
+ track->setRepeaterSource(static_cast<RepeaterSource *>(source.get()));
+ }
+
+ looper()->registerHandler(track);
+
+ mTracks.add(trackIndex, track);
+
+ if (isVideo) {
+ mVideoTrackIndex = trackIndex;
+ }
+
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::addVideoSource() {
+ sp<SurfaceMediaSource> source = new SurfaceMediaSource(width(), height());
+
+ source->setUseAbsoluteTimestamps();
+
+#if 1
+ sp<RepeaterSource> videoSource =
+ new RepeaterSource(source, 30.0 /* rateHz */);
+#endif
+
+#if 1
+ size_t numInputBuffers;
+ status_t err = addSource(
+ true /* isVideo */, videoSource, true /* isRepeaterSource */,
+ false /* usePCMAudio */, &numInputBuffers);
+#else
+ size_t numInputBuffers;
+ status_t err = addSource(
+ true /* isVideo */, source, false /* isRepeaterSource */,
+ false /* usePCMAudio */, &numInputBuffers);
+#endif
+
+ if (err != OK) {
+ return err;
+ }
+
+ err = source->setMaxAcquiredBufferCount(numInputBuffers);
+ CHECK_EQ(err, (status_t)OK);
+
+ mBufferQueue = source->getBufferQueue();
+
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::addAudioSource(bool usePCMAudio) {
+ sp<AudioSource> audioSource = new AudioSource(
+ AUDIO_SOURCE_REMOTE_SUBMIX,
+ 48000 /* sampleRate */,
+ 2 /* channelCount */);
+
+ if (audioSource->initCheck() == OK) {
+ return addSource(
+ false /* isVideo */, audioSource, false /* isRepeaterSource */,
+ usePCMAudio, NULL /* numInputBuffers */);
+ }
+
+ ALOGW("Unable to instantiate audio source");
+
+ return OK;
+}
+
+sp<ISurfaceTexture> WifiDisplaySource::PlaybackSession::getSurfaceTexture() {
+ return mBufferQueue;
+}
+
+int32_t WifiDisplaySource::PlaybackSession::width() const {
+ return 1280;
+}
+
+int32_t WifiDisplaySource::PlaybackSession::height() const {
+ return 720;
+}
+
+void WifiDisplaySource::PlaybackSession::requestIDRFrame() {
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ const sp<Track> &track = mTracks.valueAt(i);
+
+ track->requestIDRFrame();
+ }
+}
+
+bool WifiDisplaySource::PlaybackSession::allTracksHavePacketizerIndex() {
+ if (mAllTracksHavePacketizerIndex) {
+ return true;
+ }
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ if (mTracks.valueAt(i)->packetizerTrackIndex() < 0) {
+ return false;
+ }
+ }
+
+ mAllTracksHavePacketizerIndex = true;
+
+ return true;
+}
+
+status_t WifiDisplaySource::PlaybackSession::packetizeAccessUnit(
+ size_t trackIndex, const sp<ABuffer> &accessUnit,
+ sp<ABuffer> *packets) {
+ const sp<Track> &track = mTracks.valueFor(trackIndex);
+
+ uint32_t flags = 0;
+
+ bool isHDCPEncrypted = false;
+ uint64_t inputCTR;
+ uint8_t HDCP_private_data[16];
+ if (mHDCP != NULL && !track->isAudio()) {
+ isHDCPEncrypted = true;
+
+ status_t err = mHDCP->encrypt(
+ accessUnit->data(), accessUnit->size(),
+ trackIndex /* streamCTR */,
+ &inputCTR,
+ accessUnit->data());
+
+ if (err != OK) {
+ ALOGE("Failed to HDCP-encrypt media data (err %d)",
+ err);
+
+ return err;
+ }
+
+ HDCP_private_data[0] = 0x00;
+
+ HDCP_private_data[1] =
+ (((trackIndex >> 30) & 3) << 1) | 1;
+
+ HDCP_private_data[2] = (trackIndex >> 22) & 0xff;
+
+ HDCP_private_data[3] =
+ (((trackIndex >> 15) & 0x7f) << 1) | 1;
+
+ HDCP_private_data[4] = (trackIndex >> 7) & 0xff;
+
+ HDCP_private_data[5] =
+ ((trackIndex & 0x7f) << 1) | 1;
+
+ HDCP_private_data[6] = 0x00;
+
+ HDCP_private_data[7] =
+ (((inputCTR >> 60) & 0x0f) << 1) | 1;
+
+ HDCP_private_data[8] = (inputCTR >> 52) & 0xff;
+
+ HDCP_private_data[9] =
+ (((inputCTR >> 45) & 0x7f) << 1) | 1;
+
+ HDCP_private_data[10] = (inputCTR >> 37) & 0xff;
+
+ HDCP_private_data[11] =
+ (((inputCTR >> 30) & 0x7f) << 1) | 1;
+
+ HDCP_private_data[12] = (inputCTR >> 22) & 0xff;
+
+ HDCP_private_data[13] =
+ (((inputCTR >> 15) & 0x7f) << 1) | 1;
+
+ HDCP_private_data[14] = (inputCTR >> 7) & 0xff;
+
+ HDCP_private_data[15] =
+ ((inputCTR & 0x7f) << 1) | 1;
+
+#if 0
+ ALOGI("HDCP_private_data:");
+ hexdump(HDCP_private_data, sizeof(HDCP_private_data));
+
+ ABitReader br(HDCP_private_data, sizeof(HDCP_private_data));
+ CHECK_EQ(br.getBits(13), 0);
+ CHECK_EQ(br.getBits(2), (trackIndex >> 30) & 3);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), (trackIndex >> 15) & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), trackIndex & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(11), 0);
+ CHECK_EQ(br.getBits(4), (inputCTR >> 60) & 0xf);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), (inputCTR >> 45) & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), (inputCTR >> 30) & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), (inputCTR >> 15) & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+ CHECK_EQ(br.getBits(15), inputCTR & 0x7fff);
+ CHECK_EQ(br.getBits(1), 1u);
+#endif
+
+ flags |= TSPacketizer::IS_ENCRYPTED;
+ }
+
+ int64_t timeUs = ALooper::GetNowUs();
+ if (mPrevTimeUs < 0ll || mPrevTimeUs + 100000ll <= timeUs) {
+ flags |= TSPacketizer::EMIT_PCR;
+ flags |= TSPacketizer::EMIT_PAT_AND_PMT;
+
+ mPrevTimeUs = timeUs;
+ }
+
+ mPacketizer->packetize(
+ track->packetizerTrackIndex(), accessUnit, packets, flags,
+ !isHDCPEncrypted ? NULL : HDCP_private_data,
+ !isHDCPEncrypted ? 0 : sizeof(HDCP_private_data),
+ track->isAudio() ? 2 : 0 /* numStuffingBytes */);
+
+ return OK;
+}
+
+status_t WifiDisplaySource::PlaybackSession::packetizeQueuedAccessUnits() {
+ for (;;) {
+ bool gotMoreData = false;
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ size_t trackIndex = mTracks.keyAt(i);
+ const sp<Track> &track = mTracks.valueAt(i);
+
+ sp<ABuffer> accessUnit = track->dequeueAccessUnit();
+ if (accessUnit != NULL) {
+ track->queueOutputBuffer(accessUnit);
+ gotMoreData = true;
+ }
+ }
+
+ if (!gotMoreData) {
+ break;
+ }
+ }
+
+ return OK;
+}
+
+void WifiDisplaySource::PlaybackSession::notifySessionDead() {
+ // Inform WifiDisplaySource of our premature death (wish).
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatSessionDead);
+ notify->post();
+
+ mWeAreDead = true;
+}
+
+void WifiDisplaySource::PlaybackSession::drainAccessUnits() {
+ ALOGV("audio/video has %d/%d buffers ready.",
+ mTracks.valueFor(1)->countQueuedOutputBuffers(),
+ mTracks.valueFor(0)->countQueuedOutputBuffers());
+
+ while (drainAccessUnit()) {
+ }
+}
+
+bool WifiDisplaySource::PlaybackSession::drainAccessUnit() {
+ ssize_t minTrackIndex = -1;
+ int64_t minTimeUs = -1ll;
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ const sp<Track> &track = mTracks.valueAt(i);
+
+ int64_t timeUs;
+ if (track->hasOutputBuffer(&timeUs)) {
+ if (minTrackIndex < 0 || timeUs < minTimeUs) {
+ minTrackIndex = mTracks.keyAt(i);
+ minTimeUs = timeUs;
+ }
+ } else if (!track->isSuspended()) {
+ // We still consider this track "live", so it should keep
+ // delivering output data whose time stamps we'll have to
+ // consider for proper interleaving.
+ return false;
+ }
+ }
+
+ if (minTrackIndex < 0) {
+ return false;
+ }
+
+ const sp<Track> &track = mTracks.valueFor(minTrackIndex);
+ sp<ABuffer> accessUnit = track->dequeueOutputBuffer();
+
+ sp<ABuffer> packets;
+ status_t err = packetizeAccessUnit(minTrackIndex, accessUnit, &packets);
+
+ if (err != OK) {
+ notifySessionDead();
+ }
+
+ if ((ssize_t)minTrackIndex == mVideoTrackIndex) {
+ packets->meta()->setInt32("isVideo", 1);
+ }
+ mSender->queuePackets(minTimeUs, packets);
+
+ return true;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/source/PlaybackSession.h b/media/libstagefright/wifi-display/source/PlaybackSession.h
new file mode 100644
index 0000000..cc8b244
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.h
@@ -0,0 +1,148 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef PLAYBACK_SESSION_H_
+
+#define PLAYBACK_SESSION_H_
+
+#include "Sender.h"
+#include "WifiDisplaySource.h"
+
+namespace android {
+
+struct ABuffer;
+struct BufferQueue;
+struct IHDCP;
+struct ISurfaceTexture;
+struct MediaPuller;
+struct MediaSource;
+struct TSPacketizer;
+
+// Encapsulates the state of an RTP/RTCP session in the context of wifi
+// display.
+struct WifiDisplaySource::PlaybackSession : public AHandler {
+ PlaybackSession(
+ const sp<ANetworkSession> &netSession,
+ const sp<AMessage> &notify,
+ const struct in_addr &interfaceAddr,
+ const sp<IHDCP> &hdcp);
+
+ status_t init(
+ const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
+ Sender::TransportMode transportMode,
+ bool usePCMAudio);
+
+ void destroyAsync();
+
+ int32_t getRTPPort() const;
+
+ int64_t getLastLifesignUs() const;
+ void updateLiveness();
+
+ status_t play();
+ status_t finishPlay();
+ status_t pause();
+
+ sp<ISurfaceTexture> getSurfaceTexture();
+ int32_t width() const;
+ int32_t height() const;
+
+ void requestIDRFrame();
+
+ enum {
+ kWhatSessionDead,
+ kWhatBinaryData,
+ kWhatSessionEstablished,
+ kWhatSessionDestroyed,
+ };
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~PlaybackSession();
+
+private:
+ struct Track;
+
+ enum {
+ kWhatMediaPullerNotify,
+ kWhatConverterNotify,
+ kWhatTrackNotify,
+ kWhatSenderNotify,
+ kWhatUpdateSurface,
+ kWhatFinishPlay,
+ kWhatPacketize,
+ };
+
+ sp<ANetworkSession> mNetSession;
+ sp<Sender> mSender;
+ sp<ALooper> mSenderLooper;
+ sp<AMessage> mNotify;
+ in_addr mInterfaceAddr;
+ sp<IHDCP> mHDCP;
+ bool mWeAreDead;
+
+ int64_t mLastLifesignUs;
+
+ sp<TSPacketizer> mPacketizer;
+ sp<BufferQueue> mBufferQueue;
+
+ KeyedVector<size_t, sp<Track> > mTracks;
+ ssize_t mVideoTrackIndex;
+
+ int64_t mPrevTimeUs;
+
+ bool mAllTracksHavePacketizerIndex;
+
+ status_t setupPacketizer(bool usePCMAudio);
+
+ status_t addSource(
+ bool isVideo,
+ const sp<MediaSource> &source,
+ bool isRepeaterSource,
+ bool usePCMAudio,
+ size_t *numInputBuffers);
+
+ status_t addVideoSource();
+ status_t addAudioSource(bool usePCMAudio);
+
+ ssize_t appendTSData(
+ const void *data, size_t size, bool timeDiscontinuity, bool flush);
+
+ status_t onFinishPlay();
+ status_t onFinishPlay2();
+
+ bool allTracksHavePacketizerIndex();
+
+ status_t packetizeAccessUnit(
+ size_t trackIndex, const sp<ABuffer> &accessUnit,
+ sp<ABuffer> *packets);
+
+ status_t packetizeQueuedAccessUnits();
+
+ void notifySessionDead();
+
+ void drainAccessUnits();
+
+ // Returns true iff an access unit was successfully drained.
+ bool drainAccessUnit();
+
+ DISALLOW_EVIL_CONSTRUCTORS(PlaybackSession);
+};
+
+} // namespace android
+
+#endif // PLAYBACK_SESSION_H_
+
diff --git a/media/libstagefright/wifi-display/source/RepeaterSource.cpp b/media/libstagefright/wifi-display/source/RepeaterSource.cpp
new file mode 100644
index 0000000..641e63f
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.cpp
@@ -0,0 +1,196 @@
+//#define LOG_NDEBUG 0
+#define LOG_TAG "RepeaterSource"
+#include <utils/Log.h>
+
+#include "RepeaterSource.h"
+
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaBuffer.h>
+#include <media/stagefright/MetaData.h>
+
+namespace android {
+
+RepeaterSource::RepeaterSource(const sp<MediaSource> &source, double rateHz)
+ : mStarted(false),
+ mSource(source),
+ mRateHz(rateHz),
+ mBuffer(NULL),
+ mResult(OK),
+ mLastBufferUpdateUs(-1ll),
+ mStartTimeUs(-1ll),
+ mFrameCount(0) {
+}
+
+RepeaterSource::~RepeaterSource() {
+ CHECK(!mStarted);
+}
+
+status_t RepeaterSource::start(MetaData *params) {
+ CHECK(!mStarted);
+
+ status_t err = mSource->start(params);
+
+ if (err != OK) {
+ return err;
+ }
+
+ mBuffer = NULL;
+ mResult = OK;
+ mStartTimeUs = -1ll;
+ mFrameCount = 0;
+
+ mLooper = new ALooper;
+ mLooper->setName("repeater_looper");
+ mLooper->start();
+
+ mReflector = new AHandlerReflector<RepeaterSource>(this);
+ mLooper->registerHandler(mReflector);
+
+ postRead();
+
+ mStarted = true;
+
+ return OK;
+}
+
+status_t RepeaterSource::stop() {
+ CHECK(mStarted);
+
+ ALOGV("stopping");
+
+ if (mLooper != NULL) {
+ mLooper->stop();
+ mLooper.clear();
+
+ mReflector.clear();
+ }
+
+ if (mBuffer != NULL) {
+ ALOGV("releasing mbuf %p", mBuffer);
+ mBuffer->release();
+ mBuffer = NULL;
+ }
+
+ status_t err = mSource->stop();
+
+ ALOGV("stopped");
+
+ mStarted = false;
+
+ return err;
+}
+
+sp<MetaData> RepeaterSource::getFormat() {
+ return mSource->getFormat();
+}
+
+status_t RepeaterSource::read(
+ MediaBuffer **buffer, const ReadOptions *options) {
+ int64_t seekTimeUs;
+ ReadOptions::SeekMode seekMode;
+ CHECK(options == NULL || !options->getSeekTo(&seekTimeUs, &seekMode));
+
+ for (;;) {
+ int64_t bufferTimeUs = -1ll;
+
+ if (mStartTimeUs < 0ll) {
+ Mutex::Autolock autoLock(mLock);
+ while ((mLastBufferUpdateUs < 0ll || mBuffer == NULL)
+ && mResult == OK) {
+ mCondition.wait(mLock);
+ }
+
+ ALOGV("now resuming.");
+ mStartTimeUs = ALooper::GetNowUs();
+ bufferTimeUs = mStartTimeUs;
+ } else {
+ bufferTimeUs = mStartTimeUs + (mFrameCount * 1000000ll) / mRateHz;
+
+ int64_t nowUs = ALooper::GetNowUs();
+ int64_t delayUs = bufferTimeUs - nowUs;
+
+ if (delayUs > 0ll) {
+ usleep(delayUs);
+ }
+ }
+
+ bool stale = false;
+
+ {
+ Mutex::Autolock autoLock(mLock);
+ if (mResult != OK) {
+ CHECK(mBuffer == NULL);
+ return mResult;
+ }
+
+ int64_t nowUs = ALooper::GetNowUs();
+ if (nowUs - mLastBufferUpdateUs > 1000000ll) {
+ mLastBufferUpdateUs = -1ll;
+ stale = true;
+ } else {
+ mBuffer->add_ref();
+ *buffer = mBuffer;
+ (*buffer)->meta_data()->setInt64(kKeyTime, bufferTimeUs);
+ ++mFrameCount;
+ }
+ }
+
+ if (!stale) {
+ break;
+ }
+
+ mStartTimeUs = -1ll;
+ mFrameCount = 0;
+ ALOGV("now dormant");
+ }
+
+ return OK;
+}
+
+void RepeaterSource::postRead() {
+ (new AMessage(kWhatRead, mReflector->id()))->post();
+}
+
+void RepeaterSource::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatRead:
+ {
+ MediaBuffer *buffer;
+ status_t err = mSource->read(&buffer);
+
+ ALOGV("read mbuf %p", buffer);
+
+ Mutex::Autolock autoLock(mLock);
+ if (mBuffer != NULL) {
+ mBuffer->release();
+ mBuffer = NULL;
+ }
+ mBuffer = buffer;
+ mResult = err;
+ mLastBufferUpdateUs = ALooper::GetNowUs();
+
+ mCondition.broadcast();
+
+ if (err == OK) {
+ postRead();
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void RepeaterSource::wakeUp() {
+ ALOGV("wakeUp");
+ Mutex::Autolock autoLock(mLock);
+ if (mLastBufferUpdateUs < 0ll && mBuffer != NULL) {
+ mLastBufferUpdateUs = ALooper::GetNowUs();
+ mCondition.broadcast();
+ }
+}
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/source/RepeaterSource.h b/media/libstagefright/wifi-display/source/RepeaterSource.h
new file mode 100644
index 0000000..e4aa2b6
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.h
@@ -0,0 +1,62 @@
+#ifndef REPEATER_SOURCE_H_
+
+#define REPEATER_SOURCE_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <media/stagefright/foundation/AHandlerReflector.h>
+#include <media/stagefright/MediaSource.h>
+
+namespace android {
+
+// This MediaSource delivers frames at a constant rate by repeating buffers
+// if necessary.
+struct RepeaterSource : public MediaSource {
+ RepeaterSource(const sp<MediaSource> &source, double rateHz);
+
+ virtual status_t start(MetaData *params);
+ virtual status_t stop();
+ virtual sp<MetaData> getFormat();
+
+ virtual status_t read(
+ MediaBuffer **buffer, const ReadOptions *options);
+
+ void onMessageReceived(const sp<AMessage> &msg);
+
+ // If RepeaterSource is currently dormant, because SurfaceFlinger didn't
+ // send updates in a while, this is its wakeup call.
+ void wakeUp();
+
+protected:
+ virtual ~RepeaterSource();
+
+private:
+ enum {
+ kWhatRead,
+ };
+
+ Mutex mLock;
+ Condition mCondition;
+
+ bool mStarted;
+
+ sp<MediaSource> mSource;
+ double mRateHz;
+
+ sp<ALooper> mLooper;
+ sp<AHandlerReflector<RepeaterSource> > mReflector;
+
+ MediaBuffer *mBuffer;
+ status_t mResult;
+ int64_t mLastBufferUpdateUs;
+
+ int64_t mStartTimeUs;
+ int32_t mFrameCount;
+
+ void postRead();
+
+ DISALLOW_EVIL_CONSTRUCTORS(RepeaterSource);
+};
+
+} // namespace android
+
+#endif // REPEATER_SOURCE_H_
diff --git a/media/libstagefright/wifi-display/source/Sender.cpp b/media/libstagefright/wifi-display/source/Sender.cpp
new file mode 100644
index 0000000..ea12424
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Sender.cpp
@@ -0,0 +1,979 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "Sender"
+#include <utils/Log.h>
+
+#include "Sender.h"
+
+#include "ANetworkSession.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/Utils.h>
+
+#include <math.h>
+
+#define DEBUG_JITTER 0
+
+namespace android {
+
+////////////////////////////////////////////////////////////////////////////////
+
+#if DEBUG_JITTER
+struct TimeSeries {
+ TimeSeries();
+
+ void add(double val);
+
+ double mean() const;
+ double sdev() const;
+
+private:
+ enum {
+ kHistorySize = 20
+ };
+ double mValues[kHistorySize];
+
+ size_t mCount;
+ double mSum;
+};
+
+TimeSeries::TimeSeries()
+ : mCount(0),
+ mSum(0.0) {
+}
+
+void TimeSeries::add(double val) {
+ if (mCount < kHistorySize) {
+ mValues[mCount++] = val;
+ mSum += val;
+ } else {
+ mSum -= mValues[0];
+ memmove(&mValues[0], &mValues[1], (kHistorySize - 1) * sizeof(double));
+ mValues[kHistorySize - 1] = val;
+ mSum += val;
+ }
+}
+
+double TimeSeries::mean() const {
+ if (mCount < 1) {
+ return 0.0;
+ }
+
+ return mSum / mCount;
+}
+
+double TimeSeries::sdev() const {
+ if (mCount < 1) {
+ return 0.0;
+ }
+
+ double m = mean();
+
+ double sum = 0.0;
+ for (size_t i = 0; i < mCount; ++i) {
+ double tmp = mValues[i] - m;
+ tmp *= tmp;
+
+ sum += tmp;
+ }
+
+ return sqrt(sum / mCount);
+}
+#endif // DEBUG_JITTER
+
+////////////////////////////////////////////////////////////////////////////////
+
+static size_t kMaxRTPPacketSize = 1500;
+static size_t kMaxNumTSPacketsPerRTPPacket = (kMaxRTPPacketSize - 12) / 188;
+
+Sender::Sender(
+ const sp<ANetworkSession> &netSession,
+ const sp<AMessage> &notify)
+ : mNetSession(netSession),
+ mNotify(notify),
+ mTSQueue(new ABuffer(12 + kMaxNumTSPacketsPerRTPPacket * 188)),
+ mTransportMode(TRANSPORT_UDP),
+ mRTPChannel(0),
+ mRTCPChannel(0),
+ mRTPPort(0),
+ mRTPSessionID(0),
+ mRTCPSessionID(0),
+#if ENABLE_RETRANSMISSION
+ mRTPRetransmissionSessionID(0),
+ mRTCPRetransmissionSessionID(0),
+#endif
+ mClientRTPPort(0),
+ mClientRTCPPort(0),
+ mRTPConnected(false),
+ mRTCPConnected(false),
+ mFirstOutputBufferReadyTimeUs(-1ll),
+ mFirstOutputBufferSentTimeUs(-1ll),
+ mRTPSeqNo(0),
+#if ENABLE_RETRANSMISSION
+ mRTPRetransmissionSeqNo(0),
+#endif
+ mLastNTPTime(0),
+ mLastRTPTime(0),
+ mNumRTPSent(0),
+ mNumRTPOctetsSent(0),
+ mNumSRsSent(0),
+ mSendSRPending(false)
+#if ENABLE_RETRANSMISSION
+ ,mHistoryLength(0)
+#endif
+#if TRACK_BANDWIDTH
+ ,mFirstPacketTimeUs(-1ll)
+ ,mTotalBytesSent(0ll)
+#endif
+#if LOG_TRANSPORT_STREAM
+ ,mLogFile(NULL)
+#endif
+{
+ mTSQueue->setRange(0, 12);
+
+#if LOG_TRANSPORT_STREAM
+ mLogFile = fopen("/system/etc/log.ts", "wb");
+#endif
+}
+
+Sender::~Sender() {
+#if ENABLE_RETRANSMISSION
+ if (mRTCPRetransmissionSessionID != 0) {
+ mNetSession->destroySession(mRTCPRetransmissionSessionID);
+ }
+
+ if (mRTPRetransmissionSessionID != 0) {
+ mNetSession->destroySession(mRTPRetransmissionSessionID);
+ }
+#endif
+
+ if (mRTCPSessionID != 0) {
+ mNetSession->destroySession(mRTCPSessionID);
+ }
+
+ if (mRTPSessionID != 0) {
+ mNetSession->destroySession(mRTPSessionID);
+ }
+
+#if LOG_TRANSPORT_STREAM
+ if (mLogFile != NULL) {
+ fclose(mLogFile);
+ mLogFile = NULL;
+ }
+#endif
+}
+
+status_t Sender::init(
+ const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
+ TransportMode transportMode) {
+ mClientIP = clientIP;
+ mTransportMode = transportMode;
+
+ if (transportMode == TRANSPORT_TCP_INTERLEAVED) {
+ mRTPChannel = clientRtp;
+ mRTCPChannel = clientRtcp;
+ mRTPPort = 0;
+ mRTPSessionID = 0;
+ mRTCPSessionID = 0;
+ return OK;
+ }
+
+ mRTPChannel = 0;
+ mRTCPChannel = 0;
+
+ if (mTransportMode == TRANSPORT_TCP) {
+ // XXX This is wrong, we need to allocate sockets here, we only
+ // need to do this because the dongles are not establishing their
+ // end until after PLAY instead of before SETUP.
+ mRTPPort = 20000;
+ mRTPSessionID = 0;
+ mRTCPSessionID = 0;
+ mClientRTPPort = clientRtp;
+ mClientRTCPPort = clientRtcp;
+ return OK;
+ }
+
+ int serverRtp;
+
+ sp<AMessage> rtpNotify = new AMessage(kWhatRTPNotify, id());
+ sp<AMessage> rtcpNotify = new AMessage(kWhatRTCPNotify, id());
+
+#if ENABLE_RETRANSMISSION
+ sp<AMessage> rtpRetransmissionNotify =
+ new AMessage(kWhatRTPRetransmissionNotify, id());
+
+ sp<AMessage> rtcpRetransmissionNotify =
+ new AMessage(kWhatRTCPRetransmissionNotify, id());
+#endif
+
+ status_t err;
+ for (serverRtp = 15550;; serverRtp += 2) {
+ int32_t rtpSession;
+ if (mTransportMode == TRANSPORT_UDP) {
+ err = mNetSession->createUDPSession(
+ serverRtp, clientIP, clientRtp,
+ rtpNotify, &rtpSession);
+ } else {
+ err = mNetSession->createTCPDatagramSession(
+ serverRtp, clientIP, clientRtp,
+ rtpNotify, &rtpSession);
+ }
+
+ if (err != OK) {
+ ALOGI("failed to create RTP socket on port %d", serverRtp);
+ continue;
+ }
+
+ int32_t rtcpSession = 0;
+
+ if (clientRtcp >= 0) {
+ if (mTransportMode == TRANSPORT_UDP) {
+ err = mNetSession->createUDPSession(
+ serverRtp + 1, clientIP, clientRtcp,
+ rtcpNotify, &rtcpSession);
+ } else {
+ err = mNetSession->createTCPDatagramSession(
+ serverRtp + 1, clientIP, clientRtcp,
+ rtcpNotify, &rtcpSession);
+ }
+
+ if (err != OK) {
+ ALOGI("failed to create RTCP socket on port %d", serverRtp + 1);
+
+ mNetSession->destroySession(rtpSession);
+ continue;
+ }
+ }
+
+#if ENABLE_RETRANSMISSION
+ if (mTransportMode == TRANSPORT_UDP) {
+ int32_t rtpRetransmissionSession;
+
+ err = mNetSession->createUDPSession(
+ serverRtp + kRetransmissionPortOffset,
+ clientIP,
+ clientRtp + kRetransmissionPortOffset,
+ rtpRetransmissionNotify,
+ &rtpRetransmissionSession);
+
+ if (err != OK) {
+ mNetSession->destroySession(rtcpSession);
+ mNetSession->destroySession(rtpSession);
+ continue;
+ }
+
+ CHECK_GE(clientRtcp, 0);
+
+ int32_t rtcpRetransmissionSession;
+ err = mNetSession->createUDPSession(
+ serverRtp + 1 + kRetransmissionPortOffset,
+ clientIP,
+ clientRtp + 1 + kRetransmissionPortOffset,
+ rtcpRetransmissionNotify,
+ &rtcpRetransmissionSession);
+
+ if (err != OK) {
+ mNetSession->destroySession(rtpRetransmissionSession);
+ mNetSession->destroySession(rtcpSession);
+ mNetSession->destroySession(rtpSession);
+ continue;
+ }
+
+ mRTPRetransmissionSessionID = rtpRetransmissionSession;
+ mRTCPRetransmissionSessionID = rtcpRetransmissionSession;
+
+ ALOGI("rtpRetransmissionSessionID = %d, "
+ "rtcpRetransmissionSessionID = %d",
+ rtpRetransmissionSession, rtcpRetransmissionSession);
+ }
+#endif
+
+ mRTPPort = serverRtp;
+ mRTPSessionID = rtpSession;
+ mRTCPSessionID = rtcpSession;
+
+ ALOGI("rtpSessionID = %d, rtcpSessionID = %d", rtpSession, rtcpSession);
+ break;
+ }
+
+ if (mRTPPort == 0) {
+ return UNKNOWN_ERROR;
+ }
+
+ return OK;
+}
+
+status_t Sender::finishInit() {
+ if (mTransportMode != TRANSPORT_TCP) {
+ notifyInitDone();
+ return OK;
+ }
+
+ sp<AMessage> rtpNotify = new AMessage(kWhatRTPNotify, id());
+
+ status_t err = mNetSession->createTCPDatagramSession(
+ mRTPPort, mClientIP.c_str(), mClientRTPPort,
+ rtpNotify, &mRTPSessionID);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (mClientRTCPPort >= 0) {
+ sp<AMessage> rtcpNotify = new AMessage(kWhatRTCPNotify, id());
+
+ err = mNetSession->createTCPDatagramSession(
+ mRTPPort + 1, mClientIP.c_str(), mClientRTCPPort,
+ rtcpNotify, &mRTCPSessionID);
+
+ if (err != OK) {
+ return err;
+ }
+ }
+
+ return OK;
+}
+
+int32_t Sender::getRTPPort() const {
+ return mRTPPort;
+}
+
+void Sender::queuePackets(
+ int64_t timeUs, const sp<ABuffer> &packets) {
+ bool isVideo = false;
+
+ int32_t dummy;
+ if (packets->meta()->findInt32("isVideo", &dummy)) {
+ isVideo = true;
+ }
+
+ int64_t delayUs;
+ int64_t whenUs;
+
+ if (mFirstOutputBufferReadyTimeUs < 0ll) {
+ mFirstOutputBufferReadyTimeUs = timeUs;
+ mFirstOutputBufferSentTimeUs = whenUs = ALooper::GetNowUs();
+ delayUs = 0ll;
+ } else {
+ int64_t nowUs = ALooper::GetNowUs();
+
+ whenUs = (timeUs - mFirstOutputBufferReadyTimeUs)
+ + mFirstOutputBufferSentTimeUs;
+
+ delayUs = whenUs - nowUs;
+ }
+
+ sp<AMessage> msg = new AMessage(kWhatQueuePackets, id());
+ msg->setBuffer("packets", packets);
+
+ packets->meta()->setInt64("timeUs", timeUs);
+ packets->meta()->setInt64("whenUs", whenUs);
+ packets->meta()->setInt64("delayUs", delayUs);
+ msg->post(delayUs > 0 ? delayUs : 0);
+}
+
+void Sender::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatRTPNotify:
+ case kWhatRTCPNotify:
+#if ENABLE_RETRANSMISSION
+ case kWhatRTPRetransmissionNotify:
+ case kWhatRTCPRetransmissionNotify:
+#endif
+ {
+ int32_t reason;
+ CHECK(msg->findInt32("reason", &reason));
+
+ switch (reason) {
+ case ANetworkSession::kWhatError:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ int32_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ int32_t errorOccuredDuringSend;
+ CHECK(msg->findInt32("send", &errorOccuredDuringSend));
+
+ AString detail;
+ CHECK(msg->findString("detail", &detail));
+
+ if ((msg->what() == kWhatRTPNotify
+#if ENABLE_RETRANSMISSION
+ || msg->what() == kWhatRTPRetransmissionNotify
+#endif
+ ) && !errorOccuredDuringSend) {
+ // This is ok, we don't expect to receive anything on
+ // the RTP socket.
+ break;
+ }
+
+ ALOGE("An error occurred during %s in session %d "
+ "(%d, '%s' (%s)).",
+ errorOccuredDuringSend ? "send" : "receive",
+ sessionID,
+ err,
+ detail.c_str(),
+ strerror(-err));
+
+ mNetSession->destroySession(sessionID);
+
+ if (sessionID == mRTPSessionID) {
+ mRTPSessionID = 0;
+ } else if (sessionID == mRTCPSessionID) {
+ mRTCPSessionID = 0;
+ }
+#if ENABLE_RETRANSMISSION
+ else if (sessionID == mRTPRetransmissionSessionID) {
+ mRTPRetransmissionSessionID = 0;
+ } else if (sessionID == mRTCPRetransmissionSessionID) {
+ mRTCPRetransmissionSessionID = 0;
+ }
+#endif
+
+ notifySessionDead();
+ break;
+ }
+
+ case ANetworkSession::kWhatDatagram:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ sp<ABuffer> data;
+ CHECK(msg->findBuffer("data", &data));
+
+ status_t err;
+ if (msg->what() == kWhatRTCPNotify
+#if ENABLE_RETRANSMISSION
+ || msg->what() == kWhatRTCPRetransmissionNotify
+#endif
+ )
+ {
+ err = parseRTCP(data);
+ }
+ break;
+ }
+
+ case ANetworkSession::kWhatConnected:
+ {
+ CHECK_EQ(mTransportMode, TRANSPORT_TCP);
+
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ if (sessionID == mRTPSessionID) {
+ CHECK(!mRTPConnected);
+ mRTPConnected = true;
+ ALOGI("RTP Session now connected.");
+ } else if (sessionID == mRTCPSessionID) {
+ CHECK(!mRTCPConnected);
+ mRTCPConnected = true;
+ ALOGI("RTCP Session now connected.");
+ } else {
+ TRESPASS();
+ }
+
+ if (mRTPConnected
+ && (mClientRTCPPort < 0 || mRTCPConnected)) {
+ notifyInitDone();
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+ break;
+ }
+
+ case kWhatQueuePackets:
+ {
+ sp<ABuffer> packets;
+ CHECK(msg->findBuffer("packets", &packets));
+
+ onQueuePackets(packets);
+ break;
+ }
+
+ case kWhatSendSR:
+ {
+ mSendSRPending = false;
+
+ if (mRTCPSessionID == 0) {
+ break;
+ }
+
+ onSendSR();
+
+ scheduleSendSR();
+ break;
+ }
+ }
+}
+
+void Sender::onQueuePackets(const sp<ABuffer> &packets) {
+#if DEBUG_JITTER
+ int32_t dummy;
+ if (packets->meta()->findInt32("isVideo", &dummy)) {
+ static int64_t lastTimeUs = 0ll;
+ int64_t nowUs = ALooper::GetNowUs();
+
+ static TimeSeries series;
+ series.add((double)(nowUs - lastTimeUs));
+
+ ALOGI("deltaTimeUs = %lld us, mean %.2f, sdev %.2f",
+ nowUs - lastTimeUs, series.mean(), series.sdev());
+
+ lastTimeUs = nowUs;
+ }
+#endif
+
+ int64_t startTimeUs = ALooper::GetNowUs();
+
+ for (size_t offset = 0;
+ offset < packets->size(); offset += 188) {
+ bool lastTSPacket = (offset + 188 >= packets->size());
+
+ appendTSData(
+ packets->data() + offset,
+ 188,
+ true /* timeDiscontinuity */,
+ lastTSPacket /* flush */);
+ }
+
+#if 0
+ int64_t netTimeUs = ALooper::GetNowUs() - startTimeUs;
+
+ int64_t whenUs;
+ CHECK(packets->meta()->findInt64("whenUs", &whenUs));
+
+ int64_t delayUs;
+ CHECK(packets->meta()->findInt64("delayUs", &delayUs));
+
+ bool isVideo = false;
+ int32_t dummy;
+ if (packets->meta()->findInt32("isVideo", &dummy)) {
+ isVideo = true;
+ }
+
+ int64_t nowUs = ALooper::GetNowUs();
+
+ if (nowUs - whenUs > 2000) {
+ ALOGI("[%s] delayUs = %lld us, delta = %lld us",
+ isVideo ? "video" : "audio", delayUs, nowUs - netTimeUs - whenUs);
+ }
+#endif
+
+#if LOG_TRANSPORT_STREAM
+ if (mLogFile != NULL) {
+ fwrite(packets->data(), 1, packets->size(), mLogFile);
+ }
+#endif
+}
+
+ssize_t Sender::appendTSData(
+ const void *data, size_t size, bool timeDiscontinuity, bool flush) {
+ CHECK_EQ(size, 188);
+
+ CHECK_LE(mTSQueue->size() + size, mTSQueue->capacity());
+
+ memcpy(mTSQueue->data() + mTSQueue->size(), data, size);
+ mTSQueue->setRange(0, mTSQueue->size() + size);
+
+ if (flush || mTSQueue->size() == mTSQueue->capacity()) {
+ // flush
+
+ int64_t nowUs = ALooper::GetNowUs();
+
+#if TRACK_BANDWIDTH
+ if (mFirstPacketTimeUs < 0ll) {
+ mFirstPacketTimeUs = nowUs;
+ }
+#endif
+
+ // 90kHz time scale
+ uint32_t rtpTime = (nowUs * 9ll) / 100ll;
+
+ uint8_t *rtp = mTSQueue->data();
+ rtp[0] = 0x80;
+ rtp[1] = 33 | (timeDiscontinuity ? (1 << 7) : 0); // M-bit
+ rtp[2] = (mRTPSeqNo >> 8) & 0xff;
+ rtp[3] = mRTPSeqNo & 0xff;
+ rtp[4] = rtpTime >> 24;
+ rtp[5] = (rtpTime >> 16) & 0xff;
+ rtp[6] = (rtpTime >> 8) & 0xff;
+ rtp[7] = rtpTime & 0xff;
+ rtp[8] = kSourceID >> 24;
+ rtp[9] = (kSourceID >> 16) & 0xff;
+ rtp[10] = (kSourceID >> 8) & 0xff;
+ rtp[11] = kSourceID & 0xff;
+
+ ++mRTPSeqNo;
+ ++mNumRTPSent;
+ mNumRTPOctetsSent += mTSQueue->size() - 12;
+
+ mLastRTPTime = rtpTime;
+ mLastNTPTime = GetNowNTP();
+
+ if (mTransportMode == TRANSPORT_TCP_INTERLEAVED) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatBinaryData);
+
+ sp<ABuffer> data = new ABuffer(mTSQueue->size());
+ memcpy(data->data(), rtp, mTSQueue->size());
+
+ notify->setInt32("channel", mRTPChannel);
+ notify->setBuffer("data", data);
+ notify->post();
+ } else {
+ sendPacket(mRTPSessionID, rtp, mTSQueue->size());
+
+#if TRACK_BANDWIDTH
+ mTotalBytesSent += mTSQueue->size();
+ int64_t delayUs = ALooper::GetNowUs() - mFirstPacketTimeUs;
+
+ if (delayUs > 0ll) {
+ ALOGI("approx. net bandwidth used: %.2f Mbit/sec",
+ mTotalBytesSent * 8.0 / delayUs);
+ }
+#endif
+ }
+
+#if ENABLE_RETRANSMISSION
+ mTSQueue->setInt32Data(mRTPSeqNo - 1);
+
+ mHistory.push_back(mTSQueue);
+ ++mHistoryLength;
+
+ if (mHistoryLength > kMaxHistoryLength) {
+ mTSQueue = *mHistory.begin();
+ mHistory.erase(mHistory.begin());
+
+ --mHistoryLength;
+ } else {
+ mTSQueue = new ABuffer(12 + kMaxNumTSPacketsPerRTPPacket * 188);
+ }
+#endif
+
+ mTSQueue->setRange(0, 12);
+ }
+
+ return size;
+}
+
+void Sender::scheduleSendSR() {
+ if (mSendSRPending || mRTCPSessionID == 0) {
+ return;
+ }
+
+ mSendSRPending = true;
+ (new AMessage(kWhatSendSR, id()))->post(kSendSRIntervalUs);
+}
+
+void Sender::addSR(const sp<ABuffer> &buffer) {
+ uint8_t *data = buffer->data() + buffer->size();
+
+ // TODO: Use macros/utility functions to clean up all the bitshifts below.
+
+ data[0] = 0x80 | 0;
+ data[1] = 200; // SR
+ data[2] = 0;
+ data[3] = 6;
+ data[4] = kSourceID >> 24;
+ data[5] = (kSourceID >> 16) & 0xff;
+ data[6] = (kSourceID >> 8) & 0xff;
+ data[7] = kSourceID & 0xff;
+
+ data[8] = mLastNTPTime >> (64 - 8);
+ data[9] = (mLastNTPTime >> (64 - 16)) & 0xff;
+ data[10] = (mLastNTPTime >> (64 - 24)) & 0xff;
+ data[11] = (mLastNTPTime >> 32) & 0xff;
+ data[12] = (mLastNTPTime >> 24) & 0xff;
+ data[13] = (mLastNTPTime >> 16) & 0xff;
+ data[14] = (mLastNTPTime >> 8) & 0xff;
+ data[15] = mLastNTPTime & 0xff;
+
+ data[16] = (mLastRTPTime >> 24) & 0xff;
+ data[17] = (mLastRTPTime >> 16) & 0xff;
+ data[18] = (mLastRTPTime >> 8) & 0xff;
+ data[19] = mLastRTPTime & 0xff;
+
+ data[20] = mNumRTPSent >> 24;
+ data[21] = (mNumRTPSent >> 16) & 0xff;
+ data[22] = (mNumRTPSent >> 8) & 0xff;
+ data[23] = mNumRTPSent & 0xff;
+
+ data[24] = mNumRTPOctetsSent >> 24;
+ data[25] = (mNumRTPOctetsSent >> 16) & 0xff;
+ data[26] = (mNumRTPOctetsSent >> 8) & 0xff;
+ data[27] = mNumRTPOctetsSent & 0xff;
+
+ buffer->setRange(buffer->offset(), buffer->size() + 28);
+}
+
+void Sender::addSDES(const sp<ABuffer> &buffer) {
+ uint8_t *data = buffer->data() + buffer->size();
+ data[0] = 0x80 | 1;
+ data[1] = 202; // SDES
+ data[4] = kSourceID >> 24;
+ data[5] = (kSourceID >> 16) & 0xff;
+ data[6] = (kSourceID >> 8) & 0xff;
+ data[7] = kSourceID & 0xff;
+
+ size_t offset = 8;
+
+ data[offset++] = 1; // CNAME
+
+ static const char *kCNAME = "someone@somewhere";
+ data[offset++] = strlen(kCNAME);
+
+ memcpy(&data[offset], kCNAME, strlen(kCNAME));
+ offset += strlen(kCNAME);
+
+ data[offset++] = 7; // NOTE
+
+ static const char *kNOTE = "Hell's frozen over.";
+ data[offset++] = strlen(kNOTE);
+
+ memcpy(&data[offset], kNOTE, strlen(kNOTE));
+ offset += strlen(kNOTE);
+
+ data[offset++] = 0;
+
+ if ((offset % 4) > 0) {
+ size_t count = 4 - (offset % 4);
+ switch (count) {
+ case 3:
+ data[offset++] = 0;
+ case 2:
+ data[offset++] = 0;
+ case 1:
+ data[offset++] = 0;
+ }
+ }
+
+ size_t numWords = (offset / 4) - 1;
+ data[2] = numWords >> 8;
+ data[3] = numWords & 0xff;
+
+ buffer->setRange(buffer->offset(), buffer->size() + offset);
+}
+
+// static
+uint64_t Sender::GetNowNTP() {
+ uint64_t nowUs = ALooper::GetNowUs();
+
+ nowUs += ((70ll * 365 + 17) * 24) * 60 * 60 * 1000000ll;
+
+ uint64_t hi = nowUs / 1000000ll;
+ uint64_t lo = ((1ll << 32) * (nowUs % 1000000ll)) / 1000000ll;
+
+ return (hi << 32) | lo;
+}
+
+void Sender::onSendSR() {
+ sp<ABuffer> buffer = new ABuffer(1500);
+ buffer->setRange(0, 0);
+
+ addSR(buffer);
+ addSDES(buffer);
+
+ if (mTransportMode == TRANSPORT_TCP_INTERLEAVED) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatBinaryData);
+ notify->setInt32("channel", mRTCPChannel);
+ notify->setBuffer("data", buffer);
+ notify->post();
+ } else {
+ sendPacket(mRTCPSessionID, buffer->data(), buffer->size());
+ }
+
+ ++mNumSRsSent;
+}
+
+#if ENABLE_RETRANSMISSION
+status_t Sender::parseTSFB(
+ const uint8_t *data, size_t size) {
+ if ((data[0] & 0x1f) != 1) {
+ return ERROR_UNSUPPORTED; // We only support NACK for now.
+ }
+
+ uint32_t srcId = U32_AT(&data[8]);
+ if (srcId != kSourceID) {
+ return ERROR_MALFORMED;
+ }
+
+ for (size_t i = 12; i < size; i += 4) {
+ uint16_t seqNo = U16_AT(&data[i]);
+ uint16_t blp = U16_AT(&data[i + 2]);
+
+ List<sp<ABuffer> >::iterator it = mHistory.begin();
+ bool foundSeqNo = false;
+ while (it != mHistory.end()) {
+ const sp<ABuffer> &buffer = *it;
+
+ uint16_t bufferSeqNo = buffer->int32Data() & 0xffff;
+
+ bool retransmit = false;
+ if (bufferSeqNo == seqNo) {
+ retransmit = true;
+ } else if (blp != 0) {
+ for (size_t i = 0; i < 16; ++i) {
+ if ((blp & (1 << i))
+ && (bufferSeqNo == ((seqNo + i + 1) & 0xffff))) {
+ blp &= ~(1 << i);
+ retransmit = true;
+ }
+ }
+ }
+
+ if (retransmit) {
+ ALOGI("retransmitting seqNo %d", bufferSeqNo);
+
+ sp<ABuffer> retransRTP = new ABuffer(2 + buffer->size());
+ uint8_t *rtp = retransRTP->data();
+ memcpy(rtp, buffer->data(), 12);
+ rtp[2] = (mRTPRetransmissionSeqNo >> 8) & 0xff;
+ rtp[3] = mRTPRetransmissionSeqNo & 0xff;
+ rtp[12] = (bufferSeqNo >> 8) & 0xff;
+ rtp[13] = bufferSeqNo & 0xff;
+ memcpy(&rtp[14], buffer->data() + 12, buffer->size() - 12);
+
+ ++mRTPRetransmissionSeqNo;
+
+ sendPacket(
+ mRTPRetransmissionSessionID,
+ retransRTP->data(), retransRTP->size());
+
+ if (bufferSeqNo == seqNo) {
+ foundSeqNo = true;
+ }
+
+ if (foundSeqNo && blp == 0) {
+ break;
+ }
+ }
+
+ ++it;
+ }
+
+ if (!foundSeqNo || blp != 0) {
+ ALOGI("Some sequence numbers were no longer available for "
+ "retransmission");
+ }
+ }
+
+ return OK;
+}
+#endif
+
+status_t Sender::parseRTCP(
+ const sp<ABuffer> &buffer) {
+ const uint8_t *data = buffer->data();
+ size_t size = buffer->size();
+
+ while (size > 0) {
+ if (size < 8) {
+ // Too short to be a valid RTCP header
+ return ERROR_MALFORMED;
+ }
+
+ if ((data[0] >> 6) != 2) {
+ // Unsupported version.
+ return ERROR_UNSUPPORTED;
+ }
+
+ if (data[0] & 0x20) {
+ // Padding present.
+
+ size_t paddingLength = data[size - 1];
+
+ if (paddingLength + 12 > size) {
+ // If we removed this much padding we'd end up with something
+ // that's too short to be a valid RTP header.
+ return ERROR_MALFORMED;
+ }
+
+ size -= paddingLength;
+ }
+
+ size_t headerLength = 4 * (data[2] << 8 | data[3]) + 4;
+
+ if (size < headerLength) {
+ // Only received a partial packet?
+ return ERROR_MALFORMED;
+ }
+
+ switch (data[1]) {
+ case 200:
+ case 201: // RR
+ case 202: // SDES
+ case 203:
+ case 204: // APP
+ break;
+
+#if ENABLE_RETRANSMISSION
+ case 205: // TSFB (transport layer specific feedback)
+ parseTSFB(data, headerLength);
+ break;
+#endif
+
+ case 206: // PSFB (payload specific feedback)
+ hexdump(data, headerLength);
+ break;
+
+ default:
+ {
+ ALOGW("Unknown RTCP packet type %u of size %d",
+ (unsigned)data[1], headerLength);
+ break;
+ }
+ }
+
+ data += headerLength;
+ size -= headerLength;
+ }
+
+ return OK;
+}
+
+status_t Sender::sendPacket(
+ int32_t sessionID, const void *data, size_t size) {
+ return mNetSession->sendRequest(sessionID, data, size);
+}
+
+void Sender::notifyInitDone() {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatInitDone);
+ notify->post();
+}
+
+void Sender::notifySessionDead() {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatSessionDead);
+ notify->post();
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/source/Sender.h b/media/libstagefright/wifi-display/source/Sender.h
new file mode 100644
index 0000000..e476e84
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Sender.h
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SENDER_H_
+
+#define SENDER_H_
+
+#include <media/stagefright/foundation/AHandler.h>
+
+namespace android {
+
+#define LOG_TRANSPORT_STREAM 0
+#define ENABLE_RETRANSMISSION 0
+#define TRACK_BANDWIDTH 0
+
+struct ABuffer;
+struct ANetworkSession;
+
+struct Sender : public AHandler {
+ Sender(const sp<ANetworkSession> &netSession, const sp<AMessage> &notify);
+
+ enum {
+ kWhatInitDone,
+ kWhatSessionDead,
+ kWhatBinaryData,
+ };
+
+ enum TransportMode {
+ TRANSPORT_UDP,
+ TRANSPORT_TCP_INTERLEAVED,
+ TRANSPORT_TCP,
+ };
+ status_t init(
+ const char *clientIP, int32_t clientRtp, int32_t clientRtcp,
+ TransportMode transportMode);
+
+ status_t finishInit();
+
+ int32_t getRTPPort() const;
+
+ void queuePackets(int64_t timeUs, const sp<ABuffer> &packets);
+ void scheduleSendSR();
+
+protected:
+ virtual ~Sender();
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ enum {
+ kWhatQueuePackets,
+ kWhatSendSR,
+ kWhatRTPNotify,
+ kWhatRTCPNotify,
+#if ENABLE_RETRANSMISSION
+ kWhatRTPRetransmissionNotify,
+ kWhatRTCPRetransmissionNotify
+#endif
+ };
+
+ static const int64_t kSendSRIntervalUs = 10000000ll;
+
+ static const uint32_t kSourceID = 0xdeadbeef;
+ static const size_t kMaxHistoryLength = 128;
+
+#if ENABLE_RETRANSMISSION
+ static const size_t kRetransmissionPortOffset = 120;
+#endif
+
+ sp<ANetworkSession> mNetSession;
+ sp<AMessage> mNotify;
+
+ sp<ABuffer> mTSQueue;
+
+ TransportMode mTransportMode;
+ AString mClientIP;
+
+ // in TCP mode
+ int32_t mRTPChannel;
+ int32_t mRTCPChannel;
+
+ // in UDP mode
+ int32_t mRTPPort;
+ int32_t mRTPSessionID;
+ int32_t mRTCPSessionID;
+
+#if ENABLE_RETRANSMISSION
+ int32_t mRTPRetransmissionSessionID;
+ int32_t mRTCPRetransmissionSessionID;
+#endif
+
+ int32_t mClientRTPPort;
+ int32_t mClientRTCPPort;
+ bool mRTPConnected;
+ bool mRTCPConnected;
+
+
+ int64_t mFirstOutputBufferReadyTimeUs;
+ int64_t mFirstOutputBufferSentTimeUs;
+
+ uint32_t mRTPSeqNo;
+#if ENABLE_RETRANSMISSION
+ uint32_t mRTPRetransmissionSeqNo;
+#endif
+
+ uint64_t mLastNTPTime;
+ uint32_t mLastRTPTime;
+ uint32_t mNumRTPSent;
+ uint32_t mNumRTPOctetsSent;
+ uint32_t mNumSRsSent;
+
+ bool mSendSRPending;
+
+#if ENABLE_RETRANSMISSION
+ List<sp<ABuffer> > mHistory;
+ size_t mHistoryLength;
+#endif
+
+#if TRACK_BANDWIDTH
+ int64_t mFirstPacketTimeUs;
+ uint64_t mTotalBytesSent;
+#endif
+
+ void onSendSR();
+ void addSR(const sp<ABuffer> &buffer);
+ void addSDES(const sp<ABuffer> &buffer);
+ static uint64_t GetNowNTP();
+
+#if LOG_TRANSPORT_STREAM
+ FILE *mLogFile;
+#endif
+
+ ssize_t appendTSData(
+ const void *data, size_t size, bool timeDiscontinuity, bool flush);
+
+ void onQueuePackets(const sp<ABuffer> &packets);
+
+#if ENABLE_RETRANSMISSION
+ status_t parseTSFB(const uint8_t *data, size_t size);
+#endif
+
+ status_t parseRTCP(const sp<ABuffer> &buffer);
+
+ status_t sendPacket(int32_t sessionID, const void *data, size_t size);
+
+ void notifyInitDone();
+ void notifySessionDead();
+
+ DISALLOW_EVIL_CONSTRUCTORS(Sender);
+};
+
+} // namespace android
+
+#endif // SENDER_H_
diff --git a/media/libstagefright/wifi-display/source/TSPacketizer.cpp b/media/libstagefright/wifi-display/source/TSPacketizer.cpp
new file mode 100644
index 0000000..a5679ad
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/TSPacketizer.cpp
@@ -0,0 +1,864 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "TSPacketizer"
+#include <utils/Log.h>
+
+#include "TSPacketizer.h"
+#include "include/avc_utils.h"
+
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/foundation/hexdump.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+
+#include <arpa/inet.h>
+
+namespace android {
+
+struct TSPacketizer::Track : public RefBase {
+ Track(const sp<AMessage> &format,
+ unsigned PID, unsigned streamType, unsigned streamID);
+
+ unsigned PID() const;
+ unsigned streamType() const;
+ unsigned streamID() const;
+
+ // Returns the previous value.
+ unsigned incrementContinuityCounter();
+
+ bool isAudio() const;
+ bool isVideo() const;
+
+ bool isH264() const;
+ bool isAAC() const;
+ bool lacksADTSHeader() const;
+ bool isPCMAudio() const;
+
+ sp<ABuffer> prependCSD(const sp<ABuffer> &accessUnit) const;
+ sp<ABuffer> prependADTSHeader(const sp<ABuffer> &accessUnit) const;
+
+ size_t countDescriptors() const;
+ sp<ABuffer> descriptorAt(size_t index) const;
+
+ void finalize();
+
+protected:
+ virtual ~Track();
+
+private:
+ sp<AMessage> mFormat;
+
+ unsigned mPID;
+ unsigned mStreamType;
+ unsigned mStreamID;
+ unsigned mContinuityCounter;
+
+ AString mMIME;
+ Vector<sp<ABuffer> > mCSD;
+
+ Vector<sp<ABuffer> > mDescriptors;
+
+ bool mAudioLacksATDSHeaders;
+ bool mFinalized;
+
+ DISALLOW_EVIL_CONSTRUCTORS(Track);
+};
+
+TSPacketizer::Track::Track(
+ const sp<AMessage> &format,
+ unsigned PID, unsigned streamType, unsigned streamID)
+ : mFormat(format),
+ mPID(PID),
+ mStreamType(streamType),
+ mStreamID(streamID),
+ mContinuityCounter(0),
+ mAudioLacksATDSHeaders(false),
+ mFinalized(false) {
+ CHECK(format->findString("mime", &mMIME));
+
+ if (!strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_VIDEO_AVC)
+ || !strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_AUDIO_AAC)) {
+ for (size_t i = 0;; ++i) {
+ sp<ABuffer> csd;
+ if (!format->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
+ break;
+ }
+
+ mCSD.push(csd);
+ }
+
+ if (!strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_AUDIO_AAC)) {
+ int32_t isADTS;
+ if (!mFormat->findInt32("is-adts", &isADTS) || isADTS == 0) {
+ mAudioLacksATDSHeaders = true;
+ }
+ }
+ }
+}
+
+TSPacketizer::Track::~Track() {
+}
+
+unsigned TSPacketizer::Track::PID() const {
+ return mPID;
+}
+
+unsigned TSPacketizer::Track::streamType() const {
+ return mStreamType;
+}
+
+unsigned TSPacketizer::Track::streamID() const {
+ return mStreamID;
+}
+
+unsigned TSPacketizer::Track::incrementContinuityCounter() {
+ unsigned prevCounter = mContinuityCounter;
+
+ if (++mContinuityCounter == 16) {
+ mContinuityCounter = 0;
+ }
+
+ return prevCounter;
+}
+
+bool TSPacketizer::Track::isAudio() const {
+ return !strncasecmp("audio/", mMIME.c_str(), 6);
+}
+
+bool TSPacketizer::Track::isVideo() const {
+ return !strncasecmp("video/", mMIME.c_str(), 6);
+}
+
+bool TSPacketizer::Track::isH264() const {
+ return !strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_VIDEO_AVC);
+}
+
+bool TSPacketizer::Track::isAAC() const {
+ return !strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_AUDIO_AAC);
+}
+
+bool TSPacketizer::Track::isPCMAudio() const {
+ return !strcasecmp(mMIME.c_str(), MEDIA_MIMETYPE_AUDIO_RAW);
+}
+
+bool TSPacketizer::Track::lacksADTSHeader() const {
+ return mAudioLacksATDSHeaders;
+}
+
+sp<ABuffer> TSPacketizer::Track::prependCSD(
+ const sp<ABuffer> &accessUnit) const {
+ size_t size = 0;
+ for (size_t i = 0; i < mCSD.size(); ++i) {
+ size += mCSD.itemAt(i)->size();
+ }
+
+ sp<ABuffer> dup = new ABuffer(accessUnit->size() + size);
+ size_t offset = 0;
+ for (size_t i = 0; i < mCSD.size(); ++i) {
+ const sp<ABuffer> &csd = mCSD.itemAt(i);
+
+ memcpy(dup->data() + offset, csd->data(), csd->size());
+ offset += csd->size();
+ }
+
+ memcpy(dup->data() + offset, accessUnit->data(), accessUnit->size());
+
+ return dup;
+}
+
+sp<ABuffer> TSPacketizer::Track::prependADTSHeader(
+ const sp<ABuffer> &accessUnit) const {
+ CHECK_EQ(mCSD.size(), 1u);
+
+ const uint8_t *codec_specific_data = mCSD.itemAt(0)->data();
+
+ const uint32_t aac_frame_length = accessUnit->size() + 7;
+
+ sp<ABuffer> dup = new ABuffer(aac_frame_length);
+
+ unsigned profile = (codec_specific_data[0] >> 3) - 1;
+
+ unsigned sampling_freq_index =
+ ((codec_specific_data[0] & 7) << 1)
+ | (codec_specific_data[1] >> 7);
+
+ unsigned channel_configuration =
+ (codec_specific_data[1] >> 3) & 0x0f;
+
+ uint8_t *ptr = dup->data();
+
+ *ptr++ = 0xff;
+ *ptr++ = 0xf1; // b11110001, ID=0, layer=0, protection_absent=1
+
+ *ptr++ =
+ profile << 6
+ | sampling_freq_index << 2
+ | ((channel_configuration >> 2) & 1); // private_bit=0
+
+ // original_copy=0, home=0, copyright_id_bit=0, copyright_id_start=0
+ *ptr++ =
+ (channel_configuration & 3) << 6
+ | aac_frame_length >> 11;
+ *ptr++ = (aac_frame_length >> 3) & 0xff;
+ *ptr++ = (aac_frame_length & 7) << 5;
+
+ // adts_buffer_fullness=0, number_of_raw_data_blocks_in_frame=0
+ *ptr++ = 0;
+
+ memcpy(ptr, accessUnit->data(), accessUnit->size());
+
+ return dup;
+}
+
+size_t TSPacketizer::Track::countDescriptors() const {
+ return mDescriptors.size();
+}
+
+sp<ABuffer> TSPacketizer::Track::descriptorAt(size_t index) const {
+ CHECK_LT(index, mDescriptors.size());
+ return mDescriptors.itemAt(index);
+}
+
+void TSPacketizer::Track::finalize() {
+ if (mFinalized) {
+ return;
+ }
+
+ if (isH264()) {
+ {
+ // AVC video descriptor (40)
+
+ sp<ABuffer> descriptor = new ABuffer(6);
+ uint8_t *data = descriptor->data();
+ data[0] = 40; // descriptor_tag
+ data[1] = 4; // descriptor_length
+
+ CHECK_EQ(mCSD.size(), 1u);
+ const sp<ABuffer> &sps = mCSD.itemAt(0);
+ CHECK(!memcmp("\x00\x00\x00\x01", sps->data(), 4));
+ CHECK_GE(sps->size(), 7u);
+ // profile_idc, constraint_set*, level_idc
+ memcpy(&data[2], sps->data() + 4, 3);
+
+ // AVC_still_present=0, AVC_24_hour_picture_flag=0, reserved
+ data[5] = 0x3f;
+
+ mDescriptors.push_back(descriptor);
+ }
+
+ {
+ // AVC timing and HRD descriptor (42)
+
+ sp<ABuffer> descriptor = new ABuffer(4);
+ uint8_t *data = descriptor->data();
+ data[0] = 42; // descriptor_tag
+ data[1] = 2; // descriptor_length
+
+ // hrd_management_valid_flag = 0
+ // reserved = 111111b
+ // picture_and_timing_info_present = 0
+
+ data[2] = 0x7e;
+
+ // fixed_frame_rate_flag = 0
+ // temporal_poc_flag = 0
+ // picture_to_display_conversion_flag = 0
+ // reserved = 11111b
+ data[3] = 0x1f;
+
+ mDescriptors.push_back(descriptor);
+ }
+ } else if (isPCMAudio()) {
+ // LPCM audio stream descriptor (0x83)
+
+ int32_t channelCount;
+ CHECK(mFormat->findInt32("channel-count", &channelCount));
+ CHECK_EQ(channelCount, 2);
+
+ int32_t sampleRate;
+ CHECK(mFormat->findInt32("sample-rate", &sampleRate));
+ CHECK(sampleRate == 44100 || sampleRate == 48000);
+
+ sp<ABuffer> descriptor = new ABuffer(4);
+ uint8_t *data = descriptor->data();
+ data[0] = 0x83; // descriptor_tag
+ data[1] = 2; // descriptor_length
+
+ unsigned sampling_frequency = (sampleRate == 44100) ? 1 : 2;
+
+ data[2] = (sampling_frequency << 5)
+ | (3 /* reserved */ << 1)
+ | 0 /* emphasis_flag */;
+
+ data[3] =
+ (1 /* number_of_channels = stereo */ << 5)
+ | 0xf /* reserved */;
+
+ mDescriptors.push_back(descriptor);
+ }
+
+ mFinalized = true;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+TSPacketizer::TSPacketizer()
+ : mPATContinuityCounter(0),
+ mPMTContinuityCounter(0) {
+ initCrcTable();
+}
+
+TSPacketizer::~TSPacketizer() {
+}
+
+ssize_t TSPacketizer::addTrack(const sp<AMessage> &format) {
+ AString mime;
+ CHECK(format->findString("mime", &mime));
+
+ unsigned PIDStart;
+ bool isVideo = !strncasecmp("video/", mime.c_str(), 6);
+ bool isAudio = !strncasecmp("audio/", mime.c_str(), 6);
+
+ if (isVideo) {
+ PIDStart = 0x1011;
+ } else if (isAudio) {
+ PIDStart = 0x1100;
+ } else {
+ return ERROR_UNSUPPORTED;
+ }
+
+ unsigned streamType;
+ unsigned streamIDStart;
+ unsigned streamIDStop;
+
+ if (!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_VIDEO_AVC)) {
+ streamType = 0x1b;
+ streamIDStart = 0xe0;
+ streamIDStop = 0xef;
+ } else if (!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_AUDIO_AAC)) {
+ streamType = 0x0f;
+ streamIDStart = 0xc0;
+ streamIDStop = 0xdf;
+ } else if (!strcasecmp(mime.c_str(), MEDIA_MIMETYPE_AUDIO_RAW)) {
+ streamType = 0x83;
+ streamIDStart = 0xbd;
+ streamIDStop = 0xbd;
+ } else {
+ return ERROR_UNSUPPORTED;
+ }
+
+ size_t numTracksOfThisType = 0;
+ unsigned PID = PIDStart;
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ const sp<Track> &track = mTracks.itemAt(i);
+
+ if (track->streamType() == streamType) {
+ ++numTracksOfThisType;
+ }
+
+ if ((isAudio && track->isAudio()) || (isVideo && track->isVideo())) {
+ ++PID;
+ }
+ }
+
+ unsigned streamID = streamIDStart + numTracksOfThisType;
+ if (streamID > streamIDStop) {
+ return -ERANGE;
+ }
+
+ sp<Track> track = new Track(format, PID, streamType, streamID);
+ return mTracks.add(track);
+}
+
+status_t TSPacketizer::packetize(
+ size_t trackIndex,
+ const sp<ABuffer> &_accessUnit,
+ sp<ABuffer> *packets,
+ uint32_t flags,
+ const uint8_t *PES_private_data, size_t PES_private_data_len,
+ size_t numStuffingBytes) {
+ sp<ABuffer> accessUnit = _accessUnit;
+
+ int64_t timeUs;
+ CHECK(accessUnit->meta()->findInt64("timeUs", &timeUs));
+
+ packets->clear();
+
+ if (trackIndex >= mTracks.size()) {
+ return -ERANGE;
+ }
+
+ const sp<Track> &track = mTracks.itemAt(trackIndex);
+
+ if (track->isH264() && (flags & PREPEND_SPS_PPS_TO_IDR_FRAMES)
+ && IsIDR(accessUnit)) {
+ // prepend codec specific data, i.e. SPS and PPS.
+ accessUnit = track->prependCSD(accessUnit);
+ } else if (track->isAAC() && track->lacksADTSHeader()) {
+ CHECK(!(flags & IS_ENCRYPTED));
+ accessUnit = track->prependADTSHeader(accessUnit);
+ }
+
+ // 0x47
+ // transport_error_indicator = b0
+ // payload_unit_start_indicator = b1
+ // transport_priority = b0
+ // PID
+ // transport_scrambling_control = b00
+ // adaptation_field_control = b??
+ // continuity_counter = b????
+ // -- payload follows
+ // packet_startcode_prefix = 0x000001
+ // stream_id
+ // PES_packet_length = 0x????
+ // reserved = b10
+ // PES_scrambling_control = b00
+ // PES_priority = b0
+ // data_alignment_indicator = b1
+ // copyright = b0
+ // original_or_copy = b0
+ // PTS_DTS_flags = b10 (PTS only)
+ // ESCR_flag = b0
+ // ES_rate_flag = b0
+ // DSM_trick_mode_flag = b0
+ // additional_copy_info_flag = b0
+ // PES_CRC_flag = b0
+ // PES_extension_flag = b0
+ // PES_header_data_length = 0x05
+ // reserved = b0010 (PTS)
+ // PTS[32..30] = b???
+ // reserved = b1
+ // PTS[29..15] = b??? ???? ???? ???? (15 bits)
+ // reserved = b1
+ // PTS[14..0] = b??? ???? ???? ???? (15 bits)
+ // reserved = b1
+ // the first fragment of "buffer" follows
+
+ size_t PES_packet_length = accessUnit->size() + 8 + numStuffingBytes;
+ if (PES_private_data_len > 0) {
+ PES_packet_length += PES_private_data_len + 1;
+ }
+
+ size_t numTSPackets;
+ if (PES_packet_length <= 178) {
+ numTSPackets = 1;
+ } else {
+ numTSPackets = 1 + ((PES_packet_length - 178) + 183) / 184;
+ }
+
+ if (flags & EMIT_PAT_AND_PMT) {
+ numTSPackets += 2;
+ }
+
+ if (flags & EMIT_PCR) {
+ ++numTSPackets;
+ }
+
+ sp<ABuffer> buffer = new ABuffer(numTSPackets * 188);
+ uint8_t *packetDataStart = buffer->data();
+
+ if (flags & EMIT_PAT_AND_PMT) {
+ // Program Association Table (PAT):
+ // 0x47
+ // transport_error_indicator = b0
+ // payload_unit_start_indicator = b1
+ // transport_priority = b0
+ // PID = b0000000000000 (13 bits)
+ // transport_scrambling_control = b00
+ // adaptation_field_control = b01 (no adaptation field, payload only)
+ // continuity_counter = b????
+ // skip = 0x00
+ // --- payload follows
+ // table_id = 0x00
+ // section_syntax_indicator = b1
+ // must_be_zero = b0
+ // reserved = b11
+ // section_length = 0x00d
+ // transport_stream_id = 0x0000
+ // reserved = b11
+ // version_number = b00001
+ // current_next_indicator = b1
+ // section_number = 0x00
+ // last_section_number = 0x00
+ // one program follows:
+ // program_number = 0x0001
+ // reserved = b111
+ // program_map_PID = kPID_PMT (13 bits!)
+ // CRC = 0x????????
+
+ if (++mPATContinuityCounter == 16) {
+ mPATContinuityCounter = 0;
+ }
+
+ uint8_t *ptr = packetDataStart;
+ *ptr++ = 0x47;
+ *ptr++ = 0x40;
+ *ptr++ = 0x00;
+ *ptr++ = 0x10 | mPATContinuityCounter;
+ *ptr++ = 0x00;
+
+ uint8_t *crcDataStart = ptr;
+ *ptr++ = 0x00;
+ *ptr++ = 0xb0;
+ *ptr++ = 0x0d;
+ *ptr++ = 0x00;
+ *ptr++ = 0x00;
+ *ptr++ = 0xc3;
+ *ptr++ = 0x00;
+ *ptr++ = 0x00;
+ *ptr++ = 0x00;
+ *ptr++ = 0x01;
+ *ptr++ = 0xe0 | (kPID_PMT >> 8);
+ *ptr++ = kPID_PMT & 0xff;
+
+ CHECK_EQ(ptr - crcDataStart, 12);
+ uint32_t crc = htonl(crc32(crcDataStart, ptr - crcDataStart));
+ memcpy(ptr, &crc, 4);
+ ptr += 4;
+
+ size_t sizeLeft = packetDataStart + 188 - ptr;
+ memset(ptr, 0xff, sizeLeft);
+
+ packetDataStart += 188;
+
+ // Program Map (PMT):
+ // 0x47
+ // transport_error_indicator = b0
+ // payload_unit_start_indicator = b1
+ // transport_priority = b0
+ // PID = kPID_PMT (13 bits)
+ // transport_scrambling_control = b00
+ // adaptation_field_control = b01 (no adaptation field, payload only)
+ // continuity_counter = b????
+ // skip = 0x00
+ // -- payload follows
+ // table_id = 0x02
+ // section_syntax_indicator = b1
+ // must_be_zero = b0
+ // reserved = b11
+ // section_length = 0x???
+ // program_number = 0x0001
+ // reserved = b11
+ // version_number = b00001
+ // current_next_indicator = b1
+ // section_number = 0x00
+ // last_section_number = 0x00
+ // reserved = b111
+ // PCR_PID = kPCR_PID (13 bits)
+ // reserved = b1111
+ // program_info_length = 0x000
+ // one or more elementary stream descriptions follow:
+ // stream_type = 0x??
+ // reserved = b111
+ // elementary_PID = b? ???? ???? ???? (13 bits)
+ // reserved = b1111
+ // ES_info_length = 0x000
+ // CRC = 0x????????
+
+ if (++mPMTContinuityCounter == 16) {
+ mPMTContinuityCounter = 0;
+ }
+
+ ptr = packetDataStart;
+ *ptr++ = 0x47;
+ *ptr++ = 0x40 | (kPID_PMT >> 8);
+ *ptr++ = kPID_PMT & 0xff;
+ *ptr++ = 0x10 | mPMTContinuityCounter;
+ *ptr++ = 0x00;
+
+ crcDataStart = ptr;
+ *ptr++ = 0x02;
+
+ *ptr++ = 0x00; // section_length to be filled in below.
+ *ptr++ = 0x00;
+
+ *ptr++ = 0x00;
+ *ptr++ = 0x01;
+ *ptr++ = 0xc3;
+ *ptr++ = 0x00;
+ *ptr++ = 0x00;
+ *ptr++ = 0xe0 | (kPID_PCR >> 8);
+ *ptr++ = kPID_PCR & 0xff;
+ *ptr++ = 0xf0;
+ *ptr++ = 0x00;
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ const sp<Track> &track = mTracks.itemAt(i);
+
+ // Make sure all the decriptors have been added.
+ track->finalize();
+
+ *ptr++ = track->streamType();
+ *ptr++ = 0xe0 | (track->PID() >> 8);
+ *ptr++ = track->PID() & 0xff;
+
+ size_t ES_info_length = 0;
+ for (size_t i = 0; i < track->countDescriptors(); ++i) {
+ ES_info_length += track->descriptorAt(i)->size();
+ }
+ CHECK_LE(ES_info_length, 0xfff);
+
+ *ptr++ = 0xf0 | (ES_info_length >> 8);
+ *ptr++ = (ES_info_length & 0xff);
+
+ for (size_t i = 0; i < track->countDescriptors(); ++i) {
+ const sp<ABuffer> &descriptor = track->descriptorAt(i);
+ memcpy(ptr, descriptor->data(), descriptor->size());
+ ptr += descriptor->size();
+ }
+ }
+
+ size_t section_length = ptr - (crcDataStart + 3) + 4 /* CRC */;
+
+ crcDataStart[1] = 0xb0 | (section_length >> 8);
+ crcDataStart[2] = section_length & 0xff;
+
+ crc = htonl(crc32(crcDataStart, ptr - crcDataStart));
+ memcpy(ptr, &crc, 4);
+ ptr += 4;
+
+ sizeLeft = packetDataStart + 188 - ptr;
+ memset(ptr, 0xff, sizeLeft);
+
+ packetDataStart += 188;
+ }
+
+ if (flags & EMIT_PCR) {
+ // PCR stream
+ // 0x47
+ // transport_error_indicator = b0
+ // payload_unit_start_indicator = b1
+ // transport_priority = b0
+ // PID = kPCR_PID (13 bits)
+ // transport_scrambling_control = b00
+ // adaptation_field_control = b10 (adaptation field only, no payload)
+ // continuity_counter = b0000 (does not increment)
+ // adaptation_field_length = 183
+ // discontinuity_indicator = b0
+ // random_access_indicator = b0
+ // elementary_stream_priority_indicator = b0
+ // PCR_flag = b1
+ // OPCR_flag = b0
+ // splicing_point_flag = b0
+ // transport_private_data_flag = b0
+ // adaptation_field_extension_flag = b0
+ // program_clock_reference_base = b?????????????????????????????????
+ // reserved = b111111
+ // program_clock_reference_extension = b?????????
+
+ int64_t nowUs = ALooper::GetNowUs();
+
+ uint64_t PCR = nowUs * 27; // PCR based on a 27MHz clock
+ uint64_t PCR_base = PCR / 300;
+ uint32_t PCR_ext = PCR % 300;
+
+ uint8_t *ptr = packetDataStart;
+ *ptr++ = 0x47;
+ *ptr++ = 0x40 | (kPID_PCR >> 8);
+ *ptr++ = kPID_PCR & 0xff;
+ *ptr++ = 0x20;
+ *ptr++ = 0xb7; // adaptation_field_length
+ *ptr++ = 0x10;
+ *ptr++ = (PCR_base >> 25) & 0xff;
+ *ptr++ = (PCR_base >> 17) & 0xff;
+ *ptr++ = (PCR_base >> 9) & 0xff;
+ *ptr++ = ((PCR_base & 1) << 7) | 0x7e | ((PCR_ext >> 8) & 1);
+ *ptr++ = (PCR_ext & 0xff);
+
+ size_t sizeLeft = packetDataStart + 188 - ptr;
+ memset(ptr, 0xff, sizeLeft);
+
+ packetDataStart += 188;
+ }
+
+ uint64_t PTS = (timeUs * 9ll) / 100ll;
+
+ bool padding = (PES_packet_length < (188 - 10));
+
+ if (PES_packet_length >= 65536) {
+ // This really should only happen for video.
+ CHECK(track->isVideo());
+
+ // It's valid to set this to 0 for video according to the specs.
+ PES_packet_length = 0;
+ }
+
+ uint8_t *ptr = packetDataStart;
+ *ptr++ = 0x47;
+ *ptr++ = 0x40 | (track->PID() >> 8);
+ *ptr++ = track->PID() & 0xff;
+ *ptr++ = (padding ? 0x30 : 0x10) | track->incrementContinuityCounter();
+
+ if (padding) {
+ size_t paddingSize = 188 - 10 - PES_packet_length;
+ *ptr++ = paddingSize - 1;
+ if (paddingSize >= 2) {
+ *ptr++ = 0x00;
+ memset(ptr, 0xff, paddingSize - 2);
+ ptr += paddingSize - 2;
+ }
+ }
+
+ *ptr++ = 0x00;
+ *ptr++ = 0x00;
+ *ptr++ = 0x01;
+ *ptr++ = track->streamID();
+ *ptr++ = PES_packet_length >> 8;
+ *ptr++ = PES_packet_length & 0xff;
+ *ptr++ = 0x84;
+ *ptr++ = (PES_private_data_len > 0) ? 0x81 : 0x80;
+
+ size_t headerLength = 0x05 + numStuffingBytes;
+ if (PES_private_data_len > 0) {
+ headerLength += 1 + PES_private_data_len;
+ }
+
+ *ptr++ = headerLength;
+
+ *ptr++ = 0x20 | (((PTS >> 30) & 7) << 1) | 1;
+ *ptr++ = (PTS >> 22) & 0xff;
+ *ptr++ = (((PTS >> 15) & 0x7f) << 1) | 1;
+ *ptr++ = (PTS >> 7) & 0xff;
+ *ptr++ = ((PTS & 0x7f) << 1) | 1;
+
+ if (PES_private_data_len > 0) {
+ *ptr++ = 0x8e; // PES_private_data_flag, reserved.
+ memcpy(ptr, PES_private_data, PES_private_data_len);
+ ptr += PES_private_data_len;
+ }
+
+ for (size_t i = 0; i < numStuffingBytes; ++i) {
+ *ptr++ = 0xff;
+ }
+
+ // 18 bytes of TS/PES header leave 188 - 18 = 170 bytes for the payload
+
+ size_t sizeLeft = packetDataStart + 188 - ptr;
+ size_t copy = accessUnit->size();
+ if (copy > sizeLeft) {
+ copy = sizeLeft;
+ }
+
+ memcpy(ptr, accessUnit->data(), copy);
+ ptr += copy;
+ CHECK_EQ(sizeLeft, copy);
+ memset(ptr, 0xff, sizeLeft - copy);
+
+ packetDataStart += 188;
+
+ size_t offset = copy;
+ while (offset < accessUnit->size()) {
+ bool padding = (accessUnit->size() - offset) < (188 - 4);
+
+ // for subsequent fragments of "buffer":
+ // 0x47
+ // transport_error_indicator = b0
+ // payload_unit_start_indicator = b0
+ // transport_priority = b0
+ // PID = b0 0001 1110 ???? (13 bits) [0x1e0 + 1 + sourceIndex]
+ // transport_scrambling_control = b00
+ // adaptation_field_control = b??
+ // continuity_counter = b????
+ // the fragment of "buffer" follows.
+
+ uint8_t *ptr = packetDataStart;
+ *ptr++ = 0x47;
+ *ptr++ = 0x00 | (track->PID() >> 8);
+ *ptr++ = track->PID() & 0xff;
+
+ *ptr++ = (padding ? 0x30 : 0x10) | track->incrementContinuityCounter();
+
+ if (padding) {
+ size_t paddingSize = 188 - 4 - (accessUnit->size() - offset);
+ *ptr++ = paddingSize - 1;
+ if (paddingSize >= 2) {
+ *ptr++ = 0x00;
+ memset(ptr, 0xff, paddingSize - 2);
+ ptr += paddingSize - 2;
+ }
+ }
+
+ // 4 bytes of TS header leave 188 - 4 = 184 bytes for the payload
+
+ size_t sizeLeft = packetDataStart + 188 - ptr;
+ size_t copy = accessUnit->size() - offset;
+ if (copy > sizeLeft) {
+ copy = sizeLeft;
+ }
+
+ memcpy(ptr, accessUnit->data() + offset, copy);
+ ptr += copy;
+ CHECK_EQ(sizeLeft, copy);
+ memset(ptr, 0xff, sizeLeft - copy);
+
+ offset += copy;
+ packetDataStart += 188;
+ }
+
+ CHECK(packetDataStart == buffer->data() + buffer->capacity());
+
+ *packets = buffer;
+
+ return OK;
+}
+
+void TSPacketizer::initCrcTable() {
+ uint32_t poly = 0x04C11DB7;
+
+ for (int i = 0; i < 256; i++) {
+ uint32_t crc = i << 24;
+ for (int j = 0; j < 8; j++) {
+ crc = (crc << 1) ^ ((crc & 0x80000000) ? (poly) : 0);
+ }
+ mCrcTable[i] = crc;
+ }
+}
+
+uint32_t TSPacketizer::crc32(const uint8_t *start, size_t size) const {
+ uint32_t crc = 0xFFFFFFFF;
+ const uint8_t *p;
+
+ for (p = start; p < start + size; ++p) {
+ crc = (crc << 8) ^ mCrcTable[((crc >> 24) ^ *p) & 0xFF];
+ }
+
+ return crc;
+}
+
+sp<ABuffer> TSPacketizer::prependCSD(
+ size_t trackIndex, const sp<ABuffer> &accessUnit) const {
+ CHECK_LT(trackIndex, mTracks.size());
+
+ const sp<Track> &track = mTracks.itemAt(trackIndex);
+ CHECK(track->isH264() && IsIDR(accessUnit));
+
+ int64_t timeUs;
+ CHECK(accessUnit->meta()->findInt64("timeUs", &timeUs));
+
+ sp<ABuffer> accessUnit2 = track->prependCSD(accessUnit);
+
+ accessUnit2->meta()->setInt64("timeUs", timeUs);
+
+ return accessUnit2;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/source/TSPacketizer.h b/media/libstagefright/wifi-display/source/TSPacketizer.h
new file mode 100644
index 0000000..a37917d
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/TSPacketizer.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef TS_PACKETIZER_H_
+
+#define TS_PACKETIZER_H_
+
+#include <media/stagefright/foundation/ABase.h>
+#include <utils/Errors.h>
+#include <utils/RefBase.h>
+#include <utils/Vector.h>
+
+namespace android {
+
+struct ABuffer;
+struct AMessage;
+
+// Forms the packets of a transport stream given access units.
+// Emits metadata tables (PAT and PMT) and timestamp stream (PCR) based
+// on flags.
+struct TSPacketizer : public RefBase {
+ TSPacketizer();
+
+ // Returns trackIndex or error.
+ ssize_t addTrack(const sp<AMessage> &format);
+
+ enum {
+ EMIT_PAT_AND_PMT = 1,
+ EMIT_PCR = 2,
+ IS_ENCRYPTED = 4,
+ PREPEND_SPS_PPS_TO_IDR_FRAMES = 8,
+ };
+ status_t packetize(
+ size_t trackIndex, const sp<ABuffer> &accessUnit,
+ sp<ABuffer> *packets,
+ uint32_t flags,
+ const uint8_t *PES_private_data, size_t PES_private_data_len,
+ size_t numStuffingBytes = 0);
+
+ // XXX to be removed once encoder config option takes care of this for
+ // encrypted mode.
+ sp<ABuffer> prependCSD(
+ size_t trackIndex, const sp<ABuffer> &accessUnit) const;
+
+protected:
+ virtual ~TSPacketizer();
+
+private:
+ enum {
+ kPID_PMT = 0x100,
+ kPID_PCR = 0x1000,
+ };
+
+ struct Track;
+
+ Vector<sp<Track> > mTracks;
+
+ unsigned mPATContinuityCounter;
+ unsigned mPMTContinuityCounter;
+
+ uint32_t mCrcTable[256];
+
+ void initCrcTable();
+ uint32_t crc32(const uint8_t *start, size_t size) const;
+
+ DISALLOW_EVIL_CONSTRUCTORS(TSPacketizer);
+};
+
+} // namespace android
+
+#endif // TS_PACKETIZER_H_
+
diff --git a/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
new file mode 100644
index 0000000..b16c5d0
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
@@ -0,0 +1,1496 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "WifiDisplaySource"
+#include <utils/Log.h>
+
+#include "WifiDisplaySource.h"
+#include "PlaybackSession.h"
+#include "Parameters.h"
+#include "ParsedMessage.h"
+#include "Sender.h"
+
+#include <binder/IServiceManager.h>
+#include <gui/ISurfaceTexture.h>
+#include <media/IHDCP.h>
+#include <media/IMediaPlayerService.h>
+#include <media/IRemoteDisplayClient.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/MediaErrors.h>
+
+#include <arpa/inet.h>
+#include <cutils/properties.h>
+
+#include <ctype.h>
+
+namespace android {
+
+WifiDisplaySource::WifiDisplaySource(
+ const sp<ANetworkSession> &netSession,
+ const sp<IRemoteDisplayClient> &client)
+ : mState(INITIALIZED),
+ mNetSession(netSession),
+ mClient(client),
+ mSessionID(0),
+ mStopReplyID(0),
+ mChosenRTPPort(-1),
+ mUsingPCMAudio(false),
+ mClientSessionID(0),
+ mReaperPending(false),
+ mNextCSeq(1),
+ mUsingHDCP(false),
+ mIsHDCP2_0(false),
+ mHDCPPort(0),
+ mHDCPInitializationComplete(false),
+ mSetupTriggerDeferred(false)
+{
+}
+
+WifiDisplaySource::~WifiDisplaySource() {
+}
+
+status_t WifiDisplaySource::start(const char *iface) {
+ CHECK_EQ(mState, INITIALIZED);
+
+ sp<AMessage> msg = new AMessage(kWhatStart, id());
+ msg->setString("iface", iface);
+
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (!response->findInt32("err", &err)) {
+ err = OK;
+ }
+
+ return err;
+}
+
+status_t WifiDisplaySource::stop() {
+ sp<AMessage> msg = new AMessage(kWhatStop, id());
+
+ sp<AMessage> response;
+ status_t err = msg->postAndAwaitResponse(&response);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (!response->findInt32("err", &err)) {
+ err = OK;
+ }
+
+ return err;
+}
+
+void WifiDisplaySource::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatStart:
+ {
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ AString iface;
+ CHECK(msg->findString("iface", &iface));
+
+ status_t err = OK;
+
+ ssize_t colonPos = iface.find(":");
+
+ unsigned long port;
+
+ if (colonPos >= 0) {
+ const char *s = iface.c_str() + colonPos + 1;
+
+ char *end;
+ port = strtoul(s, &end, 10);
+
+ if (end == s || *end != '\0' || port > 65535) {
+ err = -EINVAL;
+ } else {
+ iface.erase(colonPos, iface.size() - colonPos);
+ }
+ } else {
+ port = kWifiDisplayDefaultPort;
+ }
+
+ if (err == OK) {
+ if (inet_aton(iface.c_str(), &mInterfaceAddr) != 0) {
+ sp<AMessage> notify = new AMessage(kWhatRTSPNotify, id());
+
+ err = mNetSession->createRTSPServer(
+ mInterfaceAddr, port, notify, &mSessionID);
+ } else {
+ err = -EINVAL;
+ }
+ }
+
+ if (err == OK) {
+ mState = AWAITING_CLIENT_CONNECTION;
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", err);
+ response->postReply(replyID);
+ break;
+ }
+
+ case kWhatRTSPNotify:
+ {
+ int32_t reason;
+ CHECK(msg->findInt32("reason", &reason));
+
+ switch (reason) {
+ case ANetworkSession::kWhatError:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ int32_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ AString detail;
+ CHECK(msg->findString("detail", &detail));
+
+ ALOGE("An error occurred in session %d (%d, '%s/%s').",
+ sessionID,
+ err,
+ detail.c_str(),
+ strerror(-err));
+
+ mNetSession->destroySession(sessionID);
+
+ if (sessionID == mClientSessionID) {
+ mClientSessionID = 0;
+
+ mClient->onDisplayError(
+ IRemoteDisplayClient::kDisplayErrorUnknown);
+ }
+ break;
+ }
+
+ case ANetworkSession::kWhatClientConnected:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ if (mClientSessionID > 0) {
+ ALOGW("A client tried to connect, but we already "
+ "have one.");
+
+ mNetSession->destroySession(sessionID);
+ break;
+ }
+
+ CHECK_EQ(mState, AWAITING_CLIENT_CONNECTION);
+
+ CHECK(msg->findString("client-ip", &mClientInfo.mRemoteIP));
+ CHECK(msg->findString("server-ip", &mClientInfo.mLocalIP));
+
+ if (mClientInfo.mRemoteIP == mClientInfo.mLocalIP) {
+ // Disallow connections from the local interface
+ // for security reasons.
+ mNetSession->destroySession(sessionID);
+ break;
+ }
+
+ CHECK(msg->findInt32(
+ "server-port", &mClientInfo.mLocalPort));
+ mClientInfo.mPlaybackSessionID = -1;
+
+ mClientSessionID = sessionID;
+
+ ALOGI("We now have a client (%d) connected.", sessionID);
+
+ mState = AWAITING_CLIENT_SETUP;
+
+ status_t err = sendM1(sessionID);
+ CHECK_EQ(err, (status_t)OK);
+ break;
+ }
+
+ case ANetworkSession::kWhatData:
+ {
+ status_t err = onReceiveClientData(msg);
+
+ if (err != OK) {
+ mClient->onDisplayError(
+ IRemoteDisplayClient::kDisplayErrorUnknown);
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+ break;
+ }
+
+ case kWhatStop:
+ {
+ CHECK(msg->senderAwaitsResponse(&mStopReplyID));
+
+ CHECK_LT(mState, AWAITING_CLIENT_TEARDOWN);
+
+ if (mState >= AWAITING_CLIENT_PLAY) {
+ // We have a session, i.e. a previous SETUP succeeded.
+
+ status_t err = sendM5(
+ mClientSessionID, true /* requestShutdown */);
+
+ if (err == OK) {
+ mState = AWAITING_CLIENT_TEARDOWN;
+
+ (new AMessage(kWhatTeardownTriggerTimedOut, id()))->post(
+ kTeardownTriggerTimeouSecs * 1000000ll);
+
+ break;
+ }
+
+ // fall through.
+ }
+
+ finishStop();
+ break;
+ }
+
+ case kWhatReapDeadClients:
+ {
+ mReaperPending = false;
+
+ if (mClientSessionID == 0
+ || mClientInfo.mPlaybackSession == NULL) {
+ break;
+ }
+
+ if (mClientInfo.mPlaybackSession->getLastLifesignUs()
+ + kPlaybackSessionTimeoutUs < ALooper::GetNowUs()) {
+ ALOGI("playback session timed out, reaping.");
+
+ mNetSession->destroySession(mClientSessionID);
+ mClientSessionID = 0;
+
+ mClient->onDisplayError(
+ IRemoteDisplayClient::kDisplayErrorUnknown);
+ } else {
+ scheduleReaper();
+ }
+ break;
+ }
+
+ case kWhatPlaybackSessionNotify:
+ {
+ int32_t playbackSessionID;
+ CHECK(msg->findInt32("playbackSessionID", &playbackSessionID));
+
+ int32_t what;
+ CHECK(msg->findInt32("what", &what));
+
+ if (what == PlaybackSession::kWhatSessionDead) {
+ ALOGI("playback session wants to quit.");
+
+ mClient->onDisplayError(
+ IRemoteDisplayClient::kDisplayErrorUnknown);
+ } else if (what == PlaybackSession::kWhatSessionEstablished) {
+ if (mClient != NULL) {
+ mClient->onDisplayConnected(
+ mClientInfo.mPlaybackSession->getSurfaceTexture(),
+ mClientInfo.mPlaybackSession->width(),
+ mClientInfo.mPlaybackSession->height(),
+ mUsingHDCP
+ ? IRemoteDisplayClient::kDisplayFlagSecure
+ : 0);
+ }
+
+ if (mState == ABOUT_TO_PLAY) {
+ mState = PLAYING;
+ }
+ } else if (what == PlaybackSession::kWhatSessionDestroyed) {
+ disconnectClient2();
+ } else {
+ CHECK_EQ(what, PlaybackSession::kWhatBinaryData);
+
+ int32_t channel;
+ CHECK(msg->findInt32("channel", &channel));
+
+ sp<ABuffer> data;
+ CHECK(msg->findBuffer("data", &data));
+
+ CHECK_LE(channel, 0xffu);
+ CHECK_LE(data->size(), 0xffffu);
+
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ char header[4];
+ header[0] = '$';
+ header[1] = channel;
+ header[2] = data->size() >> 8;
+ header[3] = data->size() & 0xff;
+
+ mNetSession->sendRequest(
+ sessionID, header, sizeof(header));
+
+ mNetSession->sendRequest(
+ sessionID, data->data(), data->size());
+ }
+ break;
+ }
+
+ case kWhatKeepAlive:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ if (mClientSessionID != sessionID) {
+ // Obsolete event, client is already gone.
+ break;
+ }
+
+ sendM16(sessionID);
+ break;
+ }
+
+ case kWhatTeardownTriggerTimedOut:
+ {
+ if (mState == AWAITING_CLIENT_TEARDOWN) {
+ ALOGI("TEARDOWN trigger timed out, forcing disconnection.");
+
+ CHECK_NE(mStopReplyID, 0);
+ finishStop();
+ break;
+ }
+ break;
+ }
+
+ case kWhatHDCPNotify:
+ {
+ int32_t msgCode, ext1, ext2;
+ CHECK(msg->findInt32("msg", &msgCode));
+ CHECK(msg->findInt32("ext1", &ext1));
+ CHECK(msg->findInt32("ext2", &ext2));
+
+ ALOGI("Saw HDCP notification code %d, ext1 %d, ext2 %d",
+ msgCode, ext1, ext2);
+
+ switch (msgCode) {
+ case HDCPModule::HDCP_INITIALIZATION_COMPLETE:
+ {
+ mHDCPInitializationComplete = true;
+
+ if (mSetupTriggerDeferred) {
+ mSetupTriggerDeferred = false;
+
+ sendM5(mClientSessionID, false /* requestShutdown */);
+ }
+ break;
+ }
+
+ case HDCPModule::HDCP_SHUTDOWN_COMPLETE:
+ case HDCPModule::HDCP_SHUTDOWN_FAILED:
+ {
+ // Ugly hack to make sure that the call to
+ // HDCPObserver::notify is completely handled before
+ // we clear the HDCP instance and unload the shared
+ // library :(
+ (new AMessage(kWhatFinishStop2, id()))->post(300000ll);
+ break;
+ }
+
+ default:
+ {
+ ALOGE("HDCP failure, shutting down.");
+
+ mClient->onDisplayError(
+ IRemoteDisplayClient::kDisplayErrorUnknown);
+ break;
+ }
+ }
+ break;
+ }
+
+ case kWhatFinishStop2:
+ {
+ finishStop2();
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void WifiDisplaySource::registerResponseHandler(
+ int32_t sessionID, int32_t cseq, HandleRTSPResponseFunc func) {
+ ResponseID id;
+ id.mSessionID = sessionID;
+ id.mCSeq = cseq;
+ mResponseHandlers.add(id, func);
+}
+
+status_t WifiDisplaySource::sendM1(int32_t sessionID) {
+ AString request = "OPTIONS * RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append(
+ "Require: org.wfa.wfd1.0\r\n"
+ "\r\n");
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM1Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::sendM3(int32_t sessionID) {
+ AString body =
+ "wfd_content_protection\r\n"
+ "wfd_video_formats\r\n"
+ "wfd_audio_codecs\r\n"
+ "wfd_client_rtp_ports\r\n";
+
+ AString request = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append("Content-Type: text/parameters\r\n");
+ request.append(StringPrintf("Content-Length: %d\r\n", body.size()));
+ request.append("\r\n");
+ request.append(body);
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM3Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::sendM4(int32_t sessionID) {
+ // wfd_video_formats:
+ // 1 byte "native"
+ // 1 byte "preferred-display-mode-supported" 0 or 1
+ // one or more avc codec structures
+ // 1 byte profile
+ // 1 byte level
+ // 4 byte CEA mask
+ // 4 byte VESA mask
+ // 4 byte HH mask
+ // 1 byte latency
+ // 2 byte min-slice-slice
+ // 2 byte slice-enc-params
+ // 1 byte framerate-control-support
+ // max-hres (none or 2 byte)
+ // max-vres (none or 2 byte)
+
+ CHECK_EQ(sessionID, mClientSessionID);
+
+ AString transportString = "UDP";
+
+ char val[PROPERTY_VALUE_MAX];
+ if (property_get("media.wfd.enable-tcp", val, NULL)
+ && (!strcasecmp("true", val) || !strcmp("1", val))) {
+ ALOGI("Using TCP transport.");
+ transportString = "TCP";
+ }
+
+ // For 720p60:
+ // use "30 00 02 02 00000040 00000000 00000000 00 0000 0000 00 none none\r\n"
+ // For 720p30:
+ // use "28 00 02 02 00000020 00000000 00000000 00 0000 0000 00 none none\r\n"
+ // For 720p24:
+ // use "78 00 02 02 00008000 00000000 00000000 00 0000 0000 00 none none\r\n"
+ AString body = StringPrintf(
+ "wfd_video_formats: "
+ "28 00 02 02 00000020 00000000 00000000 00 0000 0000 00 none none\r\n"
+ "wfd_audio_codecs: %s\r\n"
+ "wfd_presentation_URL: rtsp://%s/wfd1.0/streamid=0 none\r\n"
+ "wfd_client_rtp_ports: RTP/AVP/%s;unicast %d 0 mode=play\r\n",
+ (mUsingPCMAudio
+ ? "LPCM 00000002 00" // 2 ch PCM 48kHz
+ : "AAC 00000001 00"), // 2 ch AAC 48kHz
+ mClientInfo.mLocalIP.c_str(), transportString.c_str(), mChosenRTPPort);
+
+ AString request = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append("Content-Type: text/parameters\r\n");
+ request.append(StringPrintf("Content-Length: %d\r\n", body.size()));
+ request.append("\r\n");
+ request.append(body);
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM4Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::sendM5(int32_t sessionID, bool requestShutdown) {
+ AString body = "wfd_trigger_method: ";
+ if (requestShutdown) {
+ ALOGI("Sending TEARDOWN trigger.");
+ body.append("TEARDOWN");
+ } else {
+ body.append("SETUP");
+ }
+
+ body.append("\r\n");
+
+ AString request = "SET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ request.append("Content-Type: text/parameters\r\n");
+ request.append(StringPrintf("Content-Length: %d\r\n", body.size()));
+ request.append("\r\n");
+ request.append(body);
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM5Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::sendM16(int32_t sessionID) {
+ AString request = "GET_PARAMETER rtsp://localhost/wfd1.0 RTSP/1.0\r\n";
+ AppendCommonResponse(&request, mNextCSeq);
+
+ CHECK_EQ(sessionID, mClientSessionID);
+ request.append(
+ StringPrintf("Session: %d\r\n", mClientInfo.mPlaybackSessionID));
+ request.append("\r\n"); // Empty body
+
+ status_t err =
+ mNetSession->sendRequest(sessionID, request.c_str(), request.size());
+
+ if (err != OK) {
+ return err;
+ }
+
+ registerResponseHandler(
+ sessionID, mNextCSeq, &WifiDisplaySource::onReceiveM16Response);
+
+ ++mNextCSeq;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::onReceiveM1Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ return OK;
+}
+
+// sink_audio_list := ("LPCM"|"AAC"|"AC3" HEXDIGIT*8 HEXDIGIT*2)
+// (", " sink_audio_list)*
+static void GetAudioModes(const char *s, const char *prefix, uint32_t *modes) {
+ *modes = 0;
+
+ size_t prefixLen = strlen(prefix);
+
+ while (*s != '0') {
+ if (!strncmp(s, prefix, prefixLen) && s[prefixLen] == ' ') {
+ unsigned latency;
+ if (sscanf(&s[prefixLen + 1], "%08x %02x", modes, &latency) != 2) {
+ *modes = 0;
+ }
+
+ return;
+ }
+
+ char *commaPos = strchr(s, ',');
+ if (commaPos != NULL) {
+ s = commaPos + 1;
+
+ while (isspace(*s)) {
+ ++s;
+ }
+ } else {
+ break;
+ }
+ }
+}
+
+status_t WifiDisplaySource::onReceiveM3Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ sp<Parameters> params =
+ Parameters::Parse(msg->getContent(), strlen(msg->getContent()));
+
+ if (params == NULL) {
+ return ERROR_MALFORMED;
+ }
+
+ AString value;
+ if (!params->findParameter("wfd_client_rtp_ports", &value)) {
+ ALOGE("Sink doesn't report its choice of wfd_client_rtp_ports.");
+ return ERROR_MALFORMED;
+ }
+
+ unsigned port0, port1;
+ if (sscanf(value.c_str(),
+ "RTP/AVP/UDP;unicast %u %u mode=play",
+ &port0,
+ &port1) != 2
+ || port0 == 0 || port0 > 65535 || port1 != 0) {
+ ALOGE("Sink chose its wfd_client_rtp_ports poorly (%s)",
+ value.c_str());
+
+ return ERROR_MALFORMED;
+ }
+
+ mChosenRTPPort = port0;
+
+ if (!params->findParameter("wfd_audio_codecs", &value)) {
+ ALOGE("Sink doesn't report its choice of wfd_audio_codecs.");
+ return ERROR_MALFORMED;
+ }
+
+ if (value == "none") {
+ ALOGE("Sink doesn't support audio at all.");
+ return ERROR_UNSUPPORTED;
+ }
+
+ uint32_t modes;
+ GetAudioModes(value.c_str(), "AAC", &modes);
+
+ bool supportsAAC = (modes & 1) != 0; // AAC 2ch 48kHz
+
+ GetAudioModes(value.c_str(), "LPCM", &modes);
+
+ bool supportsPCM = (modes & 2) != 0; // LPCM 2ch 48kHz
+
+ char val[PROPERTY_VALUE_MAX];
+ if (supportsPCM
+ && property_get("media.wfd.use-pcm-audio", val, NULL)
+ && (!strcasecmp("true", val) || !strcmp("1", val))) {
+ ALOGI("Using PCM audio.");
+ mUsingPCMAudio = true;
+ } else if (supportsAAC) {
+ ALOGI("Using AAC audio.");
+ mUsingPCMAudio = false;
+ } else if (supportsPCM) {
+ ALOGI("Using PCM audio.");
+ mUsingPCMAudio = true;
+ } else {
+ ALOGI("Sink doesn't support an audio format we do.");
+ return ERROR_UNSUPPORTED;
+ }
+
+ mUsingHDCP = false;
+ if (!params->findParameter("wfd_content_protection", &value)) {
+ ALOGI("Sink doesn't appear to support content protection.");
+ } else if (value == "none") {
+ ALOGI("Sink does not support content protection.");
+ } else {
+ mUsingHDCP = true;
+
+ bool isHDCP2_0 = false;
+ if (value.startsWith("HDCP2.0 ")) {
+ isHDCP2_0 = true;
+ } else if (!value.startsWith("HDCP2.1 ")) {
+ ALOGE("malformed wfd_content_protection: '%s'", value.c_str());
+
+ return ERROR_MALFORMED;
+ }
+
+ int32_t hdcpPort;
+ if (!ParsedMessage::GetInt32Attribute(
+ value.c_str() + 8, "port", &hdcpPort)
+ || hdcpPort < 1 || hdcpPort > 65535) {
+ return ERROR_MALFORMED;
+ }
+
+ mIsHDCP2_0 = isHDCP2_0;
+ mHDCPPort = hdcpPort;
+
+ status_t err = makeHDCP();
+ if (err != OK) {
+ ALOGE("Unable to instantiate HDCP component.");
+ return err;
+ }
+ }
+
+ return sendM4(sessionID);
+}
+
+status_t WifiDisplaySource::onReceiveM4Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ if (mUsingHDCP && !mHDCPInitializationComplete) {
+ ALOGI("Deferring SETUP trigger until HDCP initialization completes.");
+
+ mSetupTriggerDeferred = true;
+ return OK;
+ }
+
+ return sendM5(sessionID, false /* requestShutdown */);
+}
+
+status_t WifiDisplaySource::onReceiveM5Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ int32_t statusCode;
+ if (!msg->getStatusCode(&statusCode)) {
+ return ERROR_MALFORMED;
+ }
+
+ if (statusCode != 200) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ return OK;
+}
+
+status_t WifiDisplaySource::onReceiveM16Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg) {
+ // If only the response was required to include a "Session:" header...
+
+ CHECK_EQ(sessionID, mClientSessionID);
+
+ if (mClientInfo.mPlaybackSession != NULL) {
+ mClientInfo.mPlaybackSession->updateLiveness();
+
+ scheduleKeepAlive(sessionID);
+ }
+
+ return OK;
+}
+
+void WifiDisplaySource::scheduleReaper() {
+ if (mReaperPending) {
+ return;
+ }
+
+ mReaperPending = true;
+ (new AMessage(kWhatReapDeadClients, id()))->post(kReaperIntervalUs);
+}
+
+void WifiDisplaySource::scheduleKeepAlive(int32_t sessionID) {
+ // We need to send updates at least 5 secs before the timeout is set to
+ // expire, make sure the timeout is greater than 5 secs to begin with.
+ CHECK_GT(kPlaybackSessionTimeoutUs, 5000000ll);
+
+ sp<AMessage> msg = new AMessage(kWhatKeepAlive, id());
+ msg->setInt32("sessionID", sessionID);
+ msg->post(kPlaybackSessionTimeoutUs - 5000000ll);
+}
+
+status_t WifiDisplaySource::onReceiveClientData(const sp<AMessage> &msg) {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ sp<RefBase> obj;
+ CHECK(msg->findObject("data", &obj));
+
+ sp<ParsedMessage> data =
+ static_cast<ParsedMessage *>(obj.get());
+
+ ALOGV("session %d received '%s'",
+ sessionID, data->debugString().c_str());
+
+ AString method;
+ AString uri;
+ data->getRequestField(0, &method);
+
+ int32_t cseq;
+ if (!data->findInt32("cseq", &cseq)) {
+ sendErrorResponse(sessionID, "400 Bad Request", -1 /* cseq */);
+ return ERROR_MALFORMED;
+ }
+
+ if (method.startsWith("RTSP/")) {
+ // This is a response.
+
+ ResponseID id;
+ id.mSessionID = sessionID;
+ id.mCSeq = cseq;
+
+ ssize_t index = mResponseHandlers.indexOfKey(id);
+
+ if (index < 0) {
+ ALOGW("Received unsolicited server response, cseq %d", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ HandleRTSPResponseFunc func = mResponseHandlers.valueAt(index);
+ mResponseHandlers.removeItemsAt(index);
+
+ status_t err = (this->*func)(sessionID, data);
+
+ if (err != OK) {
+ ALOGW("Response handler for session %d, cseq %d returned "
+ "err %d (%s)",
+ sessionID, cseq, err, strerror(-err));
+
+ return err;
+ }
+
+ return OK;
+ }
+
+ AString version;
+ data->getRequestField(2, &version);
+ if (!(version == AString("RTSP/1.0"))) {
+ sendErrorResponse(sessionID, "505 RTSP Version not supported", cseq);
+ return ERROR_UNSUPPORTED;
+ }
+
+ status_t err;
+ if (method == "OPTIONS") {
+ err = onOptionsRequest(sessionID, cseq, data);
+ } else if (method == "SETUP") {
+ err = onSetupRequest(sessionID, cseq, data);
+ } else if (method == "PLAY") {
+ err = onPlayRequest(sessionID, cseq, data);
+ } else if (method == "PAUSE") {
+ err = onPauseRequest(sessionID, cseq, data);
+ } else if (method == "TEARDOWN") {
+ err = onTeardownRequest(sessionID, cseq, data);
+ } else if (method == "GET_PARAMETER") {
+ err = onGetParameterRequest(sessionID, cseq, data);
+ } else if (method == "SET_PARAMETER") {
+ err = onSetParameterRequest(sessionID, cseq, data);
+ } else {
+ sendErrorResponse(sessionID, "405 Method Not Allowed", cseq);
+
+ err = ERROR_UNSUPPORTED;
+ }
+
+ return err;
+}
+
+status_t WifiDisplaySource::onOptionsRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession != NULL) {
+ playbackSession->updateLiveness();
+ }
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq);
+
+ response.append(
+ "Public: org.wfa.wfd1.0, SETUP, TEARDOWN, PLAY, PAUSE, "
+ "GET_PARAMETER, SET_PARAMETER\r\n");
+
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+
+ if (err == OK) {
+ err = sendM3(sessionID);
+ }
+
+ return err;
+}
+
+status_t WifiDisplaySource::onSetupRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ CHECK_EQ(sessionID, mClientSessionID);
+ if (mClientInfo.mPlaybackSessionID != -1) {
+ // We only support a single playback session per client.
+ // This is due to the reversed keep-alive design in the wfd specs...
+ sendErrorResponse(sessionID, "400 Bad Request", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ AString transport;
+ if (!data->findString("transport", &transport)) {
+ sendErrorResponse(sessionID, "400 Bad Request", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ Sender::TransportMode transportMode = Sender::TRANSPORT_UDP;
+
+ int clientRtp, clientRtcp;
+ if (transport.startsWith("RTP/AVP/TCP;")) {
+ AString interleaved;
+ if (ParsedMessage::GetAttribute(
+ transport.c_str(), "interleaved", &interleaved)
+ && sscanf(interleaved.c_str(), "%d-%d",
+ &clientRtp, &clientRtcp) == 2) {
+ transportMode = Sender::TRANSPORT_TCP_INTERLEAVED;
+ } else {
+ bool badRequest = false;
+
+ AString clientPort;
+ if (!ParsedMessage::GetAttribute(
+ transport.c_str(), "client_port", &clientPort)) {
+ badRequest = true;
+ } else if (sscanf(clientPort.c_str(), "%d-%d",
+ &clientRtp, &clientRtcp) == 2) {
+ } else if (sscanf(clientPort.c_str(), "%d", &clientRtp) == 1) {
+ // No RTCP.
+ clientRtcp = -1;
+ } else {
+ badRequest = true;
+ }
+
+ if (badRequest) {
+ sendErrorResponse(sessionID, "400 Bad Request", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ transportMode = Sender::TRANSPORT_TCP;
+ }
+ } else if (transport.startsWith("RTP/AVP;unicast;")
+ || transport.startsWith("RTP/AVP/UDP;unicast;")) {
+ bool badRequest = false;
+
+ AString clientPort;
+ if (!ParsedMessage::GetAttribute(
+ transport.c_str(), "client_port", &clientPort)) {
+ badRequest = true;
+ } else if (sscanf(clientPort.c_str(), "%d-%d",
+ &clientRtp, &clientRtcp) == 2) {
+ } else if (sscanf(clientPort.c_str(), "%d", &clientRtp) == 1) {
+ // No RTCP.
+ clientRtcp = -1;
+ } else {
+ badRequest = true;
+ }
+
+ if (badRequest) {
+ sendErrorResponse(sessionID, "400 Bad Request", cseq);
+ return ERROR_MALFORMED;
+ }
+#if 1
+ // The older LG dongles doesn't specify client_port=xxx apparently.
+ } else if (transport == "RTP/AVP/UDP;unicast") {
+ clientRtp = 19000;
+ clientRtcp = -1;
+#endif
+ } else {
+ sendErrorResponse(sessionID, "461 Unsupported Transport", cseq);
+ return ERROR_UNSUPPORTED;
+ }
+
+ int32_t playbackSessionID = makeUniquePlaybackSessionID();
+
+ sp<AMessage> notify = new AMessage(kWhatPlaybackSessionNotify, id());
+ notify->setInt32("playbackSessionID", playbackSessionID);
+ notify->setInt32("sessionID", sessionID);
+
+ sp<PlaybackSession> playbackSession =
+ new PlaybackSession(
+ mNetSession, notify, mInterfaceAddr, mHDCP);
+
+ looper()->registerHandler(playbackSession);
+
+ AString uri;
+ data->getRequestField(1, &uri);
+
+ if (strncasecmp("rtsp://", uri.c_str(), 7)) {
+ sendErrorResponse(sessionID, "400 Bad Request", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ if (!(uri.startsWith("rtsp://") && uri.endsWith("/wfd1.0/streamid=0"))) {
+ sendErrorResponse(sessionID, "404 Not found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ status_t err = playbackSession->init(
+ mClientInfo.mRemoteIP.c_str(),
+ clientRtp,
+ clientRtcp,
+ transportMode,
+ mUsingPCMAudio);
+
+ if (err != OK) {
+ looper()->unregisterHandler(playbackSession->id());
+ playbackSession.clear();
+ }
+
+ switch (err) {
+ case OK:
+ break;
+ case -ENOENT:
+ sendErrorResponse(sessionID, "404 Not Found", cseq);
+ return err;
+ default:
+ sendErrorResponse(sessionID, "403 Forbidden", cseq);
+ return err;
+ }
+
+ mClientInfo.mPlaybackSessionID = playbackSessionID;
+ mClientInfo.mPlaybackSession = playbackSession;
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+
+ if (transportMode == Sender::TRANSPORT_TCP_INTERLEAVED) {
+ response.append(
+ StringPrintf(
+ "Transport: RTP/AVP/TCP;interleaved=%d-%d;",
+ clientRtp, clientRtcp));
+ } else {
+ int32_t serverRtp = playbackSession->getRTPPort();
+
+ AString transportString = "UDP";
+ if (transportMode == Sender::TRANSPORT_TCP) {
+ transportString = "TCP";
+ }
+
+ if (clientRtcp >= 0) {
+ response.append(
+ StringPrintf(
+ "Transport: RTP/AVP/%s;unicast;client_port=%d-%d;"
+ "server_port=%d-%d\r\n",
+ transportString.c_str(),
+ clientRtp, clientRtcp, serverRtp, serverRtp + 1));
+ } else {
+ response.append(
+ StringPrintf(
+ "Transport: RTP/AVP/%s;unicast;client_port=%d;"
+ "server_port=%d\r\n",
+ transportString.c_str(),
+ clientRtp, serverRtp));
+ }
+ }
+
+ response.append("\r\n");
+
+ err = mNetSession->sendRequest(sessionID, response.c_str());
+
+ if (err != OK) {
+ return err;
+ }
+
+ mState = AWAITING_CLIENT_PLAY;
+
+ scheduleReaper();
+ scheduleKeepAlive(sessionID);
+
+ return OK;
+}
+
+status_t WifiDisplaySource::onPlayRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession == NULL) {
+ sendErrorResponse(sessionID, "454 Session Not Found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ ALOGI("Received PLAY request.");
+
+ status_t err = playbackSession->play();
+ CHECK_EQ(err, (status_t)OK);
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+ response.append("Range: npt=now-\r\n");
+ response.append("\r\n");
+
+ err = mNetSession->sendRequest(sessionID, response.c_str());
+
+ if (err != OK) {
+ return err;
+ }
+
+ playbackSession->finishPlay();
+
+ CHECK_EQ(mState, AWAITING_CLIENT_PLAY);
+ mState = ABOUT_TO_PLAY;
+
+ return OK;
+}
+
+status_t WifiDisplaySource::onPauseRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession == NULL) {
+ sendErrorResponse(sessionID, "454 Session Not Found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ status_t err = playbackSession->pause();
+ CHECK_EQ(err, (status_t)OK);
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+ response.append("\r\n");
+
+ err = mNetSession->sendRequest(sessionID, response.c_str());
+
+ return err;
+}
+
+status_t WifiDisplaySource::onTeardownRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ ALOGI("Received TEARDOWN request.");
+
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession == NULL) {
+ sendErrorResponse(sessionID, "454 Session Not Found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+ response.append("Connection: close\r\n");
+ response.append("\r\n");
+
+ mNetSession->sendRequest(sessionID, response.c_str());
+
+ if (mState == AWAITING_CLIENT_TEARDOWN) {
+ CHECK_NE(mStopReplyID, 0);
+ finishStop();
+ } else {
+ mClient->onDisplayError(IRemoteDisplayClient::kDisplayErrorUnknown);
+ }
+
+ return OK;
+}
+
+void WifiDisplaySource::finishStop() {
+ ALOGV("finishStop");
+
+ mState = STOPPING;
+
+ disconnectClientAsync();
+}
+
+void WifiDisplaySource::finishStopAfterDisconnectingClient() {
+ ALOGV("finishStopAfterDisconnectingClient");
+
+ if (mHDCP != NULL) {
+ ALOGI("Initiating HDCP shutdown.");
+ mHDCP->shutdownAsync();
+ return;
+ }
+
+ finishStop2();
+}
+
+void WifiDisplaySource::finishStop2() {
+ ALOGV("finishStop2");
+
+ if (mHDCP != NULL) {
+ mHDCP->setObserver(NULL);
+ mHDCPObserver.clear();
+ mHDCP.clear();
+ }
+
+ if (mSessionID != 0) {
+ mNetSession->destroySession(mSessionID);
+ mSessionID = 0;
+ }
+
+ ALOGI("We're stopped.");
+ mState = STOPPED;
+
+ status_t err = OK;
+
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", err);
+ response->postReply(mStopReplyID);
+}
+
+status_t WifiDisplaySource::onGetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession == NULL) {
+ sendErrorResponse(sessionID, "454 Session Not Found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ playbackSession->updateLiveness();
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ return err;
+}
+
+status_t WifiDisplaySource::onSetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data) {
+ int32_t playbackSessionID;
+ sp<PlaybackSession> playbackSession =
+ findPlaybackSession(data, &playbackSessionID);
+
+ if (playbackSession == NULL) {
+ sendErrorResponse(sessionID, "454 Session Not Found", cseq);
+ return ERROR_MALFORMED;
+ }
+
+ if (strstr(data->getContent(), "wfd_idr_request\r\n")) {
+ playbackSession->requestIDRFrame();
+ }
+
+ playbackSession->updateLiveness();
+
+ AString response = "RTSP/1.0 200 OK\r\n";
+ AppendCommonResponse(&response, cseq, playbackSessionID);
+ response.append("\r\n");
+
+ status_t err = mNetSession->sendRequest(sessionID, response.c_str());
+ return err;
+}
+
+// static
+void WifiDisplaySource::AppendCommonResponse(
+ AString *response, int32_t cseq, int32_t playbackSessionID) {
+ time_t now = time(NULL);
+ struct tm *now2 = gmtime(&now);
+ char buf[128];
+ strftime(buf, sizeof(buf), "%a, %d %b %Y %H:%M:%S %z", now2);
+
+ response->append("Date: ");
+ response->append(buf);
+ response->append("\r\n");
+
+ response->append("Server: Mine/1.0\r\n");
+
+ if (cseq >= 0) {
+ response->append(StringPrintf("CSeq: %d\r\n", cseq));
+ }
+
+ if (playbackSessionID >= 0ll) {
+ response->append(
+ StringPrintf(
+ "Session: %d;timeout=%lld\r\n",
+ playbackSessionID, kPlaybackSessionTimeoutSecs));
+ }
+}
+
+void WifiDisplaySource::sendErrorResponse(
+ int32_t sessionID,
+ const char *errorDetail,
+ int32_t cseq) {
+ AString response;
+ response.append("RTSP/1.0 ");
+ response.append(errorDetail);
+ response.append("\r\n");
+
+ AppendCommonResponse(&response, cseq);
+
+ response.append("\r\n");
+
+ mNetSession->sendRequest(sessionID, response.c_str());
+}
+
+int32_t WifiDisplaySource::makeUniquePlaybackSessionID() const {
+ return rand();
+}
+
+sp<WifiDisplaySource::PlaybackSession> WifiDisplaySource::findPlaybackSession(
+ const sp<ParsedMessage> &data, int32_t *playbackSessionID) const {
+ if (!data->findInt32("session", playbackSessionID)) {
+ // XXX the older dongles do not always include a "Session:" header.
+ *playbackSessionID = mClientInfo.mPlaybackSessionID;
+ return mClientInfo.mPlaybackSession;
+ }
+
+ if (*playbackSessionID != mClientInfo.mPlaybackSessionID) {
+ return NULL;
+ }
+
+ return mClientInfo.mPlaybackSession;
+}
+
+void WifiDisplaySource::disconnectClientAsync() {
+ ALOGV("disconnectClient");
+
+ if (mClientInfo.mPlaybackSession == NULL) {
+ disconnectClient2();
+ return;
+ }
+
+ if (mClientInfo.mPlaybackSession != NULL) {
+ ALOGV("Destroying PlaybackSession");
+ mClientInfo.mPlaybackSession->destroyAsync();
+ }
+}
+
+void WifiDisplaySource::disconnectClient2() {
+ ALOGV("disconnectClient2");
+
+ if (mClientInfo.mPlaybackSession != NULL) {
+ looper()->unregisterHandler(mClientInfo.mPlaybackSession->id());
+ mClientInfo.mPlaybackSession.clear();
+ }
+
+ if (mClientSessionID != 0) {
+ mNetSession->destroySession(mClientSessionID);
+ mClientSessionID = 0;
+ }
+
+ mClient->onDisplayDisconnected();
+
+ finishStopAfterDisconnectingClient();
+}
+
+struct WifiDisplaySource::HDCPObserver : public BnHDCPObserver {
+ HDCPObserver(const sp<AMessage> &notify);
+
+ virtual void notify(
+ int msg, int ext1, int ext2, const Parcel *obj);
+
+private:
+ sp<AMessage> mNotify;
+
+ DISALLOW_EVIL_CONSTRUCTORS(HDCPObserver);
+};
+
+WifiDisplaySource::HDCPObserver::HDCPObserver(
+ const sp<AMessage> &notify)
+ : mNotify(notify) {
+}
+
+void WifiDisplaySource::HDCPObserver::notify(
+ int msg, int ext1, int ext2, const Parcel *obj) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("msg", msg);
+ notify->setInt32("ext1", ext1);
+ notify->setInt32("ext2", ext2);
+ notify->post();
+}
+
+status_t WifiDisplaySource::makeHDCP() {
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("media.player"));
+ sp<IMediaPlayerService> service = interface_cast<IMediaPlayerService>(binder);
+ CHECK(service != NULL);
+
+ mHDCP = service->makeHDCP();
+
+ if (mHDCP == NULL) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ sp<AMessage> notify = new AMessage(kWhatHDCPNotify, id());
+ mHDCPObserver = new HDCPObserver(notify);
+
+ status_t err = mHDCP->setObserver(mHDCPObserver);
+
+ if (err != OK) {
+ ALOGE("Failed to set HDCP observer.");
+
+ mHDCPObserver.clear();
+ mHDCP.clear();
+
+ return err;
+ }
+
+ ALOGI("Initiating HDCP negotiation w/ host %s:%d",
+ mClientInfo.mRemoteIP.c_str(), mHDCPPort);
+
+ err = mHDCP->initAsync(mClientInfo.mRemoteIP.c_str(), mHDCPPort);
+
+ if (err != OK) {
+ return err;
+ }
+
+ return OK;
+}
+
+} // namespace android
+
diff --git a/media/libstagefright/wifi-display/source/WifiDisplaySource.h b/media/libstagefright/wifi-display/source/WifiDisplaySource.h
new file mode 100644
index 0000000..02fa0a6
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.h
@@ -0,0 +1,233 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WIFI_DISPLAY_SOURCE_H_
+
+#define WIFI_DISPLAY_SOURCE_H_
+
+#include "ANetworkSession.h"
+
+#include <media/stagefright/foundation/AHandler.h>
+
+#include <netinet/in.h>
+
+namespace android {
+
+struct IHDCP;
+struct IRemoteDisplayClient;
+struct ParsedMessage;
+
+// Represents the RTSP server acting as a wifi display source.
+// Manages incoming connections, sets up Playback sessions as necessary.
+struct WifiDisplaySource : public AHandler {
+ static const unsigned kWifiDisplayDefaultPort = 7236;
+
+ WifiDisplaySource(
+ const sp<ANetworkSession> &netSession,
+ const sp<IRemoteDisplayClient> &client);
+
+ status_t start(const char *iface);
+ status_t stop();
+
+protected:
+ virtual ~WifiDisplaySource();
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ struct PlaybackSession;
+ struct HDCPObserver;
+
+ enum State {
+ INITIALIZED,
+ AWAITING_CLIENT_CONNECTION,
+ AWAITING_CLIENT_SETUP,
+ AWAITING_CLIENT_PLAY,
+ ABOUT_TO_PLAY,
+ PLAYING,
+ AWAITING_CLIENT_TEARDOWN,
+ STOPPING,
+ STOPPED,
+ };
+
+ enum {
+ kWhatStart,
+ kWhatRTSPNotify,
+ kWhatStop,
+ kWhatReapDeadClients,
+ kWhatPlaybackSessionNotify,
+ kWhatKeepAlive,
+ kWhatHDCPNotify,
+ kWhatFinishStop2,
+ kWhatTeardownTriggerTimedOut,
+ };
+
+ struct ResponseID {
+ int32_t mSessionID;
+ int32_t mCSeq;
+
+ bool operator<(const ResponseID &other) const {
+ return mSessionID < other.mSessionID
+ || (mSessionID == other.mSessionID
+ && mCSeq < other.mCSeq);
+ }
+ };
+
+ typedef status_t (WifiDisplaySource::*HandleRTSPResponseFunc)(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ static const int64_t kReaperIntervalUs = 1000000ll;
+
+ // We request that the dongle send us a "TEARDOWN" in order to
+ // perform an orderly shutdown. We're willing to wait up to 2 secs
+ // for this message to arrive, after that we'll force a disconnect
+ // instead.
+ static const int64_t kTeardownTriggerTimeouSecs = 2;
+
+ static const int64_t kPlaybackSessionTimeoutSecs = 30;
+
+ static const int64_t kPlaybackSessionTimeoutUs =
+ kPlaybackSessionTimeoutSecs * 1000000ll;
+
+ State mState;
+ sp<ANetworkSession> mNetSession;
+ sp<IRemoteDisplayClient> mClient;
+ struct in_addr mInterfaceAddr;
+ int32_t mSessionID;
+
+ uint32_t mStopReplyID;
+
+ int32_t mChosenRTPPort; // extracted from "wfd_client_rtp_ports"
+
+ bool mUsingPCMAudio;
+ int32_t mClientSessionID;
+
+ struct ClientInfo {
+ AString mRemoteIP;
+ AString mLocalIP;
+ int32_t mLocalPort;
+ int32_t mPlaybackSessionID;
+ sp<PlaybackSession> mPlaybackSession;
+ };
+ ClientInfo mClientInfo;
+
+ bool mReaperPending;
+
+ int32_t mNextCSeq;
+
+ KeyedVector<ResponseID, HandleRTSPResponseFunc> mResponseHandlers;
+
+ // HDCP specific section >>>>
+ bool mUsingHDCP;
+ bool mIsHDCP2_0;
+ int32_t mHDCPPort;
+ sp<IHDCP> mHDCP;
+ sp<HDCPObserver> mHDCPObserver;
+
+ bool mHDCPInitializationComplete;
+ bool mSetupTriggerDeferred;
+
+ status_t makeHDCP();
+ // <<<< HDCP specific section
+
+ status_t sendM1(int32_t sessionID);
+ status_t sendM3(int32_t sessionID);
+ status_t sendM4(int32_t sessionID);
+ status_t sendM5(int32_t sessionID, bool requestShutdown);
+ status_t sendM16(int32_t sessionID);
+
+ status_t onReceiveM1Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveM3Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveM4Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveM5Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ status_t onReceiveM16Response(
+ int32_t sessionID, const sp<ParsedMessage> &msg);
+
+ void registerResponseHandler(
+ int32_t sessionID, int32_t cseq, HandleRTSPResponseFunc func);
+
+ status_t onReceiveClientData(const sp<AMessage> &msg);
+
+ status_t onOptionsRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onSetupRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onPlayRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onPauseRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onTeardownRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onGetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ status_t onSetParameterRequest(
+ int32_t sessionID,
+ int32_t cseq,
+ const sp<ParsedMessage> &data);
+
+ void sendErrorResponse(
+ int32_t sessionID,
+ const char *errorDetail,
+ int32_t cseq);
+
+ static void AppendCommonResponse(
+ AString *response, int32_t cseq, int32_t playbackSessionID = -1ll);
+
+ void scheduleReaper();
+ void scheduleKeepAlive(int32_t sessionID);
+
+ int32_t makeUniquePlaybackSessionID() const;
+
+ sp<PlaybackSession> findPlaybackSession(
+ const sp<ParsedMessage> &data, int32_t *playbackSessionID) const;
+
+ void finishStop();
+ void disconnectClientAsync();
+ void disconnectClient2();
+ void finishStopAfterDisconnectingClient();
+ void finishStop2();
+
+ DISALLOW_EVIL_CONSTRUCTORS(WifiDisplaySource);
+};
+
+} // namespace android
+
+#endif // WIFI_DISPLAY_SOURCE_H_
diff --git a/media/libstagefright/wifi-display/udptest.cpp b/media/libstagefright/wifi-display/udptest.cpp
new file mode 100644
index 0000000..1cd82c3
--- /dev/null
+++ b/media/libstagefright/wifi-display/udptest.cpp
@@ -0,0 +1,355 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NEBUG 0
+#define LOG_TAG "udptest"
+#include <utils/Log.h>
+
+#include "ANetworkSession.h"
+
+#include <binder/ProcessState.h>
+#include <media/stagefright/foundation/ABuffer.h>
+#include <media/stagefright/foundation/ADebug.h>
+#include <media/stagefright/foundation/AHandler.h>
+#include <media/stagefright/foundation/ALooper.h>
+#include <media/stagefright/foundation/AMessage.h>
+#include <media/stagefright/Utils.h>
+
+namespace android {
+
+struct TestHandler : public AHandler {
+ TestHandler(const sp<ANetworkSession> &netSession);
+
+ void startServer(unsigned localPort);
+ void startClient(const char *remoteHost, unsigned remotePort);
+
+protected:
+ virtual ~TestHandler();
+
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ enum {
+ kWhatStartServer,
+ kWhatStartClient,
+ kWhatUDPNotify,
+ kWhatSendPacket,
+ };
+
+ sp<ANetworkSession> mNetSession;
+
+ bool mIsServer;
+ bool mConnected;
+ int32_t mUDPSession;
+ uint32_t mSeqNo;
+ double mTotalTimeUs;
+ int32_t mCount;
+
+ void postSendPacket(int64_t delayUs = 0ll);
+
+ DISALLOW_EVIL_CONSTRUCTORS(TestHandler);
+};
+
+TestHandler::TestHandler(const sp<ANetworkSession> &netSession)
+ : mNetSession(netSession),
+ mIsServer(false),
+ mConnected(false),
+ mUDPSession(0),
+ mSeqNo(0),
+ mTotalTimeUs(0.0),
+ mCount(0) {
+}
+
+TestHandler::~TestHandler() {
+}
+
+void TestHandler::startServer(unsigned localPort) {
+ sp<AMessage> msg = new AMessage(kWhatStartServer, id());
+ msg->setInt32("localPort", localPort);
+ msg->post();
+}
+
+void TestHandler::startClient(const char *remoteHost, unsigned remotePort) {
+ sp<AMessage> msg = new AMessage(kWhatStartClient, id());
+ msg->setString("remoteHost", remoteHost);
+ msg->setInt32("remotePort", remotePort);
+ msg->post();
+}
+
+void TestHandler::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatStartClient:
+ {
+ AString remoteHost;
+ CHECK(msg->findString("remoteHost", &remoteHost));
+
+ int32_t remotePort;
+ CHECK(msg->findInt32("remotePort", &remotePort));
+
+ sp<AMessage> notify = new AMessage(kWhatUDPNotify, id());
+
+ CHECK_EQ((status_t)OK,
+ mNetSession->createUDPSession(
+ 0 /* localPort */,
+ remoteHost.c_str(),
+ remotePort,
+ notify,
+ &mUDPSession));
+
+ postSendPacket();
+ break;
+ }
+
+ case kWhatStartServer:
+ {
+ mIsServer = true;
+
+ int32_t localPort;
+ CHECK(msg->findInt32("localPort", &localPort));
+
+ sp<AMessage> notify = new AMessage(kWhatUDPNotify, id());
+
+ CHECK_EQ((status_t)OK,
+ mNetSession->createUDPSession(
+ localPort, notify, &mUDPSession));
+
+ break;
+ }
+
+ case kWhatSendPacket:
+ {
+ char buffer[12];
+ memset(buffer, 0, sizeof(buffer));
+
+ buffer[0] = mSeqNo >> 24;
+ buffer[1] = (mSeqNo >> 16) & 0xff;
+ buffer[2] = (mSeqNo >> 8) & 0xff;
+ buffer[3] = mSeqNo & 0xff;
+ ++mSeqNo;
+
+ int64_t nowUs = ALooper::GetNowUs();
+ buffer[4] = nowUs >> 56;
+ buffer[5] = (nowUs >> 48) & 0xff;
+ buffer[6] = (nowUs >> 40) & 0xff;
+ buffer[7] = (nowUs >> 32) & 0xff;
+ buffer[8] = (nowUs >> 24) & 0xff;
+ buffer[9] = (nowUs >> 16) & 0xff;
+ buffer[10] = (nowUs >> 8) & 0xff;
+ buffer[11] = nowUs & 0xff;
+
+ CHECK_EQ((status_t)OK,
+ mNetSession->sendRequest(
+ mUDPSession, buffer, sizeof(buffer)));
+
+ postSendPacket(20000ll);
+ break;
+ }
+
+ case kWhatUDPNotify:
+ {
+ int32_t reason;
+ CHECK(msg->findInt32("reason", &reason));
+
+ switch (reason) {
+ case ANetworkSession::kWhatError:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ int32_t err;
+ CHECK(msg->findInt32("err", &err));
+
+ AString detail;
+ CHECK(msg->findString("detail", &detail));
+
+ ALOGE("An error occurred in session %d (%d, '%s/%s').",
+ sessionID,
+ err,
+ detail.c_str(),
+ strerror(-err));
+
+ mNetSession->destroySession(sessionID);
+ break;
+ }
+
+ case ANetworkSession::kWhatDatagram:
+ {
+ int32_t sessionID;
+ CHECK(msg->findInt32("sessionID", &sessionID));
+
+ sp<ABuffer> data;
+ CHECK(msg->findBuffer("data", &data));
+
+ if (mIsServer) {
+ if (!mConnected) {
+ AString fromAddr;
+ CHECK(msg->findString("fromAddr", &fromAddr));
+
+ int32_t fromPort;
+ CHECK(msg->findInt32("fromPort", &fromPort));
+
+ CHECK_EQ((status_t)OK,
+ mNetSession->connectUDPSession(
+ mUDPSession, fromAddr.c_str(), fromPort));
+
+ mConnected = true;
+ }
+
+ int64_t nowUs = ALooper::GetNowUs();
+
+ sp<ABuffer> buffer = new ABuffer(data->size() + 8);
+ memcpy(buffer->data(), data->data(), data->size());
+
+ uint8_t *ptr = buffer->data() + data->size();
+
+ *ptr++ = nowUs >> 56;
+ *ptr++ = (nowUs >> 48) & 0xff;
+ *ptr++ = (nowUs >> 40) & 0xff;
+ *ptr++ = (nowUs >> 32) & 0xff;
+ *ptr++ = (nowUs >> 24) & 0xff;
+ *ptr++ = (nowUs >> 16) & 0xff;
+ *ptr++ = (nowUs >> 8) & 0xff;
+ *ptr++ = nowUs & 0xff;
+
+ CHECK_EQ((status_t)OK,
+ mNetSession->sendRequest(
+ mUDPSession, buffer->data(), buffer->size()));
+ } else {
+ CHECK_EQ(data->size(), 20u);
+
+ uint32_t seqNo = U32_AT(data->data());
+ int64_t t1 = U64_AT(data->data() + 4);
+ int64_t t2 = U64_AT(data->data() + 12);
+
+ int64_t t3;
+ CHECK(data->meta()->findInt64("arrivalTimeUs", &t3));
+
+#if 0
+ printf("roundtrip seqNo %u, time = %lld us\n",
+ seqNo, t3 - t1);
+#else
+ mTotalTimeUs += t3 - t1;
+ ++mCount;
+ printf("avg. roundtrip time %.2f us\n", mTotalTimeUs / mCount);
+#endif
+ }
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+
+ break;
+ }
+
+ default:
+ TRESPASS();
+ }
+}
+
+void TestHandler::postSendPacket(int64_t delayUs) {
+ (new AMessage(kWhatSendPacket, id()))->post(delayUs);
+}
+
+} // namespace android
+
+static void usage(const char *me) {
+ fprintf(stderr,
+ "usage: %s -c host[:port]\tconnect to test server\n"
+ " -l \tcreate a test server\n",
+ me);
+}
+
+int main(int argc, char **argv) {
+ using namespace android;
+
+ ProcessState::self()->startThreadPool();
+
+ int32_t localPort = -1;
+ int32_t connectToPort = -1;
+ AString connectToHost;
+
+ int res;
+ while ((res = getopt(argc, argv, "hc:l:")) >= 0) {
+ switch (res) {
+ case 'c':
+ {
+ const char *colonPos = strrchr(optarg, ':');
+
+ if (colonPos == NULL) {
+ connectToHost = optarg;
+ connectToPort = 49152;
+ } else {
+ connectToHost.setTo(optarg, colonPos - optarg);
+
+ char *end;
+ connectToPort = strtol(colonPos + 1, &end, 10);
+
+ if (*end != '\0' || end == colonPos + 1
+ || connectToPort < 1 || connectToPort > 65535) {
+ fprintf(stderr, "Illegal port specified.\n");
+ exit(1);
+ }
+ }
+ break;
+ }
+
+ case 'l':
+ {
+ char *end;
+ localPort = strtol(optarg, &end, 10);
+
+ if (*end != '\0' || end == optarg
+ || localPort < 1 || localPort > 65535) {
+ fprintf(stderr, "Illegal port specified.\n");
+ exit(1);
+ }
+ break;
+ }
+
+ case '?':
+ case 'h':
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (localPort < 0 && connectToPort < 0) {
+ fprintf(stderr,
+ "You need to select either client or server mode.\n");
+ exit(1);
+ }
+
+ sp<ANetworkSession> netSession = new ANetworkSession;
+ netSession->start();
+
+ sp<ALooper> looper = new ALooper;
+
+ sp<TestHandler> handler = new TestHandler(netSession);
+ looper->registerHandler(handler);
+
+ if (localPort >= 0) {
+ handler->startServer(localPort);
+ } else {
+ handler->startClient(connectToHost.c_str(), connectToPort);
+ }
+
+ looper->start(true /* runOnCallingThread */);
+
+ return 0;
+}
+
diff --git a/media/libstagefright/wifi-display/wfd.cpp b/media/libstagefright/wifi-display/wfd.cpp
new file mode 100644
index 0000000..011edab
--- /dev/null
+++ b/media/libstagefright/wifi-display/wfd.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright 2012, The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+//#define LOG_NDEBUG 0
+#define LOG_TAG "wfd"
+#include <utils/Log.h>
+
+#include "sink/WifiDisplaySink.h"
+#include "source/WifiDisplaySource.h"
+
+#include <binder/ProcessState.h>
+#include <binder/IServiceManager.h>
+#include <media/IMediaPlayerService.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+namespace android {
+
+} // namespace android
+
+static void usage(const char *me) {
+ fprintf(stderr,
+ "usage:\n"
+ " %s -c host[:port]\tconnect to wifi source\n"
+ " -u uri \tconnect to an rtsp uri\n",
+ me);
+}
+
+int main(int argc, char **argv) {
+ using namespace android;
+
+ ProcessState::self()->startThreadPool();
+
+ DataSource::RegisterDefaultSniffers();
+
+ AString connectToHost;
+ int32_t connectToPort = -1;
+ AString uri;
+
+ int res;
+ while ((res = getopt(argc, argv, "hc:l:u:")) >= 0) {
+ switch (res) {
+ case 'c':
+ {
+ const char *colonPos = strrchr(optarg, ':');
+
+ if (colonPos == NULL) {
+ connectToHost = optarg;
+ connectToPort = WifiDisplaySource::kWifiDisplayDefaultPort;
+ } else {
+ connectToHost.setTo(optarg, colonPos - optarg);
+
+ char *end;
+ connectToPort = strtol(colonPos + 1, &end, 10);
+
+ if (*end != '\0' || end == colonPos + 1
+ || connectToPort < 1 || connectToPort > 65535) {
+ fprintf(stderr, "Illegal port specified.\n");
+ exit(1);
+ }
+ }
+ break;
+ }
+
+ case 'u':
+ {
+ uri = optarg;
+ break;
+ }
+
+ case '?':
+ case 'h':
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (connectToPort < 0 && uri.empty()) {
+ fprintf(stderr,
+ "You need to select either source host or uri.\n");
+
+ exit(1);
+ }
+
+ if (connectToPort >= 0 && !uri.empty()) {
+ fprintf(stderr,
+ "You need to either connect to a wfd host or an rtsp url, "
+ "not both.\n");
+ exit(1);
+ }
+
+ sp<ANetworkSession> session = new ANetworkSession;
+ session->start();
+
+ sp<ALooper> looper = new ALooper;
+
+ sp<WifiDisplaySink> sink = new WifiDisplaySink(session);
+ looper->registerHandler(sink);
+
+ if (connectToPort >= 0) {
+ sink->start(connectToHost.c_str(), connectToPort);
+ } else {
+ sink->start(uri.c_str());
+ }
+
+ looper->start(true /* runOnCallingThread */);
+
+ return 0;
+}
diff --git a/media/mediaserver/main_mediaserver.cpp b/media/mediaserver/main_mediaserver.cpp
index 6b1abb1..ddd5b84 100644
--- a/media/mediaserver/main_mediaserver.cpp
+++ b/media/mediaserver/main_mediaserver.cpp
@@ -33,6 +33,7 @@ using namespace android;
int main(int argc, char** argv)
{
+ signal(SIGPIPE, SIG_IGN);
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
ALOGI("ServiceManager: %p", sm.get());
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index bf7795c..d672dff 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -667,7 +667,7 @@ fail:
// reads the object's data and writes it to the specified file path
bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) {
ALOGD("readObject: %s", destPath);
- int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC);
+ int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (fd < 0) {
ALOGE("open failed for %s", destPath);
return false;
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 5606187..662a93d 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -931,7 +931,7 @@ MtpResponseCode MtpServer::doSendObject() {
initialData = ret - MTP_CONTAINER_HEADER_SIZE;
mtp_file_range mfr;
- mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC);
+ mfr.fd = open(mSendObjectFilePath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
if (mfr.fd < 0) {
result = MTP_RESPONSE_GENERAL_ERROR;
goto done;