summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--camera/CameraParameters.cpp2
-rw-r--r--cmds/stagefright/Android.mk2
-rw-r--r--cmds/stagefright/codec.cpp11
-rw-r--r--cmds/stagefright/recordvideo.cpp14
-rw-r--r--cmds/stagefright/sf2.cpp1
-rw-r--r--cmds/stagefright/stagefright.cpp1
-rw-r--r--cmds/stagefright/stream.cpp22
-rw-r--r--drm/common/DrmEngineBase.cpp4
-rw-r--r--drm/common/IDrmManagerService.cpp34
-rw-r--r--drm/drmserver/DrmManager.cpp4
-rw-r--r--drm/drmserver/DrmManagerService.cpp4
-rw-r--r--drm/libdrmframework/DrmManagerClient.cpp4
-rw-r--r--drm/libdrmframework/DrmManagerClientImpl.cpp4
-rw-r--r--drm/libdrmframework/include/DrmManager.h2
-rw-r--r--drm/libdrmframework/include/DrmManagerClientImpl.h3
-rw-r--r--drm/libdrmframework/include/DrmManagerService.h2
-rw-r--r--drm/libdrmframework/include/IDrmManagerService.h4
-rw-r--r--drm/libdrmframework/plugins/common/include/DrmEngineBase.h5
-rw-r--r--drm/libdrmframework/plugins/common/include/IDrmEngine.h5
-rw-r--r--drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h5
-rw-r--r--drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp7
-rw-r--r--drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c31
-rw-r--r--drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.h30
-rw-r--r--drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c14
-rw-r--r--drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.h10
-rw-r--r--drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h2
-rw-r--r--drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp2
-rw-r--r--include/camera/CameraParameters.h10
-rw-r--r--include/drm/DrmManagerClient.h3
-rw-r--r--include/media/AudioBufferProvider.h (renamed from services/audioflinger/AudioBufferProvider.h)12
-rw-r--r--include/media/AudioRecord.h133
-rw-r--r--include/media/AudioSystem.h22
-rw-r--r--include/media/AudioTrack.h18
-rw-r--r--include/media/ExtendedAudioBufferProvider.h (renamed from services/audioflinger/ExtendedAudioBufferProvider.h)2
-rw-r--r--include/media/IAudioFlinger.h19
-rw-r--r--include/media/IAudioPolicyService.h10
-rw-r--r--include/media/IAudioRecord.h2
-rw-r--r--include/media/ICrypto.h2
-rw-r--r--include/media/IHDCP.h78
-rw-r--r--include/media/IMediaPlayer.h1
-rw-r--r--include/media/IMediaPlayerService.h14
-rw-r--r--include/media/IRemoteDisplay.h63
-rw-r--r--include/media/IRemoteDisplayClient.h79
-rw-r--r--include/media/IStreamSource.h11
-rw-r--r--include/media/MediaPlayerInterface.h14
-rw-r--r--include/media/Visualizer.h2
-rw-r--r--include/media/mediametadataretriever.h1
-rw-r--r--include/media/mediaplayer.h3
-rw-r--r--include/media/nbaio/AudioBufferProviderSource.h (renamed from services/audioflinger/AudioBufferProviderSource.h)7
-rw-r--r--include/media/nbaio/AudioStreamInSource.h (renamed from services/audioflinger/AudioStreamInSource.h)0
-rw-r--r--include/media/nbaio/AudioStreamOutSink.h (renamed from services/audioflinger/AudioStreamOutSink.h)5
-rw-r--r--include/media/nbaio/LibsndfileSink.h (renamed from services/audioflinger/LibsndfileSink.h)0
-rw-r--r--include/media/nbaio/LibsndfileSource.h (renamed from services/audioflinger/LibsndfileSource.h)0
-rw-r--r--include/media/nbaio/MonoPipe.h (renamed from services/audioflinger/MonoPipe.h)54
-rw-r--r--include/media/nbaio/MonoPipeReader.h (renamed from services/audioflinger/MonoPipeReader.h)2
-rw-r--r--include/media/nbaio/NBAIO.h (renamed from services/audioflinger/NBAIO.h)28
-rw-r--r--include/media/nbaio/Pipe.h (renamed from services/audioflinger/Pipe.h)0
-rw-r--r--include/media/nbaio/PipeReader.h (renamed from services/audioflinger/PipeReader.h)2
-rw-r--r--include/media/nbaio/SourceAudioBufferProvider.h (renamed from services/audioflinger/SourceAudioBufferProvider.h)2
-rw-r--r--include/media/nbaio/roundup.h (renamed from services/audioflinger/roundup.h)0
-rw-r--r--include/media/stagefright/ACodec.h22
-rw-r--r--include/media/stagefright/AudioSource.h11
-rw-r--r--include/media/stagefright/CameraSource.h1
-rw-r--r--include/media/stagefright/MediaCodec.h47
-rw-r--r--include/media/stagefright/MediaExtractor.h2
-rw-r--r--include/media/stagefright/MetaData.h1
-rw-r--r--include/media/stagefright/NuMediaExtractor.h2
-rw-r--r--include/media/stagefright/OMXCodec.h19
-rw-r--r--include/media/stagefright/SurfaceMediaSource.h31
-rw-r--r--include/media/stagefright/TimeSource.h2
-rw-r--r--include/media/stagefright/Utils.h2
-rw-r--r--include/media/stagefright/foundation/hexdump.h6
-rw-r--r--include/media/stagefright/timedtext/TimedTextDriver.h1
-rw-r--r--include/private/media/VideoFrame.h4
-rwxr-xr-xlibvideoeditor/lvpp/Android.mk1
-rwxr-xr-xlibvideoeditor/lvpp/NativeWindowRenderer.cpp12
-rwxr-xr-xlibvideoeditor/lvpp/PreviewRenderer.cpp9
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorAudioPlayer.cpp4
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorSRC.cpp3
-rwxr-xr-xlibvideoeditor/lvpp/VideoEditorSRC.h2
-rwxr-xr-xlibvideoeditor/osal/inc/M4OSA_Debug.h4
-rwxr-xr-xlibvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c6
-rwxr-xr-xlibvideoeditor/vss/src/M4xVSS_internal.c2
-rwxr-xr-xlibvideoeditor/vss/src/VideoEditorResampler.cpp2
-rwxr-xr-xlibvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp14
-rwxr-xr-xlibvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp6
-rw-r--r--media/common_time/ICommonClock.cpp3
-rw-r--r--media/common_time/ICommonTimeConfig.cpp3
-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.mk4
-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.cpp39
-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/ICrypto.cpp29
-rw-r--r--media/libmedia/IHDCP.cpp206
-rw-r--r--media/libmedia/IMediaMetadataRetriever.cpp17
-rw-r--r--media/libmedia/IMediaPlayer.cpp34
-rw-r--r--media/libmedia/IMediaPlayerService.cpp41
-rw-r--r--media/libmedia/IRemoteDisplay.cpp94
-rw-r--r--media/libmedia/IRemoteDisplayClient.cpp102
-rw-r--r--media/libmedia/IStreamSource.cpp19
-rw-r--r--media/libmedia/MediaProfiles.cpp4
-rw-r--r--media/libmedia/Visualizer.cpp9
-rw-r--r--media/libmedia/mediaplayer.cpp38
-rw-r--r--media/libmediaplayerservice/Android.mk67
-rw-r--r--media/libmediaplayerservice/Crypto.cpp2
-rw-r--r--media/libmediaplayerservice/Crypto.h2
-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.cpp292
-rw-r--r--media/libmediaplayerservice/MediaPlayerService.h11
-rw-r--r--media/libmediaplayerservice/MetadataRetrieverClient.cpp22
-rw-r--r--media/libmediaplayerservice/RemoteDisplay.cpp60
-rw-r--r--media/libmediaplayerservice/RemoteDisplay.h55
-rw-r--r--media/libmediaplayerservice/StagefrightRecorder.cpp29
-rw-r--r--media/libmediaplayerservice/nuplayer/Android.mk1
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.cpp6
-rw-r--r--media/libmediaplayerservice/nuplayer/GenericSource.h6
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp30
-rw-r--r--media/libmediaplayerservice/nuplayer/HTTPLiveSource.h6
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp120
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.h16
-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.h13
-rw-r--r--media/libmediaplayerservice/nuplayer/RTSPSource.cpp82
-rw-r--r--media/libmediaplayerservice/nuplayer/RTSPSource.h10
-rw-r--r--media/libmediaplayerservice/nuplayer/StreamingSource.cpp44
-rw-r--r--media/libmediaplayerservice/nuplayer/StreamingSource.h5
-rw-r--r--media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp140
-rw-r--r--media/libmediaplayerservice/nuplayer/mp4/MP4Source.h54
-rw-r--r--media/libnbaio/Android.mk32
-rw-r--r--media/libnbaio/AudioBufferProviderSource.cpp (renamed from services/audioflinger/AudioBufferProviderSource.cpp)16
-rw-r--r--media/libnbaio/AudioStreamInSource.cpp (renamed from services/audioflinger/AudioStreamInSource.cpp)2
-rw-r--r--media/libnbaio/AudioStreamOutSink.cpp (renamed from services/audioflinger/AudioStreamOutSink.cpp)14
-rw-r--r--media/libnbaio/LibsndfileSink.cpp (renamed from services/audioflinger/LibsndfileSink.cpp)2
-rw-r--r--media/libnbaio/LibsndfileSource.cpp (renamed from services/audioflinger/LibsndfileSource.cpp)2
-rw-r--r--media/libnbaio/MonoPipe.cpp313
-rw-r--r--media/libnbaio/MonoPipeReader.cpp (renamed from services/audioflinger/MonoPipeReader.cpp)20
-rw-r--r--media/libnbaio/NBAIO.cpp (renamed from services/audioflinger/NBAIO.cpp)9
-rw-r--r--media/libnbaio/Pipe.cpp (renamed from services/audioflinger/Pipe.cpp)4
-rw-r--r--media/libnbaio/PipeReader.cpp (renamed from services/audioflinger/PipeReader.cpp)4
-rw-r--r--media/libnbaio/README.txt40
-rw-r--r--media/libnbaio/SourceAudioBufferProvider.cpp (renamed from services/audioflinger/SourceAudioBufferProvider.cpp)4
-rw-r--r--media/libnbaio/roundup.c (renamed from services/audioflinger/roundup.c)2
-rw-r--r--media/libstagefright/AACWriter.cpp17
-rw-r--r--media/libstagefright/ACodec.cpp274
-rw-r--r--media/libstagefright/AMRWriter.cpp11
-rw-r--r--media/libstagefright/Android.mk16
-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/MPEG2TSWriter.cpp2
-rw-r--r--media/libstagefright/MPEG4Extractor.cpp61
-rwxr-xr-xmedia/libstagefright/MPEG4Writer.cpp464
-rw-r--r--media/libstagefright/MediaCodec.cpp107
-rw-r--r--media/libstagefright/MediaCodecList.cpp2
-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.cpp229
-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.cpp11
-rw-r--r--media/libstagefright/chromium_http/chromium_http_stub.cpp (renamed from services/audioflinger/Soaker.h)34
-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/aacenc/inc/aac_rom.h2
-rw-r--r--media/libstagefright/codecs/aacenc/src/aac_rom.c2
-rw-r--r--media/libstagefright/codecs/aacenc/src/block_switch.c2
-rw-r--r--media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp2
-rw-r--r--media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s6
-rw-r--r--media/libstagefright/codecs/avc/enc/Android.mk2
-rw-r--r--media/libstagefright/codecs/avc/enc/SoftAVCEncoder.cpp125
-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.cpp119
-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/codecs/vorbis/dec/SoftVorbis.cpp2
-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.cpp98
-rw-r--r--media/libstagefright/httplive/M3UParser.cpp9
-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/LiveSession.h14
-rw-r--r--media/libstagefright/include/M3UParser.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.cpp204
-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/ARTPConnection.cpp3
-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.h7
-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.cpp1140
-rw-r--r--media/libstagefright/wifi-display/ANetworkSession.h130
-rw-r--r--media/libstagefright/wifi-display/Android.mk85
-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/TimeSeries.cpp67
-rw-r--r--media/libstagefright/wifi-display/TimeSeries.h46
-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.cpp657
-rw-r--r--media/libstagefright/wifi-display/source/Converter.h124
-rw-r--r--media/libstagefright/wifi-display/source/MediaPuller.cpp221
-rw-r--r--media/libstagefright/wifi-display/source/MediaPuller.h68
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.cpp1062
-rw-r--r--media/libstagefright/wifi-display/source/PlaybackSession.h151
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.cpp199
-rw-r--r--media/libstagefright/wifi-display/source/RepeaterSource.h64
-rw-r--r--media/libstagefright/wifi-display/source/Sender.cpp870
-rw-r--r--media/libstagefright/wifi-display/source/Sender.h169
-rw-r--r--media/libstagefright/wifi-display/source/TSPacketizer.cpp883
-rw-r--r--media/libstagefright/wifi-display/source/TSPacketizer.h85
-rw-r--r--media/libstagefright/wifi-display/source/WifiDisplaySource.cpp1596
-rw-r--r--media/libstagefright/wifi-display/source/WifiDisplaySource.h253
-rw-r--r--media/libstagefright/wifi-display/udptest.cpp355
-rw-r--r--media/libstagefright/wifi-display/wfd.cpp301
-rw-r--r--media/mediaserver/main_mediaserver.cpp1
-rw-r--r--media/mtp/Android.mk28
-rw-r--r--media/mtp/MtpDevice.cpp2
-rw-r--r--media/mtp/MtpServer.cpp2
-rw-r--r--services/audioflinger/Android.mk65
-rw-r--r--services/audioflinger/AudioFlinger.cpp1378
-rw-r--r--services/audioflinger/AudioFlinger.h474
-rw-r--r--services/audioflinger/AudioMixer.cpp27
-rw-r--r--services/audioflinger/AudioMixer.h6
-rw-r--r--services/audioflinger/AudioPolicyService.cpp83
-rw-r--r--services/audioflinger/AudioPolicyService.h11
-rw-r--r--services/audioflinger/AudioResampler.cpp135
-rw-r--r--services/audioflinger/AudioResampler.h27
-rw-r--r--services/audioflinger/AudioResamplerCubic.h2
-rw-r--r--services/audioflinger/AudioResamplerSinc.cpp722
-rw-r--r--services/audioflinger/AudioResamplerSinc.h48
-rw-r--r--services/audioflinger/FastMixer.cpp60
-rw-r--r--services/audioflinger/FastMixerState.h4
-rw-r--r--services/audioflinger/MonoPipe.cpp165
-rw-r--r--services/audioflinger/audio-resampler/Android.mk14
-rw-r--r--services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp54
-rw-r--r--services/audioflinger/audio-resampler/filter_coefficients.h285
-rw-r--r--services/audioflinger/test-resample.cpp274
-rw-r--r--services/camera/libcameraservice/Android.mk24
-rw-r--r--services/camera/libcameraservice/Camera2Client.cpp1636
-rw-r--r--services/camera/libcameraservice/Camera2Client.h228
-rw-r--r--services/camera/libcameraservice/Camera2Device.cpp1513
-rw-r--r--services/camera/libcameraservice/Camera2Device.h476
-rw-r--r--services/camera/libcameraservice/CameraClient.cpp959
-rw-r--r--services/camera/libcameraservice/CameraClient.h156
-rw-r--r--services/camera/libcameraservice/CameraHardwareInterface.h9
-rw-r--r--services/camera/libcameraservice/CameraHardwareStub.cpp410
-rw-r--r--services/camera/libcameraservice/CameraHardwareStub.h126
-rw-r--r--services/camera/libcameraservice/CameraService.cpp1104
-rw-r--r--services/camera/libcameraservice/CameraService.h219
-rw-r--r--services/camera/libcameraservice/CannedJpeg.h750
-rw-r--r--services/camera/libcameraservice/FakeCamera.cpp433
-rw-r--r--services/camera/libcameraservice/FakeCamera.h67
-rw-r--r--services/camera/libcameraservice/camera2/BurstCapture.cpp112
-rw-r--r--services/camera/libcameraservice/camera2/BurstCapture.h71
-rw-r--r--services/camera/libcameraservice/camera2/CallbackProcessor.cpp301
-rw-r--r--services/camera/libcameraservice/camera2/CallbackProcessor.h82
-rw-r--r--services/camera/libcameraservice/camera2/Camera2Heap.h55
-rw-r--r--services/camera/libcameraservice/camera2/CameraMetadata.cpp296
-rw-r--r--services/camera/libcameraservice/camera2/CameraMetadata.h173
-rw-r--r--services/camera/libcameraservice/camera2/CaptureSequencer.cpp673
-rw-r--r--services/camera/libcameraservice/camera2/CaptureSequencer.h177
-rw-r--r--services/camera/libcameraservice/camera2/FrameProcessor.cpp308
-rw-r--r--services/camera/libcameraservice/camera2/FrameProcessor.h89
-rw-r--r--services/camera/libcameraservice/camera2/JpegCompressor.cpp220
-rw-r--r--services/camera/libcameraservice/camera2/JpegCompressor.h107
-rw-r--r--services/camera/libcameraservice/camera2/JpegProcessor.cpp380
-rw-r--r--services/camera/libcameraservice/camera2/JpegProcessor.h83
-rw-r--r--services/camera/libcameraservice/camera2/Parameters.cpp2431
-rw-r--r--services/camera/libcameraservice/camera2/Parameters.h365
-rw-r--r--services/camera/libcameraservice/camera2/StreamingProcessor.cpp657
-rw-r--r--services/camera/libcameraservice/camera2/StreamingProcessor.h118
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.cpp538
-rw-r--r--services/camera/libcameraservice/camera2/ZslProcessor.h126
-rw-r--r--tools/resampler_tools/Android.mk17
-rw-r--r--tools/resampler_tools/fir.cpp281
715 files changed, 36915 insertions, 94507 deletions
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index 059a8a5f..fd91bf2b 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -146,6 +146,7 @@ const char CameraParameters::SCENE_MODE_SPORTS[] = "sports";
const char CameraParameters::SCENE_MODE_PARTY[] = "party";
const char CameraParameters::SCENE_MODE_CANDLELIGHT[] = "candlelight";
const char CameraParameters::SCENE_MODE_BARCODE[] = "barcode";
+const char CameraParameters::SCENE_MODE_HDR[] = "hdr";
const char CameraParameters::PIXEL_FORMAT_YUV422SP[] = "yuv422sp";
const char CameraParameters::PIXEL_FORMAT_YUV420SP[] = "yuv420sp";
@@ -155,6 +156,7 @@ const char CameraParameters::PIXEL_FORMAT_RGB565[] = "rgb565";
const char CameraParameters::PIXEL_FORMAT_RGBA8888[] = "rgba8888";
const char CameraParameters::PIXEL_FORMAT_JPEG[] = "jpeg";
const char CameraParameters::PIXEL_FORMAT_BAYER_RGGB[] = "bayer-rggb";
+const char CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE[] = "android-opaque";
// Values for focus mode settings.
const char CameraParameters::FOCUS_MODE_AUTO[] = "auto";
diff --git a/cmds/stagefright/Android.mk b/cmds/stagefright/Android.mk
index 8687fabe..1247588d 100644
--- a/cmds/stagefright/Android.mk
+++ b/cmds/stagefright/Android.mk
@@ -104,7 +104,7 @@ LOCAL_SRC_FILES:= \
LOCAL_SHARED_LIBRARIES := \
libstagefright liblog libutils libbinder libgui \
- libstagefright_foundation libmedia libmedia_native
+ libstagefright_foundation libmedia libmedia_native libcutils
LOCAL_C_INCLUDES:= \
frameworks/av/media/libstagefright \
diff --git a/cmds/stagefright/codec.cpp b/cmds/stagefright/codec.cpp
index f3370a54..723a6e5e 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -34,7 +34,9 @@
#include <media/stagefright/MediaCodecList.h>
#include <media/stagefright/MediaDefs.h>
#include <media/stagefright/NuMediaExtractor.h>
+#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
+#include <ui/DisplayInfo.h>
static void usage(const char *me) {
fprintf(stderr, "usage: %s [-a] use audio\n"
@@ -378,14 +380,17 @@ int main(int argc, char **argv) {
composerClient = new SurfaceComposerClient;
CHECK_EQ(composerClient->initCheck(), (status_t)OK);
- ssize_t displayWidth = composerClient->getDisplayWidth(0);
- ssize_t displayHeight = composerClient->getDisplayHeight(0);
+ sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(
+ ISurfaceComposer::eDisplayIdMain));
+ DisplayInfo info;
+ SurfaceComposerClient::getDisplayInfo(display, &info);
+ ssize_t displayWidth = info.w;
+ ssize_t displayHeight = info.h;
ALOGV("display is %ld x %ld\n", displayWidth, displayHeight);
control = composerClient->createSurface(
String8("A Surface"),
- 0,
displayWidth,
displayHeight,
PIXEL_FORMAT_RGB_565,
diff --git a/cmds/stagefright/recordvideo.cpp b/cmds/stagefright/recordvideo.cpp
index 3bd1fe22..e02f1112 100644
--- a/cmds/stagefright/recordvideo.cpp
+++ b/cmds/stagefright/recordvideo.cpp
@@ -43,6 +43,7 @@ static void usage(const char *me) {
fprintf(stderr, " -l encoder level. see omx il header (default: encoder specific)\n");
fprintf(stderr, " -p encoder profile. see omx il header (default: encoder specific)\n");
fprintf(stderr, " -v video codec: [0] AVC [1] M4V [2] H263 (default: 0)\n");
+ fprintf(stderr, " -s(oftware) prefer software codec\n");
fprintf(stderr, "The output file is /sdcard/output.mp4\n");
exit(1);
}
@@ -162,10 +163,11 @@ int main(int argc, char **argv) {
int profile = -1; // Encoder specific default
int codec = 0;
const char *fileName = "/sdcard/output.mp4";
+ bool preferSoftwareCodec = false;
android::ProcessState::self()->startThreadPool();
int res;
- while ((res = getopt(argc, argv, "b:c:f:i:n:w:t:l:p:v:h")) >= 0) {
+ while ((res = getopt(argc, argv, "b:c:f:i:n:w:t:l:p:v:hs")) >= 0) {
switch (res) {
case 'b':
{
@@ -233,6 +235,12 @@ int main(int argc, char **argv) {
break;
}
+ case 's':
+ {
+ preferSoftwareCodec = true;
+ break;
+ }
+
case 'h':
default:
{
@@ -278,13 +286,15 @@ int main(int argc, char **argv) {
sp<MediaSource> encoder =
OMXCodec::Create(
- client.interface(), enc_meta, true /* createEncoder */, source);
+ client.interface(), enc_meta, true /* createEncoder */, source,
+ 0, preferSoftwareCodec ? OMXCodec::kPreferSoftwareCodecs : 0);
sp<MPEG4Writer> writer = new MPEG4Writer(fileName);
writer->addSource(encoder);
int64_t start = systemTime();
CHECK_EQ((status_t)OK, writer->start());
while (!writer->reachedEOS()) {
+ usleep(100000);
}
err = writer->stop();
int64_t end = systemTime();
diff --git a/cmds/stagefright/sf2.cpp b/cmds/stagefright/sf2.cpp
index 3bbfbdca..c817443c 100644
--- a/cmds/stagefright/sf2.cpp
+++ b/cmds/stagefright/sf2.cpp
@@ -612,7 +612,6 @@ int main(int argc, char **argv) {
control = composerClient->createSurface(
String8("A Surface"),
- 0,
1280,
800,
PIXEL_FORMAT_RGB_565,
diff --git a/cmds/stagefright/stagefright.cpp b/cmds/stagefright/stagefright.cpp
index 0362f399..b92a8a0d 100644
--- a/cmds/stagefright/stagefright.cpp
+++ b/cmds/stagefright/stagefright.cpp
@@ -922,7 +922,6 @@ int main(int argc, char **argv) {
control = composerClient->createSurface(
String8("A Surface"),
- 0,
1280,
800,
PIXEL_FORMAT_RGB_565,
diff --git a/cmds/stagefright/stream.cpp b/cmds/stagefright/stream.cpp
index efa14455..7329dcc0 100644
--- a/cmds/stagefright/stream.cpp
+++ b/cmds/stagefright/stream.cpp
@@ -19,6 +19,7 @@
#include "utils/Log.h"
#include <binder/ProcessState.h>
+#include <cutils/properties.h> // for property_get
#include <media/IStreamSource.h>
#include <media/mediaplayer.h>
@@ -32,9 +33,11 @@
#include <binder/IServiceManager.h>
#include <media/IMediaPlayerService.h>
+#include <gui/ISurfaceComposer.h>
#include <gui/SurfaceComposerClient.h>
#include <fcntl.h>
+#include <ui/DisplayInfo.h>
using namespace android;
@@ -304,15 +307,18 @@ int main(int argc, char **argv) {
sp<SurfaceComposerClient> composerClient = new SurfaceComposerClient;
CHECK_EQ(composerClient->initCheck(), (status_t)OK);
- ssize_t displayWidth = composerClient->getDisplayWidth(0);
- ssize_t displayHeight = composerClient->getDisplayHeight(0);
+ sp<IBinder> display(SurfaceComposerClient::getBuiltInDisplay(
+ ISurfaceComposer::eDisplayIdMain));
+ DisplayInfo info;
+ SurfaceComposerClient::getDisplayInfo(display, &info);
+ ssize_t displayWidth = info.w;
+ ssize_t displayHeight = info.h;
ALOGV("display is %d x %d\n", displayWidth, displayHeight);
sp<SurfaceControl> control =
composerClient->createSurface(
String8("A Surface"),
- 0,
displayWidth,
displayHeight,
PIXEL_FORMAT_RGB_565,
@@ -339,8 +345,16 @@ int main(int argc, char **argv) {
sp<IStreamSource> source;
+ char prop[PROPERTY_VALUE_MAX];
+ bool usemp4 = property_get("media.stagefright.use-mp4source", prop, NULL) &&
+ (!strcmp(prop, "1") || !strcasecmp(prop, "true"));
+
size_t len = strlen(argv[1]);
- if (len >= 3 && !strcasecmp(".ts", &argv[1][len - 3])) {
+ if ((!usemp4 && len >= 3 && !strcasecmp(".ts", &argv[1][len - 3])) ||
+ (usemp4 && len >= 4 &&
+ (!strcasecmp(".mp4", &argv[1][len - 4])
+ || !strcasecmp(".3gp", &argv[1][len- 4])
+ || !strcasecmp(".3g2", &argv[1][len- 4])))) {
int fd = open(argv[1], O_RDONLY);
if (fd < 0) {
diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp
index a060f387..f734905b 100644
--- a/drm/common/DrmEngineBase.cpp
+++ b/drm/common/DrmEngineBase.cpp
@@ -66,8 +66,8 @@ DrmInfo* DrmEngineBase::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmIn
return onAcquireDrmInfo(uniqueId, drmInfoRequest);
}
-String8 DrmEngineBase::getOriginalMimeType(int uniqueId, const String8& path) {
- return onGetOriginalMimeType(uniqueId, path);
+String8 DrmEngineBase::getOriginalMimeType(int uniqueId, const String8& path, int fd) {
+ return onGetOriginalMimeType(uniqueId, path, fd);
}
int DrmEngineBase::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) {
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp
index ccff2573..0282036f 100644
--- a/drm/common/IDrmManagerService.cpp
+++ b/drm/common/IDrmManagerService.cpp
@@ -310,7 +310,13 @@ DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest*
const String8 key = keyIt.next();
data.writeString8(key);
const String8 value = drmInforequest->get(key);
- data.writeString8((value == String8("")) ? String8("NULL") : value);
+ if (key == String8("FileDescriptorKey")) {
+ int fd = -1;
+ sscanf(value.string(), "FileDescriptor[%d]", &fd);
+ data.writeFileDescriptor(fd);
+ } else {
+ data.writeString8((value == String8("")) ? String8("NULL") : value);
+ }
}
remote()->transact(ACQUIRE_DRM_INFO, data, &reply);
@@ -368,13 +374,18 @@ status_t BpDrmManagerService::saveRights(
return reply.readInt32();
}
-String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
+String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path, int fd) {
ALOGV("Get Original MimeType");
Parcel data, reply;
data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor());
data.writeInt32(uniqueId);
data.writeString8(path);
+ int32_t isFdValid = (fd >= 0);
+ data.writeInt32(isFdValid);
+ if (isFdValid) {
+ data.writeFileDescriptor(fd);
+ }
remote()->transact(GET_ORIGINAL_MIMETYPE, data, &reply);
return reply.readString8();
@@ -997,8 +1008,15 @@ status_t BnDrmManagerService::onTransact(
const int size = data.readInt32();
for (int index = 0; index < size; ++index) {
const String8 key(data.readString8());
- const String8 value(data.readString8());
- drmInfoRequest->put(key, (value == String8("NULL")) ? String8("") : value);
+ if (key == String8("FileDescriptorKey")) {
+ char buffer[16];
+ int fd = data.readFileDescriptor();
+ sprintf(buffer, "%lu", (unsigned long)fd);
+ drmInfoRequest->put(key, String8(buffer));
+ } else {
+ const String8 value(data.readString8());
+ drmInfoRequest->put(key, (value == String8("NULL")) ? String8("") : value);
+ }
}
DrmInfo* drmInfo = acquireDrmInfo(uniqueId, drmInfoRequest);
@@ -1067,7 +1085,12 @@ status_t BnDrmManagerService::onTransact(
const int uniqueId = data.readInt32();
const String8 path = data.readString8();
- const String8 originalMimeType = getOriginalMimeType(uniqueId, path);
+ const int32_t isFdValid = data.readInt32();
+ int fd = -1;
+ if (isFdValid) {
+ fd = data.readFileDescriptor();
+ }
+ const String8 originalMimeType = getOriginalMimeType(uniqueId, path, fd);
reply->writeString8(originalMimeType);
return DRM_NO_ERROR;
@@ -1495,4 +1518,3 @@ status_t BnDrmManagerService::onTransact(
return BBinder::onTransact(code, data, reply, flags);
}
}
-
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 737edabe..e7b0e90e 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -266,12 +266,12 @@ status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights,
return result;
}
-String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) {
+String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path, int fd) {
Mutex::Autolock _l(mLock);
const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path);
if (EMPTY_STRING != plugInId) {
IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
- return rDrmEngine.getOriginalMimeType(uniqueId, path);
+ return rDrmEngine.getOriginalMimeType(uniqueId, path, fd);
}
return EMPTY_STRING;
}
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index 25a4e7b4..bbd3b7fd 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -125,9 +125,9 @@ status_t DrmManagerService::saveRights(
return mDrmManager->saveRights(uniqueId, drmRights, rightsPath, contentPath);
}
-String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) {
+String8 DrmManagerService::getOriginalMimeType(int uniqueId, const String8& path, int fd) {
ALOGV("Entering getOriginalMimeType");
- return mDrmManager->getOriginalMimeType(uniqueId, path);
+ return mDrmManager->getOriginalMimeType(uniqueId, path, fd);
}
int DrmManagerService::getDrmObjectType(
diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp
index d4db461a..ea30d010 100644
--- a/drm/libdrmframework/DrmManagerClient.cpp
+++ b/drm/libdrmframework/DrmManagerClient.cpp
@@ -64,8 +64,8 @@ status_t DrmManagerClient::saveRights(
return mDrmManagerClientImpl->saveRights(mUniqueId, drmRights, rightsPath, contentPath);
}
-String8 DrmManagerClient::getOriginalMimeType(const String8& path) {
- return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path);
+String8 DrmManagerClient::getOriginalMimeType(const String8& path, int fd) {
+ return mDrmManagerClientImpl->getOriginalMimeType(mUniqueId, path, fd);
}
int DrmManagerClient::getDrmObjectType(const String8& path, const String8& mimeType) {
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp
index b1228d4f..a9700350 100644
--- a/drm/libdrmframework/DrmManagerClientImpl.cpp
+++ b/drm/libdrmframework/DrmManagerClientImpl.cpp
@@ -147,10 +147,10 @@ status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRigh
}
String8 DrmManagerClientImpl::getOriginalMimeType(
- int uniqueId, const String8& path) {
+ int uniqueId, const String8& path, int fd) {
String8 mimeType = EMPTY_STRING;
if (EMPTY_STRING != path) {
- mimeType = getDrmManagerService()->getOriginalMimeType(uniqueId, path);
+ mimeType = getDrmManagerService()->getOriginalMimeType(uniqueId, path, fd);
}
return mimeType;
}
diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h
index 3942efe1..491e8f70 100644
--- a/drm/libdrmframework/include/DrmManager.h
+++ b/drm/libdrmframework/include/DrmManager.h
@@ -85,7 +85,7 @@ public:
status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
- String8 getOriginalMimeType(int uniqueId, const String8& path);
+ String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h
index f3d93157..9b4c9ae3 100644
--- a/drm/libdrmframework/include/DrmManagerClientImpl.h
+++ b/drm/libdrmframework/include/DrmManagerClientImpl.h
@@ -148,10 +148,11 @@ public:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] path the path of the protected content
+ * @param[in] fd the file descriptor of the protected content
* @return String8
* Returns mime-type of the original content, such as "video/mpeg"
*/
- String8 getOriginalMimeType(int uniqueId, const String8& path);
+ String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
/**
* Retrieves the type of the protected object (content, rights, etc..)
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index 066fe4a6..0dfdca63 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -72,7 +72,7 @@ public:
status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
- String8 getOriginalMimeType(int uniqueId, const String8& path);
+ String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h
index 5b89c91a..5a4d70a1 100644
--- a/drm/libdrmframework/include/IDrmManagerService.h
+++ b/drm/libdrmframework/include/IDrmManagerService.h
@@ -109,7 +109,7 @@ public:
virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath) = 0;
- virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
+ virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd) = 0;
virtual int getDrmObjectType(
int uniqueId, const String8& path, const String8& mimeType) = 0;
@@ -200,7 +200,7 @@ public:
virtual status_t saveRights(int uniqueId, const DrmRights& drmRights,
const String8& rightsPath, const String8& contentPath);
- virtual String8 getOriginalMimeType(int uniqueId, const String8& path);
+ virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
virtual int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
index 6cebb97b..fa51c13c 100644
--- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
+++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h
@@ -53,7 +53,7 @@ public:
DrmInfo* acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
- String8 getOriginalMimeType(int uniqueId, const String8& path);
+ String8 getOriginalMimeType(int uniqueId, const String8& path, int fd);
int getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
@@ -222,10 +222,11 @@ protected:
*
* @param[in] uniqueId Unique identifier for a session
* @param[in] path Path of the protected content
+ * @param[in] fd descriptor of the protected content as a file source
* @return String8
* Returns mime-type of the original content, such as "video/mpeg"
*/
- virtual String8 onGetOriginalMimeType(int uniqueId, const String8& path) = 0;
+ virtual String8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd) = 0;
/**
* Retrieves the type of the protected object (content, rights, etc..)
diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
index 60f4c1b6..acc8ed94 100644
--- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h
+++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h
@@ -165,11 +165,12 @@ public:
* Retrieves the mime type embedded inside the original content
*
* @param[in] uniqueId Unique identifier for a session
- * @param[in] path Path of the protected content
+ * @param[in] path Path of the content or null.
+ * @param[in] fd File descriptor of the protected content
* @return String8
* Returns mime-type of the original content, such as "video/mpeg"
*/
- virtual String8 getOriginalMimeType(int uniqueId, const String8& path) = 0;
+ virtual String8 getOriginalMimeType(int uniqueId, const String8& path, int fd) = 0;
/**
* Retrieves the type of the protected object (content, rights, etc..)
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
index c0e408e3..a31b951e 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/include/FwdLockEngine.h
@@ -150,11 +150,12 @@ DrmInfo* onAcquireDrmInfo(int uniqueId,
* Retrieves the mime type embedded inside the original content.
*
* @param uniqueId Unique identifier for a session
- * @param path Path of the protected content
+ * @param path Path of the conent or null.
+ * @param fd descriptor of the protected content as a file source
* @return String8
* Returns mime-type of the original content, such as "video/mpeg"
*/
-String8 onGetOriginalMimeType(int uniqueId, const String8& path);
+String8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd);
/**
* Retrieves the type of the protected object (content, rights, etc..)
diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
index 4b1b40eb..234aef28 100644
--- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
+++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp
@@ -309,12 +309,15 @@ bool FwdLockEngine::onValidateAction(int uniqueId,
return (onCheckRightsStatus(uniqueId, path, action) == RightsStatus::RIGHTS_VALID);
}
-String8 FwdLockEngine::onGetOriginalMimeType(int uniqueId, const String8& path) {
+String8 FwdLockEngine::onGetOriginalMimeType(int uniqueId, const String8& path, int fd) {
LOG_VERBOSE("FwdLockEngine::onGetOriginalMimeType");
String8 mimeString = String8("");
- int fileDesc = FwdLockFile_open(path.string());
+ int fileDesc = dup(fd);
if (-1 < fileDesc) {
+ if (FwdLockFile_attach(fileDesc) < 0) {
+ return mimeString;
+ }
const char* pMimeType = FwdLockFile_GetContentType(fileDesc);
if (NULL != pMimeType) {
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c
index 299116de..bb97abcd 100644
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c
@@ -1314,34 +1314,3 @@ FwdLockConv_Status_t FwdLockConv_ConvertOpenFile(int inputFileDesc,
}
return status;
}
-
-FwdLockConv_Status_t FwdLockConv_ConvertFile(const char *pInputFilename,
- const char *pOutputFilename,
- off64_t *pErrorPos) {
- FwdLockConv_Status_t status;
- if (pErrorPos != NULL) {
- *pErrorPos = INVALID_OFFSET;
- }
- if (pInputFilename == NULL || pOutputFilename == NULL) {
- status = FwdLockConv_Status_InvalidArgument;
- } else {
- int inputFileDesc = open(pInputFilename, O_RDONLY);
- if (inputFileDesc < 0) {
- status = FwdLockConv_Status_FileNotFound;
- } else {
- int outputFileDesc = open(pOutputFilename, O_CREAT | O_TRUNC | O_WRONLY,
- S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
- if (outputFileDesc < 0) {
- status = FwdLockConv_Status_FileCreationFailed;
- } else {
- status = FwdLockConv_ConvertOpenFile(inputFileDesc, read, outputFileDesc, write,
- lseek64, pErrorPos);
- if (close(outputFileDesc) == 0 && status != FwdLockConv_Status_OK) {
- remove(pOutputFilename);
- }
- }
- (void)close(inputFileDesc);
- }
- }
- return status;
-}
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.h b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.h
index e20c0c38..6449d89f 100644
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.h
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.h
@@ -245,36 +245,6 @@ FwdLockConv_Status_t FwdLockConv_ConvertOpenFile(int inputFileDesc,
FwdLockConv_LSeekFunc_t *fpLSeekFunc,
off64_t *pErrorPos);
-/**
- * Converts an OMA DRM v1 Forward Lock file to the internal Forward Lock file format in pull mode.
- *
- * @param[in] pInputFilename A reference to the input filename.
- * @param[in] pOutputFilename A reference to the output filename.
- * @param[out] pErrorPos
- * The file position where the error occurred, in the case of a syntax error. May be NULL.
- *
- * @return A status code.
- * @retval FwdLockConv_Status_OK
- * @retval FwdLockConv_Status_InvalidArgument
- * @retval FwdLockConv_Status_OutOfMemory
- * @retval FwdLockConv_Status_FileNotFound
- * @retval FwdLockConv_Status_FileCreationFailed
- * @retval FwdLockConv_Status_FileReadError
- * @retval FwdLockConv_Status_FileWriteError
- * @retval FwdLockConv_Status_FileSeekError
- * @retval FwdLockConv_Status_SyntaxError
- * @retval FwdLockConv_Status_UnsupportedFileFormat
- * @retval FwdLockConv_Status_UnsupportedContentTransferEncoding
- * @retval FwdLockConv_Status_RandomNumberGenerationFailed
- * @retval FwdLockConv_Status_KeyEncryptionFailed
- * @retval FwdLockConv_Status_DataEncryptionFailed
- * @retval FwdLockConv_Status_IntegrityProtectionFailed
- * @retval FwdLockConv_Status_TooManySessions
- */
-FwdLockConv_Status_t FwdLockConv_ConvertFile(const char *pInputFilename,
- const char *pOutputFilename,
- off64_t *pErrorPos);
-
#ifdef __cplusplus
}
#endif
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c
index 365bdece..7ff3c003 100644
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.c
@@ -293,20 +293,6 @@ int FwdLockFile_attach(int fileDesc) {
return (sessionId >= 0) ? 0 : -1;
}
-int FwdLockFile_open(const char *pFilename) {
- int fileDesc = open(pFilename, O_RDONLY);
- if (fileDesc < 0) {
- ALOGE("failed to open file '%s': %s", pFilename, strerror(errno));
- return fileDesc;
- }
-
- if (FwdLockFile_attach(fileDesc) < 0) {
- (void)close(fileDesc);
- fileDesc = -1;
- }
- return fileDesc;
-}
-
ssize_t FwdLockFile_read(int fileDesc, void *pBuffer, size_t numBytes) {
ssize_t numBytesRead;
int sessionId = FwdLockFile_FindSession(fileDesc);
diff --git a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.h b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.h
index fc64050e..187505bf 100644
--- a/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.h
+++ b/drm/libdrmframework/plugins/forward-lock/internal-format/decoder/FwdLockFile.h
@@ -36,16 +36,6 @@ extern "C" {
int FwdLockFile_attach(int fileDesc);
/**
- * Opens a Forward Lock file for reading.
- *
- * @param[in] pFilename A reference to a filename.
- *
- * @return A file descriptor.
- * @retval -1 Failure.
- */
-int FwdLockFile_open(const char *pFilename);
-
-/**
* Reads the specified number of bytes from an open Forward Lock file.
*
* @param[in] fileDesc The file descriptor of an open Forward Lock file.
diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
index f941f700..7b66dc7d 100644
--- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
+++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h
@@ -47,7 +47,7 @@ protected:
DrmInfo* onAcquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest);
- String8 onGetOriginalMimeType(int uniqueId, const String8& path);
+ String8 onGetOriginalMimeType(int uniqueId, const String8& path, int fd);
int onGetDrmObjectType(int uniqueId, const String8& path, const String8& mimeType);
diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
index a3eac3e0..fa659fde 100644
--- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
+++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp
@@ -163,7 +163,7 @@ bool DrmPassthruPlugIn::onCanHandle(int uniqueId, const String8& path) {
return (String8(".passthru") == extension);
}
-String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId, const String8& path) {
+String8 DrmPassthruPlugIn::onGetOriginalMimeType(int uniqueId, const String8& path, int fd) {
ALOGV("DrmPassthruPlugIn::onGetOriginalMimeType() : %d", uniqueId);
return String8("video/passthru");
}
diff --git a/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 36248a0f..5540d328 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -298,7 +298,7 @@ public:
// Example value: "42.5". Read only.
static const char KEY_VERTICAL_VIEW_ANGLE[];
// Exposure compensation index. 0 means exposure is not adjusted.
- // Example value: "0" or "5". Read/write.
+ // Example value: "-5" or "5". Read/write.
static const char KEY_EXPOSURE_COMPENSATION[];
// The maximum exposure compensation index (>=0).
// Example value: "6". Read only.
@@ -307,7 +307,7 @@ public:
// Example value: "-6". Read only.
static const char KEY_MIN_EXPOSURE_COMPENSATION[];
// The exposure compensation step. Exposure compensation index multiply by
- // step eqals to EV. Ex: if exposure compensation index is 6 and step is
+ // step eqals to EV. Ex: if exposure compensation index is -6 and step is
// 0.3333, EV is -2.
// Example value: "0.333333333" or "0.5". Read only.
static const char KEY_EXPOSURE_COMPENSATION_STEP[];
@@ -593,6 +593,10 @@ public:
// Applications are looking for a barcode. Camera driver will be optimized
// for barcode reading.
static const char SCENE_MODE_BARCODE[];
+ // A high-dynamic range mode. In this mode, the HAL module will use a
+ // capture strategy that extends the dynamic range of the captured
+ // image in some fashion. Only the final image is returned.
+ static const char SCENE_MODE_HDR[];
// Pixel color formats for KEY_PREVIEW_FORMAT, KEY_PICTURE_FORMAT,
// and KEY_VIDEO_FRAME_FORMAT
@@ -606,6 +610,8 @@ public:
// Raw bayer format used for images, which is 10 bit precision samples
// stored in 16 bit words. The filter pattern is RGGB.
static const char PIXEL_FORMAT_BAYER_RGGB[];
+ // Pixel format is not known to the framework
+ static const char PIXEL_FORMAT_ANDROID_OPAQUE[];
// Values for focus mode settings.
// Auto-focus mode. Applications should call
diff --git a/include/drm/DrmManagerClient.h b/include/drm/DrmManagerClient.h
index a5c69925..866edac5 100644
--- a/include/drm/DrmManagerClient.h
+++ b/include/drm/DrmManagerClient.h
@@ -279,10 +279,11 @@ public:
* Retrieves the mime type embedded inside the original content
*
* @param[in] path the path of the protected content
+ * @param[in] fd the file descriptor of the protected content
* @return String8
* Returns mime-type of the original content, such as "video/mpeg"
*/
- String8 getOriginalMimeType(const String8& path);
+ String8 getOriginalMimeType(const String8& path, int fd);
/**
* Retrieves the type of the protected object (content, rights, etc..)
diff --git a/services/audioflinger/AudioBufferProvider.h b/include/media/AudioBufferProvider.h
index 43e4de75..865ed7e2 100644
--- a/services/audioflinger/AudioBufferProvider.h
+++ b/include/media/AudioBufferProvider.h
@@ -36,8 +36,11 @@ public:
size_t frameCount;
};
- virtual ~AudioBufferProvider() {}
+protected:
+ AudioBufferProvider() : mValid(kValid) { }
+ virtual ~AudioBufferProvider() { mValid = kDead; }
+public:
// value representing an invalid presentation timestamp
static const int64_t kInvalidPTS = 0x7FFFFFFFFFFFFFFFLL; // <stdint.h> is too painful
@@ -47,6 +50,13 @@ public:
virtual status_t getNextBuffer(Buffer* buffer, int64_t pts = kInvalidPTS) = 0;
virtual void releaseBuffer(Buffer* buffer) = 0;
+
+ int getValid() const { return mValid; }
+ static const int kValid = 'GOOD';
+ static const int kDead = 'DEAD';
+
+private:
+ int mValid;
};
// ----------------------------------------------------------------------------
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index ef77692b..156c5924 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -17,22 +17,15 @@
#ifndef AUDIORECORD_H_
#define AUDIORECORD_H_
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <media/IAudioFlinger.h>
+#include <binder/IMemory.h>
+#include <cutils/sched_policy.h>
+#include <media/AudioSystem.h>
#include <media/IAudioRecord.h>
-
+#include <system/audio.h>
#include <utils/RefBase.h>
#include <utils/Errors.h>
-#include <binder/IInterface.h>
-#include <binder/IMemory.h>
-#include <cutils/sched_policy.h>
#include <utils/threads.h>
-#include <system/audio.h>
-#include <media/AudioSystem.h>
-
namespace android {
class audio_track_cblk_t;
@@ -46,11 +39,10 @@ public:
static const int DEFAULT_SAMPLE_RATE = 8000;
/* Events used by AudioRecord callback function (callback_t).
- *
- * to keep in sync with frameworks/base/media/java/android/media/AudioRecord.java
+ * Keep in sync with frameworks/base/media/java/android/media/AudioRecord.java NATIVE_EVENT_*.
*/
enum event_type {
- EVENT_MORE_DATA = 0, // Request to reqd more data from PCM buffer.
+ EVENT_MORE_DATA = 0, // Request to read more data from PCM buffer.
EVENT_OVERRUN = 1, // PCM buffer overrun occured.
EVENT_MARKER = 2, // Record head is at the specified marker position
// (See setMarkerPosition()).
@@ -72,7 +64,7 @@ public:
int channelCount;
audio_format_t format;
size_t frameCount;
- size_t size;
+ size_t size; // total size in bytes == frameCount * frameSize
union {
void* raw;
short* i16;
@@ -80,12 +72,6 @@ public:
};
};
- /* These are static methods to control the system-wide AudioFlinger
- * only privileged processes can have access to them
- */
-
-// static status_t setMasterMute(bool mute);
-
/* As a convenience, if a callback is supplied, a handler thread
* is automatically created with the appropriate priority. This thread
* invokes the callback when a new buffer becomes ready or an overrun condition occurs.
@@ -98,8 +84,8 @@ public:
* more bytes than indicated by 'size' field and update 'size' if less bytes are
* read.
* - EVENT_OVERRUN: unused.
- * - EVENT_MARKER: pointer to an uin32_t containing the marker position in frames.
- * - EVENT_NEW_POS: pointer to an uin32_t containing the new position in frames.
+ * - EVENT_MARKER: pointer to const uint32_t containing the marker position in frames.
+ * - EVENT_NEW_POS: pointer to const uint32_t containing the new position in frames.
*/
typedef void (*callback_t)(int event, void* user, void *info);
@@ -115,7 +101,7 @@ public:
static status_t getMinFrameCount(int* frameCount,
uint32_t sampleRate,
audio_format_t format,
- int channelCount);
+ audio_channel_mask_t channelMask);
/* Constructs an uninitialized AudioRecord. No connection with
* AudioFlinger takes place.
@@ -133,32 +119,22 @@ public:
* sampleRate: Track sampling rate in Hz.
* format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
* 16 bits per sample).
- * channelMask: Channel mask: see audio_channels_t.
+ * channelMask: Channel mask.
* frameCount: Total size of track PCM buffer in frames. This defines the
* latency of the track.
- * flags: A bitmask of acoustic values from enum record_flags. It enables
- * AGC, NS, and IIR.
* cbf: Callback function. If not null, this function is called periodically
* to provide new PCM data.
+ * user: Context for use by the callback receiver.
* notificationFrames: The callback function is called each time notificationFrames PCM
* frames are ready in record track output buffer.
- * user Context for use by the callback receiver.
+ * sessionId: Not yet supported.
*/
- // FIXME consider removing this alias and replacing it by audio_in_acoustics_t
- // or removing the parameter entirely if it is unused
- enum record_flags {
- RECORD_AGC_ENABLE = AUDIO_IN_ACOUSTICS_AGC_ENABLE,
- RECORD_NS_ENABLE = AUDIO_IN_ACOUSTICS_NS_ENABLE,
- RECORD_IIR_ENABLE = AUDIO_IN_ACOUSTICS_TX_IIR_ENABLE,
- };
-
AudioRecord(audio_source_t inputSource,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channelMask = AUDIO_CHANNEL_IN_MONO,
+ audio_channel_mask_t channelMask = AUDIO_CHANNEL_IN_MONO,
int frameCount = 0,
- record_flags flags = (record_flags) 0,
callback_t cbf = NULL,
void* user = NULL,
int notificationFrames = 0,
@@ -166,7 +142,7 @@ public:
/* Terminates the AudioRecord and unregisters it from AudioFlinger.
- * Also destroys all resources assotiated with the AudioRecord.
+ * Also destroys all resources associated with the AudioRecord.
*/
~AudioRecord();
@@ -182,9 +158,8 @@ public:
status_t set(audio_source_t inputSource = AUDIO_SOURCE_DEFAULT,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channelMask = AUDIO_CHANNEL_IN_MONO,
+ audio_channel_mask_t channelMask = AUDIO_CHANNEL_IN_MONO,
int frameCount = 0,
- record_flags flags = (record_flags) 0,
callback_t cbf = NULL,
void* user = NULL,
int notificationFrames = 0,
@@ -205,11 +180,10 @@ public:
*/
uint32_t latency() const;
- /* getters, see constructor */
+ /* getters, see constructor and set() */
audio_format_t format() const;
int channelCount() const;
- int channels() const;
uint32_t frameCount() const;
size_t frameSize() const;
audio_source_t inputSource() const;
@@ -227,7 +201,7 @@ public:
* obtainBuffer returns STOPPED. Note that obtainBuffer() still works
* and will fill up buffers until the pool is exhausted.
*/
- status_t stop();
+ void stop();
bool stopped() const;
/* get sample rate for this record track
@@ -271,7 +245,7 @@ public:
status_t getPositionUpdatePeriod(uint32_t *updatePeriod) const;
- /* Gets record head position. The position is the total number of frames
+ /* Gets record head position. The position is the total number of frames
* recorded since record start.
*
* Parameters:
@@ -294,7 +268,7 @@ public:
*/
audio_io_handle_t getInput() const;
- /* returns the audio session ID associated to this AudioRecord.
+ /* returns the audio session ID associated with this AudioRecord.
*
* Parameters:
* none.
@@ -342,57 +316,72 @@ private:
AudioRecord& operator = (const AudioRecord& other);
/* a small internal class to handle the callback */
- class ClientRecordThread : public Thread
+ class AudioRecordThread : public Thread
{
public:
- ClientRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
+ AudioRecordThread(AudioRecord& receiver, bool bCanCallJava = false);
+
+ // Do not call Thread::requestExitAndWait() without first calling requestExit().
+ // Thread::requestExitAndWait() is not virtual, and the implementation doesn't do enough.
+ virtual void requestExit();
+
+ void pause(); // suspend thread from execution at next loop boundary
+ void resume(); // allow thread to execute, if not requested to exit
+
private:
friend class AudioRecord;
virtual bool threadLoop();
- virtual status_t readyToRun();
- virtual void onFirstRef() {}
AudioRecord& mReceiver;
+ virtual ~AudioRecordThread();
+ Mutex mMyLock; // Thread::mLock is private
+ Condition mMyCond; // Thread::mThreadExitedCondition is private
+ bool mPaused; // whether thread is currently paused
};
- bool processAudioBuffer(const sp<ClientRecordThread>& thread);
+ // body of AudioRecordThread::threadLoop()
+ bool processAudioBuffer(const sp<AudioRecordThread>& thread);
+
status_t openRecord_l(uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
audio_io_handle_t input);
audio_io_handle_t getInput_l();
status_t restoreRecord_l(audio_track_cblk_t*& cblk);
- sp<IAudioRecord> mAudioRecord;
- sp<IMemory> mCblkMemory;
- sp<ClientRecordThread> mClientRecordThread;
- status_t mReadyToRun;
+ sp<AudioRecordThread> mAudioRecordThread;
mutable Mutex mLock;
- Condition mCondition;
- uint32_t mFrameCount;
+ bool mActive; // protected by mLock
- audio_track_cblk_t* mCblk;
+ // for client callback handler
+ callback_t mCbf;
+ void* mUserData;
+
+ // for notification APIs
+ uint32_t mNotificationFrames;
+ uint32_t mRemainingFrames;
+ uint32_t mMarkerPosition; // in frames
+ bool mMarkerReached;
+ uint32_t mNewPosition; // in frames
+ uint32_t mUpdatePeriod; // in ms
+
+ // constant after constructor or set()
+ uint32_t mFrameCount;
audio_format_t mFormat;
uint8_t mChannelCount;
audio_source_t mInputSource;
status_t mStatus;
uint32_t mLatency;
+ audio_channel_mask_t mChannelMask;
+ audio_io_handle_t mInput; // returned by AudioSystem::getInput()
+ int mSessionId;
- volatile int32_t mActive;
+ // may be changed if IAudioRecord object is re-created
+ sp<IAudioRecord> mAudioRecord;
+ sp<IMemory> mCblkMemory;
+ audio_track_cblk_t* mCblk;
- callback_t mCbf;
- void* mUserData;
- uint32_t mNotificationFrames;
- uint32_t mRemainingFrames;
- uint32_t mMarkerPosition;
- bool mMarkerReached;
- uint32_t mNewPosition;
- uint32_t mUpdatePeriod;
- record_flags mFlags;
- uint32_t mChannelMask;
- audio_io_handle_t mInput;
- int mSessionId;
int mPreviousPriority; // before start()
SchedPolicy mPreviousSchedulingGroup;
};
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index e2662f27..49e1afcb 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -70,6 +70,8 @@ public:
// returns true in *state if tracks are active on the specified stream or has been active
// in the past inPastMs milliseconds
static status_t isStreamActive(audio_stream_type_t stream, bool *state, uint32_t inPastMs = 0);
+ // returns true in *state if a recorder is currently recording with the specified source
+ static status_t isSourceActive(audio_source_t source, bool *state);
// set/get audio hardware parameters. The function accepts a list of parameters
// key value pairs in the form: key1=value1;key2=value2;...
@@ -110,8 +112,8 @@ public:
static bool routedToA2dpOutput(audio_stream_type_t streamType);
- static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount,
- size_t* buffSize);
+ static status_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
+ audio_channel_mask_t channelMask, size_t* buffSize);
static status_t setVoiceVolume(float volume);
@@ -126,6 +128,7 @@ public:
// necessary to check returned status before using the returned values.
static status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, audio_stream_type_t stream = AUDIO_STREAM_DEFAULT);
+ // return the number of input frames lost by HAL implementation, or 0 if the handle is invalid
static unsigned int getInputFramesLost(audio_io_handle_t ioHandle);
static int newAudioSessionId();
@@ -188,7 +191,7 @@ public:
static audio_io_handle_t getOutput(audio_stream_type_t stream,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = AUDIO_CHANNEL_OUT_STEREO,
+ audio_channel_mask_t channelMask = AUDIO_CHANNEL_OUT_STEREO,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE);
static status_t startOutput(audio_io_handle_t output,
audio_stream_type_t stream,
@@ -200,8 +203,7 @@ public:
static audio_io_handle_t getInput(audio_source_t inputSource,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = AUDIO_CHANNEL_IN_MONO,
- audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
+ audio_channel_mask_t channelMask = AUDIO_CHANNEL_IN_MONO,
int sessionId = 0);
static status_t startInput(audio_io_handle_t input);
static status_t stopInput(audio_io_handle_t input);
@@ -219,8 +221,8 @@ public:
static uint32_t getStrategyForStream(audio_stream_type_t stream);
static audio_devices_t getDevicesForStream(audio_stream_type_t stream);
- static audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
- static status_t registerEffect(effect_descriptor_t *desc,
+ static audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc);
+ static status_t registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -234,6 +236,10 @@ public:
static const sp<IAudioPolicyService>& get_audio_policy_service();
+ // helpers for android.media.AudioManager.getProperty(), see description there for meaning
+ static int32_t getPrimaryOutputSamplingRate();
+ static int32_t getPrimaryOutputFrameCount();
+
// ----------------------------------------------------------------------------
private:
@@ -277,7 +283,7 @@ private:
// previous parameters for recording buffer size queries
static uint32_t gPrevInSamplingRate;
static audio_format_t gPrevInFormat;
- static int gPrevInChannelCount;
+ static audio_channel_mask_t gPrevInChannelMask;
static sp<IAudioPolicyService> gAudioPolicyService;
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 639d6d22..34108b38 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -135,7 +135,7 @@ public:
* sampleRate: Track sampling rate in Hz.
* format: Audio format (e.g AUDIO_FORMAT_PCM_16_BIT for signed
* 16 bits per sample).
- * channelMask: Channel mask: see audio_channels_t.
+ * channelMask: Channel mask.
* frameCount: Minimum size of track PCM buffer in frames. This defines the
* latency of the track. The actual size selected by the AudioTrack could be
* larger if the requested size is not compatible with current audio HAL
@@ -154,7 +154,7 @@ public:
AudioTrack( audio_stream_type_t streamType,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- int channelMask = 0,
+ audio_channel_mask_t channelMask = 0,
int frameCount = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
callback_t cbf = NULL,
@@ -186,7 +186,7 @@ public:
AudioTrack( audio_stream_type_t streamType,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- int channelMask = 0,
+ audio_channel_mask_t channelMask = 0,
const sp<IMemory>& sharedBuffer = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
callback_t cbf = NULL,
@@ -204,13 +204,13 @@ public:
* Returned status (from utils/Errors.h) can be:
* - NO_ERROR: successful initialization
* - INVALID_OPERATION: AudioTrack is already initialized
- * - BAD_VALUE: invalid parameter (channels, format, sampleRate...)
+ * - BAD_VALUE: invalid parameter (channelMask, format, sampleRate...)
* - NO_INIT: audio server or audio hardware not initialized
* */
status_t set(audio_stream_type_t streamType = AUDIO_STREAM_DEFAULT,
uint32_t sampleRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- int channelMask = 0,
+ audio_channel_mask_t channelMask = 0,
int frameCount = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE,
callback_t cbf = NULL,
@@ -472,8 +472,6 @@ protected:
private:
friend class AudioTrack;
virtual bool threadLoop();
- virtual status_t readyToRun();
- virtual void onFirstRef();
AudioTrack& mReceiver;
~AudioTrackThread();
Mutex mMyLock; // Thread::mLock is private
@@ -487,7 +485,7 @@ protected:
status_t 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,
@@ -512,7 +510,7 @@ protected:
uint8_t mChannelCount;
uint8_t mMuted;
uint8_t mReserved;
- uint32_t mChannelMask;
+ audio_channel_mask_t mChannelMask;
status_t mStatus;
uint32_t mLatency;
@@ -549,7 +547,7 @@ public:
status_t allocateTimedBuffer(size_t size, sp<IMemory>* buffer);
/* queue a buffer obtained via allocateTimedBuffer for playback at the
- given timestamp. PTS units a microseconds on the media time timeline.
+ given timestamp. PTS units are microseconds on the media time timeline.
The media time transform (set with setMediaTimeTransform) set by the
audio producer will handle converting from media time to local time
(perhaps going through the common time timeline in the case of
diff --git a/services/audioflinger/ExtendedAudioBufferProvider.h b/include/media/ExtendedAudioBufferProvider.h
index 88279b48..00c4444f 100644
--- a/services/audioflinger/ExtendedAudioBufferProvider.h
+++ b/include/media/ExtendedAudioBufferProvider.h
@@ -17,7 +17,7 @@
#ifndef ANDROID_EXTENDED_AUDIO_BUFFER_PROVIDER_H
#define ANDROID_EXTENDED_AUDIO_BUFFER_PROVIDER_H
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
namespace android {
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 86e228bf..5170a87e 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -48,7 +48,7 @@ public:
enum {
TRACK_DEFAULT = 0, // client requests a default AudioTrack
TRACK_TIMED = 1, // client requests a TimedAudioTrack
- TRACK_FAST = 2, // client requests a fast AudioTrack
+ TRACK_FAST = 2, // client requests a fast AudioTrack or AudioRecord
};
typedef uint32_t track_flags_t;
@@ -60,7 +60,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,
@@ -74,9 +74,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, // -1 means unused, otherwise must be valid non-0
int *sessionId,
status_t *status) = 0;
@@ -84,7 +85,9 @@ public:
* and therefore can be cached.
*/
virtual uint32_t sampleRate(audio_io_handle_t output) const = 0;
+#if 0
virtual int channelCount(audio_io_handle_t output) const = 0;
+#endif
virtual audio_format_t format(audio_io_handle_t output) const = 0;
virtual size_t frameCount(audio_io_handle_t output) const = 0;
@@ -126,7 +129,8 @@ public:
virtual void registerClient(const sp<IAudioFlingerClient>& client) = 0;
// retrieve the audio recording buffer size
- virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const = 0;
+ virtual size_t getInputBufferSize(uint32_t sampleRate, audio_format_t format,
+ audio_channel_mask_t channelMask) const = 0;
virtual audio_io_handle_t openOutput(audio_module_handle_t module,
audio_devices_t *pDevices,
@@ -183,6 +187,13 @@ public:
audio_io_handle_t dstOutput) = 0;
virtual audio_module_handle_t loadHwModule(const char *name) = 0;
+
+ // helpers for android.media.AudioManager.getProperty(), see description there for meaning
+ // FIXME move these APIs to AudioPolicy to permit a more accurate implementation
+ // that looks on primary device for a stream with fast flag, primary flag, or first one.
+ virtual int32_t getPrimaryOutputSamplingRate() = 0;
+ virtual int32_t getPrimaryOutputFrameCount() = 0;
+
};
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index e160d70e..cc2e0692 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -51,7 +51,7 @@ public:
virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = 0,
+ audio_channel_mask_t channelMask = 0,
audio_output_flags_t flags = AUDIO_OUTPUT_FLAG_NONE) = 0;
virtual status_t startOutput(audio_io_handle_t output,
audio_stream_type_t stream,
@@ -63,8 +63,7 @@ public:
virtual audio_io_handle_t getInput(audio_source_t inputSource,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = 0,
- audio_in_acoustics_t acoustics = (audio_in_acoustics_t)0,
+ audio_channel_mask_t channelMask = 0,
int audioSession = 0) = 0;
virtual status_t startInput(audio_io_handle_t input) = 0;
virtual status_t stopInput(audio_io_handle_t input) = 0;
@@ -80,8 +79,8 @@ public:
audio_devices_t device) = 0;
virtual uint32_t getStrategyForStream(audio_stream_type_t stream) = 0;
virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream) = 0;
- virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc) = 0;
- virtual status_t registerEffect(effect_descriptor_t *desc,
+ virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc) = 0;
+ virtual status_t registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -89,6 +88,7 @@ public:
virtual status_t unregisterEffect(int id) = 0;
virtual status_t setEffectEnabled(int id, bool enabled) = 0;
virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const = 0;
+ virtual bool isSourceActive(audio_source_t source) const = 0;
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count) = 0;
diff --git a/include/media/IAudioRecord.h b/include/media/IAudioRecord.h
index ebc03eaa..d6e3141c 100644
--- a/include/media/IAudioRecord.h
+++ b/include/media/IAudioRecord.h
@@ -37,7 +37,7 @@ public:
/* After it's created the track is not active. Call start() to
* make it active.
*/
- virtual status_t start(int event, int triggerSession) = 0;
+ virtual status_t start(int /*AudioSystem::sync_event_t*/ event, int triggerSession) = 0;
/* Stop a track. If set, the callback will cease being called and
* obtainBuffer will return an error. Buffers that are already released
diff --git a/include/media/ICrypto.h b/include/media/ICrypto.h
index 32a2cf77..61059bde 100644
--- a/include/media/ICrypto.h
+++ b/include/media/ICrypto.h
@@ -41,7 +41,7 @@ struct ICrypto : public IInterface {
virtual bool requiresSecureDecoderComponent(
const char *mime) const = 0;
- virtual status_t decrypt(
+ virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
diff --git a/include/media/IHDCP.h b/include/media/IHDCP.h
new file mode 100644
index 00000000..a0613c7a
--- /dev/null
+++ b/include/media/IHDCP.h
@@ -0,0 +1,78 @@
+/*
+ * 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 <binder/IInterface.h>
+#include <media/hardware/HDCPAPI.h>
+#include <media/stagefright/foundation/ABase.h>
+
+namespace android {
+
+struct IHDCPObserver : public IInterface {
+ DECLARE_META_INTERFACE(HDCPObserver);
+
+ virtual void notify(
+ int msg, int ext1, int ext2, const Parcel *obj) = 0;
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(IHDCPObserver);
+};
+
+struct IHDCP : public IInterface {
+ DECLARE_META_INTERFACE(HDCP);
+
+ // Called to specify the observer that receives asynchronous notifications
+ // from the HDCP implementation to signal completion/failure of asynchronous
+ // operations (such as initialization) or out of band events.
+ virtual status_t setObserver(const sp<IHDCPObserver> &observer) = 0;
+
+ // Request to setup an HDCP session with the specified host listening
+ // on the specified port.
+ virtual status_t initAsync(const char *host, unsigned port) = 0;
+
+ // Request to shutdown the active HDCP session.
+ virtual status_t shutdownAsync() = 0;
+
+ // Encrypt a data according to the HDCP spec. The data is to be
+ // encrypted in-place, only size bytes of data should be read/write,
+ // even if the size is not a multiple of 128 bit (16 bytes).
+ // This operation is to be synchronous, i.e. this call does not return
+ // until outData contains size bytes of encrypted data.
+ // streamCTR will be assigned by the caller (to 0 for the first PES stream,
+ // 1 for the second and so on)
+ // inputCTR will be maintained by the callee for each PES stream.
+ virtual status_t encrypt(
+ const void *inData, size_t size, uint32_t streamCTR,
+ uint64_t *outInputCTR, void *outData) = 0;
+
+private:
+ DISALLOW_EVIL_CONSTRUCTORS(IHDCP);
+};
+
+struct BnHDCPObserver : public BnInterface<IHDCPObserver> {
+ virtual status_t onTransact(
+ uint32_t code, const Parcel &data, Parcel *reply,
+ uint32_t flags = 0);
+};
+
+struct BnHDCP : public BnInterface<IHDCP> {
+ virtual status_t onTransact(
+ uint32_t code, const Parcel &data, Parcel *reply,
+ uint32_t flags = 0);
+};
+
+} // namespace android
+
+
diff --git a/include/media/IMediaPlayer.h b/include/media/IMediaPlayer.h
index 00facc5a..4ed18634 100644
--- a/include/media/IMediaPlayer.h
+++ b/include/media/IMediaPlayer.h
@@ -64,6 +64,7 @@ public:
virtual status_t setParameter(int key, const Parcel& request) = 0;
virtual status_t getParameter(int key, Parcel* reply) = 0;
virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) = 0;
+ virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint) = 0;
virtual status_t setNextPlayer(const sp<IMediaPlayer>& next) = 0;
// Invoke a generic method on the player by using opaque parcels
diff --git a/include/media/IMediaPlayerService.h b/include/media/IMediaPlayerService.h
index 76c45a02..7a89135c 100644
--- a/include/media/IMediaPlayerService.h
+++ b/include/media/IMediaPlayerService.h
@@ -32,8 +32,11 @@
namespace android {
struct ICrypto;
+struct IHDCP;
class IMediaRecorder;
class IOMX;
+class IRemoteDisplay;
+class IRemoteDisplayClient;
struct IStreamSource;
class IMediaPlayerService: public IInterface
@@ -49,6 +52,17 @@ public:
virtual sp<IMemory> decode(int fd, int64_t offset, int64_t length, uint32_t *pSampleRate, int* pNumChannels, audio_format_t* pFormat) = 0;
virtual sp<IOMX> getOMX() = 0;
virtual sp<ICrypto> makeCrypto() = 0;
+ virtual sp<IHDCP> makeHDCP() = 0;
+
+ // Connects to a remote display.
+ // 'iface' specifies the address of the local interface on which to listen for
+ // a connection from the remote display as an ip address and port number
+ // of the form "x.x.x.x:y". The media server should call back into the provided remote
+ // display client when display connection, disconnection or errors occur.
+ // The assumption is that at most one remote display will be connected to the
+ // provided interface at a time.
+ virtual sp<IRemoteDisplay> listenForRemoteDisplay(const sp<IRemoteDisplayClient>& client,
+ const String8& iface) = 0;
// codecs and audio devices usage tracking for the battery app
enum BatteryDataBits {
diff --git a/include/media/IRemoteDisplay.h b/include/media/IRemoteDisplay.h
new file mode 100644
index 00000000..c8baae9d
--- /dev/null
+++ b/include/media/IRemoteDisplay.h
@@ -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.
+ */
+
+#ifndef ANDROID_IREMOTEDISPLAY_H
+#define ANDROID_IREMOTEDISPLAY_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+
+namespace android {
+
+/*
+ * Represents a remote display, such as a Wifi display.
+ *
+ * When the remote display is created, it may not yet be connected to the
+ * display. The remote display asynchronously reports events such as successful
+ * connection, disconnection and errors to an IRemoteDisplayClient interface provided by
+ * the client.
+ */
+class IRemoteDisplay : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(RemoteDisplay);
+
+ virtual status_t pause() = 0;
+ virtual status_t resume() = 0;
+
+ // Disconnects the remote display and stops listening for new connections.
+ virtual status_t dispose() = 0;
+};
+
+
+// ----------------------------------------------------------------------------
+
+class BnRemoteDisplay : public BnInterface<IRemoteDisplay>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IREMOTEDISPLAY_H
diff --git a/include/media/IRemoteDisplayClient.h b/include/media/IRemoteDisplayClient.h
new file mode 100644
index 00000000..252b401d
--- /dev/null
+++ b/include/media/IRemoteDisplayClient.h
@@ -0,0 +1,79 @@
+/*
+ * 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 ANDROID_IREMOTEDISPLAYCLIENT_H
+#define ANDROID_IREMOTEDISPLAYCLIENT_H
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <utils/RefBase.h>
+#include <binder/IInterface.h>
+#include <binder/Parcel.h>
+
+namespace android {
+
+class ISurfaceTexture;
+
+class IRemoteDisplayClient : public IInterface
+{
+public:
+ DECLARE_META_INTERFACE(RemoteDisplayClient);
+
+ enum {
+ // Flag: The remote display is using a secure transport protocol such as HDCP.
+ kDisplayFlagSecure = 1 << 0,
+ };
+
+ enum {
+ // Error: An unknown / generic error occurred.
+ kDisplayErrorUnknown = 1,
+ // Error: The connection was dropped unexpectedly.
+ kDisplayErrorConnectionDropped = 2,
+ };
+
+ // Indicates that the remote display has been connected successfully.
+ // Provides a surface texture that the client should use to stream buffers to
+ // the remote display.
+ virtual void onDisplayConnected(const sp<ISurfaceTexture>& surfaceTexture,
+ uint32_t width, uint32_t height, uint32_t flags) = 0; // one-way
+
+ // Indicates that the remote display has been disconnected normally.
+ // This method should only be called once the client has called 'dispose()'
+ // on the IRemoteDisplay.
+ // It is currently an error for the display to disconnect for any other reason.
+ virtual void onDisplayDisconnected() = 0; // one-way
+
+ // Indicates that a connection could not be established to the remote display
+ // or an unrecoverable error occurred and the connection was severed.
+ virtual void onDisplayError(int32_t error) = 0; // one-way
+};
+
+
+// ----------------------------------------------------------------------------
+
+class BnRemoteDisplayClient : public BnInterface<IRemoteDisplayClient>
+{
+public:
+ virtual status_t onTransact( uint32_t code,
+ const Parcel& data,
+ Parcel* reply,
+ uint32_t flags = 0);
+};
+
+}; // namespace android
+
+#endif // ANDROID_IREMOTEDISPLAYCLIENT_H
diff --git a/include/media/IStreamSource.h b/include/media/IStreamSource.h
index 19646b0c..39e0a9ed 100644
--- a/include/media/IStreamSource.h
+++ b/include/media/IStreamSource.h
@@ -33,6 +33,12 @@ struct IStreamSource : public IInterface {
virtual void setBuffers(const Vector<sp<IMemory> > &buffers) = 0;
virtual void onBufferAvailable(size_t index) = 0;
+
+ enum {
+ // Video PES packets contain exactly one (aligned) access unit.
+ kFlagAlignedVideoData = 1,
+ };
+ virtual uint32_t flags() const { return 0; }
};
struct IStreamListener : public IInterface {
@@ -67,6 +73,11 @@ struct IStreamListener : public IInterface {
// ATSParser::DiscontinuityType.
static const char *const kKeyDiscontinuityMask;
+ // Optionally signalled as part of a discontinuity that includes
+ // DISCONTINUITY_TIME. It indicates the media time (in us) to be associated
+ // with the next PTS occuring in the stream. The value is of type int64_t.
+ static const char *const kKeyMediaTimeUs;
+
virtual void issueCommand(
Command cmd, bool synchronous, const sp<AMessage> &msg = NULL) = 0;
};
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index a70fe8c7..b7bee3f8 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -50,9 +50,6 @@ enum player_type {
// The shared library with the test player is passed passed as an
// argument to the 'test:' url in the setDataSource call.
TEST_PLAYER = 5,
-
- AAH_RX_PLAYER = 100,
- AAH_TX_PLAYER = 101,
};
@@ -153,13 +150,16 @@ public:
virtual status_t setParameter(int key, const Parcel &request) = 0;
virtual status_t getParameter(int key, Parcel *reply) = 0;
- // Right now, only the AAX TX player supports this functionality. For now,
- // provide a default implementation which indicates a lack of support for
- // this functionality to make life easier for all of the other media player
- // maintainers out there.
+ // default no-op implementation of optional extensions
virtual status_t setRetransmitEndpoint(const struct sockaddr_in* endpoint) {
return INVALID_OPERATION;
}
+ virtual status_t getRetransmitEndpoint(struct sockaddr_in* endpoint) {
+ return INVALID_OPERATION;
+ }
+ virtual status_t setNextPlayer(const sp<MediaPlayerBase>& next) {
+ return OK;
+ }
// Invoke a generic method on the player by using opaque parcels
// for the request and reply.
diff --git a/include/media/Visualizer.h b/include/media/Visualizer.h
index fdec5eee..aa589057 100644
--- a/include/media/Visualizer.h
+++ b/include/media/Visualizer.h
@@ -142,8 +142,6 @@ private:
private:
friend class Visualizer;
virtual bool threadLoop();
- virtual status_t readyToRun();
- virtual void onFirstRef();
Visualizer& mReceiver;
Mutex mLock;
uint32_t mSleepTimeUs;
diff --git a/include/media/mediametadataretriever.h b/include/media/mediametadataretriever.h
index 534afce4..0df77c1f 100644
--- a/include/media/mediametadataretriever.h
+++ b/include/media/mediametadataretriever.h
@@ -55,6 +55,7 @@ enum {
METADATA_KEY_TIMED_TEXT_LANGUAGES = 21,
METADATA_KEY_IS_DRM = 22,
METADATA_KEY_LOCATION = 23,
+ METADATA_KEY_VIDEO_ROTATION = 24,
// Add more here...
};
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index 1fad3833..d753ebaa 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -99,6 +99,8 @@ enum media_info_type {
// The player was started because it was used as the next player for another
// player, which just completed playback
MEDIA_INFO_STARTED_AS_NEXT = 2,
+ // The player just pushed the very first video frame for rendering
+ MEDIA_INFO_RENDERING_START = 3,
// 7xx
// The video is too complex for the decoder: it can't decode frames fast
// enough. Possibly only the audio plays fine at this stage.
@@ -247,7 +249,6 @@ private:
sp<MediaPlayerListener> mListener;
void* mCookie;
media_player_states mCurrentState;
- int mDuration;
int mCurrentPosition;
int mSeekPosition;
bool mPrepareSync;
diff --git a/services/audioflinger/AudioBufferProviderSource.h b/include/media/nbaio/AudioBufferProviderSource.h
index 2b399372..2c4aaffb 100644
--- a/services/audioflinger/AudioBufferProviderSource.h
+++ b/include/media/nbaio/AudioBufferProviderSource.h
@@ -20,7 +20,7 @@
#define ANDROID_AUDIO_BUFFER_PROVIDER_SOURCE_H
#include "NBAIO.h"
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
namespace android {
@@ -42,8 +42,9 @@ public:
//virtual size_t framesOverrun();
//virtual size_t overruns();
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count);
- virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block);
+ virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
+ virtual ssize_t readVia(readVia_t via, size_t total, void *user,
+ int64_t readPTS, size_t block);
private:
AudioBufferProvider * const mProvider;
diff --git a/services/audioflinger/AudioStreamInSource.h b/include/media/nbaio/AudioStreamInSource.h
index 07d8c89e..07d8c89e 100644
--- a/services/audioflinger/AudioStreamInSource.h
+++ b/include/media/nbaio/AudioStreamInSource.h
diff --git a/services/audioflinger/AudioStreamOutSink.h b/include/media/nbaio/AudioStreamOutSink.h
index 1eff3f64..5976b186 100644
--- a/services/audioflinger/AudioStreamOutSink.h
+++ b/include/media/nbaio/AudioStreamOutSink.h
@@ -47,6 +47,11 @@ public:
virtual ssize_t write(const void *buffer, size_t count);
+ // AudioStreamOutSink wraps a HAL's output stream. Its
+ // getNextWriteTimestamp method is simply a passthru to the HAL's underlying
+ // implementation of GNWT (if any)
+ virtual status_t getNextWriteTimestamp(int64_t *timestamp);
+
// NBAIO_Sink end
#if 0 // until necessary
diff --git a/services/audioflinger/LibsndfileSink.h b/include/media/nbaio/LibsndfileSink.h
index f5d53d51..f5d53d51 100644
--- a/services/audioflinger/LibsndfileSink.h
+++ b/include/media/nbaio/LibsndfileSink.h
diff --git a/services/audioflinger/LibsndfileSource.h b/include/media/nbaio/LibsndfileSource.h
index 4fbdb4b7..4fbdb4b7 100644
--- a/services/audioflinger/LibsndfileSource.h
+++ b/include/media/nbaio/LibsndfileSource.h
diff --git a/services/audioflinger/MonoPipe.h b/include/media/nbaio/MonoPipe.h
index f6e2cb35..5fcfe9ee 100644
--- a/services/audioflinger/MonoPipe.h
+++ b/include/media/nbaio/MonoPipe.h
@@ -18,6 +18,7 @@
#define ANDROID_AUDIO_MONO_PIPE_H
#include <time.h>
+#include <utils/LinearTransform.h>
#include "NBAIO.h"
namespace android {
@@ -56,27 +57,76 @@ public:
virtual ssize_t write(const void *buffer, size_t count);
//virtual ssize_t writeVia(writeVia_t via, size_t total, void *user, size_t block);
+ // MonoPipe's implementation of getNextWriteTimestamp works in conjunction
+ // with MonoPipeReader. Every time a MonoPipeReader reads from the pipe, it
+ // receives a "readPTS" indicating the point in time for which the reader
+ // would like to read data. This "last read PTS" is offset by the amt of
+ // data the reader is currently mixing and then cached cached along with the
+ // updated read pointer. This cached value is the local time for which the
+ // reader is going to request data next time it reads data (assuming we are
+ // in steady state and operating with no underflows). Writers to the
+ // MonoPipe who would like to know when their next write operation will hit
+ // the speakers can call getNextWriteTimestamp which will return the value
+ // of the last read PTS plus the duration of the amt of data waiting to be
+ // read in the MonoPipe.
+ virtual status_t getNextWriteTimestamp(int64_t *timestamp);
+
// average number of frames present in the pipe under normal conditions.
// See throttling mechanism in MonoPipe::write()
size_t getAvgFrames() const { return mSetpoint; }
void setAvgFrames(size_t setpoint);
size_t maxFrames() const { return mMaxFrames; }
+ // Set the shutdown state for the write side of a pipe.
+ // This may be called by an unrelated thread. When shutdown state is 'true',
+ // a write that would otherwise block instead returns a short transfer count.
+ // There is no guarantee how long it will take for the shutdown to be recognized,
+ // but it will not be an unbounded amount of time.
+ // The state can be restored to normal by calling shutdown(false).
+ void shutdown(bool newState = true);
+
+ // Return true if the write side of a pipe is currently shutdown.
+ bool isShutdown();
+
private:
+ // A pair of methods and a helper variable which allows the reader and the
+ // writer to update and observe the values of mFront and mNextRdPTS in an
+ // atomic lock-less fashion.
+ //
+ // :: Important ::
+ // Two assumptions must be true in order for this lock-less approach to
+ // function properly on all systems. First, there may only be one updater
+ // thread in the system. Second, the updater thread must be running at a
+ // strictly higher priority than the observer threads. Currently, both of
+ // these assumptions are true. The only updater is always a single
+ // FastMixer thread (which runs with SCHED_FIFO/RT priority while the only
+ // observer is always an AudioFlinger::PlaybackThread running with
+ // traditional (non-RT) audio priority.
+ void updateFrontAndNRPTS(int32_t newFront, int64_t newNextRdPTS);
+ void observeFrontAndNRPTS(int32_t *outFront, int64_t *outNextRdPTS);
+ volatile int32_t mUpdateSeq;
+
const size_t mReqFrames; // as requested in constructor, unrounded
const size_t mMaxFrames; // always a power of 2
void * const mBuffer;
// mFront and mRear will never be separated by more than mMaxFrames.
// 32-bit overflow is possible if the pipe is active for a long time, but if that happens it's
// safe because we "&" with (mMaxFrames-1) at end of computations to calculate a buffer index.
- volatile int32_t mFront; // written by reader with android_atomic_release_store,
- // read by writer with android_atomic_acquire_load
+ volatile int32_t mFront; // written by the reader with updateFrontAndNRPTS, observed by
+ // the writer with observeFrontAndNRPTS
volatile int32_t mRear; // written by writer with android_atomic_release_store,
// read by reader with android_atomic_acquire_load
+ volatile int64_t mNextRdPTS; // written by the reader with updateFrontAndNRPTS, observed by
+ // the writer with observeFrontAndNRPTS
bool mWriteTsValid; // whether mWriteTs is valid
struct timespec mWriteTs; // time that the previous write() completed
size_t mSetpoint; // target value for pipe fill depth
const bool mWriteCanBlock; // whether write() should block if the pipe is full
+
+ int64_t offsetTimestampByAudioFrames(int64_t ts, size_t audFrames);
+ LinearTransform mSamplesToLocalTime;
+
+ bool mIsShutdown; // whether shutdown(true) was called, no barriers are needed
};
} // namespace android
diff --git a/services/audioflinger/MonoPipeReader.h b/include/media/nbaio/MonoPipeReader.h
index 9bb0a94f..0e1c9927 100644
--- a/services/audioflinger/MonoPipeReader.h
+++ b/include/media/nbaio/MonoPipeReader.h
@@ -47,7 +47,7 @@ public:
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count);
+ virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
// NBAIO_Source end
diff --git a/services/audioflinger/NBAIO.h b/include/media/nbaio/NBAIO.h
index b5ae0f10..81f42ed4 100644
--- a/services/audioflinger/NBAIO.h
+++ b/include/media/nbaio/NBAIO.h
@@ -26,6 +26,7 @@
#include <limits.h>
#include <stdlib.h>
+#include <utils/Errors.h>
#include <utils/RefBase.h>
namespace android {
@@ -74,7 +75,8 @@ unsigned Format_channelCount(NBAIO_Format format);
// Callbacks used by NBAIO_Sink::writeVia() and NBAIO_Source::readVia() below.
typedef ssize_t (*writeVia_t)(void *user, void *buffer, size_t count);
-typedef ssize_t (*readVia_t)(void *user, const void *buffer, size_t count);
+typedef ssize_t (*readVia_t)(void *user, const void *buffer,
+ size_t count, int64_t readPTS);
// Abstract class (interface) representing a data port.
class NBAIO_Port : public RefBase {
@@ -198,6 +200,21 @@ public:
// < 0 status_t error occurred prior to the first frame transfer during this callback.
virtual ssize_t writeVia(writeVia_t via, size_t total, void *user, size_t block = 0);
+ // Get the time (on the LocalTime timeline) at which the first frame of audio of the next write
+ // operation to this sink will be eventually rendered by the HAL.
+ // Inputs:
+ // ts A pointer pointing to the int64_t which will hold the result.
+ // Return value:
+ // OK Everything went well, *ts holds the time at which the first audio frame of the next
+ // write operation will be rendered, or AudioBufferProvider::kInvalidPTS if this sink
+ // does not know the answer for some reason. Sinks which eventually lead to a HAL
+ // which implements get_next_write_timestamp may return Invalid temporarily if the DMA
+ // output of the audio driver has not started yet. Sinks which lead to a HAL which
+ // does not implement get_next_write_timestamp, or which don't lead to a HAL at all,
+ // will always return kInvalidPTS.
+ // <other> Something unexpected happened internally. Check the logs and start debugging.
+ virtual status_t getNextWriteTimestamp(int64_t *ts) { return INVALID_OPERATION; }
+
protected:
NBAIO_Sink(NBAIO_Format format = Format_Invalid) : NBAIO_Port(format), mFramesWritten(0) { }
virtual ~NBAIO_Sink() { }
@@ -238,6 +255,8 @@ public:
// Inputs:
// buffer Non-NULL destination buffer owned by consumer.
// count Maximum number of frames to transfer.
+ // readPTS The presentation time (on the LocalTime timeline) for which data
+ // is being requested, or kInvalidPTS if not known.
// Return value:
// > 0 Number of frames successfully transferred prior to first error.
// = 0 Count was zero.
@@ -247,7 +266,7 @@ public:
// WOULD_BLOCK No frames can be transferred without blocking.
// OVERRUN read() has not been called frequently enough, or with enough frames to keep up.
// One or more frames were lost due to overrun, try again to read more recent data.
- virtual ssize_t read(void *buffer, size_t count) = 0;
+ virtual ssize_t read(void *buffer, size_t count, int64_t readPTS) = 0;
// Transfer data from source using a series of callbacks. More suitable for zero-fill,
// synthesis, and non-contiguous transfers (e.g. circular buffer or readv).
@@ -256,6 +275,8 @@ public:
// total Estimate of the number of frames the consumer desires. This is an estimate,
// and it can consume a different number of frames during the series of callbacks.
// user Arbitrary void * reserved for data consumer.
+ // readPTS The presentation time (on the LocalTime timeline) for which data
+ // is being requested, or kInvalidPTS if not known.
// block Number of frames per block, that is a suggested value for 'count' in each callback.
// Zero means no preference. This parameter is a hint only, and may be ignored.
// Return value:
@@ -278,7 +299,8 @@ public:
// > 0 Number of frames successfully transferred during this callback prior to first error.
// = 0 Count was zero.
// < 0 status_t error occurred prior to the first frame transfer during this callback.
- virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block = 0);
+ virtual ssize_t readVia(readVia_t via, size_t total, void *user,
+ int64_t readPTS, size_t block = 0);
protected:
NBAIO_Source(NBAIO_Format format = Format_Invalid) : NBAIO_Port(format), mFramesRead(0) { }
diff --git a/services/audioflinger/Pipe.h b/include/media/nbaio/Pipe.h
index 79a4eee3..79a4eee3 100644
--- a/services/audioflinger/Pipe.h
+++ b/include/media/nbaio/Pipe.h
diff --git a/services/audioflinger/PipeReader.h b/include/media/nbaio/PipeReader.h
index 398353b0..350e6ab8 100644
--- a/services/audioflinger/PipeReader.h
+++ b/include/media/nbaio/PipeReader.h
@@ -45,7 +45,7 @@ public:
virtual ssize_t availableToRead();
- virtual ssize_t read(void *buffer, size_t count);
+ virtual ssize_t read(void *buffer, size_t count, int64_t readPTS);
// NBAIO_Source end
diff --git a/services/audioflinger/SourceAudioBufferProvider.h b/include/media/nbaio/SourceAudioBufferProvider.h
index 85ccbb2e..c08331bf 100644
--- a/services/audioflinger/SourceAudioBufferProvider.h
+++ b/include/media/nbaio/SourceAudioBufferProvider.h
@@ -20,7 +20,7 @@
#define ANDROID_SOURCE_AUDIO_BUFFER_PROVIDER_H
#include "NBAIO.h"
-#include "ExtendedAudioBufferProvider.h"
+#include <media/ExtendedAudioBufferProvider.h>
namespace android {
diff --git a/services/audioflinger/roundup.h b/include/media/nbaio/roundup.h
index 4c3cc257..4c3cc257 100644
--- a/services/audioflinger/roundup.h
+++ b/include/media/nbaio/roundup.h
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index 2371619b..df1c46b3 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -25,6 +25,8 @@
#include <media/stagefright/SkipCutBuffer.h>
#include <OMX_Audio.h>
+#define TRACK_BUFFER_TIMING 0
+
namespace android {
struct ABuffer;
@@ -56,6 +58,8 @@ struct ACodec : public AHierarchicalStateMachine {
void initiateConfigureComponent(const sp<AMessage> &msg);
void initiateStart();
+ void signalRequestIDRFrame();
+
struct PortDescription : public RefBase {
size_t countBuffers();
IOMX::buffer_id bufferIDAt(size_t index) const;
@@ -100,6 +104,7 @@ private:
kWhatAllocateComponent = 'allo',
kWhatConfigureComponent = 'conf',
kWhatStart = 'star',
+ kWhatRequestIDRFrame = 'ridr',
};
enum {
@@ -127,6 +132,15 @@ private:
sp<GraphicBuffer> mGraphicBuffer;
};
+#if TRACK_BUFFER_TIMING
+ struct BufferStats {
+ int64_t mEmptyBufferTimeUs;
+ int64_t mFillBufferDoneTimeUs;
+ };
+
+ KeyedVector<int64_t, BufferStats> mBufferStats;
+#endif
+
sp<AMessage> mNotify;
sp<UninitializedState> mUninitializedState;
@@ -170,6 +184,7 @@ private:
bool mChannelMaskPresent;
int32_t mChannelMask;
+ status_t setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode);
status_t allocateBuffersOnPort(OMX_U32 portIndex);
status_t freeBuffersOnPort(OMX_U32 portIndex);
status_t freeBuffer(OMX_U32 portIndex, size_t i);
@@ -228,7 +243,10 @@ private:
status_t setupAVCEncoderParameters(const sp<AMessage> &msg);
status_t verifySupportForProfileAndLevel(int32_t profile, int32_t level);
- status_t configureBitrate(int32_t bitrate);
+
+ status_t configureBitrate(
+ int32_t bitrate, OMX_VIDEO_CONTROLRATETYPE bitrateMode);
+
status_t setupErrorCorrectionParameters();
status_t initNativeWindow();
@@ -251,6 +269,8 @@ private:
OMX_ERRORTYPE error = OMX_ErrorUndefined,
status_t internalError = UNKNOWN_ERROR);
+ status_t requestIDRFrame();
+
DISALLOW_EVIL_CONSTRUCTORS(ACodec);
};
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index f5466e80..99f3c3bb 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -31,11 +31,12 @@ namespace android {
class AudioRecord;
struct AudioSource : public MediaSource, public MediaBufferObserver {
- // Note that the "channels" parameter is _not_ the number of channels,
- // but a bitmask of audio_channels_t constants.
+ // Note that the "channels" parameter _is_ the number of channels,
+ // _not_ a bitmask of audio_channels_t constants.
AudioSource(
- audio_source_t inputSource, uint32_t sampleRate,
- uint32_t channels = AUDIO_CHANNEL_IN_MONO);
+ audio_source_t inputSource,
+ uint32_t sampleRate,
+ uint32_t channels = 1);
status_t initCheck() const;
@@ -49,7 +50,7 @@ struct AudioSource : public MediaSource, public MediaBufferObserver {
virtual status_t read(
MediaBuffer **buffer, const ReadOptions *options = NULL);
- status_t dataCallbackTimestamp(const AudioRecord::Buffer& buffer, int64_t timeUs);
+ status_t dataCallback(const AudioRecord::Buffer& buffer);
virtual void signalBufferReturned(MediaBuffer *buffer);
protected:
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 5a35358d..6d6b8a96 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -137,6 +137,7 @@ protected:
int32_t mCameraFlags;
Size mVideoSize;
+ int32_t mNumInputBuffers;
int32_t mVideoFrameRate;
int32_t mColorFormat;
status_t mInitCheck;
diff --git a/include/media/stagefright/MediaCodec.h b/include/media/stagefright/MediaCodec.h
index e46e8e95..b1e57cf5 100644
--- a/include/media/stagefright/MediaCodec.h
+++ b/include/media/stagefright/MediaCodec.h
@@ -106,6 +106,15 @@ struct MediaCodec : public AHandler {
status_t getInputBuffers(Vector<sp<ABuffer> > *buffers) const;
status_t getOutputBuffers(Vector<sp<ABuffer> > *buffers) const;
+ status_t requestIDRFrame();
+
+ // Notification will be posted once there "is something to do", i.e.
+ // an input/output buffer has become available, a format change is
+ // pending, an error is pending.
+ void requestActivityNotification(const sp<AMessage> &notify);
+
+ status_t getName(AString *componentName) const;
+
protected:
virtual ~MediaCodec();
virtual void onMessageReceived(const sp<AMessage> &msg);
@@ -130,21 +139,24 @@ private:
};
enum {
- kWhatInit = 'init',
- kWhatConfigure = 'conf',
- kWhatStart = 'strt',
- kWhatStop = 'stop',
- kWhatRelease = 'rele',
- kWhatDequeueInputBuffer = 'deqI',
- kWhatQueueInputBuffer = 'queI',
- kWhatDequeueOutputBuffer = 'deqO',
- kWhatReleaseOutputBuffer = 'relO',
- kWhatGetBuffers = 'getB',
- kWhatFlush = 'flus',
- kWhatGetOutputFormat = 'getO',
- kWhatDequeueInputTimedOut = 'dITO',
- kWhatDequeueOutputTimedOut = 'dOTO',
- kWhatCodecNotify = 'codc',
+ kWhatInit = 'init',
+ kWhatConfigure = 'conf',
+ kWhatStart = 'strt',
+ kWhatStop = 'stop',
+ kWhatRelease = 'rele',
+ kWhatDequeueInputBuffer = 'deqI',
+ kWhatQueueInputBuffer = 'queI',
+ kWhatDequeueOutputBuffer = 'deqO',
+ kWhatReleaseOutputBuffer = 'relO',
+ kWhatGetBuffers = 'getB',
+ kWhatFlush = 'flus',
+ kWhatGetOutputFormat = 'getO',
+ kWhatDequeueInputTimedOut = 'dITO',
+ kWhatDequeueOutputTimedOut = 'dOTO',
+ kWhatCodecNotify = 'codc',
+ kWhatRequestIDRFrame = 'ridr',
+ kWhatRequestActivityNotification = 'racN',
+ kWhatGetName = 'getN',
};
enum {
@@ -169,6 +181,7 @@ private:
sp<ALooper> mLooper;
sp<ALooper> mCodecLooper;
sp<ACodec> mCodec;
+ AString mComponentName;
uint32_t mReplyID;
uint32_t mFlags;
sp<SurfaceTextureClient> mNativeWindow;
@@ -188,6 +201,8 @@ private:
List<sp<ABuffer> > mCSD;
+ sp<AMessage> mActivityNotify;
+
MediaCodec(const sp<ALooper> &looper);
static status_t PostAndAwaitResponse(
@@ -213,6 +228,8 @@ private:
status_t setNativeWindow(
const sp<SurfaceTextureClient> &surfaceTextureClient);
+ void postActivityNotificationIfPossible();
+
DISALLOW_EVIL_CONSTRUCTORS(MediaCodec);
};
diff --git a/include/media/stagefright/MediaExtractor.h b/include/media/stagefright/MediaExtractor.h
index 94090eef..3076a96c 100644
--- a/include/media/stagefright/MediaExtractor.h
+++ b/include/media/stagefright/MediaExtractor.h
@@ -67,7 +67,7 @@ public:
}
protected:
- MediaExtractor() {}
+ MediaExtractor() : mIsDrm(false) {}
virtual ~MediaExtractor() {}
private:
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index 3c25a14d..e91904c9 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -111,6 +111,7 @@ enum {
kKeyTrackTimeStatus = 'tktm', // int64_t
kKeyNotRealTime = 'ntrt', // bool (int32_t)
+ kKeyNumBuffers = 'nbbf', // int32_t
// Ogg files can be tagged to be automatically looping...
kKeyAutoLoop = 'autL', // bool (int32_t)
diff --git a/include/media/stagefright/NuMediaExtractor.h b/include/media/stagefright/NuMediaExtractor.h
index c9c709cc..0833110b 100644
--- a/include/media/stagefright/NuMediaExtractor.h
+++ b/include/media/stagefright/NuMediaExtractor.h
@@ -50,6 +50,8 @@ struct NuMediaExtractor : public RefBase {
status_t setDataSource(int fd, off64_t offset, off64_t size);
+ status_t setDataSource(const sp<DataSource> &datasource);
+
size_t countTracks() const;
status_t getTrackFormat(size_t index, sp<AMessage> *format) const;
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 81350ca3..583c3b3a 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -98,9 +98,13 @@ struct OMXCodec : public MediaSource,
kDecoderLiesAboutNumberOfChannels = 256,
kInputBufferSizesAreBogus = 512,
kSupportsMultipleFramesPerInputBuffer = 1024,
- kAvoidMemcopyInputRecordingFrames = 2048,
- kRequiresLargerEncoderOutputBuffer = 4096,
- kOutputBuffersAreUnreadable = 8192,
+ kRequiresLargerEncoderOutputBuffer = 2048,
+ kOutputBuffersAreUnreadable = 4096,
+ };
+
+ struct CodecNameAndQuirks {
+ String8 mName;
+ uint32_t mQuirks;
};
// for use by ACodec
@@ -108,8 +112,7 @@ struct OMXCodec : public MediaSource,
const char *mime,
bool createEncoder, const char *matchComponentName,
uint32_t flags,
- Vector<String8> *matchingCodecs,
- Vector<uint32_t> *matchingCodecQuirks = NULL);
+ Vector<CodecNameAndQuirks> *matchingCodecNamesAndQuirks);
static uint32_t getComponentQuirks(
const MediaCodecList *list, size_t index);
@@ -273,7 +276,7 @@ private:
CodecProfileLevel& profileLevel);
status_t setVideoOutputFormat(
- const char *mime, OMX_U32 width, OMX_U32 height);
+ const char *mime, const sp<MetaData>& meta);
void setImageOutputFormat(
OMX_COLOR_FORMATTYPE format, OMX_U32 width, OMX_U32 height);
@@ -342,8 +345,6 @@ private:
status_t configureCodec(const sp<MetaData> &meta);
- void restorePatchedDataPointer(BufferInfo *info);
-
status_t applyRotation();
status_t waitForBufferFilled_l();
@@ -353,6 +354,8 @@ private:
const void *data, size_t size,
unsigned *profile, unsigned *level);
+ status_t stopOmxComponent_l();
+
OMXCodec(const OMXCodec &);
OMXCodec &operator=(const OMXCodec &);
};
diff --git a/include/media/stagefright/SurfaceMediaSource.h b/include/media/stagefright/SurfaceMediaSource.h
index 4a8e2217..e56527d6 100644
--- a/include/media/stagefright/SurfaceMediaSource.h
+++ b/include/media/stagefright/SurfaceMediaSource.h
@@ -52,6 +52,8 @@ class GraphicBuffer;
// may be dropped. It is possible to wait for the buffers to be
// returned (but not implemented)
+#define DEBUG_PENDING_BUFFERS 0
+
class SurfaceMediaSource : public MediaSource,
public MediaBufferObserver,
protected BufferQueue::ConsumerListener {
@@ -73,10 +75,9 @@ public:
// For the MediaSource interface for use by StageFrightRecorder:
virtual status_t start(MetaData *params = NULL);
-
- virtual status_t stop() { return reset(); }
- virtual status_t read(
- MediaBuffer **buffer, const ReadOptions *options = NULL);
+ virtual status_t stop();
+ virtual status_t read(MediaBuffer **buffer,
+ const ReadOptions *options = NULL);
virtual sp<MetaData> getFormat();
// Get / Set the frame rate used for encoding. Default fps = 30
@@ -112,6 +113,12 @@ public:
sp<BufferQueue> getBufferQueue() const { return mBufferQueue; }
+ // To be called before start()
+ status_t setMaxAcquiredBufferCount(size_t count);
+
+ // To be called before start()
+ status_t setUseAbsoluteTimestamps();
+
protected:
// Implementation of the BufferQueue::ConsumerListener interface. These
@@ -165,6 +172,12 @@ private:
// this list in signalBufferReturned
Vector<sp<GraphicBuffer> > mCurrentBuffers;
+ size_t mNumPendingBuffers;
+
+#if DEBUG_PENDING_BUFFERS
+ Vector<MediaBuffer *> mPendingBuffers;
+#endif
+
// mCurrentTimestamp is the timestamp for the current texture. It
// gets set to mLastQueuedTimestamp each time updateTexImage is called.
int64_t mCurrentTimestamp;
@@ -183,8 +196,8 @@ private:
// Set to a default of 30 fps if not specified by the client side
int32_t mFrameRate;
- // mStopped is a flag to check if the recording is going on
- bool mStopped;
+ // mStarted is a flag to check if the recording is going on
+ bool mStarted;
// mNumFramesReceived indicates the number of frames recieved from
// the client side
@@ -200,11 +213,15 @@ private:
// offset timestamps.
int64_t mStartTimeNs;
+ size_t mMaxAcquiredBufferCount;
+
+ bool mUseAbsoluteTimestamps;
+
// mFrameAvailableCondition condition used to indicate whether there
// is a frame available for dequeuing
Condition mFrameAvailableCondition;
- status_t reset();
+ Condition mMediaBuffersAvailableCondition;
// Avoid copying and equating and default constructor
DISALLOW_IMPLICIT_CONSTRUCTORS(SurfaceMediaSource);
diff --git a/include/media/stagefright/TimeSource.h b/include/media/stagefright/TimeSource.h
index 443673de..8f11e14c 100644
--- a/include/media/stagefright/TimeSource.h
+++ b/include/media/stagefright/TimeSource.h
@@ -41,8 +41,6 @@ public:
virtual int64_t getRealTimeUs();
private:
- static int64_t GetSystemTimeUs();
-
int64_t mStartTimeUs;
};
diff --git a/include/media/stagefright/Utils.h b/include/media/stagefright/Utils.h
index d87902e7..8213af96 100644
--- a/include/media/stagefright/Utils.h
+++ b/include/media/stagefright/Utils.h
@@ -42,6 +42,8 @@ struct MetaData;
struct AMessage;
status_t convertMetaDataToMessage(
const sp<MetaData> &meta, sp<AMessage> *format);
+void convertMessageToMetaData(
+ const sp<AMessage> &format, sp<MetaData> &meta);
} // namespace android
diff --git a/include/media/stagefright/foundation/hexdump.h b/include/media/stagefright/foundation/hexdump.h
index f6083a93..8360c5a3 100644
--- a/include/media/stagefright/foundation/hexdump.h
+++ b/include/media/stagefright/foundation/hexdump.h
@@ -22,7 +22,11 @@
namespace android {
-void hexdump(const void *_data, size_t size);
+struct AString;
+
+void hexdump(
+ const void *_data, size_t size,
+ size_t indent = 0, AString *appendTo = NULL);
} // namespace android
diff --git a/include/media/stagefright/timedtext/TimedTextDriver.h b/include/media/stagefright/timedtext/TimedTextDriver.h
index cde551b7..f23c3375 100644
--- a/include/media/stagefright/timedtext/TimedTextDriver.h
+++ b/include/media/stagefright/timedtext/TimedTextDriver.h
@@ -64,6 +64,7 @@ private:
enum State {
UNINITIALIZED,
+ PREPARED,
PLAYING,
PAUSED,
};
diff --git a/include/private/media/VideoFrame.h b/include/private/media/VideoFrame.h
index 0ecc3481..a211ed94 100644
--- a/include/private/media/VideoFrame.h
+++ b/include/private/media/VideoFrame.h
@@ -88,7 +88,8 @@ public:
class VideoFrame
{
public:
- VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0) {}
+ VideoFrame(): mWidth(0), mHeight(0), mDisplayWidth(0), mDisplayHeight(0), mSize(0), mData(0),
+ mRotationAngle(0) {}
VideoFrame(const VideoFrame& copy) {
mWidth = copy.mWidth;
@@ -105,6 +106,7 @@ public:
mSize = 0;
}
}
+ mRotationAngle = copy.mRotationAngle;
}
~VideoFrame() {
diff --git a/libvideoeditor/lvpp/Android.mk b/libvideoeditor/lvpp/Android.mk
index c018d745..0ed7e6c2 100755
--- a/libvideoeditor/lvpp/Android.mk
+++ b/libvideoeditor/lvpp/Android.mk
@@ -59,6 +59,7 @@ LOCAL_SHARED_LIBRARIES := \
libstagefright \
libstagefright_foundation \
libstagefright_omx \
+ libsync \
libui \
libutils \
libvideoeditor_osal \
diff --git a/libvideoeditor/lvpp/NativeWindowRenderer.cpp b/libvideoeditor/lvpp/NativeWindowRenderer.cpp
index b2c2675d..2e15ff9e 100755
--- a/libvideoeditor/lvpp/NativeWindowRenderer.cpp
+++ b/libvideoeditor/lvpp/NativeWindowRenderer.cpp
@@ -22,9 +22,9 @@
#include <cutils/log.h>
#include <gui/SurfaceTexture.h>
#include <gui/SurfaceTextureClient.h>
-#include <media/stagefright/foundation/ADebug.h>
#include <media/stagefright/MediaBuffer.h>
#include <media/stagefright/MetaData.h>
+#include <media/stagefright/foundation/ADebug.h>
#include "VideoEditorTools.h"
#define CHECK_EGL_ERROR CHECK(EGL_SUCCESS == eglGetError())
@@ -382,7 +382,7 @@ void NativeWindowRenderer::queueInternalBuffer(ANativeWindow *anw,
int64_t timeUs;
CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
native_window_set_buffers_timestamp(anw, timeUs * 1000);
- status_t err = anw->queueBuffer(anw, buffer->graphicBuffer().get());
+ status_t err = anw->queueBuffer(anw, buffer->graphicBuffer().get(), -1);
if (err != 0) {
ALOGE("queueBuffer failed with error %s (%d)", strerror(-err), -err);
return;
@@ -399,18 +399,16 @@ void NativeWindowRenderer::queueExternalBuffer(ANativeWindow* anw,
native_window_set_usage(anw, GRALLOC_USAGE_SW_WRITE_OFTEN);
ANativeWindowBuffer* anb;
- anw->dequeueBuffer(anw, &anb);
+ CHECK(NO_ERROR == native_window_dequeue_buffer_and_wait(anw, &anb));
CHECK(anb != NULL);
- sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
- CHECK(NO_ERROR == anw->lockBuffer(anw, buf->getNativeBuffer()));
-
// Copy the buffer
uint8_t* img = NULL;
+ sp<GraphicBuffer> buf(new GraphicBuffer(anb, false));
buf->lock(GRALLOC_USAGE_SW_WRITE_OFTEN, (void**)(&img));
copyI420Buffer(buffer, img, width, height, buf->getStride());
buf->unlock();
- CHECK(NO_ERROR == anw->queueBuffer(anw, buf->getNativeBuffer()));
+ CHECK(NO_ERROR == anw->queueBuffer(anw, buf->getNativeBuffer(), -1));
}
void NativeWindowRenderer::copyI420Buffer(MediaBuffer* src, uint8_t* dst,
diff --git a/libvideoeditor/lvpp/PreviewRenderer.cpp b/libvideoeditor/lvpp/PreviewRenderer.cpp
index 4aa4eb35..b1cfc8e1 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.cpp
+++ b/libvideoeditor/lvpp/PreviewRenderer.cpp
@@ -97,13 +97,12 @@ PreviewRenderer::~PreviewRenderer() {
void PreviewRenderer::getBufferYV12(uint8_t **data, size_t *stride) {
int err = OK;
- if ((err = mSurface->ANativeWindow::dequeueBuffer(mSurface.get(), &mBuf)) != 0) {
- ALOGW("Surface::dequeueBuffer returned error %d", err);
+ if ((err = native_window_dequeue_buffer_and_wait(mSurface.get(),
+ &mBuf)) != 0) {
+ ALOGW("native_window_dequeue_buffer_and_wait returned error %d", err);
return;
}
- CHECK_EQ(0, mSurface->ANativeWindow::lockBuffer(mSurface.get(), mBuf));
-
GraphicBufferMapper &mapper = GraphicBufferMapper::get();
Rect bounds(mWidth, mHeight);
@@ -131,7 +130,7 @@ void PreviewRenderer::renderYV12() {
if (mBuf!= NULL) {
CHECK_EQ(0, mapper.unlock(mBuf->handle));
- if ((err = mSurface->ANativeWindow::queueBuffer(mSurface.get(), mBuf)) != 0) {
+ if ((err = mSurface->ANativeWindow::queueBuffer(mSurface.get(), mBuf, -1)) != 0) {
ALOGW("Surface::queueBuffer returned error %d", err);
}
}
diff --git a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
index 797686cc..c111ba81 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -534,9 +534,7 @@ status_t VideoEditorAudioPlayer::start(bool sourceAlreadyStarted) {
} else {
mAudioTrack = new AudioTrack(
AUDIO_STREAM_MUSIC, mSampleRate, AUDIO_FORMAT_PCM_16_BIT,
- (numChannels == 2)
- ? AUDIO_CHANNEL_OUT_STEREO
- : AUDIO_CHANNEL_OUT_MONO,
+ audio_channel_out_mask_from_count(numChannels),
0, AUDIO_OUTPUT_FLAG_NONE, &AudioCallback, this, 0);
if ((err = mAudioTrack->initCheck()) != OK) {
diff --git a/libvideoeditor/lvpp/VideoEditorSRC.cpp b/libvideoeditor/lvpp/VideoEditorSRC.cpp
index 4753dd46..36d0812b 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.cpp
+++ b/libvideoeditor/lvpp/VideoEditorSRC.cpp
@@ -321,8 +321,7 @@ void VideoEditorSRC::checkAndSetResampler() {
mResampler = AudioResampler::create(
16 /* bit depth */,
mChannelCnt,
- mOutputSampleRate,
- AudioResampler::DEFAULT);
+ mOutputSampleRate);
CHECK(mResampler);
mResampler->setSampleRate(mSampleRate);
mResampler->setVolume(kUnityGain, kUnityGain);
diff --git a/libvideoeditor/lvpp/VideoEditorSRC.h b/libvideoeditor/lvpp/VideoEditorSRC.h
index 2b7e9b6c..1707d4d4 100755
--- a/libvideoeditor/lvpp/VideoEditorSRC.h
+++ b/libvideoeditor/lvpp/VideoEditorSRC.h
@@ -17,7 +17,7 @@
#include <stdint.h>
#include <media/stagefright/MediaSource.h>
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
#include "AudioResampler.h"
namespace android {
diff --git a/libvideoeditor/osal/inc/M4OSA_Debug.h b/libvideoeditor/osal/inc/M4OSA_Debug.h
index b06183da..826ab51d 100755
--- a/libvideoeditor/osal/inc/M4OSA_Debug.h
+++ b/libvideoeditor/osal/inc/M4OSA_Debug.h
@@ -68,14 +68,14 @@ extern M4OSA_Void M4OSA_DEBUG_traceFunction(M4OSA_UInt32 line,
if(cond)\
{\
M4OSA_DEBUG_traceFunction(__LINE__, (M4OSA_Char*)__FILE__, level,\
- (M4OSA_Char*)#cond, (M4OSA_Char*)msg,
+ (M4OSA_Char*)#cond, (M4OSA_Char*)msg,\
(errorCode));\
return(errorCode);\
}
#define M4OSA_DEBUG(errorCode, msg)\
M4OSA_DEBUG_traceFunction(__LINE__, (M4OSA_Char*)__FILE__, 1,\
- (M4OSA_Char*)#errorCode, (M4OSA_Char*)msg,
+ (M4OSA_Char*)#errorCode, (M4OSA_Char*)msg,\
(errorCode));
#else /*(M4OSA_DEBUG_LEVEL >= 1) || (M4OSA_SUPER_DEBUG_LEVEL >= 1)*/
diff --git a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
index 9ad94e08..cdfc441c 100755
--- a/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
+++ b/libvideoeditor/vss/3gpwriter/src/M4MP4W_Writer.c
@@ -2486,6 +2486,12 @@ M4OSA_ERR M4MP4W_processAU( M4OSA_Context context, M4SYS_StreamID streamID,
#endif
+ if ((M4MP4W_Time32)auPtr->CTS < mMp4FileDataPtr->videoTrackPtr->CommonData.lastCTS) {
+ // Do not report as error, it will abort the entire filewrite. Just skip this frame.
+ M4OSA_TRACE1_0("Skip frame. Video frame has too old timestamp.");
+ return M4NO_ERROR;
+ }
+
mMp4FileDataPtr->videoTrackPtr->currentPos += auPtr->size;
/* Warning: time conversion cast 64to32! */
diff --git a/libvideoeditor/vss/src/M4xVSS_internal.c b/libvideoeditor/vss/src/M4xVSS_internal.c
index 5844115c..64a6f403 100755
--- a/libvideoeditor/vss/src/M4xVSS_internal.c
+++ b/libvideoeditor/vss/src/M4xVSS_internal.c
@@ -4025,7 +4025,7 @@ M4OSA_ERR M4VSS3GPP_externalVideoEffectFifties( M4OSA_Void *pUserData,
M4xVSS_FiftiesStruct* p_FiftiesData = (M4xVSS_FiftiesStruct *)pUserData;
/* Check the inputs (debug only) */
- M4OSA_DEBUG_IF2((pFiftiesData == M4OSA_NULL),M4ERR_PARAMETER,
+ M4OSA_DEBUG_IF2((p_FiftiesData == M4OSA_NULL),M4ERR_PARAMETER,
"xVSS: p_FiftiesData is M4OSA_NULL in M4VSS3GPP_externalVideoEffectFifties");
M4OSA_DEBUG_IF2((pPlaneOut == M4OSA_NULL),M4ERR_PARAMETER,
"xVSS: p_PlaneOut is M4OSA_NULL in M4VSS3GPP_externalVideoEffectFifties");
diff --git a/libvideoeditor/vss/src/VideoEditorResampler.cpp b/libvideoeditor/vss/src/VideoEditorResampler.cpp
index 38dffb78..1129c3cb 100755
--- a/libvideoeditor/vss/src/VideoEditorResampler.cpp
+++ b/libvideoeditor/vss/src/VideoEditorResampler.cpp
@@ -80,7 +80,7 @@ M4OSA_Context LVAudioResamplerCreate(M4OSA_Int32 bitDepth, M4OSA_Int32 inChanne
VideoEditorResampler *context = new VideoEditorResampler();
context->mResampler = AudioResampler::create(
- bitDepth, inChannelCount, sampleRate, AudioResampler::DEFAULT);
+ bitDepth, inChannelCount, sampleRate);
if (context->mResampler == NULL) {
return NULL;
}
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
index 50260739..3c8915ad 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
@@ -975,7 +975,7 @@ M4OSA_ERR VideoEditor3gpReader_getNextAu(M4OSA_Context context,
status_t error;
int32_t i32Tmp = 0;
- M4OSA_DEBUG_IF1((pReaderContext == 0), M4ERR_PARAMETER,
+ M4OSA_DEBUG_IF1(( pC== 0), M4ERR_PARAMETER,
"VideoEditor3gpReader_getNextAu: invalid context");
M4OSA_DEBUG_IF1((pStreamHandler == 0), M4ERR_PARAMETER,
"VideoEditor3gpReader_getNextAu: invalid pointer to M4_StreamHandler");
@@ -1483,11 +1483,15 @@ M4OSA_ERR VideoEditor3gpReader_getNextStreamHandler(M4OSA_Context context,
(int32_t*)&(pVideoStreamHandler->m_videoHeight));
(*pStreamHandler) = (M4_StreamHandler*)(pVideoStreamHandler);
- meta->findInt64(kKeyDuration,
- (int64_t*)&(Duration));
- ((*pStreamHandler)->m_duration) =
- (int32_t)((Duration)/1000); // conversion to mS
+ meta->findInt64(kKeyDuration, (int64_t*)&(Duration));
+ ((*pStreamHandler)->m_duration) = (int32_t)((Duration)/1000); // conversion to mS
pC->mMaxDuration = ((*pStreamHandler)->m_duration);
+ if (pC->mMaxDuration == 0) {
+ ALOGE("Video is too short: %lld Us", Duration);
+ delete pVideoStreamHandler;
+ pVideoStreamHandler = NULL;
+ return M4ERR_PARAMETER;
+ }
ALOGV("VideoEditor3gpReader_getNextStreamHandler m_duration %d",
(*pStreamHandler)->m_duration);
diff --git a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
index 21d3c305..de917310 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditorVideoDecoder.cpp
@@ -1149,6 +1149,12 @@ M4OSA_ERR VideoEditorVideoSoftwareDecoder_create(M4OSA_Context *pContext,
pDecShellContext->mLastOutputCts = -1;
pDecShellContext->m_pDecBufferPool = M4OSA_NULL;
+ // Calculate the interval between two video frames.
+ if(pDecShellContext->m_pVideoStreamhandler->m_averageFrameRate > 0){
+ pDecShellContext->mFrameIntervalMs =
+ 1000.0 / pDecShellContext->m_pVideoStreamhandler->m_averageFrameRate;
+ }
+
/**
* StageFright graph building
*/
diff --git a/media/common_time/ICommonClock.cpp b/media/common_time/ICommonClock.cpp
index 28b43acf..25ae69ed 100644
--- a/media/common_time/ICommonClock.cpp
+++ b/media/common_time/ICommonClock.cpp
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <linux/socket.h>
+
+#include <sys/socket.h>
#include <common_time/ICommonClock.h>
#include <binder/Parcel.h>
diff --git a/media/common_time/ICommonTimeConfig.cpp b/media/common_time/ICommonTimeConfig.cpp
index 8eb37cb8..67167b0c 100644
--- a/media/common_time/ICommonTimeConfig.cpp
+++ b/media/common_time/ICommonTimeConfig.cpp
@@ -13,7 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <linux/socket.h>
+
+#include <sys/socket.h>
#include <common_time/ICommonTimeConfig.h>
#include <binder/Parcel.h>
diff --git a/media/libaah_rtp/Android.mk b/media/libaah_rtp/Android.mk
deleted file mode 100644
index df533ecd..00000000
--- 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 e69de29b..00000000
--- 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 c5b1efa7..00000000
--- 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 bebba54e..00000000
--- 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 4d57e49f..00000000
--- 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 9dd79fd2..00000000
--- 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 ba5617eb..00000000
--- 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 d6b31fd4..00000000
--- 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 779405e0..00000000
--- 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 18b0e2b2..00000000
--- 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 4cd6e471..00000000
--- 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 7f78ea0b..00000000
--- 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 974805b3..00000000
--- 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 2e4b1f7e..00000000
--- 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 08e32d26..00000000
--- 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 74206c49..00000000
--- 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 b8e69608..00000000
--- 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 e53b0fdb..00000000
--- 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 d681c697..93f27cb4 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 59cd9e3c..f158929c 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 3b3c07c7..32c4ce0f 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 20370b7e..542c3c88 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 e83e5157..c4767a86 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 40dffd40..d706c2d8 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 5634ca13..330bb32f 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 9599dcc6..941d651e 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 cfa7f513..597866ad 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 35a4a617..90ebe1fb 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 83517120..a87a834d 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 d3c69f49..44baf937 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 c8e1dc76..54666fb7 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 \
@@ -61,7 +64,6 @@ LOCAL_C_INCLUDES := \
$(call include-path-for, graphics corecg) \
$(TOP)/frameworks/native/include/media/openmax \
external/icu4c/common \
- external/expat/lib \
$(call include-path-for, audio-effects) \
$(call include-path-for, audio-utils)
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 34451caf..680604b4 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 0562f8ee..8ea6306b 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 4c41ba58..207f96f9 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 e5a60f5d..3278dbe0 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,
@@ -1115,8 +1121,8 @@ ssize_t AudioTrack::write(const void* buffer, size_t userSize)
} else {
toWrite = audioBuffer.size;
memcpy(audioBuffer.i8, src, toWrite);
- src += toWrite;
}
+ src += toWrite;
userSize -= toWrite;
written += toWrite;
@@ -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 e8dd4387..ce8ffc4f 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 7aab8d60..401437c1 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 57a80a95..0d06e989 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/ICrypto.cpp b/media/libmedia/ICrypto.cpp
index 3452e5c6..2defc2da 100644
--- a/media/libmedia/ICrypto.cpp
+++ b/media/libmedia/ICrypto.cpp
@@ -91,7 +91,7 @@ struct BpCrypto : public BpInterface<ICrypto> {
return reply.readInt32() != 0;
}
- virtual status_t decrypt(
+ virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
@@ -136,21 +136,17 @@ struct BpCrypto : public BpInterface<ICrypto> {
remote()->transact(DECRYPT, data, &reply);
- status_t result = reply.readInt32();
+ ssize_t result = reply.readInt32();
if (result >= ERROR_DRM_VENDOR_MIN && result <= ERROR_DRM_VENDOR_MAX) {
errorDetailMsg->setTo(reply.readCString());
}
- if (result != OK) {
- return result;
+ if (!secure && result >= 0) {
+ reply.read(dstPtr, result);
}
- if (!secure) {
- reply.read(dstPtr, totalSize);
- }
-
- return OK;
+ return result;
}
private:
@@ -259,8 +255,7 @@ status_t BnCrypto::onTransact(
}
AString errorDetailMsg;
-
- status_t err = decrypt(
+ ssize_t result = decrypt(
secure,
key,
iv,
@@ -270,18 +265,18 @@ status_t BnCrypto::onTransact(
dstPtr,
&errorDetailMsg);
- reply->writeInt32(err);
+ reply->writeInt32(result);
- if (err >= ERROR_DRM_VENDOR_MIN
- && err <= ERROR_DRM_VENDOR_MAX) {
+ if (result >= ERROR_DRM_VENDOR_MIN
+ && result <= ERROR_DRM_VENDOR_MAX) {
reply->writeCString(errorDetailMsg.c_str());
}
if (!secure) {
- if (err == OK) {
- reply->write(dstPtr, totalSize);
+ if (result >= 0) {
+ CHECK_LE(result, static_cast<ssize_t>(totalSize));
+ reply->write(dstPtr, result);
}
-
free(dstPtr);
dstPtr = NULL;
}
diff --git a/media/libmedia/IHDCP.cpp b/media/libmedia/IHDCP.cpp
new file mode 100644
index 00000000..493f5a47
--- /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/IMediaMetadataRetriever.cpp b/media/libmedia/IMediaMetadataRetriever.cpp
index 7e6d54bd..bb066a00 100644
--- a/media/libmedia/IMediaMetadataRetriever.cpp
+++ b/media/libmedia/IMediaMetadataRetriever.cpp
@@ -20,6 +20,7 @@
#include <binder/Parcel.h>
#include <media/IMediaMetadataRetriever.h>
#include <utils/String8.h>
+#include <utils/KeyedVector.h>
// The binder is supposed to propagate the scheduler group across
// the binder interface so that remote calls are executed with
@@ -161,8 +162,22 @@ public:
if (ret != NO_ERROR) {
return NULL;
}
- return reply.readCString();
+ const char* str = reply.readCString();
+ if (str != NULL) {
+ String8 value(str);
+ if (mMetadata.indexOfKey(keyCode) < 0) {
+ mMetadata.add(keyCode, value);
+ } else {
+ mMetadata.replaceValueFor(keyCode, value);
+ }
+ return mMetadata.valueFor(keyCode).string();
+ } else {
+ return NULL;
+ }
}
+
+private:
+ KeyedVector<int, String8> mMetadata;
};
IMPLEMENT_META_INTERFACE(MediaMetadataRetriever, "android.media.IMediaMetadataRetriever");
diff --git a/media/libmedia/IMediaPlayer.cpp b/media/libmedia/IMediaPlayer.cpp
index 0bb237db..cb077661 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 91206173..c0a02600 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 00000000..1e154343
--- /dev/null
+++ b/media/libmedia/IRemoteDisplay.cpp
@@ -0,0 +1,94 @@
+/*
+ * 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,
+ PAUSE,
+ RESUME,
+};
+
+class BpRemoteDisplay: public BpInterface<IRemoteDisplay>
+{
+public:
+ BpRemoteDisplay(const sp<IBinder>& impl)
+ : BpInterface<IRemoteDisplay>(impl)
+ {
+ }
+
+ virtual status_t pause() {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
+ remote()->transact(PAUSE, data, &reply);
+ return reply.readInt32();
+ }
+
+ virtual status_t resume() {
+ Parcel data, reply;
+ data.writeInterfaceToken(IRemoteDisplay::getInterfaceDescriptor());
+ remote()->transact(RESUME, data, &reply);
+ return reply.readInt32();
+ }
+
+ 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;
+ }
+
+ case PAUSE:
+ {
+ CHECK_INTERFACE(IRemoteDisplay, data, reply);
+ reply->writeInt32(pause());
+ return OK;
+ }
+
+ case RESUME:
+ {
+ CHECK_INTERFACE(IRemoteDisplay, data, reply);
+ reply->writeInt32(resume());
+ return OK;
+ }
+
+ 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 00000000..4a1b570f
--- /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 078be944..68ffca85 100644
--- a/media/libmedia/IStreamSource.cpp
+++ b/media/libmedia/IStreamSource.cpp
@@ -32,11 +32,15 @@ const char *const IStreamListener::kKeyResumeAtPTS = "resume-at-PTS";
// static
const char *const IStreamListener::kKeyDiscontinuityMask = "discontinuity-mask";
+// static
+const char *const IStreamListener::kKeyMediaTimeUs = "media-time-us";
+
enum {
// IStreamSource
SET_LISTENER = IBinder::FIRST_CALL_TRANSACTION,
SET_BUFFERS,
ON_BUFFER_AVAILABLE,
+ FLAGS,
// IStreamListener
QUEUE_BUFFER,
@@ -72,6 +76,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 +121,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 84bc7a72..8319cd7e 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -23,7 +23,7 @@
#include <utils/Log.h>
#include <utils/Vector.h>
#include <cutils/properties.h>
-#include <expat.h>
+#include <libexpat/expat.h>
#include <media/MediaProfiles.h>
#include <media/stagefright/foundation/ADebug.h>
#include <OMX_Video.h>
@@ -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 de0bf7db..8196e107 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/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index b52a37de..4ab98e3e 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -47,7 +47,6 @@ MediaPlayer::MediaPlayer()
ALOGV("constructor");
mListener = NULL;
mCookie = NULL;
- mDuration = -1;
mStreamType = AUDIO_STREAM_MUSIC;
mCurrentPosition = -1;
mSeekPosition = -1;
@@ -90,7 +89,6 @@ void MediaPlayer::disconnect()
// always call with lock held
void MediaPlayer::clear_l()
{
- mDuration = -1;
mCurrentPosition = -1;
mSeekPosition = -1;
mVideoWidth = mVideoHeight = 0;
@@ -126,7 +124,7 @@ status_t MediaPlayer::attachNewPlayer(const sp<IMediaPlayer>& player)
mCurrentState = MEDIA_PLAYER_INITIALIZED;
err = NO_ERROR;
} else {
- ALOGE("Unable to to create media player");
+ ALOGE("Unable to create media player");
}
}
@@ -395,14 +393,14 @@ status_t MediaPlayer::getCurrentPosition(int *msec)
status_t MediaPlayer::getDuration_l(int *msec)
{
- ALOGV("getDuration");
+ ALOGV("getDuration_l");
bool isValidState = (mCurrentState & (MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_STOPPED | MEDIA_PLAYER_PLAYBACK_COMPLETE));
if (mPlayer != 0 && isValidState) {
- status_t ret = NO_ERROR;
- if (mDuration <= 0)
- ret = mPlayer->getDuration(&mDuration);
- if (msec)
- *msec = mDuration;
+ int durationMs;
+ status_t ret = mPlayer->getDuration(&durationMs);
+ if (msec) {
+ *msec = durationMs;
+ }
return ret;
}
ALOGE("Attempt to call getDuration without a valid mediaplayer");
@@ -422,14 +420,28 @@ status_t MediaPlayer::seekTo_l(int msec)
if ( msec < 0 ) {
ALOGW("Attempt to seek to invalid position: %d", msec);
msec = 0;
- } else if ((mDuration > 0) && (msec > mDuration)) {
- ALOGW("Attempt to seek to past end of file: request = %d, EOF = %d", msec, mDuration);
- msec = mDuration;
}
+
+ int durationMs;
+ status_t err = mPlayer->getDuration(&durationMs);
+
+ if (err != OK) {
+ ALOGW("Stream has no duration and is therefore not seekable.");
+ return err;
+ }
+
+ if (msec > durationMs) {
+ ALOGW("Attempt to seek to past end of file: request = %d, "
+ "durationMs = %d",
+ msec,
+ durationMs);
+
+ msec = durationMs;
+ }
+
// cache duration
mCurrentPosition = msec;
if (mSeekPosition < 0) {
- getDuration_l(NULL);
mSeekPosition = msec;
return mPlayer->seekTo(msec);
}
diff --git a/media/libmediaplayerservice/Android.mk b/media/libmediaplayerservice/Android.mk
index f173e2e1..5b5ed719 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/Crypto.cpp b/media/libmediaplayerservice/Crypto.cpp
index d35d5b1e..0e8f913d 100644
--- a/media/libmediaplayerservice/Crypto.cpp
+++ b/media/libmediaplayerservice/Crypto.cpp
@@ -141,7 +141,7 @@ bool Crypto::requiresSecureDecoderComponent(const char *mime) const {
return mPlugin->requiresSecureDecoderComponent(mime);
}
-status_t Crypto::decrypt(
+ssize_t Crypto::decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
diff --git a/media/libmediaplayerservice/Crypto.h b/media/libmediaplayerservice/Crypto.h
index c5aa3c6c..d066774f 100644
--- a/media/libmediaplayerservice/Crypto.h
+++ b/media/libmediaplayerservice/Crypto.h
@@ -42,7 +42,7 @@ struct Crypto : public BnCrypto {
virtual bool requiresSecureDecoderComponent(
const char *mime) const;
- virtual status_t decrypt(
+ virtual ssize_t decrypt(
bool secure,
const uint8_t key[16],
const uint8_t iv[16],
diff --git a/media/libmediaplayerservice/HDCP.cpp b/media/libmediaplayerservice/HDCP.cpp
new file mode 100644
index 00000000..09b9719d
--- /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 00000000..b2fc457d
--- /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 00000000..3f69c119
--- /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 00000000..fe8972b8
--- /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 c47fbd68..25aa6117 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;
@@ -523,8 +521,8 @@ void MediaPlayerService::Client::disconnect()
{
Mutex::Autolock l(mLock);
p = mPlayer;
+ mClient.clear();
}
- mClient.clear();
mPlayer.clear();
@@ -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 95b1b052..fd648dfc 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 e44031e6..348957f7 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 00000000..20e65136
--- /dev/null
+++ b/media/libmediaplayerservice/RemoteDisplay.cpp
@@ -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 "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::pause() {
+ return mSource->pause();
+}
+
+status_t RemoteDisplay::resume() {
+ return mSource->resume();
+}
+
+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 00000000..bd8b6847
--- /dev/null
+++ b/media/libmediaplayerservice/RemoteDisplay.h
@@ -0,0 +1,55 @@
+/*
+ * 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 pause();
+ virtual status_t resume();
+ 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 727fd0d4..57b0ec23 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 f97ba570..f946c1ce 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 99569c9f..f281879b 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) {
@@ -258,8 +258,8 @@ void NuPlayer::GenericSource::readBuffer(
}
}
-bool NuPlayer::GenericSource::isSeekable() {
- return true;
+uint32_t NuPlayer::GenericSource::flags() const {
+ return FLAG_SEEKABLE;
}
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index aaa5876c..e1ce2c1a 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -43,16 +43,18 @@ 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);
virtual status_t seekTo(int64_t seekTimeUs);
- virtual bool isSeekable();
+
+ virtual uint32_t flags() const;
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 22b88471..5dcca122 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;
@@ -121,9 +121,20 @@ status_t NuPlayer::HTTPLiveSource::feedMoreTSData() {
} else {
if (buffer[0] == 0x00) {
// XXX legacy
- sp<AMessage> extra;
+
+ uint8_t type = buffer[1];
+
+ sp<AMessage> extra = new AMessage;
+
+ if (type & 2) {
+ int64_t mediaTimeUs;
+ memcpy(&mediaTimeUs, &buffer[2], sizeof(mediaTimeUs));
+
+ extra->setInt64(IStreamListener::kKeyMediaTimeUs, mediaTimeUs);
+ }
+
mTSParser->signalDiscontinuity(
- buffer[1] == 0x00
+ ((type & 1) == 0)
? ATSParser::DISCONTINUITY_SEEK
: ATSParser::DISCONTINUITY_FORMATCHANGE,
extra);
@@ -181,8 +192,17 @@ status_t NuPlayer::HTTPLiveSource::seekTo(int64_t seekTimeUs) {
return OK;
}
-bool NuPlayer::HTTPLiveSource::isSeekable() {
- return mLiveSession->isSeekable();
+uint32_t NuPlayer::HTTPLiveSource::flags() const {
+ uint32_t flags = 0;
+ if (mLiveSession->isSeekable()) {
+ flags |= FLAG_SEEKABLE;
+ }
+
+ if (mLiveSession->hasDynamicDuration()) {
+ flags |= FLAG_DYNAMIC_DURATION;
+ }
+
+ return flags;
}
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
index f22af5be..79f4ab8e 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
@@ -37,16 +37,18 @@ 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);
virtual status_t seekTo(int64_t seekTimeUs);
- virtual bool isSeekable();
+
+ virtual uint32_t flags() const;
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 86e122fc..ff278732 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 {
////////////////////////////////////////////////////////////////////////////////
@@ -54,6 +59,7 @@ NuPlayer::NuPlayer()
mVideoEOS(false),
mScanSourcesPending(false),
mScanSourcesGeneration(0),
+ mPollDurationGeneration(0),
mTimeDiscontinuityPending(false),
mFlushingAudio(NONE),
mFlushingVideo(NONE),
@@ -63,7 +69,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 +88,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();
}
@@ -197,6 +211,28 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
break;
}
+ case kWhatPollDuration:
+ {
+ int32_t generation;
+ CHECK(msg->findInt32("generation", &generation));
+
+ if (generation != mPollDurationGeneration) {
+ // stale
+ break;
+ }
+
+ int64_t durationUs;
+ if (mDriver != NULL && mSource->getDuration(&durationUs) == OK) {
+ sp<NuPlayerDriver> driver = mDriver.promote();
+ if (driver != NULL) {
+ driver->notifyDuration(durationUs);
+ }
+ }
+
+ msg->post(1000000ll); // poll again in a second.
+ break;
+ }
+
case kWhatSetVideoNativeWindow:
{
ALOGV("kWhatSetVideoNativeWindow");
@@ -205,6 +241,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,12 +297,28 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
mAudioDecoder != NULL, mVideoDecoder != NULL);
- instantiateDecoder(false, &mVideoDecoder);
+ bool mHadAnySourcesBefore =
+ (mAudioDecoder != NULL) || (mVideoDecoder != NULL);
+
+ if (mNativeWindow != NULL) {
+ instantiateDecoder(false, &mVideoDecoder);
+ }
if (mAudioSink != NULL) {
instantiateDecoder(true, &mAudioDecoder);
}
+ if (!mHadAnySourcesBefore
+ && (mAudioDecoder != NULL || mVideoDecoder != NULL)) {
+ // This is the first time we've found anything playable.
+
+ uint32_t flags = mSource->flags();
+
+ if (flags & Source::FLAG_DYNAMIC_DURATION) {
+ schedulePollDuration();
+ }
+ }
+
status_t err;
if ((err = mSource->feedMoreTSData()) != OK) {
if (mAudioDecoder == NULL && mVideoDecoder == NULL) {
@@ -279,7 +334,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 +556,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;
}
@@ -513,6 +571,8 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
{
ALOGV("kWhatReset");
+ cancelPollDuration();
+
if (mRenderer != NULL) {
// There's an edge case where the renderer owns all output
// buffers and is paused, therefore the decoder will not read
@@ -674,16 +734,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 +754,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 +985,44 @@ 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;
+}
+
+void NuPlayer::schedulePollDuration() {
+ sp<AMessage> msg = new AMessage(kWhatPollDuration, id());
+ msg->setInt32("generation", mPollDurationGeneration);
+ msg->post();
+}
+
+void NuPlayer::cancelPollDuration() {
+ ++mPollDurationGeneration;
+}
+
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 25766e00..31efb2e5 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 {
@@ -84,6 +88,7 @@ private:
kWhatSeek = 'seek',
kWhatPause = 'paus',
kWhatResume = 'rsme',
+ kWhatPollDuration = 'polD',
};
wp<NuPlayerDriver> mDriver;
@@ -103,6 +108,8 @@ private:
bool mScanSourcesPending;
int32_t mScanSourcesGeneration;
+ int32_t mPollDurationGeneration;
+
enum FlushStatus {
NONE,
AWAITING_DISCONTINUITY,
@@ -128,6 +135,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);
@@ -144,6 +153,9 @@ private:
void finishReset();
void postScanSources();
+ void schedulePollDuration();
+ void cancelPollDuration();
+
DISALLOW_EVIL_CONSTRUCTORS(NuPlayer);
};
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 0e536626..22f699e6 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 3ab1fcf1..a876148e 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 441cbf31..d03601fd 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 1f139557..8a75f83a 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 268628bd..e4368c74 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 531b29f8..a635340a 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
@@ -25,6 +25,11 @@ namespace android {
struct ABuffer;
struct NuPlayer::Source : public RefBase {
+ enum Flags {
+ FLAG_SEEKABLE = 1,
+ FLAG_DYNAMIC_DURATION = 2,
+ };
+
Source() {}
virtual void start() = 0;
@@ -34,7 +39,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;
@@ -47,13 +52,13 @@ struct NuPlayer::Source : public RefBase {
return INVALID_OPERATION;
}
- virtual bool isSeekable() {
- return false;
- }
+ virtual uint32_t flags() const = 0;
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 c910488d..cf455bd4 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;
}
@@ -202,8 +210,8 @@ void NuPlayer::RTSPSource::performSeek(int64_t seekTimeUs) {
mHandler->seek(seekTimeUs);
}
-bool NuPlayer::RTSPSource::isSeekable() {
- return true;
+uint32_t NuPlayer::RTSPSource::flags() const {
+ return FLAG_SEEKABLE;
}
void NuPlayer::RTSPSource::onMessageReceived(const sp<AMessage> &msg) {
@@ -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 e11e3049..779d791e 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,18 +42,20 @@ 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);
virtual status_t seekTo(int64_t seekTimeUs);
- virtual bool isSeekable();
+
+ virtual uint32_t flags() const;
void onMessageReceived(const sp<AMessage> &msg);
protected:
virtual ~RTSPSource();
+ virtual sp<MetaData> getFormatMeta(bool audio);
+
private:
enum {
kWhatNotify = 'noti',
@@ -98,6 +102,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 7c9bc5e0..71594041 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();
}
@@ -85,8 +93,22 @@ status_t NuPlayer::StreamingSource::feedMoreTSData() {
} else {
if (buffer[0] == 0x00) {
// XXX legacy
+
+ if (extra == NULL) {
+ extra = new AMessage;
+ }
+
+ uint8_t type = buffer[1];
+
+ if (type & 2) {
+ int64_t mediaTimeUs;
+ memcpy(&mediaTimeUs, &buffer[2], sizeof(mediaTimeUs));
+
+ extra->setInt64(IStreamListener::kKeyMediaTimeUs, mediaTimeUs);
+ }
+
mTSParser->signalDiscontinuity(
- buffer[1] == 0x00
+ ((type & 1) == 0)
? ATSParser::DISCONTINUITY_SEEK
: ATSParser::DISCONTINUITY_FORMATCHANGE,
extra);
@@ -107,7 +129,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 +160,21 @@ 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;
+}
+
+uint32_t NuPlayer::StreamingSource::flags() const {
+ return 0;
}
} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.h b/media/libmediaplayerservice/nuplayer/StreamingSource.h
index ca00ef91..a27b58ad 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.h
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.h
@@ -33,12 +33,15 @@ 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);
+ virtual uint32_t flags() const;
+
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 00000000..a62d5a2a
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp
@@ -0,0 +1,140 @@
+/*
+ * 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);
+}
+
+uint32_t MP4Source::flags() const {
+ return 0;
+}
+
+} // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h
new file mode 100644
index 00000000..abca236a
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.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 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);
+
+ virtual uint32_t flags() const;
+
+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 00000000..757272fa
--- /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/services/audioflinger/AudioBufferProviderSource.cpp b/media/libnbaio/AudioBufferProviderSource.cpp
index 43421719..74a6fdb5 100644
--- a/services/audioflinger/AudioBufferProviderSource.cpp
+++ b/media/libnbaio/AudioBufferProviderSource.cpp
@@ -19,7 +19,7 @@
#include <cutils/compiler.h>
#include <utils/Log.h>
-#include "AudioBufferProviderSource.h"
+#include <media/nbaio/AudioBufferProviderSource.h>
namespace android {
@@ -46,14 +46,16 @@ ssize_t AudioBufferProviderSource::availableToRead()
return mBuffer.raw != NULL ? mBuffer.frameCount - mConsumed : 0;
}
-ssize_t AudioBufferProviderSource::read(void *buffer, size_t count)
+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, AudioBufferProvider::kInvalidPTS);
+ status_t status = mProvider->getNextBuffer(&mBuffer, readPTS);
if (status != OK) {
return status == NOT_ENOUGH_DATA ? (ssize_t) WOULD_BLOCK : (ssize_t) status;
}
@@ -79,7 +81,8 @@ ssize_t AudioBufferProviderSource::read(void *buffer, size_t count)
return count;
}
-ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *user, size_t block)
+ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *user,
+ int64_t readPTS, size_t block)
{
if (CC_UNLIKELY(!mNegotiated)) {
return NEGOTIATE;
@@ -99,7 +102,7 @@ ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *us
// 1 <= count <= block
if (CC_UNLIKELY(mBuffer.raw == NULL)) {
mBuffer.frameCount = count;
- status_t status = mProvider->getNextBuffer(&mBuffer, AudioBufferProvider::kInvalidPTS);
+ 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()
@@ -117,7 +120,8 @@ ssize_t AudioBufferProviderSource::readVia(readVia_t via, size_t total, void *us
count = available;
}
if (CC_LIKELY(count > 0)) {
- ssize_t ret = via(user, (char *) mBuffer.raw + (mConsumed << mBitShift), count);
+ 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;
diff --git a/services/audioflinger/AudioStreamInSource.cpp b/media/libnbaio/AudioStreamInSource.cpp
index 8b4bebf0..05273f69 100644
--- a/services/audioflinger/AudioStreamInSource.cpp
+++ b/media/libnbaio/AudioStreamInSource.cpp
@@ -19,7 +19,7 @@
#include <cutils/compiler.h>
#include <utils/Log.h>
-#include "AudioStreamInSource.h"
+#include <media/nbaio/AudioStreamInSource.h>
namespace android {
diff --git a/services/audioflinger/AudioStreamOutSink.cpp b/media/libnbaio/AudioStreamOutSink.cpp
index 8a5aa0c3..6f525e5d 100644
--- a/services/audioflinger/AudioStreamOutSink.cpp
+++ b/media/libnbaio/AudioStreamOutSink.cpp
@@ -18,7 +18,7 @@
//#define LOG_NDEBUG 0
#include <utils/Log.h>
-#include "AudioStreamOutSink.h"
+#include <media/nbaio/AudioStreamOutSink.h>
namespace android {
@@ -67,4 +67,16 @@ ssize_t AudioStreamOutSink::write(const void *buffer, size_t count)
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/services/audioflinger/LibsndfileSink.cpp b/media/libnbaio/LibsndfileSink.cpp
index efc1c8f7..77debc04 100644
--- a/services/audioflinger/LibsndfileSink.cpp
+++ b/media/libnbaio/LibsndfileSink.cpp
@@ -19,7 +19,7 @@
#include <utils/Errors.h>
#include <utils/Log.h>
-#include "LibsndfileSink.h"
+#include <media/nbaio/LibsndfileSink.h>
namespace android {
diff --git a/services/audioflinger/LibsndfileSource.cpp b/media/libnbaio/LibsndfileSource.cpp
index 28317d65..98610e02 100644
--- a/services/audioflinger/LibsndfileSource.cpp
+++ b/media/libnbaio/LibsndfileSource.cpp
@@ -19,7 +19,7 @@
#include <utils/Errors.h>
#include <utils/Log.h>
-#include "LibsndfileSource.h"
+#include <media/nbaio/LibsndfileSource.h>
namespace android {
diff --git a/media/libnbaio/MonoPipe.cpp b/media/libnbaio/MonoPipe.cpp
new file mode 100644
index 00000000..e8d3d9b8
--- /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/services/audioflinger/MonoPipeReader.cpp b/media/libnbaio/MonoPipeReader.cpp
index b80d0c08..394f6acd 100644
--- a/services/audioflinger/MonoPipeReader.cpp
+++ b/media/libnbaio/MonoPipeReader.cpp
@@ -19,7 +19,7 @@
#include <cutils/compiler.h>
#include <utils/Log.h>
-#include "MonoPipeReader.h"
+#include <media/nbaio/MonoPipeReader.h>
namespace android {
@@ -43,11 +43,25 @@ ssize_t MonoPipeReader::availableToRead()
return ret;
}
-ssize_t MonoPipeReader::read(void *buffer, size_t count)
+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)) {
@@ -66,7 +80,7 @@ ssize_t MonoPipeReader::read(void *buffer, size_t count)
memcpy((char *) buffer + (part1 << mBitShift), mPipe->mBuffer, part2 << mBitShift);
}
}
- android_atomic_release_store(red + mPipe->mFront, &mPipe->mFront);
+ mPipe->updateFrontAndNRPTS(red + mPipe->mFront, nextReadPTS);
mFramesRead += red;
}
return red;
diff --git a/services/audioflinger/NBAIO.cpp b/media/libnbaio/NBAIO.cpp
index 9d71eae5..00d20176 100644
--- a/services/audioflinger/NBAIO.cpp
+++ b/media/libnbaio/NBAIO.cpp
@@ -18,7 +18,7 @@
//#define LOG_NDEBUG 0
#include <utils/Log.h>
-#include "NBAIO.h"
+#include <media/nbaio/NBAIO.h>
namespace android {
@@ -128,7 +128,8 @@ ssize_t NBAIO_Sink::writeVia(writeVia_t via, size_t total, void *user, size_t bl
}
// 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, size_t block)
+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;
@@ -147,11 +148,11 @@ ssize_t NBAIO_Source::readVia(readVia_t via, size_t total, void *user, size_t bl
if (count > block) {
count = block;
}
- ssize_t ret = read(buffer, count);
+ 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);
+ ret = via(user, buffer, maxRet, readPTS);
if (ret > 0) {
ALOG_ASSERT((size_t) ret <= maxRet);
accumulator += ret;
diff --git a/services/audioflinger/Pipe.cpp b/media/libnbaio/Pipe.cpp
index e5b35610..1c21f9c3 100644
--- a/services/audioflinger/Pipe.cpp
+++ b/media/libnbaio/Pipe.cpp
@@ -20,8 +20,8 @@
#include <cutils/atomic.h>
#include <cutils/compiler.h>
#include <utils/Log.h>
-#include "Pipe.h"
-#include "roundup.h"
+#include <media/nbaio/Pipe.h>
+#include <media/nbaio/roundup.h>
namespace android {
diff --git a/services/audioflinger/PipeReader.cpp b/media/libnbaio/PipeReader.cpp
index df3ee04f..d786b843 100644
--- a/services/audioflinger/PipeReader.cpp
+++ b/media/libnbaio/PipeReader.cpp
@@ -19,7 +19,7 @@
#include <cutils/compiler.h>
#include <utils/Log.h>
-#include "PipeReader.h"
+#include <media/nbaio/PipeReader.h>
namespace android {
@@ -59,7 +59,7 @@ ssize_t PipeReader::availableToRead()
return avail;
}
-ssize_t PipeReader::read(void *buffer, size_t count)
+ssize_t PipeReader::read(void *buffer, size_t count, int64_t readPTS)
{
ssize_t avail = availableToRead();
if (CC_UNLIKELY(avail <= 0)) {
diff --git a/media/libnbaio/README.txt b/media/libnbaio/README.txt
new file mode 100644
index 00000000..8d74ab2c
--- /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/services/audioflinger/SourceAudioBufferProvider.cpp b/media/libnbaio/SourceAudioBufferProvider.cpp
index e9d6d2c7..d11a86c5 100644
--- a/services/audioflinger/SourceAudioBufferProvider.cpp
+++ b/media/libnbaio/SourceAudioBufferProvider.cpp
@@ -18,7 +18,7 @@
//#define LOG_NDEBUG 0
#include <utils/Log.h>
-#include "SourceAudioBufferProvider.h"
+#include <media/nbaio/SourceAudioBufferProvider.h>
namespace android {
@@ -65,7 +65,7 @@ status_t SourceAudioBufferProvider::getNextBuffer(Buffer *buffer, int64_t pts)
mSize = buffer->frameCount;
}
// read from source
- ssize_t actual = mSource->read(mAllocated, buffer->frameCount);
+ ssize_t actual = mSource->read(mAllocated, buffer->frameCount, pts);
if (actual > 0) {
ALOG_ASSERT((size_t) actual <= buffer->frameCount);
mOffset = 0;
diff --git a/services/audioflinger/roundup.c b/media/libnbaio/roundup.c
index 4f9af6aa..1d552d1a 100644
--- a/services/audioflinger/roundup.c
+++ b/media/libnbaio/roundup.c
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-#include "roundup.h"
+#include <media/nbaio/roundup.h>
unsigned roundup(unsigned v)
{
diff --git a/media/libstagefright/AACWriter.cpp b/media/libstagefright/AACWriter.cpp
index 284ba016..a6f7cfb1 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 c4743a1c..a01d03f2 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);
@@ -887,7 +937,8 @@ status_t ACodec::configureCodec(
}
err = setupAACCodec(
- encoder, numChannels, sampleRate, bitRate, aacProfile, isADTS != 0);
+ encoder, numChannels, sampleRate, bitRate, aacProfile,
+ isADTS != 0);
}
} else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_AMR_NB)) {
err = setupAMRCodec(encoder, false /* isWAMR */, bitRate);
@@ -936,6 +987,10 @@ status_t ACodec::configureCodec(
}
}
+ if (err != OK) {
+ return err;
+ }
+
if (!msg->findInt32("encoder-delay", &mEncoderDelay)) {
mEncoderDelay = 0;
}
@@ -1357,7 +1412,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,
@@ -1574,6 +1630,43 @@ status_t ACodec::setupVideoEncoder(const char *mime, const sp<AMessage> &msg) {
return err;
}
+status_t ACodec::setCyclicIntraMacroblockRefresh(const sp<AMessage> &msg, int32_t mode) {
+ OMX_VIDEO_PARAM_INTRAREFRESHTYPE params;
+ InitOMXParams(&params);
+ params.nPortIndex = kPortIndexOutput;
+
+ params.eRefreshMode = static_cast<OMX_VIDEO_INTRAREFRESHTYPE>(mode);
+
+ if (params.eRefreshMode == OMX_VIDEO_IntraRefreshCyclic ||
+ params.eRefreshMode == OMX_VIDEO_IntraRefreshBoth) {
+ int32_t mbs;
+ if (!msg->findInt32("intra-refresh-CIR-mbs", &mbs)) {
+ return INVALID_OPERATION;
+ }
+ params.nCirMBs = mbs;
+ }
+
+ if (params.eRefreshMode == OMX_VIDEO_IntraRefreshAdaptive ||
+ params.eRefreshMode == OMX_VIDEO_IntraRefreshBoth) {
+ int32_t mbs;
+ if (!msg->findInt32("intra-refresh-AIR-mbs", &mbs)) {
+ return INVALID_OPERATION;
+ }
+ params.nAirMBs = mbs;
+
+ int32_t ref;
+ if (!msg->findInt32("intra-refresh-AIR-ref", &ref)) {
+ return INVALID_OPERATION;
+ }
+ params.nAirRef = ref;
+ }
+
+ status_t err = mOMX->setParameter(
+ mNode, OMX_IndexParamVideoIntraRefresh,
+ &params, sizeof(params));
+ return err;
+}
+
static OMX_U32 setPFramesSpacing(int32_t iFramesInterval, int32_t frameRate) {
if (iFramesInterval < 0) {
return 0xFFFFFFFF;
@@ -1585,6 +1678,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 +1694,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 +1759,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 +1775,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 +1835,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 +1851,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;
@@ -1754,11 +1862,22 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
frameRate = (float)tmp;
}
+ status_t err = OK;
+ int32_t intraRefreshMode = 0;
+ if (msg->findInt32("intra-refresh-mode", &intraRefreshMode)) {
+ err = setCyclicIntraMacroblockRefresh(msg, intraRefreshMode);
+ if (err != OK) {
+ ALOGE("Setting intra macroblock refresh mode (%d) failed: 0x%x",
+ err, intraRefreshMode);
+ return err;
+ }
+ }
+
OMX_VIDEO_PARAM_AVCTYPE h264type;
InitOMXParams(&h264type);
h264type.nPortIndex = kPortIndexOutput;
- status_t err = mOMX->getParameter(
+ err = mOMX->getParameter(
mNode, OMX_IndexParamVideoAvc, &h264type, sizeof(h264type));
if (err != OK) {
@@ -1830,7 +1949,7 @@ status_t ACodec::setupAVCEncoderParameters(const sp<AMessage> &msg) {
return err;
}
- return configureBitrate(bitrate);
+ return configureBitrate(bitrate, bitrateMode);
}
status_t ACodec::verifySupportForProfileAndLevel(
@@ -1859,7 +1978,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 +1992,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 +2308,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 +2317,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 +2337,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 +2352,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 +2388,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 +2560,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 +2685,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 +2701,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 +2813,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 +2862,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 +2935,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 +3074,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 +3102,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 +3110,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 +3437,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 +3531,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 ca856409..8d5eec8b 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 8ad1cb9f..cc0581e9 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,12 +54,13 @@ 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 \
$(TOP)/frameworks/native/include/media/hardware \
$(TOP)/frameworks/native/include/media/openmax \
- $(TOP)/external/expat/lib \
$(TOP)/external/flac/include \
$(TOP)/external/tremolo \
$(TOP)/external/openssl/include \
@@ -81,6 +83,7 @@ LOCAL_SHARED_LIBRARIES := \
libssl \
libstagefright_omx \
libstagefright_yuv \
+ libsync \
libui \
libutils \
libvorbisidec \
@@ -92,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
@@ -118,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 72d797eb..861aebee 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 0f346d88..1e2625a6 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 3ddad932..efd7af7e 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 524c3aad..63cb4301 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 c75f1008..9d0eea26 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 668d7f7d..098fcf97 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 00000000..82712efd
--- /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 d7eea3f0..40bfc558 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 6abaf23b..380dab46 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/MPEG2TSWriter.cpp b/media/libstagefright/MPEG2TSWriter.cpp
index 92f12afa..c9ed5bb4 100644
--- a/media/libstagefright/MPEG2TSWriter.cpp
+++ b/media/libstagefright/MPEG2TSWriter.cpp
@@ -419,6 +419,8 @@ void MPEG2TSWriter::SourceInfo::onMessageReceived(const sp<AMessage> &msg) {
} else {
postAVCFrame(buffer);
}
+ } else {
+ readMore();
}
buffer->release();
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index a5725417..1a62f9df 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 61082982..326930f5 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);
@@ -2442,7 +2558,8 @@ void MPEG4Writer::Track::writeVideoFourCCBox() {
mOwner->writeInt32(0x480000); // vert resolution
mOwner->writeInt32(0); // reserved
mOwner->writeInt16(1); // frame count
- mOwner->write(" ", 32);
+ mOwner->writeInt8(0); // compressor string length
+ mOwner->write(" ", 31);
mOwner->writeInt16(0x18); // depth
mOwner->writeInt16(-1); // predefined
@@ -2586,7 +2703,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 +2860,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 +2879,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 d28322f4..cb8a6518 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;
@@ -1347,7 +1423,7 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
AString *errorDetailMsg;
CHECK(msg->findPointer("errorDetailMsg", (void **)&errorDetailMsg));
- status_t err = mCrypto->decrypt(
+ ssize_t result = mCrypto->decrypt(
(mFlags & kFlagIsSecure) != 0,
key,
iv,
@@ -1358,11 +1434,11 @@ status_t MediaCodec::onQueueInputBuffer(const sp<AMessage> &msg) {
info->mData->base(),
errorDetailMsg);
- if (err != OK) {
- return err;
+ if (result < 0) {
+ return result;
}
- info->mData->setRange(0, size);
+ info->mData->setRange(0, result);
}
reply->setBuffer("buffer", info->mData);
@@ -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/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index 9f6d4a36..d24337f2 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -26,7 +26,7 @@
#include <media/stagefright/OMXCodec.h>
#include <utils/threads.h>
-#include <expat.h>
+#include <libexpat/expat.h>
namespace android {
diff --git a/media/libstagefright/MediaDefs.cpp b/media/libstagefright/MediaDefs.cpp
index 2740d6b5..e7b59036 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 9ab66119..b18c916f 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 755594a7..a01ec978 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 f1075b1c..05e599b3 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 29e1d212..404fa946 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 fde7ebf7..70de1749 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(),
@@ -2049,8 +2071,14 @@ int64_t OMXCodec::getDecodingTimeUs() {
void OMXCodec::on_message(const omx_message &msg) {
if (mState == ERROR) {
- ALOGW("Dropping OMX message - we're in ERROR state.");
- return;
+ /*
+ * only drop EVENT messages, EBD and FBD are still
+ * processed for bookkeeping purposes
+ */
+ if (msg.type == omx_message::EVENT) {
+ ALOGW("Dropping OMX EVENT message - we're in ERROR state.");
+ return;
+ }
}
switch (msg.type) {
@@ -2086,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;
}
@@ -3065,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;
@@ -3199,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);
@@ -3620,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;
}
@@ -3635,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;
@@ -3652,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);
@@ -3756,10 +3773,6 @@ status_t OMXCodec::stop() {
mLeftOverBuffer = NULL;
}
- mSource->stop();
-
- CODEC_LOGV("stopped in state %d", mState);
-
return OK;
}
@@ -4511,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,
@@ -4521,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);
@@ -4608,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 b7cf96e1..bccffd85 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 79514962..19af4fbd 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 300d2fcd..3c002fca 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 b1fcafda..348a9d36 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 d987fbf1..041980fe 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 9df15eb2..7e9c4bfe 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 2a16f660..74e9222b 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 851321d0..2a7f6284 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 08d2ae26..5ae80cc0 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 65c1848a..a141752d 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 6ab2a00a..2c6d84cd 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 3f0b2c25..91ce175b 100644
--- a/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
+++ b/media/libstagefright/chromium_http/ChromiumHTTPDataSource.cpp
@@ -65,7 +65,10 @@ status_t ChromiumHTTPDataSource::connect(
if (getUID(&uid)) {
mDelegate->setUID(uid);
}
+
+#if defined(LOG_NDEBUG) && !LOG_NDEBUG
LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG, "connect on behalf of uid %d", uid);
+#endif
return connect_l(uri, headers, offset);
}
@@ -78,12 +81,10 @@ 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,
+#if defined(LOG_NDEBUG) && !LOG_NDEBUG
+ LOG_PRI(ANDROID_LOG_VERBOSE, LOG_TAG,
"connect to <URL suppressed> @%lld", offset);
- }
+#endif
mURI = uri;
mContentType = String8("application/octet-stream");
diff --git a/services/audioflinger/Soaker.h b/media/libstagefright/chromium_http/chromium_http_stub.cpp
index 43d9d2f3..560a61f5 100644
--- a/services/audioflinger/Soaker.h
+++ b/media/libstagefright/chromium_http/chromium_http_stub.cpp
@@ -14,32 +14,20 @@
* limitations under the License.
*/
-#ifndef _ANDROID_AUDIO_SOAKER_H
-#define _ANDROID_AUDIO_SOAKER_H
+#include <dlfcn.h>
-#include <utils/Thread.h>
+#include <include/chromium_http_stub.h>
+#include <include/ChromiumHTTPDataSource.h>
+#include <include/DataUriSource.h>
namespace android {
-class Soaker : public Thread {
-public:
- Soaker() : Thread() { }
- virtual ~Soaker() { }
-protected:
- virtual bool threadLoop() {
- int j = 0;
- for (;;) {
- for (int i = 0; i < 10000; ++i) {
- j += i * i;
- }
- if (exitPending()) {
- return false;
- }
- }
- return j < 555555;
- }
-};
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags) {
+ return new ChromiumHTTPDataSource(flags);
+}
-} // namespace android
+DataSource *createDataUriSource(const char *uri) {
+ return new DataUriSource(uri);
+}
-#endif // _ANDROID_AUDIO_SOAKER_H
+}
diff --git a/media/libstagefright/chromium_http_stub.cpp b/media/libstagefright/chromium_http_stub.cpp
new file mode 100644
index 00000000..cbd8796c
--- /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 91457c58..4dc38a81 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 7c824841..00000000
--- 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 2e750058..00000000
--- 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 ff95f9f2..d88813e4 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 ce7cb124..00000000
--- 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 2786dccc..00000000
--- 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 815456c5..00000000
--- 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 ab36c6af..00000000
--- 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 ed7fb7a9..00000000
--- 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 96ecd274..00000000
--- 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 85fb8519..00000000
--- 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 2669f877..00000000
--- 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 34f4f607..00000000
--- 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 1b5d2528..00000000
--- 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 031216a2..00000000
--- 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 e75c79e3..00000000
--- 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 ee323988..00000000
--- 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 0f0dae2a..00000000
--- 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 40475029..00000000
--- 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 5ec3f692..00000000
--- 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 c93848e6..00000000
--- 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 4fb35351..00000000
--- 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 2a6ae577..00000000
--- 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 e557aa1f..00000000
--- 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 28bd6deb..00000000
--- 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 325b5cd8..00000000
--- 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 17f3b87f..00000000
--- 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 9293d479..00000000
--- 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 75bd4ba2..00000000
--- 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 6f8fcb29..00000000
--- 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 a21a814a..00000000
--- 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 3d5e82be..00000000
--- 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 0d1561b5..00000000
--- 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 41cd1878..00000000
--- 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 a9c3551c..00000000
--- 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 5298b191..00000000
--- 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 ffa980d2..00000000
--- 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 7fdaaf74..00000000
--- 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 41c9259a..00000000
--- 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 bce73ba4..00000000
--- 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 5edecf16..00000000
--- 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 c2bf1d20..00000000
--- 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 eaf82802..00000000
--- 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 2738e808..00000000
--- 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 08b54159..00000000
--- 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 bf6ad150..00000000
--- 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 68244bb0..00000000
--- 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 5f846437..00000000
--- 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 5d0e6281..00000000
--- 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 788b5e93..00000000
--- 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 57b32816..00000000
--- 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 010b6f8a..00000000
--- 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 10064065..00000000
--- 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 b5fdc087..00000000
--- 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 a460d138..00000000
--- 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 1b021ffb..00000000
--- 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 b6c8a900..00000000
--- 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 5b2a43fd..00000000
--- 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 16e43a48..00000000
--- 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 d9f86699..00000000
--- 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 eff00dd2..00000000
--- 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 83ccccec..00000000
--- 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 157d4711..00000000
--- 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 c4b933eb..00000000
--- 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 3eca4389..00000000
--- 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 778c88cb..00000000
--- 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 a846b9f8..00000000
--- 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 571cc985..00000000
--- 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 2fcfe378..00000000
--- 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 8e7acb31..00000000
--- 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 c517e7e6..00000000
--- 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 4a8a0d6a..00000000
--- 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 2476b875..00000000
--- 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 535f1774..00000000
--- 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 d147bc5b..00000000
--- 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 b85c7df8..00000000
--- 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 59789064..00000000
--- 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 964f7666..00000000
--- 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 3d1e1f1e..00000000
--- 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 230cef5e..00000000
--- 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 dc589766..00000000
--- 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 6869c54c..00000000
--- 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 f4ab2f79..00000000
--- 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 8ab108f9..00000000
--- 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 5bcbe534..00000000
--- 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 64397cf7..00000000
--- 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 04cbf493..00000000
--- 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 72862e78..00000000
--- 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 08ccc4ac..00000000
--- 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 17b5490f..00000000
--- 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 8a1e74bc..00000000
--- 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 8bc34116..00000000
--- 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 3ac27563..00000000
--- 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 13afa05a..00000000
--- 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 092f3978..00000000
--- 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 b7cfcf59..00000000
--- 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 d64087f9..00000000
--- 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 3563f71e..00000000
--- 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 0534c139..00000000
--- 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 82f140bd..00000000
--- 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 65c00ea0..00000000
--- 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 7c77da51..00000000
--- 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 17204ccb..00000000
--- 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 b94ef8e3..00000000
--- 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 6bddd573..00000000
--- 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 646ba466..00000000
--- 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 f9c24f4c..00000000
--- 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 267f5341..00000000
--- 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 b6ec365c..00000000
--- 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 8094b1ab..00000000
--- 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 38ddc0b0..00000000
--- 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 10fa1601..00000000
--- 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 e32c61d5..00000000
--- 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 341a3d4d..00000000
--- 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 445d2f29..00000000
--- 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 e0b021ba..00000000
--- 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 731484f0..00000000
--- 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 e854be51..00000000
--- 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 3c4fc4c0..00000000
--- 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 3ba976ac..00000000
--- 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 0f909cda..00000000
--- 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 8d767443..00000000
--- 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 2fd34f14..00000000
--- 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 a35fed04..00000000
--- 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 d097af1f..00000000
--- 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 30f38fa2..00000000
--- 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 890a6fb9..00000000
--- 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 e5a9c59e..00000000
--- 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 030ae23f..00000000
--- 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 b18c12d5..00000000
--- 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 8b644dc8..00000000
--- 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 324fe9ee..00000000
--- 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 afade078..00000000
--- 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 ac9773b5..00000000
--- 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 12c685a8..00000000
--- 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 8f040cef..00000000
--- 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 ad7eaae1..00000000
--- 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 ad67f209..00000000
--- 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 58377503..00000000
--- 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 7bdcdcd4..00000000
--- 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 fc47dd39..00000000
--- 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 844fa0e8..00000000
--- 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 106298a1..00000000
--- 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 823da075..00000000
--- 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 84a7ec86..00000000
--- 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 8b958674..00000000
--- 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 5b4f1c57..00000000
--- 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 97ed7307..00000000
--- 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 aee47d6f..00000000
--- 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 dadc3d0c..00000000
--- 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 69e4c466..00000000
--- 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 014934be..00000000
--- 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 c361db16..00000000
--- 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 11957091..00000000
--- 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 e5f5f918..00000000
--- 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 c6552701..00000000
--- 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 e52a1e85..00000000
--- 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 d76ac756..00000000
--- 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 df371e84..00000000
--- 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 b8d5a807..00000000
--- 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 709cbf20..00000000
--- 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 19f82e32..00000000
--- 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 5b3e1c99..00000000
--- 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 6081c46d..00000000
--- 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 563c2807..00000000
--- 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 fbbec788..00000000
--- 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 1f255162..00000000
--- 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 a00e6e20..00000000
--- 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 4cfe720d..00000000
--- 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 c892a8cb..00000000
--- 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 f2d50c10..00000000
--- 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 7b6f79fe..00000000
--- 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 2446de2b..00000000
--- 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 c44b13c7..00000000
--- 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 48432f89..00000000
--- 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 0358acb9..00000000
--- 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 81761a6c..00000000
--- 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 b4e98766..00000000
--- 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 ab15651f..00000000
--- 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 d5f152f4..00000000
--- 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 77fd8a71..00000000
--- 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 231d9c3f..00000000
--- 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 c7ed60b9..00000000
--- 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 5212bf8d..00000000
--- 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 03a53df9..00000000
--- 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 19cda79b..00000000
--- 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 d5b2ad4b..00000000
--- 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 241da34c..00000000
--- 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 a672d94c..00000000
--- 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 6776d6e7..00000000
--- 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 c2a025aa..00000000
--- 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 7669be3b..00000000
--- 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 6c3482e2..00000000
--- 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 933b07e1..00000000
--- 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 0140a1f7..00000000
--- 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 4ff23853..00000000
--- 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 fbc0d80c..00000000
--- 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 4fbd0165..00000000
--- 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 d7242dda..00000000
--- 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 7027b5cb..00000000
--- 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 6c307813..00000000
--- 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 a0e8c386..00000000
--- 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 80a73a82..00000000
--- 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 c49eb3d8..00000000
--- 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 e2fec531..00000000
--- 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 813b55da..00000000
--- 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 58b025a3..00000000
--- 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 87b264d2..00000000
--- 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 8181dd03..00000000
--- 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 dee66bc7..00000000
--- 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 86d24879..00000000
--- 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 2dfa8a0c..00000000
--- 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 69cbe918..00000000
--- 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 4834e823..00000000
--- 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 365b5ad9..00000000
--- 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 dce080e3..00000000
--- 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 8dfca23f..00000000
--- 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 04bfe936..00000000
--- 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 54319b12..00000000
--- 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 145013a6..00000000
--- 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 065fa380..00000000
--- 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 45d6f52f..00000000
--- 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 7806f886..00000000
--- 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 9208fa83..00000000
--- 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 7a279dc6..00000000
--- 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 7cdecd04..00000000
--- 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 146ba0ff..00000000
--- 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 c10423b1..00000000
--- 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 d183d842..00000000
--- 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 52669669..00000000
--- 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 63a9d53d..00000000
--- 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 1164129a..00000000
--- 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 c8968cb8..00000000
--- 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 7fd49d34..00000000
--- 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 9f0dbdab..00000000
--- 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 cae69adb..00000000
--- 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 9fd259c3..00000000
--- 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 69250e75..00000000
--- 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 40b2f137..00000000
--- 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 871ae837..00000000
--- 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 6a64c27c..00000000
--- 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 2db3dd9b..00000000
--- 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 3880d30a..00000000
--- 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 4b5b56e4..00000000
--- 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 90061195..00000000
--- 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 7f456d5e..00000000
--- 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 554fc2d0..00000000
--- 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 e58e5fc3..00000000
--- 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 8b4391cb..00000000
--- 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 a7ced046..00000000
--- 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 99e28dd5..00000000
--- 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 810479cc..00000000
--- 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 e9b67803..00000000
--- 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 89d1bb18..00000000
--- 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 7d7d7466..00000000
--- 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 609463ae..00000000
--- 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 83dcc319..00000000
--- 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 9b710037..00000000
--- 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 f7a36022..00000000
--- 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 d0ffb0b5..00000000
--- 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 61af0ac1..00000000
--- 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 c1d78af7..00000000
--- 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 c8a05c85..00000000
--- 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 efbab7dd..00000000
--- 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 2ce99ec5..00000000
--- 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 c8b81b22..00000000
--- 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 68785379..00000000
--- 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 9db32214..00000000
--- 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 3df05310..00000000
--- 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 d54a699b..00000000
--- 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 3bb4398e..00000000
--- 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 9e6b1be5..00000000
--- 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 9472ffc7..00000000
--- 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 7a539447..00000000
--- 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 8519b175..00000000
--- 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 ba7c1f37..00000000
--- 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 771bb32d..00000000
--- 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 19c04a98..00000000
--- 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 290fd184..00000000
--- 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 bfbdb676..00000000
--- 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 c2b007ab..00000000
--- 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 2f49aea9..00000000
--- 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 2ed76dda..00000000
--- 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 60e806d5..00000000
--- 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 7fce46bc..00000000
--- 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 b9498305..00000000
--- 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 92b22f77..00000000
--- 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 bbca3b9a..00000000
--- 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 fc3d38fa..00000000
--- 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 88283c69..00000000
--- 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 2126e47c..00000000
--- 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 0e9c9283..00000000
--- 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 60072ddf..00000000
--- 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 51285c5e..00000000
--- 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 657d0321..00000000
--- 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 b6f99f8d..00000000
--- 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 3d7ad8c7..00000000
--- 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 3b587dcc..00000000
--- 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 e92abb1f..00000000
--- 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 b7a266ae..00000000
--- 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 42789aee..00000000
--- 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 7bfb2725..00000000
--- 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 8d861580..00000000
--- 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 e61abda7..00000000
--- 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 ba514f43..00000000
--- 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 36adb044..00000000
--- 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 833ace30..00000000
--- 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 586214c8..00000000
--- 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 868819a5..00000000
--- 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 8d17ffaf..00000000
--- 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 2220fce1..00000000
--- 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 74cf5b98..00000000
--- 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 487496f7..00000000
--- 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 21135866..00000000
--- 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 810a34ab..00000000
--- 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 0ff94a56..00000000
--- 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 18bd5d9f..00000000
--- 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 4acf3aaf..00000000
--- 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 5a119410..00000000
--- 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 8043b3b5..00000000
--- 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 f2d3a3e2..00000000
--- 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 0cc17077..00000000
--- 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 5feb8039..00000000
--- 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 a4658e3e..00000000
--- 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 3e27c70a..00000000
--- 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 c1418e3b..00000000
--- 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 042c488b..00000000
--- 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 db31a638..00000000
--- 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 2538b4d4..00000000
--- 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 366cce50..00000000
--- 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 a6bac6c1..00000000
--- 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 631f8874..00000000
--- 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 1b57fc13..00000000
--- 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 6ccc0238..00000000
--- 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 b1b44f0b..00000000
--- 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 9180994b..00000000
--- 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 a308c4ad..00000000
--- 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 f9361997..00000000
--- 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 aa04225e..00000000
--- 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 0085a636..00000000
--- 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/aacenc/inc/aac_rom.h b/media/libstagefright/codecs/aacenc/inc/aac_rom.h
index 8e206b7f..0b6f656a 100644
--- a/media/libstagefright/codecs/aacenc/inc/aac_rom.h
+++ b/media/libstagefright/codecs/aacenc/inc/aac_rom.h
@@ -57,7 +57,7 @@ extern const Word32 mTab_4_3[512];
/*! $2^{-\frac{n}{16}}$ table */
extern const Word16 pow2tominusNover16[17] ;
-extern Word32 specExpMantTableComb_enc[4][14];
+extern const Word32 specExpMantTableComb_enc[4][14];
extern const UWord8 specExpTableComb_enc[4][14];
extern const Word16 quantBorders[4][4];
diff --git a/media/libstagefright/codecs/aacenc/src/aac_rom.c b/media/libstagefright/codecs/aacenc/src/aac_rom.c
index 127322d2..f08f3a97 100644
--- a/media/libstagefright/codecs/aacenc/src/aac_rom.c
+++ b/media/libstagefright/codecs/aacenc/src/aac_rom.c
@@ -1367,7 +1367,7 @@ const Word16 sideInfoTabShort[MAX_SFB_SHORT + 1] = {
10, 10, 10, 10, 10, 13, 13
};
-Word32 specExpMantTableComb_enc[4][14] =
+const Word32 specExpMantTableComb_enc[4][14] =
{
{0x40000000, 0x50a28be6, 0x6597fa95, 0x40000000,
0x50a28be6, 0x6597fa95, 0x40000000, 0x50a28be6,
diff --git a/media/libstagefright/codecs/aacenc/src/block_switch.c b/media/libstagefright/codecs/aacenc/src/block_switch.c
index 47fd15e7..c80538fb 100644
--- a/media/libstagefright/codecs/aacenc/src/block_switch.c
+++ b/media/libstagefright/codecs/aacenc/src/block_switch.c
@@ -51,7 +51,7 @@ CalcWindowEnergy(BLOCK_SWITCHING_CONTROL *blockSwitchingControl,
/*
IIR high pass coeffs
*/
-Word32 hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
+const Word32 hiPassCoeff[BLOCK_SWITCHING_IIR_LEN] = {
0xbec8b439, 0x609d4952 /* -0.5095f, 0.7548f */
};
diff --git a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
index c5f733b3..4d4212f1 100644
--- a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
+++ b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
@@ -154,7 +154,7 @@ OMX_ERRORTYPE SoftAMR::internalGetParameter(
amrParams->nChannels = 1;
amrParams->eAMRDTXMode = OMX_AUDIO_AMRDTXModeOff;
- amrParams->eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatConformance;
+ amrParams->eAMRFrameFormat = OMX_AUDIO_AMRFrameFormatFSF;
if (!isConfigured()) {
amrParams->nBitRate = 0;
diff --git a/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s b/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
index e0b338d5..ac2dd136 100644
--- a/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
+++ b/media/libstagefright/codecs/amrwbenc/src/asm/ARMV5E/pred_lt4_1_opt.s
@@ -44,7 +44,9 @@ pred_lt4_asm:
SUBLT r5, r5, #2 @x--
SUB r5, r5, #30 @x -= 15
RSB r4, r2, #3 @k = 3 - frac
- LDR r6, Table
+ ADRL r8, Table
+ LDR r6, [r8]
+ ADD r6, r8
MOV r8, r4, LSL #6
@MOV r7, #0 @j = 0
ADD r8, r6, r8 @ptr2 = &(inter4_2[k][0])
@@ -451,7 +453,7 @@ pred_lt4_end:
LDMFD r13!, {r4 - r12, r15}
Table:
- .word inter4_2
+ .word inter4_2-Table
@ENDFUNC
.END
diff --git a/media/libstagefright/codecs/avc/enc/Android.mk b/media/libstagefright/codecs/avc/enc/Android.mk
index 845d1d34..cffe4692 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 259562b6..1d661209 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,17 +903,21 @@ void SoftAVCEncoder::onQueueFilled(OMX_U32 portIndex) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
+ releaseGrallocData(srcBuffer);
notifyEmptyBufferDone(inHeader);
outQueue.erase(outQueue.begin());
CHECK(!mInputBufferInfoVec.empty());
InputBufferInfo *inputBufInfo = mInputBufferInfoVec.begin();
- mInputBufferInfoVec.erase(mInputBufferInfoVec.begin());
outHeader->nTimeStamp = inputBufInfo->mTimeUs;
outHeader->nFlags |= (inputBufInfo->mFlags | OMX_BUFFERFLAG_ENDOFFRAME);
+ if (mSawInputEOS) {
+ outHeader->nFlags |= OMX_BUFFERFLAG_EOS;
+ }
outHeader->nFilledLen = dataLength;
outInfo->mOwnedByUs = false;
notifyFillBufferDone(outHeader);
+ mInputBufferInfoVec.erase(mInputBufferInfoVec.begin());
}
}
@@ -884,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 a2587c69..23d5ff19 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 484180d6..865cc9c1 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 a5a23322..e02af90e 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,20 +742,62 @@ void SoftMPEG4Encoder::onQueueFilled(OMX_U32 portIndex) {
inQueue.erase(inQueue.begin());
inInfo->mOwnedByUs = false;
+ releaseGrallocData(srcBuffer);
notifyEmptyBufferDone(inHeader);
outQueue.erase(outQueue.begin());
CHECK(!mInputBufferInfoVec.empty());
InputBufferInfo *inputBufInfo = mInputBufferInfoVec.begin();
- mInputBufferInfoVec.erase(mInputBufferInfoVec.begin());
outHeader->nTimeStamp = inputBufInfo->mTimeUs;
outHeader->nFlags |= (inputBufInfo->mFlags | OMX_BUFFERFLAG_ENDOFFRAME);
outHeader->nFilledLen = dataLength;
+ mInputBufferInfoVec.erase(mInputBufferInfoVec.begin());
outInfo->mOwnedByUs = false;
notifyFillBufferDone(outHeader);
}
}
+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 3e90d54f..cc4ea8f2 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 8f2a3aa5..fb1135cb 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 32238718..0082d7ce 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/codecs/vorbis/dec/SoftVorbis.cpp b/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
index ac881075..fab0b0cc 100644
--- a/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
+++ b/media/libstagefright/codecs/vorbis/dec/SoftVorbis.cpp
@@ -93,7 +93,7 @@ void SoftVorbis::initPorts() {
def.format.audio.pNativeRender = NULL;
def.format.audio.bFlagErrorConcealment = OMX_FALSE;
- def.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
+ def.format.audio.eEncoding = OMX_AUDIO_CodingVORBIS;
addPort(def);
diff --git a/media/libstagefright/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 8673bad9..2704a371 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 a5b316d7..22777a22 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 8b01ac65..dc42f913 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 16c1ca51..a44d8321 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 0cddd2e7..733753b3 100644
--- a/media/libstagefright/httplive/LiveSession.cpp
+++ b/media/libstagefright/httplive/LiveSession.cpp
@@ -55,7 +55,9 @@ LiveSession::LiveSession(uint32_t flags, bool uidValid, uid_t uid)
mSeqNumber(-1),
mSeekTimeUs(-1),
mNumRetries(0),
+ mStartOfPlayback(true),
mDurationUs(-1),
+ mDurationFixed(false),
mSeekDone(false),
mDisconnectPending(false),
mMonitorQueueGeneration(0),
@@ -167,11 +169,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;
@@ -315,6 +313,8 @@ status_t LiveSession::fetchFile(
}
sp<M3UParser> LiveSession::fetchPlaylist(const char *url, bool *unchanged) {
+ ALOGV("fetchPlaylist '%s'", url);
+
*unchanged = false;
sp<ABuffer> buffer;
@@ -368,6 +368,37 @@ sp<M3UParser> LiveSession::fetchPlaylist(const char *url, bool *unchanged) {
return playlist;
}
+int64_t LiveSession::getSegmentStartTimeUs(int32_t seqNumber) const {
+ CHECK(mPlaylist != NULL);
+
+ int32_t firstSeqNumberInPlaylist;
+ if (mPlaylist->meta() == NULL || !mPlaylist->meta()->findInt32(
+ "media-sequence", &firstSeqNumberInPlaylist)) {
+ firstSeqNumberInPlaylist = 0;
+ }
+
+ int32_t lastSeqNumberInPlaylist =
+ firstSeqNumberInPlaylist + (int32_t)mPlaylist->size() - 1;
+
+ CHECK_GE(seqNumber, firstSeqNumberInPlaylist);
+ CHECK_LE(seqNumber, lastSeqNumberInPlaylist);
+
+ int64_t segmentStartUs = 0ll;
+ for (int32_t index = 0;
+ index < seqNumber - firstSeqNumberInPlaylist; ++index) {
+ sp<AMessage> itemMeta;
+ CHECK(mPlaylist->itemAt(
+ index, NULL /* uri */, &itemMeta));
+
+ int64_t itemDurationUs;
+ CHECK(itemMeta->findInt64("durationUs", &itemDurationUs));
+
+ segmentStartUs += itemDurationUs;
+ }
+
+ return segmentStartUs;
+}
+
static double uniformRand() {
return (double)rand() / RAND_MAX;
}
@@ -516,8 +547,6 @@ rinse_repeat:
url = mMasterURL;
}
- bool firstTime = (mPlaylist == NULL);
-
if ((ssize_t)bandwidthIndex != mPrevBandwidthIndex) {
// If we switch bandwidths, do not pay any heed to whether
// playlists changed since the last time...
@@ -539,11 +568,12 @@ rinse_repeat:
mPlaylist = playlist;
}
- if (firstTime) {
+ if (!mDurationFixed) {
Mutex::Autolock autoLock(mLock);
- if (!mPlaylist->isComplete()) {
+ if (!mPlaylist->isComplete() && !mPlaylist->isEvent()) {
mDurationUs = -1;
+ mDurationFixed = true;
} else {
mDurationUs = 0;
for (size_t i = 0; i < mPlaylist->size(); ++i) {
@@ -556,6 +586,8 @@ rinse_repeat:
mDurationUs += itemDurationUs;
}
+
+ mDurationFixed = mPlaylist->isComplete();
}
}
@@ -573,7 +605,7 @@ rinse_repeat:
bool bandwidthChanged = false;
if (mSeekTimeUs >= 0) {
- if (mPlaylist->isComplete()) {
+ if (mPlaylist->isComplete() || mPlaylist->isEvent()) {
size_t index = 0;
int64_t segmentStartUs = 0;
while (index < mPlaylist->size()) {
@@ -621,13 +653,21 @@ rinse_repeat:
mCondition.broadcast();
}
+ const int32_t lastSeqNumberInPlaylist =
+ firstSeqNumberInPlaylist + (int32_t)mPlaylist->size() - 1;
+
if (mSeqNumber < 0) {
- mSeqNumber = firstSeqNumberInPlaylist;
+ if (mPlaylist->isComplete()) {
+ mSeqNumber = firstSeqNumberInPlaylist;
+ } else {
+ // If this is a live session, start 3 segments from the end.
+ mSeqNumber = lastSeqNumberInPlaylist - 3;
+ if (mSeqNumber < firstSeqNumberInPlaylist) {
+ mSeqNumber = firstSeqNumberInPlaylist;
+ }
+ }
}
- int32_t lastSeqNumberInPlaylist =
- firstSeqNumberInPlaylist + (int32_t)mPlaylist->size() - 1;
-
if (mSeqNumber < firstSeqNumberInPlaylist
|| mSeqNumber > lastSeqNumberInPlaylist) {
if (mPrevBandwidthIndex != (ssize_t)bandwidthIndex) {
@@ -690,6 +730,9 @@ rinse_repeat:
range_length = -1;
}
+ ALOGV("fetching segment %d from (%d .. %d)",
+ mSeqNumber, firstSeqNumberInPlaylist, lastSeqNumberInPlaylist);
+
sp<ABuffer> buffer;
status_t err = fetchFile(uri.c_str(), &buffer, range_offset, range_length);
if (err != OK) {
@@ -741,6 +784,11 @@ rinse_repeat:
bandwidthChanged = false;
}
+ if (mStartOfPlayback) {
+ seekDiscontinuity = true;
+ mStartOfPlayback = false;
+ }
+
if (seekDiscontinuity || explicitDiscontinuity || bandwidthChanged) {
// Signal discontinuity.
@@ -751,7 +799,19 @@ rinse_repeat:
memset(tmp->data(), 0, tmp->size());
// signal a 'hard' discontinuity for explicit or bandwidthChanged.
- tmp->data()[1] = (explicitDiscontinuity || bandwidthChanged) ? 1 : 0;
+ uint8_t type = (explicitDiscontinuity || bandwidthChanged) ? 1 : 0;
+
+ if (mPlaylist->isComplete() || mPlaylist->isEvent()) {
+ // If this was a live event this made no sense since
+ // we don't have access to all the segment before the current
+ // one.
+ int64_t segmentStartTimeUs = getSegmentStartTimeUs(mSeqNumber);
+ memcpy(tmp->data() + 2, &segmentStartTimeUs, sizeof(segmentStartTimeUs));
+
+ type |= 2;
+ }
+
+ tmp->data()[1] = type;
mDataSource->queueBuffer(tmp);
}
@@ -927,17 +987,21 @@ void LiveSession::onSeek(const sp<AMessage> &msg) {
postMonitorQueue();
}
-status_t LiveSession::getDuration(int64_t *durationUs) {
+status_t LiveSession::getDuration(int64_t *durationUs) const {
Mutex::Autolock autoLock(mLock);
*durationUs = mDurationUs;
return OK;
}
-bool LiveSession::isSeekable() {
+bool LiveSession::isSeekable() const {
int64_t durationUs;
return getDuration(&durationUs) == OK && durationUs >= 0;
}
+bool LiveSession::hasDynamicDuration() const {
+ return !mDurationFixed;
+}
+
} // namespace android
diff --git a/media/libstagefright/httplive/M3UParser.cpp b/media/libstagefright/httplive/M3UParser.cpp
index 71c63812..68bbca2c 100644
--- a/media/libstagefright/httplive/M3UParser.cpp
+++ b/media/libstagefright/httplive/M3UParser.cpp
@@ -32,7 +32,8 @@ M3UParser::M3UParser(
mBaseURI(baseURI),
mIsExtM3U(false),
mIsVariantPlaylist(false),
- mIsComplete(false) {
+ mIsComplete(false),
+ mIsEvent(false) {
mInitCheck = parse(data, size);
}
@@ -55,6 +56,10 @@ bool M3UParser::isComplete() const {
return mIsComplete;
}
+bool M3UParser::isEvent() const {
+ return mIsEvent;
+}
+
sp<AMessage> M3UParser::meta() {
return mMeta;
}
@@ -197,6 +202,8 @@ status_t M3UParser::parse(const void *_data, size_t size) {
err = parseCipherInfo(line, &itemMeta, mBaseURI);
} else if (line.startsWith("#EXT-X-ENDLIST")) {
mIsComplete = true;
+ } else if (line.startsWith("#EXT-X-PLAYLIST-TYPE:EVENT")) {
+ mIsEvent = true;
} else if (line.startsWith("#EXTINF")) {
if (mIsVariantPlaylist) {
return ERROR_MALFORMED;
diff --git a/media/libstagefright/id3/ID3.cpp b/media/libstagefright/id3/ID3.cpp
index 69274ca4..22c2f5a9 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 68380a87..1422687d 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 00000000..763cd3af
--- /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 00000000..0edafb9b
--- /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 87140084..3028f56a 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/LiveSession.h b/media/libstagefright/include/LiveSession.h
index 3a11612f..f329cc98 100644
--- a/media/libstagefright/include/LiveSession.h
+++ b/media/libstagefright/include/LiveSession.h
@@ -48,8 +48,10 @@ struct LiveSession : public AHandler {
// Blocks until seek is complete.
void seekTo(int64_t timeUs);
- status_t getDuration(int64_t *durationUs);
- bool isSeekable();
+ status_t getDuration(int64_t *durationUs) const;
+
+ bool isSeekable() const;
+ bool hasDynamicDuration() const;
protected:
virtual ~LiveSession();
@@ -95,10 +97,12 @@ private:
int32_t mSeqNumber;
int64_t mSeekTimeUs;
int32_t mNumRetries;
+ bool mStartOfPlayback;
- Mutex mLock;
+ mutable Mutex mLock;
Condition mCondition;
int64_t mDurationUs;
+ bool mDurationFixed; // Duration has been determined once and for all.
bool mSeekDone;
bool mDisconnectPending;
@@ -136,6 +140,10 @@ private:
static int SortByBandwidth(const BandwidthItem *, const BandwidthItem *);
+ // Returns the media time in us of the segment specified by seqNumber.
+ // This is computed by summing the durations of all segments before it.
+ int64_t getSegmentStartTimeUs(int32_t seqNumber) const;
+
DISALLOW_EVIL_CONSTRUCTORS(LiveSession);
};
diff --git a/media/libstagefright/include/M3UParser.h b/media/libstagefright/include/M3UParser.h
index e30d6fdb..2d2f50f2 100644
--- a/media/libstagefright/include/M3UParser.h
+++ b/media/libstagefright/include/M3UParser.h
@@ -33,6 +33,7 @@ struct M3UParser : public RefBase {
bool isExtM3U() const;
bool isVariantPlaylist() const;
bool isComplete() const;
+ bool isEvent() const;
sp<AMessage> meta();
@@ -54,6 +55,7 @@ private:
bool mIsExtM3U;
bool mIsVariantPlaylist;
bool mIsComplete;
+ bool mIsEvent;
sp<AMessage> mMeta;
Vector<Item> mItems;
diff --git a/media/libstagefright/include/WVMExtractor.h b/media/libstagefright/include/WVMExtractor.h
index 2b952e2b..8e629466 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 00000000..869d4acf
--- /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 2cccb4f9..2d8c1e16 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 00000000..451c8376
--- /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 00000000..3699038c
--- /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 00000000..e1ad46e2
--- /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 5f3e3003..4f6c4b27 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,13 +208,21 @@ bool ATSParser::Program::parsePID(
}
*err = mStreams.editValueAt(index)->parse(
- payload_unit_start_indicator, br);
+ continuity_counter, payload_unit_start_indicator, br);
return true;
}
void ATSParser::Program::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ int64_t mediaTimeUs;
+ if ((type & DISCONTINUITY_TIME)
+ && extra != NULL
+ && extra->findInt64(
+ IStreamListener::kKeyMediaTimeUs, &mediaTimeUs)) {
+ mFirstPTSValid = false;
+ }
+
for (size_t i = 0; i < mStreams.size(); ++i) {
mStreams.editValueAt(i)->signalDiscontinuity(type, extra);
}
@@ -241,7 +263,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 +407,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 +446,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 +497,11 @@ ATSParser::Stream::Stream(
ElementaryStreamQueue::MPEG4_VIDEO);
break;
+ case STREAMTYPE_PCM_AUDIO:
+ mQueue = new ElementaryStreamQueue(
+ ElementaryStreamQueue::PCM_AUDIO);
+ break;
+
default:
break;
}
@@ -473,11 +520,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 +599,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 +609,8 @@ bool ATSParser::Stream::isAudio() const {
void ATSParser::Stream::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ mExpectedContinuityCounter = -1;
+
if (mQueue == NULL) {
return;
}
@@ -664,8 +728,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 +844,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 +918,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 +937,21 @@ status_t ATSParser::feedTSPacket(const void *data, size_t size) {
void ATSParser::signalDiscontinuity(
DiscontinuityType type, const sp<AMessage> &extra) {
+ int64_t mediaTimeUs;
+ if ((type & DISCONTINUITY_TIME)
+ && extra != NULL
+ && extra->findInt64(
+ IStreamListener::kKeyMediaTimeUs, &mediaTimeUs)) {
+ mAbsoluteTimeAnchorUs = mediaTimeUs;
+ } else 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 +1031,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 +1092,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 +1110,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 +1184,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 +1232,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 9ef29399..46edc45c 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 1cab077f..82fb6379 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 4035ed3a..66a8087f 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 681e3210..29bc7336 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 fab17710..6cca8da2 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 fb8abc58..9e8725ab 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 d0313cc8..75cd9119 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 00000000..4c9bf5b7
--- /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 00000000..712e18e1
--- /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 f9a44f02..aa8ffc65 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 ddd2f062..462c3841 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 1844bc54..c7a65c20 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/ARTPConnection.cpp b/media/libstagefright/rtsp/ARTPConnection.cpp
index 501a970b..af369b56 100644
--- a/media/libstagefright/rtsp/ARTPConnection.cpp
+++ b/media/libstagefright/rtsp/ARTPConnection.cpp
@@ -117,7 +117,8 @@ void ARTPConnection::MakePortPair(
bumpSocketBufferSize(*rtcpSocket);
- unsigned start = (rand() * 1000)/ RAND_MAX + 15550;
+ /* rand() * 1000 may overflow int type, use long long */
+ unsigned start = (unsigned)((rand()* 1000ll)/RAND_MAX) + 15550;
start &= ~1;
for (unsigned port = start; port < 65536; port += 2) {
diff --git a/media/libstagefright/rtsp/ARTPSource.cpp b/media/libstagefright/rtsp/ARTPSource.cpp
index ed687906..d7c3bd67 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 539a8882..161bd4fb 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 d0f52599..49e2daf0 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 deee30f1..b2f0e5eb 100644
--- a/media/libstagefright/rtsp/MyHandler.h
+++ b/media/libstagefright/rtsp/MyHandler.h
@@ -422,6 +422,9 @@ struct MyHandler : public AHandler {
if (response->mStatusCode != 200) {
result = UNKNOWN_ERROR;
+ } else if (response->mContent == NULL) {
+ result = ERROR_MALFORMED;
+ ALOGE("The response has no content.");
} else {
mSessionDesc = new ASessionDescription;
@@ -1091,6 +1094,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 a1e6be7b..57fff0ba 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 466f5216..a61d6a20 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 42ca1f5b..12fd7f43 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 9b001ccd..9fb0afe7 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 b7e15f8a..ec8ed250 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 1f5d037e..eac23baa 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 9eeab396..598c2006 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 00000000..a5e7ba22
--- /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 00000000..40e93c7c
--- /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 00000000..62a6e7f6
--- /dev/null
+++ b/media/libstagefright/wifi-display/ANetworkSession.cpp
@@ -0,0 +1,1140 @@
+/*
+ * 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();
+
+ uint8_t *data = datagram->data();
+ if (data[0] == 0x80 && (data[1] & 0x7f) == 33) {
+ int64_t nowUs = ALooper::GetNowUs();
+
+ uint32_t prevRtpTime = U32_AT(&data[4]);
+
+ // 90kHz time scale
+ uint32_t rtpTime = (nowUs * 9ll) / 100ll;
+ int32_t diffTime = (int32_t)rtpTime - (int32_t)prevRtpTime;
+
+ ALOGV("correcting rtpTime by %.0f ms", diffTime / 90.0);
+
+ data[4] = rtpTime >> 24;
+ data[5] = (rtpTime >> 16) & 0xff;
+ data[6] = (rtpTime >> 8) & 0xff;
+ data[7] = rtpTime & 0xff;
+ }
+
+ 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) {
+ if (!mOutDatagrams.empty()) {
+ ALOGI("%d datagrams remain queued.", mOutDatagrams.size());
+ }
+ 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 00000000..c1acdcc0
--- /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 00000000..75098f17
--- /dev/null
+++ b/media/libstagefright/wifi-display/Android.mk
@@ -0,0 +1,85 @@
+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 \
+ TimeSeries.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 00000000..f7118b32
--- /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 00000000..a5e787e2
--- /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 00000000..c0e60c39
--- /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 00000000..e9a18599
--- /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/TimeSeries.cpp b/media/libstagefright/wifi-display/TimeSeries.cpp
new file mode 100644
index 00000000..d882d98b
--- /dev/null
+++ b/media/libstagefright/wifi-display/TimeSeries.cpp
@@ -0,0 +1,67 @@
+/*
+ * 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 "TimeSeries.h"
+
+#include <math.h>
+#include <string.h>
+
+namespace android {
+
+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);
+}
+
+} // namespace android
diff --git a/media/libstagefright/wifi-display/TimeSeries.h b/media/libstagefright/wifi-display/TimeSeries.h
new file mode 100644
index 00000000..c818d51f
--- /dev/null
+++ b/media/libstagefright/wifi-display/TimeSeries.h
@@ -0,0 +1,46 @@
+/*
+ * 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 TIME_SERIES_H_
+
+#define TIME_SERIES_H_
+
+#include <sys/types.h>
+
+namespace android {
+
+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;
+};
+
+} // namespace android
+
+#endif // TIME_SERIES_H_
+
diff --git a/media/libstagefright/wifi-display/sink/LinearRegression.cpp b/media/libstagefright/wifi-display/sink/LinearRegression.cpp
new file mode 100644
index 00000000..8cfce37b
--- /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 00000000..ca6f5a1e
--- /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 00000000..09180349
--- /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 00000000..a1d127da
--- /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 00000000..bc35aefa
--- /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 00000000..c9597e0e
--- /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 00000000..fcd20d47
--- /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 00000000..f886ee55
--- /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 00000000..7a874447
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Converter.cpp
@@ -0,0 +1,657 @@
+/*
+ * 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),
+ mNeedToManuallyPrependSPSPPS(false),
+ 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;
+}
+
+bool Converter::needToManuallyPrependSPSPPS() const {
+ return mNeedToManuallyPrependSPSPPS;
+}
+
+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", 15); // Iframes every 15 secs
+
+ // Configure encoder to use intra macroblock refresh mode
+ mOutputFormat->setInt32("intra-refresh-mode", OMX_VIDEO_IntraRefreshCyclic);
+
+ int width, height, mbs;
+ if (!mOutputFormat->findInt32("width", &width)
+ || !mOutputFormat->findInt32("height", &height)) {
+ return ERROR_UNSUPPORTED;
+ }
+
+ // Update macroblocks in a cyclic fashion with 10% of all MBs within
+ // frame gets updated at one time. It takes about 10 frames to
+ // completely update a whole video frame. If the frame rate is 30,
+ // it takes about 333 ms in the best case (if next frame is not an IDR)
+ // to recover from a lost/corrupted packet.
+ mbs = (((width + 15) / 16) * ((height + 15) / 16) * 10) / 100;
+ mOutputFormat->setInt32("intra-refresh-CIR-mbs", mbs);
+ }
+
+ ALOGV("output format is '%s'", mOutputFormat->debugString(0).c_str());
+
+ mNeedToManuallyPrependSPSPPS = false;
+
+ status_t err = NO_INIT;
+
+ if (!isAudio) {
+ sp<AMessage> tmp = mOutputFormat->dup();
+ tmp->setInt32("prepend-sps-pps-to-idr-frames", 1);
+
+ err = mEncoder->configure(
+ tmp,
+ NULL /* nativeWindow */,
+ NULL /* crypto */,
+ MediaCodec::CONFIGURE_FLAG_ENCODE);
+
+ if (err == OK) {
+ // Encoder supported prepending SPS/PPS, we don't need to emulate
+ // it.
+ mOutputFormat = tmp;
+ } else {
+ mNeedToManuallyPrependSPSPPS = true;
+
+ ALOGI("We going to manually prepend SPS and PPS to IDR frames.");
+ }
+ }
+
+ if (err != OK) {
+ // We'll get here for audio or if we failed to configure the encoder
+ // to automatically prepend SPS/PPS in the case of video.
+
+ 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 00000000..0665eea7
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Converter.h
@@ -0,0 +1,124 @@
+/*
+ * 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;
+ bool needToManuallyPrependSPSPPS() 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;
+ bool mNeedToManuallyPrependSPSPPS;
+
+ 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 00000000..189bea36
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/MediaPuller.cpp
@@ -0,0 +1,221 @@
+/*
+ * 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),
+ mPaused(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::pause() {
+ (new AMessage(kWhatPause, id()))->post();
+}
+
+void MediaPuller::resume() {
+ (new AMessage(kWhatResume, id()))->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 (mPaused) {
+ if (err == OK) {
+ mbuf->release();
+ mbuf = NULL;
+ }
+
+ schedulePull();
+ break;
+ }
+
+ 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;
+ }
+
+ case kWhatPause:
+ {
+ mPaused = true;
+ break;
+ }
+
+ case kWhatResume:
+ {
+ mPaused = false;
+ 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 00000000..1291bb3f
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/MediaPuller.h
@@ -0,0 +1,68 @@
+/*
+ * 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);
+
+ void pause();
+ void resume();
+
+protected:
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+ virtual ~MediaPuller();
+
+private:
+ enum {
+ kWhatStart,
+ kWhatStop,
+ kWhatPull,
+ kWhatPause,
+ kWhatResume,
+ };
+
+ sp<MediaSource> mSource;
+ sp<AMessage> mNotify;
+ int32_t mPullGeneration;
+ bool mIsAudio;
+ bool mPaused;
+
+ 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 00000000..916f7978
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.cpp
@@ -0,0 +1,1062 @@
+/*
+ * 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 "WifiDisplaySource.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 pause();
+ void resume();
+
+ void queueAccessUnit(const sp<ABuffer> &accessUnit);
+ sp<ABuffer> dequeueAccessUnit();
+
+ bool hasOutputBuffer(int64_t *timeUs) const;
+ void queueOutputBuffer(const sp<ABuffer> &accessUnit);
+ sp<ABuffer> dequeueOutputBuffer();
+
+#if SUSPEND_VIDEO_IF_IDLE
+ bool isSuspended() const;
+#endif
+
+ 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::pause() {
+ mMediaPuller->pause();
+}
+
+void WifiDisplaySource::PlaybackSession::Track::resume() {
+ mMediaPuller->resume();
+}
+
+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;
+}
+
+#if SUSPEND_VIDEO_IF_IDLE
+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;
+}
+#endif
+
+////////////////////////////////////////////////////////////////////////////////
+
+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),
+ mPaused(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();
+
+ (new AMessage(kWhatResume, id()))->post();
+
+ 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();
+
+ (new AMessage(kWhatPause, id()))->post();
+
+ 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) {
+ sp<AMessage> trackFormat = track->getFormat()->dup();
+ if (mHDCP != NULL && !track->isAudio()) {
+ // HDCP2.0 _and_ HDCP 2.1 specs say to set the version
+ // inside the HDCP descriptor to 0x20!!!
+ trackFormat->setInt32("hdcp-version", 0x20);
+ }
+ packetizerTrackIndex = mPacketizer->addTrack(trackFormat);
+
+ 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;
+ }
+
+ case kWhatPause:
+ {
+ if (mPaused) {
+ break;
+ }
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ mTracks.editValueAt(i)->pause();
+ }
+
+ mPaused = true;
+ break;
+ }
+
+ case kWhatResume:
+ {
+ if (!mPaused) {
+ break;
+ }
+
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ mTracks.editValueAt(i)->resume();
+ }
+
+ mPaused = false;
+ 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);
+
+ err = converter->initCheck();
+ if (err != OK) {
+ ALOGE("%s converter returned err %d", isVideo ? "video" : "audio", err);
+ return err;
+ }
+
+ 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 {
+#if USE_1080P
+ return 1920;
+#else
+ return 1280;
+#endif
+}
+
+int32_t WifiDisplaySource::PlaybackSession::height() const {
+#if USE_1080P
+ return 1080;
+#else
+ return 720;
+#endif
+}
+
+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, 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];
+
+ bool manuallyPrependSPSPPS =
+ !track->isAudio()
+ && track->converter()->needToManuallyPrependSPSPPS()
+ && IsIDR(accessUnit);
+
+ if (mHDCP != NULL && !track->isAudio()) {
+ isHDCPEncrypted = true;
+
+ if (manuallyPrependSPSPPS) {
+ accessUnit = mPacketizer->prependCSD(
+ track->packetizerTrackIndex(), accessUnit);
+ }
+
+ 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;
+ } else if (manuallyPrependSPSPPS) {
+ flags |= TSPacketizer::PREPEND_SPS_PPS_TO_IDR_FRAMES;
+ }
+
+ 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;
+ }
+ }
+#if SUSPEND_VIDEO_IF_IDLE
+ 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;
+ }
+#else
+ else {
+ // We need access units available on all tracks to be able to
+ // dequeue the earliest one.
+ return false;
+ }
+#endif
+ }
+
+ 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();
+ return false;
+ }
+
+ if ((ssize_t)minTrackIndex == mVideoTrackIndex) {
+ packets->meta()->setInt32("isVideo", 1);
+ }
+ mSender->queuePackets(minTimeUs, packets);
+
+#if 0
+ if (minTrackIndex == mVideoTrackIndex) {
+ int64_t nowUs = ALooper::GetNowUs();
+
+ // Latency from "data acquired" to "ready to send if we wanted to".
+ ALOGI("[%s] latencyUs = %lld ms",
+ minTrackIndex == mVideoTrackIndex ? "video" : "audio",
+ (nowUs - minTimeUs) / 1000ll);
+ }
+#endif
+
+ 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 00000000..b9d193bf
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/PlaybackSession.h
@@ -0,0 +1,151 @@
+/*
+ * 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,
+ kWhatPause,
+ kWhatResume,
+ };
+
+ sp<ANetworkSession> mNetSession;
+ sp<Sender> mSender;
+ sp<ALooper> mSenderLooper;
+ sp<AMessage> mNotify;
+ in_addr mInterfaceAddr;
+ sp<IHDCP> mHDCP;
+ bool mWeAreDead;
+ bool mPaused;
+
+ 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, 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 00000000..72be9273
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.cpp
@@ -0,0 +1,199 @@
+//#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;
+ }
+
+#if SUSPEND_VIDEO_IF_IDLE
+ int64_t nowUs = ALooper::GetNowUs();
+ if (nowUs - mLastBufferUpdateUs > 1000000ll) {
+ mLastBufferUpdateUs = -1ll;
+ stale = true;
+ } else
+#endif
+ {
+ 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 00000000..a13973c3
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/RepeaterSource.h
@@ -0,0 +1,64 @@
+#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>
+
+#define SUSPEND_VIDEO_IF_IDLE 1
+
+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 00000000..90486917
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Sender.cpp
@@ -0,0 +1,870 @@
+/*
+ * 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 "TimeSeries.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 {
+
+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),
+ mTransportMode(TRANSPORT_UDP),
+ mRTPChannel(0),
+ mRTCPChannel(0),
+ mRTPPort(0),
+ mRTPSessionID(0),
+ mRTCPSessionID(0),
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ mRTPRetransmissionSessionID(0),
+ mRTCPRetransmissionSessionID(0),
+#endif
+ mClientRTPPort(0),
+ mClientRTCPPort(0),
+ mRTPConnected(false),
+ mRTCPConnected(false),
+ mFirstOutputBufferReadyTimeUs(-1ll),
+ mFirstOutputBufferSentTimeUs(-1ll),
+ mRTPSeqNo(0),
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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
+{
+#if LOG_TRANSPORT_STREAM
+ mLogFile = fopen("/system/etc/log.ts", "wb");
+#endif
+}
+
+Sender::~Sender() {
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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> &tsPackets) {
+ const size_t numTSPackets = tsPackets->size() / 188;
+
+ const size_t numRTPPackets =
+ (numTSPackets + kMaxNumTSPacketsPerRTPPacket - 1)
+ / kMaxNumTSPacketsPerRTPPacket;
+
+ sp<ABuffer> udpPackets = new ABuffer(
+ numRTPPackets * (12 + kMaxNumTSPacketsPerRTPPacket * 188));
+
+ udpPackets->meta()->setInt64("timeUs", timeUs);
+
+ size_t dstOffset = 0;
+ for (size_t i = 0; i < numTSPackets; ++i) {
+ if ((i % kMaxNumTSPacketsPerRTPPacket) == 0) {
+ static const bool kMarkerBit = false;
+
+ uint8_t *rtp = udpPackets->data() + dstOffset;
+ rtp[0] = 0x80;
+ rtp[1] = 33 | (kMarkerBit ? (1 << 7) : 0); // M-bit
+ rtp[2] = (mRTPSeqNo >> 8) & 0xff;
+ rtp[3] = mRTPSeqNo & 0xff;
+ rtp[4] = 0x00; // rtp time to be filled in later.
+ rtp[5] = 0x00;
+ rtp[6] = 0x00;
+ rtp[7] = 0x00;
+ rtp[8] = kSourceID >> 24;
+ rtp[9] = (kSourceID >> 16) & 0xff;
+ rtp[10] = (kSourceID >> 8) & 0xff;
+ rtp[11] = kSourceID & 0xff;
+
+ ++mRTPSeqNo;
+
+ dstOffset += 12;
+ }
+
+ memcpy(udpPackets->data() + dstOffset,
+ tsPackets->data() + 188 * i,
+ 188);
+
+ dstOffset += 188;
+ }
+
+ udpPackets->setRange(0, dstOffset);
+
+ sp<AMessage> msg = new AMessage(kWhatDrainQueue, id());
+ msg->setBuffer("udpPackets", udpPackets);
+ msg->post();
+
+#if LOG_TRANSPORT_STREAM
+ if (mLogFile != NULL) {
+ fwrite(tsPackets->data(), 1, tsPackets->size(), mLogFile);
+ }
+#endif
+}
+
+void Sender::onMessageReceived(const sp<AMessage> &msg) {
+ switch (msg->what()) {
+ case kWhatRTPNotify:
+ case kWhatRTCPNotify:
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ || 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ || 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 kWhatDrainQueue:
+ {
+ sp<ABuffer> udpPackets;
+ CHECK(msg->findBuffer("udpPackets", &udpPackets));
+
+ onDrainQueue(udpPackets);
+ break;
+ }
+
+ case kWhatSendSR:
+ {
+ mSendSRPending = false;
+
+ if (mRTCPSessionID == 0) {
+ break;
+ }
+
+ onSendSR();
+
+ scheduleSendSR();
+ break;
+ }
+ }
+}
+
+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);
+
+#if RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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());
+#else
+ sendPacket(
+ mRTPSessionID, buffer->data(), buffer->size());
+#endif
+
+ 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();
+}
+
+void Sender::onDrainQueue(const sp<ABuffer> &udpPackets) {
+ static const size_t kFullRTPPacketSize =
+ 12 + 188 * kMaxNumTSPacketsPerRTPPacket;
+
+ size_t srcOffset = 0;
+ while (srcOffset < udpPackets->size()) {
+ uint8_t *rtp = udpPackets->data() + srcOffset;
+
+ size_t rtpPacketSize = udpPackets->size() - srcOffset;
+ if (rtpPacketSize > kFullRTPPacketSize) {
+ rtpPacketSize = kFullRTPPacketSize;
+ }
+
+ int64_t nowUs = ALooper::GetNowUs();
+ mLastNTPTime = GetNowNTP();
+
+ // 90kHz time scale
+ uint32_t rtpTime = (nowUs * 9ll) / 100ll;
+
+ rtp[4] = rtpTime >> 24;
+ rtp[5] = (rtpTime >> 16) & 0xff;
+ rtp[6] = (rtpTime >> 8) & 0xff;
+ rtp[7] = rtpTime & 0xff;
+
+ ++mNumRTPSent;
+ mNumRTPOctetsSent += rtpPacketSize - 12;
+
+ mLastRTPTime = rtpTime;
+
+ if (mTransportMode == TRANSPORT_TCP_INTERLEAVED) {
+ sp<AMessage> notify = mNotify->dup();
+ notify->setInt32("what", kWhatBinaryData);
+
+ sp<ABuffer> data = new ABuffer(rtpPacketSize);
+ memcpy(data->data(), rtp, rtpPacketSize);
+
+ notify->setInt32("channel", mRTPChannel);
+ notify->setBuffer("data", data);
+ notify->post();
+ } else {
+ sendPacket(mRTPSessionID, rtp, rtpPacketSize);
+
+#if TRACK_BANDWIDTH
+ mTotalBytesSent += rtpPacketSize->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
+ addToHistory(rtp, rtpPacketSize);
+#endif
+
+ srcOffset += rtpPacketSize;
+ }
+
+#if 0
+ int64_t timeUs;
+ CHECK(udpPackets->meta()->findInt64("timeUs", &timeUs));
+
+ ALOGI("dTimeUs = %lld us", ALooper::GetNowUs() - timeUs);
+#endif
+}
+
+#if ENABLE_RETRANSMISSION
+void Sender::addToHistory(const uint8_t *rtp, size_t rtpPacketSize) {
+ sp<ABuffer> packet = new ABuffer(rtpPacketSize);
+ memcpy(packet->data(), rtp, rtpPacketSize);
+
+ unsigned rtpSeqNo = U16_AT(&rtp[2]);
+ packet->setInt32Data(rtpSeqNo);
+
+ mHistory.push_back(packet);
+ ++mHistoryLength;
+
+ if (mHistoryLength > kMaxHistoryLength) {
+ mHistory.erase(mHistory.begin());
+ --mHistoryLength;
+ }
+}
+#endif
+
+} // 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 00000000..66951f7d
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/Sender.h
@@ -0,0 +1,169 @@
+/*
+ * 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 TRACK_BANDWIDTH 0
+
+#define ENABLE_RETRANSMISSION 1
+
+// If retransmission is enabled the following define determines what
+// kind we support, if RETRANSMISSION_ACCORDING_TO_RFC_XXXX is 0
+// we'll send NACKs on the original RTCP channel and retransmit packets
+// on the original RTP channel, otherwise a separate channel pair is used
+// for this purpose.
+#define RETRANSMISSION_ACCORDING_TO_RFC_XXXX 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> &tsPackets);
+ void scheduleSendSR();
+
+protected:
+ virtual ~Sender();
+ virtual void onMessageReceived(const sp<AMessage> &msg);
+
+private:
+ enum {
+ kWhatDrainQueue,
+ kWhatSendSR,
+ kWhatRTPNotify,
+ kWhatRTCPNotify,
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ kWhatRTPRetransmissionNotify,
+ kWhatRTCPRetransmissionNotify,
+#endif
+ };
+
+ static const int64_t kSendSRIntervalUs = 10000000ll;
+
+ static const uint32_t kSourceID = 0xdeadbeef;
+ static const size_t kMaxHistoryLength = 128;
+
+#if ENABLE_RETRANSMISSION && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ static const size_t kRetransmissionPortOffset = 120;
+#endif
+
+ sp<ANetworkSession> mNetSession;
+ sp<AMessage> mNotify;
+
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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 && RETRANSMISSION_ACCORDING_TO_RFC_XXXX
+ 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
+
+#if LOG_TRANSPORT_STREAM
+ FILE *mLogFile;
+#endif
+
+ void onSendSR();
+ void addSR(const sp<ABuffer> &buffer);
+ void addSDES(const sp<ABuffer> &buffer);
+ static uint64_t GetNowNTP();
+
+#if ENABLE_RETRANSMISSION
+ status_t parseTSFB(const uint8_t *data, size_t size);
+ void addToHistory(const uint8_t *rtp, size_t rtpPacketSize);
+#endif
+
+ status_t parseRTCP(const sp<ABuffer> &buffer);
+
+ status_t sendPacket(int32_t sessionID, const void *data, size_t size);
+
+ void notifyInitDone();
+ void notifySessionDead();
+
+ void onDrainQueue(const sp<ABuffer> &udpPackets);
+
+ 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 00000000..ef57a4d5
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/TSPacketizer.cpp
@@ -0,0 +1,883 @@
+/*
+ * 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);
+ }
+
+ int32_t hdcpVersion;
+ if (mFormat->findInt32("hdcp-version", &hdcpVersion)) {
+ // HDCP descriptor
+
+ CHECK(hdcpVersion == 0x20 || hdcpVersion == 0x21);
+
+ sp<ABuffer> descriptor = new ABuffer(7);
+ uint8_t *data = descriptor->data();
+ data[0] = 0x05; // descriptor_tag
+ data[1] = 5; // descriptor_length
+ data[2] = 'H';
+ data[3] = 'D';
+ data[4] = 'C';
+ data[5] = 'P';
+ data[6] = hdcpVersion;
+
+ 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 00000000..a37917dd
--- /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 00000000..08f67f9c
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.cpp
@@ -0,0 +1,1596 @@
+/*
+ * 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() {
+}
+
+static status_t PostAndAwaitResponse(
+ const sp<AMessage> &msg, sp<AMessage> *response) {
+ status_t err = msg->postAndAwaitResponse(response);
+
+ if (err != OK) {
+ return err;
+ }
+
+ if (response == NULL || !(*response)->findInt32("err", &err)) {
+ err = OK;
+ }
+
+ return err;
+}
+
+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;
+ return PostAndAwaitResponse(msg, &response);
+}
+
+status_t WifiDisplaySource::stop() {
+ sp<AMessage> msg = new AMessage(kWhatStop, id());
+
+ sp<AMessage> response;
+ return PostAndAwaitResponse(msg, &response);
+}
+
+status_t WifiDisplaySource::pause() {
+ sp<AMessage> msg = new AMessage(kWhatPause, id());
+
+ sp<AMessage> response;
+ return PostAndAwaitResponse(msg, &response);
+}
+
+status_t WifiDisplaySource::resume() {
+ sp<AMessage> msg = new AMessage(kWhatResume, id());
+
+ sp<AMessage> response;
+ return PostAndAwaitResponse(msg, &response);
+}
+
+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);
+ }
+
+#if 0
+ // testing only.
+ char val[PROPERTY_VALUE_MAX];
+ if (property_get("media.wfd.trigger", val, NULL)) {
+ if (!strcasecmp(val, "pause") && mState == PLAYING) {
+ mState = PLAYING_TO_PAUSED;
+ sendTrigger(mClientSessionID, TRIGGER_PAUSE);
+ } else if (!strcasecmp(val, "play") && mState == PAUSED) {
+ mState = PAUSED_TO_PLAYING;
+ sendTrigger(mClientSessionID, TRIGGER_PLAY);
+ }
+ }
+#endif
+ 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 = sendTrigger(
+ mClientSessionID, TRIGGER_TEARDOWN);
+
+ if (err == OK) {
+ mState = AWAITING_CLIENT_TEARDOWN;
+
+ (new AMessage(kWhatTeardownTriggerTimedOut, id()))->post(
+ kTeardownTriggerTimeouSecs * 1000000ll);
+
+ break;
+ }
+
+ // fall through.
+ }
+
+ finishStop();
+ break;
+ }
+
+ case kWhatPause:
+ {
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ status_t err = OK;
+
+ if (mState != PLAYING) {
+ err = INVALID_OPERATION;
+ } else {
+ mState = PLAYING_TO_PAUSED;
+ sendTrigger(mClientSessionID, TRIGGER_PAUSE);
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", err);
+ response->postReply(replyID);
+ break;
+ }
+
+ case kWhatResume:
+ {
+ uint32_t replyID;
+ CHECK(msg->senderAwaitsResponse(&replyID));
+
+ status_t err = OK;
+
+ if (mState != PAUSED) {
+ err = INVALID_OPERATION;
+ } else {
+ mState = PAUSED_TO_PLAYING;
+ sendTrigger(mClientSessionID, TRIGGER_PLAY);
+ }
+
+ sp<AMessage> response = new AMessage;
+ response->setInt32("err", err);
+ response->postReply(replyID);
+ 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;
+
+ sendTrigger(mClientSessionID, TRIGGER_SETUP);
+ }
+ 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"
+ // For 1080p30:
+ // use "38 00 02 02 00000080 00000000 00000000 00 0000 0000 00 none none\r\n"
+ AString body = StringPrintf(
+ "wfd_video_formats: "
+#if USE_1080P
+ "38 00 02 02 00000080 00000000 00000000 00 0000 0000 00 none none\r\n"
+#else
+ "28 00 02 02 00000020 00000000 00000000 00 0000 0000 00 none none\r\n"
+#endif
+ "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::sendTrigger(
+ int32_t sessionID, TriggerType triggerType) {
+ AString body = "wfd_trigger_method: ";
+ switch (triggerType) {
+ case TRIGGER_SETUP:
+ body.append("SETUP");
+ break;
+ case TRIGGER_TEARDOWN:
+ ALOGI("Sending TEARDOWN trigger.");
+ body.append("TEARDOWN");
+ break;
+ case TRIGGER_PAUSE:
+ body.append("PAUSE");
+ break;
+ case TRIGGER_PLAY:
+ body.append("PLAY");
+ break;
+ default:
+ TRESPASS();
+ }
+
+ 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. "
+ "Not using HDCP after all.");
+
+ mUsingHDCP = false;
+ }
+ }
+
+ 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 sendTrigger(sessionID, TRIGGER_SETUP);
+}
+
+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;
+ }
+
+ if (mState == PAUSED_TO_PLAYING) {
+ mState = PLAYING;
+ return OK;
+ }
+
+ 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;
+ }
+
+ ALOGI("Received PAUSE request.");
+
+ if (mState != PLAYING_TO_PAUSED) {
+ return INVALID_OPERATION;
+ }
+
+ 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());
+
+ if (err != OK) {
+ return err;
+ }
+
+ mState = PAUSED;
+
+ 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 00000000..974e0708
--- /dev/null
+++ b/media/libstagefright/wifi-display/source/WifiDisplaySource.h
@@ -0,0 +1,253 @@
+/*
+ * 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 {
+
+#define USE_1080P 0
+
+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();
+
+ status_t pause();
+ status_t resume();
+
+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,
+ PLAYING_TO_PAUSED,
+ PAUSED,
+ PAUSED_TO_PLAYING,
+ AWAITING_CLIENT_TEARDOWN,
+ STOPPING,
+ STOPPED,
+ };
+
+ enum {
+ kWhatStart,
+ kWhatRTSPNotify,
+ kWhatStop,
+ kWhatPause,
+ kWhatResume,
+ 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);
+
+ enum TriggerType {
+ TRIGGER_SETUP,
+ TRIGGER_TEARDOWN,
+ TRIGGER_PAUSE,
+ TRIGGER_PLAY,
+ };
+
+ // M5
+ status_t sendTrigger(int32_t sessionID, TriggerType triggerType);
+
+ 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 00000000..1cd82c32
--- /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 00000000..03a1123d
--- /dev/null
+++ b/media/libstagefright/wifi-display/wfd.cpp
@@ -0,0 +1,301 @@
+/*
+ * 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 <gui/SurfaceComposerClient.h>
+#include <media/AudioSystem.h>
+#include <media/IMediaPlayerService.h>
+#include <media/IRemoteDisplay.h>
+#include <media/IRemoteDisplayClient.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/foundation/ADebug.h>
+
+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"
+ " -l ip[:port] \tlisten on the specified port "
+ "(create a sink)\n",
+ me);
+}
+
+struct RemoteDisplayClient : public BnRemoteDisplayClient {
+ RemoteDisplayClient();
+
+ virtual void onDisplayConnected(
+ const sp<ISurfaceTexture> &surfaceTexture,
+ uint32_t width,
+ uint32_t height,
+ uint32_t flags);
+
+ virtual void onDisplayDisconnected();
+ virtual void onDisplayError(int32_t error);
+
+ void waitUntilDone();
+
+protected:
+ virtual ~RemoteDisplayClient();
+
+private:
+ Mutex mLock;
+ Condition mCondition;
+
+ bool mDone;
+
+ sp<SurfaceComposerClient> mComposerClient;
+ sp<ISurfaceTexture> mSurfaceTexture;
+ sp<IBinder> mDisplayBinder;
+
+ DISALLOW_EVIL_CONSTRUCTORS(RemoteDisplayClient);
+};
+
+RemoteDisplayClient::RemoteDisplayClient()
+ : mDone(false) {
+ mComposerClient = new SurfaceComposerClient;
+ CHECK_EQ(mComposerClient->initCheck(), (status_t)OK);
+}
+
+RemoteDisplayClient::~RemoteDisplayClient() {
+}
+
+void RemoteDisplayClient::onDisplayConnected(
+ const sp<ISurfaceTexture> &surfaceTexture,
+ uint32_t width,
+ uint32_t height,
+ uint32_t flags) {
+ ALOGI("onDisplayConnected width=%u, height=%u, flags = 0x%08x",
+ width, height, flags);
+
+ mSurfaceTexture = surfaceTexture;
+ mDisplayBinder = mComposerClient->createDisplay(
+ String8("foo"), false /* secure */);
+
+ SurfaceComposerClient::openGlobalTransaction();
+ mComposerClient->setDisplaySurface(mDisplayBinder, mSurfaceTexture);
+
+ Rect layerStackRect(1280, 720); // XXX fix this.
+ Rect displayRect(1280, 720);
+
+ mComposerClient->setDisplayProjection(
+ mDisplayBinder, 0 /* 0 degree rotation */,
+ layerStackRect,
+ displayRect);
+
+ SurfaceComposerClient::closeGlobalTransaction();
+}
+
+void RemoteDisplayClient::onDisplayDisconnected() {
+ ALOGI("onDisplayDisconnected");
+
+ Mutex::Autolock autoLock(mLock);
+ mDone = true;
+ mCondition.broadcast();
+}
+
+void RemoteDisplayClient::onDisplayError(int32_t error) {
+ ALOGI("onDisplayError error=%d", error);
+
+ Mutex::Autolock autoLock(mLock);
+ mDone = true;
+ mCondition.broadcast();
+}
+
+void RemoteDisplayClient::waitUntilDone() {
+ Mutex::Autolock autoLock(mLock);
+ while (!mDone) {
+ mCondition.wait(mLock);
+ }
+}
+
+static status_t enableAudioSubmix(bool enable) {
+ status_t err = AudioSystem::setDeviceConnectionState(
+ AUDIO_DEVICE_IN_REMOTE_SUBMIX,
+ enable
+ ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE
+ : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ NULL /* device_address */);
+
+ if (err != OK) {
+ return err;
+ }
+
+ err = AudioSystem::setDeviceConnectionState(
+ AUDIO_DEVICE_OUT_REMOTE_SUBMIX,
+ enable
+ ? AUDIO_POLICY_DEVICE_STATE_AVAILABLE
+ : AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE,
+ NULL /* device_address */);
+
+ return err;
+}
+
+static void createSource(const AString &addr, int32_t port) {
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("media.player"));
+ sp<IMediaPlayerService> service =
+ interface_cast<IMediaPlayerService>(binder);
+
+ CHECK(service.get() != NULL);
+
+ enableAudioSubmix(true /* enable */);
+
+ String8 iface;
+ iface.append(addr.c_str());
+ iface.append(StringPrintf(":%d", port).c_str());
+
+ sp<RemoteDisplayClient> client = new RemoteDisplayClient;
+ sp<IRemoteDisplay> display = service->listenForRemoteDisplay(client, iface);
+
+ client->waitUntilDone();
+
+ display->dispose();
+ display.clear();
+
+ enableAudioSubmix(false /* enable */);
+}
+
+} // namespace android
+
+int main(int argc, char **argv) {
+ using namespace android;
+
+ ProcessState::self()->startThreadPool();
+
+ DataSource::RegisterDefaultSniffers();
+
+ AString connectToHost;
+ int32_t connectToPort = -1;
+ AString uri;
+
+ AString listenOnAddr;
+ int32_t listenOnPort = -1;
+
+ 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 'l':
+ {
+ const char *colonPos = strrchr(optarg, ':');
+
+ if (colonPos == NULL) {
+ listenOnAddr = optarg;
+ listenOnPort = WifiDisplaySource::kWifiDisplayDefaultPort;
+ } else {
+ listenOnAddr.setTo(optarg, colonPos - optarg);
+
+ char *end;
+ listenOnPort = strtol(colonPos + 1, &end, 10);
+
+ if (*end != '\0' || end == colonPos + 1
+ || listenOnPort < 1 || listenOnPort > 65535) {
+ fprintf(stderr, "Illegal port specified.\n");
+ exit(1);
+ }
+ }
+ break;
+ }
+
+ case '?':
+ case 'h':
+ default:
+ usage(argv[0]);
+ exit(1);
+ }
+ }
+
+ if (connectToPort >= 0 && listenOnPort >= 0) {
+ fprintf(stderr,
+ "You can connect to a source or create one, "
+ "but not both at the same time.\n");
+ exit(1);
+ }
+
+ if (listenOnPort >= 0) {
+ createSource(listenOnAddr, listenOnPort);
+ exit(0);
+ }
+
+ 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 6b1abb1b..ddd5b842 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/Android.mk b/media/mtp/Android.mk
index fc7fc4fc..bee28d42 100644
--- a/media/mtp/Android.mk
+++ b/media/mtp/Android.mk
@@ -45,31 +45,3 @@ LOCAL_C_INCLUDES := bionic/libc/private
LOCAL_SHARED_LIBRARIES := libutils libcutils libusbhost libbinder
include $(BUILD_SHARED_LIBRARY)
-
-ifeq ($(HOST_OS),linux)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:= \
- MtpDataPacket.cpp \
- MtpDebug.cpp \
- MtpDevice.cpp \
- MtpEventPacket.cpp \
- MtpDeviceInfo.cpp \
- MtpObjectInfo.cpp \
- MtpPacket.cpp \
- MtpProperty.cpp \
- MtpRequestPacket.cpp \
- MtpResponsePacket.cpp \
- MtpStorageInfo.cpp \
- MtpStringBuffer.cpp \
- MtpStorage.cpp \
- MtpUtils.cpp \
-
-LOCAL_MODULE:= libmtp
-
-LOCAL_CFLAGS := -DMTP_HOST
-
-include $(BUILD_HOST_STATIC_LIBRARY)
-
-endif
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index bf7795cb..d672dffb 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 56061872..662a93dc 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;
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk
index 8473fabf..28999533 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -13,40 +13,14 @@ include $(BUILD_STATIC_LIBRARY)
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
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
LOCAL_SRC_FILES:= \
AudioFlinger.cpp \
AudioMixer.cpp.arm \
AudioResampler.cpp.arm \
AudioPolicyService.cpp \
- ServiceUtilities.cpp
-# AudioResamplerSinc.cpp.arm
-# AudioResamplerCubic.cpp.arm
+ ServiceUtilities.cpp \
+ AudioResamplerCubic.cpp.arm \
+ AudioResamplerSinc.cpp.arm
LOCAL_SRC_FILES += StateQueue.cpp
@@ -66,6 +40,7 @@ LOCAL_SHARED_LIBRARIES := \
libbinder \
libmedia \
libmedia_native \
+ libnbaio \
libhardware \
libhardware_legacy \
libeffects \
@@ -74,7 +49,6 @@ LOCAL_SHARED_LIBRARIES := \
LOCAL_STATIC_LIBRARIES := \
libscheduling_policy \
- libnbaio \
libcpustats \
libmedia_helper
@@ -89,7 +63,7 @@ LOCAL_CFLAGS += -DFAST_MIXER_STATISTICS
LOCAL_CFLAGS += -DSTATE_QUEUE_INSTANTIATIONS='"StateQueueInstantiations.cpp"'
-LOCAL_CFLAGS += -DHAVE_REQUEST_PRIORITY -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE -USOAKER
+LOCAL_CFLAGS += -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE
# uncomment for systrace
# LOCAL_CFLAGS += -DATRACE_TAG=ATRACE_TAG_AUDIO
@@ -99,7 +73,32 @@ LOCAL_CFLAGS += -DHAVE_REQUEST_PRIORITY -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE
# LOCAL_CFLAGS += -DTEE_SINK_FRAMES=0x200000
# uncomment to enable the audio watchdog
-LOCAL_SRC_FILES += AudioWatchdog.cpp
-LOCAL_CFLAGS += -DAUDIO_WATCHDOG
+# LOCAL_SRC_FILES += AudioWatchdog.cpp
+# LOCAL_CFLAGS += -DAUDIO_WATCHDOG
include $(BUILD_SHARED_LIBRARY)
+
+#
+# build audio resampler test tool
+#
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES:= \
+ test-resample.cpp \
+ AudioResampler.cpp.arm \
+ AudioResamplerCubic.cpp.arm \
+ AudioResamplerSinc.cpp.arm
+
+LOCAL_SHARED_LIBRARIES := \
+ libdl \
+ libcutils \
+ libutils
+
+LOCAL_MODULE:= test-resample
+
+LOCAL_MODULE_TAGS := optional
+
+include $(BUILD_EXECUTABLE)
+
+
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index aab99849..1913b6f8 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -76,20 +76,14 @@
#include "FastMixer.h"
// NBAIO implementations
-#include "AudioStreamOutSink.h"
-#include "MonoPipe.h"
-#include "MonoPipeReader.h"
-#include "Pipe.h"
-#include "PipeReader.h"
-#include "SourceAudioBufferProvider.h"
-
-#ifdef HAVE_REQUEST_PRIORITY
-#include "SchedulingPolicyService.h"
-#endif
+#include <media/nbaio/AudioStreamOutSink.h>
+#include <media/nbaio/MonoPipe.h>
+#include <media/nbaio/MonoPipeReader.h>
+#include <media/nbaio/Pipe.h>
+#include <media/nbaio/PipeReader.h>
+#include <media/nbaio/SourceAudioBufferProvider.h>
-#ifdef SOAKER
-#include "Soaker.h"
-#endif
+#include "SchedulingPolicyService.h"
// ----------------------------------------------------------------------------
@@ -167,6 +161,19 @@ static const enum {
static uint32_t gScreenState; // incremented by 2 when screen state changes, bit 0 == 1 means "off"
// AudioFlinger::setParameters() updates, other threads read w/o lock
+// Priorities for requestPriority
+static const int kPriorityAudioApp = 2;
+static const int kPriorityFastMixer = 3;
+
+// IAudioFlinger::createTrack() reports back to client the total size of shared memory area
+// for the track. The client then sub-divides this into smaller buffers for its use.
+// Currently the client uses double-buffering by default, but doesn't tell us about that.
+// So for now we just assume that client is double-buffered.
+// FIXME It would be better for client to tell AudioFlinger whether it wants double-buffering or
+// N-buffering, so AudioFlinger could allocate the right amount of memory.
+// See the client's minBufCount and mNotificationFramesAct calculations for details.
+static const int kFastTrackMultiplier = 2;
+
// ----------------------------------------------------------------------------
#ifdef ADD_BATTERY_DATA
@@ -216,9 +223,8 @@ out:
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),
mPrimaryHardwareDev(NULL),
- mHardwareStatus(AUDIO_HW_IDLE), // see also onFirstRef()
+ mHardwareStatus(AUDIO_HW_IDLE),
mMasterVolume(1.0f),
- mMasterVolumeSupportLvl(MVS_NONE),
mMasterMute(false),
mNextUniqueId(1),
mMode(AUDIO_MODE_INVALID),
@@ -247,21 +253,17 @@ void AudioFlinger::onFirstRef()
}
mMode = AUDIO_MODE_NORMAL;
- mMasterVolumeSW = 1.0;
- mMasterVolume = 1.0;
- mHardwareStatus = AUDIO_HW_IDLE;
}
AudioFlinger::~AudioFlinger()
{
-
while (!mRecordThreads.isEmpty()) {
- // closeInput() will remove first entry from mRecordThreads
- closeInput(mRecordThreads.keyAt(0));
+ // closeInput_nonvirtual() will remove specified entry from mRecordThreads
+ closeInput_nonvirtual(mRecordThreads.keyAt(0));
}
while (!mPlaybackThreads.isEmpty()) {
- // closeOutput() will remove first entry from mPlaybackThreads
- closeOutput(mPlaybackThreads.keyAt(0));
+ // closeOutput_nonvirtual() will remove specified entry from mPlaybackThreads
+ closeOutput_nonvirtual(mPlaybackThreads.keyAt(0));
}
for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
@@ -278,7 +280,9 @@ static const char * const audio_interfaces[] = {
};
#define ARRAY_SIZE(x) (sizeof((x))/sizeof(((x)[0])))
-audio_hw_device_t* AudioFlinger::findSuitableHwDev_l(audio_module_handle_t module, uint32_t devices)
+AudioFlinger::AudioHwDevice* AudioFlinger::findSuitableHwDev_l(
+ audio_module_handle_t module,
+ audio_devices_t devices)
{
// if module is 0, the request comes from an old policy manager and we should load
// well known modules
@@ -287,24 +291,26 @@ audio_hw_device_t* AudioFlinger::findSuitableHwDev_l(audio_module_handle_t modul
for (size_t i = 0; i < ARRAY_SIZE(audio_interfaces); i++) {
loadHwModule_l(audio_interfaces[i]);
}
+ // then try to find a module supporting the requested device.
+ for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
+ AudioHwDevice *audioHwDevice = mAudioHwDevs.valueAt(i);
+ audio_hw_device_t *dev = audioHwDevice->hwDevice();
+ if ((dev->get_supported_devices != NULL) &&
+ (dev->get_supported_devices(dev) & devices) == devices)
+ return audioHwDevice;
+ }
} else {
// check a match for the requested module handle
- AudioHwDevice *audioHwdevice = mAudioHwDevs.valueFor(module);
- if (audioHwdevice != NULL) {
- return audioHwdevice->hwDevice();
+ AudioHwDevice *audioHwDevice = mAudioHwDevs.valueFor(module);
+ if (audioHwDevice != NULL) {
+ return audioHwDevice;
}
}
- // then try to find a module supporting the requested device.
- for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
- audio_hw_device_t *dev = mAudioHwDevs.valueAt(i)->hwDevice();
- if ((dev->get_supported_devices(dev) & devices) == devices)
- return dev;
- }
return NULL;
}
-status_t AudioFlinger::dumpClients(int fd, const Vector<String16>& args)
+void AudioFlinger::dumpClients(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -327,11 +333,10 @@ status_t AudioFlinger::dumpClients(int fd, const Vector<String16>& args)
result.append(buffer);
}
write(fd, result.string(), result.size());
- return NO_ERROR;
}
-status_t AudioFlinger::dumpInternals(int fd, const Vector<String16>& args)
+void AudioFlinger::dumpInternals(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -344,10 +349,9 @@ status_t AudioFlinger::dumpInternals(int fd, const Vector<String16>& args)
(uint32_t)(mStandbyTimeInNsecs / 1000000));
result.append(buffer);
write(fd, result.string(), result.size());
- return NO_ERROR;
}
-status_t AudioFlinger::dumpPermissionDenial(int fd, const Vector<String16>& args)
+void AudioFlinger::dumpPermissionDenial(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -358,7 +362,6 @@ status_t AudioFlinger::dumpPermissionDenial(int fd, const Vector<String16>& args
IPCThreadState::self()->getCallingUid());
result.append(buffer);
write(fd, result.string(), result.size());
- return NO_ERROR;
}
static bool tryLock(Mutex& mutex)
@@ -440,7 +443,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
IAudioFlinger::track_flags_t flags,
const sp<IMemory>& sharedBuffer,
@@ -515,7 +518,7 @@ sp<IAudioTrack> AudioFlinger::createTrack(
if (mPendingSyncEvents[i]->triggerSession() == lSessionId) {
if (thread->isValidSyncEvent(mPendingSyncEvents[i])) {
if (lStatus == NO_ERROR) {
- track->setSyncEvent(mPendingSyncEvents[i]);
+ (void) track->setSyncEvent(mPendingSyncEvents[i]);
} else {
mPendingSyncEvents[i]->cancel();
}
@@ -610,30 +613,27 @@ status_t AudioFlinger::setMasterVolume(float value)
return PERMISSION_DENIED;
}
- float swmv = value;
-
Mutex::Autolock _l(mLock);
+ mMasterVolume = value;
- // when hw supports master volume, don't scale in sw mixer
- if (MVS_NONE != mMasterVolumeSupportLvl) {
- for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
- AutoMutex lock(mHardwareLock);
- audio_hw_device_t *dev = mAudioHwDevs.valueAt(i)->hwDevice();
+ // Set master volume in the HALs which support it.
+ for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
+ AutoMutex lock(mHardwareLock);
+ AudioHwDevice *dev = mAudioHwDevs.valueAt(i);
- mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
- if (NULL != dev->set_master_volume) {
- dev->set_master_volume(dev, value);
- }
- mHardwareStatus = AUDIO_HW_IDLE;
+ mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
+ if (dev->canSetMasterVolume()) {
+ dev->hwDevice()->set_master_volume(dev->hwDevice(), value);
}
-
- swmv = 1.0;
+ mHardwareStatus = AUDIO_HW_IDLE;
}
- mMasterVolume = value;
- mMasterVolumeSW = swmv;
+ // Now set the master volume in each playback thread. Playback threads
+ // assigned to HALs which do not have master volume support will apply
+ // master volume during the mix operation. Threads with HALs which do
+ // support master volume will simply ignore the setting.
for (size_t i = 0; i < mPlaybackThreads.size(); i++)
- mPlaybackThreads.valueAt(i)->setMasterVolume(swmv);
+ mPlaybackThreads.valueAt(i)->setMasterVolume(value);
return NO_ERROR;
}
@@ -656,8 +656,9 @@ status_t AudioFlinger::setMode(audio_mode_t mode)
{ // scope for the lock
AutoMutex lock(mHardwareLock);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
mHardwareStatus = AUDIO_HW_SET_MODE;
- ret = mPrimaryHardwareDev->set_mode(mPrimaryHardwareDev, mode);
+ ret = dev->set_mode(dev, mode);
mHardwareStatus = AUDIO_HW_IDLE;
}
@@ -684,8 +685,9 @@ status_t AudioFlinger::setMicMute(bool state)
}
AutoMutex lock(mHardwareLock);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
mHardwareStatus = AUDIO_HW_SET_MIC_MUTE;
- ret = mPrimaryHardwareDev->set_mic_mute(mPrimaryHardwareDev, state);
+ ret = dev->set_mic_mute(dev, state);
mHardwareStatus = AUDIO_HW_IDLE;
return ret;
}
@@ -699,22 +701,44 @@ bool AudioFlinger::getMicMute() const
bool state = AUDIO_MODE_INVALID;
AutoMutex lock(mHardwareLock);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
mHardwareStatus = AUDIO_HW_GET_MIC_MUTE;
- mPrimaryHardwareDev->get_mic_mute(mPrimaryHardwareDev, &state);
+ dev->get_mic_mute(dev, &state);
mHardwareStatus = AUDIO_HW_IDLE;
return state;
}
status_t AudioFlinger::setMasterMute(bool muted)
{
+ status_t ret = initCheck();
+ if (ret != NO_ERROR) {
+ return ret;
+ }
+
// check calling permissions
if (!settingsAllowed()) {
return PERMISSION_DENIED;
}
Mutex::Autolock _l(mLock);
- // This is an optimization, so PlaybackThread doesn't have to look at the one from AudioFlinger
mMasterMute = muted;
+
+ // Set master mute in the HALs which support it.
+ for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
+ AutoMutex lock(mHardwareLock);
+ AudioHwDevice *dev = mAudioHwDevs.valueAt(i);
+
+ mHardwareStatus = AUDIO_HW_SET_MASTER_MUTE;
+ if (dev->canSetMasterMute()) {
+ dev->hwDevice()->set_master_mute(dev->hwDevice(), muted);
+ }
+ mHardwareStatus = AUDIO_HW_IDLE;
+ }
+
+ // Now set the master mute in each playback thread. Playback threads
+ // assigned to HALs which do not have master mute support will apply master
+ // mute during the mix operation. Threads with HALs which do support master
+ // mute will simply ignore the setting.
for (size_t i = 0; i < mPlaybackThreads.size(); i++)
mPlaybackThreads.valueAt(i)->setMasterMute(muted);
@@ -727,12 +751,6 @@ float AudioFlinger::masterVolume() const
return masterVolume_l();
}
-float AudioFlinger::masterVolumeSW() const
-{
- Mutex::Autolock _l(mLock);
- return masterVolumeSW_l();
-}
-
bool AudioFlinger::masterMute() const
{
Mutex::Autolock _l(mLock);
@@ -741,23 +759,14 @@ bool AudioFlinger::masterMute() const
float AudioFlinger::masterVolume_l() const
{
- if (MVS_FULL == mMasterVolumeSupportLvl) {
- float ret_val;
- AutoMutex lock(mHardwareLock);
-
- mHardwareStatus = AUDIO_HW_GET_MASTER_VOLUME;
- ALOG_ASSERT((NULL != mPrimaryHardwareDev) &&
- (NULL != mPrimaryHardwareDev->get_master_volume),
- "can't get master volume");
-
- mPrimaryHardwareDev->get_master_volume(mPrimaryHardwareDev, &ret_val);
- mHardwareStatus = AUDIO_HW_IDLE;
- return ret_val;
- }
-
return mMasterVolume;
}
+bool AudioFlinger::masterMute_l() const
+{
+ return mMasterMute;
+}
+
status_t AudioFlinger::setStreamVolume(audio_stream_type_t stream, float value,
audio_io_handle_t output)
{
@@ -876,17 +885,19 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8&
if (mBtNrecIsOff != btNrecIsOff) {
for (size_t i = 0; i < mRecordThreads.size(); i++) {
sp<RecordThread> thread = mRecordThreads.valueAt(i);
- RecordThread::RecordTrack *track = thread->track();
- if (track != NULL) {
- audio_devices_t device = (audio_devices_t)(
- thread->device() & AUDIO_DEVICE_IN_ALL);
- bool suspend = audio_is_bluetooth_sco_device(device) && btNrecIsOff;
+ audio_devices_t device = thread->inDevice();
+ bool suspend = audio_is_bluetooth_sco_device(device) && btNrecIsOff;
+ // collect all of the thread's session IDs
+ KeyedVector<int, bool> ids = thread->sessionIds();
+ // suspend effects associated with those session IDs
+ for (size_t j = 0; j < ids.size(); ++j) {
+ int sessionId = ids.keyAt(j);
thread->setEffectSuspended(FX_IID_AEC,
suspend,
- track->sessionId());
+ sessionId);
thread->setEffectSuspended(FX_IID_NS,
suspend,
- track->sessionId());
+ sessionId);
}
}
mBtNrecIsOff = btNrecIsOff;
@@ -908,7 +919,7 @@ status_t AudioFlinger::setParameters(audio_io_handle_t ioHandle, const String8&
{
Mutex::Autolock _l(mLock);
thread = checkPlaybackThread_l(ioHandle);
- if (thread == NULL) {
+ if (thread == 0) {
thread = checkRecordThread_l(ioHandle);
} else if (thread == primaryPlaybackThread_l()) {
// indicate output device change to all input threads for pre processing
@@ -964,7 +975,8 @@ String8 AudioFlinger::getParameters(audio_io_handle_t ioHandle, const String8& k
return String8("");
}
-size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t format, int channelCount) const
+size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t format,
+ audio_channel_mask_t channelMask) const
{
status_t ret = initCheck();
if (ret != NO_ERROR) {
@@ -975,20 +987,17 @@ size_t AudioFlinger::getInputBufferSize(uint32_t sampleRate, audio_format_t form
mHardwareStatus = AUDIO_HW_GET_INPUT_BUFFER_SIZE;
struct audio_config config = {
sample_rate: sampleRate,
- channel_mask: audio_channel_in_mask_from_count(channelCount),
+ channel_mask: channelMask,
format: format,
};
- size_t size = mPrimaryHardwareDev->get_input_buffer_size(mPrimaryHardwareDev, &config);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
+ size_t size = dev->get_input_buffer_size(dev, &config);
mHardwareStatus = AUDIO_HW_IDLE;
return size;
}
unsigned int AudioFlinger::getInputFramesLost(audio_io_handle_t ioHandle) const
{
- if (ioHandle == 0) {
- return 0;
- }
-
Mutex::Autolock _l(mLock);
RecordThread *recordThread = checkRecordThread_l(ioHandle);
@@ -1011,8 +1020,9 @@ status_t AudioFlinger::setVoiceVolume(float value)
}
AutoMutex lock(mHardwareLock);
+ audio_hw_device_t *dev = mPrimaryHardwareDev->hwDevice();
mHardwareStatus = AUDIO_HW_SET_VOICE_VOLUME;
- ret = mPrimaryHardwareDev->set_voice_volume(mPrimaryHardwareDev, value);
+ ret = dev->set_voice_volume(dev, value);
mHardwareStatus = AUDIO_HW_IDLE;
return ret;
@@ -1053,11 +1063,11 @@ void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
// the config change is always sent from playback or record threads to avoid deadlock
// with AudioSystem::gLock
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
- mPlaybackThreads.valueAt(i)->sendConfigEvent(AudioSystem::OUTPUT_OPENED);
+ mPlaybackThreads.valueAt(i)->sendIoConfigEvent(AudioSystem::OUTPUT_OPENED);
}
for (size_t i = 0; i < mRecordThreads.size(); i++) {
- mRecordThreads.valueAt(i)->sendConfigEvent(AudioSystem::INPUT_OPENED);
+ mRecordThreads.valueAt(i)->sendIoConfigEvent(AudioSystem::INPUT_OPENED);
}
}
}
@@ -1124,16 +1134,17 @@ sp<AudioFlinger::PlaybackThread> AudioFlinger::getEffectThread_l(int sessionId,
// ----------------------------------------------------------------------------
AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id,
- uint32_t device, type_t type)
- : Thread(false),
+ audio_devices_t outDevice, audio_devices_t inDevice, type_t type)
+ : Thread(false /*canCallJava*/),
mType(type),
mAudioFlinger(audioFlinger), mSampleRate(0), mFrameCount(0), mNormalFrameCount(0),
// mChannelMask
mChannelCount(0),
mFrameSize(1), mFormat(AUDIO_FORMAT_INVALID),
mParamStatus(NO_ERROR),
- mStandby(false), mId(id),
- mDevice(device),
+ mStandby(false), mOutDevice(outDevice), mInDevice(inDevice),
+ mAudioSource(AUDIO_SOURCE_DEFAULT), mId(id),
+ // mName will be set by concrete (non-virtual) subclass
mDeathRecipient(new PMDeathRecipient(this))
{
}
@@ -1152,6 +1163,8 @@ AudioFlinger::ThreadBase::~ThreadBase()
void AudioFlinger::ThreadBase::exit()
{
ALOGV("ThreadBase::exit");
+ // do any cleanup required for exit to succeed
+ preExit();
{
// This lock prevents the following race in thread (uniprocessor for illustration):
// if (!exitPending()) {
@@ -1164,7 +1177,7 @@ void AudioFlinger::ThreadBase::exit()
// }
AutoMutex lock(mLock);
requestExit();
- mWaitWorkCV.signal();
+ mWaitWorkCV.broadcast();
}
// When Thread::requestExitAndWait is made virtual and this method is renamed to
// "virtual status_t requestExitAndWait()", replace by "return Thread::requestExitAndWait();"
@@ -1191,20 +1204,28 @@ status_t AudioFlinger::ThreadBase::setParameters(const String8& keyValuePairs)
return status;
}
-void AudioFlinger::ThreadBase::sendConfigEvent(int event, int param)
+void AudioFlinger::ThreadBase::sendIoConfigEvent(int event, int param)
{
Mutex::Autolock _l(mLock);
- sendConfigEvent_l(event, param);
+ sendIoConfigEvent_l(event, param);
+}
+
+// sendIoConfigEvent_l() must be called with ThreadBase::mLock held
+void AudioFlinger::ThreadBase::sendIoConfigEvent_l(int event, int param)
+{
+ IoConfigEvent *ioEvent = new IoConfigEvent(event, param);
+ mConfigEvents.add(static_cast<ConfigEvent *>(ioEvent));
+ ALOGV("sendIoConfigEvent() num events %d event %d, param %d", mConfigEvents.size(), event, param);
+ mWaitWorkCV.signal();
}
-// sendConfigEvent_l() must be called with ThreadBase::mLock held
-void AudioFlinger::ThreadBase::sendConfigEvent_l(int event, int param)
+// sendPrioConfigEvent_l() must be called with ThreadBase::mLock held
+void AudioFlinger::ThreadBase::sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio)
{
- ConfigEvent configEvent;
- configEvent.mEvent = event;
- configEvent.mParam = param;
- mConfigEvents.add(configEvent);
- ALOGV("sendConfigEvent() num events %d event %d, param %d", mConfigEvents.size(), event, param);
+ PrioConfigEvent *prioEvent = new PrioConfigEvent(pid, tid, prio);
+ mConfigEvents.add(static_cast<ConfigEvent *>(prioEvent));
+ ALOGV("sendPrioConfigEvent_l() num events %d pid %d, tid %d prio %d",
+ mConfigEvents.size(), pid, tid, prio);
mWaitWorkCV.signal();
}
@@ -1213,20 +1234,37 @@ void AudioFlinger::ThreadBase::processConfigEvents()
mLock.lock();
while (!mConfigEvents.isEmpty()) {
ALOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
- ConfigEvent configEvent = mConfigEvents[0];
+ ConfigEvent *event = mConfigEvents[0];
mConfigEvents.removeAt(0);
// release mLock before locking AudioFlinger mLock: lock order is always
// AudioFlinger then ThreadBase to avoid cross deadlock
mLock.unlock();
- mAudioFlinger->mLock.lock();
- audioConfigChanged_l(configEvent.mEvent, configEvent.mParam);
- mAudioFlinger->mLock.unlock();
+ switch(event->type()) {
+ case CFG_EVENT_PRIO: {
+ PrioConfigEvent *prioEvent = static_cast<PrioConfigEvent *>(event);
+ int err = requestPriority(prioEvent->pid(), prioEvent->tid(), prioEvent->prio());
+ if (err != 0) {
+ ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
+ prioEvent->prio(), prioEvent->pid(), prioEvent->tid(), err);
+ }
+ } break;
+ case CFG_EVENT_IO: {
+ IoConfigEvent *ioEvent = static_cast<IoConfigEvent *>(event);
+ mAudioFlinger->mLock.lock();
+ audioConfigChanged_l(ioEvent->event(), ioEvent->param());
+ mAudioFlinger->mLock.unlock();
+ } break;
+ default:
+ ALOGE("processConfigEvents() unknown event type %d", event->type());
+ break;
+ }
+ delete event;
mLock.lock();
}
mLock.unlock();
}
-status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args)
+void AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -1270,10 +1308,8 @@ status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args
snprintf(buffer, SIZE, "\n\nPending config events: \n");
result.append(buffer);
- snprintf(buffer, SIZE, " Index event param\n");
- result.append(buffer);
for (size_t i = 0; i < mConfigEvents.size(); i++) {
- snprintf(buffer, SIZE, " %02d %02d %d\n", i, mConfigEvents[i].mEvent, mConfigEvents[i].mParam);
+ mConfigEvents[i]->dump(buffer, SIZE);
result.append(buffer);
}
result.append("\n");
@@ -1283,10 +1319,9 @@ status_t AudioFlinger::ThreadBase::dumpBase(int fd, const Vector<String16>& args
if (locked) {
mLock.unlock();
}
- return NO_ERROR;
}
-status_t AudioFlinger::ThreadBase::dumpEffectChains(int fd, const Vector<String16>& args)
+void AudioFlinger::ThreadBase::dumpEffectChains(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -1301,7 +1336,6 @@ status_t AudioFlinger::ThreadBase::dumpEffectChains(int fd, const Vector<String1
chain->dump(fd, args);
}
}
- return NO_ERROR;
}
void AudioFlinger::ThreadBase::acquireWakeLock()
@@ -1397,8 +1431,8 @@ void AudioFlinger::ThreadBase::checkSuspendOnAddEffectChain_l(const sp<EffectCha
return;
}
- KeyedVector <int, sp<SuspendedSessionDesc> > sessionEffects =
- mSuspendedSessions.editValueAt(index);
+ const KeyedVector <int, sp<SuspendedSessionDesc> >& sessionEffects =
+ mSuspendedSessions.valueAt(index);
for (size_t i = 0; i < sessionEffects.size(); i++) {
sp<SuspendedSessionDesc> desc = sessionEffects.valueAt(i);
@@ -1424,7 +1458,7 @@ void AudioFlinger::ThreadBase::updateSuspendedSessions_l(const effect_uuid_t *ty
if (suspend) {
if (index >= 0) {
- sessionEffects = mSuspendedSessions.editValueAt(index);
+ sessionEffects = mSuspendedSessions.valueAt(index);
} else {
mSuspendedSessions.add(sessionId, sessionEffects);
}
@@ -1432,7 +1466,7 @@ void AudioFlinger::ThreadBase::updateSuspendedSessions_l(const effect_uuid_t *ty
if (index < 0) {
return;
}
- sessionEffects = mSuspendedSessions.editValueAt(index);
+ sessionEffects = mSuspendedSessions.valueAt(index);
}
@@ -1449,7 +1483,7 @@ void AudioFlinger::ThreadBase::updateSuspendedSessions_l(const effect_uuid_t *ty
} else {
desc = new SuspendedSessionDesc();
if (type != NULL) {
- memcpy(&desc->mType, type, sizeof(effect_uuid_t));
+ desc->mType = *type;
}
sessionEffects.add(key, desc);
ALOGV("updateSuspendedSessions_l() suspend adding effect %08x", key);
@@ -1509,18 +1543,12 @@ void AudioFlinger::ThreadBase::checkSuspendOnEffectEnabled_l(const sp<EffectModu
AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
audio_io_handle_t id,
- uint32_t device,
+ audio_devices_t device,
type_t type)
- : ThreadBase(audioFlinger, id, device, type),
+ : ThreadBase(audioFlinger, id, device, AUDIO_DEVICE_NONE, type),
mMixBuffer(NULL), mSuspended(0), mBytesWritten(0),
- // Assumes constructor is called by AudioFlinger with it's mLock held,
- // but it would be safer to explicitly pass initial masterMute as parameter
- mMasterMute(audioFlinger->masterMute_l()),
// mStreamTypes[] initialized in constructor body
mOutput(output),
- // Assumes constructor is called by AudioFlinger with it's mLock held,
- // but it would be safer to explicitly pass initial masterVolume as parameter
- mMasterVolume(audioFlinger->masterVolumeSW_l()),
mLastWriteTime(0), mNumWrites(0), mNumDelayedWrites(0), mInWrite(false),
mMixerStatus(MIXER_IDLE),
mMixerStatusIgnoringFastTracks(MIXER_IDLE),
@@ -1531,6 +1559,25 @@ AudioFlinger::PlaybackThread::PlaybackThread(const sp<AudioFlinger>& audioFlinge
{
snprintf(mName, kNameLength, "AudioOut_%X", id);
+ // Assumes constructor is called by AudioFlinger with it's mLock held, but
+ // it would be safer to explicitly pass initial masterVolume/masterMute as
+ // parameter.
+ //
+ // If the HAL we are using has support for master volume or master mute,
+ // then do not attenuate or mute during mixing (just leave the volume at 1.0
+ // and the mute set to false).
+ mMasterVolume = audioFlinger->masterVolume_l();
+ mMasterMute = audioFlinger->masterMute_l();
+ if (mOutput && mOutput->audioHwDev) {
+ if (mOutput->audioHwDev->canSetMasterVolume()) {
+ mMasterVolume = 1.0;
+ }
+
+ if (mOutput->audioHwDev->canSetMasterMute()) {
+ mMasterMute = false;
+ }
+ }
+
readOutputParameters();
// mStreamTypes[AUDIO_STREAM_CNT] is initialized by stream_type_t default constructor
@@ -1549,15 +1596,14 @@ AudioFlinger::PlaybackThread::~PlaybackThread()
delete [] mMixBuffer;
}
-status_t AudioFlinger::PlaybackThread::dump(int fd, const Vector<String16>& args)
+void AudioFlinger::PlaybackThread::dump(int fd, const Vector<String16>& args)
{
dumpInternals(fd, args);
dumpTracks(fd, args);
dumpEffectChains(fd, args);
- return NO_ERROR;
}
-status_t AudioFlinger::PlaybackThread::dumpTracks(int fd, const Vector<String16>& args)
+void AudioFlinger::PlaybackThread::dumpTracks(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -1605,11 +1651,9 @@ status_t AudioFlinger::PlaybackThread::dumpTracks(int fd, const Vector<String16>
FastTrackUnderruns underruns = getFastTrackUnderruns(0);
fdprintf(fd, "Normal mixer raw underrun counters: partial=%u empty=%u\n",
underruns.mBitFields.mPartial, underruns.mBitFields.mEmpty);
-
- return NO_ERROR;
}
-status_t AudioFlinger::PlaybackThread::dumpInternals(int fd, const Vector<String16>& args)
+void AudioFlinger::PlaybackThread::dumpInternals(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -1633,8 +1677,6 @@ status_t AudioFlinger::PlaybackThread::dumpInternals(int fd, const Vector<String
fdprintf(fd, "Fast track availMask=%#x\n", mFastTrackAvailMask);
dumpBase(fd, args);
-
- return NO_ERROR;
}
// Thread virtuals
@@ -1654,13 +1696,22 @@ void AudioFlinger::PlaybackThread::onFirstRef()
run(mName, ANDROID_PRIORITY_URGENT_AUDIO);
}
+// ThreadBase virtuals
+void AudioFlinger::PlaybackThread::preExit()
+{
+ ALOGV(" preExit()");
+ // FIXME this is using hard-coded strings but in the future, this functionality will be
+ // converted to use audio HAL extensions required to support tunneling
+ mOutput->stream->common.set_parameters(&mOutput->stream->common, "exiting=1");
+}
+
// PlaybackThread::createTrack_l() must be called with AudioFlinger::mLock held
sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrack_l(
const sp<AudioFlinger::Client>& client,
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId,
@@ -1688,7 +1739,7 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
(
(tid != -1) &&
((frameCount == 0) ||
- (frameCount >= (int) (mFrameCount * 2))) // * 2 is due to SRC jitter, see below
+ (frameCount >= (int) (mFrameCount * kFastTrackMultiplier)))
)
) &&
// PCM data
@@ -1709,13 +1760,13 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
) {
// if frameCount not specified, then it defaults to fast mixer (HAL) frame count
if (frameCount == 0) {
- frameCount = mFrameCount * 2; // FIXME * 2 is due to SRC jitter, should be computed
+ frameCount = mFrameCount * kFastTrackMultiplier;
}
ALOGV("AUDIO_OUTPUT_FLAG_FAST accepted: frameCount=%d mFrameCount=%d",
frameCount, mFrameCount);
} else {
ALOGV("AUDIO_OUTPUT_FLAG_FAST denied: isTimed=%d sharedBuffer=%p frameCount=%d "
- "mFrameCount=%d format=%d isLinear=%d channelMask=%d sampleRate=%d mSampleRate=%d "
+ "mFrameCount=%d format=%d isLinear=%d channelMask=%#x sampleRate=%d mSampleRate=%d "
"hasFastMixer=%d tid=%d fastTrackAvailMask=%#x",
isTimed, sharedBuffer.get(), frameCount, mFrameCount, format,
audio_is_linear_pcm(format),
@@ -1789,7 +1840,7 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
track = TimedTrack::create(this, client, streamType, sampleRate, format,
channelMask, frameCount, sharedBuffer, sessionId);
}
- if (track == NULL || track->getCblk() == NULL || track->name() < 0) {
+ if (track == 0 || track->getCblk() == NULL || track->name() < 0) {
lStatus = NO_MEMORY;
goto Exit;
}
@@ -1802,20 +1853,14 @@ sp<AudioFlinger::PlaybackThread::Track> AudioFlinger::PlaybackThread::createTrac
chain->setStrategy(AudioSystem::getStrategyForStream(track->streamType()));
chain->incTrackCnt();
}
- }
-#ifdef HAVE_REQUEST_PRIORITY
- if ((flags & IAudioFlinger::TRACK_FAST) && (tid != -1)) {
- pid_t callingPid = IPCThreadState::self()->getCallingPid();
- // we don't have CAP_SYS_NICE, nor do we want to have it as it's too powerful,
- // so ask activity manager to do this on our behalf
- int err = requestPriority(callingPid, tid, 1);
- if (err != 0) {
- ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
- 1, callingPid, tid, err);
+ if ((flags & IAudioFlinger::TRACK_FAST) && (tid != -1)) {
+ pid_t callingPid = IPCThreadState::self()->getCallingPid();
+ // we don't have CAP_SYS_NICE, nor do we want to have it as it's too powerful,
+ // so ask activity manager to do this on our behalf
+ sendPrioConfigEvent_l(callingPid, tid, kPriorityAudioApp);
}
}
-#endif
lStatus = NO_ERROR;
@@ -1857,13 +1902,25 @@ uint32_t AudioFlinger::PlaybackThread::latency_l() const
void AudioFlinger::PlaybackThread::setMasterVolume(float value)
{
Mutex::Autolock _l(mLock);
- mMasterVolume = value;
+ // Don't apply master volume in SW if our HAL can do it for us.
+ if (mOutput && mOutput->audioHwDev &&
+ mOutput->audioHwDev->canSetMasterVolume()) {
+ mMasterVolume = 1.0;
+ } else {
+ mMasterVolume = value;
+ }
}
void AudioFlinger::PlaybackThread::setMasterMute(bool muted)
{
Mutex::Autolock _l(mLock);
- setMasterMute_l(muted);
+ // Don't apply master mute in SW if our HAL can do it for us.
+ if (mOutput && mOutput->audioHwDev &&
+ mOutput->audioHwDev->canSetMasterMute()) {
+ mMasterMute = false;
+ } else {
+ mMasterMute = muted;
+ }
}
void AudioFlinger::PlaybackThread::setStreamVolume(audio_stream_type_t stream, float value)
@@ -2070,10 +2127,20 @@ status_t AudioFlinger::PlaybackThread::getRenderPosition(uint32_t *halFrames, ui
}
*halFrames = mBytesWritten / audio_stream_frame_size(&mOutput->stream->common);
- return mOutput->stream->get_render_position(mOutput->stream, dspFrames);
+ if (isSuspended()) {
+ // return an estimation of rendered frames when the output is suspended
+ int32_t frames = mBytesWritten - latency_l();
+ if (frames < 0) {
+ frames = 0;
+ }
+ *dspFrames = (uint32_t)frames;
+ return NO_ERROR;
+ } else {
+ return mOutput->stream->get_render_position(mOutput->stream, dspFrames);
+ }
}
-uint32_t AudioFlinger::PlaybackThread::hasAudioSession(int sessionId)
+uint32_t AudioFlinger::PlaybackThread::hasAudioSession(int sessionId) const
{
Mutex::Autolock _l(mLock);
uint32_t result = 0;
@@ -2155,7 +2222,7 @@ status_t AudioFlinger::PlaybackThread::setSyncEvent(const sp<SyncEvent>& event)
for (size_t i = 0; i < mTracks.size(); ++i) {
sp<Track> track = mTracks[i];
if (event->triggerSession() == track->sessionId()) {
- track->setSyncEvent(event);
+ (void) track->setSyncEvent(event);
return NO_ERROR;
}
}
@@ -2163,15 +2230,9 @@ status_t AudioFlinger::PlaybackThread::setSyncEvent(const sp<SyncEvent>& event)
return NAME_NOT_FOUND;
}
-bool AudioFlinger::PlaybackThread::isValidSyncEvent(const sp<SyncEvent>& event)
+bool AudioFlinger::PlaybackThread::isValidSyncEvent(const sp<SyncEvent>& event) const
{
- switch (event->type()) {
- case AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE:
- return true;
- default:
- break;
- }
- return false;
+ return event->type() == AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE;
}
void AudioFlinger::PlaybackThread::threadLoop_removeTracks(const Vector< sp<Track> >& tracksToRemove)
@@ -2192,28 +2253,25 @@ void AudioFlinger::PlaybackThread::threadLoop_removeTracks(const Vector< sp<Trac
// ----------------------------------------------------------------------------
AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, uint32_t device, type_t type)
+ audio_io_handle_t id, audio_devices_t device, type_t type)
: PlaybackThread(audioFlinger, output, id, device, type),
// mAudioMixer below
-#ifdef SOAKER
- mSoaker(NULL),
-#endif
// mFastMixer below
mFastMixerFutex(0)
// mOutputSink below
// mPipeSink below
// mNormalSink below
{
- ALOGV("MixerThread() id=%d device=%d type=%d", id, device, type);
- ALOGV("mSampleRate=%d, mChannelMask=%d, mChannelCount=%d, mFormat=%d, mFrameSize=%d, "
+ ALOGV("MixerThread() id=%d device=%#x type=%d", id, device, type);
+ ALOGV("mSampleRate=%d, mChannelMask=%#x, mChannelCount=%d, mFormat=%d, mFrameSize=%d, "
"mFrameCount=%d, mNormalFrameCount=%d",
mSampleRate, mChannelMask, mChannelCount, mFormat, mFrameSize, mFrameCount,
mNormalFrameCount);
mAudioMixer = new AudioMixer(mNormalFrameCount, mSampleRate);
// FIXME - Current mixer implementation only supports stereo output
- if (mChannelCount == 1) {
- ALOGE("Invalid audio hardware channel count");
+ if (mChannelCount != FCC_2) {
+ ALOGE("Invalid audio hardware channel count %d", mChannelCount);
}
// create an NBAIO sink for the HAL output stream, and negotiate
@@ -2267,13 +2325,6 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
mTeeSource = teeSource;
#endif
-#ifdef SOAKER
- // create a soaker as workaround for governor issues
- mSoaker = new Soaker();
- // FIXME Soaker should only run when needed, i.e. when FastMixer is not in COLD_IDLE
- mSoaker->run("Soaker", PRIORITY_LOWEST);
-#endif
-
// create fast mixer and configure it initially with just one fast track for our submix
mFastMixer = new FastMixer();
FastMixerStateQueue *sq = mFastMixer->sq();
@@ -2305,14 +2356,12 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
// start the fast mixer
mFastMixer->run("FastMixer", PRIORITY_URGENT_AUDIO);
-#ifdef HAVE_REQUEST_PRIORITY
pid_t tid = mFastMixer->getTid();
- int err = requestPriority(getpid_cached, tid, 2);
+ int err = requestPriority(getpid_cached, tid, kPriorityFastMixer);
if (err != 0) {
ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
- 2, getpid_cached, tid, err);
+ kPriorityFastMixer, getpid_cached, tid, err);
}
-#endif
#ifdef AUDIO_WATCHDOG
// create and start the watchdog
@@ -2320,10 +2369,10 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud
mAudioWatchdog->setDump(&mAudioWatchdogDump);
mAudioWatchdog->run("AudioWatchdog", PRIORITY_URGENT_AUDIO);
tid = mAudioWatchdog->getTid();
- err = requestPriority(getpid_cached, tid, 1);
+ err = requestPriority(getpid_cached, tid, kPriorityFastMixer);
if (err != 0) {
ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
- 1, getpid_cached, tid, err);
+ kPriorityFastMixer, getpid_cached, tid, err);
}
#endif
@@ -2370,17 +2419,13 @@ AudioFlinger::MixerThread::~MixerThread()
delete fastTrack->mBufferProvider;
sq->end(false /*didModify*/);
delete mFastMixer;
-#ifdef SOAKER
- if (mSoaker != NULL) {
- mSoaker->requestExitAndWait();
- }
- delete mSoaker;
-#endif
+#ifdef AUDIO_WATCHDOG
if (mAudioWatchdog != 0) {
mAudioWatchdog->requestExit();
mAudioWatchdog->requestExitAndWait();
mAudioWatchdog.clear();
}
+#endif
}
delete mAudioMixer;
}
@@ -2508,9 +2553,6 @@ bool AudioFlinger::PlaybackThread::threadLoop()
// MIXER
nsecs_t lastWarning = 0;
-if (mType == MIXER) {
- longStandbyExit = false;
-}
// DUPLICATING
// FIXME could this be made local to while loop?
@@ -2519,9 +2561,9 @@ if (mType == MIXER) {
cacheParameters_l();
sleepTime = idleSleepTime;
-if (mType == MIXER) {
- sleepTimeShift = 0;
-}
+ if (mType == MIXER) {
+ sleepTimeShift = 0;
+ }
CpuStats cpuStats;
const String8 myName(String8::format("thread %p type %d TID %d", this, mType, gettid()));
@@ -2548,13 +2590,12 @@ if (mType == MIXER) {
// put audio hardware into standby after short delay
if (CC_UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
- mSuspended > 0)) {
+ isSuspended())) {
if (!mStandby) {
threadLoop_standby();
mStandby = true;
- mBytesWritten = 0;
}
if (!mActiveTracks.size() && mConfigEvents.isEmpty()) {
@@ -2574,6 +2615,7 @@ if (mType == MIXER) {
mMixerStatus = MIXER_IDLE;
mMixerStatusIgnoringFastTracks = MIXER_IDLE;
+ mBytesWritten = 0;
checkSilentMode_l();
@@ -2602,8 +2644,9 @@ if (mType == MIXER) {
threadLoop_sleepTime();
}
- if (mSuspended > 0) {
+ if (isSuspended()) {
sleepTime = suspendSleepTimeUs();
+ mBytesWritten += mixBufferSize;
}
// only process effects if we're going to write
@@ -2635,11 +2678,6 @@ if (mType == MIXER) {
ns2ms(delta), mNumDelayedWrites, this);
lastWarning = now;
}
- // FIXME this is broken: longStandbyExit should be handled out of the if() and with
- // a different threshold. Or completely removed for what it is worth anyway...
- if (mStandby) {
- longStandbyExit = true;
- }
}
}
@@ -2667,15 +2705,13 @@ if (mType == MIXER) {
// is now local to this block, but will keep it for now (at least until merge done).
}
-if (mType == MIXER || mType == DIRECT) {
- // put output stream into standby mode
- if (!mStandby) {
- mOutput->stream->common.standby(&mOutput->stream->common);
+ // for DuplicatingThread, standby mode is handled by the outputTracks, otherwise ...
+ if (mType == MIXER || mType == DIRECT) {
+ // put output stream into standby mode
+ if (!mStandby) {
+ mOutput->stream->common.standby(&mOutput->stream->common);
+ }
}
-}
-if (mType == DUPLICATING) {
- // for DuplicatingThread, standby mode is handled by the outputTracks
-}
releaseWakeLock();
@@ -2702,9 +2738,11 @@ void AudioFlinger::MixerThread::threadLoop_write()
if (old == -1) {
__futex_syscall3(&mFastMixerFutex, FUTEX_WAKE_PRIVATE, 1);
}
+#ifdef AUDIO_WATCHDOG
if (mAudioWatchdog != 0) {
mAudioWatchdog->resume();
}
+#endif
}
state->mCommand = FastMixerState::MIX_WRITE;
sq->end();
@@ -2781,9 +2819,11 @@ void AudioFlinger::MixerThread::threadLoop_standby()
if (kUseFastMixer == FastMixer_Dynamic) {
mNormalSink = mOutputSink;
}
+#ifdef AUDIO_WATCHDOG
if (mAudioWatchdog != 0) {
mAudioWatchdog->pause();
}
+#endif
} else {
sq->end(false /*didModify*/);
}
@@ -2794,7 +2834,7 @@ void AudioFlinger::MixerThread::threadLoop_standby()
// shared by MIXER and DIRECT, overridden by DUPLICATING
void AudioFlinger::PlaybackThread::threadLoop_standby()
{
- ALOGV("Audio hardware entering standby, mixer %p, suspend count %u", this, mSuspended);
+ ALOGV("Audio hardware entering standby, mixer %p, suspend count %d", this, mSuspended);
mOutput->stream->common.standby(&mOutput->stream->common);
}
@@ -2804,9 +2844,10 @@ void AudioFlinger::MixerThread::threadLoop_mix()
int64_t pts;
status_t status = INVALID_OPERATION;
- if (NULL != mOutput->stream->get_next_write_timestamp) {
- status = mOutput->stream->get_next_write_timestamp(
- mOutput->stream, &pts);
+ if (mNormalSink != 0) {
+ status = mNormalSink->getNextWriteTimestamp(&pts);
+ } else {
+ status = mOutputSink->getNextWriteTimestamp(&pts);
}
if (status != NO_ERROR) {
@@ -2847,11 +2888,10 @@ void AudioFlinger::MixerThread::threadLoop_sleepTime()
} else {
sleepTime = idleSleepTime;
}
- } else if (mBytesWritten != 0 ||
- (mMixerStatus == MIXER_TRACKS_ENABLED && longStandbyExit)) {
+ } else if (mBytesWritten != 0 || (mMixerStatus == MIXER_TRACKS_ENABLED)) {
memset (mMixBuffer, 0, mixBufferSize);
sleepTime = 0;
- ALOGV_IF((mBytesWritten == 0 && (mMixerStatus == MIXER_TRACKS_ENABLED && longStandbyExit)), "anticipated start");
+ ALOGV_IF((mBytesWritten == 0 && (mMixerStatus == MIXER_TRACKS_ENABLED)), "anticipated start");
}
// TODO add standby time extension fct of effect tail
}
@@ -2993,7 +3033,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
(mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000;
size_t framesWritten =
mBytesWritten / audio_stream_frame_size(&mOutput->stream->common);
- if (!track->presentationComplete(framesWritten, audioHALFrames)) {
+ if (!(mStandby || track->presentationComplete(framesWritten, audioHALFrames))) {
// track stays in active list until presentation is complete
break;
}
@@ -3235,11 +3275,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac
// Remove it from the list of active tracks.
// TODO: use actual buffer filling status instead of latency when available from
// audio HAL
- size_t audioHALFrames =
- (mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000;
+ size_t audioHALFrames = (latency_l() * mSampleRate) / 1000;
size_t framesWritten =
mBytesWritten / audio_stream_frame_size(&mOutput->stream->common);
- if (track->presentationComplete(framesWritten, audioHALFrames)) {
+ if (mStandby || track->presentationComplete(framesWritten, audioHALFrames)) {
if (track->isStopped()) {
track->reset();
}
@@ -3296,9 +3335,11 @@ track_is_ready: ;
sq->end(didModify);
sq->push(block);
}
+#ifdef AUDIO_WATCHDOG
if (pauseAudioWatchdog && mAudioWatchdog != 0) {
mAudioWatchdog->pause();
}
+#endif
// Now perform the deferred reset on fast tracks that have stopped
while (resetMask != 0) {
@@ -3373,7 +3414,7 @@ void AudioFlinger::PlaybackThread::cacheParameters_l()
idleSleepTime = idleSleepTimeUs();
}
-void AudioFlinger::MixerThread::invalidateTracks(audio_stream_type_t streamType)
+void AudioFlinger::PlaybackThread::invalidateTracks(audio_stream_type_t streamType)
{
ALOGV ("MixerThread::invalidateTracks() mixer %p, streamType %d, mTracks.size %d",
this, streamType, mTracks.size());
@@ -3390,9 +3431,9 @@ void AudioFlinger::MixerThread::invalidateTracks(audio_stream_type_t streamType)
}
// getTrackName_l() must be called with ThreadBase::mLock held
-int AudioFlinger::MixerThread::getTrackName_l(audio_channel_mask_t channelMask)
+int AudioFlinger::MixerThread::getTrackName_l(audio_channel_mask_t channelMask, int sessionId)
{
- return mAudioMixer->getTrackName(channelMask);
+ return mAudioMixer->getTrackName(channelMask, sessionId);
}
// deleteTrackName_l() must be called with ThreadBase::mLock held
@@ -3460,14 +3501,14 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
#ifdef ADD_BATTERY_DATA
// when changing the audio output device, call addBatteryData to notify
// the change
- if ((int)mDevice != value) {
+ if (mOutDevice != value) {
uint32_t params = 0;
// check whether speaker is on
if (value & AUDIO_DEVICE_OUT_SPEAKER) {
params |= IMediaPlayerService::kBatteryDataSpeakerOn;
}
- int deviceWithoutSpeaker
+ audio_devices_t deviceWithoutSpeaker
= AUDIO_DEVICE_OUT_ALL & ~AUDIO_DEVICE_OUT_SPEAKER;
// check if any other device (except speaker) is on
if (value & deviceWithoutSpeaker ) {
@@ -3482,9 +3523,9 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
// forward device change to effects that have requested to be
// aware of attached audio device.
- mDevice = (uint32_t)value;
+ mOutDevice = value;
for (size_t i = 0; i < mEffectChains.size(); i++) {
- mEffectChains[i]->setDevice_l(mDevice);
+ mEffectChains[i]->setDevice_l(mOutDevice);
}
}
@@ -3505,7 +3546,7 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
readOutputParameters();
mAudioMixer = new AudioMixer(mNormalFrameCount, mSampleRate);
for (size_t i = 0; i < mTracks.size() ; i++) {
- int name = getTrackName_l((audio_channel_mask_t)mTracks[i]->mChannelMask);
+ int name = getTrackName_l(mTracks[i]->mChannelMask, mTracks[i]->mSessionId);
if (name < 0) break;
mTracks[i]->mName = name;
// limit track sample rate to 2 x new output sample rate
@@ -3513,7 +3554,7 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
mTracks[i]->mCblk->sampleRate = 2 * sampleRate();
}
}
- sendConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED);
+ sendIoConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED);
}
}
@@ -3539,7 +3580,7 @@ bool AudioFlinger::MixerThread::checkForNewParameters_l()
return reconfig;
}
-status_t AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& args)
+void AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -3593,7 +3634,8 @@ status_t AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>
#define TEE_SINK_READ 1024
short buffer[TEE_SINK_READ * FCC_2];
size_t count = TEE_SINK_READ;
- ssize_t actual = teeSource->read(buffer, count);
+ ssize_t actual = teeSource->read(buffer, count,
+ AudioBufferProvider::kInvalidPTS);
bool wasFirstRead = firstRead;
firstRead = false;
if (actual <= 0) {
@@ -3602,7 +3644,7 @@ status_t AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>
}
break;
}
- ALOG_ASSERT(actual <= count);
+ ALOG_ASSERT(actual <= (ssize_t)count);
write(teeFd, buffer, actual * channelCount * sizeof(short));
total += actual;
}
@@ -3619,13 +3661,13 @@ status_t AudioFlinger::MixerThread::dumpInternals(int fd, const Vector<String16>
}
}
+#ifdef AUDIO_WATCHDOG
if (mAudioWatchdog != 0) {
// Make a non-atomic copy of audio watchdog dump so it won't change underneath us
AudioWatchdogDump wdCopy = mAudioWatchdogDump;
wdCopy.dump(fd);
}
-
- return NO_ERROR;
+#endif
}
uint32_t AudioFlinger::MixerThread::idleSleepTimeUs() const
@@ -3651,7 +3693,7 @@ void AudioFlinger::MixerThread::cacheParameters_l()
// ----------------------------------------------------------------------------
AudioFlinger::DirectOutputThread::DirectOutputThread(const sp<AudioFlinger>& audioFlinger,
- AudioStreamOut* output, audio_io_handle_t id, uint32_t device)
+ AudioStreamOut* output, audio_io_handle_t id, audio_devices_t device)
: PlaybackThread(audioFlinger, output, id, device, DIRECT)
// mLeftVolFloat, mRightVolFloat
{
@@ -3756,11 +3798,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep
// We have consumed all the buffers of this track.
// Remove it from the list of active tracks.
// TODO: implement behavior for compressed audio
- size_t audioHALFrames =
- (mOutput->stream->get_latency(mOutput->stream)*mSampleRate) / 1000;
+ size_t audioHALFrames = (latency_l() * mSampleRate) / 1000;
size_t framesWritten =
mBytesWritten / audio_stream_frame_size(&mOutput->stream->common);
- if (track->presentationComplete(framesWritten, audioHALFrames)) {
+ if (mStandby || track->presentationComplete(framesWritten, audioHALFrames)) {
if (track->isStopped()) {
track->reset();
}
@@ -3836,7 +3877,8 @@ void AudioFlinger::DirectOutputThread::threadLoop_sleepTime()
}
// getTrackName_l() must be called with ThreadBase::mLock held
-int AudioFlinger::DirectOutputThread::getTrackName_l(audio_channel_mask_t channelMask)
+int AudioFlinger::DirectOutputThread::getTrackName_l(audio_channel_mask_t channelMask,
+ int sessionId)
{
return 0;
}
@@ -3879,7 +3921,7 @@ bool AudioFlinger::DirectOutputThread::checkForNewParameters_l()
}
if (status == NO_ERROR && reconfig) {
readOutputParameters();
- sendConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED);
+ sendIoConfigEvent_l(AudioSystem::OUTPUT_CONFIG_CHANGED);
}
}
@@ -3940,7 +3982,7 @@ void AudioFlinger::DirectOutputThread::cacheParameters_l()
AudioFlinger::DuplicatingThread::DuplicatingThread(const sp<AudioFlinger>& audioFlinger,
AudioFlinger::MixerThread* mainThread, audio_io_handle_t id)
- : MixerThread(audioFlinger, mainThread->getOutput(), id, mainThread->device(), DUPLICATING),
+ : MixerThread(audioFlinger, mainThread->getOutput(), id, mainThread->outDevice(), DUPLICATING),
mWaitTimeMs(UINT_MAX)
{
addOutputTrack(mainThread);
@@ -4070,6 +4112,7 @@ bool AudioFlinger::DuplicatingThread::outputsReady(const SortedVector< sp<Output
return false;
}
PlaybackThread *playbackThread = (PlaybackThread *)thread.get();
+ // see note at standby() declaration
if (playbackThread->standby() && !playbackThread->isSuspended()) {
ALOGV("DuplicatingThread output track %p on thread %p Not Ready", outputTracks[i].get(), thread.get());
return false;
@@ -4099,7 +4142,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase(
const sp<Client>& client,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId)
@@ -4274,7 +4317,7 @@ AudioFlinger::PlaybackThread::Track::Track(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId,
@@ -4300,7 +4343,7 @@ AudioFlinger::PlaybackThread::Track::Track(
// 16 bit because data is converted to 16 bit before being stored in buffer by AudioTrack
mCblk->frameSize = audio_is_linear_pcm(format) ? mChannelCount * sizeof(int16_t) : sizeof(uint8_t);
// to avoid leaking a track name, do not allocate one unless there is an mCblk
- mName = thread->getTrackName_l((audio_channel_mask_t)channelMask);
+ mName = thread->getTrackName_l(channelMask, sessionId);
mCblk->mName = mName;
if (mName < 0) {
ALOGE("no more track names available");
@@ -4329,11 +4372,6 @@ AudioFlinger::PlaybackThread::Track::Track(
AudioFlinger::PlaybackThread::Track::~Track()
{
ALOGV("PlaybackThread::Track destructor");
- sp<ThreadBase> thread = mThread.promote();
- if (thread != 0) {
- Mutex::Autolock _l(thread->mLock);
- mState = TERMINATED;
- }
}
void AudioFlinger::PlaybackThread::Track::destroy()
@@ -4496,8 +4534,6 @@ status_t AudioFlinger::PlaybackThread::Track::getNextBuffer(
}
buffer->raw = getBuffer(s, framesReq);
- if (buffer->raw == NULL) goto getNextBuffer_exit;
-
buffer->frameCount = framesReq;
return NO_ERROR;
}
@@ -4645,7 +4681,7 @@ void AudioFlinger::PlaybackThread::Track::flush()
if (thread != 0) {
Mutex::Autolock _l(thread->mLock);
if (mState != STOPPING_1 && mState != STOPPING_2 && mState != STOPPED && mState != PAUSED &&
- mState != PAUSING) {
+ mState != PAUSING && mState != IDLE && mState != FLUSHED) {
return;
}
// No point remaining in PAUSED state after a flush => go to
@@ -4808,7 +4844,7 @@ status_t AudioFlinger::PlaybackThread::Track::setSyncEvent(const sp<SyncEvent>&
event->cancel();
return INVALID_OPERATION;
}
- TrackBase::setSyncEvent(event);
+ (void) TrackBase::setSyncEvent(event);
return NO_ERROR;
}
@@ -4821,12 +4857,12 @@ AudioFlinger::PlaybackThread::TimedTrack::create(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId) {
if (!client->reserveTimedTrack())
- return NULL;
+ return 0;
return new TimedTrack(
thread, client, streamType, sampleRate, format, channelMask, frameCount,
@@ -4839,7 +4875,7 @@ AudioFlinger::PlaybackThread::TimedTrack::TimedTrack(
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId)
@@ -5061,7 +5097,7 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer(
AudioBufferProvider::Buffer* buffer, int64_t pts)
{
if (pts == AudioBufferProvider::kInvalidPTS) {
- buffer->raw = 0;
+ buffer->raw = NULL;
buffer->frameCount = 0;
mTimedAudioOutputOnTime = false;
return INVALID_OPERATION;
@@ -5076,7 +5112,7 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer(
// if we have no timed buffers, then fail
if (mTimedBufferQueue.isEmpty()) {
- buffer->raw = 0;
+ buffer->raw = NULL;
buffer->frameCount = 0;
return NOT_ENOUGH_DATA;
}
@@ -5103,7 +5139,7 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer(
// the transform failed. this shouldn't happen, but if it does
// then just drop this buffer
ALOGW("timedGetNextBuffer transform failed");
- buffer->raw = 0;
+ buffer->raw = NULL;
buffer->frameCount = 0;
trimTimedBufferQueueHead_l("getNextBuffer; no transform");
return NO_ERROR;
@@ -5112,7 +5148,7 @@ status_t AudioFlinger::PlaybackThread::TimedTrack::getNextBuffer(
if (mMediaTimeTransformTarget == TimedAudioTrack::COMMON_TIME) {
if (OK != mCCHelper.commonTimeToLocalTime(transformedPTS,
&headLocalPTS)) {
- buffer->raw = 0;
+ buffer->raw = NULL;
buffer->frameCount = 0;
return INVALID_OPERATION;
}
@@ -5334,7 +5370,7 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
const sp<Client>& client,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
int sessionId)
: TrackBase(thread, client, sampleRate, format,
@@ -5355,10 +5391,7 @@ AudioFlinger::RecordThread::RecordTrack::RecordTrack(
AudioFlinger::RecordThread::RecordTrack::~RecordTrack()
{
- sp<ThreadBase> thread = mThread.promote();
- if (thread != 0) {
- AudioSystem::releaseInput(thread->id());
- }
+ ALOGV("%s", __func__);
}
// AudioBufferProvider interface
@@ -5389,8 +5422,6 @@ status_t AudioFlinger::RecordThread::RecordTrack::getNextBuffer(AudioBufferProvi
}
buffer->raw = getBuffer(s, framesReq);
- if (buffer->raw == NULL) goto getNextBuffer_exit;
-
buffer->frameCount = framesReq;
return NO_ERROR;
}
@@ -5418,17 +5449,29 @@ void AudioFlinger::RecordThread::RecordTrack::stop()
sp<ThreadBase> thread = mThread.promote();
if (thread != 0) {
RecordThread *recordThread = (RecordThread *)thread.get();
- recordThread->stop(this);
- TrackBase::reset();
- // Force overrun condition to avoid false overrun callback until first data is
- // read from buffer
- android_atomic_or(CBLK_UNDERRUN_ON, &mCblk->flags);
+ recordThread->mLock.lock();
+ bool doStop = recordThread->stop_l(this);
+ if (doStop) {
+ TrackBase::reset();
+ // Force overrun condition to avoid false overrun callback until first data is
+ // read from buffer
+ android_atomic_or(CBLK_UNDERRUN_ON, &mCblk->flags);
+ }
+ recordThread->mLock.unlock();
+ if (doStop) {
+ AudioSystem::stopInput(recordThread->id());
+ }
}
}
+/*static*/ void AudioFlinger::RecordThread::RecordTrack::appendDumpHeader(String8& result)
+{
+ result.append(" Clien Fmt Chn mask Session Buf S SRate Serv User FrameCount\n");
+}
+
void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size)
{
- snprintf(buffer, size, " %05d %03u 0x%08x %05d %04u %01d %05u %08x %08x\n",
+ snprintf(buffer, size, " %05d %03u 0x%08x %05d %04u %01d %05u %08x %08x %05d\n",
(mClient == 0) ? getpid_cached : mClient->pid(),
mFormat,
mChannelMask,
@@ -5437,7 +5480,8 @@ void AudioFlinger::RecordThread::RecordTrack::dump(char* buffer, size_t size)
mState,
mCblk->sampleRate,
mCblk->server,
- mCblk->user);
+ mCblk->user,
+ mCblk->frameCount);
}
@@ -5448,7 +5492,7 @@ AudioFlinger::PlaybackThread::OutputTrack::OutputTrack(
DuplicatingThread *sourceThread,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount)
: Track(playbackThread, NULL, AUDIO_STREAM_CNT, sampleRate, format, channelMask, frameCount,
NULL, 0, IAudioFlinger::TRACK_DEFAULT),
@@ -5836,9 +5880,10 @@ sp<IAudioRecord> AudioFlinger::openRecord(
audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
IAudioFlinger::track_flags_t flags,
+ pid_t tid,
int *sessionId,
status_t *status)
{
@@ -5877,13 +5922,8 @@ sp<IAudioRecord> AudioFlinger::openRecord(
}
}
// create new record track. The record track uses one track in mHardwareMixerThread by convention.
- recordTrack = thread->createRecordTrack_l(client,
- sampleRate,
- format,
- channelMask,
- frameCount,
- lSessionId,
- &lStatus);
+ recordTrack = thread->createRecordTrack_l(client, sampleRate, format, channelMask,
+ frameCount, lSessionId, flags, tid, &lStatus);
}
if (lStatus != NO_ERROR) {
// remove local strong reference to Client before deleting the RecordTrack so that the Client
@@ -5913,19 +5953,24 @@ AudioFlinger::RecordHandle::RecordHandle(const sp<AudioFlinger::RecordThread::Re
}
AudioFlinger::RecordHandle::~RecordHandle() {
- stop();
+ stop_nonvirtual();
+ mRecordTrack->destroy();
}
sp<IMemory> AudioFlinger::RecordHandle::getCblk() const {
return mRecordTrack->getCblk();
}
-status_t AudioFlinger::RecordHandle::start(int event, int triggerSession) {
+status_t AudioFlinger::RecordHandle::start(int /*AudioSystem::sync_event_t*/ event, int triggerSession) {
ALOGV("RecordHandle::start()");
return mRecordTrack->start((AudioSystem::sync_event_t)event, triggerSession);
}
void AudioFlinger::RecordHandle::stop() {
+ stop_nonvirtual();
+}
+
+void AudioFlinger::RecordHandle::stop_nonvirtual() {
ALOGV("RecordHandle::stop()");
mRecordTrack->stop();
}
@@ -5941,13 +5986,13 @@ status_t AudioFlinger::RecordHandle::onTransact(
AudioFlinger::RecordThread::RecordThread(const sp<AudioFlinger>& audioFlinger,
AudioStreamIn *input,
uint32_t sampleRate,
- uint32_t channels,
+ audio_channel_mask_t channelMask,
audio_io_handle_t id,
- uint32_t device) :
- ThreadBase(audioFlinger, id, device, RECORD),
- mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL),
+ audio_devices_t device) :
+ ThreadBase(audioFlinger, id, AUDIO_DEVICE_NONE, device, RECORD),
+ mInput(input), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL),
// mRsmpInIndex and mInputBytes set by readInputParameters()
- mReqChannelCount(popcount(channels)),
+ mReqChannelCount(popcount(channelMask)),
mReqSampleRate(sampleRate)
// mBytesRead is only meaningful while active, and so is cleared in start()
// (but might be better to also clear here for dump?)
@@ -5985,8 +6030,12 @@ bool AudioFlinger::RecordThread::threadLoop()
nsecs_t lastWarning = 0;
+ inputStandBy();
acquireWakeLock();
+ // used to verify we've read at least once before evaluating how many bytes were read
+ bool readOnce = false;
+
// start recording
while (!exitPending()) {
@@ -5996,10 +6045,7 @@ bool AudioFlinger::RecordThread::threadLoop()
Mutex::Autolock _l(mLock);
checkForNewParameters_l();
if (mActiveTrack == 0 && mConfigEvents.isEmpty()) {
- if (!mStandby) {
- mInput->stream->common.standby(&mInput->stream->common);
- mStandby = true;
- }
+ standby();
if (exitPending()) break;
@@ -6013,20 +6059,17 @@ bool AudioFlinger::RecordThread::threadLoop()
}
if (mActiveTrack != 0) {
if (mActiveTrack->mState == TrackBase::PAUSING) {
- if (!mStandby) {
- mInput->stream->common.standby(&mInput->stream->common);
- mStandby = true;
- }
+ standby();
mActiveTrack.clear();
mStartStopCond.broadcast();
} else if (mActiveTrack->mState == TrackBase::RESUMING) {
if (mReqChannelCount != mActiveTrack->channelCount()) {
mActiveTrack.clear();
mStartStopCond.broadcast();
- } else if (mBytesRead != 0) {
+ } else if (readOnce) {
// record start succeeds only if first read from audio input
// succeeds
- if (mBytesRead > 0) {
+ if (mBytesRead >= 0) {
mActiveTrack->mState = TrackBase::ACTIVE;
} else {
mActiveTrack.clear();
@@ -6034,6 +6077,9 @@ bool AudioFlinger::RecordThread::threadLoop()
mStartStopCond.broadcast();
}
mStandby = false;
+ } else if (mActiveTrack->mState == TrackBase::TERMINATED) {
+ removeTrack_l(mActiveTrack);
+ mActiveTrack.clear();
}
}
lockEffectChains_l(effectChains);
@@ -6052,6 +6098,7 @@ bool AudioFlinger::RecordThread::threadLoop()
buffer.frameCount = mFrameCount;
if (CC_LIKELY(mActiveTrack->getNextBuffer(&buffer) == NO_ERROR)) {
+ readOnce = true;
size_t framesOut = buffer.frameCount;
if (mResampler == NULL) {
// no resampling
@@ -6068,18 +6115,12 @@ bool AudioFlinger::RecordThread::threadLoop()
mFormat != AUDIO_FORMAT_PCM_16_BIT) {
memcpy(dst, src, framesIn * mFrameSize);
} else {
- int16_t *src16 = (int16_t *)src;
- int16_t *dst16 = (int16_t *)dst;
if (mChannelCount == 1) {
- while (framesIn--) {
- *dst16++ = *src16;
- *dst16++ = *src16++;
- }
+ upmix_to_stereo_i16_from_mono_i16((int16_t *)dst,
+ (int16_t *)src, framesIn);
} else {
- while (framesIn--) {
- *dst16++ = (int16_t)(((int32_t)*src16 + (int32_t)*(src16 + 1)) >> 1);
- src16 += 2;
- }
+ downmix_to_mono_i16_from_stereo_i16((int16_t *)dst,
+ (int16_t *)src, framesIn);
}
}
}
@@ -6092,12 +6133,13 @@ bool AudioFlinger::RecordThread::threadLoop()
mBytesRead = mInput->stream->read(mInput->stream, mRsmpInBuffer, mInputBytes);
mRsmpInIndex = 0;
}
- if (mBytesRead < 0) {
- ALOGE("Error reading audio input");
- if (mActiveTrack->mState == TrackBase::ACTIVE) {
+ if (mBytesRead <= 0) {
+ if ((mBytesRead < 0) && (mActiveTrack->mState == TrackBase::ACTIVE))
+ {
+ ALOGE("Error reading audio input");
// Force input into standby so that it tries to
// recover at next read attempt
- mInput->stream->common.standby(&mInput->stream->common);
+ inputStandBy();
usleep(kRecordThreadSleepUs);
}
mRsmpInIndex = mFrameCount;
@@ -6114,18 +6156,14 @@ bool AudioFlinger::RecordThread::threadLoop()
if (mChannelCount == 1 && mReqChannelCount == 1) {
framesOut >>= 1;
}
- mResampler->resample(mRsmpOutBuffer, framesOut, this);
+ mResampler->resample(mRsmpOutBuffer, framesOut, this /* AudioBufferProvider* */);
// ditherAndClamp() works as long as all buffers returned by mActiveTrack->getNextBuffer()
// are 32 bit aligned which should be always true.
if (mChannelCount == 2 && mReqChannelCount == 1) {
ditherAndClamp(mRsmpOutBuffer, mRsmpOutBuffer, framesOut);
// the resampler always outputs stereo samples: do post stereo to mono conversion
- int16_t *src = (int16_t *)mRsmpOutBuffer;
- int16_t *dst = buffer.i16;
- while (framesOut--) {
- *dst++ = (int16_t)(((int32_t)*src + (int32_t)*(src + 1)) >> 1);
- src += 2;
- }
+ downmix_to_mono_i16_from_stereo_i16(buffer.i16, (int16_t *)mRsmpOutBuffer,
+ framesOut);
} else {
ditherAndClamp((int32_t *)buffer.raw, mRsmpOutBuffer, framesOut);
}
@@ -6151,7 +6189,7 @@ bool AudioFlinger::RecordThread::threadLoop()
}
}
}
- mActiveTrack->overflow();
+ mActiveTrack->clearOverflow();
}
// client isn't retrieving buffers fast enough
else {
@@ -6173,12 +6211,13 @@ bool AudioFlinger::RecordThread::threadLoop()
effectChains.clear();
}
- if (!mStandby) {
- mInput->stream->common.standby(&mInput->stream->common);
- }
- mActiveTrack.clear();
+ standby();
- mStartStopCond.broadcast();
+ {
+ Mutex::Autolock _l(mLock);
+ mActiveTrack.clear();
+ mStartStopCond.broadcast();
+ }
releaseWakeLock();
@@ -6186,14 +6225,28 @@ bool AudioFlinger::RecordThread::threadLoop()
return false;
}
+void AudioFlinger::RecordThread::standby()
+{
+ if (!mStandby) {
+ inputStandBy();
+ mStandby = true;
+ }
+}
+
+void AudioFlinger::RecordThread::inputStandBy()
+{
+ mInput->stream->common.standby(&mInput->stream->common);
+}
sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createRecordTrack_l(
const sp<AudioFlinger::Client>& client,
uint32_t sampleRate,
audio_format_t format,
- int channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
int sessionId,
+ IAudioFlinger::track_flags_t flags,
+ pid_t tid,
status_t *status)
{
sp<RecordTrack> track;
@@ -6205,6 +6258,8 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR
goto Exit;
}
+ // FIXME use flags and tid similar to createTrack_l()
+
{ // scope for mLock
Mutex::Autolock _l(mLock);
@@ -6215,11 +6270,11 @@ sp<AudioFlinger::RecordThread::RecordTrack> AudioFlinger::RecordThread::createR
lStatus = NO_MEMORY;
goto Exit;
}
+ mTracks.add(track);
- mTrack = track.get();
// disable AEC and NS if the device is a BT SCO headset supporting those pre processings
- bool suspend = audio_is_bluetooth_sco_device(
- (audio_devices_t)(mDevice & AUDIO_DEVICE_IN_ALL)) && mAudioFlinger->btNrecIsOff();
+ bool suspend = audio_is_bluetooth_sco_device(mInDevice) &&
+ mAudioFlinger->btNrecIsOff();
setEffectSuspended_l(FX_IID_AEC, suspend, sessionId);
setEffectSuspended_l(FX_IID_NS, suspend, sessionId);
}
@@ -6287,7 +6342,7 @@ status_t AudioFlinger::RecordThread::start(RecordThread::RecordTrack* recordTrac
mActiveTrack->mState = TrackBase::RESUMING;
// signal thread to start
ALOGV("Signal record thread");
- mWaitWorkCV.signal();
+ mWaitWorkCV.broadcast();
// do not wait for mStartStopCond if exiting
if (exitPending()) {
mActiveTrack.clear();
@@ -6337,50 +6392,97 @@ void AudioFlinger::RecordThread::handleSyncStartEvent(const sp<SyncEvent>& event
}
}
-void AudioFlinger::RecordThread::stop(RecordThread::RecordTrack* recordTrack) {
+bool AudioFlinger::RecordThread::stop_l(RecordThread::RecordTrack* recordTrack) {
ALOGV("RecordThread::stop");
- sp<ThreadBase> strongMe = this;
- {
- AutoMutex lock(mLock);
- if (mActiveTrack != 0 && recordTrack == mActiveTrack.get()) {
- mActiveTrack->mState = TrackBase::PAUSING;
- // do not wait for mStartStopCond if exiting
- if (exitPending()) {
- return;
- }
- mStartStopCond.wait(mLock);
- // if we have been restarted, recordTrack == mActiveTrack.get() here
- if (mActiveTrack == 0 || recordTrack != mActiveTrack.get()) {
- mLock.unlock();
- AudioSystem::stopInput(mId);
- mLock.lock();
- ALOGV("Record stopped OK");
- }
- }
+ if (recordTrack != mActiveTrack.get() || recordTrack->mState == TrackBase::PAUSING) {
+ return false;
}
+ recordTrack->mState = TrackBase::PAUSING;
+ // do not wait for mStartStopCond if exiting
+ if (exitPending()) {
+ return true;
+ }
+ mStartStopCond.wait(mLock);
+ // if we have been restarted, recordTrack == mActiveTrack.get() here
+ if (exitPending() || recordTrack != mActiveTrack.get()) {
+ ALOGV("Record stopped OK");
+ return true;
+ }
+ return false;
}
-bool AudioFlinger::RecordThread::isValidSyncEvent(const sp<SyncEvent>& event)
+bool AudioFlinger::RecordThread::isValidSyncEvent(const sp<SyncEvent>& event) const
{
return false;
}
status_t AudioFlinger::RecordThread::setSyncEvent(const sp<SyncEvent>& event)
{
+#if 0 // This branch is currently dead code, but is preserved in case it will be needed in future
if (!isValidSyncEvent(event)) {
return BAD_VALUE;
}
+ int eventSession = event->triggerSession();
+ status_t ret = NAME_NOT_FOUND;
+
Mutex::Autolock _l(mLock);
- if (mTrack != NULL && event->triggerSession() == mTrack->sessionId()) {
- mTrack->setSyncEvent(event);
- return NO_ERROR;
+ for (size_t i = 0; i < mTracks.size(); i++) {
+ sp<RecordTrack> track = mTracks[i];
+ if (eventSession == track->sessionId()) {
+ (void) track->setSyncEvent(event);
+ ret = NO_ERROR;
+ }
+ }
+ return ret;
+#else
+ return BAD_VALUE;
+#endif
+}
+
+void AudioFlinger::RecordThread::RecordTrack::destroy()
+{
+ // see comments at AudioFlinger::PlaybackThread::Track::destroy()
+ sp<RecordTrack> keep(this);
+ {
+ sp<ThreadBase> thread = mThread.promote();
+ if (thread != 0) {
+ if (mState == ACTIVE || mState == RESUMING) {
+ AudioSystem::stopInput(thread->id());
+ }
+ AudioSystem::releaseInput(thread->id());
+ Mutex::Autolock _l(thread->mLock);
+ RecordThread *recordThread = (RecordThread *) thread.get();
+ recordThread->destroyTrack_l(this);
+ }
+ }
+}
+
+// destroyTrack_l() must be called with ThreadBase::mLock held
+void AudioFlinger::RecordThread::destroyTrack_l(const sp<RecordTrack>& track)
+{
+ track->mState = TrackBase::TERMINATED;
+ // active tracks are removed by threadLoop()
+ if (mActiveTrack != track) {
+ removeTrack_l(track);
}
- return NAME_NOT_FOUND;
}
-status_t AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args)
+void AudioFlinger::RecordThread::removeTrack_l(const sp<RecordTrack>& track)
+{
+ mTracks.remove(track);
+ // need anything related to effects here?
+}
+
+void AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args)
+{
+ dumpInternals(fd, args);
+ dumpTracks(fd, args);
+ dumpEffectChains(fd, args);
+}
+
+void AudioFlinger::RecordThread::dumpInternals(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -6390,11 +6492,6 @@ status_t AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args)
result.append(buffer);
if (mActiveTrack != 0) {
- result.append("Active Track:\n");
- result.append(" Clien Fmt Chn mask Session Buf S SRate Serv User\n");
- mActiveTrack->dump(buffer, SIZE);
- result.append(buffer);
-
snprintf(buffer, SIZE, "In index: %d\n", mRsmpInIndex);
result.append(buffer);
snprintf(buffer, SIZE, "In size: %d\n", mInputBytes);
@@ -6405,17 +6502,41 @@ status_t AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args)
result.append(buffer);
snprintf(buffer, SIZE, "Out sample rate: %d\n", mReqSampleRate);
result.append(buffer);
-
-
} else {
- result.append("No record client\n");
+ result.append("No active record client\n");
}
+
write(fd, result.string(), result.size());
dumpBase(fd, args);
- dumpEffectChains(fd, args);
+}
- return NO_ERROR;
+void AudioFlinger::RecordThread::dumpTracks(int fd, const Vector<String16>& args)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+
+ snprintf(buffer, SIZE, "Input thread %p tracks\n", this);
+ result.append(buffer);
+ RecordTrack::appendDumpHeader(result);
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ sp<RecordTrack> track = mTracks[i];
+ if (track != 0) {
+ track->dump(buffer, SIZE);
+ result.append(buffer);
+ }
+ }
+
+ if (mActiveTrack != 0) {
+ snprintf(buffer, SIZE, "\nInput thread %p active tracks\n", this);
+ result.append(buffer);
+ RecordTrack::appendDumpHeader(result);
+ mActiveTrack->dump(buffer, SIZE);
+ result.append(buffer);
+
+ }
+ write(fd, result.string(), result.size());
}
// AudioBufferProvider interface
@@ -6427,12 +6548,12 @@ status_t AudioFlinger::RecordThread::getNextBuffer(AudioBufferProvider::Buffer*
if (framesReady == 0) {
mBytesRead = mInput->stream->read(mInput->stream, mRsmpInBuffer, mInputBytes);
- if (mBytesRead < 0) {
- ALOGE("RecordThread::getNextBuffer() Error reading audio input");
- if (mActiveTrack->mState == TrackBase::ACTIVE) {
+ if (mBytesRead <= 0) {
+ if ((mBytesRead < 0) && (mActiveTrack->mState == TrackBase::ACTIVE)) {
+ ALOGE("RecordThread::getNextBuffer() Error reading audio input");
// Force input into standby so that it tries to
// recover at next read attempt
- mInput->stream->common.standby(&mInput->stream->common);
+ inputStandBy();
usleep(kRecordThreadSleepUs);
}
buffer->raw = NULL;
@@ -6505,28 +6626,40 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l()
for (size_t i = 0; i < mEffectChains.size(); i++) {
mEffectChains[i]->setDevice_l(value);
}
+
// store input device and output device but do not forward output device to audio HAL.
// Note that status is ignored by the caller for output device
// (see AudioFlinger::setParameters()
- if (value & AUDIO_DEVICE_OUT_ALL) {
- mDevice &= (uint32_t)~(value & AUDIO_DEVICE_OUT_ALL);
+ if (audio_is_output_devices(value)) {
+ mOutDevice = value;
status = BAD_VALUE;
} else {
- mDevice &= (uint32_t)~(value & AUDIO_DEVICE_IN_ALL);
+ mInDevice = value;
// disable AEC and NS if the device is a BT SCO headset supporting those pre processings
- if (mTrack != NULL) {
- bool suspend = audio_is_bluetooth_sco_device(
- (audio_devices_t)value) && mAudioFlinger->btNrecIsOff();
- setEffectSuspended_l(FX_IID_AEC, suspend, mTrack->sessionId());
- setEffectSuspended_l(FX_IID_NS, suspend, mTrack->sessionId());
+ if (mTracks.size() > 0) {
+ bool suspend = audio_is_bluetooth_sco_device(mInDevice) &&
+ mAudioFlinger->btNrecIsOff();
+ for (size_t i = 0; i < mTracks.size(); i++) {
+ sp<RecordTrack> track = mTracks[i];
+ setEffectSuspended_l(FX_IID_AEC, suspend, track->sessionId());
+ setEffectSuspended_l(FX_IID_NS, suspend, track->sessionId());
+ }
}
}
- mDevice |= (uint32_t)value;
+ }
+ if (param.getInt(String8(AudioParameter::keyInputSource), value) == NO_ERROR &&
+ mAudioSource != (audio_source_t)value) {
+ // forward device change to effects that have requested to be
+ // aware of attached audio device.
+ for (size_t i = 0; i < mEffectChains.size(); i++) {
+ mEffectChains[i]->setAudioSource_l((audio_source_t)value);
+ }
+ mAudioSource = (audio_source_t)value;
}
if (status == NO_ERROR) {
status = mInput->stream->common.set_parameters(&mInput->stream->common, keyValuePair.string());
if (status == INVALID_OPERATION) {
- mInput->stream->common.standby(&mInput->stream->common);
+ inputStandBy();
status = mInput->stream->common.set_parameters(&mInput->stream->common,
keyValuePair.string());
}
@@ -6541,7 +6674,7 @@ bool AudioFlinger::RecordThread::checkForNewParameters_l()
}
if (status == NO_ERROR) {
readInputParameters();
- sendConfigEvent_l(AudioSystem::INPUT_CONFIG_CHANGED);
+ sendIoConfigEvent_l(AudioSystem::INPUT_CONFIG_CHANGED);
}
}
}
@@ -6648,7 +6781,7 @@ unsigned int AudioFlinger::RecordThread::getInputFramesLost()
return mInput->stream->get_input_frames_lost(mInput->stream);
}
-uint32_t AudioFlinger::RecordThread::hasAudioSession(int sessionId)
+uint32_t AudioFlinger::RecordThread::hasAudioSession(int sessionId) const
{
Mutex::Autolock _l(mLock);
uint32_t result = 0;
@@ -6656,23 +6789,28 @@ uint32_t AudioFlinger::RecordThread::hasAudioSession(int sessionId)
result = EFFECT_SESSION;
}
- if (mTrack != NULL && sessionId == mTrack->sessionId()) {
- result |= TRACK_SESSION;
+ for (size_t i = 0; i < mTracks.size(); ++i) {
+ if (sessionId == mTracks[i]->sessionId()) {
+ result |= TRACK_SESSION;
+ break;
+ }
}
return result;
}
-AudioFlinger::RecordThread::RecordTrack* AudioFlinger::RecordThread::track()
+KeyedVector<int, bool> AudioFlinger::RecordThread::sessionIds() const
{
+ KeyedVector<int, bool> ids;
Mutex::Autolock _l(mLock);
- return mTrack;
-}
-
-AudioFlinger::AudioStreamIn* AudioFlinger::RecordThread::getInput() const
-{
- Mutex::Autolock _l(mLock);
- return mInput;
+ for (size_t j = 0; j < mTracks.size(); ++j) {
+ sp<RecordThread::RecordTrack> track = mTracks[j];
+ int sessionId = track->sessionId();
+ if (ids.indexOfKey(sessionId) < 0) {
+ ids.add(sessionId, true);
+ }
+ }
+ return ids;
}
AudioFlinger::AudioStreamIn* AudioFlinger::RecordThread::clearInput()
@@ -6730,16 +6868,52 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
return 0;
}
- if ((mMasterVolumeSupportLvl != MVS_NONE) &&
- (NULL != dev->set_master_volume)) {
+ // Check and cache this HAL's level of support for master mute and master
+ // volume. If this is the first HAL opened, and it supports the get
+ // methods, use the initial values provided by the HAL as the current
+ // master mute and volume settings.
+
+ AudioHwDevice::Flags flags = static_cast<AudioHwDevice::Flags>(0);
+ { // scope for auto-lock pattern
AutoMutex lock(mHardwareLock);
+
+ if (0 == mAudioHwDevs.size()) {
+ mHardwareStatus = AUDIO_HW_GET_MASTER_VOLUME;
+ if (NULL != dev->get_master_volume) {
+ float mv;
+ if (OK == dev->get_master_volume(dev, &mv)) {
+ mMasterVolume = mv;
+ }
+ }
+
+ mHardwareStatus = AUDIO_HW_GET_MASTER_MUTE;
+ if (NULL != dev->get_master_mute) {
+ bool mm;
+ if (OK == dev->get_master_mute(dev, &mm)) {
+ mMasterMute = mm;
+ }
+ }
+ }
+
mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
- dev->set_master_volume(dev, mMasterVolume);
+ if ((NULL != dev->set_master_volume) &&
+ (OK == dev->set_master_volume(dev, mMasterVolume))) {
+ flags = static_cast<AudioHwDevice::Flags>(flags |
+ AudioHwDevice::AHWD_CAN_SET_MASTER_VOLUME);
+ }
+
+ mHardwareStatus = AUDIO_HW_SET_MASTER_MUTE;
+ if ((NULL != dev->set_master_mute) &&
+ (OK == dev->set_master_mute(dev, mMasterMute))) {
+ flags = static_cast<AudioHwDevice::Flags>(flags |
+ AudioHwDevice::AHWD_CAN_SET_MASTER_MUTE);
+ }
+
mHardwareStatus = AUDIO_HW_IDLE;
}
audio_module_handle_t handle = nextUniqueId();
- mAudioHwDevs.add(handle, new AudioHwDevice(name, dev));
+ mAudioHwDevs.add(handle, new AudioHwDevice(name, dev, flags));
ALOGI("loadHwModule() Loaded %s audio interface from %s (%s) handle %d",
name, dev->common.module->name, dev->common.module->id, handle);
@@ -6748,6 +6922,24 @@ audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name)
}
+// ----------------------------------------------------------------------------
+
+int32_t AudioFlinger::getPrimaryOutputSamplingRate()
+{
+ Mutex::Autolock _l(mLock);
+ PlaybackThread *thread = primaryPlaybackThread_l();
+ return thread != NULL ? thread->sampleRate() : 0;
+}
+
+int32_t AudioFlinger::getPrimaryOutputFrameCount()
+{
+ Mutex::Autolock _l(mLock);
+ PlaybackThread *thread = primaryPlaybackThread_l();
+ return thread != NULL ? thread->frameCountHAL() : 0;
+}
+
+// ----------------------------------------------------------------------------
+
audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
audio_devices_t *pDevices,
uint32_t *pSamplingRate,
@@ -6764,11 +6956,11 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
format: pFormat ? *pFormat : AUDIO_FORMAT_DEFAULT,
};
audio_stream_out_t *outStream = NULL;
- audio_hw_device_t *outHwDev;
+ AudioHwDevice *outHwDev;
ALOGV("openOutput(), module %d Device %x, SamplingRate %d, Format %d, Channels %x, flags %x",
module,
- (pDevices != NULL) ? (int)*pDevices : 0,
+ (pDevices != NULL) ? *pDevices : 0,
config.sample_rate,
config.format,
config.channel_mask,
@@ -6784,11 +6976,12 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
if (outHwDev == NULL)
return 0;
+ audio_hw_device_t *hwDevHal = outHwDev->hwDevice();
audio_io_handle_t id = nextUniqueId();
mHardwareStatus = AUDIO_HW_OUTPUT_OPEN;
- status = outHwDev->open_output_stream(outHwDev,
+ status = hwDevHal->open_output_stream(hwDevHal,
id,
*pDevices,
(audio_output_flags_t)flags,
@@ -6832,41 +7025,8 @@ audio_io_handle_t AudioFlinger::openOutput(audio_module_handle_t module,
AutoMutex lock(mHardwareLock);
mHardwareStatus = AUDIO_HW_SET_MODE;
- outHwDev->set_mode(outHwDev, mMode);
-
- // Determine the level of master volume support the primary audio HAL has,
- // and set the initial master volume at the same time.
- float initialVolume = 1.0;
- mMasterVolumeSupportLvl = MVS_NONE;
-
- mHardwareStatus = AUDIO_HW_GET_MASTER_VOLUME;
- if ((NULL != outHwDev->get_master_volume) &&
- (NO_ERROR == outHwDev->get_master_volume(outHwDev, &initialVolume))) {
- mMasterVolumeSupportLvl = MVS_FULL;
- } else {
- mMasterVolumeSupportLvl = MVS_SETONLY;
- initialVolume = 1.0;
- }
-
- mHardwareStatus = AUDIO_HW_SET_MASTER_VOLUME;
- if ((NULL == outHwDev->set_master_volume) ||
- (NO_ERROR != outHwDev->set_master_volume(outHwDev, initialVolume))) {
- mMasterVolumeSupportLvl = MVS_NONE;
- }
- // now that we have a primary device, initialize master volume on other devices
- for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
- audio_hw_device_t *dev = mAudioHwDevs.valueAt(i)->hwDevice();
-
- if ((dev != mPrimaryHardwareDev) &&
- (NULL != dev->set_master_volume)) {
- dev->set_master_volume(dev, initialVolume);
- }
- }
+ hwDevHal->set_mode(hwDevHal, mMode);
mHardwareStatus = AUDIO_HW_IDLE;
- mMasterVolumeSW = (MVS_NONE == mMasterVolumeSupportLvl)
- ? initialVolume
- : 1.0;
- mMasterVolume = initialVolume;
}
return id;
}
@@ -6897,6 +7057,11 @@ audio_io_handle_t AudioFlinger::openDuplicateOutput(audio_io_handle_t output1,
status_t AudioFlinger::closeOutput(audio_io_handle_t output)
{
+ return closeOutput_nonvirtual(output);
+}
+
+status_t AudioFlinger::closeOutput_nonvirtual(audio_io_handle_t output)
+{
// keep strong reference on the playback thread so that
// it is not destroyed while exit() is executed
sp<PlaybackThread> thread;
@@ -6928,7 +7093,7 @@ status_t AudioFlinger::closeOutput(audio_io_handle_t output)
AudioStreamOut *out = thread->clearOutput();
ALOG_ASSERT(out != NULL, "out shouldn't be NULL");
// from now on thread->mOutput is NULL
- out->hwDev->close_output_stream(out->hwDev, out->stream);
+ out->hwDev()->close_output_stream(out->hwDev(), out->stream);
delete out;
}
return NO_ERROR;
@@ -6969,7 +7134,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
audio_devices_t *pDevices,
uint32_t *pSamplingRate,
audio_format_t *pFormat,
- uint32_t *pChannelMask)
+ audio_channel_mask_t *pChannelMask)
{
status_t status;
RecordThread *thread = NULL;
@@ -6982,7 +7147,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
audio_format_t reqFormat = config.format;
audio_channel_mask_t reqChannels = config.channel_mask;
audio_stream_in_t *inStream = NULL;
- audio_hw_device_t *inHwDev;
+ AudioHwDevice *inHwDev;
if (pDevices == NULL || *pDevices == 0) {
return 0;
@@ -6994,9 +7159,10 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
if (inHwDev == NULL)
return 0;
+ audio_hw_device_t *inHwHal = inHwDev->hwDevice();
audio_io_handle_t id = nextUniqueId();
- status = inHwDev->open_input_stream(inHwDev, id, *pDevices, &config,
+ status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config,
&inStream);
ALOGV("openInput() openInputStream returned input %p, SamplingRate %d, Format %d, Channels %x, status %d",
inStream,
@@ -7012,9 +7178,9 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
reqFormat == config.format && config.format == AUDIO_FORMAT_PCM_16_BIT &&
(config.sample_rate <= 2 * reqSamplingRate) &&
(popcount(config.channel_mask) <= FCC_2) && (popcount(reqChannels) <= FCC_2)) {
- ALOGV("openInput() reopening with proposed sampling rate and channels");
+ ALOGV("openInput() reopening with proposed sampling rate and channel mask");
inStream = NULL;
- status = inHwDev->open_input_stream(inHwDev, id, *pDevices, &config, &inStream);
+ status = inHwHal->open_input_stream(inHwHal, id, *pDevices, &config, &inStream);
}
if (status == NO_ERROR && inStream != NULL) {
@@ -7023,7 +7189,7 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
// Start record thread
// RecorThread require both input and output device indication to forward to audio
// pre processing modules
- uint32_t device = (*pDevices) | primaryOutputDevice_l();
+ audio_devices_t device = (*pDevices) | primaryOutputDevice_l();
thread = new RecordThread(this,
input,
reqSamplingRate,
@@ -7036,8 +7202,6 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
if (pFormat != NULL) *pFormat = config.format;
if (pChannelMask != NULL) *pChannelMask = reqChannels;
- input->stream->common.standby(&input->stream->common);
-
// notify client processes of the new input creation
thread->audioConfigChanged_l(AudioSystem::INPUT_OPENED);
return id;
@@ -7048,13 +7212,18 @@ audio_io_handle_t AudioFlinger::openInput(audio_module_handle_t module,
status_t AudioFlinger::closeInput(audio_io_handle_t input)
{
+ return closeInput_nonvirtual(input);
+}
+
+status_t AudioFlinger::closeInput_nonvirtual(audio_io_handle_t input)
+{
// keep strong reference on the record thread so that
// it is not destroyed while exit() is executed
sp<RecordThread> thread;
{
Mutex::Autolock _l(mLock);
thread = checkRecordThread_l(input);
- if (thread == NULL) {
+ if (thread == 0) {
return BAD_VALUE;
}
@@ -7069,7 +7238,7 @@ status_t AudioFlinger::closeInput(audio_io_handle_t input)
AudioStreamIn *in = thread->clearInput();
ALOG_ASSERT(in != NULL, "in shouldn't be NULL");
// from now on thread->mInput is NULL
- in->hwDev->close_input_stream(in->hwDev, in->stream);
+ in->hwDev()->close_input_stream(in->hwDev(), in->stream);
delete in;
return NO_ERROR;
@@ -7078,21 +7247,11 @@ status_t AudioFlinger::closeInput(audio_io_handle_t input)
status_t AudioFlinger::setStreamOutput(audio_stream_type_t stream, audio_io_handle_t output)
{
Mutex::Autolock _l(mLock);
- MixerThread *dstThread = checkMixerThread_l(output);
- if (dstThread == NULL) {
- ALOGW("setStreamOutput() bad output id %d", output);
- return BAD_VALUE;
- }
-
ALOGV("setStreamOutput() stream %d to output %d", stream, output);
- audioConfigChanged_l(AudioSystem::STREAM_CONFIG_CHANGED, output, &stream);
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
- if (thread != dstThread && thread->type() != ThreadBase::DIRECT) {
- MixerThread *srcThread = (MixerThread *)thread;
- srcThread->invalidateTracks(stream);
- }
+ thread->invalidateTracks(stream);
}
return NO_ERROR;
@@ -7186,20 +7345,14 @@ void AudioFlinger::purgeStaleEffects_l() {
}
}
if (!found) {
+ Mutex::Autolock _l (t->mLock);
// remove all effects from the chain
while (ec->mEffects.size()) {
sp<EffectModule> effect = ec->mEffects[0];
effect->unPin();
- Mutex::Autolock _l (t->mLock);
t->removeEffect_l(effect);
- for (size_t j = 0; j < effect->mHandles.size(); j++) {
- sp<EffectHandle> handle = effect->mHandles[j].promote();
- if (handle != 0) {
- handle->mEffect.clear();
- if (handle->mHasControl && handle->mEnabled) {
- t->checkSuspendOnEffectEnabled_l(effect, false, effect->sessionId());
- }
- }
+ if (effect->purgeHandles()) {
+ t->checkSuspendOnEffectEnabled_l(effect, false, effect->sessionId());
}
AudioSystem::unregisterEffect(effect->id());
}
@@ -7237,14 +7390,14 @@ AudioFlinger::PlaybackThread *AudioFlinger::primaryPlaybackThread_l() const
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
PlaybackThread *thread = mPlaybackThreads.valueAt(i).get();
AudioStreamOut *output = thread->getOutput();
- if (output != NULL && output->hwDev == mPrimaryHardwareDev) {
+ if (output != NULL && output->audioHwDev == mPrimaryHardwareDev) {
return thread;
}
}
return NULL;
}
-uint32_t AudioFlinger::primaryOutputDevice_l() const
+audio_devices_t AudioFlinger::primaryOutputDevice_l() const
{
PlaybackThread *thread = primaryPlaybackThread_l();
@@ -7252,7 +7405,7 @@ uint32_t AudioFlinger::primaryOutputDevice_l() const
return 0;
}
- return thread->device();
+ return thread->outDevice();
}
sp<AudioFlinger::SyncEvent> AudioFlinger::createSyncEvent(AudioSystem::sync_event_t type,
@@ -7401,7 +7554,7 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
// 0 and the effect is not auxiliary, continue enumeration in case
// an auxiliary version of this effect type is available
found = true;
- memcpy(&d, &desc, sizeof(effect_descriptor_t));
+ d = desc;
if (sessionId != AUDIO_SESSION_OUTPUT_MIX ||
(desc.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
break;
@@ -7417,7 +7570,7 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
// connect to output mix (Compliance to OpenSL ES)
if (sessionId == AUDIO_SESSION_OUTPUT_MIX &&
(d.flags & EFFECT_FLAG_TYPE_MASK) != EFFECT_FLAG_TYPE_AUXILIARY) {
- memcpy(&desc, &d, sizeof(effect_descriptor_t));
+ desc = d;
}
}
@@ -7436,7 +7589,7 @@ sp<IEffect> AudioFlinger::createEffect(pid_t pid,
}
// return effect descriptor
- memcpy(pDesc, &desc, sizeof(effect_descriptor_t));
+ *pDesc = desc;
// If output is not specified try to find a matching audio session ID in one of the
// output threads.
@@ -7665,12 +7818,14 @@ sp<AudioFlinger::EffectHandle> AudioFlinger::ThreadBase::createEffect_l(
}
effectCreated = true;
- effect->setDevice(mDevice);
+ effect->setDevice(mOutDevice);
+ effect->setDevice(mInDevice);
effect->setMode(mAudioFlinger->getMode());
+ effect->setAudioSource(mAudioSource);
}
// create effect handle and connect it to effect module
handle = new EffectHandle(effect, client, effectClient, priority);
- lStatus = effect->addHandle(handle);
+ lStatus = effect->addHandle(handle.get());
if (enabled != NULL) {
*enabled = (int)effect->isEnabled();
}
@@ -7742,8 +7897,10 @@ status_t AudioFlinger::ThreadBase::addEffect_l(const sp<EffectModule>& effect)
return status;
}
- effect->setDevice(mDevice);
+ effect->setDevice(mOutDevice);
+ effect->setDevice(mInDevice);
effect->setMode(mAudioFlinger->getMode());
+ effect->setAudioSource(mAudioSource);
return NO_ERROR;
}
@@ -7789,7 +7946,7 @@ sp<AudioFlinger::EffectChain> AudioFlinger::ThreadBase::getEffectChain(int sessi
return getEffectChain_l(sessionId);
}
-sp<AudioFlinger::EffectChain> AudioFlinger::ThreadBase::getEffectChain_l(int sessionId)
+sp<AudioFlinger::EffectChain> AudioFlinger::ThreadBase::getEffectChain_l(int sessionId) const
{
size_t size = mEffectChains.size();
for (size_t i = 0; i < size; i++) {
@@ -7810,7 +7967,7 @@ void AudioFlinger::ThreadBase::setMode(audio_mode_t mode)
}
void AudioFlinger::ThreadBase::disconnectEffect(const sp<EffectModule>& effect,
- const wp<EffectHandle>& handle,
+ EffectHandle *handle,
bool unpinIfLast) {
Mutex::Autolock _l(mLock);
@@ -8002,16 +8159,18 @@ AudioFlinger::EffectModule::EffectModule(ThreadBase *thread,
effect_descriptor_t *desc,
int id,
int sessionId)
- : mThread(thread), mChain(chain), mId(id), mSessionId(sessionId), mEffectInterface(NULL),
- mStatus(NO_INIT), mState(IDLE), mSuspended(false)
+ : mPinned(sessionId > AUDIO_SESSION_OUTPUT_MIX),
+ mThread(thread), mChain(chain), mId(id), mSessionId(sessionId),
+ mDescriptor(*desc),
+ // mConfig is set by configure() and not used before then
+ mEffectInterface(NULL),
+ mStatus(NO_INIT), mState(IDLE),
+ // mMaxDisableWaitCnt is set by configure() and not used before then
+ // mDisableWaitCnt is set by process() and updateState() and not used before then
+ mSuspended(false)
{
ALOGV("Constructor %p", this);
int lStatus;
- if (thread == NULL) {
- return;
- }
-
- memcpy(&mDescriptor, desc, sizeof(effect_descriptor_t));
// create effect engine from effect factory
mStatus = EffectCreate(&desc->uuid, sessionId, thread->id(), &mEffectInterface);
@@ -8025,9 +8184,6 @@ AudioFlinger::EffectModule::EffectModule(ThreadBase *thread,
goto Error;
}
- if (mSessionId > AUDIO_SESSION_OUTPUT_MIX) {
- mPinned = true;
- }
ALOGV("Constructor success name %s, Interface %p", mDescriptor.name, mEffectInterface);
return;
Error:
@@ -8055,38 +8211,41 @@ AudioFlinger::EffectModule::~EffectModule()
}
}
-status_t AudioFlinger::EffectModule::addHandle(const sp<EffectHandle>& handle)
+status_t AudioFlinger::EffectModule::addHandle(EffectHandle *handle)
{
status_t status;
Mutex::Autolock _l(mLock);
int priority = handle->priority();
size_t size = mHandles.size();
- sp<EffectHandle> h;
+ EffectHandle *controlHandle = NULL;
size_t i;
for (i = 0; i < size; i++) {
- h = mHandles[i].promote();
- if (h == 0) continue;
+ EffectHandle *h = mHandles[i];
+ if (h == NULL || h->destroyed_l()) continue;
+ // first non destroyed handle is considered in control
+ if (controlHandle == NULL)
+ controlHandle = h;
if (h->priority() <= priority) break;
}
// if inserted in first place, move effect control from previous owner to this handle
if (i == 0) {
bool enabled = false;
- if (h != 0) {
- enabled = h->enabled();
- h->setControl(false/*hasControl*/, true /*signal*/, enabled /*enabled*/);
+ if (controlHandle != NULL) {
+ enabled = controlHandle->enabled();
+ controlHandle->setControl(false/*hasControl*/, true /*signal*/, enabled /*enabled*/);
}
handle->setControl(true /*hasControl*/, false /*signal*/, enabled /*enabled*/);
status = NO_ERROR;
} else {
status = ALREADY_EXISTS;
}
- ALOGV("addHandle() %p added handle %p in position %d", this, handle.get(), i);
+ ALOGV("addHandle() %p added handle %p in position %d", this, handle, i);
mHandles.insertAt(handle, i);
return status;
}
-size_t AudioFlinger::EffectModule::removeHandle(const wp<EffectHandle>& handle)
+size_t AudioFlinger::EffectModule::removeHandle(EffectHandle *handle)
{
Mutex::Autolock _l(mLock);
size_t size = mHandles.size();
@@ -8097,43 +8256,44 @@ size_t AudioFlinger::EffectModule::removeHandle(const wp<EffectHandle>& handle)
if (i == size) {
return size;
}
- ALOGV("removeHandle() %p removed handle %p in position %d", this, handle.unsafe_get(), i);
+ ALOGV("removeHandle() %p removed handle %p in position %d", this, handle, i);
- bool enabled = false;
- EffectHandle *hdl = handle.unsafe_get();
- if (hdl != NULL) {
- ALOGV("removeHandle() unsafe_get OK");
- enabled = hdl->enabled();
- }
mHandles.removeAt(i);
- size = mHandles.size();
// if removed from first place, move effect control from this handle to next in line
- if (i == 0 && size != 0) {
- sp<EffectHandle> h = mHandles[0].promote();
- if (h != 0) {
- h->setControl(true /*hasControl*/, true /*signal*/ , enabled /*enabled*/);
+ if (i == 0) {
+ EffectHandle *h = controlHandle_l();
+ if (h != NULL) {
+ h->setControl(true /*hasControl*/, true /*signal*/ , handle->enabled() /*enabled*/);
}
}
// Prevent calls to process() and other functions on effect interface from now on.
// The effect engine will be released by the destructor when the last strong reference on
// this object is released which can happen after next process is called.
- if (size == 0 && !mPinned) {
+ if (mHandles.size() == 0 && !mPinned) {
mState = DESTROYED;
}
- return size;
+ return mHandles.size();
}
-sp<AudioFlinger::EffectHandle> AudioFlinger::EffectModule::controlHandle()
+// must be called with EffectModule::mLock held
+AudioFlinger::EffectHandle *AudioFlinger::EffectModule::controlHandle_l()
{
- Mutex::Autolock _l(mLock);
- return mHandles.size() != 0 ? mHandles[0].promote() : 0;
+ // the first valid handle in the list has control over the module
+ for (size_t i = 0; i < mHandles.size(); i++) {
+ EffectHandle *h = mHandles[i];
+ if (h != NULL && !h->destroyed_l()) {
+ return h;
+ }
+ }
+
+ return NULL;
}
-void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool unpinIfLast)
+size_t AudioFlinger::EffectModule::disconnect(EffectHandle *handle, bool unpinIfLast)
{
- ALOGV("disconnect() %p handle %p", this, handle.unsafe_get());
+ ALOGV("disconnect() %p handle %p", this, handle);
// keep a strong reference on this EffectModule to avoid calling the
// destructor before we exit
sp<EffectModule> keep(this);
@@ -8143,6 +8303,7 @@ void AudioFlinger::EffectModule::disconnect(const wp<EffectHandle>& handle, bool
thread->disconnectEffect(keep, handle, unpinIfLast);
}
}
+ return mHandles.size();
}
void AudioFlinger::EffectModule::updateState() {
@@ -8240,7 +8401,6 @@ void AudioFlinger::EffectModule::reset_l()
status_t AudioFlinger::EffectModule::configure()
{
- uint32_t channels;
if (mEffectInterface == NULL) {
return NO_INIT;
}
@@ -8251,18 +8411,14 @@ status_t AudioFlinger::EffectModule::configure()
}
// TODO: handle configuration of effects replacing track process
- if (thread->channelCount() == 1) {
- channels = AUDIO_CHANNEL_OUT_MONO;
- } else {
- channels = AUDIO_CHANNEL_OUT_STEREO;
- }
+ audio_channel_mask_t channelMask = thread->channelMask();
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
} else {
- mConfig.inputCfg.channels = channels;
+ mConfig.inputCfg.channels = channelMask;
}
- mConfig.outputCfg.channels = channels;
+ mConfig.outputCfg.channels = channelMask;
mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
mConfig.inputCfg.samplingRate = thread->sampleRate();
@@ -8452,8 +8608,8 @@ status_t AudioFlinger::EffectModule::command(uint32_t cmdCode,
if (cmdCode != EFFECT_CMD_GET_PARAM && status == NO_ERROR) {
uint32_t size = (replySize == NULL) ? 0 : *replySize;
for (size_t i = 1; i < mHandles.size(); i++) {
- sp<EffectHandle> h = mHandles[i].promote();
- if (h != 0) {
+ EffectHandle *h = mHandles[i];
+ if (h != NULL && !h->destroyed_l()) {
h->commandExecuted(cmdCode, cmdSize, pCmdData, size, pReplyData);
}
}
@@ -8463,8 +8619,14 @@ status_t AudioFlinger::EffectModule::command(uint32_t cmdCode,
status_t AudioFlinger::EffectModule::setEnabled(bool enabled)
{
-
Mutex::Autolock _l(mLock);
+ return setEnabled_l(enabled);
+}
+
+// must be called with EffectModule::mLock held
+status_t AudioFlinger::EffectModule::setEnabled_l(bool enabled)
+{
+
ALOGV("setEnabled %p enabled %d", this, enabled);
if (enabled != isEnabled()) {
@@ -8499,8 +8661,8 @@ status_t AudioFlinger::EffectModule::setEnabled(bool enabled)
return NO_ERROR; // simply ignore as we are being destroyed
}
for (size_t i = 1; i < mHandles.size(); i++) {
- sp<EffectHandle> h = mHandles[i].promote();
- if (h != 0) {
+ EffectHandle *h = mHandles[i];
+ if (h != NULL && !h->destroyed_l()) {
h->setEnabled(enabled);
}
}
@@ -8573,46 +8735,25 @@ status_t AudioFlinger::EffectModule::setVolume(uint32_t *left, uint32_t *right,
return status;
}
-status_t AudioFlinger::EffectModule::setDevice(uint32_t device)
+status_t AudioFlinger::EffectModule::setDevice(audio_devices_t device)
{
+ if (device == AUDIO_DEVICE_NONE) {
+ return NO_ERROR;
+ }
+
Mutex::Autolock _l(mLock);
status_t status = NO_ERROR;
if (device && (mDescriptor.flags & EFFECT_FLAG_DEVICE_MASK) == EFFECT_FLAG_DEVICE_IND) {
- // audio pre processing modules on RecordThread can receive both output and
- // input device indication in the same call
- uint32_t dev = device & AUDIO_DEVICE_OUT_ALL;
- if (dev) {
- status_t cmdStatus;
- uint32_t size = sizeof(status_t);
-
- status = (*mEffectInterface)->command(mEffectInterface,
- EFFECT_CMD_SET_DEVICE,
- sizeof(uint32_t),
- &dev,
- &size,
- &cmdStatus);
- if (status == NO_ERROR) {
- status = cmdStatus;
- }
- }
- dev = device & AUDIO_DEVICE_IN_ALL;
- if (dev) {
- status_t cmdStatus;
- uint32_t size = sizeof(status_t);
-
- status_t status2 = (*mEffectInterface)->command(mEffectInterface,
- EFFECT_CMD_SET_INPUT_DEVICE,
- sizeof(uint32_t),
- &dev,
- &size,
- &cmdStatus);
- if (status2 == NO_ERROR) {
- status2 = cmdStatus;
- }
- if (status == NO_ERROR) {
- status = status2;
- }
- }
+ status_t cmdStatus;
+ uint32_t size = sizeof(status_t);
+ uint32_t cmd = audio_is_output_devices(device) ? EFFECT_CMD_SET_DEVICE :
+ EFFECT_CMD_SET_INPUT_DEVICE;
+ status = (*mEffectInterface)->command(mEffectInterface,
+ cmd,
+ sizeof(uint32_t),
+ &device,
+ &size,
+ &cmdStatus);
}
return status;
}
@@ -8637,6 +8778,22 @@ status_t AudioFlinger::EffectModule::setMode(audio_mode_t mode)
return status;
}
+status_t AudioFlinger::EffectModule::setAudioSource(audio_source_t source)
+{
+ Mutex::Autolock _l(mLock);
+ status_t status = NO_ERROR;
+ if ((mDescriptor.flags & EFFECT_FLAG_AUDIO_SOURCE_MASK) == EFFECT_FLAG_AUDIO_SOURCE_IND) {
+ uint32_t size = 0;
+ status = (*mEffectInterface)->command(mEffectInterface,
+ EFFECT_CMD_SET_AUDIO_SOURCE,
+ sizeof(audio_source_t),
+ &source,
+ &size,
+ NULL);
+ }
+ return status;
+}
+
void AudioFlinger::EffectModule::setSuspended(bool suspended)
{
Mutex::Autolock _l(mLock);
@@ -8649,7 +8806,23 @@ bool AudioFlinger::EffectModule::suspended() const
return mSuspended;
}
-status_t AudioFlinger::EffectModule::dump(int fd, const Vector<String16>& args)
+bool AudioFlinger::EffectModule::purgeHandles()
+{
+ bool enabled = false;
+ Mutex::Autolock _l(mLock);
+ for (size_t i = 0; i < mHandles.size(); i++) {
+ EffectHandle *handle = mHandles[i];
+ if (handle != NULL && !handle->destroyed_l()) {
+ handle->effect().clear();
+ if (handle->hasControl()) {
+ enabled = handle->enabled();
+ }
+ }
+ }
+ return enabled;
+}
+
+void AudioFlinger::EffectModule::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -8715,8 +8888,8 @@ status_t AudioFlinger::EffectModule::dump(int fd, const Vector<String16>& args)
result.append(buffer);
result.append("\t\t\tPid Priority Ctrl Locked client server\n");
for (size_t i = 0; i < mHandles.size(); ++i) {
- sp<EffectHandle> handle = mHandles[i].promote();
- if (handle != 0) {
+ EffectHandle *handle = mHandles[i];
+ if (handle != NULL && !handle->destroyed_l()) {
handle->dump(buffer, SIZE);
result.append(buffer);
}
@@ -8729,8 +8902,6 @@ status_t AudioFlinger::EffectModule::dump(int fd, const Vector<String16>& args)
if (locked) {
mLock.unlock();
}
-
- return NO_ERROR;
}
// ----------------------------------------------------------------------------
@@ -8746,7 +8917,7 @@ AudioFlinger::EffectHandle::EffectHandle(const sp<EffectModule>& effect,
int32_t priority)
: BnEffect(),
mEffect(effect), mEffectClient(effectClient), mClient(client), mCblk(NULL),
- mPriority(priority), mHasControl(false), mEnabled(false)
+ mPriority(priority), mHasControl(false), mEnabled(false), mDestroyed(false)
{
ALOGV("constructor %p", this);
@@ -8771,8 +8942,15 @@ AudioFlinger::EffectHandle::EffectHandle(const sp<EffectModule>& effect,
AudioFlinger::EffectHandle::~EffectHandle()
{
ALOGV("Destructor %p", this);
+
+ if (mEffect == 0) {
+ mDestroyed = true;
+ return;
+ }
+ mEffect->lock();
+ mDestroyed = true;
+ mEffect->unlock();
disconnect(false);
- ALOGV("Destructor DONE %p", this);
}
status_t AudioFlinger::EffectHandle::enable()
@@ -8843,9 +9021,8 @@ void AudioFlinger::EffectHandle::disconnect(bool unpinIfLast)
if (mEffect == 0) {
return;
}
- mEffect->disconnect(this, unpinIfLast);
-
- if (mHasControl && mEnabled) {
+ // restore suspended effects if the disconnected handle was enabled and the last one.
+ if ((mEffect->disconnect(this, unpinIfLast) == 0) && mEnabled) {
sp<ThreadBase> thread = mEffect->thread().promote();
if (thread != 0) {
thread->checkSuspendOnEffectEnabled(mEffect, false, mEffect->sessionId());
@@ -9275,7 +9452,7 @@ size_t AudioFlinger::EffectChain::removeEffect_l(const sp<EffectModule>& effect)
}
// setDevice_l() must be called with PlaybackThread::mLock held
-void AudioFlinger::EffectChain::setDevice_l(uint32_t device)
+void AudioFlinger::EffectChain::setDevice_l(audio_devices_t device)
{
size_t size = mEffects.size();
for (size_t i = 0; i < size; i++) {
@@ -9292,6 +9469,15 @@ void AudioFlinger::EffectChain::setMode_l(audio_mode_t mode)
}
}
+// setAudioSource_l() must be called with PlaybackThread::mLock held
+void AudioFlinger::EffectChain::setAudioSource_l(audio_source_t source)
+{
+ size_t size = mEffects.size();
+ for (size_t i = 0; i < size; i++) {
+ mEffects[i]->setAudioSource(source);
+ }
+}
+
// setVolume_l() must be called with PlaybackThread::mLock held
bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right)
{
@@ -9350,7 +9536,7 @@ bool AudioFlinger::EffectChain::setVolume_l(uint32_t *left, uint32_t *right)
return hasControl;
}
-status_t AudioFlinger::EffectChain::dump(int fd, const Vector<String16>& args)
+void AudioFlinger::EffectChain::dump(int fd, const Vector<String16>& args)
{
const size_t SIZE = 256;
char buffer[SIZE];
@@ -9384,8 +9570,6 @@ status_t AudioFlinger::EffectChain::dump(int fd, const Vector<String16>& args)
if (locked) {
mLock.unlock();
}
-
- return NO_ERROR;
}
// must be called with ThreadBase::mLock held
@@ -9401,7 +9585,7 @@ void AudioFlinger::EffectChain::setEffectSuspended_l(
desc = mSuspendedEffects.valueAt(index);
} else {
desc = new SuspendedEffectDesc();
- memcpy(&desc->mType, type, sizeof(effect_uuid_t));
+ desc->mType = *type;
mSuspendedEffects.add(type->timeLow, desc);
ALOGV("setEffectSuspended_l() add entry for %08x", type->timeLow);
}
@@ -9428,10 +9612,12 @@ void AudioFlinger::EffectChain::setEffectSuspended_l(
sp<EffectModule> effect = desc->mEffect.promote();
if (effect != 0) {
effect->setSuspended(false);
- sp<EffectHandle> handle = effect->controlHandle();
- if (handle != 0) {
- effect->setEnabled(handle->enabled());
+ effect->lock();
+ EffectHandle *handle = effect->controlHandle_l();
+ if (handle != NULL && !handle->destroyed_l()) {
+ effect->setEnabled_l(handle->enabled());
}
+ effect->unlock();
}
desc->mEffect.clear();
}
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index cfd718f4..49e2b2cb 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -45,10 +45,10 @@
#include <hardware/audio.h>
#include <hardware/audio_policy.h>
-#include "AudioBufferProvider.h"
-#include "ExtendedAudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
+#include <media/ExtendedAudioBufferProvider.h>
#include "FastMixer.h"
-#include "NBAIO.h"
+#include <media/nbaio/NBAIO.h>
#include "AudioWatchdog.h"
#include <powermanager/IPowerManager.h>
@@ -91,7 +91,7 @@ public:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
IAudioFlinger::track_flags_t flags,
const sp<IMemory>& sharedBuffer,
@@ -105,9 +105,10 @@ public:
audio_io_handle_t input,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
IAudioFlinger::track_flags_t flags,
+ pid_t tid,
int *sessionId,
status_t *status);
@@ -121,7 +122,6 @@ public:
virtual status_t setMasterMute(bool muted);
virtual float masterVolume() const;
- virtual float masterVolumeSW() const;
virtual bool masterMute() const;
virtual status_t setStreamVolume(audio_stream_type_t stream, float value,
@@ -142,7 +142,8 @@ public:
virtual void registerClient(const sp<IAudioFlingerClient>& client);
- 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;
virtual audio_io_handle_t openOutput(audio_module_handle_t module,
audio_devices_t *pDevices,
@@ -206,6 +207,9 @@ public:
virtual audio_module_handle_t loadHwModule(const char *name);
+ virtual int32_t getPrimaryOutputSamplingRate();
+ virtual int32_t getPrimaryOutputFrameCount();
+
virtual status_t onTransact(
uint32_t code,
const Parcel& data,
@@ -232,8 +236,8 @@ public:
virtual ~SyncEvent() {}
void trigger() { Mutex::Autolock _l(mLock); if (mCallback) mCallback(this); }
- bool isCancelled() { Mutex::Autolock _l(mLock); return (mCallback == NULL); }
- void cancel() {Mutex::Autolock _l(mLock); mCallback = NULL; }
+ bool isCancelled() const { Mutex::Autolock _l(mLock); return (mCallback == NULL); }
+ void cancel() { Mutex::Autolock _l(mLock); mCallback = NULL; }
AudioSystem::sync_event_t type() const { return mType; }
int triggerSession() const { return mTriggerSession; }
int listenerSession() const { return mListenerSession; }
@@ -245,7 +249,7 @@ public:
const int mListenerSession;
sync_event_callback_t mCallback;
void * const mCookie;
- Mutex mLock;
+ mutable Mutex mLock;
};
sp<SyncEvent> createSyncEvent(AudioSystem::sync_event_t type,
@@ -255,6 +259,8 @@ public:
void *cookie);
private:
+ class AudioHwDevice; // fwd declaration for findSuitableHwDev_l
+
audio_mode_t getMode() const { return mMode; }
bool btNrecIsOff() const { return mBtNrecIsOff; }
@@ -268,17 +274,17 @@ private:
// RefBase
virtual void onFirstRef();
- audio_hw_device_t* findSuitableHwDev_l(audio_module_handle_t module, uint32_t devices);
+ AudioHwDevice* findSuitableHwDev_l(audio_module_handle_t module, audio_devices_t devices);
void purgeStaleEffects_l();
// standby delay for MIXER and DUPLICATING playback threads is read from property
// ro.audio.flinger_standbytime_ms or defaults to kDefaultStandbyTimeInNsecs
static nsecs_t mStandbyTimeInNsecs;
- // Internal dump utilites.
- status_t dumpPermissionDenial(int fd, const Vector<String16>& args);
- status_t dumpClients(int fd, const Vector<String16>& args);
- status_t dumpInternals(int fd, const Vector<String16>& args);
+ // Internal dump utilities.
+ void dumpPermissionDenial(int fd, const Vector<String16>& args);
+ void dumpClients(int fd, const Vector<String16>& args);
+ void dumpInternals(int fd, const Vector<String16>& args);
// --- Client ---
class Client : public RefBase {
@@ -350,11 +356,12 @@ private:
RECORD // Thread class is RecordThread
};
- ThreadBase (const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id, uint32_t device, type_t type);
+ ThreadBase (const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id,
+ audio_devices_t outDevice, audio_devices_t inDevice, type_t type);
virtual ~ThreadBase();
- status_t dumpBase(int fd, const Vector<String16>& args);
- status_t dumpEffectChains(int fd, const Vector<String16>& args);
+ void dumpBase(int fd, const Vector<String16>& args);
+ void dumpEffectChains(int fd, const Vector<String16>& args);
void clearPowerManager();
@@ -380,14 +387,14 @@ private:
const sp<Client>& client,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId);
virtual ~TrackBase();
- virtual status_t start(AudioSystem::sync_event_t event = AudioSystem::SYNC_EVENT_NONE,
- int triggerSession = 0) = 0;
+ virtual status_t start(AudioSystem::sync_event_t event,
+ int triggerSession) = 0;
virtual void stop() = 0;
sp<IMemory> getCblk() const { return mCblkMemory; }
audio_track_cblk_t* cblk() const { return mCblk; }
@@ -412,10 +419,17 @@ private:
int channelCount() const { return mChannelCount; }
- uint32_t channelMask() const { return mChannelMask; }
+ audio_channel_mask_t channelMask() const { return mChannelMask; }
int sampleRate() const; // FIXME inline after cblk sr moved
+ // Return a pointer to the start of a contiguous slice of the track buffer.
+ // Parameter 'offset' is the requested start position, expressed in
+ // monotonically increasing frame units relative to the track epoch.
+ // Parameter 'frames' is the requested length, also in frame units.
+ // Always returns non-NULL. It is the caller's responsibility to
+ // verify that this will be successful; the result of calling this
+ // function with invalid 'offset' or 'frames' is undefined.
void* getBuffer(uint32_t offset, uint32_t frames) const;
bool isStopped() const {
@@ -444,8 +458,9 @@ private:
/*const*/ sp<Client> mClient; // see explanation at ~TrackBase() why not const
sp<IMemory> mCblkMemory;
audio_track_cblk_t* mCblk;
- void* mBuffer;
- void* mBufferEnd;
+ void* mBuffer; // start of track buffer, typically in shared memory
+ void* mBufferEnd; // &mBuffer[mFrameCount * frameSize], where frameSize
+ // is based on mChannelCount and 16-bit samples
uint32_t mFrameCount;
// we don't really need a lock for these
track_state mState;
@@ -455,18 +470,67 @@ private:
bool mStepServerFailed;
const int mSessionId;
uint8_t mChannelCount;
- uint32_t mChannelMask;
+ audio_channel_mask_t mChannelMask;
Vector < sp<SyncEvent> >mSyncEvents;
};
+ enum {
+ CFG_EVENT_IO,
+ CFG_EVENT_PRIO
+ };
+
class ConfigEvent {
public:
- ConfigEvent() : mEvent(0), mParam(0) {}
+ ConfigEvent(int type) : mType(type) {}
+ virtual ~ConfigEvent() {}
+
+ int type() const { return mType; }
+
+ virtual void dump(char *buffer, size_t size) = 0;
+
+ private:
+ const int mType;
+ };
+
+ class IoConfigEvent : public ConfigEvent {
+ public:
+ IoConfigEvent(int event, int param) :
+ ConfigEvent(CFG_EVENT_IO), mEvent(event), mParam(event) {}
+ virtual ~IoConfigEvent() {}
+
+ int event() const { return mEvent; }
+ int param() const { return mParam; }
+
+ virtual void dump(char *buffer, size_t size) {
+ snprintf(buffer, size, "IO event: event %d, param %d\n", mEvent, mParam);
+ }
+
+ private:
+ const int mEvent;
+ const int mParam;
+ };
+
+ class PrioConfigEvent : public ConfigEvent {
+ public:
+ PrioConfigEvent(pid_t pid, pid_t tid, int32_t prio) :
+ ConfigEvent(CFG_EVENT_PRIO), mPid(pid), mTid(tid), mPrio(prio) {}
+ virtual ~PrioConfigEvent() {}
+
+ pid_t pid() const { return mPid; }
+ pid_t tid() const { return mTid; }
+ int32_t prio() const { return mPrio; }
+
+ virtual void dump(char *buffer, size_t size) {
+ snprintf(buffer, size, "Prio event: pid %d, tid %d, prio %d\n", mPid, mTid, mPrio);
+ }
- int mEvent;
- int mParam;
+ private:
+ const pid_t mPid;
+ const pid_t mTid;
+ const int32_t mPrio;
};
+
class PMDeathRecipient : public IBinder::DeathRecipient {
public:
PMDeathRecipient(const wp<ThreadBase>& thread) : mThread(thread) {}
@@ -483,14 +547,22 @@ private:
};
virtual status_t initCheck() const = 0;
+
+ // static externally-visible
type_t type() const { return mType; }
+ audio_io_handle_t id() const { return mId;}
+
+ // dynamic externally-visible
uint32_t sampleRate() const { return mSampleRate; }
int channelCount() const { return mChannelCount; }
+ audio_channel_mask_t channelMask() const { return mChannelMask; }
audio_format_t format() const { return mFormat; }
// Called by AudioFlinger::frameCount(audio_io_handle_t output) and effects,
- // and returns the normal mix buffer's frame count. No API for HAL frame count.
+ // and returns the normal mix buffer's frame count.
size_t frameCount() const { return mNormalFrameCount; }
- void wakeUp() { mWaitWorkCV.broadcast(); }
+ // Return's the HAL's frame count i.e. fast mixer buffer size.
+ size_t frameCountHAL() const { return mFrameCount; }
+
// Should be "virtual status_t requestExitAndWait()" and override same
// method in Thread, but Thread::requestExitAndWait() is not yet virtual.
void exit();
@@ -498,12 +570,16 @@ private:
virtual status_t setParameters(const String8& keyValuePairs);
virtual String8 getParameters(const String8& keys) = 0;
virtual void audioConfigChanged_l(int event, int param = 0) = 0;
- void sendConfigEvent(int event, int param = 0);
- void sendConfigEvent_l(int event, int param = 0);
+ void sendIoConfigEvent(int event, int param = 0);
+ void sendIoConfigEvent_l(int event, int param = 0);
+ void sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio);
void processConfigEvents();
- audio_io_handle_t id() const { return mId;}
+
+ // see note at declaration of mStandby, mOutDevice and mInDevice
bool standby() const { return mStandby; }
- uint32_t device() const { return mDevice; }
+ audio_devices_t outDevice() const { return mOutDevice; }
+ audio_devices_t inDevice() const { return mInDevice; }
+
virtual audio_stream_t* stream() const = 0;
sp<EffectHandle> createEffect_l(
@@ -515,7 +591,7 @@ private:
int *enabled,
status_t *status);
void disconnectEffect(const sp< EffectModule>& effect,
- const wp<EffectHandle>& handle,
+ EffectHandle *handle,
bool unpinIfLast);
// return values for hasAudioSession (bit field)
@@ -529,7 +605,7 @@ private:
// get effect chain corresponding to session Id.
sp<EffectChain> getEffectChain(int sessionId);
// same as getEffectChain() but must be called with ThreadBase mutex locked
- sp<EffectChain> getEffectChain_l(int sessionId);
+ sp<EffectChain> getEffectChain_l(int sessionId) const;
// add an effect chain to the chain list (mEffectChains)
virtual status_t addEffectChain_l(const sp<EffectChain>& chain) = 0;
// remove an effect chain from the chain list (mEffectChains)
@@ -556,7 +632,7 @@ private:
virtual void detachAuxEffect_l(int effectId) {}
// returns either EFFECT_SESSION if effects on this audio session exist in one
// chain, or TRACK_SESSION if tracks on this audio session exist, or both
- virtual uint32_t hasAudioSession(int sessionId) = 0;
+ virtual uint32_t hasAudioSession(int sessionId) const = 0;
// the value returned by default implementation is not important as the
// strategy is only meaningful for PlaybackThread which implements this method
virtual uint32_t getStrategyForSession_l(int sessionId) { return 0; }
@@ -576,7 +652,7 @@ private:
int sessionId = AUDIO_SESSION_OUTPUT_MIX);
virtual status_t setSyncEvent(const sp<SyncEvent>& event) = 0;
- virtual bool isValidSyncEvent(const sp<SyncEvent>& event) = 0;
+ virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const = 0;
mutable Mutex mLock;
@@ -598,7 +674,7 @@ private:
void releaseWakeLock_l();
void setEffectSuspended_l(const effect_uuid_t *type,
bool suspend,
- int sessionId = AUDIO_SESSION_OUTPUT_MIX);
+ int sessionId);
// updated mSuspendedSessions when an effect suspended or restored
void updateSuspendedSessions_l(const effect_uuid_t *type,
bool suspend,
@@ -606,6 +682,8 @@ private:
// check if some effects must be suspended when an effect chain is added
void checkSuspendOnAddEffectChain_l(const sp<EffectChain>& chain);
+ virtual void preExit() { }
+
friend class AudioFlinger; // for mEffectChains
const type_t mType;
@@ -617,7 +695,7 @@ private:
uint32_t mSampleRate;
size_t mFrameCount; // output HAL, direct output, record
size_t mNormalFrameCount; // normal mixer and effects
- uint32_t mChannelMask;
+ audio_channel_mask_t mChannelMask;
uint16_t mChannelCount;
size_t mFrameSize;
audio_format_t mFormat;
@@ -645,12 +723,22 @@ private:
Vector<String8> mNewParameters;
status_t mParamStatus;
- Vector<ConfigEvent> mConfigEvents;
- bool mStandby;
+ Vector<ConfigEvent *> mConfigEvents;
+
+ // These fields are written and read by thread itself without lock or barrier,
+ // and read by other threads without lock or barrier via standby() , outDevice()
+ // and inDevice().
+ // Because of the absence of a lock or barrier, any other thread that reads
+ // these fields must use the information in isolation, or be prepared to deal
+ // with possibility that it might be inconsistent with other information.
+ bool mStandby; // Whether thread is currently in standby.
+ audio_devices_t mOutDevice; // output device
+ audio_devices_t mInDevice; // input device
+ audio_source_t mAudioSource; // (see audio.h, audio_source_t)
+
const audio_io_handle_t mId;
Vector< sp<EffectChain> > mEffectChains;
- uint32_t mDevice; // output device for PlaybackThread
- // input + output devices for RecordThread
+
static const int kNameLength = 16; // prctl(PR_SET_NAME) limit
char mName[kNameLength];
sp<IPowerManager> mPowerManager;
@@ -691,7 +779,7 @@ private:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId,
@@ -708,9 +796,7 @@ private:
void flush();
void destroy();
void mute(bool);
- int name() const {
- return mName;
- }
+ int name() const { return mName; }
audio_stream_type_t streamType() const {
return mStreamType;
@@ -767,10 +853,14 @@ private:
void triggerEvents(AudioSystem::sync_event_t type);
virtual bool isTimedTrack() const { return false; }
bool isFastTrack() const { return (mFlags & IAudioFlinger::TRACK_FAST) != 0; }
+
protected:
- // we don't really need a lock for these
- volatile bool mMute;
+ // written by Track::mute() called by binder thread(s), without a mutex or barrier.
+ // read by Track::isMuted() called by playback thread, also without a mutex or barrier.
+ // The lack of mutex or barrier is safe because the mute status is only used by itself.
+ bool mMute;
+
// FILLED state is used for suppressing volume ramp at begin of playing
enum {FS_INVALID, FS_FILLING, FS_FILLED, FS_ACTIVE};
mutable uint8_t mFillingUpStatus;
@@ -813,11 +903,11 @@ private:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId);
- ~TimedTrack();
+ virtual ~TimedTrack();
class TimedBuffer {
public:
@@ -856,7 +946,7 @@ private:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId);
@@ -905,7 +995,7 @@ private:
DuplicatingThread *sourceThread,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount);
virtual ~OutputTrack();
@@ -936,10 +1026,10 @@ private:
}; // end of OutputTrack
PlaybackThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, uint32_t device, type_t type);
+ audio_io_handle_t id, audio_devices_t device, type_t type);
virtual ~PlaybackThread();
- status_t dump(int fd, const Vector<String16>& args);
+ void dump(int fd, const Vector<String16>& args);
// Thread virtuals
virtual status_t readyToRun();
@@ -962,6 +1052,9 @@ protected:
// is safe to do so. That will drop the final ref count and destroy the tracks.
virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove) = 0;
+ // ThreadBase virtuals
+ virtual void preExit();
+
public:
virtual status_t initCheck() const { return (mOutput == NULL) ? NO_INIT : NO_ERROR; }
@@ -984,7 +1077,7 @@ public:
audio_stream_type_t streamType,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
const sp<IMemory>& sharedBuffer,
int sessionId,
@@ -996,9 +1089,19 @@ public:
AudioStreamOut* clearOutput();
virtual audio_stream_t* stream() const;
- void suspend() { mSuspended++; }
- void restore() { if (mSuspended > 0) mSuspended--; }
- bool isSuspended() const { return (mSuspended > 0); }
+ // a very large number of suspend() will eventually wraparound, but unlikely
+ void suspend() { (void) android_atomic_inc(&mSuspended); }
+ void restore()
+ {
+ // if restore() is done without suspend(), get back into
+ // range so that the next suspend() will operate correctly
+ if (android_atomic_dec(&mSuspended) <= 0) {
+ android_atomic_release_store(0, &mSuspended);
+ }
+ }
+ bool isSuspended() const
+ { return android_atomic_acquire_load(&mSuspended) > 0; }
+
virtual String8 getParameters(const String8& keys);
virtual void audioConfigChanged_l(int event, int param = 0);
status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames);
@@ -1012,16 +1115,25 @@ public:
virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
- virtual uint32_t hasAudioSession(int sessionId);
+ virtual uint32_t hasAudioSession(int sessionId) const;
virtual uint32_t getStrategyForSession_l(int sessionId);
virtual status_t setSyncEvent(const sp<SyncEvent>& event);
- virtual bool isValidSyncEvent(const sp<SyncEvent>& event);
+ virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const;
+ void invalidateTracks(audio_stream_type_t streamType);
+
protected:
int16_t* mMixBuffer;
- uint32_t mSuspended; // suspend count, > 0 means suspended
+
+ // suspend count, > 0 means suspended. While suspended, the thread continues to pull from
+ // tracks and mix, but doesn't write to HAL. A2DP and SCO HAL implementations can't handle
+ // concurrent use of both of them, so Audio Policy Service suspends one of the threads to
+ // workaround that restriction.
+ // 'volatile' means accessed via atomic operations and no lock.
+ volatile int32_t mSuspended;
+
int mBytesWritten;
private:
// mMasterMute is in both PlaybackThread and in AudioFlinger. When a
@@ -1034,7 +1146,7 @@ public:
// Allocate a track name for a given channel mask.
// Returns name >= 0 if successful, -1 on failure.
- virtual int getTrackName_l(audio_channel_mask_t channelMask) = 0;
+ virtual int getTrackName_l(audio_channel_mask_t channelMask, int sessionId) = 0;
virtual void deleteTrackName_l(int name) = 0;
// Time to sleep between cycles when:
@@ -1069,13 +1181,14 @@ public:
void readOutputParameters();
- virtual status_t dumpInternals(int fd, const Vector<String16>& args);
- status_t dumpTracks(int fd, const Vector<String16>& args);
+ virtual void dumpInternals(int fd, const Vector<String16>& args);
+ void dumpTracks(int fd, const Vector<String16>& args);
SortedVector< sp<Track> > mTracks;
// mStreamTypes[] uses 1 additional stream type internally for the OutputTrack used by DuplicatingThread
stream_type_t mStreamTypes[AUDIO_STREAM_CNT + 1];
AudioStreamOut *mOutput;
+
float mMasterVolume;
nsecs_t mLastWriteTime;
int mNumWrites;
@@ -1100,7 +1213,6 @@ public:
// FIXME move these declarations into the specific sub-class that needs them
// MIXER only
- bool longStandbyExit;
uint32_t sleepTimeShift;
// same as AudioFlinger::mStandbyTimeInNsecs except for DIRECT which uses a shorter value
@@ -1139,19 +1251,18 @@ public:
MixerThread (const sp<AudioFlinger>& audioFlinger,
AudioStreamOut* output,
audio_io_handle_t id,
- uint32_t device,
+ audio_devices_t device,
type_t type = MIXER);
virtual ~MixerThread();
// Thread virtuals
- void invalidateTracks(audio_stream_type_t streamType);
virtual bool checkForNewParameters_l();
- virtual status_t dumpInternals(int fd, const Vector<String16>& args);
+ virtual void dumpInternals(int fd, const Vector<String16>& args);
protected:
virtual mixer_state prepareTracks_l(Vector< sp<Track> > *tracksToRemove);
- virtual int getTrackName_l(audio_channel_mask_t channelMask);
+ virtual int getTrackName_l(audio_channel_mask_t channelMask, int sessionId);
virtual void deleteTrackName_l(int name);
virtual uint32_t idleSleepTimeUs() const;
virtual uint32_t suspendSleepTimeUs() const;
@@ -1167,9 +1278,6 @@ public:
AudioMixer* mAudioMixer; // normal mixer
private:
-#ifdef SOAKER
- Thread* mSoaker;
-#endif
// one-time initialization, no locks required
FastMixer* mFastMixer; // non-NULL if there is also a fast mixer
sp<AudioWatchdog> mAudioWatchdog; // non-0 if there is an audio watchdog thread
@@ -1198,7 +1306,7 @@ public:
public:
DirectOutputThread (const sp<AudioFlinger>& audioFlinger, AudioStreamOut* output,
- audio_io_handle_t id, uint32_t device);
+ audio_io_handle_t id, audio_devices_t device);
virtual ~DirectOutputThread();
// Thread virtuals
@@ -1206,7 +1314,7 @@ public:
virtual bool checkForNewParameters_l();
protected:
- virtual int getTrackName_l(audio_channel_mask_t channelMask);
+ virtual int getTrackName_l(audio_channel_mask_t channelMask, int sessionId);
virtual void deleteTrackName_l(int name);
virtual uint32_t activeSleepTimeUs() const;
virtual uint32_t idleSleepTimeUs() const;
@@ -1287,7 +1395,7 @@ private:
bool reRegister);
// return thread associated with primary hardware device, or NULL
PlaybackThread *primaryPlaybackThread_l() const;
- uint32_t primaryOutputDevice_l() const;
+ audio_devices_t primaryOutputDevice_l() const;
sp<PlaybackThread> getEffectThread_l(int sessionId, int EffectId);
@@ -1321,6 +1429,7 @@ private:
// record thread
class RecordThread : public ThreadBase, public AudioBufferProvider
+ // derives from AudioBufferProvider interface for use by resampler
{
public:
@@ -1331,18 +1440,22 @@ private:
const sp<Client>& client,
uint32_t sampleRate,
audio_format_t format,
- uint32_t channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
int sessionId);
virtual ~RecordTrack();
- virtual status_t start(AudioSystem::sync_event_t event = AudioSystem::SYNC_EVENT_NONE,
- int triggerSession = 0);
+ virtual status_t start(AudioSystem::sync_event_t event, int triggerSession);
virtual void stop();
- bool overflow() { bool tmp = mOverflow; mOverflow = false; return tmp; }
+ void destroy();
+
+ // clear the buffer overflow flag
+ void clearOverflow() { mOverflow = false; }
+ // set the buffer overflow flag and return previous value
bool setOverflow() { bool tmp = mOverflow; mOverflow = true; return tmp; }
+ static void appendDumpHeader(String8& result);
void dump(char* buffer, size_t size);
private:
@@ -1355,19 +1468,25 @@ private:
virtual status_t getNextBuffer(AudioBufferProvider::Buffer* buffer, int64_t pts = kInvalidPTS);
// releaseBuffer() not overridden
- bool mOverflow;
+ bool mOverflow; // overflow on most recent attempt to fill client buffer
};
-
RecordThread(const sp<AudioFlinger>& audioFlinger,
AudioStreamIn *input,
uint32_t sampleRate,
- uint32_t channels,
+ audio_channel_mask_t channelMask,
audio_io_handle_t id,
- uint32_t device);
+ audio_devices_t device);
virtual ~RecordThread();
- // Thread
+ // no addTrack_l ?
+ void destroyTrack_l(const sp<RecordTrack>& track);
+ void removeTrack_l(const sp<RecordTrack>& track);
+
+ void dumpInternals(int fd, const Vector<String16>& args);
+ void dumpTracks(int fd, const Vector<String16>& args);
+
+ // Thread virtuals
virtual bool threadLoop();
virtual status_t readyToRun();
@@ -1379,17 +1498,22 @@ private:
const sp<AudioFlinger::Client>& client,
uint32_t sampleRate,
audio_format_t format,
- int channelMask,
+ audio_channel_mask_t channelMask,
int frameCount,
int sessionId,
+ IAudioFlinger::track_flags_t flags,
+ pid_t tid,
status_t *status);
status_t start(RecordTrack* recordTrack,
AudioSystem::sync_event_t event,
int triggerSession);
- void stop(RecordTrack* recordTrack);
- status_t dump(int fd, const Vector<String16>& args);
- AudioStreamIn* getInput() const;
+
+ // ask the thread to stop the specified track, and
+ // return true if the caller should then do it's part of the stopping process
+ bool stop_l(RecordTrack* recordTrack);
+
+ void dump(int fd, const Vector<String16>& args);
AudioStreamIn* clearInput();
virtual audio_stream_t* stream() const;
@@ -1405,11 +1529,15 @@ private:
virtual status_t addEffectChain_l(const sp<EffectChain>& chain);
virtual size_t removeEffectChain_l(const sp<EffectChain>& chain);
- virtual uint32_t hasAudioSession(int sessionId);
- RecordTrack* track();
+ virtual uint32_t hasAudioSession(int sessionId) const;
+
+ // Return the set of unique session IDs across all tracks.
+ // The keys are the session IDs, and the associated values are meaningless.
+ // FIXME replace by Set [and implement Bag/Multiset for other uses].
+ KeyedVector<int, bool> sessionIds() const;
virtual status_t setSyncEvent(const sp<SyncEvent>& event);
- virtual bool isValidSyncEvent(const sp<SyncEvent>& event);
+ virtual bool isValidSyncEvent(const sp<SyncEvent>& event) const;
static void syncStartEventCallback(const wp<SyncEvent>& event);
void handleSyncStartEvent(const sp<SyncEvent>& event);
@@ -1417,9 +1545,16 @@ private:
private:
void clearSyncStartEvent();
- RecordThread();
+ // Enter standby if not already in standby, and set mStandby flag
+ void standby();
+
+ // Call the HAL standby method unconditionally, and don't change mStandby flag
+ void inputStandBy();
+
AudioStreamIn *mInput;
- RecordTrack* mTrack;
+ SortedVector < sp<RecordTrack> > mTracks;
+ // mActiveTrack has dual roles: it indicates the current active track, and
+ // is used together with mStartStopCond to indicate start()/stop() progress
sp<RecordTrack> mActiveTrack;
Condition mStartStopCond;
AudioResampler *mResampler;
@@ -1445,12 +1580,15 @@ private:
RecordHandle(const sp<RecordThread::RecordTrack>& recordTrack);
virtual ~RecordHandle();
virtual sp<IMemory> getCblk() const;
- virtual status_t start(int event, int triggerSession);
+ virtual status_t start(int /*AudioSystem::sync_event_t*/ event, int triggerSession);
virtual void stop();
virtual status_t onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags);
private:
const sp<RecordThread::RecordTrack> mRecordTrack;
+
+ // for use from destructor
+ void stop_nonvirtual();
};
//--- Audio Effect Management
@@ -1510,6 +1648,7 @@ private:
return mSessionId;
}
status_t setEnabled(bool enabled);
+ status_t setEnabled_l(bool enabled);
bool isEnabled() const;
bool isProcessEnabled() const;
@@ -1521,27 +1660,31 @@ private:
void setThread(const wp<ThreadBase>& thread) { mThread = thread; }
const wp<ThreadBase>& thread() { return mThread; }
- status_t addHandle(const sp<EffectHandle>& handle);
- void disconnect(const wp<EffectHandle>& handle, bool unpinIfLast);
- size_t removeHandle (const wp<EffectHandle>& handle);
+ status_t addHandle(EffectHandle *handle);
+ size_t disconnect(EffectHandle *handle, bool unpinIfLast);
+ size_t removeHandle(EffectHandle *handle);
- effect_descriptor_t& desc() { return mDescriptor; }
+ const effect_descriptor_t& desc() const { return mDescriptor; }
wp<EffectChain>& chain() { return mChain; }
- status_t setDevice(uint32_t device);
+ status_t setDevice(audio_devices_t device);
status_t setVolume(uint32_t *left, uint32_t *right, bool controller);
status_t setMode(audio_mode_t mode);
+ status_t setAudioSource(audio_source_t source);
status_t start();
status_t stop();
void setSuspended(bool suspended);
bool suspended() const;
- sp<EffectHandle> controlHandle();
+ EffectHandle* controlHandle_l();
bool isPinned() const { return mPinned; }
void unPin() { mPinned = false; }
+ bool purgeHandles();
+ void lock() { mLock.lock(); }
+ void unlock() { mLock.unlock(); }
- status_t dump(int fd, const Vector<String16>& args);
+ void dump(int fd, const Vector<String16>& args);
protected:
friend class AudioFlinger; // for mHandles
@@ -1559,14 +1702,14 @@ private:
mutable Mutex mLock; // mutex for process, commands and handles list protection
wp<ThreadBase> mThread; // parent thread
wp<EffectChain> mChain; // parent effect chain
- int mId; // this instance unique ID
- int mSessionId; // audio session ID
- effect_descriptor_t mDescriptor;// effect descriptor received from effect engine
+ const int mId; // this instance unique ID
+ const int mSessionId; // audio session ID
+ const effect_descriptor_t mDescriptor;// effect descriptor received from effect engine
effect_config_t mConfig; // input and output audio configuration
effect_handle_t mEffectInterface; // Effect module C API
status_t mStatus; // initialization status
effect_state mState; // current activation state
- Vector< wp<EffectHandle> > mHandles; // list of client handles
+ Vector<EffectHandle *> mHandles; // list of client handles
// First handle in mHandles has highest priority and controls the effect module
uint32_t mMaxDisableWaitCnt; // maximum grace period before forcing an effect off after
// sending disable command.
@@ -1624,6 +1767,8 @@ mutable Mutex mLock; // mutex for process, commands and handl
int priority() const { return mPriority; }
bool hasControl() const { return mHasControl; }
sp<EffectModule> effect() const { return mEffect; }
+ // destroyed_l() must be called with the associated EffectModule mLock held
+ bool destroyed_l() const { return mDestroyed; }
void dump(char* buffer, size_t size);
@@ -1642,6 +1787,8 @@ mutable Mutex mLock; // mutex for process, commands and handl
bool mHasControl; // true if this handle is controlling the effect
bool mEnabled; // cached enable state: needed when the effect is
// restored after being suspended
+ bool mDestroyed; // Set to true by destructor. Access with EffectModule
+ // mLock held
};
// the EffectChain class represents a group of effects associated to one audio session.
@@ -1684,8 +1831,9 @@ mutable Mutex mLock; // mutex for process, commands and handl
sp<EffectModule> getEffectFromId_l(int id);
sp<EffectModule> getEffectFromType_l(const effect_uuid_t *type);
bool setVolume_l(uint32_t *left, uint32_t *right);
- void setDevice_l(uint32_t device);
+ void setDevice_l(audio_devices_t device);
void setMode_l(audio_mode_t mode);
+ void setAudioSource_l(audio_source_t source);
void setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
mInBuffer = buffer;
@@ -1703,12 +1851,12 @@ mutable Mutex mLock; // mutex for process, commands and handl
void incTrackCnt() { android_atomic_inc(&mTrackCnt); }
void decTrackCnt() { android_atomic_dec(&mTrackCnt); }
- int32_t trackCnt() const { return mTrackCnt;}
+ int32_t trackCnt() const { return android_atomic_acquire_load(&mTrackCnt); }
void incActiveTrackCnt() { android_atomic_inc(&mActiveTrackCnt);
mTailBufferCount = mMaxTailBuffers; }
void decActiveTrackCnt() { android_atomic_dec(&mActiveTrackCnt); }
- int32_t activeTrackCnt() const { return mActiveTrackCnt;}
+ int32_t activeTrackCnt() const { return android_atomic_acquire_load(&mActiveTrackCnt); }
uint32_t strategy() const { return mStrategy; }
void setStrategy(uint32_t strategy)
@@ -1725,7 +1873,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
void clearInputBuffer();
- status_t dump(int fd, const Vector<String16>& args);
+ void dump(int fd, const Vector<String16>& args);
protected:
friend class AudioFlinger; // for mThread, mEffects
@@ -1760,8 +1908,11 @@ mutable Mutex mLock; // mutex for process, commands and handl
int mSessionId; // audio session ID
int16_t *mInBuffer; // chain input buffer
int16_t *mOutBuffer; // chain output buffer
- volatile int32_t mActiveTrackCnt; // number of active tracks connected
- volatile int32_t mTrackCnt; // number of tracks connected
+
+ // 'volatile' here means these are accessed with atomic operations instead of mutex
+ volatile int32_t mActiveTrackCnt; // number of active tracks connected
+ volatile int32_t mTrackCnt; // number of tracks connected
+
int32_t mTailBufferCount; // current effect tail buffer count
int32_t mMaxTailBuffers; // maximum effect tail buffers
bool mOwnInBuffer; // true if the chain owns its input buffer
@@ -1778,24 +1929,59 @@ mutable Mutex mLock; // mutex for process, commands and handl
KeyedVector< int, sp<SuspendedEffectDesc> > mSuspendedEffects;
};
+ class AudioHwDevice {
+ public:
+ enum Flags {
+ AHWD_CAN_SET_MASTER_VOLUME = 0x1,
+ AHWD_CAN_SET_MASTER_MUTE = 0x2,
+ };
+
+ AudioHwDevice(const char *moduleName,
+ audio_hw_device_t *hwDevice,
+ Flags flags)
+ : mModuleName(strdup(moduleName))
+ , mHwDevice(hwDevice)
+ , mFlags(flags) { }
+ /*virtual*/ ~AudioHwDevice() { free((void *)mModuleName); }
+
+ bool canSetMasterVolume() const {
+ return (0 != (mFlags & AHWD_CAN_SET_MASTER_VOLUME));
+ }
+
+ bool canSetMasterMute() const {
+ return (0 != (mFlags & AHWD_CAN_SET_MASTER_MUTE));
+ }
+
+ const char *moduleName() const { return mModuleName; }
+ audio_hw_device_t *hwDevice() const { return mHwDevice; }
+ private:
+ const char * const mModuleName;
+ audio_hw_device_t * const mHwDevice;
+ Flags mFlags;
+ };
+
// AudioStreamOut and AudioStreamIn are immutable, so their fields are const.
// For emphasis, we could also make all pointers to them be "const *",
// but that would clutter the code unnecessarily.
struct AudioStreamOut {
- audio_hw_device_t* const hwDev;
+ AudioHwDevice* const audioHwDev;
audio_stream_out_t* const stream;
- AudioStreamOut(audio_hw_device_t *dev, audio_stream_out_t *out) :
- hwDev(dev), stream(out) {}
+ audio_hw_device_t* hwDev() const { return audioHwDev->hwDevice(); }
+
+ AudioStreamOut(AudioHwDevice *dev, audio_stream_out_t *out) :
+ audioHwDev(dev), stream(out) {}
};
struct AudioStreamIn {
- audio_hw_device_t* const hwDev;
+ AudioHwDevice* const audioHwDev;
audio_stream_in_t* const stream;
- AudioStreamIn(audio_hw_device_t *dev, audio_stream_in_t *in) :
- hwDev(dev), stream(in) {}
+ audio_hw_device_t* hwDev() const { return audioHwDev->hwDevice(); }
+
+ AudioStreamIn(AudioHwDevice *dev, audio_stream_in_t *in) :
+ audioHwDev(dev), stream(in) {}
};
// for mAudioSessionRefs only
@@ -1807,41 +1993,6 @@ mutable Mutex mLock; // mutex for process, commands and handl
int mCnt;
};
- enum master_volume_support {
- // MVS_NONE:
- // Audio HAL has no support for master volume, either setting or
- // getting. All master volume control must be implemented in SW by the
- // AudioFlinger mixing core.
- MVS_NONE,
-
- // MVS_SETONLY:
- // Audio HAL has support for setting master volume, but not for getting
- // master volume (original HAL design did not include a getter).
- // AudioFlinger needs to keep track of the last set master volume in
- // addition to needing to set an initial, default, master volume at HAL
- // load time.
- MVS_SETONLY,
-
- // MVS_FULL:
- // Audio HAL has support both for setting and getting master volume.
- // AudioFlinger should send all set and get master volume requests
- // directly to the HAL.
- MVS_FULL,
- };
-
- class AudioHwDevice {
- public:
- AudioHwDevice(const char *moduleName, audio_hw_device_t *hwDevice) :
- mModuleName(strdup(moduleName)), mHwDevice(hwDevice){}
- ~AudioHwDevice() { free((void *)mModuleName); }
-
- const char *moduleName() const { return mModuleName; }
- audio_hw_device_t *hwDevice() const { return mHwDevice; }
- private:
- const char * const mModuleName;
- audio_hw_device_t * const mHwDevice;
- };
-
mutable Mutex mLock;
DefaultKeyedVector< pid_t, wp<Client> > mClients; // see ~Client()
@@ -1851,7 +2002,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
// always take mLock before mHardwareLock
// These two fields are immutable after onFirstRef(), so no lock needed to access
- audio_hw_device_t* mPrimaryHardwareDev; // mAudioHwDevs[0] or NULL
+ AudioHwDevice* mPrimaryHardwareDev; // mAudioHwDevs[0] or NULL
DefaultKeyedVector<audio_module_handle_t, AudioHwDevice*> mAudioHwDevs;
// for dump, indicates which hardware operation is currently in progress (but not stream ops)
@@ -1875,6 +2026,8 @@ mutable Mutex mLock; // mutex for process, commands and handl
AUDIO_HW_GET_INPUT_BUFFER_SIZE, // get_input_buffer_size
AUDIO_HW_GET_MASTER_VOLUME, // get_master_volume
AUDIO_HW_GET_PARAMETER, // get_parameters
+ AUDIO_HW_SET_MASTER_MUTE, // set_master_mute
+ AUDIO_HW_GET_MASTER_MUTE, // get_master_mute
};
mutable hardware_call_state mHardwareStatus; // for dump only
@@ -1883,11 +2036,10 @@ mutable Mutex mLock; // mutex for process, commands and handl
DefaultKeyedVector< audio_io_handle_t, sp<PlaybackThread> > mPlaybackThreads;
stream_type_t mStreamTypes[AUDIO_STREAM_CNT];
- // both are protected by mLock
+ // member variables below are protected by mLock
float mMasterVolume;
- float mMasterVolumeSW;
- master_volume_support mMasterVolumeSupportLvl;
bool mMasterMute;
+ // end of variables protected by mLock
DefaultKeyedVector< audio_io_handle_t, sp<RecordThread> > mRecordThreads;
@@ -1900,8 +2052,7 @@ mutable Mutex mLock; // mutex for process, commands and handl
Vector<AudioSessionRef*> mAudioSessionRefs;
float masterVolume_l() const;
- float masterVolumeSW_l() const { return mMasterVolumeSW; }
- bool masterMute_l() const { return mMasterMute; }
+ bool masterMute_l() const;
audio_module_handle_t loadHwModule_l(const char *name);
Vector < sp<SyncEvent> > mPendingSyncEvents; // sync events awaiting for a session
@@ -1910,6 +2061,9 @@ mutable Mutex mLock; // mutex for process, commands and handl
private:
sp<Client> registerPid_l(pid_t pid); // always returns non-0
+ // for use from destructor
+ status_t closeOutput_nonvirtual(audio_io_handle_t output);
+ status_t closeInput_nonvirtual(audio_io_handle_t input);
};
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index 3e4c55e0..1e4049ab 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -163,7 +163,7 @@ AudioMixer::~AudioMixer()
delete [] mState.resampleTemp;
}
-int AudioMixer::getTrackName(audio_channel_mask_t channelMask)
+int AudioMixer::getTrackName(audio_channel_mask_t channelMask, int sessionId)
{
uint32_t names = (~mTrackNames) & mConfiguredNames;
if (names != 0) {
@@ -189,6 +189,7 @@ int AudioMixer::getTrackName(audio_channel_mask_t channelMask)
t->enabled = false;
t->format = 16;
t->channelMask = AUDIO_CHANNEL_OUT_STEREO;
+ t->sessionId = sessionId;
// setBufferProvider(name, AudioBufferProvider *) is required before enable(name)
t->bufferProvider = NULL;
t->downmixerBufferProvider = NULL;
@@ -270,7 +271,7 @@ status_t AudioMixer::prepareTrackForDownmix(track_t* pTrack, int trackName)
}
if (EffectCreate(&dwnmFxDesc.uuid,
- -2 /*sessionId*/, -2 /*ioId*/,// both not relevant here, using random value
+ pTrack->sessionId /*sessionId*/, -2 /*ioId not relevant here, using random value*/,
&pDbp->mDownmixHandle/*pHandle*/) != 0) {
ALOGE("prepareTrackForDownmix(%d) fails: error creating downmixer effect", trackName);
goto noDownmixForActiveTrack;
@@ -416,7 +417,7 @@ void AudioMixer::setParameter(int name, int target, int param, void *value)
case TRACK:
switch (param) {
case CHANNEL_MASK: {
- uint32_t mask = (uint32_t)value;
+ audio_channel_mask_t mask = (audio_channel_mask_t) value;
if (track.channelMask != mask) {
uint32_t channelCount = popcount(mask);
ALOG_ASSERT((channelCount <= MAX_NUM_CHANNELS_TO_DOWNMIX) && channelCount);
@@ -538,11 +539,23 @@ bool AudioMixer::track_t::setResampler(uint32_t value, uint32_t devSampleRate)
if (sampleRate != value) {
sampleRate = value;
if (resampler == NULL) {
+ ALOGV("creating resampler from track %d Hz to device %d Hz", value, devSampleRate);
+ AudioResampler::src_quality quality;
+ // force lowest quality level resampler if use case isn't music or video
+ // FIXME this is flawed for dynamic sample rates, as we choose the resampler
+ // quality level based on the initial ratio, but that could change later.
+ // Should have a way to distinguish tracks with static ratios vs. dynamic ratios.
+ if (!((value == 44100 && devSampleRate == 48000) ||
+ (value == 48000 && devSampleRate == 44100))) {
+ quality = AudioResampler::LOW_QUALITY;
+ } else {
+ quality = AudioResampler::DEFAULT_QUALITY;
+ }
resampler = AudioResampler::create(
format,
// the resampler sees the number of channels after the downmixer, if any
downmixerBufferProvider != NULL ? MAX_NUM_CHANNELS : channelCount,
- devSampleRate);
+ devSampleRate, quality);
resampler->setLocalTimeFreq(localTimeFreq);
}
return true;
@@ -1085,6 +1098,12 @@ void AudioMixer::process__genericNoResampling(state_t* state, int64_t pts)
e0 &= ~(1<<i);
track_t& t = state->tracks[i];
t.buffer.frameCount = state->frameCount;
+ int valid = t.bufferProvider->getValid();
+ if (valid != AudioBufferProvider::kValid) {
+ ALOGE("invalid bufferProvider=%p name=%d frameCount=%d valid=%#x enabledTracks=%#x",
+ t.bufferProvider, i, t.buffer.frameCount, valid, enabledTracks);
+ // expect to crash
+ }
t.bufferProvider->getNextBuffer(&t.buffer, pts);
t.frameCount = t.buffer.frameCount;
t.in = t.buffer.raw;
diff --git a/services/audioflinger/AudioMixer.h b/services/audioflinger/AudioMixer.h
index 46deae75..63333578 100644
--- a/services/audioflinger/AudioMixer.h
+++ b/services/audioflinger/AudioMixer.h
@@ -23,7 +23,7 @@
#include <utils/threads.h>
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
#include "AudioResampler.h"
#include <audio_effects/effect_downmix.h>
@@ -91,7 +91,7 @@ public:
// For all APIs with "name": TRACK0 <= name < TRACK0 + MAX_NUM_TRACKS
// Allocate a track name. Returns new track name if successful, -1 on failure.
- int getTrackName(audio_channel_mask_t channelMask);
+ int getTrackName(audio_channel_mask_t channelMask, int sessionId);
// Free an allocated track by name
void deleteTrackName(int name);
@@ -192,7 +192,7 @@ private:
DownmixerBufferProvider* downmixerBufferProvider; // 4 bytes
- int32_t padding;
+ int32_t sessionId;
// 16-byte boundary
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 0d139703..55e08269 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -49,6 +49,8 @@ static const char kCmdDeadlockedString[] = "AudioPolicyService command thread ma
static const int kDumpLockRetries = 50;
static const int kDumpLockSleepUs = 20000;
+static const nsecs_t kAudioCommandTimeout = 3000000000; // 3 seconds
+
namespace {
extern struct audio_policy_service_ops aps_ops;
};
@@ -91,10 +93,6 @@ AudioPolicyService::AudioPolicyService()
if (rc)
return;
- property_get("ro.camera.sound.forced", value, "0");
- forced_val = strtol(value, NULL, 0);
- mpAudioPolicy->set_can_mute_enforced_audible(mpAudioPolicy, !forced_val);
-
ALOGI("Loaded audio policy from %s (%s)", module->name, module->id);
// load audio pre processing modules
@@ -223,7 +221,7 @@ audio_policy_forced_cfg_t AudioPolicyService::getForceUse(audio_policy_force_use
audio_io_handle_t AudioPolicyService::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)
{
if (mpAudioPolicy == NULL) {
@@ -231,7 +229,7 @@ audio_io_handle_t AudioPolicyService::getOutput(audio_stream_type_t stream,
}
ALOGV("getOutput() tid %d", gettid());
Mutex::Autolock _l(mLock);
- return mpAudioPolicy->get_output(mpAudioPolicy, stream, samplingRate, format, channels, flags);
+ return mpAudioPolicy->get_output(mpAudioPolicy, stream, samplingRate, format, channelMask, flags);
}
status_t AudioPolicyService::startOutput(audio_io_handle_t output,
@@ -271,8 +269,7 @@ void AudioPolicyService::releaseOutput(audio_io_handle_t output)
audio_io_handle_t AudioPolicyService::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 audioSession)
{
if (mpAudioPolicy == NULL) {
@@ -283,8 +280,9 @@ audio_io_handle_t AudioPolicyService::getInput(audio_source_t inputSource,
return 0;
}
Mutex::Autolock _l(mLock);
+ // the audio_in_acoustics_t parameter is ignored by get_input()
audio_io_handle_t input = mpAudioPolicy->get_input(mpAudioPolicy, inputSource, samplingRate,
- format, channels, acoustics);
+ format, channelMask, (audio_in_acoustics_t) 0);
if (input == 0) {
return input;
@@ -373,6 +371,7 @@ status_t AudioPolicyService::initStreamVolume(audio_stream_type_t stream,
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
+ Mutex::Autolock _l(mLock);
mpAudioPolicy->init_stream_volume(mpAudioPolicy, stream, indexMin, indexMax);
return NO_ERROR;
}
@@ -390,7 +389,7 @@ status_t AudioPolicyService::setStreamVolumeIndex(audio_stream_type_t stream,
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
-
+ Mutex::Autolock _l(mLock);
if (mpAudioPolicy->set_stream_volume_index_for_device) {
return mpAudioPolicy->set_stream_volume_index_for_device(mpAudioPolicy,
stream,
@@ -411,6 +410,7 @@ status_t AudioPolicyService::getStreamVolumeIndex(audio_stream_type_t stream,
if (uint32_t(stream) >= AUDIO_STREAM_CNT) {
return BAD_VALUE;
}
+ Mutex::Autolock _l(mLock);
if (mpAudioPolicy->get_stream_volume_index_for_device) {
return mpAudioPolicy->get_stream_volume_index_for_device(mpAudioPolicy,
stream,
@@ -439,7 +439,7 @@ audio_devices_t AudioPolicyService::getDevicesForStream(audio_stream_type_t stre
return mpAudioPolicy->get_devices_for_stream(mpAudioPolicy, stream);
}
-audio_io_handle_t AudioPolicyService::getOutputForEffect(effect_descriptor_t *desc)
+audio_io_handle_t AudioPolicyService::getOutputForEffect(const effect_descriptor_t *desc)
{
if (mpAudioPolicy == NULL) {
return NO_INIT;
@@ -448,7 +448,7 @@ audio_io_handle_t AudioPolicyService::getOutputForEffect(effect_descriptor_t *de
return mpAudioPolicy->get_output_for_effect(mpAudioPolicy, desc);
}
-status_t AudioPolicyService::registerEffect(effect_descriptor_t *desc,
+status_t AudioPolicyService::registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -485,6 +485,18 @@ bool AudioPolicyService::isStreamActive(audio_stream_type_t stream, uint32_t inP
return mpAudioPolicy->is_stream_active(mpAudioPolicy, stream, inPastMs);
}
+bool AudioPolicyService::isSourceActive(audio_source_t source) const
+{
+ if (mpAudioPolicy == NULL) {
+ return false;
+ }
+ if (mpAudioPolicy->is_source_active == 0) {
+ return false;
+ }
+ Mutex::Autolock _l(mLock);
+ return mpAudioPolicy->is_source_active(mpAudioPolicy, source);
+}
+
status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
uint32_t *count)
@@ -512,7 +524,7 @@ status_t AudioPolicyService::queryDefaultPreProcessing(int audioSession,
for (size_t i = 0; i < effects.size(); i++) {
effect_descriptor_t desc = effects[i]->descriptor();
if (i < *count) {
- memcpy(descriptors + i, &desc, sizeof(effect_descriptor_t));
+ descriptors[i] = desc;
}
}
if (effects.size() > *count) {
@@ -687,7 +699,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
data->mIO);
if (command->mWaitStatus) {
command->mCond.signal();
- mWaitWorkCV.wait(mLock);
+ command->mCond.waitRelative(mLock, kAudioCommandTimeout);
}
delete data;
}break;
@@ -698,7 +710,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
command->mStatus = AudioSystem::setParameters(data->mIO, data->mKeyValuePairs);
if (command->mWaitStatus) {
command->mCond.signal();
- mWaitWorkCV.wait(mLock);
+ command->mCond.waitRelative(mLock, kAudioCommandTimeout);
}
delete data;
}break;
@@ -709,7 +721,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
command->mStatus = AudioSystem::setVoiceVolume(data->mVolume);
if (command->mWaitStatus) {
command->mCond.signal();
- mWaitWorkCV.wait(mLock);
+ command->mCond.waitRelative(mLock, kAudioCommandTimeout);
}
delete data;
}break;
@@ -778,7 +790,6 @@ void AudioPolicyService::AudioCommandThread::startToneCommand(ToneGenerator::ton
data->mType = type;
data->mStream = stream;
command->mParam = (void *)data;
- command->mWaitStatus = false;
Mutex::Autolock _l(mLock);
insertCommand_l(command);
ALOGV("AudioCommandThread() adding tone start type %d, stream %d", type, stream);
@@ -790,7 +801,6 @@ void AudioPolicyService::AudioCommandThread::stopToneCommand()
AudioCommand *command = new AudioCommand();
command->mCommand = STOP_TONE;
command->mParam = NULL;
- command->mWaitStatus = false;
Mutex::Autolock _l(mLock);
insertCommand_l(command);
ALOGV("AudioCommandThread() adding tone stop");
@@ -811,11 +821,6 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type
data->mVolume = volume;
data->mIO = output;
command->mParam = data;
- if (delayMs == 0) {
- command->mWaitStatus = true;
- } else {
- command->mWaitStatus = false;
- }
Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
ALOGV("AudioCommandThread() adding set volume stream %d, volume %f, output %d",
@@ -824,7 +829,7 @@ status_t AudioPolicyService::AudioCommandThread::volumeCommand(audio_stream_type
if (command->mWaitStatus) {
command->mCond.wait(mLock);
status = command->mStatus;
- mWaitWorkCV.signal();
+ command->mCond.signal();
}
return status;
}
@@ -841,11 +846,6 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_hand
data->mIO = ioHandle;
data->mKeyValuePairs = String8(keyValuePairs);
command->mParam = data;
- if (delayMs == 0) {
- command->mWaitStatus = true;
- } else {
- command->mWaitStatus = false;
- }
Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
ALOGV("AudioCommandThread() adding set parameter string %s, io %d ,delay %d",
@@ -854,7 +854,7 @@ status_t AudioPolicyService::AudioCommandThread::parametersCommand(audio_io_hand
if (command->mWaitStatus) {
command->mCond.wait(mLock);
status = command->mStatus;
- mWaitWorkCV.signal();
+ command->mCond.signal();
}
return status;
}
@@ -868,11 +868,6 @@ status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume
VoiceVolumeData *data = new VoiceVolumeData();
data->mVolume = volume;
command->mParam = data;
- if (delayMs == 0) {
- command->mWaitStatus = true;
- } else {
- command->mWaitStatus = false;
- }
Mutex::Autolock _l(mLock);
insertCommand_l(command, delayMs);
ALOGV("AudioCommandThread() adding set voice volume volume %f", volume);
@@ -880,7 +875,7 @@ status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume
if (command->mWaitStatus) {
command->mCond.wait(mLock);
status = command->mStatus;
- mWaitWorkCV.signal();
+ command->mCond.signal();
}
return status;
}
@@ -891,6 +886,7 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
ssize_t i; // not size_t because i will count down to -1
Vector <AudioCommand *> removedCommands;
+ nsecs_t time = 0;
command->mTime = systemTime() + milliseconds(delayMs);
// acquire wake lock to make sure delayed commands are processed
@@ -936,6 +932,7 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
} else {
data2->mKeyValuePairs = param2.toString();
}
+ time = command2->mTime;
} break;
case SET_VOLUME: {
@@ -946,6 +943,7 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
ALOGV("Filtering out volume command on output %d for stream %d",
data->mIO, data->mStream);
removedCommands.add(command2);
+ time = command2->mTime;
} break;
case START_TONE:
case STOP_TONE:
@@ -967,6 +965,17 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
}
removedCommands.clear();
+ // wait for status only if delay is 0 and command time was not modified above
+ if (delayMs == 0 && time == 0) {
+ command->mWaitStatus = true;
+ } else {
+ command->mWaitStatus = false;
+ }
+ // update command time if modified above
+ if (time != 0) {
+ command->mTime = time;
+ }
+
// insert command at the right place according to its time stamp
ALOGV("inserting command: %d at index %d, num commands %d",
command->mCommand, (int)i+1, mAudioCommands.size());
@@ -1422,7 +1431,7 @@ static int aps_restore_output(void *service, audio_io_handle_t output)
return af->restoreOutput(output);
}
-// deprecated: replaced by aps_open_input_on_module()
+// deprecated: replaced by aps_open_input_on_module(), and acoustics parameter is ignored
static audio_io_handle_t aps_open_input(void *service,
audio_devices_t *pDevices,
uint32_t *pSamplingRate,
diff --git a/services/audioflinger/AudioPolicyService.h b/services/audioflinger/AudioPolicyService.h
index fbca0008..63f95494 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -64,7 +64,7 @@ public:
virtual audio_io_handle_t getOutput(audio_stream_type_t stream,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = 0,
+ audio_channel_mask_t channelMask = 0,
audio_output_flags_t flags =
AUDIO_OUTPUT_FLAG_NONE);
virtual status_t startOutput(audio_io_handle_t output,
@@ -77,9 +77,7 @@ public:
virtual audio_io_handle_t getInput(audio_source_t inputSource,
uint32_t samplingRate = 0,
audio_format_t format = AUDIO_FORMAT_DEFAULT,
- uint32_t channels = 0,
- audio_in_acoustics_t acoustics =
- (audio_in_acoustics_t)0 /*AUDIO_IN_ACOUSTICS_NONE*/,
+ audio_channel_mask_t channelMask = 0,
int audioSession = 0);
virtual status_t startInput(audio_io_handle_t input);
virtual status_t stopInput(audio_io_handle_t input);
@@ -97,8 +95,8 @@ public:
virtual uint32_t getStrategyForStream(audio_stream_type_t stream);
virtual audio_devices_t getDevicesForStream(audio_stream_type_t stream);
- virtual audio_io_handle_t getOutputForEffect(effect_descriptor_t *desc);
- virtual status_t registerEffect(effect_descriptor_t *desc,
+ virtual audio_io_handle_t getOutputForEffect(const effect_descriptor_t *desc);
+ virtual status_t registerEffect(const effect_descriptor_t *desc,
audio_io_handle_t io,
uint32_t strategy,
int session,
@@ -106,6 +104,7 @@ public:
virtual status_t unregisterEffect(int id);
virtual status_t setEffectEnabled(int id, bool enabled);
virtual bool isStreamActive(audio_stream_type_t stream, uint32_t inPastMs = 0) const;
+ virtual bool isSourceActive(audio_source_t source) const;
virtual status_t queryDefaultPreProcessing(int audioSession,
effect_descriptor_t *descriptors,
diff --git a/services/audioflinger/AudioResampler.cpp b/services/audioflinger/AudioResampler.cpp
index fbb54cf9..2c3c719b 100644
--- a/services/audioflinger/AudioResampler.cpp
+++ b/services/audioflinger/AudioResampler.cpp
@@ -23,10 +23,8 @@
#include <cutils/log.h>
#include <cutils/properties.h>
#include "AudioResampler.h"
-#if 0
#include "AudioResamplerSinc.h"
#include "AudioResamplerCubic.h"
-#endif
#ifdef __arm__
#include <machine/cpu-features.h>
@@ -42,7 +40,7 @@ namespace android {
class AudioResamplerOrder1 : public AudioResampler {
public:
AudioResamplerOrder1(int bitDepth, int inChannelCount, int32_t sampleRate) :
- AudioResampler(bitDepth, inChannelCount, sampleRate), mX0L(0), mX0R(0) {
+ AudioResampler(bitDepth, inChannelCount, sampleRate, LOW_QUALITY), mX0L(0), mX0R(0) {
}
virtual void resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider);
@@ -79,38 +77,129 @@ private:
int mX0R;
};
+bool AudioResampler::qualityIsSupported(src_quality quality)
+{
+ switch (quality) {
+ case DEFAULT_QUALITY:
+ case LOW_QUALITY:
+ case MED_QUALITY:
+ case HIGH_QUALITY:
+ case VERY_HIGH_QUALITY:
+ return true;
+ default:
+ return false;
+ }
+}
+
// ----------------------------------------------------------------------------
-AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
- int32_t sampleRate, int quality) {
- // can only create low quality resample now
- AudioResampler* resampler;
+static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+static AudioResampler::src_quality defaultQuality = AudioResampler::DEFAULT_QUALITY;
+void AudioResampler::init_routine()
+{
char value[PROPERTY_VALUE_MAX];
- if (property_get("af.resampler.quality", value, 0)) {
- quality = atoi(value);
- ALOGD("forcing AudioResampler quality to %d", quality);
+ if (property_get("af.resampler.quality", value, NULL) > 0) {
+ char *endptr;
+ unsigned long l = strtoul(value, &endptr, 0);
+ if (*endptr == '\0') {
+ defaultQuality = (src_quality) l;
+ ALOGD("forcing AudioResampler quality to %d", defaultQuality);
+ if (defaultQuality < DEFAULT_QUALITY || defaultQuality > VERY_HIGH_QUALITY) {
+ defaultQuality = DEFAULT_QUALITY;
+ }
+ }
}
+}
- if (quality == DEFAULT)
- quality = LOW_QUALITY;
+uint32_t AudioResampler::qualityMHz(src_quality quality)
+{
+ switch (quality) {
+ default:
+ case DEFAULT_QUALITY:
+ case LOW_QUALITY:
+ return 3;
+ case MED_QUALITY:
+ return 6;
+ case HIGH_QUALITY:
+ return 20;
+ case VERY_HIGH_QUALITY:
+ return 34;
+ }
+}
+
+static const uint32_t maxMHz = 130; // an arbitrary number that permits 3 VHQ, should be tunable
+static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
+static uint32_t currentMHz = 0;
+
+AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
+ int32_t sampleRate, src_quality quality) {
+
+ bool atFinalQuality;
+ if (quality == DEFAULT_QUALITY) {
+ // read the resampler default quality property the first time it is needed
+ int ok = pthread_once(&once_control, init_routine);
+ if (ok != 0) {
+ ALOGE("%s pthread_once failed: %d", __func__, ok);
+ }
+ quality = defaultQuality;
+ atFinalQuality = false;
+ } else {
+ atFinalQuality = true;
+ }
+
+ // naive implementation of CPU load throttling doesn't account for whether resampler is active
+ pthread_mutex_lock(&mutex);
+ for (;;) {
+ uint32_t deltaMHz = qualityMHz(quality);
+ uint32_t newMHz = currentMHz + deltaMHz;
+ if ((qualityIsSupported(quality) && newMHz <= maxMHz) || atFinalQuality) {
+ ALOGV("resampler load %u -> %u MHz due to delta +%u MHz from quality %d",
+ currentMHz, newMHz, deltaMHz, quality);
+ currentMHz = newMHz;
+ break;
+ }
+ // not enough CPU available for proposed quality level, so try next lowest level
+ switch (quality) {
+ default:
+ case DEFAULT_QUALITY:
+ case LOW_QUALITY:
+ atFinalQuality = true;
+ break;
+ case MED_QUALITY:
+ quality = LOW_QUALITY;
+ break;
+ case HIGH_QUALITY:
+ quality = MED_QUALITY;
+ break;
+ case VERY_HIGH_QUALITY:
+ quality = HIGH_QUALITY;
+ break;
+ }
+ }
+ pthread_mutex_unlock(&mutex);
+
+ AudioResampler* resampler;
switch (quality) {
default:
+ case DEFAULT_QUALITY:
case LOW_QUALITY:
ALOGV("Create linear Resampler");
resampler = new AudioResamplerOrder1(bitDepth, inChannelCount, sampleRate);
break;
-#if 0
case MED_QUALITY:
ALOGV("Create cubic Resampler");
resampler = new AudioResamplerCubic(bitDepth, inChannelCount, sampleRate);
break;
case HIGH_QUALITY:
- ALOGV("Create sinc Resampler");
+ ALOGV("Create HIGH_QUALITY sinc Resampler");
resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate);
break;
-#endif
+ case VERY_HIGH_QUALITY:
+ ALOGV("Create VERY_HIGH_QUALITY sinc Resampler = %d", quality);
+ resampler = new AudioResamplerSinc(bitDepth, inChannelCount, sampleRate, quality);
+ break;
}
// initialize resampler
@@ -119,17 +208,20 @@ AudioResampler* AudioResampler::create(int bitDepth, int inChannelCount,
}
AudioResampler::AudioResampler(int bitDepth, int inChannelCount,
- int32_t sampleRate) :
+ int32_t sampleRate, src_quality quality) :
mBitDepth(bitDepth), mChannelCount(inChannelCount),
mSampleRate(sampleRate), mInSampleRate(sampleRate), mInputIndex(0),
mPhaseFraction(0), mLocalTimeFreq(0),
- mPTS(AudioBufferProvider::kInvalidPTS) {
+ mPTS(AudioBufferProvider::kInvalidPTS), mQuality(quality) {
// sanity check on format
if ((bitDepth != 16) ||(inChannelCount < 1) || (inChannelCount > 2)) {
ALOGE("Unsupported sample format, %d bits, %d channels", bitDepth,
inChannelCount);
// ALOG_ASSERT(0);
}
+ if (sampleRate <= 0) {
+ ALOGE("Unsupported sample rate %d Hz", sampleRate);
+ }
// initialize common members
mVolume[0] = mVolume[1] = 0;
@@ -138,6 +230,15 @@ AudioResampler::AudioResampler(int bitDepth, int inChannelCount,
}
AudioResampler::~AudioResampler() {
+ pthread_mutex_lock(&mutex);
+ src_quality quality = getQuality();
+ uint32_t deltaMHz = qualityMHz(quality);
+ int32_t newMHz = currentMHz - deltaMHz;
+ ALOGV("resampler load %u -> %d MHz due to delta -%u MHz from quality %d",
+ currentMHz, newMHz, deltaMHz, quality);
+ LOG_ALWAYS_FATAL_IF(newMHz < 0, "negative resampler load %d MHz", newMHz);
+ currentMHz = newMHz;
+ pthread_mutex_unlock(&mutex);
}
void AudioResampler::setSampleRate(int32_t inSampleRate) {
diff --git a/services/audioflinger/AudioResampler.h b/services/audioflinger/AudioResampler.h
index 1610e003..2b8694f1 100644
--- a/services/audioflinger/AudioResampler.h
+++ b/services/audioflinger/AudioResampler.h
@@ -20,7 +20,7 @@
#include <stdint.h>
#include <sys/types.h>
-#include "AudioBufferProvider.h"
+#include <media/AudioBufferProvider.h>
namespace android {
// ----------------------------------------------------------------------------
@@ -35,14 +35,15 @@ public:
// certain fixed rate conversions. Sample rate cannot be
// changed dynamically.
enum src_quality {
- DEFAULT=0,
+ DEFAULT_QUALITY=0,
LOW_QUALITY=1,
MED_QUALITY=2,
- HIGH_QUALITY=3
+ HIGH_QUALITY=3,
+ VERY_HIGH_QUALITY=4,
};
static AudioResampler* create(int bitDepth, int inChannelCount,
- int32_t sampleRate, int quality=DEFAULT);
+ int32_t sampleRate, src_quality quality=DEFAULT_QUALITY);
virtual ~AudioResampler();
@@ -60,6 +61,9 @@ public:
virtual void reset();
virtual size_t getUnreleasedFrames() const { return mInputIndex; }
+ // called from destructor, so must not be virtual
+ src_quality getQuality() const { return mQuality; }
+
protected:
// number of bits for phase fraction - 30 bits allows nearly 2x downsampling
static const int kNumPhaseBits = 30;
@@ -70,7 +74,7 @@ protected:
// multiplier to calculate fixed point phase increment
static const double kPhaseMultiplier = 1L << kNumPhaseBits;
- AudioResampler(int bitDepth, int inChannelCount, int32_t sampleRate);
+ AudioResampler(int bitDepth, int inChannelCount, int32_t sampleRate, src_quality quality);
// prevent copying
AudioResampler(const AudioResampler&);
@@ -93,6 +97,19 @@ protected:
uint32_t mPhaseFraction;
uint64_t mLocalTimeFreq;
int64_t mPTS;
+
+private:
+ const src_quality mQuality;
+
+ // Return 'true' if the quality level is supported without explicit request
+ static bool qualityIsSupported(src_quality quality);
+
+ // For pthread_once()
+ static void init_routine();
+
+ // Return the estimated CPU load for specific resampler in MHz.
+ // The absolute number is irrelevant, it's the relative values that matter.
+ static uint32_t qualityMHz(src_quality quality);
};
// ----------------------------------------------------------------------------
diff --git a/services/audioflinger/AudioResamplerCubic.h b/services/audioflinger/AudioResamplerCubic.h
index 892785aa..203b9335 100644
--- a/services/audioflinger/AudioResamplerCubic.h
+++ b/services/audioflinger/AudioResamplerCubic.h
@@ -29,7 +29,7 @@ namespace android {
class AudioResamplerCubic : public AudioResampler {
public:
AudioResamplerCubic(int bitDepth, int inChannelCount, int32_t sampleRate) :
- AudioResampler(bitDepth, inChannelCount, sampleRate) {
+ AudioResampler(bitDepth, inChannelCount, sampleRate, MED_QUALITY) {
}
virtual void resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider);
diff --git a/services/audioflinger/AudioResamplerSinc.cpp b/services/audioflinger/AudioResamplerSinc.cpp
index 76662d80..3f22ca64 100644
--- a/services/audioflinger/AudioResamplerSinc.cpp
+++ b/services/audioflinger/AudioResamplerSinc.cpp
@@ -14,9 +14,36 @@
* limitations under the License.
*/
+#define LOG_TAG "AudioResamplerSinc"
+//#define LOG_NDEBUG 0
+
+#include <malloc.h>
#include <string.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+
+#include <cutils/compiler.h>
+#include <cutils/properties.h>
+
+#include <utils/Log.h>
+
#include "AudioResamplerSinc.h"
+
+
+#if defined(__arm__) && !defined(__thumb__)
+#define USE_INLINE_ASSEMBLY (true)
+#else
+#define USE_INLINE_ASSEMBLY (false)
+#endif
+
+#if USE_INLINE_ASSEMBLY && defined(__ARM_NEON__)
+#define USE_NEON (true)
+#else
+#define USE_NEON (false)
+#endif
+
+
namespace android {
// ----------------------------------------------------------------------------
@@ -24,45 +51,345 @@ namespace android {
/*
* These coeficients are computed with the "fir" utility found in
* tools/resampler_tools
- * TODO: A good optimization would be to transpose this matrix, to take
- * better advantage of the data-cache.
+ * cmd-line: fir -l 7 -s 48000 -c 20478
*/
-const int32_t AudioResamplerSinc::mFirCoefsUp[] = {
- 0x7fffffff, 0x7f15d078, 0x7c5e0da6, 0x77ecd867, 0x71e2e251, 0x6a6c304a, 0x61be7269, 0x58170412, 0x4db8ab05, 0x42e92ea6, 0x37eee214, 0x2d0e3bb1, 0x22879366, 0x18951e95, 0x0f693d0d, 0x072d2621,
- 0x00000000, 0xf9f66655, 0xf51a5fd7, 0xf16bbd84, 0xeee0d9ac, 0xed67a922, 0xece70de6, 0xed405897, 0xee50e505, 0xeff3be30, 0xf203370f, 0xf45a6741, 0xf6d67d53, 0xf957db66, 0xfbc2f647, 0xfe00f2b9,
- 0x00000000, 0x01b37218, 0x0313a0c6, 0x041d930d, 0x04d28057, 0x053731b0, 0x05534dff, 0x05309bfd, 0x04da440d, 0x045c1aee, 0x03c1fcdd, 0x03173ef5, 0x02663ae8, 0x01b7f736, 0x0113ec79, 0x007fe6a9,
- 0x00000000, 0xff96b229, 0xff44f99f, 0xff0a86be, 0xfee5f803, 0xfed518fd, 0xfed521fd, 0xfee2f4fd, 0xfefb54f8, 0xff1b159b, 0xff3f4203, 0xff6539e0, 0xff8ac502, 0xffae1ddd, 0xffcdf3f9, 0xffe96798,
- 0x00000000, 0x00119de6, 0x001e6b7e, 0x0026cb7a, 0x002b4830, 0x002c83d6, 0x002b2a82, 0x0027e67a, 0x002356f9, 0x001e098e, 0x001875e4, 0x0012fbbe, 0x000de2d1, 0x00095c10, 0x00058414, 0x00026636,
- 0x00000000, 0xfffe44a9, 0xfffd206d, 0xfffc7b7f, 0xfffc3c8f, 0xfffc4ac2, 0xfffc8f2b, 0xfffcf5c4, 0xfffd6df3, 0xfffdeab2, 0xfffe6275, 0xfffececf, 0xffff2c07, 0xffff788c, 0xffffb471, 0xffffe0f2,
- 0x00000000, 0x000013e6, 0x00001f03, 0x00002396, 0x00002399, 0x000020b6, 0x00001c3c, 0x00001722, 0x00001216, 0x00000d81, 0x0000099c, 0x0000067c, 0x00000419, 0x0000025f, 0x00000131, 0x00000070,
- 0x00000000, 0xffffffc7, 0xffffffb3, 0xffffffb3, 0xffffffbe, 0xffffffcd, 0xffffffdb, 0xffffffe7, 0xfffffff0, 0xfffffff7, 0xfffffffb, 0xfffffffe, 0xffffffff, 0x00000000, 0x00000000, 0x00000000,
- 0x00000000 // this one is needed for lerping the last coefficient
+const int32_t AudioResamplerSinc::mFirCoefsUp[] __attribute__ ((aligned (32))) = {
+ 0x6d374bc7, 0x111c6ba0, 0xf3240e61, 0x07d14a38, 0xfc509e64, 0x0139cee9, 0xffc8c866, 0xfffcc300,
+ 0x6d35278a, 0x103e8192, 0xf36b9dfd, 0x07bdfaa5, 0xfc5102d0, 0x013d618d, 0xffc663b9, 0xfffd9592,
+ 0x6d2ebafe, 0x0f62811a, 0xf3b3d8ac, 0x07a9f399, 0xfc51d9a6, 0x0140bea5, 0xffc41212, 0xfffe631e,
+ 0x6d24069d, 0x0e8875ad, 0xf3fcb43e, 0x07953976, 0xfc53216f, 0x0143e67c, 0xffc1d373, 0xffff2b9f,
+ 0x6d150b35, 0x0db06a89, 0xf4462690, 0x077fd0ac, 0xfc54d8ae, 0x0146d965, 0xffbfa7d9, 0xffffef10,
+ 0x6d01c9e3, 0x0cda6ab5, 0xf4902587, 0x0769bdaf, 0xfc56fdda, 0x014997bb, 0xffbd8f40, 0x0000ad6e,
+ 0x6cea4418, 0x0c0680fe, 0xf4daa718, 0x07530501, 0xfc598f60, 0x014c21db, 0xffbb89a1, 0x000166b6,
+ 0x6cce7b97, 0x0b34b7f5, 0xf525a143, 0x073bab28, 0xfc5c8ba5, 0x014e782a, 0xffb996f3, 0x00021ae5,
+ 0x6cae7272, 0x0a6519f4, 0xf5710a17, 0x0723b4b4, 0xfc5ff105, 0x01509b14, 0xffb7b728, 0x0002c9fd,
+ 0x6c8a2b0f, 0x0997b116, 0xf5bcd7b1, 0x070b2639, 0xfc63bdd3, 0x01528b08, 0xffb5ea31, 0x000373fb,
+ 0x6c61a823, 0x08cc873c, 0xf609003f, 0x06f20453, 0xfc67f05a, 0x0154487b, 0xffb42ffc, 0x000418e2,
+ 0x6c34ecb5, 0x0803a60a, 0xf6557a00, 0x06d853a2, 0xfc6c86dd, 0x0155d3e8, 0xffb28876, 0x0004b8b3,
+ 0x6c03fc1c, 0x073d16e7, 0xf6a23b44, 0x06be18cd, 0xfc717f97, 0x01572dcf, 0xffb0f388, 0x00055371,
+ 0x6bced9ff, 0x0678e2fc, 0xf6ef3a6e, 0x06a3587e, 0xfc76d8bc, 0x015856b6, 0xffaf7118, 0x0005e921,
+ 0x6b958a54, 0x05b71332, 0xf73c6df4, 0x06881761, 0xfc7c9079, 0x01594f25, 0xffae010b, 0x000679c5,
+ 0x6b581163, 0x04f7b037, 0xf789cc61, 0x066c5a27, 0xfc82a4f4, 0x015a17ab, 0xffaca344, 0x00070564,
+ 0x6b1673c1, 0x043ac276, 0xf7d74c53, 0x06502583, 0xfc89144d, 0x015ab0db, 0xffab57a1, 0x00078c04,
+ 0x6ad0b652, 0x0380521c, 0xf824e480, 0x06337e2a, 0xfc8fdc9f, 0x015b1b4e, 0xffaa1e02, 0x00080dab,
+ 0x6a86de48, 0x02c86715, 0xf8728bb3, 0x061668d2, 0xfc96fbfc, 0x015b579e, 0xffa8f641, 0x00088a62,
+ 0x6a38f123, 0x0213090c, 0xf8c038d0, 0x05f8ea30, 0xfc9e7074, 0x015b666c, 0xffa7e039, 0x00090230,
+ 0x69e6f4b1, 0x01603f6e, 0xf90de2d1, 0x05db06fc, 0xfca63810, 0x015b485b, 0xffa6dbc0, 0x0009751e,
+ 0x6990ef0b, 0x00b01162, 0xf95b80cb, 0x05bcc3ed, 0xfcae50d6, 0x015afe14, 0xffa5e8ad, 0x0009e337,
+ 0x6936e697, 0x000285d0, 0xf9a909ea, 0x059e25b5, 0xfcb6b8c4, 0x015a8843, 0xffa506d2, 0x000a4c85,
+ 0x68d8e206, 0xff57a35e, 0xf9f67577, 0x057f310a, 0xfcbf6dd8, 0x0159e796, 0xffa43603, 0x000ab112,
+ 0x6876e855, 0xfeaf706f, 0xfa43bad2, 0x055fea9d, 0xfcc86e09, 0x01591cc0, 0xffa3760e, 0x000b10ec,
+ 0x681100c9, 0xfe09f323, 0xfa90d17b, 0x0540571a, 0xfcd1b74c, 0x01582878, 0xffa2c6c2, 0x000b6c1d,
+ 0x67a732f4, 0xfd673159, 0xfaddb10c, 0x05207b2f, 0xfcdb4793, 0x01570b77, 0xffa227ec, 0x000bc2b3,
+ 0x673986ac, 0xfcc730aa, 0xfb2a513b, 0x05005b82, 0xfce51ccb, 0x0155c678, 0xffa19957, 0x000c14bb,
+ 0x66c80413, 0xfc29f670, 0xfb76a9dd, 0x04dffcb6, 0xfcef34e1, 0x01545a3c, 0xffa11acb, 0x000c6244,
+ 0x6652b392, 0xfb8f87bd, 0xfbc2b2e4, 0x04bf6369, 0xfcf98dbe, 0x0152c783, 0xffa0ac11, 0x000cab5c,
+ 0x65d99dd5, 0xfaf7e963, 0xfc0e6461, 0x049e9433, 0xfd04254a, 0x01510f13, 0xffa04cf0, 0x000cf012,
+ 0x655ccbd3, 0xfa631fef, 0xfc59b685, 0x047d93a8, 0xfd0ef969, 0x014f31b2, 0xff9ffd2c, 0x000d3075,
+ 0x64dc46c3, 0xf9d12fab, 0xfca4a19f, 0x045c6654, 0xfd1a0801, 0x014d3029, 0xff9fbc89, 0x000d6c97,
+ 0x64581823, 0xf9421c9d, 0xfcef1e20, 0x043b10bd, 0xfd254ef4, 0x014b0b45, 0xff9f8ac9, 0x000da486,
+ 0x63d049b4, 0xf8b5ea87, 0xfd392498, 0x04199760, 0xfd30cc24, 0x0148c3d2, 0xff9f67ae, 0x000dd854,
+ 0x6344e578, 0xf82c9ce7, 0xfd82adba, 0x03f7feb4, 0xfd3c7d73, 0x01465a9f, 0xff9f52f7, 0x000e0812,
+ 0x62b5f5b2, 0xf7a636fa, 0xfdcbb25a, 0x03d64b27, 0xfd4860c2, 0x0143d07f, 0xff9f4c65, 0x000e33d3,
+ 0x622384e8, 0xf722bbb5, 0xfe142b6e, 0x03b4811d, 0xfd5473f3, 0x01412643, 0xff9f53b4, 0x000e5ba7,
+ 0x618d9ddc, 0xf6a22dcf, 0xfe5c120f, 0x0392a4f4, 0xfd60b4e7, 0x013e5cc0, 0xff9f68a1, 0x000e7fa1,
+ 0x60f44b91, 0xf6248fb6, 0xfea35f79, 0x0370bafc, 0xfd6d2180, 0x013b74ca, 0xff9f8ae9, 0x000e9fd5,
+ 0x60579947, 0xf5a9e398, 0xfeea0d0c, 0x034ec77f, 0xfd79b7a1, 0x01386f3a, 0xff9fba47, 0x000ebc54,
+ 0x5fb79278, 0xf5322b61, 0xff30144a, 0x032ccebb, 0xfd86752e, 0x01354ce7, 0xff9ff674, 0x000ed533,
+ 0x5f1442dc, 0xf4bd68b6, 0xff756edc, 0x030ad4e1, 0xfd93580d, 0x01320ea9, 0xffa03f2b, 0x000eea84,
+ 0x5e6db665, 0xf44b9cfe, 0xffba168d, 0x02e8de19, 0xfda05e23, 0x012eb55a, 0xffa09425, 0x000efc5c,
+ 0x5dc3f93c, 0xf3dcc959, 0xfffe054e, 0x02c6ee7f, 0xfdad855b, 0x012b41d3, 0xffa0f519, 0x000f0ace,
+ 0x5d1717c4, 0xf370eea9, 0x00413536, 0x02a50a22, 0xfdbacb9e, 0x0127b4f1, 0xffa161bf, 0x000f15ef,
+ 0x5c671e96, 0xf3080d8c, 0x0083a081, 0x02833506, 0xfdc82edb, 0x01240f8e, 0xffa1d9cf, 0x000f1dd2,
+ 0x5bb41a80, 0xf2a2265e, 0x00c54190, 0x02617321, 0xfdd5ad01, 0x01205285, 0xffa25cfe, 0x000f228d,
+ 0x5afe1886, 0xf23f393b, 0x010612eb, 0x023fc85c, 0xfde34403, 0x011c7eb2, 0xffa2eb04, 0x000f2434,
+ 0x5a4525df, 0xf1df45fd, 0x01460f41, 0x021e3891, 0xfdf0f1d6, 0x011894f0, 0xffa38395, 0x000f22dc,
+ 0x59894ff3, 0xf1824c3e, 0x01853165, 0x01fcc78f, 0xfdfeb475, 0x0114961b, 0xffa42668, 0x000f1e99,
+ 0x58caa45b, 0xf1284b58, 0x01c37452, 0x01db7914, 0xfe0c89db, 0x0110830f, 0xffa4d332, 0x000f1781,
+ 0x580930e1, 0xf0d14267, 0x0200d32c, 0x01ba50d2, 0xfe1a7009, 0x010c5ca6, 0xffa589a6, 0x000f0da8,
+ 0x5745037c, 0xf07d3043, 0x023d493c, 0x0199526b, 0xfe286505, 0x010823ba, 0xffa6497c, 0x000f0125,
+ 0x567e2a51, 0xf02c138a, 0x0278d1f2, 0x01788170, 0xfe3666d5, 0x0103d927, 0xffa71266, 0x000ef20b,
+ 0x55b4b3af, 0xefddea9a, 0x02b368e6, 0x0157e166, 0xfe447389, 0x00ff7dc4, 0xffa7e41a, 0x000ee070,
+ 0x54e8ae13, 0xef92b393, 0x02ed09d7, 0x013775bf, 0xfe528931, 0x00fb126b, 0xffa8be4c, 0x000ecc69,
+ 0x541a281e, 0xef4a6c58, 0x0325b0ad, 0x011741df, 0xfe60a5e5, 0x00f697f3, 0xffa9a0b1, 0x000eb60b,
+ 0x5349309e, 0xef051290, 0x035d5977, 0x00f7491a, 0xfe6ec7c0, 0x00f20f32, 0xffaa8afe, 0x000e9d6b,
+ 0x5275d684, 0xeec2a3a3, 0x0394006a, 0x00d78eb3, 0xfe7cece2, 0x00ed78ff, 0xffab7ce7, 0x000e829e,
+ 0x51a028e8, 0xee831cc3, 0x03c9a1e5, 0x00b815da, 0xfe8b1373, 0x00e8d62d, 0xffac7621, 0x000e65ba,
+ 0x50c83704, 0xee467ae1, 0x03fe3a6f, 0x0098e1b3, 0xfe99399f, 0x00e4278f, 0xffad7662, 0x000e46d3,
+ 0x4fee1037, 0xee0cbab9, 0x0431c6b5, 0x0079f54c, 0xfea75d97, 0x00df6df7, 0xffae7d5f, 0x000e25fd,
+ 0x4f11c3fe, 0xedd5d8ca, 0x0464438c, 0x005b53a4, 0xfeb57d92, 0x00daaa34, 0xffaf8acd, 0x000e034f,
+ 0x4e3361f7, 0xeda1d15c, 0x0495adf2, 0x003cffa9, 0xfec397cf, 0x00d5dd16, 0xffb09e63, 0x000ddedb,
+ 0x4d52f9df, 0xed70a07d, 0x04c6030d, 0x001efc35, 0xfed1aa92, 0x00d10769, 0xffb1b7d8, 0x000db8b7,
+ 0x4c709b8e, 0xed424205, 0x04f54029, 0x00014c12, 0xfedfb425, 0x00cc29f7, 0xffb2d6e1, 0x000d90f6,
+ 0x4b8c56f8, 0xed16b196, 0x052362ba, 0xffe3f1f7, 0xfeedb2da, 0x00c7458a, 0xffb3fb37, 0x000d67ae,
+ 0x4aa63c2c, 0xecedea99, 0x0550685d, 0xffc6f08a, 0xfefba508, 0x00c25ae8, 0xffb52490, 0x000d3cf1,
+ 0x49be5b50, 0xecc7e845, 0x057c4ed4, 0xffaa4a5d, 0xff09890f, 0x00bd6ad7, 0xffb652a7, 0x000d10d5,
+ 0x48d4c4a2, 0xeca4a59b, 0x05a7140b, 0xff8e01f1, 0xff175d53, 0x00b87619, 0xffb78533, 0x000ce36b,
+ 0x47e98874, 0xec841d68, 0x05d0b612, 0xff7219b3, 0xff252042, 0x00b37d70, 0xffb8bbed, 0x000cb4c8,
+ 0x46fcb72d, 0xec664a48, 0x05f93324, 0xff5693fe, 0xff32d04f, 0x00ae8198, 0xffb9f691, 0x000c84ff,
+ 0x460e6148, 0xec4b26a2, 0x0620899e, 0xff3b731b, 0xff406bf8, 0x00a9834e, 0xffbb34d8, 0x000c5422,
+ 0x451e9750, 0xec32acb0, 0x0646b808, 0xff20b93e, 0xff4df1be, 0x00a4834c, 0xffbc767f, 0x000c2245,
+ 0x442d69de, 0xec1cd677, 0x066bbd0d, 0xff066889, 0xff5b602c, 0x009f8249, 0xffbdbb42, 0x000bef79,
+ 0x433ae99c, 0xec099dcf, 0x068f9781, 0xfeec830d, 0xff68b5d5, 0x009a80f8, 0xffbf02dd, 0x000bbbd2,
+ 0x4247273f, 0xebf8fc64, 0x06b2465b, 0xfed30ac5, 0xff75f153, 0x0095800c, 0xffc04d0f, 0x000b8760,
+ 0x41523389, 0xebeaebaf, 0x06d3c8bb, 0xfeba0199, 0xff831148, 0x00908034, 0xffc19996, 0x000b5235,
+ 0x405c1f43, 0xebdf6500, 0x06f41de3, 0xfea16960, 0xff90145e, 0x008b821b, 0xffc2e832, 0x000b1c64,
+ 0x3f64fb40, 0xebd6617b, 0x0713453d, 0xfe8943dc, 0xff9cf947, 0x0086866b, 0xffc438a3, 0x000ae5fc,
+ 0x3e6cd85b, 0xebcfda19, 0x07313e56, 0xfe7192bd, 0xffa9bebe, 0x00818dcb, 0xffc58aaa, 0x000aaf0f,
+ 0x3d73c772, 0xebcbc7a7, 0x074e08e0, 0xfe5a579d, 0xffb66386, 0x007c98de, 0xffc6de09, 0x000a77ac,
+ 0x3c79d968, 0xebca22cc, 0x0769a4b2, 0xfe439407, 0xffc2e669, 0x0077a845, 0xffc83285, 0x000a3fe5,
+ 0x3b7f1f23, 0xebcae405, 0x078411c7, 0xfe2d496f, 0xffcf463a, 0x0072bc9d, 0xffc987e0, 0x000a07c9,
+ 0x3a83a989, 0xebce03aa, 0x079d503b, 0xfe177937, 0xffdb81d6, 0x006dd680, 0xffcadde1, 0x0009cf67,
+ 0x3987897f, 0xebd379eb, 0x07b56051, 0xfe0224b0, 0xffe79820, 0x0068f687, 0xffcc344c, 0x000996ce,
+ 0x388acfe9, 0xebdb3ed5, 0x07cc426c, 0xfded4d13, 0xfff38806, 0x00641d44, 0xffcd8aeb, 0x00095e0e,
+ 0x378d8da8, 0xebe54a4f, 0x07e1f712, 0xfdd8f38b, 0xffff507b, 0x005f4b4a, 0xffcee183, 0x00092535,
+ 0x368fd397, 0xebf1941f, 0x07f67eec, 0xfdc5192d, 0x000af07f, 0x005a8125, 0xffd037e0, 0x0008ec50,
+ 0x3591b28b, 0xec0013e8, 0x0809dac3, 0xfdb1befc, 0x00166718, 0x0055bf60, 0xffd18dcc, 0x0008b36e,
+ 0x34933b50, 0xec10c12c, 0x081c0b84, 0xfd9ee5e7, 0x0021b355, 0x00510682, 0xffd2e311, 0x00087a9c,
+ 0x33947eab, 0xec23934f, 0x082d1239, 0xfd8c8ecc, 0x002cd44d, 0x004c570f, 0xffd4377d, 0x000841e8,
+ 0x32958d55, 0xec388194, 0x083cf010, 0xfd7aba74, 0x0037c922, 0x0047b186, 0xffd58ade, 0x0008095d,
+ 0x319677fa, 0xec4f8322, 0x084ba654, 0xfd696998, 0x004290fc, 0x00431666, 0xffd6dd02, 0x0007d108,
+ 0x30974f3b, 0xec688f02, 0x08593671, 0xfd589cdc, 0x004d2b0e, 0x003e8628, 0xffd82dba, 0x000798f5,
+ 0x2f9823a8, 0xec839c22, 0x0865a1f1, 0xfd4854d3, 0x00579691, 0x003a0141, 0xffd97cd6, 0x00076130,
+ 0x2e9905c1, 0xeca0a156, 0x0870ea7e, 0xfd3891fd, 0x0061d2ca, 0x00358824, 0xffdaca2a, 0x000729c4,
+ 0x2d9a05f4, 0xecbf9558, 0x087b11de, 0xfd2954c8, 0x006bdf05, 0x00311b41, 0xffdc1588, 0x0006f2bb,
+ 0x2c9b349e, 0xece06ecb, 0x088419f6, 0xfd1a9d91, 0x0075ba95, 0x002cbb03, 0xffdd5ec6, 0x0006bc21,
+ 0x2b9ca203, 0xed032439, 0x088c04c8, 0xfd0c6ca2, 0x007f64da, 0x002867d2, 0xffdea5bb, 0x000685ff,
+ 0x2a9e5e57, 0xed27ac16, 0x0892d470, 0xfcfec233, 0x0088dd38, 0x00242213, 0xffdfea3c, 0x0006505f,
+ 0x29a079b2, 0xed4dfcc2, 0x08988b2a, 0xfcf19e6b, 0x0092231e, 0x001fea27, 0xffe12c22, 0x00061b4b,
+ 0x28a30416, 0xed760c88, 0x089d2b4a, 0xfce50161, 0x009b3605, 0x001bc06b, 0xffe26b48, 0x0005e6cb,
+ 0x27a60d6a, 0xed9fd1a2, 0x08a0b740, 0xfcd8eb17, 0x00a4156b, 0x0017a53b, 0xffe3a788, 0x0005b2e8,
+ 0x26a9a57b, 0xedcb4237, 0x08a33196, 0xfccd5b82, 0x00acc0da, 0x001398ec, 0xffe4e0bf, 0x00057faa,
+ 0x25addbf9, 0xedf8545b, 0x08a49cf0, 0xfcc25285, 0x00b537e1, 0x000f9bd2, 0xffe616c8, 0x00054d1a,
+ 0x24b2c075, 0xee26fe17, 0x08a4fc0d, 0xfcb7cff0, 0x00bd7a1c, 0x000bae3c, 0xffe74984, 0x00051b3e,
+ 0x23b86263, 0xee573562, 0x08a451c0, 0xfcadd386, 0x00c5872a, 0x0007d075, 0xffe878d3, 0x0004ea1d,
+ 0x22bed116, 0xee88f026, 0x08a2a0f8, 0xfca45cf7, 0x00cd5eb7, 0x000402c8, 0xffe9a494, 0x0004b9c0,
+ 0x21c61bc0, 0xeebc2444, 0x089fecbb, 0xfc9b6be5, 0x00d50075, 0x00004579, 0xffeaccaa, 0x00048a2b,
+ 0x20ce516f, 0xeef0c78d, 0x089c3824, 0xfc92ffe1, 0x00dc6c1e, 0xfffc98c9, 0xffebf0fa, 0x00045b65,
+ 0x1fd7810f, 0xef26cfca, 0x08978666, 0xfc8b186d, 0x00e3a175, 0xfff8fcf7, 0xffed1166, 0x00042d74,
+ 0x1ee1b965, 0xef5e32bd, 0x0891dac8, 0xfc83b4fc, 0x00eaa045, 0xfff5723d, 0xffee2dd7, 0x0004005e,
+ 0x1ded0911, 0xef96e61c, 0x088b38a9, 0xfc7cd4f0, 0x00f16861, 0xfff1f8d2, 0xffef4632, 0x0003d426,
+ 0x1cf97e8b, 0xefd0df9a, 0x0883a378, 0xfc76779e, 0x00f7f9a3, 0xffee90eb, 0xfff05a60, 0x0003a8d2,
+ 0x1c072823, 0xf00c14e1, 0x087b1ebc, 0xfc709c4d, 0x00fe53ef, 0xffeb3ab8, 0xfff16a4a, 0x00037e65,
+ 0x1b1613ff, 0xf0487b98, 0x0871ae0d, 0xfc6b4233, 0x0104772e, 0xffe7f666, 0xfff275db, 0x000354e5,
+ 0x1a26501b, 0xf0860962, 0x08675516, 0xfc66687a, 0x010a6353, 0xffe4c41e, 0xfff37d00, 0x00032c54,
+ 0x1937ea47, 0xf0c4b3e0, 0x085c1794, 0xfc620e3d, 0x01101858, 0xffe1a408, 0xfff47fa5, 0x000304b7,
+ 0x184af025, 0xf10470b0, 0x084ff957, 0xfc5e328c, 0x0115963d, 0xffde9646, 0xfff57db8, 0x0002de0e,
+ 0x175f6f2b, 0xf1453571, 0x0842fe3d, 0xfc5ad465, 0x011add0b, 0xffdb9af8, 0xfff67729, 0x0002b85f,
+ 0x1675749e, 0xf186f7c0, 0x08352a35, 0xfc57f2be, 0x011fecd3, 0xffd8b23b, 0xfff76be9, 0x000293aa,
+ 0x158d0d95, 0xf1c9ad40, 0x0826813e, 0xfc558c7c, 0x0124c5ab, 0xffd5dc28, 0xfff85be8, 0x00026ff2,
+ 0x14a646f6, 0xf20d4b92, 0x08170767, 0xfc53a07b, 0x012967b1, 0xffd318d6, 0xfff9471b, 0x00024d39,
+ 0x13c12d73, 0xf251c85d, 0x0806c0cb, 0xfc522d88, 0x012dd30a, 0xffd06858, 0xfffa2d74, 0x00022b7f,
+ 0x12ddcd8f, 0xf297194d, 0x07f5b193, 0xfc513266, 0x013207e4, 0xffcdcabe, 0xfffb0ee9, 0x00020ac7,
+ 0x11fc3395, 0xf2dd3411, 0x07e3ddf7, 0xfc50adcc, 0x01360670, 0xffcb4014, 0xfffbeb70, 0x0001eb10,
+ 0x111c6ba0, 0xf3240e61, 0x07d14a38, 0xfc509e64, 0x0139cee9, 0xffc8c866, 0xfffcc300, 0x0001cc5c,
};
/*
- * These coefficients are optimized for 48KHz -> 44.1KHz (stop-band at 22.050KHz)
- * It's possible to use the above coefficient for any down-sampling
- * at the expense of a slower processing loop (we can interpolate
- * these coefficient from the above by "Stretching" them in time).
+ * These coefficients are optimized for 48KHz -> 44.1KHz
+ * cmd-line: fir -l 7 -s 48000 -c 17189
*/
-const int32_t AudioResamplerSinc::mFirCoefsDown[] = {
- 0x7fffffff, 0x7f55e46d, 0x7d5b4c60, 0x7a1b4b98, 0x75a7fb14, 0x7019f0bd, 0x698f875a, 0x622bfd59, 0x5a167256, 0x5178cc54, 0x487e8e6c, 0x3f53aae8, 0x36235ad4, 0x2d17047b, 0x245539ab, 0x1c00d540,
- 0x14383e57, 0x0d14d5ca, 0x06aa910b, 0x0107c38b, 0xfc351654, 0xf835abae, 0xf5076b45, 0xf2a37202, 0xf0fe9faa, 0xf00a3bbd, 0xefb4aa81, 0xefea2b05, 0xf0959716, 0xf1a11e83, 0xf2f6f7a0, 0xf481fff4,
- 0xf62e48ce, 0xf7e98ca5, 0xf9a38b4c, 0xfb4e4bfa, 0xfcde456f, 0xfe4a6d30, 0xff8c2fdf, 0x009f5555, 0x0181d393, 0x0233940f, 0x02b62f06, 0x030ca07d, 0x033afa62, 0x03461725, 0x03334f83, 0x030835fa,
- 0x02ca59cc, 0x027f12d1, 0x022b570d, 0x01d39a49, 0x017bb78f, 0x0126e414, 0x00d7aaaf, 0x008feec7, 0x0050f584, 0x001b73e3, 0xffefa063, 0xffcd46ed, 0xffb3ddcd, 0xffa29aaa, 0xff988691, 0xff949066,
- 0xff959d24, 0xff9a959e, 0xffa27195, 0xffac4011, 0xffb72d2b, 0xffc28569, 0xffcdb706, 0xffd85171, 0xffe20364, 0xffea97e9, 0xfff1f2b2, 0xfff80c06, 0xfffcec92, 0x0000a955, 0x00035fd8, 0x000532cf,
- 0x00064735, 0x0006c1f9, 0x0006c62d, 0x000673ba, 0x0005e68f, 0x00053630, 0x000475a3, 0x0003b397, 0x0002fac1, 0x00025257, 0x0001be9e, 0x0001417a, 0x0000dafd, 0x000089eb, 0x00004c28, 0x00001f1d,
- 0x00000000, 0xffffec10, 0xffffe0be, 0xffffdbc5, 0xffffdb39, 0xffffdd8b, 0xffffe182, 0xffffe638, 0xffffeb0a, 0xffffef8f, 0xfffff38b, 0xfffff6e3, 0xfffff993, 0xfffffba6, 0xfffffd30, 0xfffffe4a,
- 0xffffff09, 0xffffff85, 0xffffffd1, 0xfffffffb, 0x0000000f, 0x00000016, 0x00000015, 0x00000012, 0x0000000d, 0x00000009, 0x00000006, 0x00000003, 0x00000002, 0x00000001, 0x00000000, 0x00000000,
- 0x00000000 // this one is needed for lerping the last coefficient
+const int32_t AudioResamplerSinc::mFirCoefsDown[] __attribute__ ((aligned (32))) = {
+ 0x5bacb6f4, 0x1ded1a1d, 0xf0398d56, 0x0394f674, 0x0193a5f9, 0xfe66dbeb, 0x00791043, 0xfffe6631,
+ 0x5bab6c81, 0x1d3ddccd, 0xf0421d2c, 0x03af9995, 0x01818dc9, 0xfe6bb63e, 0x0079812a, 0xfffdc37d,
+ 0x5ba78d37, 0x1c8f2cf9, 0xf04beb1d, 0x03c9a04a, 0x016f8aca, 0xfe70a511, 0x0079e34d, 0xfffd2545,
+ 0x5ba1194f, 0x1be11231, 0xf056f2c7, 0x03e309fe, 0x015d9e64, 0xfe75a79f, 0x007a36e2, 0xfffc8b86,
+ 0x5b981122, 0x1b3393f8, 0xf0632fb7, 0x03fbd625, 0x014bc9fa, 0xfe7abd23, 0x007a7c20, 0xfffbf639,
+ 0x5b8c7530, 0x1a86b9bf, 0xf0709d74, 0x04140449, 0x013a0ee9, 0xfe7fe4db, 0x007ab33d, 0xfffb655b,
+ 0x5b7e461a, 0x19da8ae5, 0xf07f3776, 0x042b93fd, 0x01286e86, 0xfe851e05, 0x007adc72, 0xfffad8e4,
+ 0x5b6d84a8, 0x192f0eb7, 0xf08ef92d, 0x044284e6, 0x0116ea22, 0xfe8a67dd, 0x007af7f6, 0xfffa50ce,
+ 0x5b5a31c6, 0x18844c70, 0xf09fddfe, 0x0458d6b7, 0x01058306, 0xfe8fc1a5, 0x007b0603, 0xfff9cd12,
+ 0x5b444e81, 0x17da4b37, 0xf0b1e143, 0x046e8933, 0x00f43a74, 0xfe952a9b, 0x007b06d4, 0xfff94da9,
+ 0x5b2bdc0e, 0x17311222, 0xf0c4fe50, 0x04839c29, 0x00e311a9, 0xfe9aa201, 0x007afaa1, 0xfff8d28c,
+ 0x5b10dbc2, 0x1688a832, 0xf0d9306d, 0x04980f79, 0x00d209db, 0xfea02719, 0x007ae1a7, 0xfff85bb1,
+ 0x5af34f18, 0x15e11453, 0xf0ee72db, 0x04abe310, 0x00c12439, 0xfea5b926, 0x007abc20, 0xfff7e910,
+ 0x5ad337af, 0x153a5d5e, 0xf104c0d2, 0x04bf16e9, 0x00b061eb, 0xfeab576d, 0x007a8a49, 0xfff77a9f,
+ 0x5ab09748, 0x14948a16, 0xf11c1583, 0x04d1ab0d, 0x009fc413, 0xfeb10134, 0x007a4c5d, 0xfff71057,
+ 0x5a8b6fc7, 0x13efa12c, 0xf1346c17, 0x04e39f93, 0x008f4bcb, 0xfeb6b5c0, 0x007a029a, 0xfff6aa2b,
+ 0x5a63c336, 0x134ba937, 0xf14dbfb1, 0x04f4f4a2, 0x007efa29, 0xfebc745c, 0x0079ad3d, 0xfff64812,
+ 0x5a3993c0, 0x12a8a8bb, 0xf1680b6e, 0x0505aa6a, 0x006ed038, 0xfec23c50, 0x00794c82, 0xfff5ea02,
+ 0x5a0ce3b2, 0x1206a625, 0xf1834a63, 0x0515c12d, 0x005ecf01, 0xfec80ce8, 0x0078e0a9, 0xfff58ff0,
+ 0x59ddb57f, 0x1165a7cc, 0xf19f77a0, 0x05253938, 0x004ef782, 0xfecde571, 0x007869ee, 0xfff539cf,
+ 0x59ac0bba, 0x10c5b3ef, 0xf1bc8e31, 0x053412e4, 0x003f4ab4, 0xfed3c538, 0x0077e891, 0xfff4e794,
+ 0x5977e919, 0x1026d0b8, 0xf1da891b, 0x05424e9b, 0x002fc98a, 0xfed9ab8f, 0x00775ccf, 0xfff49934,
+ 0x59415075, 0x0f890437, 0xf1f96360, 0x054feccf, 0x002074ed, 0xfedf97c6, 0x0076c6e8, 0xfff44ea3,
+ 0x590844c9, 0x0eec5465, 0xf21917ff, 0x055cee03, 0x00114dc3, 0xfee58932, 0x00762719, 0xfff407d2,
+ 0x58ccc930, 0x0e50c723, 0xf239a1ef, 0x056952c3, 0x000254e8, 0xfeeb7f27, 0x00757da3, 0xfff3c4b7,
+ 0x588ee0ea, 0x0db6623b, 0xf25afc29, 0x05751baa, 0xfff38b32, 0xfef178fc, 0x0074cac4, 0xfff38542,
+ 0x584e8f56, 0x0d1d2b5d, 0xf27d219f, 0x0580495c, 0xffe4f171, 0xfef7760c, 0x00740ebb, 0xfff34968,
+ 0x580bd7f4, 0x0c85281f, 0xf2a00d43, 0x058adc8d, 0xffd6886d, 0xfefd75af, 0x007349c7, 0xfff3111b,
+ 0x57c6be67, 0x0bee5dff, 0xf2c3ba04, 0x0594d5fa, 0xffc850e6, 0xff037744, 0x00727c27, 0xfff2dc4c,
+ 0x577f4670, 0x0b58d262, 0xf2e822ce, 0x059e366c, 0xffba4b98, 0xff097a29, 0x0071a61b, 0xfff2aaef,
+ 0x573573f2, 0x0ac48a92, 0xf30d428e, 0x05a6feb9, 0xffac7936, 0xff0f7dbf, 0x0070c7e1, 0xfff27cf3,
+ 0x56e94af1, 0x0a318bc1, 0xf333142f, 0x05af2fbf, 0xff9eda6d, 0xff15816a, 0x006fe1b8, 0xfff2524c,
+ 0x569acf90, 0x099fdb04, 0xf359929a, 0x05b6ca6b, 0xff916fe1, 0xff1b848e, 0x006ef3df, 0xfff22aea,
+ 0x564a0610, 0x090f7d57, 0xf380b8ba, 0x05bdcfb2, 0xff843a32, 0xff218692, 0x006dfe94, 0xfff206bf,
+ 0x55f6f2d3, 0x0880779d, 0xf3a88179, 0x05c44095, 0xff7739f7, 0xff2786e1, 0x006d0217, 0xfff1e5bb,
+ 0x55a19a5c, 0x07f2ce9b, 0xf3d0e7c2, 0x05ca1e1f, 0xff6a6fc1, 0xff2d84e5, 0x006bfea4, 0xfff1c7d0,
+ 0x554a0148, 0x076686fc, 0xf3f9e680, 0x05cf6965, 0xff5ddc1a, 0xff33800e, 0x006af47b, 0xfff1acef,
+ 0x54f02c56, 0x06dba551, 0xf42378a0, 0x05d42387, 0xff517f86, 0xff3977cb, 0x0069e3d9, 0xfff19508,
+ 0x54942061, 0x06522e0f, 0xf44d9912, 0x05d84daf, 0xff455a80, 0xff3f6b8f, 0x0068ccfa, 0xfff1800b,
+ 0x5435e263, 0x05ca258f, 0xf47842c5, 0x05dbe90f, 0xff396d7f, 0xff455acf, 0x0067b01e, 0xfff16de9,
+ 0x53d57774, 0x0543900d, 0xf4a370ad, 0x05def6e4, 0xff2db8f2, 0xff4b4503, 0x00668d80, 0xfff15e93,
+ 0x5372e4c6, 0x04be71ab, 0xf4cf1dbf, 0x05e17873, 0xff223d40, 0xff5129a3, 0x0065655d, 0xfff151f9,
+ 0x530e2fac, 0x043ace6e, 0xf4fb44f4, 0x05e36f0d, 0xff16faca, 0xff57082e, 0x006437f1, 0xfff1480b,
+ 0x52a75d90, 0x03b8aa40, 0xf527e149, 0x05e4dc08, 0xff0bf1ed, 0xff5ce021, 0x00630577, 0xfff140b9,
+ 0x523e73fd, 0x033808eb, 0xf554edbd, 0x05e5c0c6, 0xff0122fc, 0xff62b0fd, 0x0061ce2c, 0xfff13bf3,
+ 0x51d37897, 0x02b8ee22, 0xf5826555, 0x05e61eae, 0xfef68e45, 0xff687a47, 0x00609249, 0xfff139aa,
+ 0x5166711c, 0x023b5d76, 0xf5b0431a, 0x05e5f733, 0xfeec340f, 0xff6e3b84, 0x005f520a, 0xfff139cd,
+ 0x50f76368, 0x01bf5a5e, 0xf5de8218, 0x05e54bcd, 0xfee2149b, 0xff73f43d, 0x005e0da8, 0xfff13c4c,
+ 0x5086556f, 0x0144e834, 0xf60d1d63, 0x05e41dfe, 0xfed83023, 0xff79a3fe, 0x005cc55c, 0xfff14119,
+ 0x50134d3e, 0x00cc0a36, 0xf63c1012, 0x05e26f4e, 0xfece86db, 0xff7f4a54, 0x005b7961, 0xfff14821,
+ 0x4f9e50ff, 0x0054c382, 0xf66b5544, 0x05e0414d, 0xfec518f1, 0xff84e6d0, 0x005a29ed, 0xfff15156,
+ 0x4f2766f2, 0xffdf171b, 0xf69ae81d, 0x05dd9593, 0xfebbe68c, 0xff8a7905, 0x0058d738, 0xfff15ca8,
+ 0x4eae9571, 0xff6b07e7, 0xf6cac3c7, 0x05da6dbe, 0xfeb2efcd, 0xff900089, 0x0057817b, 0xfff16a07,
+ 0x4e33e2ee, 0xfef898ae, 0xf6fae373, 0x05d6cb72, 0xfeaa34d0, 0xff957cf4, 0x005628ec, 0xfff17962,
+ 0x4db755f3, 0xfe87cc1b, 0xf72b425b, 0x05d2b05c, 0xfea1b5a9, 0xff9aede0, 0x0054cdc0, 0xfff18aab,
+ 0x4d38f520, 0xfe18a4bc, 0xf75bdbbd, 0x05ce1e2d, 0xfe997268, 0xffa052ec, 0x0053702d, 0xfff19dd1,
+ 0x4cb8c72e, 0xfdab2501, 0xf78caae0, 0x05c9169d, 0xfe916b15, 0xffa5abb8, 0x00521068, 0xfff1b2c5,
+ 0x4c36d2eb, 0xfd3f4f3d, 0xf7bdab16, 0x05c39b6a, 0xfe899fb2, 0xffaaf7e6, 0x0050aea5, 0xfff1c976,
+ 0x4bb31f3c, 0xfcd525a5, 0xf7eed7b4, 0x05bdae57, 0xfe82103f, 0xffb0371c, 0x004f4b17, 0xfff1e1d6,
+ 0x4b2db31a, 0xfc6caa53, 0xf8202c1c, 0x05b7512e, 0xfe7abcb1, 0xffb56902, 0x004de5f1, 0xfff1fbd5,
+ 0x4aa69594, 0xfc05df40, 0xf851a3b6, 0x05b085bc, 0xfe73a4fb, 0xffba8d44, 0x004c7f66, 0xfff21764,
+ 0x4a1dcdce, 0xfba0c64b, 0xf88339f5, 0x05a94dd5, 0xfe6cc909, 0xffbfa38d, 0x004b17a6, 0xfff23473,
+ 0x499362ff, 0xfb3d6133, 0xf8b4ea55, 0x05a1ab52, 0xfe6628c1, 0xffc4ab8f, 0x0049aee3, 0xfff252f3,
+ 0x49075c72, 0xfadbb19a, 0xf8e6b059, 0x0599a00e, 0xfe5fc405, 0xffc9a4fc, 0x0048454b, 0xfff272d6,
+ 0x4879c185, 0xfa7bb908, 0xf9188793, 0x05912dea, 0xfe599aaf, 0xffce8f8a, 0x0046db0f, 0xfff2940b,
+ 0x47ea99a9, 0xfa1d78e3, 0xf94a6b9b, 0x058856cd, 0xfe53ac97, 0xffd36af1, 0x0045705c, 0xfff2b686,
+ 0x4759ec60, 0xf9c0f276, 0xf97c5815, 0x057f1c9e, 0xfe4df98e, 0xffd836eb, 0x00440561, 0xfff2da36,
+ 0x46c7c140, 0xf96626f0, 0xf9ae48af, 0x0575814c, 0xfe48815e, 0xffdcf336, 0x00429a4a, 0xfff2ff0d,
+ 0x46341fed, 0xf90d1761, 0xf9e03924, 0x056b86c6, 0xfe4343d0, 0xffe19f91, 0x00412f43, 0xfff324fd,
+ 0x459f101d, 0xf8b5c4be, 0xfa122537, 0x05612f00, 0xfe3e40a6, 0xffe63bc0, 0x003fc478, 0xfff34bf9,
+ 0x45089996, 0xf8602fdc, 0xfa4408ba, 0x05567bf1, 0xfe39779a, 0xffeac787, 0x003e5a12, 0xfff373f0,
+ 0x4470c42d, 0xf80c5977, 0xfa75df87, 0x054b6f92, 0xfe34e867, 0xffef42af, 0x003cf03d, 0xfff39cd7,
+ 0x43d797c7, 0xf7ba422b, 0xfaa7a586, 0x05400be1, 0xfe3092bf, 0xfff3ad01, 0x003b871f, 0xfff3c69f,
+ 0x433d1c56, 0xf769ea78, 0xfad956ab, 0x053452dc, 0xfe2c7650, 0xfff8064b, 0x003a1ee3, 0xfff3f13a,
+ 0x42a159dc, 0xf71b52c4, 0xfb0aeef6, 0x05284685, 0xfe2892c5, 0xfffc4e5c, 0x0038b7ae, 0xfff41c9c,
+ 0x42045865, 0xf6ce7b57, 0xfb3c6a73, 0x051be8dd, 0xfe24e7c3, 0x00008507, 0x003751a7, 0xfff448b7,
+ 0x4166200e, 0xf683645a, 0xfb6dc53c, 0x050f3bec, 0xfe2174ec, 0x0004aa1f, 0x0035ecf4, 0xfff4757e,
+ 0x40c6b8fd, 0xf63a0ddf, 0xfb9efb77, 0x050241b6, 0xfe1e39da, 0x0008bd7c, 0x003489b9, 0xfff4a2e5,
+ 0x40262b65, 0xf5f277d9, 0xfbd00956, 0x04f4fc46, 0xfe1b3628, 0x000cbef7, 0x0033281a, 0xfff4d0de,
+ 0x3f847f83, 0xf5aca21f, 0xfc00eb1b, 0x04e76da3, 0xfe18696a, 0x0010ae6e, 0x0031c83a, 0xfff4ff5d,
+ 0x3ee1bda2, 0xf5688c6d, 0xfc319d13, 0x04d997d8, 0xfe15d32f, 0x00148bbd, 0x00306a3b, 0xfff52e57,
+ 0x3e3dee13, 0xf5263665, 0xfc621b9a, 0x04cb7cf2, 0xfe137304, 0x001856c7, 0x002f0e3f, 0xfff55dbf,
+ 0x3d991932, 0xf4e59f8a, 0xfc926319, 0x04bd1efb, 0xfe114872, 0x001c0f6e, 0x002db466, 0xfff58d89,
+ 0x3cf34766, 0xf4a6c748, 0xfcc27008, 0x04ae8000, 0xfe0f52fc, 0x001fb599, 0x002c5cd0, 0xfff5bdaa,
+ 0x3c4c811c, 0xf469aced, 0xfcf23eec, 0x049fa20f, 0xfe0d9224, 0x0023492f, 0x002b079a, 0xfff5ee17,
+ 0x3ba4cec9, 0xf42e4faf, 0xfd21cc59, 0x04908733, 0xfe0c0567, 0x0026ca1c, 0x0029b4e4, 0xfff61ec5,
+ 0x3afc38eb, 0xf3f4aea6, 0xfd5114f0, 0x0481317a, 0xfe0aac3f, 0x002a384c, 0x002864c9, 0xfff64fa8,
+ 0x3a52c805, 0xf3bcc8d3, 0xfd801564, 0x0471a2ef, 0xfe098622, 0x002d93ae, 0x00271766, 0xfff680b5,
+ 0x39a884a1, 0xf3869d1a, 0xfdaeca73, 0x0461dda0, 0xfe089283, 0x0030dc34, 0x0025ccd7, 0xfff6b1e4,
+ 0x38fd774e, 0xf3522a49, 0xfddd30eb, 0x0451e396, 0xfe07d0d3, 0x003411d2, 0x00248535, 0xfff6e329,
+ 0x3851a8a2, 0xf31f6f0f, 0xfe0b45aa, 0x0441b6dd, 0xfe07407d, 0x0037347d, 0x0023409a, 0xfff7147a,
+ 0x37a52135, 0xf2ee6a07, 0xfe39059b, 0x0431597d, 0xfe06e0eb, 0x003a442e, 0x0021ff1f, 0xfff745cd,
+ 0x36f7e9a4, 0xf2bf19ae, 0xfe666dbc, 0x0420cd80, 0xfe06b184, 0x003d40e0, 0x0020c0dc, 0xfff7771a,
+ 0x364a0a90, 0xf2917c6d, 0xfe937b15, 0x041014eb, 0xfe06b1ac, 0x00402a8e, 0x001f85e6, 0xfff7a857,
+ 0x359b8c9d, 0xf265908f, 0xfec02ac2, 0x03ff31c3, 0xfe06e0c4, 0x00430137, 0x001e4e56, 0xfff7d97a,
+ 0x34ec786f, 0xf23b544b, 0xfeec79ec, 0x03ee260d, 0xfe073e2a, 0x0045c4dd, 0x001d1a3f, 0xfff80a7c,
+ 0x343cd6af, 0xf212c5be, 0xff1865cd, 0x03dcf3ca, 0xfe07c93a, 0x00487582, 0x001be9b7, 0xfff83b52,
+ 0x338cb004, 0xf1ebe2ec, 0xff43ebac, 0x03cb9cf9, 0xfe08814e, 0x004b132b, 0x001abcd0, 0xfff86bf6,
+ 0x32dc0d17, 0xf1c6a9c3, 0xff6f08e4, 0x03ba2398, 0xfe0965bc, 0x004d9dde, 0x0019939d, 0xfff89c60,
+ 0x322af693, 0xf1a3181a, 0xff99badb, 0x03a889a1, 0xfe0a75da, 0x005015a5, 0x00186e31, 0xfff8cc86,
+ 0x3179751f, 0xf1812bb0, 0xffc3ff0c, 0x0396d10c, 0xfe0bb0f9, 0x00527a8a, 0x00174c9c, 0xfff8fc62,
+ 0x30c79163, 0xf160e22d, 0xffedd2fd, 0x0384fbd1, 0xfe0d166b, 0x0054cc9a, 0x00162eef, 0xfff92bec,
+ 0x30155404, 0xf1423924, 0x00173447, 0x03730be0, 0xfe0ea57e, 0x00570be4, 0x00151538, 0xfff95b1e,
+ 0x2f62c5a7, 0xf1252e0f, 0x00402092, 0x0361032a, 0xfe105d7e, 0x00593877, 0x0013ff88, 0xfff989ef,
+ 0x2eafeeed, 0xf109be56, 0x00689598, 0x034ee39b, 0xfe123db6, 0x005b5267, 0x0012edea, 0xfff9b85b,
+ 0x2dfcd873, 0xf0efe748, 0x0090911f, 0x033caf1d, 0xfe144570, 0x005d59c6, 0x0011e06d, 0xfff9e65a,
+ 0x2d498ad3, 0xf0d7a622, 0x00b81102, 0x032a6796, 0xfe1673f2, 0x005f4eac, 0x0010d71d, 0xfffa13e5,
+ 0x2c960ea3, 0xf0c0f808, 0x00df1328, 0x03180ee7, 0xfe18c884, 0x0061312e, 0x000fd205, 0xfffa40f8,
+ 0x2be26c73, 0xf0abda0e, 0x0105958c, 0x0305a6f0, 0xfe1b4268, 0x00630167, 0x000ed130, 0xfffa6d8d,
+ 0x2b2eaccf, 0xf0984931, 0x012b9635, 0x02f3318a, 0xfe1de0e2, 0x0064bf71, 0x000dd4a7, 0xfffa999d,
+ 0x2a7ad83c, 0xf086425a, 0x0151133e, 0x02e0b08d, 0xfe20a335, 0x00666b68, 0x000cdc74, 0xfffac525,
+ 0x29c6f738, 0xf075c260, 0x01760ad1, 0x02ce25ca, 0xfe2388a1, 0x0068056b, 0x000be89f, 0xfffaf01e,
+ 0x2913123c, 0xf066c606, 0x019a7b27, 0x02bb9310, 0xfe269065, 0x00698d98, 0x000af931, 0xfffb1a84,
+ 0x285f31b7, 0xf05949fb, 0x01be628c, 0x02a8fa2a, 0xfe29b9c1, 0x006b0411, 0x000a0e2f, 0xfffb4453,
+ 0x27ab5e12, 0xf04d4ade, 0x01e1bf58, 0x02965cdb, 0xfe2d03f2, 0x006c68f8, 0x000927a0, 0xfffb6d86,
+ 0x26f79fab, 0xf042c539, 0x02048ff8, 0x0283bce6, 0xfe306e35, 0x006dbc71, 0x00084589, 0xfffb961a,
+ 0x2643feda, 0xf039b587, 0x0226d2e6, 0x02711c05, 0xfe33f7c7, 0x006efea0, 0x000767f0, 0xfffbbe09,
+ 0x259083eb, 0xf032182f, 0x024886ad, 0x025e7bf0, 0xfe379fe3, 0x00702fae, 0x00068ed8, 0xfffbe552,
+ 0x24dd3721, 0xf02be98a, 0x0269a9e9, 0x024bde5a, 0xfe3b65c4, 0x00714fc0, 0x0005ba46, 0xfffc0bef,
+ 0x242a20b3, 0xf02725dc, 0x028a3b44, 0x023944ee, 0xfe3f48a5, 0x00725f02, 0x0004ea3a, 0xfffc31df,
+ 0x237748cf, 0xf023c95d, 0x02aa397b, 0x0226b156, 0xfe4347c0, 0x00735d9c, 0x00041eb9, 0xfffc571e,
+ 0x22c4b795, 0xf021d031, 0x02c9a359, 0x02142533, 0xfe476250, 0x00744bba, 0x000357c2, 0xfffc7ba9,
+ 0x2212751a, 0xf0213671, 0x02e877b9, 0x0201a223, 0xfe4b978e, 0x0075298a, 0x00029558, 0xfffc9f7e,
+ 0x21608968, 0xf021f823, 0x0306b586, 0x01ef29be, 0xfe4fe6b3, 0x0075f739, 0x0001d779, 0xfffcc29a,
+ 0x20aefc79, 0xf0241140, 0x03245bbc, 0x01dcbd96, 0xfe544efb, 0x0076b4f5, 0x00011e26, 0xfffce4fc,
+ 0x1ffdd63b, 0xf0277db1, 0x03416966, 0x01ca5f37, 0xfe58cf9d, 0x007762f0, 0x0000695e, 0xfffd06a1,
+ 0x1f4d1e8e, 0xf02c3953, 0x035ddd9e, 0x01b81028, 0xfe5d67d4, 0x0078015a, 0xffffb91f, 0xfffd2787,
+ 0x1e9cdd43, 0xf0323ff5, 0x0379b790, 0x01a5d1ea, 0xfe6216db, 0x00789065, 0xffff0d66, 0xfffd47ae,
+ 0x1ded1a1d, 0xf0398d56, 0x0394f674, 0x0193a5f9, 0xfe66dbeb, 0x00791043, 0xfffe6631, 0xfffd6713,
};
+// we use 15 bits to interpolate between these samples
+// this cannot change because the mul below rely on it.
+static const int pLerpBits = 15;
+
+static pthread_once_t once_control = PTHREAD_ONCE_INIT;
+static readCoefficientsFn readResampleCoefficients = NULL;
+
+/*static*/ AudioResamplerSinc::Constants AudioResamplerSinc::highQualityConstants;
+/*static*/ AudioResamplerSinc::Constants AudioResamplerSinc::veryHighQualityConstants;
+
+void AudioResamplerSinc::init_routine()
+{
+ // for high quality resampler, the parameters for coefficients are compile-time constants
+ Constants *c = &highQualityConstants;
+ c->coefsBits = RESAMPLE_FIR_LERP_INT_BITS;
+ c->cShift = kNumPhaseBits - c->coefsBits;
+ c->cMask = ((1<< c->coefsBits)-1) << c->cShift;
+ c->pShift = kNumPhaseBits - c->coefsBits - pLerpBits;
+ c->pMask = ((1<< pLerpBits)-1) << c->pShift;
+ c->halfNumCoefs = RESAMPLE_FIR_NUM_COEF;
+
+ // for very high quality resampler, the parameters are load-time constants
+ veryHighQualityConstants = highQualityConstants;
+
+ // Open the dll to get the coefficients for VERY_HIGH_QUALITY
+ void *resampleCoeffLib = dlopen("libaudio-resampler.so", RTLD_NOW);
+ ALOGV("Open libaudio-resampler library = %p", resampleCoeffLib);
+ if (resampleCoeffLib == NULL) {
+ ALOGE("Could not open audio-resampler library: %s", dlerror());
+ return;
+ }
+
+ readResampleFirNumCoeffFn readResampleFirNumCoeff;
+ readResampleFirLerpIntBitsFn readResampleFirLerpIntBits;
+
+ readResampleCoefficients = (readCoefficientsFn)
+ dlsym(resampleCoeffLib, "readResamplerCoefficients");
+ readResampleFirNumCoeff = (readResampleFirNumCoeffFn)
+ dlsym(resampleCoeffLib, "readResampleFirNumCoeff");
+ readResampleFirLerpIntBits = (readResampleFirLerpIntBitsFn)
+ dlsym(resampleCoeffLib, "readResampleFirLerpIntBits");
+
+ if (!readResampleCoefficients || !readResampleFirNumCoeff || !readResampleFirLerpIntBits) {
+ readResampleCoefficients = NULL;
+ dlclose(resampleCoeffLib);
+ resampleCoeffLib = NULL;
+ ALOGE("Could not find symbol: %s", dlerror());
+ return;
+ }
+
+ c = &veryHighQualityConstants;
+ c->coefsBits = readResampleFirLerpIntBits();
+ c->cShift = kNumPhaseBits - c->coefsBits;
+ c->cMask = ((1<<c->coefsBits)-1) << c->cShift;
+ c->pShift = kNumPhaseBits - c->coefsBits - pLerpBits;
+ c->pMask = ((1<<pLerpBits)-1) << c->pShift;
+ // number of zero-crossing on each side
+ c->halfNumCoefs = readResampleFirNumCoeff();
+ ALOGV("coefsBits = %d", c->coefsBits);
+ ALOGV("halfNumCoefs = %d", c->halfNumCoefs);
+ // note that we "leak" resampleCoeffLib until the process exits
+}
+
// ----------------------------------------------------------------------------
static inline
int32_t mulRL(int left, int32_t in, uint32_t vRL)
{
-#if defined(__arm__) && !defined(__thumb__)
+#if USE_INLINE_ASSEMBLY
int32_t out;
if (left) {
asm( "smultb %[out], %[in], %[vRL] \n"
@@ -77,18 +404,15 @@ int32_t mulRL(int left, int32_t in, uint32_t vRL)
}
return out;
#else
- if (left) {
- return int16_t(in>>16) * int16_t(vRL&0xFFFF);
- } else {
- return int16_t(in>>16) * int16_t(vRL>>16);
- }
+ int16_t v = left ? int16_t(vRL) : int16_t(vRL>>16);
+ return int32_t((int64_t(in) * v) >> 16);
#endif
}
static inline
int32_t mulAdd(int16_t in, int32_t v, int32_t a)
{
-#if defined(__arm__) && !defined(__thumb__)
+#if USE_INLINE_ASSEMBLY
int32_t out;
asm( "smlawb %[out], %[v], %[in], %[a] \n"
: [out]"=r"(out)
@@ -96,16 +420,14 @@ int32_t mulAdd(int16_t in, int32_t v, int32_t a)
: );
return out;
#else
- return a + in * (v>>16);
- // improved precision
- // return a + in * (v>>16) + ((in * (v & 0xffff)) >> 16);
+ return a + int32_t((int64_t(v) * in) >> 16);
#endif
}
static inline
int32_t mulAddRL(int left, uint32_t inRL, int32_t v, int32_t a)
{
-#if defined(__arm__) && !defined(__thumb__)
+#if USE_INLINE_ASSEMBLY
int32_t out;
if (left) {
asm( "smlawb %[out], %[v], %[inRL], %[a] \n"
@@ -120,22 +442,17 @@ int32_t mulAddRL(int left, uint32_t inRL, int32_t v, int32_t a)
}
return out;
#else
- if (left) {
- return a + (int16_t(inRL&0xFFFF) * (v>>16));
- //improved precision
- // return a + (int16_t(inRL&0xFFFF) * (v>>16)) + ((int16_t(inRL&0xFFFF) * (v & 0xffff)) >> 16);
- } else {
- return a + (int16_t(inRL>>16) * (v>>16));
- }
+ int16_t s = left ? int16_t(inRL) : int16_t(inRL>>16);
+ return a + int32_t((int64_t(v) * s) >> 16);
#endif
}
// ----------------------------------------------------------------------------
AudioResamplerSinc::AudioResamplerSinc(int bitDepth,
- int inChannelCount, int32_t sampleRate)
- : AudioResampler(bitDepth, inChannelCount, sampleRate),
- mState(0)
+ int inChannelCount, int32_t sampleRate, src_quality quality)
+ : AudioResampler(bitDepth, inChannelCount, sampleRate, quality),
+ mState(0), mImpulse(0), mRingFull(0), mFirCoefs(0)
{
/*
* Layout of the state buffer for 32 tap:
@@ -153,26 +470,50 @@ AudioResamplerSinc::AudioResamplerSinc(int bitDepth,
*
*/
- const size_t numCoefs = 2*halfNumCoefs;
- const size_t stateSize = numCoefs * inChannelCount * 2;
- mState = new int16_t[stateSize];
- memset(mState, 0, sizeof(int16_t)*stateSize);
- mImpulse = mState + (halfNumCoefs-1)*inChannelCount;
- mRingFull = mImpulse + (numCoefs+1)*inChannelCount;
+ mVolumeSIMD[0] = 0;
+ mVolumeSIMD[1] = 0;
+
+ // Load the constants for coefficients
+ int ok = pthread_once(&once_control, init_routine);
+ if (ok != 0) {
+ ALOGE("%s pthread_once failed: %d", __func__, ok);
+ }
+ mConstants = (quality == VERY_HIGH_QUALITY) ?
+ &veryHighQualityConstants : &highQualityConstants;
}
-AudioResamplerSinc::~AudioResamplerSinc()
-{
- delete [] mState;
+
+AudioResamplerSinc::~AudioResamplerSinc() {
+ free(mState);
}
void AudioResamplerSinc::init() {
+ const Constants& c(*mConstants);
+ const size_t numCoefs = 2 * c.halfNumCoefs;
+ const size_t stateSize = numCoefs * mChannelCount * 2;
+ mState = (int16_t*)memalign(32, stateSize*sizeof(int16_t));
+ memset(mState, 0, sizeof(int16_t)*stateSize);
+ mImpulse = mState + (c.halfNumCoefs-1)*mChannelCount;
+ mRingFull = mImpulse + (numCoefs+1)*mChannelCount;
+}
+
+void AudioResamplerSinc::setVolume(int16_t left, int16_t right) {
+ AudioResampler::setVolume(left, right);
+ mVolumeSIMD[0] = int32_t(left)<<16;
+ mVolumeSIMD[1] = int32_t(right)<<16;
}
void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider)
{
- mFirCoefs = (mInSampleRate <= mSampleRate) ? mFirCoefsUp : mFirCoefsDown;
+ // FIXME store current state (up or down sample) and only load the coefs when the state
+ // changes. Or load two pointers one for up and one for down in the init function.
+ // Not critical now since the read functions are fast, but would be important if read was slow.
+ if (mConstants == &veryHighQualityConstants && readResampleCoefficients) {
+ mFirCoefs = readResampleCoefficients( mInSampleRate <= mSampleRate );
+ } else {
+ mFirCoefs = (mInSampleRate <= mSampleRate) ? mFirCoefsUp : mFirCoefsDown;
+ }
// select the appropriate resampler
switch (mChannelCount) {
@@ -190,6 +531,8 @@ template<int CHANNELS>
void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider)
{
+ const Constants& c(*mConstants);
+ const size_t headOffset = c.halfNumCoefs*CHANNELS;
int16_t* impulse = mImpulse;
uint32_t vRL = mVolumeRL;
size_t inputIndex = mInputIndex;
@@ -224,43 +567,31 @@ void AudioResamplerSinc::resample(int32_t* out, size_t outFrameCount,
}
}
}
- int16_t *in = mBuffer.i16;
+ int16_t const * const in = mBuffer.i16;
const size_t frameCount = mBuffer.frameCount;
// Always read-in the first samples from the input buffer
- int16_t* head = impulse + halfNumCoefs*CHANNELS;
- head[0] = in[inputIndex*CHANNELS + 0];
- if (CHANNELS == 2)
- head[1] = in[inputIndex*CHANNELS + 1];
+ int16_t* head = impulse + headOffset;
+ for (size_t i=0 ; i<CHANNELS ; i++) {
+ head[i] = in[inputIndex*CHANNELS + i];
+ }
// handle boundary case
- int32_t l, r;
- while (outputIndex < outputSampleCount) {
- filterCoefficient<CHANNELS>(l, r, phaseFraction, impulse);
- out[outputIndex++] += 2 * mulRL(1, l, vRL);
- out[outputIndex++] += 2 * mulRL(0, r, vRL);
+ while (CC_LIKELY(outputIndex < outputSampleCount)) {
+ filterCoefficient<CHANNELS>(&out[outputIndex], phaseFraction, impulse, vRL);
+ outputIndex += 2;
phaseFraction += phaseIncrement;
- const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits;
- if (phaseIndex == 1) {
- inputIndex++;
- if (inputIndex >= frameCount)
- break; // need a new buffer
- read<CHANNELS>(impulse, phaseFraction, in, inputIndex);
- } else if (phaseIndex == 2) { // maximum value
- inputIndex++;
- if (inputIndex >= frameCount)
- break; // 0 frame available, 2 frames needed
- // read first frame
- read<CHANNELS>(impulse, phaseFraction, in, inputIndex);
+ const size_t phaseIndex = phaseFraction >> kNumPhaseBits;
+ for (size_t i=0 ; i<phaseIndex ; i++) {
inputIndex++;
- if (inputIndex >= frameCount)
- break; // 0 frame available, 1 frame needed
- // read second frame
+ if (inputIndex >= frameCount) {
+ goto done; // need a new buffer
+ }
read<CHANNELS>(impulse, phaseFraction, in, inputIndex);
}
}
-
+done:
// if done with buffer, save samples
if (inputIndex >= frameCount) {
inputIndex -= frameCount;
@@ -286,63 +617,215 @@ void AudioResamplerSinc::read(
int16_t*& impulse, uint32_t& phaseFraction,
const int16_t* in, size_t inputIndex)
{
- const uint32_t phaseIndex = phaseFraction >> kNumPhaseBits;
impulse += CHANNELS;
phaseFraction -= 1LU<<kNumPhaseBits;
- if (impulse >= mRingFull) {
- const size_t stateSize = (halfNumCoefs*2)*CHANNELS;
+
+ const Constants& c(*mConstants);
+ if (CC_UNLIKELY(impulse >= mRingFull)) {
+ const size_t stateSize = (c.halfNumCoefs*2)*CHANNELS;
memcpy(mState, mState+stateSize, sizeof(int16_t)*stateSize);
impulse -= stateSize;
}
- int16_t* head = impulse + halfNumCoefs*CHANNELS;
- head[0] = in[inputIndex*CHANNELS + 0];
- if (CHANNELS == 2)
- head[1] = in[inputIndex*CHANNELS + 1];
+
+ int16_t* head = impulse + c.halfNumCoefs*CHANNELS;
+ for (size_t i=0 ; i<CHANNELS ; i++) {
+ head[i] = in[inputIndex*CHANNELS + i];
+ }
}
template<int CHANNELS>
void AudioResamplerSinc::filterCoefficient(
- int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples)
+ int32_t* out, uint32_t phase, const int16_t *samples, uint32_t vRL)
{
+ // NOTE: be very careful when modifying the code here. register
+ // pressure is very high and a small change might cause the compiler
+ // to generate far less efficient code.
+ // Always sanity check the result with objdump or test-resample.
+
// compute the index of the coefficient on the positive side and
// negative side
- uint32_t indexP = (phase & cMask) >> cShift;
- uint16_t lerpP = (phase & pMask) >> pShift;
- uint32_t indexN = (-phase & cMask) >> cShift;
- uint16_t lerpN = (-phase & pMask) >> pShift;
- if ((indexP == 0) && (lerpP == 0)) {
- indexN = cMask >> cShift;
- lerpN = pMask >> pShift;
- }
+ const Constants& c(*mConstants);
+ const int32_t ONE = c.cMask | c.pMask;
+ uint32_t indexP = ( phase & c.cMask) >> c.cShift;
+ uint32_t lerpP = ( phase & c.pMask) >> c.pShift;
+ uint32_t indexN = ((ONE-phase) & c.cMask) >> c.cShift;
+ uint32_t lerpN = ((ONE-phase) & c.pMask) >> c.pShift;
+
+ const size_t offset = c.halfNumCoefs;
+ indexP *= offset;
+ indexN *= offset;
+
+ int32_t const* coefsP = mFirCoefs + indexP;
+ int32_t const* coefsN = mFirCoefs + indexN;
+ int16_t const* sP = samples;
+ int16_t const* sN = samples + CHANNELS;
- l = 0;
- r = 0;
- const int32_t* coefs = mFirCoefs;
- const int16_t *sP = samples;
- const int16_t *sN = samples+CHANNELS;
- for (unsigned int i=0 ; i<halfNumCoefs/4 ; i++) {
- interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP);
- interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN);
- sP -= CHANNELS; sN += CHANNELS; coefs += 1<<coefsBits;
- interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP);
- interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN);
- sP -= CHANNELS; sN += CHANNELS; coefs += 1<<coefsBits;
- interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP);
- interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN);
- sP -= CHANNELS; sN += CHANNELS; coefs += 1<<coefsBits;
- interpolate<CHANNELS>(l, r, coefs+indexP, lerpP, sP);
- interpolate<CHANNELS>(l, r, coefs+indexN, lerpN, sN);
- sP -= CHANNELS; sN += CHANNELS; coefs += 1<<coefsBits;
+ size_t count = offset;
+
+ if (!USE_NEON) {
+ int32_t l = 0;
+ int32_t r = 0;
+ for (size_t i=0 ; i<count ; i++) {
+ interpolate<CHANNELS>(l, r, coefsP++, offset, lerpP, sP);
+ sP -= CHANNELS;
+ interpolate<CHANNELS>(l, r, coefsN++, offset, lerpN, sN);
+ sN += CHANNELS;
+ }
+ out[0] += 2 * mulRL(1, l, vRL);
+ out[1] += 2 * mulRL(0, r, vRL);
+ } else if (CHANNELS == 1) {
+ int32_t const* coefsP1 = coefsP + offset;
+ int32_t const* coefsN1 = coefsN + offset;
+ sP -= CHANNELS*3;
+ asm (
+ "vmov.32 d2[0], %[lerpP] \n" // load the positive phase
+ "vmov.32 d2[1], %[lerpN] \n" // load the negative phase
+ "veor q0, q0, q0 \n" // result, initialize to 0
+ "vshl.s32 d2, d2, #16 \n" // convert to 32 bits
+
+ "1: \n"
+ "vld1.16 { d4}, [%[sP]] \n" // load 4 16-bits stereo samples
+ "vld1.32 { q8}, [%[coefsP0]:128]! \n" // load 4 32-bits coefs
+ "vld1.32 { q9}, [%[coefsP1]:128]! \n" // load 4 32-bits coefs for interpolation
+ "vld1.16 { d6}, [%[sN]]! \n" // load 4 16-bits stereo samples
+ "vld1.32 {q10}, [%[coefsN0]:128]! \n" // load 4 32-bits coefs
+ "vld1.32 {q11}, [%[coefsN1]:128]! \n" // load 4 32-bits coefs for interpolation
+
+ "vrev64.16 d4, d4 \n" // reverse 2 frames of the positive side
+
+ "vsub.s32 q9, q9, q8 \n" // interpolate (step1) 1st set of coefs
+ "vsub.s32 q11, q11, q10 \n" // interpolate (step1) 2nd set of coets
+ "vshll.s16 q12, d4, #15 \n" // extend samples to 31 bits
+
+ "vqrdmulh.s32 q9, q9, d2[0] \n" // interpolate (step2) 1st set of coefs
+ "vqrdmulh.s32 q11, q11, d2[1] \n" // interpolate (step3) 2nd set of coefs
+ "vshll.s16 q14, d6, #15 \n" // extend samples to 31 bits
+
+ "vadd.s32 q8, q8, q9 \n" // interpolate (step3) 1st set
+ "vadd.s32 q10, q10, q11 \n" // interpolate (step4) 2nd set
+ "subs %[count], %[count], #4 \n" // update loop counter
+
+ "vqrdmulh.s32 q12, q12, q8 \n" // multiply samples by interpolated coef
+ "vqrdmulh.s32 q14, q14, q10 \n" // multiply samples by interpolated coef
+ "sub %[sP], %[sP], #8 \n" // move pointer to next set of samples
+
+ "vadd.s32 q0, q0, q12 \n" // accumulate result
+ "vadd.s32 q0, q0, q14 \n" // accumulate result
+
+ "bne 1b \n" // loop
+
+ "vld1.s32 {d2}, [%[vLR]] \n" // load volumes
+ "vld1.s32 {d3}, %[out] \n" // load the output
+ "vpadd.s32 d0, d0, d1 \n" // add all 4 partial sums
+ "vpadd.s32 d0, d0, d0 \n" // together
+ "vdup.i32 d0, d0[0] \n" // interleave L,R channels
+ "vqrdmulh.s32 d0, d0, d2 \n" // apply volume
+ "vadd.s32 d3, d3, d0 \n" // accumulate result
+ "vst1.s32 {d3}, %[out] \n" // store result
+
+ : [out] "=Uv" (out[0]),
+ [count] "+r" (count),
+ [coefsP0] "+r" (coefsP),
+ [coefsP1] "+r" (coefsP1),
+ [coefsN0] "+r" (coefsN),
+ [coefsN1] "+r" (coefsN1),
+ [sP] "+r" (sP),
+ [sN] "+r" (sN)
+ : [lerpP] "r" (lerpP),
+ [lerpN] "r" (lerpN),
+ [vLR] "r" (mVolumeSIMD)
+ : "cc", "memory",
+ "q0", "q1", "q2", "q3",
+ "q8", "q9", "q10", "q11",
+ "q12", "q14"
+ );
+ } else if (CHANNELS == 2) {
+ int32_t const* coefsP1 = coefsP + offset;
+ int32_t const* coefsN1 = coefsN + offset;
+ sP -= CHANNELS*3;
+ asm (
+ "vmov.32 d2[0], %[lerpP] \n" // load the positive phase
+ "vmov.32 d2[1], %[lerpN] \n" // load the negative phase
+ "veor q0, q0, q0 \n" // result, initialize to 0
+ "veor q4, q4, q4 \n" // result, initialize to 0
+ "vshl.s32 d2, d2, #16 \n" // convert to 32 bits
+
+ "1: \n"
+ "vld2.16 {d4,d5}, [%[sP]] \n" // load 4 16-bits stereo samples
+ "vld1.32 { q8}, [%[coefsP0]:128]! \n" // load 4 32-bits coefs
+ "vld1.32 { q9}, [%[coefsP1]:128]! \n" // load 4 32-bits coefs for interpolation
+ "vld2.16 {d6,d7}, [%[sN]]! \n" // load 4 16-bits stereo samples
+ "vld1.32 {q10}, [%[coefsN0]:128]! \n" // load 4 32-bits coefs
+ "vld1.32 {q11}, [%[coefsN1]:128]! \n" // load 4 32-bits coefs for interpolation
+
+ "vrev64.16 d4, d4 \n" // reverse 2 frames of the positive side
+ "vrev64.16 d5, d5 \n" // reverse 2 frames of the positive side
+
+ "vsub.s32 q9, q9, q8 \n" // interpolate (step1) 1st set of coefs
+ "vsub.s32 q11, q11, q10 \n" // interpolate (step1) 2nd set of coets
+ "vshll.s16 q12, d4, #15 \n" // extend samples to 31 bits
+ "vshll.s16 q13, d5, #15 \n" // extend samples to 31 bits
+
+ "vqrdmulh.s32 q9, q9, d2[0] \n" // interpolate (step2) 1st set of coefs
+ "vqrdmulh.s32 q11, q11, d2[1] \n" // interpolate (step3) 2nd set of coefs
+ "vshll.s16 q14, d6, #15 \n" // extend samples to 31 bits
+ "vshll.s16 q15, d7, #15 \n" // extend samples to 31 bits
+
+ "vadd.s32 q8, q8, q9 \n" // interpolate (step3) 1st set
+ "vadd.s32 q10, q10, q11 \n" // interpolate (step4) 2nd set
+ "subs %[count], %[count], #4 \n" // update loop counter
+
+ "vqrdmulh.s32 q12, q12, q8 \n" // multiply samples by interpolated coef
+ "vqrdmulh.s32 q13, q13, q8 \n" // multiply samples by interpolated coef
+ "vqrdmulh.s32 q14, q14, q10 \n" // multiply samples by interpolated coef
+ "vqrdmulh.s32 q15, q15, q10 \n" // multiply samples by interpolated coef
+ "sub %[sP], %[sP], #16 \n" // move pointer to next set of samples
+
+ "vadd.s32 q0, q0, q12 \n" // accumulate result
+ "vadd.s32 q4, q4, q13 \n" // accumulate result
+ "vadd.s32 q0, q0, q14 \n" // accumulate result
+ "vadd.s32 q4, q4, q15 \n" // accumulate result
+
+ "bne 1b \n" // loop
+
+ "vld1.s32 {d2}, [%[vLR]] \n" // load volumes
+ "vld1.s32 {d3}, %[out] \n" // load the output
+ "vpadd.s32 d0, d0, d1 \n" // add all 4 partial sums from q0
+ "vpadd.s32 d8, d8, d9 \n" // add all 4 partial sums from q4
+ "vpadd.s32 d0, d0, d0 \n" // together
+ "vpadd.s32 d8, d8, d8 \n" // together
+ "vtrn.s32 d0, d8 \n" // interlace L,R channels
+ "vqrdmulh.s32 d0, d0, d2 \n" // apply volume
+ "vadd.s32 d3, d3, d0 \n" // accumulate result
+ "vst1.s32 {d3}, %[out] \n" // store result
+
+ : [out] "=Uv" (out[0]),
+ [count] "+r" (count),
+ [coefsP0] "+r" (coefsP),
+ [coefsP1] "+r" (coefsP1),
+ [coefsN0] "+r" (coefsN),
+ [coefsN1] "+r" (coefsN1),
+ [sP] "+r" (sP),
+ [sN] "+r" (sN)
+ : [lerpP] "r" (lerpP),
+ [lerpN] "r" (lerpN),
+ [vLR] "r" (mVolumeSIMD)
+ : "cc", "memory",
+ "q0", "q1", "q2", "q3", "q4",
+ "q8", "q9", "q10", "q11",
+ "q12", "q13", "q14", "q15"
+ );
}
}
template<int CHANNELS>
void AudioResamplerSinc::interpolate(
int32_t& l, int32_t& r,
- const int32_t* coefs, int16_t lerp, const int16_t* samples)
+ const int32_t* coefs, size_t offset,
+ int32_t lerp, const int16_t* samples)
{
int32_t c0 = coefs[0];
- int32_t c1 = coefs[1];
+ int32_t c1 = coefs[offset];
int32_t sinc = mulAdd(lerp, (c1-c0)<<1, c0);
if (CHANNELS == 2) {
uint32_t rl = *reinterpret_cast<const uint32_t*>(samples);
@@ -352,6 +835,5 @@ void AudioResamplerSinc::interpolate(
r = l = mulAdd(samples[0], sinc, l);
}
}
-
// ----------------------------------------------------------------------------
}; // namespace android
diff --git a/services/audioflinger/AudioResamplerSinc.h b/services/audioflinger/AudioResamplerSinc.h
index f0a07b8d..09c68660 100644
--- a/services/audioflinger/AudioResamplerSinc.h
+++ b/services/audioflinger/AudioResamplerSinc.h
@@ -25,11 +25,17 @@
namespace android {
+
+typedef const int32_t * (*readCoefficientsFn)(bool upDownSample);
+typedef int32_t (*readResampleFirNumCoeffFn)();
+typedef int32_t (*readResampleFirLerpIntBitsFn)();
+
// ----------------------------------------------------------------------------
class AudioResamplerSinc : public AudioResampler {
public:
- AudioResamplerSinc(int bitDepth, int inChannelCount, int32_t sampleRate);
+ AudioResamplerSinc(int bitDepth, int inChannelCount, int32_t sampleRate,
+ src_quality quality = HIGH_QUALITY);
virtual ~AudioResamplerSinc();
@@ -38,18 +44,21 @@ public:
private:
void init();
+ virtual void setVolume(int16_t left, int16_t right);
+
template<int CHANNELS>
void resample(int32_t* out, size_t outFrameCount,
AudioBufferProvider* provider);
template<int CHANNELS>
inline void filterCoefficient(
- int32_t& l, int32_t& r, uint32_t phase, const int16_t *samples);
+ int32_t* out, uint32_t phase, const int16_t *samples, uint32_t vRL);
template<int CHANNELS>
inline void interpolate(
int32_t& l, int32_t& r,
- const int32_t* coefs, int16_t lerp, const int16_t* samples);
+ const int32_t* coefs, size_t offset,
+ int32_t lerp, const int16_t* samples);
template<int CHANNELS>
inline void read(int16_t*& impulse, uint32_t& phaseFraction,
@@ -58,6 +67,7 @@ private:
int16_t *mState;
int16_t *mImpulse;
int16_t *mRingFull;
+ int32_t mVolumeSIMD[2];
const int32_t * mFirCoefs;
static const int32_t mFirCoefsDown[];
@@ -65,21 +75,23 @@ private:
// ----------------------------------------------------------------------------
static const int32_t RESAMPLE_FIR_NUM_COEF = 8;
- static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 4;
-
- // we have 16 coefs samples per zero-crossing
- static const int coefsBits = RESAMPLE_FIR_LERP_INT_BITS; // 4
- static const int cShift = kNumPhaseBits - coefsBits; // 26
- static const uint32_t cMask = ((1<<coefsBits)-1) << cShift; // 0xf<<26 = 3c00 0000
-
- // and we use 15 bits to interpolate between these samples
- // this cannot change because the mul below rely on it.
- static const int pLerpBits = 15;
- static const int pShift = kNumPhaseBits - coefsBits - pLerpBits; // 11
- static const uint32_t pMask = ((1<<pLerpBits)-1) << pShift; // 0x7fff << 11
-
- // number of zero-crossing on each side
- static const unsigned int halfNumCoefs = RESAMPLE_FIR_NUM_COEF;
+ static const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7;
+
+ struct Constants {
+ int coefsBits;
+ int cShift;
+ uint32_t cMask;
+ int pShift;
+ uint32_t pMask;
+ // number of zero-crossing on each side
+ unsigned int halfNumCoefs;
+ };
+
+ static Constants highQualityConstants;
+ static Constants veryHighQualityConstants;
+ const Constants *mConstants; // points to appropriate set of coefficient parameters
+
+ static void init_routine();
};
// ----------------------------------------------------------------------------
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 76521323..3c8a256a 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -222,8 +222,8 @@ bool FastMixer::threadLoop()
mixBuffer = new short[frameCount * 2];
periodNs = (frameCount * 1000000000LL) / sampleRate; // 1.00
underrunNs = (frameCount * 1750000000LL) / sampleRate; // 1.75
- overrunNs = (frameCount * 250000000LL) / sampleRate; // 0.25
- forceNs = (frameCount * 750000000LL) / sampleRate; // 0.75
+ overrunNs = (frameCount * 500000000LL) / sampleRate; // 0.50
+ forceNs = (frameCount * 950000000LL) / sampleRate; // 0.95
warmupNs = (frameCount * 500000000LL) / sampleRate; // 0.50
} else {
periodNs = 0;
@@ -281,8 +281,9 @@ bool FastMixer::threadLoop()
AudioBufferProvider *bufferProvider = fastTrack->mBufferProvider;
ALOG_ASSERT(bufferProvider != NULL && fastTrackNames[i] == -1);
if (mixer != NULL) {
- // calling getTrackName with default channel mask
- name = mixer->getTrackName(AUDIO_CHANNEL_OUT_STEREO);
+ // calling getTrackName with default channel mask and a random invalid
+ // sessionId (no effects here)
+ name = mixer->getTrackName(AUDIO_CHANNEL_OUT_STEREO, -555);
ALOG_ASSERT(name >= 0);
fastTrackNames[i] = name;
mixer->setBufferProvider(name, bufferProvider);
@@ -399,8 +400,13 @@ bool FastMixer::threadLoop()
ftDump->mUnderruns = underruns;
ftDump->mFramesReady = framesReady;
}
+
+ int64_t pts;
+ if (outputSink == NULL || (OK != outputSink->getNextWriteTimestamp(&pts)))
+ pts = AudioBufferProvider::kInvalidPTS;
+
// process() is CPU-bound
- mixer->process(AudioBufferProvider::kInvalidPTS);
+ mixer->process(pts);
mixBufferState = MIXED;
} else if (mixBufferState == MIXED) {
mixBufferState = UNDEFINED;
@@ -448,6 +454,9 @@ bool FastMixer::threadLoop()
if (oldTsValid) {
time_t sec = newTs.tv_sec - oldTs.tv_sec;
long nsec = newTs.tv_nsec - oldTs.tv_nsec;
+ ALOGE_IF(sec < 0 || (sec == 0 && nsec < 0),
+ "clock_gettime(CLOCK_MONOTONIC) failed: was %ld.%09ld but now %ld.%09ld",
+ oldTs.tv_sec, oldTs.tv_nsec, newTs.tv_sec, newTs.tv_nsec);
if (nsec < 0) {
--sec;
nsec += 1000000000;
@@ -607,6 +616,20 @@ FastMixerDumpState::~FastMixerDumpState()
{
}
+// helper function called by qsort()
+static int compare_uint32_t(const void *pa, const void *pb)
+{
+ uint32_t a = *(const uint32_t *)pa;
+ uint32_t b = *(const uint32_t *)pb;
+ if (a < b) {
+ return -1;
+ } else if (a > b) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
void FastMixerDumpState::dump(int fd)
{
if (mCommand == FastMixerState::INITIAL) {
@@ -669,10 +692,18 @@ void FastMixerDumpState::dump(int fd)
CentralTendencyStatistics kHz, loadMHz;
uint32_t previousCpukHz = 0;
#endif
+ // Assuming a normal distribution for cycle times, three standard deviations on either side of
+ // the mean account for 99.73% of the population. So if we take each tail to be 1/1000 of the
+ // sample set, we get 99.8% combined, or close to three standard deviations.
+ static const uint32_t kTailDenominator = 1000;
+ uint32_t *tail = n >= kTailDenominator ? new uint32_t[n] : NULL;
// loop over all the samples
- for (; n > 0; --n) {
+ for (uint32_t j = 0; j < n; ++j) {
size_t i = oldestClosed++ & (kSamplingN - 1);
uint32_t wallNs = mMonotonicNs[i];
+ if (tail != NULL) {
+ tail[j] = wallNs;
+ }
wall.sample(wallNs);
uint32_t sampleLoadNs = mLoadNs[i];
loadNs.sample(sampleLoadNs);
@@ -706,6 +737,23 @@ void FastMixerDumpState::dump(int fd)
" mean=%.1f min=%.1f max=%.1f stddev=%.1f\n",
loadMHz.mean(), loadMHz.minimum(), loadMHz.maximum(), loadMHz.stddev());
#endif
+ if (tail != NULL) {
+ qsort(tail, n, sizeof(uint32_t), compare_uint32_t);
+ // assume same number of tail samples on each side, left and right
+ uint32_t count = n / kTailDenominator;
+ CentralTendencyStatistics left, right;
+ for (uint32_t i = 0; i < count; ++i) {
+ left.sample(tail[i]);
+ right.sample(tail[n - (i + 1)]);
+ }
+ fdprintf(fd, "Distribution of mix cycle times in ms for the tails (> ~3 stddev outliers):\n"
+ " left tail: mean=%.2f min=%.2f max=%.2f stddev=%.2f\n"
+ " right tail: mean=%.2f min=%.2f max=%.2f stddev=%.2f\n",
+ left.mean()*1e-6, left.minimum()*1e-6, left.maximum()*1e-6, left.stddev()*1e-6,
+ right.mean()*1e-6, right.minimum()*1e-6, right.maximum()*1e-6,
+ right.stddev()*1e-6);
+ delete[] tail;
+ }
#endif
// The active track mask and track states are updated non-atomically.
// So if we relied on isActive to decide whether to display,
diff --git a/services/audioflinger/FastMixerState.h b/services/audioflinger/FastMixerState.h
index bc69c9c4..6e53f217 100644
--- a/services/audioflinger/FastMixerState.h
+++ b/services/audioflinger/FastMixerState.h
@@ -18,8 +18,8 @@
#define ANDROID_AUDIO_FAST_MIXER_STATE_H
#include <system/audio.h>
-#include "ExtendedAudioBufferProvider.h"
-#include "NBAIO.h"
+#include <media/ExtendedAudioBufferProvider.h>
+#include <media/nbaio/NBAIO.h>
namespace android {
diff --git a/services/audioflinger/MonoPipe.cpp b/services/audioflinger/MonoPipe.cpp
deleted file mode 100644
index f3fc19a7..00000000
--- a/services/audioflinger/MonoPipe.cpp
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
- * 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 <cutils/atomic.h>
-#include <cutils/compiler.h>
-#include <utils/Log.h>
-#include <utils/Trace.h>
-#include "MonoPipe.h"
-#include "roundup.h"
-
-namespace android {
-
-MonoPipe::MonoPipe(size_t reqFrames, NBAIO_Format format, bool writeCanBlock) :
- NBAIO_Sink(format),
- mReqFrames(reqFrames),
- mMaxFrames(roundup(reqFrames)),
- mBuffer(malloc(mMaxFrames * Format_frameSize(format))),
- mFront(0),
- mRear(0),
- mWriteTsValid(false),
- // mWriteTs
- mSetpoint((reqFrames * 11) / 16),
- mWriteCanBlock(writeCanBlock)
-{
-}
-
-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) {
- 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;
- 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;
-}
-
-} // namespace android
diff --git a/services/audioflinger/audio-resampler/Android.mk b/services/audioflinger/audio-resampler/Android.mk
new file mode 100644
index 00000000..ba37b198
--- /dev/null
+++ b/services/audioflinger/audio-resampler/Android.mk
@@ -0,0 +1,14 @@
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ AudioResamplerCoefficients.cpp
+
+LOCAL_MODULE := libaudio-resampler
+
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libutils liblog
+
+include $(BUILD_SHARED_LIBRARY)
diff --git a/services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp b/services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp
new file mode 100644
index 00000000..d45d6972
--- /dev/null
+++ b/services/audioflinger/audio-resampler/AudioResamplerCoefficients.cpp
@@ -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.
+ */
+
+#define LOG_TAG "ResamplerCoefficients"
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+
+#include "filter_coefficients.h"
+
+const int32_t RESAMPLE_FIR_NUM_COEF = 16;
+const int32_t RESAMPLE_FIR_LERP_INT_BITS = 7;
+
+using namespace android;
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+const int32_t* readResamplerCoefficients(bool upSample) {
+
+ ALOGV("readResamplerCoefficients");
+ if (upSample) {
+ return up_sampler_filter_coefficients;
+ } else {
+ return dn_sampler_filter_coefficients;
+ }
+
+}
+
+int32_t readResampleFirNumCoeff() {
+ return RESAMPLE_FIR_NUM_COEF;
+}
+
+int32_t readResampleFirLerpIntBits() {
+ return RESAMPLE_FIR_LERP_INT_BITS;
+}
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/services/audioflinger/audio-resampler/filter_coefficients.h b/services/audioflinger/audio-resampler/filter_coefficients.h
new file mode 100644
index 00000000..bf70c632
--- /dev/null
+++ b/services/audioflinger/audio-resampler/filter_coefficients.h
@@ -0,0 +1,285 @@
+/*
+ * 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 <stdlib.h>
+
+namespace android {
+
+// cmd-line: fir -l 7 -s 48000 -c 23400 -n 16 -b 9.62
+const int32_t up_sampler_filter_coefficients[] __attribute__ ((aligned (32))) = {
+ 0x7ccccccd, 0x0323eb7f, 0xfd086246, 0x02b2aa5c, 0xfda45e2c, 0x01fa5183, 0xfe694e12, 0x0137e672, 0xff1c87d3, 0x009ce6d8, 0xff9a68b0, 0x003d150d, 0xffde727a, 0x00106595, 0xfff93679, 0x00021fc5,
+ 0x7cc9b757, 0x022ac835, 0xfd7e3a71, 0x026b7da1, 0xfdd2b905, 0x01db7c90, 0xfe7db77c, 0x012aa7bf, 0xff24dc32, 0x0097dfc9, 0xff9d4ae9, 0x003b8742, 0xffdf38e5, 0x00100be5, 0xfff959f5, 0x0002144b,
+ 0x7cc0773c, 0x01354bc1, 0xfdf365e8, 0x0224726d, 0xfe011d2e, 0x01bc908b, 0xfe923a2b, 0x011d528d, 0xff2d426f, 0x0092cbc0, 0xffa035cc, 0x0039f42e, 0xffe00236, 0x000fb0d2, 0xfff97dfa, 0x000208b0,
+ 0x7cb10d52, 0x0043843f, 0xfe67d5a8, 0x01dd92df, 0xfe2f83c1, 0x019d9230, 0xfea6d2e5, 0x010fe901, 0xff35b924, 0x008dab9d, 0xffa328d4, 0x00385c1d, 0xffe0ce46, 0x000f5471, 0xfff9a27f, 0x0001fcf5,
+ 0x7c9b7afd, 0xff557f58, 0xfedb7ae9, 0x0196e8fe, 0xfe5de5e3, 0x017e8635, 0xfebb7e75, 0x01026d40, 0xff3e3eed, 0x0088803e, 0xffa6237a, 0x0036bf58, 0xffe19cec, 0x000ef6d4, 0xfff9c77d, 0x0001f11e,
+ 0x7c7fc22f, 0xfe6b4a44, 0xff4e471d, 0x01507eb8, 0xfe8c3cc3, 0x015f714d, 0xfed039a8, 0x00f4e16f, 0xff46d266, 0x00834a83, 0xffa9253b, 0x00351e2d, 0xffe26e01, 0x000e980f, 0xfff9eceb, 0x0001e52e,
+ 0x7c5de56a, 0xfd84f1c8, 0xffc02bf2, 0x010a5de2, 0xfeba819d, 0x01405821, 0xfee5014c, 0x00e747b0, 0xff4f722b, 0x007e0b4b, 0xffac2d8f, 0x003378e7, 0xffe3415d, 0x000e3834, 0xfffa12c0, 0x0001d927,
+ 0x7c35e7bb, 0xfca28234, 0x00311b54, 0x00c49034, 0xfee8adba, 0x01213f58, 0xfef9d232, 0x00d9a226, 0xff581cd8, 0x0078c375, 0xffaf3bf2, 0x0031cfd1, 0xffe416d8, 0x000dd758, 0xfffa38f5, 0x0001cd0d,
+ 0x7c07ccbe, 0xfbc40766, 0x00a1076e, 0x007f1f4b, 0xff16ba71, 0x01022b90, 0xff0ea931, 0x00cbf2f0, 0xff60d10b, 0x007373de, 0xffb24fde, 0x00302337, 0xffe4ee4b, 0x000d758d, 0xfffa5f81, 0x0001c0e1,
+ 0x7bd3989d, 0xfae98cc5, 0x010fe2ab, 0x003a14a6, 0xff44a128, 0x00e3215e, 0xff238322, 0x00be3c2d, 0xff698d62, 0x006e1d66, 0xffb568ce, 0x002e7363, 0xffe5c78d, 0x000d12e6, 0xfffa865d, 0x0001b4a8,
+ 0x7b99500c, 0xfa131d41, 0x017d9fb8, 0xfff579a3, 0xff725b54, 0x00c42551, 0xff385ce3, 0x00b07ff8, 0xff72507e, 0x0068c0e9, 0xffb8863e, 0x002cc0a2, 0xffe6a277, 0x000caf76, 0xfffaad81, 0x0001a863,
+ 0x7b58f84d, 0xf940c355, 0x01ea3184, 0xffb15783, 0xff9fe27d, 0x00a53bed, 0xff4d3358, 0x00a2c06b, 0xff7b18fe, 0x00635f45, 0xffbba7aa, 0x002b0b3d, 0xffe77ee2, 0x000c4b50, 0xfffad4e4, 0x00019c15,
+ 0x7b12972d, 0xf8728902, 0x02558b43, 0xff6db764, 0xffcd303b, 0x008669ae, 0xff620368, 0x0094ff9b, 0xff83e586, 0x005df954, 0xffbecc8d, 0x00295380, 0xffe85ca7, 0x000be687, 0xfffafc7f, 0x00018fc1,
+ 0x7ac63304, 0xf7a877d4, 0x02bfa06d, 0xff2aa243, 0xfffa3e37, 0x0067b303, 0xff76ca02, 0x00873f9b, 0xff8cb4bb, 0x00588ff1, 0xffc1f465, 0x002799b3, 0xffe93b9e, 0x000b812d, 0xfffb244a, 0x0001836a,
+ 0x7a73d2b5, 0xf6e298db, 0x032864c1, 0xfee820f8, 0x00270631, 0x00491c54, 0xff8b841a, 0x0079827a, 0xff958542, 0x005323f7, 0xffc51eaf, 0x0025de22, 0xffea1ba2, 0x000b1b55, 0xfffb4c3e, 0x00017712,
+ 0x7a1b7daa, 0xf620f4b2, 0x038fcc44, 0xfea63c38, 0x005381fa, 0x002aa9fa, 0xffa02eac, 0x006bca44, 0xff9e55c6, 0x004db63c, 0xffc84ae9, 0x00242115, 0xffeafc8b, 0x000ab510, 0xfffb7452, 0x00016abb,
+ 0x79bd3bd8, 0xf5639376, 0x03f5cb46, 0xfe64fc93, 0x007fab77, 0x000c6043, 0xffb4c6b9, 0x005e1900, 0xffa724f0, 0x00484799, 0xffcb7893, 0x002262d6, 0xffebde33, 0x000a4e72, 0xfffb9c80, 0x00015e68,
+ 0x795915bc, 0xf4aa7cce, 0x045a565c, 0xfe246a72, 0x00ab7ca6, 0xffee4372, 0xffc9494b, 0x005070b0, 0xffaff16f, 0x0042d8e1, 0xffcea72c, 0x0020a3ad, 0xffecc075, 0x0009e78c, 0xfffbc4bf, 0x0001521b,
+ 0x78ef1457, 0xf3f5b7e4, 0x04bd6269, 0xfde48e17, 0x00d6ef99, 0xffd057bb, 0xffddb374, 0x0042d353, 0xffb8b9f3, 0x003d6aea, 0xffd1d635, 0x001ee3e1, 0xffeda32a, 0x00098070, 0xfffbed0a, 0x000145d7,
+ 0x787f4134, 0xf3454b6a, 0x051ee498, 0xfda56f9c, 0x0101fe7a, 0xffb2a145, 0xfff2024e, 0x003542e2, 0xffc17d30, 0x0037fe85, 0xffd50530, 0x001d23b9, 0xffee862e, 0x0009192f, 0xfffc1558, 0x0001399e,
+ 0x7809a65e, 0xf2993d95, 0x057ed264, 0xfd6716f2, 0x012ca389, 0xff952429, 0x000632fa, 0x0027c151, 0xffca39dd, 0x00329483, 0xffd833a0, 0x001b637e, 0xffef695c, 0x0008b1db, 0xfffc3da2, 0x00012d72,
+ 0x778e4e68, 0xf1f19421, 0x05dd218f, 0xfd298be0, 0x0156d920, 0xff77e470, 0x001a42a4, 0x001a508e, 0xffd2eeb3, 0x002d2db0, 0xffdb6109, 0x0019a373, 0xfff04c8f, 0x00084a86, 0xfffc65e2, 0x00012155,
+ 0x770d4466, 0xf14e544f, 0x0639c82d, 0xfcecd602, 0x018099b2, 0xff5ae614, 0x002e2e82, 0x000cf281, 0xffdb9a70, 0x0027cada, 0xffde8cf1, 0x0017e3df, 0xfff12fa3, 0x0007e33f, 0xfffc8e11, 0x0001154a,
+ 0x768693ec, 0xf0af82e4, 0x0694bca0, 0xfcb0fcca, 0x01a9dfcc, 0xff3e2d01, 0x0041f3d2, 0xffffa90e, 0xffe43bd5, 0x00226ccb, 0xffe1b6dd, 0x00162507, 0xfff21275, 0x00077c17, 0xfffcb628, 0x00010952,
+ 0x75fa4911, 0xf015242b, 0x06edf595, 0xfc76077b, 0x01d2a615, 0xff21bd11, 0x00558fdc, 0xfff27611, 0xffecd1a6, 0x001d144a, 0xffe4de56, 0x0014672d, 0xfff2f4e0, 0x00071520, 0xfffcde20, 0x0000fd6f,
+ 0x75687068, 0xef7f3bf5, 0x07456a0e, 0xfc3bfd2e, 0x01fae74e, 0xff059a0e, 0x0068fff3, 0xffe55b60, 0xfff55aae, 0x0017c21c, 0xffe802e6, 0x0012aa95, 0xfff3d6c3, 0x0006ae6a, 0xfffd05f3, 0x0000f1a4,
+ 0x74d11703, 0xeeedcd98, 0x079b1158, 0xfc02e4cc, 0x02229e57, 0xfee9c7af, 0x007c4177, 0xffd85ac9, 0xfffdd5b8, 0x00127704, 0xffeb2416, 0x0010ef82, 0xfff4b7fb, 0x00064804, 0xfffd2d9b, 0x0000e5f3,
+ 0x74344a70, 0xee60dbee, 0x07eee314, 0xfbcac510, 0x0249c629, 0xfece499d, 0x008f51cf, 0xffcb7615, 0x00064197, 0x000d33c3, 0xffee4174, 0x000f3633, 0xfff59866, 0x0005e1fe, 0xfffd5511, 0x0000da5c,
+ 0x739218b8, 0xedd86958, 0x0840d732, 0xfb93a486, 0x027059da, 0xfeb3236b, 0x00a22e71, 0xffbeaf06, 0x000e9d1f, 0x0007f915, 0xfff15a8d, 0x000d7eea, 0xfff677e2, 0x00057c68, 0xfffd7c4f, 0x0000cee3,
+ 0x72ea905a, 0xed5477be, 0x0890e5f7, 0xfb5d898c, 0x029654a0, 0xfe98589b, 0x00b4d4dd, 0xffb20754, 0x0016e72c, 0x0002c7b6, 0xfff46ef1, 0x000bc9e6, 0xfff75650, 0x00051750, 0xfffda350, 0x0000c388,
+ 0x723dc051, 0xecd5088e, 0x08df07f6, 0xfb287a4d, 0x02bbb1cc, 0xfe7dec9c, 0x00c7429f, 0xffa580b1, 0x001f1e9b, 0xfffda05c, 0xfff77e31, 0x000a1765, 0xfff8338e, 0x0004b2c7, 0xfffdca0d, 0x0000b84d,
+ 0x718bb80b, 0xec5a1cbc, 0x092b3617, 0xfaf47cc4, 0x02e06ccf, 0xfe63e2cc, 0x00d97550, 0xff991cc9, 0x00274253, 0xfff883be, 0xfffa87df, 0x000867a5, 0xfff90f7c, 0x00044eda, 0xfffdf080, 0x0000ad34,
+ 0x70d4876b, 0xebe3b4c5, 0x09756994, 0xfac196bb, 0x03048139, 0xfe4a3e70, 0x00eb6a95, 0xff8cdd3c, 0x002f513a, 0xfff3728d, 0xfffd8b92, 0x0006bae1, 0xfff9e9fd, 0x0003eb98, 0xfffe16a6, 0x0000a23f,
+ 0x70183ec5, 0xeb71d0ab, 0x09bd9bfb, 0xfa8fcdca, 0x0327eab8, 0xfe3102bd, 0x00fd2022, 0xff80c3a4, 0x00374a40, 0xffee6d78, 0x000088df, 0x00051157, 0xfffac2f0, 0x0003890e, 0xfffe3c76, 0x0000976e,
+ 0x6f56eee1, 0xeb046ffc, 0x0a03c72b, 0xfa5f2755, 0x034aa51b, 0xfe1832d4, 0x010e93b5, 0xff74d194, 0x003f2c57, 0xffe97529, 0x00037f60, 0x00036b3f, 0xfffb9a38, 0x0003274c, 0xfffe61ee, 0x00008cc4,
+ 0x6e90a8f2, 0xea9b91cc, 0x0a47e559, 0xfa2fa890, 0x036cac52, 0xfdffd1bd, 0x011fc31c, 0xff690894, 0x0046f679, 0xffe48a4a, 0x00066eae, 0x0001c8d2, 0xfffc6fb8, 0x0002c65d, 0xfffe8707, 0x00008241,
+ 0x6dc57e9b, 0xea3734bb, 0x0a89f10c, 0xfa015679, 0x038dfc6c, 0xfde7e26f, 0x0130ac31, 0xff5d6a24, 0x004ea7a3, 0xffdfad7f, 0x00095666, 0x00002a4a, 0xfffd4352, 0x00026650, 0xfffeabbd, 0x000077e8,
+ 0x6cf581e8, 0xe9d756f3, 0x0ac9e521, 0xf9d435dc, 0x03ae919a, 0xfdd067ca, 0x01414cdd, 0xff51f7bb, 0x00563edb, 0xffdadf69, 0x000c3627, 0xfffe8fdc, 0xfffe14eb, 0x00020730, 0xfffed00a, 0x00006db9,
+ 0x6c20c550, 0xe97bf627, 0x0b07bcc6, 0xf9a84b50, 0x03ce682d, 0xfdb96498, 0x0151a317, 0xff46b2c7, 0x005dbb29, 0xffd620a6, 0x000f0d91, 0xfffcf9be, 0xfffee466, 0x0001a90b, 0xfffef3ea, 0x000063b5,
+ 0x6b475bb0, 0xe9250f99, 0x0b437380, 0xf97d9b37, 0x03ed7c9a, 0xfda2db8c, 0x0161ace5, 0xff3b9cad, 0x00651b9c, 0xffd171d1, 0x0011dc47, 0xfffb6825, 0xffffb1aa, 0x00014bed, 0xffff1759, 0x000059dd,
+ 0x6a69584a, 0xe8d2a017, 0x0b7d0525, 0xf95429c0, 0x040bcb77, 0xfd8ccf46, 0x01716859, 0xff30b6c8, 0x006c5f4b, 0xffccd380, 0x0014a1ee, 0xfff9db44, 0x00007c9c, 0x0000efe1, 0xffff3a53, 0x00005033,
+ 0x6986cec4, 0xe884a3fb, 0x0bb46de2, 0xf92bfae4, 0x0429517b, 0xfd77424c, 0x0180d397, 0xff260269, 0x00738551, 0xffc84645, 0x00175e2d, 0xfff8534d, 0x00014521, 0x000094f3, 0xffff5cd2, 0x000046b8,
+ 0x689fd324, 0xe83b1731, 0x0be9aa34, 0xf9051266, 0x04460b81, 0xfd62370e, 0x018fecd1, 0xff1b80da, 0x007a8cd0, 0xffc3cab1, 0x001a10ad, 0xfff6d070, 0x00020b23, 0x00003b2e, 0xffff7ed3, 0x00003d6c,
+ 0x67b479cf, 0xe7f5f531, 0x0c1cb6ef, 0xf8df73d6, 0x0461f688, 0xfd4dafe6, 0x019eb246, 0xff113358, 0x008174ef, 0xffbf614e, 0x001cb91a, 0xfff552de, 0x0002ce87, 0xffffe29d, 0xffffa052, 0x00003450,
+ 0x66c4d787, 0xe7b53908, 0x0c4d913a, 0xf8bb228c, 0x047d0fb1, 0xfd39af17, 0x01ad2249, 0xff071b16, 0x00883cdc, 0xffbb0aa3, 0x001f5723, 0xfff3dac3, 0x00038f37, 0xffff8b4b, 0xffffc14b, 0x00002b66,
+ 0x65d10168, 0xe778dd50, 0x0c7c368d, 0xf89821ac, 0x0497543f, 0xfd2636ca, 0x01bb3b37, 0xfefd3941, 0x008ee3cd, 0xffb6c735, 0x0021ea76, 0xfff2684e, 0x00044d1b, 0xffff3540, 0xffffe1bc, 0x000022ad,
+ 0x64d90ce7, 0xe740dc3c, 0x0ca8a4b7, 0xf8767422, 0x04b0c19a, 0xfd134913, 0x01c8fb81, 0xfef38ef6, 0x009568fc, 0xffb29782, 0x002472c8, 0xfff0fba9, 0x0005081f, 0xfffee088, 0x0000019f, 0x00001a28,
+ 0x63dd0fcd, 0xe70d2f8d, 0x0cd2d9d5, 0xf8561ca7, 0x04c9554e, 0xfd00e7ec, 0x01d661a6, 0xfeea1d4c, 0x009bcbab, 0xffae7c06, 0x0026efcc, 0xffef94fe, 0x0005c02c, 0xfffe8d2c, 0x000020f3, 0x000011d5,
+ 0x62dd2039, 0xe6ddd09f, 0x0cfad45a, 0xf8371dbb, 0x04e10d0a, 0xfcef153a, 0x01e36c34, 0xfee0e54e, 0x00a20b23, 0xffaa7538, 0x0029613a, 0xffee3477, 0x0006752d, 0xfffe3b35, 0x00003fb3, 0x000009b6,
+ 0x61d95497, 0xe6b2b862, 0x0d209309, 0xf81979ab, 0x04f7e6a2, 0xfcddd2c7, 0x01f019cb, 0xfed7e7fd, 0x00a826b2, 0xffa6838c, 0x002bc6cd, 0xffecda3b, 0x0007270f, 0xfffdeaaa, 0x00005ddd, 0x000001cc,
+ 0x60d1c3a6, 0xe68bdf5e, 0x0d4414f9, 0xf7fd328c, 0x050de00d, 0xfccd2246, 0x01fc691b, 0xfecf2650, 0x00ae1dae, 0xffa2a770, 0x002e2040, 0xffeb866f, 0x0007d5bf, 0xfffd9b96, 0x00007b6f, 0xfffffa17,
+ 0x5fc68470, 0xe6693db5, 0x0d65598f, 0xf7e24a3c, 0x0522f766, 0xfcbd0551, 0x020858e2, 0xfec6a130, 0x00b3ef73, 0xff9ee150, 0x00306d52, 0xffea3939, 0x0008812a, 0xfffd4dff, 0x00009865, 0xfffff297,
+ 0x5eb7ae46, 0xe64acb24, 0x0d846084, 0xf7c8c267, 0x05372aee, 0xfcad7d6b, 0x0213e7f0, 0xfebe5980, 0x00b99b65, 0xff9b3192, 0x0032adc4, 0xffe8f2bb, 0x0009293e, 0xfffd01ee, 0x0000b4bd, 0xffffeb4c,
+ 0x5da558c5, 0xe6307f05, 0x0da129df, 0xf7b09c7f, 0x054a7909, 0xfc9e8bfd, 0x021f1526, 0xfeb65015, 0x00bf20ee, 0xff979898, 0x0034e15b, 0xffe7b317, 0x0009cdeb, 0xfffcb769, 0x0000d074, 0xffffe438,
+ 0x5c8f9bcb, 0xe61a504f, 0x0dbbb5f6, 0xf799d9c4, 0x055ce03f, 0xfc903258, 0x0229df75, 0xfeae85bb, 0x00c47f7f, 0xff9416c1, 0x003707dc, 0xffe67a6f, 0x000a6f20, 0xfffc6e78, 0x0000eb89, 0xffffdd5a,
+ 0x5b768f7a, 0xe6083599, 0x0dd40571, 0xf7847b3d, 0x056e5f3d, 0xfc8271b4, 0x023445dd, 0xfea6fb32, 0x00c9b691, 0xff90ac66, 0x00392111, 0xffe548e0, 0x000b0cce, 0xfffc2720, 0x000105f9, 0xffffd6b2,
+ 0x5a5a4c32, 0xe5fa2519, 0x0dea1943, 0xf77081be, 0x057ef4d3, 0xfc754b32, 0x023e4772, 0xfe9fb12e, 0x00cec5a1, 0xff8d59dd, 0x003b2cc5, 0xffe41e88, 0x000ba6e5, 0xfffbe169, 0x00011fc3, 0xffffd041,
+ 0x593aea93, 0xe5f014aa, 0x0dfdf2ae, 0xf75dede5, 0x058e9ff8, 0xfc68bfd7, 0x0247e354, 0xfe98a85b, 0x00d3ac38, 0xff8a1f77, 0x003d2ac6, 0xffe2fb83, 0x000c3d59, 0xfffb9d59, 0x000138e4, 0xffffca06,
+ 0x58188376, 0xe5e9f9ca, 0x0e0f9342, 0xf74cc01c, 0x059d5fc5, 0xfc5cd092, 0x025118b8, 0xfe91e159, 0x00d869e1, 0xff86fd81, 0x003f1ae4, 0xffe1dfec, 0x000cd01b, 0xfffb5af3, 0x0001515c, 0xffffc402,
+ 0x56f32fea, 0xe5e7c99e, 0x0e1efcdb, 0xf73cf898, 0x05ab3377, 0xfc517e38, 0x0259e6e1, 0xfe8b5cba, 0x00dcfe32, 0xff83f443, 0x0040fcf3, 0xffe0cbdc, 0x000d5f1f, 0xfffb1a3f, 0x00016928, 0xffffbe35,
+ 0x55cb0935, 0xe5e978f0, 0x0e2c319d, 0xf72e9758, 0x05b81a70, 0xfc46c987, 0x02624d23, 0xfe851b09, 0x00e168c5, 0xff810401, 0x0042d0c9, 0xffdfbf6b, 0x000dea5a, 0xfffadb40, 0x00018048, 0xffffb89f,
+ 0x54a028d0, 0xe5eefc35, 0x0e3733fc, 0xf7219c2a, 0x05c41435, 0xfc3cb323, 0x026a4ae5, 0xfe7f1cc4, 0x00e5a93c, 0xff7e2cfb, 0x0044963d, 0xffdebaaf, 0x000e71c1, 0xfffa9dfa, 0x000196ba, 0xffffb340,
+ 0x5372a862, 0xe5f8478d, 0x0e4006b2, 0xf71606a6, 0x05cf2070, 0xfc333b97, 0x0271df9c, 0xfe79625e, 0x00e9bf43, 0xff7b6f6c, 0x00464d2b, 0xffddbdbd, 0x000ef549, 0xfffa6273, 0x0001ac7d, 0xffffae17,
+ 0x5242a1c1, 0xe6054ec6, 0x0e46acc4, 0xf70bd632, 0x05d93eee, 0xfc2a6356, 0x02790ace, 0xfe73ec40, 0x00edaa88, 0xff78cb8c, 0x0047f571, 0xffdcc8a9, 0x000f74e9, 0xfffa28ad, 0x0001c191, 0xffffa924,
+ 0x51102eec, 0xe616055a, 0x0e4b297c, 0xf7030a01, 0x05e26f9f, 0xfc222abb, 0x027fcc12, 0xfe6ebac6, 0x00f16ac4, 0xff76418b, 0x00498eed, 0xffdbdb84, 0x000ff098, 0xfff9f0ac, 0x0001d5f4, 0xffffa467,
+ 0x4fdb6a09, 0xe62a5e76, 0x0e4d806f, 0xf6fba113, 0x05eab296, 0xfc1a9208, 0x02862311, 0xfe69ce43, 0x00f4ffb6, 0xff73d199, 0x004b1984, 0xffdaf65e, 0x0010684e, 0xfff9ba73, 0x0001e9a7, 0xffff9fe0,
+ 0x4ea46d66, 0xe6424cf8, 0x0e4db575, 0xf6f59a36, 0x05f20809, 0xfc139968, 0x028c0f83, 0xfe6526fe, 0x00f86924, 0xff717bdf, 0x004c951b, 0xffda1948, 0x0010dc05, 0xfff98604, 0x0001fca8, 0xffff9b8f,
+ 0x4d6b536f, 0xe65dc373, 0x0e4bccac, 0xf6f0f407, 0x05f87053, 0xfc0d40ec, 0x0291912f, 0xfe60c533, 0x00fba6da, 0xff6f4083, 0x004e0199, 0xffd9444e, 0x00114bb4, 0xfff95363, 0x00020ef7, 0xffff9773,
+ 0x4c3036b2, 0xe67cb42f, 0x0e47ca78, 0xf6edacf2, 0x05fdebee, 0xfc07888e, 0x0296a7f0, 0xfe5ca913, 0x00feb8ad, 0xff6d1fa5, 0x004f5ee9, 0xffd8777d, 0x0011b757, 0xfff92290, 0x00022095, 0xffff938c,
+ 0x4af331d9, 0xe69f112f, 0x0e41b37c, 0xf6ebc332, 0x06027b78, 0xfc027031, 0x029b53af, 0xfe58d2c5, 0x01019e78, 0xff6b1961, 0x0050acf7, 0xffd7b2e0, 0x00121ee9, 0xfff8f38e, 0x00023181, 0xffff8fd9,
+ 0x49b45fa8, 0xe6c4cc2e, 0x0e398c9f, 0xf6eb34d4, 0x06061fb2, 0xfbfdf79e, 0x029f9466, 0xfe554265, 0x0104581c, 0xff692dd2, 0x0051ebb4, 0xffd6f67f, 0x00128265, 0xfff8c65d, 0x000241bb, 0xffff8c5a,
+ 0x4873daf7, 0xe6edd6a4, 0x0e2f5b0b, 0xf6ebffb2, 0x0608d97c, 0xfbfa1e88, 0x02a36a1e, 0xfe51f802, 0x0106e583, 0xff675d09, 0x00531b12, 0xffd64264, 0x0012e1c8, 0xfff89b00, 0x00025143, 0xffff890e,
+ 0x4731beb7, 0xe71a21c7, 0x0e232425, 0xf6ee217b, 0x060aa9da, 0xfbf6e48c, 0x02a6d4f0, 0xfe4ef3a4, 0x0109469d, 0xff65a718, 0x00543b04, 0xffd59695, 0x00133d0e, 0xfff87176, 0x0002601b, 0xffff85f5,
+ 0x45ee25e7, 0xe7499e8f, 0x0e14ed93, 0xf6f197ad, 0x060b91ee, 0xfbf4492d, 0x02a9d508, 0xfe4c3546, 0x010b7b61, 0xff640c08, 0x00554b83, 0xffd4f316, 0x00139436, 0xfff849c0, 0x00026e41, 0xffff830e,
+ 0x44a92b96, 0xe77c3db4, 0x0e04bd39, 0xf6f65f9b, 0x060b92ff, 0xfbf24bd9, 0x02ac6a9e, 0xfe49bcd9, 0x010d83cb, 0xff628be3, 0x00564c88, 0xffd457ec, 0x0013e73e, 0xfff823dd, 0x00027bb8, 0xffff805a,
+ 0x4362eadc, 0xe7b1efb4, 0x0df29936, 0xf6fc766a, 0x060aae6e, 0xfbf0ebe7, 0x02ae95fb, 0xfe478a42, 0x010f5fe2, 0xff6126a9, 0x00573e0f, 0xffd3c519, 0x00143626, 0xfff7ffce, 0x0002887f, 0xffff7dd6,
+ 0x421b7edf, 0xe7eaa4d4, 0x0dde87e2, 0xf703d912, 0x0608e5c2, 0xfbf02896, 0x02b05779, 0xfe459d5e, 0x01110faf, 0xff5fdc5b, 0x00582016, 0xffd33a9e, 0x001480ec, 0xfff7dd92, 0x00029497, 0xffff7b82,
+ 0x40d302c5, 0xe8264d21, 0x0dc88fd2, 0xf70c8461, 0x06063a9d, 0xfbf00112, 0x02b1af7f, 0xfe43f5ff, 0x01129344, 0xff5eacf3, 0x0058f29f, 0xffd2b87c, 0x0014c792, 0xfff7bd28, 0x0002a002, 0xffff795f,
+ 0x3f8991bd, 0xe864d874, 0x0db0b7d1, 0xf71674fa, 0x0602aec3, 0xfbf0746e, 0x02b29e84, 0xfe4293ec, 0x0113eabb, 0xff5d9867, 0x0059b5ad, 0xffd23eaf, 0x00150a19, 0xfff79e8f, 0x0002aac0, 0xffff776a,
+ 0x3e3f46f2, 0xe8a63671, 0x0d9706e1, 0xf721a756, 0x05fe4414, 0xfbf181a9, 0x02b3250f, 0xfe4176e2, 0x01151632, 0xff5c9eaa, 0x005a6946, 0xffd1cd37, 0x00154883, 0xfff781c5, 0x0002b4d2, 0xffff75a3,
+ 0x3cf43d8f, 0xe8ea568f, 0x0d7b843b, 0xf72e17c4, 0x05f8fc8f, 0xfbf327ab, 0x02b343b5, 0xfe409e95, 0x011615ce, 0xff5bbfaa, 0x005b0d72, 0xffd1640e, 0x001582d3, 0xfff766c8, 0x0002be3b, 0xffff740a,
+ 0x3ba890b9, 0xe9312813, 0x0d5e3749, 0xf73bc26b, 0x05f2da52, 0xfbf56549, 0x02b2fb1a, 0xfe400aae, 0x0116e9bc, 0xff5afb53, 0x005ba23b, 0xffd1032f, 0x0015b90b, 0xfff74d97, 0x0002c6fa, 0xffff729e,
+ 0x3a5c5b8e, 0xe97a9a17, 0x0d3f27ab, 0xf74aa34c, 0x05ebdf97, 0xfbf83941, 0x02b24bf1, 0xfe3fbacd, 0x0117922f, 0xff5a5189, 0x005c27af, 0xffd0aa93, 0x0015eb2f, 0xfff7362f, 0x0002cf12, 0xffff715d,
+ 0x390fb920, 0xe9c69b8c, 0x0d1e5d32, 0xf75ab63f, 0x05e40eb3, 0xfbfba23f, 0x02b136f9, 0xfe3fae87, 0x01180f5d, 0xff59c230, 0x005c9ddc, 0xffd05a33, 0x00161944, 0xfff7208d, 0x0002d684, 0xffff7047,
+ 0x37c2c474, 0xea151b3a, 0x0cfbdfdd, 0xf76bf6f7, 0x05db6a19, 0xfbff9ed7, 0x02afbd02, 0xfe3fe569, 0x01186187, 0xff594d27, 0x005d04d4, 0xffd01205, 0x0016434f, 0xfff70caf, 0x0002dd53, 0xffff6f5c,
+ 0x36759880, 0xea6607c4, 0x0cd7b7dd, 0xf77e6103, 0x05d1f459, 0xfc042d8e, 0x02addee8, 0xfe405ef6, 0x011888f2, 0xff58f249, 0x005d5cab, 0xffcfd1ff, 0x00166956, 0xfff6fa92, 0x0002e37e, 0xffff6e99,
+ 0x35285026, 0xeab94fa9, 0x0cb1ed8c, 0xf791efcb, 0x05c7b01a, 0xfc094cd2, 0x02ab9d96, 0xfe411aa8, 0x011885e7, 0xff58b16c, 0x005da575, 0xffcf9a15, 0x00168b5e, 0xfff6ea31, 0x0002e90a, 0xffff6dff,
+ 0x33db0631, 0xeb0ee148, 0x0c8a8973, 0xf7a69e96, 0x05bca021, 0xfc0efafe, 0x02a8fa03, 0xfe4217ef, 0x011858b9, 0xff588a65, 0x005ddf4c, 0xffcf6a3b, 0x0016a96f, 0xfff6db89, 0x0002edf6, 0xffff6d8d,
+ 0x328dd556, 0xeb66aae0, 0x0c619444, 0xf7bc6889, 0x05b0c74b, 0xfc15365c, 0x02a5f535, 0xfe435633, 0x011801be, 0xff587d03, 0x005e0a48, 0xffcf4262, 0x0016c390, 0xfff6ce97, 0x0002f246, 0xffff6d40,
+ 0x3140d82e, 0xebc09a94, 0x0c3716da, 0xf7d348a4, 0x05a42890, 0xfc1bfd22, 0x02a2903e, 0xfe44d4d3, 0x01178152, 0xff588913, 0x005e2687, 0xffcf227b, 0x0016d9c9, 0xfff6c356, 0x0002f5fc, 0xffff6d1a,
+ 0x2ff42933, 0xec1c9e6d, 0x0c0b1a37, 0xf7eb39cc, 0x0596c6ff, 0xfc234d75, 0x029ecc3c, 0xfe469325, 0x0116d7d7, 0xff58ae5d, 0x005e3427, 0xffcf0a77, 0x0016ec22, 0xfff6b9c1, 0x0002f919, 0xffff6d17,
+ 0x2ea7e2c0, 0xec7aa45b, 0x0bdda783, 0xf80436c0, 0x0588a5bf, 0xfc2b2567, 0x029aaa5a, 0xfe489077, 0x011605b5, 0xff58eca8, 0x005e3347, 0xffcefa44, 0x0016faa5, 0xfff6b1d5, 0x0002fba0, 0xffff6d38,
+ 0x2d5c1f0e, 0xecda9a39, 0x0baec80a, 0xf81e3a25, 0x0579c812, 0xfc3382fb, 0x02962bd1, 0xfe4acc0e, 0x01150b5a, 0xff5943b4, 0x005e240a, 0xffcef1cf, 0x0017055b, 0xfff6ab8c, 0x0002fd94, 0xffff6d7c,
+ 0x2c10f82d, 0xed3c6dce, 0x0b7e853c, 0xf8393e81, 0x056a314b, 0xfc3c6420, 0x029151e3, 0xfe4d4526, 0x0113e937, 0xff59b340, 0x005e0694, 0xffcef106, 0x00170c4f, 0xfff6a6e2, 0x0002fef6, 0xffff6de2,
+ 0x2ac68807, 0xeda00cd1, 0x0b4ce8a8, 0xf8553e3c, 0x0559e4da, 0xfc45c6b6, 0x028c1de0, 0xfe4ffaf6, 0x01129fc5, 0xff5a3b09, 0x005ddb0b, 0xffcef7d4, 0x00170f8a, 0xfff6a3d0, 0x0002ffc9, 0xffff6e67,
+ 0x297ce85a, 0xee0564e8, 0x0b19fbfe, 0xf87233a4, 0x0548e63f, 0xfc4fa88f, 0x02869122, 0xfe52ecab, 0x01112f81, 0xff5adac6, 0x005da198, 0xffcf0623, 0x00170f18, 0xfff6a252, 0x00030010, 0xffff6f0d,
+ 0x283432b9, 0xee6c63ad, 0x0ae5c90b, 0xf89018eb, 0x05373912, 0xfc5a076a, 0x0280ad0f, 0xfe561969, 0x010f98eb, 0xff5b922d, 0x005d5a62, 0xffcf1bde, 0x00170b04, 0xfff6a262, 0x0002ffcd, 0xffff6fd1,
+ 0x26ec8083, 0xeed4f6b0, 0x0ab059bc, 0xf8aee828, 0x0524e100, 0xfc64e0f9, 0x027a7318, 0xfe598050, 0x010ddc8c, 0xff5c60ee, 0x005d0597, 0xffcf38ec, 0x0017035a, 0xfff6a3f9, 0x0002ff03, 0xffff70b2,
+ 0x25a5eae8, 0xef3f0b78, 0x0a79b814, 0xf8ce9b5d, 0x0511e1c6, 0xfc7032de, 0x0273e4b8, 0xfe5d2075, 0x010bfaee, 0xff5d46bb, 0x005ca363, 0xffcf5d36, 0x0016f828, 0xfff6a713, 0x0002fdb4, 0xffff71b0,
+ 0x24608ae2, 0xefaa8f87, 0x0a41ee32, 0xf8ef2c71, 0x04fe3f39, 0xfc7bfaad, 0x026d0374, 0xfe60f8ea, 0x0109f4a2, 0xff5e433e, 0x005c33f6, 0xffcf88a2, 0x0016e979, 0xfff6aba9, 0x0002fbe4, 0xffff72c9,
+ 0x231c7932, 0xf017705a, 0x0a09064e, 0xf9109535, 0x04e9fd3c, 0xfc8835ed, 0x0265d0dd, 0xfe6508b6, 0x0107ca3c, 0xff5f5621, 0x005bb77f, 0xffcfbb17, 0x0016d75b, 0xfff6b1b4, 0x0002f995, 0xffff73fc,
+ 0x21d9ce63, 0xf0859b6e, 0x09cf0ab4, 0xf932cf65, 0x04d51fc6, 0xfc94e216, 0x025e4e8b, 0xfe694edd, 0x01057c57, 0xff607f0b, 0x005b2e31, 0xffcff478, 0x0016c1dc, 0xfff6b92d, 0x0002f6c9, 0xffff7549,
+ 0x2098a2bf, 0xf0f4fe3d, 0x099405c6, 0xf955d4a7, 0x04bfaadf, 0xfca1fc96, 0x02567e22, 0xfe6dca58, 0x01030b8e, 0xff61bd9f, 0x005a9840, 0xffd034ac, 0x0016a90a, 0xfff6c20f, 0x0002f385, 0xffff76ae,
+ 0x1f590e55, 0xf1658649, 0x095801f8, 0xf9799e8f, 0x04a9a29e, 0xfcaf82ca, 0x024e614c, 0xfe727a1f, 0x01007885, 0xff631180, 0x0059f5e1, 0xffd07b95, 0x00168cf2, 0xfff6cc52, 0x0002efca, 0xffff782a,
+ 0x1e1b28f2, 0xf1d72114, 0x091b09d1, 0xf99e269e, 0x04930b2b, 0xfcbd7206, 0x0245f9bf, 0xfe775d1f, 0x00fdc3e0, 0xff647a4b, 0x0059474a, 0xffd0c915, 0x00166da5, 0xfff6d7f0, 0x0002eb9c, 0xffff79bc,
+ 0x1cdf0a20, 0xf249bc2c, 0x08dd27e6, 0xf9c36642, 0x047be8bc, 0xfccbc793, 0x023d4937, 0xfe7c7243, 0x00faee49, 0xff65f79e, 0x00588cb4, 0xffd11d0f, 0x00164b32, 0xfff6e4e1, 0x0002e6fe, 0xffff7b63,
+ 0x1ba4c923, 0xf2bd4523, 0x089e66dd, 0xf9e956da, 0x04643f95, 0xfcda80ad, 0x0234517a, 0xfe81b86d, 0x00f7f86e, 0xff678912, 0x0057c658, 0xffd17764, 0x001625a7, 0xfff6f31d, 0x0002e1f3, 0xffff7d1f,
+ 0x1a6c7cf9, 0xf331a99b, 0x085ed167, 0xfa0ff1b6, 0x044c1409, 0xfce99a86, 0x022b1455, 0xfe872e7c, 0x00f4e2ff, 0xff692e3f, 0x0056f471, 0xffd1d7f5, 0x0015fd15, 0xfff7029f, 0x0002dc7d, 0xffff7eed,
+ 0x19363c54, 0xf3a6d741, 0x081e7241, 0xfa373017, 0x04336a75, 0xfcf91246, 0x0221939d, 0xfe8cd349, 0x00f1aeb2, 0xff6ae6ba, 0x0056173b, 0xffd23ea1, 0x0015d18b, 0xfff7135d, 0x0002d6a0, 0xffff80cd,
+ 0x18021d9d, 0xf41cbbd3, 0x07dd5430, 0xfa5f0b30, 0x041a4744, 0xfd08e50c, 0x0217d12d, 0xfe92a5a7, 0x00ee5c3e, 0xff6cb218, 0x00552ef3, 0xffd2ab47, 0x0015a31b, 0xfff72551, 0x0002d060, 0xffff82bf,
+ 0x16d036eb, 0xf493451f, 0x079b8203, 0xfa877c29, 0x0400aeec, 0xfd190fed, 0x020dcee8, 0xfe98a466, 0x00eaec5e, 0xff6e8fe9, 0x00543bd8, 0xffd31dc7, 0x001571d5, 0xfff73873, 0x0002c9be, 0xffff84c0,
+ 0x15a09e09, 0xf50a610a, 0x0759068f, 0xfab07c1d, 0x03e6a5ee, 0xfd298ff6, 0x02038eb7, 0xfe9ece4f, 0x00e75fd1, 0xff707fbd, 0x00533e29, 0xffd395fd, 0x00153dca, 0xfff74cba, 0x0002c2be, 0xffff86d0,
+ 0x1473686d, 0xf581fd8b, 0x0715ecae, 0xfada0420, 0x03cc30d4, 0xfd3a622b, 0x01f9128a, 0xfea52227, 0x00e3b758, 0xff728121, 0x00523626, 0xffd413c9, 0x0015070b, 0xfff76220, 0x0002bb64, 0xffff88ee,
+ 0x1348ab3a, 0xf5fa08b5, 0x06d23f3d, 0xfb040d3b, 0x03b15431, 0xfd4b8389, 0x01ee5c55, 0xfeab9eb2, 0x00dff3b7, 0xff7493a2, 0x00512412, 0xffd49705, 0x0014cdab, 0xfff7789c, 0x0002b3b3, 0xffff8b19,
+ 0x12207b3e, 0xf67270b1, 0x068e091c, 0xfb2e906f, 0x039614a1, 0xfd5cf105, 0x01e36e14, 0xfeb242ac, 0x00dc15b4, 0xff76b6ca, 0x0050082f, 0xffd51f90, 0x001491b9, 0xfff79026, 0x0002abad, 0xffff8d50,
+ 0x10faecee, 0xf6eb23c6, 0x0649552a, 0xfb5986b6, 0x037a76c7, 0xfd6ea790, 0x01d849c7, 0xfeb90cce, 0x00d81e1a, 0xff78ea20, 0x004ee2c1, 0xffd5ad44, 0x00145349, 0xfff7a8b6, 0x0002a357, 0xffff8f92,
+ 0x0fd81464, 0xf7641059, 0x06042e45, 0xfb84e906, 0x035e7f4e, 0xfd80a411, 0x01ccf173, 0xfebffbd0, 0x00d40db3, 0xff7b2d2d, 0x004db40c, 0xffd63ffe, 0x0014126c, 0xfff7c245, 0x00029ab2, 0xffff91de,
+ 0x0eb80562, 0xf7dd24ef, 0x05be9f49, 0xfbb0b04e, 0x034232e6, 0xfd92e36c, 0x01c16720, 0xfec70e64, 0x00cfe54f, 0xff7d7f76, 0x004c7c55, 0xffd6d798, 0x0013cf36, 0xfff7dcc8, 0x000291c3, 0xffff9434,
+ 0x0d9ad348, 0xf856502d, 0x0578b30e, 0xfbdcd57a, 0x03259644, 0xfda5627e, 0x01b5acdd, 0xfece433a, 0x00cba5bc, 0xff7fe07f, 0x004b3be3, 0xffd773ed, 0x001389b7, 0xfff7f83a, 0x0002888c, 0xffff9691,
+ 0x0c80911b, 0xf8cf80de, 0x05327467, 0xfc095174, 0x0308ae24, 0xfdb81e22, 0x01a9c4bc, 0xfed598fe, 0x00c74fce, 0xff824fca, 0x0049f2fc, 0xffd814d7, 0x00134204, 0xfff81490, 0x00027f11, 0xffff98f5,
+ 0x0b69517e, 0xf948a5f0, 0x04ebee1c, 0xfc361d25, 0x02eb7f44, 0xfdcb132d, 0x019db0d0, 0xfedd0e5c, 0x00c2e457, 0xff84ccdb, 0x0048a1e7, 0xffd8ba31, 0x0012f82e, 0xfff831c3, 0x00027555, 0xffff9b60,
+ 0x0a5526b0, 0xf9c1ae7b, 0x04a52af2, 0xfc633173, 0x02ce0e67, 0xfdde3e6f, 0x01917334, 0xfee4a1fa, 0x00be642f, 0xff875731, 0x004748ed, 0xffd963d4, 0x0012ac48, 0xfff84fcb, 0x00026b5b, 0xffff9dd0,
+ 0x0944228e, 0xfa3a89be, 0x045e359f, 0xfc908746, 0x02b0604f, 0xfdf19cb9, 0x01850e00, 0xfeec527e, 0x00b9d02b, 0xff89ee4d, 0x0045e856, 0xffda1199, 0x00125e66, 0xfff86e9e, 0x00026126, 0xffffa045,
+ 0x08365690, 0xfab32723, 0x041718d2, 0xfcbe1789, 0x029279c4, 0xfe052ad4, 0x01788354, 0xfef41e8c, 0x00b52925, 0xff8c91ad, 0x0044806c, 0xffdac35a, 0x00120e9b, 0xfff88e35, 0x000256b9, 0xffffa2be,
+ 0x072bd3c5, 0xfb2b7641, 0x03cfdf29, 0xfcebdb26, 0x02745f8c, 0xfe18e58c, 0x016bd54f, 0xfefc04c6, 0x00b06ff7, 0xff8f40d0, 0x00431177, 0xffdb78ef, 0x0011bcf9, 0xfff8ae88, 0x00024c18, 0xffffa539,
+ 0x0624aad6, 0xfba366df, 0x03889336, 0xfd19cb0e, 0x02561670, 0xfe2cc9a7, 0x015f0612, 0xff0403cc, 0x00aba57c, 0xff91fb31, 0x00419bc2, 0xffdc3231, 0x00116994, 0xfff8cf8d, 0x00024146, 0xffffa7b7,
+ 0x0520ec00, 0xfc1ae8f2, 0x03413f7b, 0xfd47e035, 0x0237a337, 0xfe40d3ed, 0x015217c0, 0xff0c1a3c, 0x00a6ca90, 0xff94c04f, 0x00401f98, 0xffdceef9, 0x00111480, 0xfff8f13c, 0x00023645, 0xffffaa35,
+ 0x0420a716, 0xfc91eca1, 0x02f9ee68, 0xfd761395, 0x02190aa6, 0xfe550124, 0x01450c7f, 0xff1446b5, 0x00a1e00f, 0xff978fa6, 0x003e9d42, 0xffddaf1e, 0x0010bdcf, 0xfff9138e, 0x00022b19, 0xffffacb4,
+ 0x0323eb7f, 0xfd086246, 0x02b2aa5c, 0xfda45e2c, 0x01fa5183, 0xfe694e12, 0x0137e672, 0xff1c87d3, 0x009ce6d8, 0xff9a68b0, 0x003d150d, 0xffde727a, 0x00106595, 0xfff93679, 0x00021fc5, 0xffffaf33,
+};
+
+// cmd-line: fir -l 7 -s 44100 -c 19876 -n 16 -b 9.62
+const int32_t dn_sampler_filter_coefficients[] __attribute__ ((aligned (32))) = {
+ 0x736144b5, 0x0c333a22, 0xf4fca390, 0x09424904, 0xf8c92a41, 0x052ac04c, 0xfca4fc64, 0x01ed8cc7, 0xff119cc0, 0x0053ba6e, 0xfff9a80d, 0xffeaeaab, 0x001690d9, 0xfff11dcd, 0x000715d9, 0xfffdb4b9,
+ 0x735ed3aa, 0x0b433de8, 0xf560f0f3, 0x091282c4, 0xf8dd5ccf, 0x0525cb66, 0xfca23e3d, 0x01f33960, 0xff0bc9c2, 0x00586127, 0xfff68603, 0xffecbad5, 0x0015ab8b, 0xfff17c10, 0x0006f71a, 0xfffdbc2f,
+ 0x735780bb, 0x0a55a98f, 0xf5c5b2a1, 0x08e1ea27, 0xf8f25767, 0x0520366d, 0xfc9ff262, 0x01f89c98, 0xff0620a4, 0x005cf349, 0xfff36c0d, 0xffee8913, 0x0014c5dc, 0xfff1db1a, 0x0006d7d7, 0xfffdc3db,
+ 0x734b4c77, 0x096a8a51, 0xf62adb7c, 0x08b086aa, 0xf9081629, 0x051a030f, 0xfc9e186a, 0x01fdb637, 0xff00a1d8, 0x00617065, 0xfff05a84, 0xfff0552d, 0x0013dfed, 0xfff23ada, 0x0006b817, 0xfffdcbba,
+ 0x733a37d2, 0x0881ed1f, 0xf6905e79, 0x087e5fd7, 0xf91e9521, 0x05133308, 0xfc9cafe0, 0x0202860e, 0xfefb4dc7, 0x0065d80c, 0xffed51bc, 0xfff21ee8, 0x0012f9de, 0xfff29b40, 0x000697e0, 0xfffdd3ca,
+ 0x7324441e, 0x079bdea7, 0xf6f62e9d, 0x084b7d43, 0xf935d048, 0x050bc828, 0xfc9bb83e, 0x02070bf9, 0xfef624d8, 0x006a29d6, 0xffea520a, 0xfff3e60f, 0x001213d0, 0xfff2fc3d, 0x00067739, 0xfffddc07,
+ 0x7309730f, 0x06b86b52, 0xf75c3eff, 0x0817e68c, 0xf94dc388, 0x0503c44d, 0xfc9b30f3, 0x020b47dd, 0xfef12766, 0x006e655c, 0xffe75bbe, 0xfff5aa69, 0x00112de1, 0xfff35dc1, 0x00065629, 0xfffde470,
+ 0x72e9c6b8, 0x05d79f40, 0xf7c282cb, 0x07e3a35a, 0xf9666ab7, 0x04fb2969, 0xfc9b195f, 0x020f39ab, 0xfeec55cc, 0x00728a3d, 0xffe46f2a, 0xfff76bc2, 0x00104831, 0xfff3bfbc, 0x000634b6, 0xfffded03,
+ 0x72c5418e, 0x04f98649, 0xf828ed43, 0x07aebb5d, 0xf97fc19e, 0x04f1f97c, 0xfc9b70d6, 0x0212e15c, 0xfee7b059, 0x0076981a, 0xffe18c9a, 0xfff929e3, 0x000f62de, 0xfff4221f, 0x000612e8, 0xfffdf5bc,
+ 0x729be665, 0x041e2bfe, 0xf88f71bf, 0x0779364a, 0xf999c3f4, 0x04e83697, 0xfc9c369c, 0x02163ef1, 0xfee33759, 0x007a8e98, 0xffdeb45b, 0xfffae49b, 0x000e7e08, 0xfff484db, 0x0005f0c4, 0xfffdfe9b,
+ 0x726db871, 0x03459ba4, 0xf8f603ae, 0x07431bdf, 0xf9b46d64, 0x04dde2da, 0xfc9d69eb, 0x02195278, 0xfedeeb11, 0x007e6d61, 0xffdbe6b6, 0xfffc9bb4, 0x000d99cc, 0xfff4e7e1, 0x0005ce51, 0xfffe079b,
+ 0x723abb44, 0x026fe039, 0xf95c9699, 0x070c73dd, 0xf9cfb988, 0x04d30074, 0xfc9f09ee, 0x021c1c06, 0xfedacbbf, 0x00823422, 0xffd923f4, 0xfffe4efd, 0x000cb647, 0xfff54b20, 0x0005ab95, 0xfffe10bc,
+ 0x7202f2d3, 0x019d046d, 0xf9c31e22, 0x06d5460b, 0xf9eba3ef, 0x04c791a4, 0xfca115c5, 0x021e9bbb, 0xfed6d99c, 0x0085e28b, 0xffd66c59, 0xfffffe46, 0x000bd397, 0xfff5ae8c, 0x00058898, 0xfffe19fa,
+ 0x71c6636d, 0x00cd12a4, 0xfa298e07, 0x069d9a31, 0xfa082817, 0x04bb98b5, 0xfca38c83, 0x0220d1bf, 0xfed314da, 0x00897851, 0xffd3c02a, 0x0001a95d, 0x000af1d9, 0xfff61214, 0x0005655e, 0xfffe2354,
+ 0x718511c2, 0x000014f8, 0xfa8fda21, 0x0665781b, 0xfa254176, 0x04af1804, 0xfca66d2e, 0x0222be45, 0xfecf7da3, 0x008cf52d, 0xffd11fa9, 0x00035015, 0x000a1129, 0xfff675ab, 0x000541f0, 0xfffe2cc8,
+ 0x713f02e0, 0xff361534, 0xfaf5f669, 0x062ce795, 0xfa42eb75, 0x04a211f8, 0xfca9b6bf, 0x02246187, 0xfecc141d, 0x009058da, 0xffce8b13, 0x0004f23e, 0x000931a3, 0xfff6d942, 0x00051e52, 0xfffe3652,
+ 0x70f43c32, 0xfe6f1cd7, 0xfb5bd6f4, 0x05f3f06b, 0xfa61216f, 0x04948906, 0xfcad6827, 0x0225bbca, 0xfec8d867, 0x0093a31a, 0xffcc02a8, 0x00068fad, 0x00085362, 0xfff73ccb, 0x0004fa8b, 0xfffe3ff2,
+ 0x70a4c37f, 0xfdab350f, 0xfbc16ff6, 0x05ba9a6b, 0xfa7fdeba, 0x04867fb3, 0xfcb18047, 0x0226cd5b, 0xfec5ca9a, 0x0096d3af, 0xffc986a1, 0x00082835, 0x00077681, 0xfff7a037, 0x0004d6a1, 0xfffe49a4,
+ 0x70509eec, 0xfcea66be, 0xfc26b5c5, 0x0580ed5f, 0xfa9f1e9e, 0x0477f88d, 0xfcb5fdf7, 0x02279691, 0xfec2eaca, 0x0099ea62, 0xffc71738, 0x0009bbab, 0x00069b1b, 0xfff8037a, 0x0004b29a, 0xfffe5367,
+ 0x6ff7d4f8, 0xfc2cba75, 0xfc8b9cda, 0x0546f10f, 0xfabedc5a, 0x0468f62e, 0xfcbae002, 0x022817ca, 0xfec03901, 0x009ce6fe, 0xffc4b4a4, 0x000b49e6, 0x0005c149, 0xfff86686, 0x00048e7c, 0xfffe5d38,
+ 0x6f9a6c7f, 0xfb723876, 0xfcf019cd, 0x050cad3f, 0xfadf1328, 0x04597b40, 0xfcc0252b, 0x0228516f, 0xfebdb547, 0x009fc954, 0xffc25f1a, 0x000cd2bd, 0x0004e926, 0xfff8c94c, 0x00046a4c, 0xfffe6716,
+ 0x6f386cb6, 0xfabae8b2, 0xfd54215c, 0x04d229b1, 0xfaffbe36, 0x04498a72, 0xfcc5cc26, 0x022843f0, 0xfebb5f9b, 0x00a29136, 0xffc016cb, 0x000e5609, 0x000412c9, 0xfff92bc0, 0x00044612, 0xfffe70ff,
+ 0x6ed1dd2e, 0xfa06d2ca, 0xfdb7a869, 0x04976e20, 0xfb20d8ad, 0x04392684, 0xfccbd3a0, 0x0227efc6, 0xfeb937f9, 0x00a53e7b, 0xffbddbe8, 0x000fd3a3, 0x00033e4c, 0xfff98dd6, 0x000421d2, 0xfffe7aef,
+ 0x6e66c5ce, 0xf955fe0c, 0xfe1aa3fc, 0x045c8240, 0xfb425db0, 0x0428523d, 0xfcd23a3a, 0x02275572, 0xfeb73e54, 0x00a7d0ff, 0xffbbae9f, 0x00114b67, 0x00026bc6, 0xfff9ef80, 0x0003fd92, 0xfffe84e7,
+ 0x6df72ed9, 0xf8a87178, 0xfe7d0942, 0x04216dc0, 0xfb64485b, 0x0417106e, 0xfcd8fe8b, 0x0226757e, 0xfeb5729b, 0x00aa48a0, 0xffb98f1c, 0x0012bd30, 0x00019b4e, 0xfffa50b1, 0x0003d957, 0xfffe8ee3,
+ 0x6d8320e6, 0xf7fe33ba, 0xfedecd90, 0x03e63846, 0xfb8693c6, 0x040563f4, 0xfce01f21, 0x0225507c, 0xfeb3d4b7, 0x00aca542, 0xffb77d88, 0x001428db, 0x0000ccfc, 0xfffab15e, 0x0003b527, 0xfffe98e2,
+ 0x6d0aa4e6, 0xf7574b2b, 0xff3fe663, 0x03aae970, 0xfba93b01, 0x03f34fb2, 0xfce79a7f, 0x0223e706, 0xfeb26489, 0x00aee6ca, 0xffb57a0b, 0x00158e47, 0x000000e6, 0xfffb117a, 0x00039108, 0xfffea2e1,
+ 0x6c8dc41f, 0xf6b3bdd3, 0xffa04963, 0x036f88d2, 0xfbcc391d, 0x03e0d697, 0xfcef6f20, 0x022239bc, 0xfeb121ee, 0x00b10d23, 0xffb384ca, 0x0016ed53, 0xffff3721, 0xfffb70fa, 0x00036cfe, 0xfffeacdf,
+ 0x6c0c882a, 0xf6139169, 0xffffec5f, 0x03341df4, 0xfbef8924, 0x03cdfb99, 0xfcf79b75, 0x02204949, 0xfeb00cbf, 0x00b3183c, 0xffb19de7, 0x001845e0, 0xfffe6fc3, 0xfffbcfd2, 0x00034910, 0xfffeb6db,
+ 0x6b86faf8, 0xf576cb4e, 0x005ec552, 0x02f8b055, 0xfc13261f, 0x03bac1b4, 0xfd001de8, 0x021e165d, 0xfeaf24cc, 0x00b50805, 0xffafc584, 0x001997d0, 0xfffdaadf, 0xfffc2df6, 0x00032541, 0xfffec0d2,
+ 0x6afd26cb, 0xf4dd7092, 0x00bcca63, 0x02bd4768, 0xfc370b14, 0x03a72bf0, 0xfd08f4d6, 0x021ba1b2, 0xfeae69e1, 0x00b6dc75, 0xffadfbbe, 0x001ae306, 0xfffce88b, 0xfffc8b5c, 0x00030196, 0xfffecac3,
+ 0x6a6f1638, 0xf44785f1, 0x0119f1e4, 0x0281ea90, 0xfc5b3309, 0x03933d58, 0xfd121e99, 0x0218ec06, 0xfeaddbc4, 0x00b89584, 0xffac40b3, 0x001c2765, 0xfffc28d9, 0xfffce7f8, 0x0002de16, 0xfffed4ab,
+ 0x69dcd425, 0xf3b50fd6, 0x01763256, 0x0246a125, 0xfc7f9902, 0x037ef900, 0xfd1b9980, 0x0215f621, 0xfead7a37, 0x00ba3330, 0xffaa947c, 0x001d64d5, 0xfffb6bdd, 0xfffd43c1, 0x0002bac4, 0xfffede8a,
+ 0x69466bc8, 0xf3261255, 0x01d18265, 0x020b726f, 0xfca43803, 0x036a6201, 0xfd2563d3, 0x0212c0d2, 0xfead44f4, 0x00bbb579, 0xffa8f730, 0x001e9b3a, 0xfffab1a8, 0xfffd9eab, 0x000297a5, 0xfffee85e,
+ 0x68abe8a8, 0xf29a9133, 0x022bd8ee, 0x01d065a8, 0xfcc90b12, 0x03557b7a, 0xfd2f7bd1, 0x020f4cec, 0xfead3bb2, 0x00bd1c63, 0xffa768e6, 0x001fca7d, 0xfff9fa4d, 0xfffdf8ae, 0x000274be, 0xfffef225,
+ 0x680d5698, 0xf2128fde, 0x02852cfc, 0x019581f9, 0xfcee0d33, 0x03404890, 0xfd39dfb4, 0x020b9b4c, 0xfead5e22, 0x00be67f6, 0xffa5e9b1, 0x0020f288, 0xfff945dc, 0xfffe51be, 0x00025214, 0xfffefbde,
+ 0x676ac1bb, 0xf18e1174, 0x02dd75ca, 0x015ace79, 0xfd133970, 0x032acc6d, 0xfd448dae, 0x0207acd4, 0xfeadabef, 0x00bf983d, 0xffa479a2, 0x00221344, 0xfff89465, 0xfffea9d2, 0x00022fa9, 0xffff0587,
+ 0x66c4367d, 0xf10d18bd, 0x0334aac4, 0x0120522f, 0xfd388ad1, 0x03150a3f, 0xfd4f83eb, 0x0203826c, 0xfeae24c1, 0x00c0ad48, 0xffa318c7, 0x00232c9d, 0xfff7e5f9, 0xffff00e1, 0x00020d84, 0xffff0f1f,
+ 0x6619c197, 0xf08fa82f, 0x038ac385, 0x00e6140f, 0xfd5dfc63, 0x02ff0538, 0xfd5ac08e, 0x01ff1d04, 0xfeaec838, 0x00c1a728, 0xffa1c72f, 0x00243e7f, 0xfff73aa7, 0xffff56e3, 0x0001eba8, 0xffff18a4,
+ 0x656b700a, 0xf015c1ee, 0x03dfb7dd, 0x00ac1af9, 0xfd838938, 0x02e8c08e, 0xfd6641b8, 0x01fa7d91, 0xfeaf95f2, 0x00c285f4, 0xffa084e3, 0x002548d9, 0xfff6927e, 0xffffabcd, 0x0001ca18, 0xffff2215,
+ 0x64b94f22, 0xef9f67cb, 0x04337fcb, 0x00726dbb, 0xfda92c63, 0x02d23f7a, 0xfd720581, 0x01f5a50d, 0xfeb08d86, 0x00c349c4, 0xff9f51eb, 0x00264b9a, 0xfff5ed8b, 0xffffff99, 0x0001a8da, 0xffff2b70,
+ 0x64036c6f, 0xef2c9b43, 0x04861383, 0x0039130c, 0xfdcee0ff, 0x02bb8537, 0xfd7e09fc, 0x01f0947a, 0xfeb1ae87, 0x00c3f2b6, 0xff9e2e50, 0x002746b2, 0xfff54bdc, 0x0000523d, 0x000187f0, 0xffff34b6,
+ 0x6349d5c9, 0xeebd5d81, 0x04d76b6b, 0x00001191, 0xfdf4a22a, 0x02a49505, 0xfd8a4d37, 0x01eb4cde, 0xfeb2f884, 0x00c480e9, 0xff9d1a14, 0x00283a12, 0xfff4ad7e, 0x0000a3b3, 0x0001675f, 0xffff3de3,
+ 0x628c994c, 0xee51af5f, 0x0527801d, 0xffc76fd5, 0xfe1a6b08, 0x028d7223, 0xfd96cd3d, 0x01e5cf44, 0xfeb46b07, 0x00c4f480, 0xff9c1539, 0x002925ae, 0xfff4127d, 0x0000f3f1, 0x00014729, 0xffff46f7,
+ 0x61cbc559, 0xede99165, 0x05764a68, 0xff8f344f, 0xfe4036c5, 0x02761fd3, 0xfda3880f, 0x01e01cbe, 0xfeb60596, 0x00c54da2, 0xff9b1fc1, 0x002a0979, 0xfff37ae4, 0x000142f1, 0x00012754, 0xffff4ff1,
+ 0x61076890, 0xed8503c7, 0x05c3c34e, 0xff576560, 0xfe660094, 0x025ea157, 0xfdb07bb0, 0x01da3661, 0xfeb7c7b0, 0x00c58c79, 0xff9a39a9, 0x002ae568, 0xfff2e6bf, 0x000190ac, 0x000107e1, 0xffff58d0,
+ 0x603f91d5, 0xed24066b, 0x060fe408, 0xff20094d, 0xfe8bc3ad, 0x0246f9f3, 0xfdbda61a, 0x01d41d4a, 0xfeb9b0d3, 0x00c5b132, 0xff9962ec, 0x002bb971, 0xfff25619, 0x0001dd1b, 0x0000e8d4, 0xffff6192,
+ 0x5f745049, 0xecc698e6, 0x065aa604, 0xfee92646, 0xfeb17b53, 0x022f2cea, 0xfdcb0546, 0x01cdd297, 0xfebbc078, 0x00c5bbfc, 0xff989b85, 0x002c858d, 0xfff1c8fa, 0x00022837, 0x0000ca30, 0xffff6a38,
+ 0x5ea5b34c, 0xec6cba79, 0x06a402e4, 0xfeb2c261, 0xfed722d0, 0x02173d81, 0xfdd89727, 0x01c7576d, 0xfebdf613, 0x00c5ad0a, 0xff97e36c, 0x002d49b4, 0xfff13f6c, 0x000271fa, 0x0000abf8, 0xffff72be,
+ 0x5dd3ca7a, 0xec166a19, 0x06ebf483, 0xfe7ce399, 0xfefcb57a, 0x01ff2ef9, 0xfde659af, 0x01c0acf5, 0xfec05114, 0x00c58494, 0xff973a96, 0x002e05df, 0xfff0b977, 0x0002ba5f, 0x00008e30, 0xffff7b26,
+ 0x5cfea5aa, 0xebc3a669, 0x073274f1, 0xfe478fd2, 0xff222eac, 0x01e70494, 0xfdf44acc, 0x01b9d45b, 0xfec2d0e8, 0x00c542d1, 0xff96a0f8, 0x002eba0a, 0xfff03724, 0x0003015f, 0x000070d9, 0xffff836d,
+ 0x5c2654ed, 0xeb746dbe, 0x07777e74, 0xfe12ccd1, 0xff4789d1, 0x01cec194, 0xfe026869, 0x01b2ced1, 0xfec574f9, 0x00c4e7fe, 0xff961684, 0x002f6630, 0xffefb87a, 0x000346f6, 0x000053f7, 0xffff8b93,
+ 0x5b4ae88d, 0xeb28be1f, 0x07bb0b8b, 0xfddea042, 0xff6cc25a, 0x01b66936, 0xfe10b06f, 0x01ab9d8b, 0xfec83caa, 0x00c47459, 0xff959b29, 0x00300a4f, 0xffef3d7f, 0x00038b1d, 0x0000378c, 0xffff9398,
+ 0x5a6c7108, 0xeae09544, 0x07fd16eb, 0xfdab0fb6, 0xff91d3c6, 0x019dfeb6, 0xfe1f20c5, 0x01a441c2, 0xfecb275e, 0x00c3e824, 0xff952ed7, 0x0030a665, 0xffeec63a, 0x0003cdd1, 0x00001b9a, 0xffff9b7a,
+ 0x598aff13, 0xea9bf097, 0x083d9b81, 0xfd7820a0, 0xffb6b99f, 0x0185854f, 0xfe2db74f, 0x019cbcb1, 0xfece3472, 0x00c343a4, 0xff94d178, 0x00313a72, 0xffee52b1, 0x00040f0d, 0x00000024, 0xffffa339,
+ 0x58a6a397, 0xea5acd38, 0x087c9471, 0xfd45d856, 0xffdb6f7c, 0x016d0037, 0xfe3c71f1, 0x01950f98, 0xfed16342, 0x00c2871f, 0xff9482f8, 0x0031c677, 0xffede2e7, 0x00044ecb, 0xffffe52d, 0xffffaad3,
+ 0x57bf6fae, 0xea1d27f7, 0x08b9fd18, 0xfd143c12, 0xfffff100, 0x015472a1, 0xfe4b4e8c, 0x018d3bb8, 0xfed4b325, 0x00c1b2e0, 0xff944340, 0x00324a74, 0xffed76e3, 0x00048d0a, 0xffffcab5, 0xffffb249,
+ 0x56d574a2, 0xe9e2fd5b, 0x08f5d10a, 0xfce350f0, 0x002439db, 0x013bdfbc, 0xfe5a4b03, 0x01854258, 0xfed82370, 0x00c0c731, 0xff941236, 0x0032c66e, 0xffed0ea7, 0x0004c9c4, 0xffffb0bf, 0xffffb99a,
+ 0x55e8c3ee, 0xe9ac49a0, 0x09300c14, 0xfcb31bec, 0x004845cc, 0x01234ab4, 0xfe696534, 0x017d24bf, 0xfedbb373, 0x00bfc463, 0xff93efbf, 0x00333a67, 0xffecaa36, 0x000504f6, 0xffff974d, 0xffffc0c5,
+ 0x54f96f37, 0xe97908b8, 0x0968aa3b, 0xfc83a1e5, 0x006c10a0, 0x010ab6b0, 0xfe789b01, 0x0174e437, 0xfedf627d, 0x00beaac6, 0xff93dbc0, 0x0033a665, 0xffec4994, 0x00053e9e, 0xffff7e61, 0xffffc7ca,
+ 0x54078851, 0xe9493649, 0x099fa7bb, 0xfc54e79a, 0x008f9631, 0x00f226d0, 0xfe87ea47, 0x016c820d, 0xfee32fdb, 0x00bd7aae, 0xff93d618, 0x00340a6d, 0xffebecc2, 0x000576b8, 0xffff65fc, 0xffffcea8,
+ 0x53132138, 0xe91ccdb5, 0x09d5010b, 0xfc26f1ad, 0x00b2d26b, 0x00d99e31, 0xfe9750e8, 0x0163ff90, 0xfee71ad4, 0x00bc3470, 0xff93deaa, 0x00346687, 0xffeb93c3, 0x0005ad41, 0xffff4e20, 0xffffd55f,
+ 0x521c4c10, 0xe8f3ca12, 0x0a08b2d9, 0xfbf9c49d, 0x00d5c147, 0x00c11feb, 0xfea6ccc3, 0x015b5e11, 0xfeeb22af, 0x00bad866, 0xff93f552, 0x0034babb, 0xffeb3e96, 0x0005e238, 0xffff36ce, 0xffffdbee,
+ 0x51231b26, 0xe8ce2631, 0x0a3aba09, 0xfbcd64ca, 0x00f85ecf, 0x00a8af0c, 0xfeb65bb9, 0x01529ee3, 0xfeef46b0, 0x00b966e9, 0xff9419ef, 0x00350711, 0xffeaed3c, 0x00061599, 0xffff2007, 0xffffe255,
+ 0x5027a0e9, 0xe8abdc9d, 0x0a6b13bc, 0xfba1d673, 0x011aa71d, 0x00904ea0, 0xfec5fbac, 0x0149c35a, 0xfef3861a, 0x00b7e055, 0xff944c5a, 0x00354b94, 0xffea9fb6, 0x00064764, 0xffff09ce, 0xffffe894,
+ 0x4f29efed, 0xe88ce79a, 0x0a99bd47, 0xfb771db9, 0x013c965b, 0x007801aa, 0xfed5aa7e, 0x0140cccb, 0xfef7e02a, 0x00b6450a, 0xff948c6e, 0x0035884f, 0xffea5602, 0x00067797, 0xfffef421, 0xffffeeaa,
+ 0x4e2a1ae8, 0xe871412a, 0x0ac6b43a, 0xfb4d3e97, 0x015e28c7, 0x005fcb26, 0xfee56614, 0x0137bc8f, 0xfefc541e, 0x00b49568, 0xff94da03, 0x0035bd4e, 0xffea1020, 0x0006a630, 0xfffedf04, 0xfffff498,
+ 0x4d2834b0, 0xe858e30a, 0x0af1f65d, 0xfb243cea, 0x017f5aad, 0x0047ae09, 0xfef52c54, 0x012e93fc, 0xff00e133, 0x00b2d1d1, 0xff9534f0, 0x0035ea9d, 0xffe9ce0d, 0x0006d32f, 0xfffeca76, 0xfffffa5d,
+ 0x4c245038, 0xe843c6b5, 0x0b1b81ad, 0xfafc1c6e, 0x01a0286c, 0x002fad3f, 0xff04fb25, 0x0125546c, 0xff0586a0, 0x00b0faaa, 0xff959d0a, 0x0036104b, 0xffe98fc8, 0x0006fe92, 0xfffeb678, 0xfffffff8,
+ 0x4b1e8091, 0xe831e563, 0x0b435462, 0xfad4e0b9, 0x01c08e78, 0x0017cbae, 0xff14d073, 0x011bff38, 0xff0a439e, 0x00af1059, 0xff961224, 0x00362e66, 0xffe9554c, 0x00072859, 0xfffea30b, 0x0000056a,
+ 0x4a16d8e5, 0xe823380d, 0x0b696ceb, 0xfaae8d43, 0x01e08952, 0x00000c33, 0xff24aa2a, 0x011295bb, 0xff0f1762, 0x00ad1346, 0xff969412, 0x003644fd, 0xffe91e99, 0x00075084, 0xfffe9030, 0x00000ab3,
+ 0x490d6c79, 0xe817b76c, 0x0b8dc9ed, 0xfa89255f, 0x02001593, 0xffe871a0, 0xff348639, 0x0109194f, 0xff140121, 0x00ab03da, 0xff9722a5, 0x00365422, 0xffe8eba8, 0x00077712, 0xfffe7de7, 0x00000fd2,
+ 0x48024ea7, 0xe80f5bfb, 0x0bb06a47, 0xfa64ac3f, 0x021f2fe5, 0xffd0fec1, 0xff446293, 0x00ff8b4f, 0xff19000e, 0x00a8e282, 0xff97bdac, 0x00365be6, 0xffe8bc77, 0x00079c04, 0xfffe6c2f, 0x000014c8,
+ 0x46f592e2, 0xe80a1df5, 0x0bd14d0b, 0xfa4124f2, 0x023dd505, 0xffb9b656, 0xff543d2e, 0x00f5ed15, 0xff1e135b, 0x00a6afa8, 0xff9864f6, 0x00365c5b, 0xffe89101, 0x0007bf5b, 0xfffe5b0b, 0x00001994,
+ 0x45e74cad, 0xe807f55b, 0x0bf07186, 0xfa1e9262, 0x025c01c5, 0xffa29b18, 0xff641402, 0x00ec3ffc, 0xff233a39, 0x00a46bbc, 0xff991851, 0x00365594, 0xffe8693f, 0x0007e116, 0xfffe4a79, 0x00001e37,
+ 0x44d78fa0, 0xe808d9f1, 0x0c0dd738, 0xf9fcf758, 0x0279b30b, 0xff8bafb3, 0xff73e50e, 0x00e2855d, 0xff2873d6, 0x00a2172d, 0xff99d789, 0x003647a5, 0xffe8452d, 0x00080137, 0xfffe3a79, 0x000022b1,
+ 0x43c66f62, 0xe80cc342, 0x0c297dd9, 0xf9dc567b, 0x0296e5d0, 0xff74f6cc, 0xff83ae52, 0x00d8be92, 0xff2dbf61, 0x009fb26c, 0xff9aa268, 0x003632a2, 0xffe824c5, 0x00081fbf, 0xfffe2b0d, 0x00002701,
+ 0x42b3ffa9, 0xe813a89f, 0x0c436557, 0xf9bcb24a, 0x02b39724, 0xff5e72fb, 0xff936dd2, 0x00ceecf5, 0xff331c08, 0x009d3deb, 0xff9b78ba, 0x003616a2, 0xffe807ff, 0x00083cb0, 0xfffe1c32, 0x00002b28,
+ 0x41a05437, 0xe81d8122, 0x0c5b8dd4, 0xf99e0d26, 0x02cfc429, 0xff4826cf, 0xffa3219a, 0x00c511dc, 0xff3888f8, 0x009aba1d, 0xff9c5a47, 0x0035f3b9, 0xffe7eed5, 0x0008580a, 0xfffe0dea, 0x00002f26,
+ 0x408b80d9, 0xe82a43ac, 0x0c71f7a9, 0xf980694a, 0x02eb6a18, 0xff3214c9, 0xffb2c7b6, 0x00bb2e9f, 0xff3e055d, 0x00982778, 0xff9d46d6, 0x0035ca00, 0xffe7d93f, 0x000871cf, 0xfffe0034, 0x000032fb,
+ 0x3f759967, 0xe839e6e9, 0x0c86a361, 0xf963c8cc, 0x03068640, 0xff1c3f63, 0xffc25e3b, 0x00b14493, 0xff439064, 0x0095866f, 0xff9e3e30, 0x0035998d, 0xffe7c735, 0x00088a02, 0xfffdf310, 0x000036a8,
+ 0x3e5eb1bd, 0xe84c6152, 0x0c9991be, 0xf9482da0, 0x03211603, 0xff06a907, 0xffd1e340, 0x00a7550c, 0xff492937, 0x0092d77b, 0xff9f4019, 0x00356279, 0xffe7b8af, 0x0008a0a5, 0xfffde67c, 0x00003a2d,
+ 0x3d46ddc1, 0xe861a92b, 0x0caac3b5, 0xf92d9997, 0x033b16dc, 0xfef15417, 0xffe154e3, 0x009d615d, 0xff4ecf02, 0x00901b11, 0xffa04c57, 0x003524dd, 0xffe7ada5, 0x0008b5ba, 0xfffdda79, 0x00003d89,
+ 0x3c2e315a, 0xe879b487, 0x0cba3a6d, 0xf9140e5e, 0x03548659, 0xfedc42e7, 0xfff0b148, 0x00936ad6, 0xff5480f0, 0x008d51ab, 0xffa162ae, 0x0034e0d3, 0xffe7a60d, 0x0008c944, 0xfffdcf05, 0x000040be,
+ 0x3b14c072, 0xe8947947, 0x0cc7f742, 0xf8fb8d7d, 0x036d621f, 0xfec777be, 0xfffff697, 0x008972c7, 0xff5a3e2c, 0x008a7bc1, 0xffa282e1, 0x00349674, 0xffe7a1de, 0x0008db46, 0xfffdc421, 0x000043cc,
+ 0x39fa9ef3, 0xe8b1ed1c, 0x0cd3fbc0, 0xf8e4185a, 0x0385a7eb, 0xfeb2f4d9, 0x000f22fe, 0x007f7a7c, 0xff6005e1, 0x008799cd, 0xffa3acb4, 0x003445dc, 0xffe7a10d, 0x0008ebc1, 0xfffdb9cb, 0x000046b2,
+ 0x38dfe0c6, 0xe8d2058b, 0x0cde49a8, 0xf8cdb036, 0x039d558e, 0xfe9ebc66, 0x001e34b4, 0x00758341, 0xff65d73a, 0x0084ac48, 0xffa4dfe8, 0x0033ef25, 0xffe7a391, 0x0008fabb, 0xfffdb002, 0x00004972,
+ 0x37c499d0, 0xe8f4b7e9, 0x0ce6e2ea, 0xf8b85631, 0x03b468f1, 0xfe8ad087, 0x002d29f3, 0x006b8e5c, 0xff6bb163, 0x0081b3af, 0xffa61c3e, 0x0033926d, 0xffe7a95f, 0x00090836, 0xfffda6c5, 0x00004c0b,
+ 0x36a8ddf3, 0xe919f961, 0x0cedc9a7, 0xf8a40b44, 0x03cae014, 0xfe773351, 0x003c00fd, 0x00619d15, 0xff719388, 0x007eb07b, 0xffa76176, 0x00332fcf, 0xffe7b26c, 0x00091435, 0xfffd9e13, 0x00004e7f,
+ 0x358cc109, 0xe941bef3, 0x0cf30031, 0xf890d048, 0x03e0b90d, 0xfe63e6cb, 0x004ab81b, 0x0057b0ae, 0xff777cd6, 0x007ba32a, 0xffa8af51, 0x0032c769, 0xffe7bead, 0x00091ebd, 0xfffd95eb, 0x000050cd,
+ 0x347056e3, 0xe96bfd76, 0x0cf6890a, 0xf87ea5f1, 0x03f5f20a, 0xfe50ecf0, 0x00594d9d, 0x004dca68, 0xff7d6c79, 0x00788c36, 0xffaa058d, 0x00325958, 0xffe7ce16, 0x000927d1, 0xfffd8e4d, 0x000052f7,
+ 0x3353b349, 0xe998a999, 0x0cf866e1, 0xf86d8cd1, 0x040a894e, 0xfe3e47ac, 0x0067bfd8, 0x0043eb7f, 0xff83619f, 0x00756c1d, 0xffab63ea, 0x0031e5ba, 0xffe7e09c, 0x00092f75, 0xfffd8735, 0x000054fc,
+ 0x3236e9f7, 0xe9c7b7e3, 0x0cf89c96, 0xf85d8555, 0x041e7d34, 0xfe2bf8de, 0x00760d2a, 0x003a152f, 0xff895b77, 0x0072435b, 0xffacca25, 0x00316cae, 0xffe7f631, 0x000935ad, 0xfffd80a4, 0x000056dd,
+ 0x311a0e9b, 0xe9f91cb9, 0x0cf72d34, 0xf84e8fc9, 0x0431cc31, 0xfe1a0256, 0x008433f9, 0x003048ae, 0xff8f5930, 0x006f126b, 0xffae37fd, 0x0030ee53, 0xffe80eca, 0x00093a7f, 0xfffd7a98, 0x0000589b,
+ 0x2ffd34d4, 0xea2ccc59, 0x0cf41bf7, 0xf840ac57, 0x044474ce, 0xfe0865d7, 0x009232b2, 0x0026872f, 0xff9559fb, 0x006bd9cd, 0xffafad2e, 0x00306ac8, 0xffe82a59, 0x00093ded, 0xfffd750f, 0x00005a36,
+ 0x2ee07030, 0xea62bae0, 0x0cef6c43, 0xf833db04, 0x045675ab, 0xfdf72515, 0x00a007c9, 0x001cd1e4, 0xff9b5d0a, 0x006899fb, 0xffb12976, 0x002fe22c, 0xffe848d3, 0x00093ffe, 0xfffd7008, 0x00005baf,
+ 0x2dc3d429, 0xea9adc49, 0x0ce921ab, 0xf8281bb6, 0x0467cd83, 0xfde641b7, 0x00adb1bb, 0x001329f7, 0xffa16190, 0x00655372, 0xffb2ac90, 0x002f54a1, 0xffe86a29, 0x000940b6, 0xfffd6b81, 0x00005d06,
+ 0x2ca77428, 0xead52471, 0x0ce13feb, 0xf81d6e2e, 0x04787b24, 0xfdd5bd53, 0x00bb2f0b, 0x00099093, 0xffa766c0, 0x006206b1, 0xffb4363a, 0x002ec246, 0xffe88e4d, 0x00094019, 0xfffd6779, 0x00005e3d,
+ 0x2b8b637b, 0xeb118714, 0x0cd7caec, 0xf813d20d, 0x04887d76, 0xfdc59972, 0x00c87e47, 0x000006db, 0xffad6bd0, 0x005eb431, 0xffb5c630, 0x002e2b3c, 0xffe8b532, 0x00093e2e, 0xfffd63ed, 0x00005f52,
+ 0x2a6fb55e, 0xeb4ff7d4, 0x0cccc6bc, 0xf80b46d3, 0x0497d378, 0xfdb5d78f, 0x00d59e03, 0xfff68df1, 0xffb36ff9, 0x005b5c71, 0xffb75c2c, 0x002d8fa4, 0xffe8decb, 0x00093af8, 0xfffd60dd, 0x00006048,
+ 0x29547ced, 0xeb906a35, 0x0cc03797, 0xf803cbdc, 0x04a67c41, 0xfda67913, 0x00e28cdd, 0xffed26f0, 0xffb97271, 0x0057ffec, 0xffb8f7ea, 0x002cefa1, 0xffe90b08, 0x0009367e, 0xfffd5e46, 0x0000611f,
+ 0x2839cd30, 0xebd2d1a1, 0x0cb221de, 0xf7fd6065, 0x04b476fe, 0xfd977f5d, 0x00ef497a, 0xffe3d2f2, 0xffbf7274, 0x00549f1c, 0xffba9927, 0x002c4b53, 0xffe939db, 0x000930c4, 0xfffd5c26, 0x000061d8,
+ 0x271fb90d, 0xec17216b, 0x0ca28a1a, 0xf7f8038c, 0x04c1c2f3, 0xfd88ebb9, 0x00fbd28a, 0xffda930a, 0xffc56f3e, 0x00513a7e, 0xffbc3f9d, 0x002ba2dc, 0xffe96b35, 0x000929d1, 0xfffd5a7c, 0x00006272,
+ 0x2606534e, 0xec5d4ccd, 0x0c9174fa, 0xf7f3b44b, 0x04ce5f7d, 0xfd7abf64, 0x010826c4, 0xffd16848, 0xffcb680e, 0x004dd28c, 0xffbdeb07, 0x002af65f, 0xffe99f08, 0x000921aa, 0xfffd5945, 0x000062f0,
+ 0x24edae9c, 0xeca546eb, 0x0c7ee754, 0xf7f0717e, 0x04da4c10, 0xfd6cfb8e, 0x011444e7, 0xffc853b6, 0xffd15c22, 0x004a67c0, 0xffbf9b21, 0x002a45fe, 0xffe9d545, 0x00091854, 0xfffd5880, 0x00006351,
+ 0x23d5dd81, 0xecef02d5, 0x0c6ae622, 0xf7ee39e2, 0x04e58836, 0xfd5fa157, 0x01202bbe, 0xffbf565a, 0xffd74abe, 0x0046fa93, 0xffc14fa5, 0x002991db, 0xffea0ddc, 0x00090dd6, 0xfffd582a, 0x00006396,
+ 0x22bef262, 0xed3a7388, 0x0c557681, 0xf7ed0c12, 0x04f01392, 0xfd52b1cf, 0x012bda1b, 0xffb67137, 0xffdd3325, 0x00438b7e, 0xffc3084f, 0x0028da1a, 0xffea48be, 0x00090236, 0xfffd5842, 0x000063c0,
+ 0x21a8ff7e, 0xed878bf0, 0x0c3e9db5, 0xf7ece68c, 0x04f9edda, 0xfd462df6, 0x01374eda, 0xffada547, 0xffe3149e, 0x00401af9, 0xffc4c4da, 0x00281edd, 0xffea85dc, 0x0008f57a, 0xfffd58c5, 0x000063d0,
+ 0x209416f2, 0xedd63ee5, 0x0c26611f, 0xf7edc7af, 0x050316e0, 0xfd3a16c0, 0x014288e0, 0xffa4f383, 0xffe8ee72, 0x003ca97b, 0xffc68502, 0x00276046, 0xffeac525, 0x0008e7a7, 0xfffd59b2, 0x000063c6,
+ 0x1f804ab0, 0xee267f35, 0x0c0cc646, 0xf7efadbd, 0x050b8e8a, 0xfd2e6d0d, 0x014d871b, 0xff9c5cdc, 0xffeebfec, 0x0039377a, 0xffc84881, 0x00269e7a, 0xffeb068a, 0x0008d8c4, 0xfffd5b05, 0x000063a3,
+ 0x1e6dac83, 0xee783f9e, 0x0bf1d2d0, 0xf7f296d7, 0x051354d5, 0xfd2331b0, 0x01584883, 0xff93e241, 0xfff48859, 0x0035c56c, 0xffca0f14, 0x0025d99b, 0xffeb49fc, 0x0008c8d7, 0xfffd5cbe, 0x00006368,
+ 0x1d5c4e09, 0xeecb72d1, 0x0bd58c81, 0xf7f68103, 0x051a69d4, 0xfd18656f, 0x0162cc19, 0xff8b8498, 0xfffa470a, 0x003253c6, 0xffcbd876, 0x002511cd, 0xffeb8f6a, 0x0008b7e7, 0xfffd5ed8, 0x00006316,
+ 0x1c4c40b6, 0xef200b76, 0x0bb7f940, 0xf7fb6a29, 0x0520cdb1, 0xfd0e08fb, 0x016d10e9, 0xff8344c4, 0xfffffb51, 0x002ee2fa, 0xffcda463, 0x00244733, 0xffebd6c4, 0x0008a5fa, 0xfffd6154, 0x000062ad,
+ 0x1b3d95d1, 0xef75fc2b, 0x0b991f0f, 0xf8015015, 0x052680ae, 0xfd041cfa, 0x01771608, 0xff7b23a1, 0x0005a483, 0x002b737b, 0xffcf7299, 0x002379ef, 0xffec1ffa, 0x00089316, 0xfffd642d, 0x0000622e,
+ 0x1a305e70, 0xefcd3787, 0x0b79040c, 0xf8083077, 0x052b8320, 0xfcfaa200, 0x0180da94, 0xff732209, 0x000b41fa, 0x002805ba, 0xffd142d3, 0x0022aa26, 0xffec6afc, 0x00087f43, 0xfffd6762, 0x0000619a,
+ 0x1924ab7b, 0xf025b01a, 0x0b57ae75, 0xf81008e2, 0x052fd573, 0xfcf19894, 0x018a5db5, 0xff6b40cb, 0x0010d30e, 0x00249a28, 0xffd314cf, 0x0021d7fa, 0xffecb7b9, 0x00086a86, 0xfffd6af1, 0x000060f1,
+ 0x181a8da5, 0xf07f586e, 0x0b3524a0, 0xf818d6cf, 0x0533782a, 0xfce9012c, 0x01939e9e, 0xff6380b5, 0x00165720, 0x00213134, 0xffd4e84a, 0x00210390, 0xffed0621, 0x000854e6, 0xfffd6ed6, 0x00006035,
+ 0x17121573, 0xf0da230b, 0x0b116cff, 0xf822979b, 0x05366bdc, 0xfce0dc2f, 0x019c9c8b, 0xff5be28d, 0x001bcd8e, 0x001dcb4a, 0xffd6bd01, 0x00202d09, 0xffed5624, 0x00083e6a, 0xfffd7310, 0x00005f66,
+ 0x160b5331, 0xf1360276, 0x0aec8e1c, 0xf82d488c, 0x0538b136, 0xfcd929f4, 0x01a556c1, 0xff546713, 0x002135bd, 0x001a68d8, 0xffd892b4, 0x001f5489, 0xffeda7b1, 0x00082718, 0xfffd779d, 0x00005e84,
+ 0x150656f8, 0xf192e932, 0x0ac68e9b, 0xf838e6c9, 0x053a48fa, 0xfcd1eac3, 0x01adcc91, 0xff4d0f02, 0x00268f13, 0x00170a47, 0xffda6921, 0x001e7a33, 0xffedfab8, 0x00080ef7, 0xfffd7c7a, 0x00005d92,
+ 0x140330a9, 0xf1f0c9c5, 0x0a9f7537, 0xf8456f65, 0x053b3400, 0xfccb1ed7, 0x01b5fd54, 0xff45db10, 0x002bd8fa, 0x0013b003, 0xffdc4007, 0x001d9e2a, 0xffee4f29, 0x0007f60f, 0xfffd81a4, 0x00005c8e,
+ 0x1301efed, 0xf24f96b5, 0x0a7748c0, 0xf852df56, 0x053b7332, 0xfcc4c658, 0x01bde86f, 0xff3ecbea, 0x003112e0, 0x00105a72, 0xffde1726, 0x001cc091, 0xffeea4f2, 0x0007dc65, 0xfffd8719, 0x00005b7b,
+ 0x1202a434, 0xf2af428c, 0x0a4e101f, 0xf861337c, 0x053b0791, 0xfcbee162, 0x01c58d50, 0xff37e23b, 0x00363c35, 0x000d09fc, 0xffdfee3f, 0x001be18a, 0xffeefc04, 0x0007c201, 0xfffd8cd7, 0x00005a58,
+ 0x11055cb4, 0xf30fbfd7, 0x0a23d24e, 0xf870689f, 0x0539f231, 0xfcb97001, 0x01cceb6e, 0xff311ea4, 0x003b546b, 0x0009bf05, 0xffe1c511, 0x001b0138, 0xffef544e, 0x0007a6e9, 0xfffd92db, 0x00005927,
+ 0x100a2864, 0xf371012c, 0x09f8965d, 0xf8807b70, 0x0538343a, 0xfcb47232, 0x01d4024c, 0xff2a81c4, 0x00405afa, 0x000679f2, 0xffe39b60, 0x001a1fbc, 0xffefadc0, 0x00078b24, 0xfffd9923, 0x000057e9,
+ 0x0f111603, 0xf3d2f926, 0x09cc636e, 0xf8916889, 0x0535cee9, 0xfcafe7e2, 0x01dad175, 0xff240c2f, 0x00454f5d, 0x00033b23, 0xffe570ed, 0x00193d3a, 0xfff00849, 0x00076eba, 0xfffd9fac, 0x0000569d,
+ 0x0e1a340d, 0xf4359a6a, 0x099f40b5, 0xf8a32c6e, 0x0532c38c, 0xfcabd0f2, 0x01e15880, 0xff1dbe77, 0x004a310f, 0x000002f9, 0xffe7457c, 0x001859d2, 0xfff063d9, 0x000751b0, 0xfffda675, 0x00005545,
+ 0x0d2590c3, 0xf498d7a5, 0x09713575, 0xf8b5c38d, 0x052f1386, 0xfca82d32, 0x01e7970e, 0xff179926, 0x004eff94, 0xfffcd1d3, 0xffe918ce, 0x001775a7, 0xfff0c060, 0x0007340d, 0xfffdad79, 0x000053e2,
+ 0x0c333a22, 0xf4fca390, 0x09424904, 0xf8c92a41, 0x052ac04c, 0xfca4fc64, 0x01ed8cc7, 0xff119cc0, 0x0053ba6e, 0xfff9a80d, 0xffeaeaab, 0x001690d9, 0xfff11dcd, 0x000715d9, 0xfffdb4b9, 0x00005274,
+};
+}
diff --git a/services/audioflinger/test-resample.cpp b/services/audioflinger/test-resample.cpp
new file mode 100644
index 00000000..7a314cfa
--- /dev/null
+++ b/services/audioflinger/test-resample.cpp
@@ -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.
+ */
+
+#include "AudioResampler.h"
+#include <media/AudioBufferProvider.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <fcntl.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <time.h>
+#include <math.h>
+
+using namespace android;
+
+struct HeaderWav {
+ HeaderWav(size_t size, int nc, int sr, int bits) {
+ strncpy(RIFF, "RIFF", 4);
+ chunkSize = size + sizeof(HeaderWav);
+ strncpy(WAVE, "WAVE", 4);
+ strncpy(fmt, "fmt ", 4);
+ fmtSize = 16;
+ audioFormat = 1;
+ numChannels = nc;
+ samplesRate = sr;
+ byteRate = sr * numChannels * (bits/8);
+ align = nc*(bits/8);
+ bitsPerSample = bits;
+ strncpy(data, "data", 4);
+ dataSize = size;
+ }
+
+ char RIFF[4]; // RIFF
+ uint32_t chunkSize; // File size
+ char WAVE[4]; // WAVE
+ char fmt[4]; // fmt\0
+ uint32_t fmtSize; // fmt size
+ uint16_t audioFormat; // 1=PCM
+ uint16_t numChannels; // num channels
+ uint32_t samplesRate; // sample rate in hz
+ uint32_t byteRate; // Bps
+ uint16_t align; // 2=16-bit mono, 4=16-bit stereo
+ uint16_t bitsPerSample; // bits per sample
+ char data[4]; // "data"
+ uint32_t dataSize; // size
+};
+
+static int usage(const char* name) {
+ fprintf(stderr,"Usage: %s [-p] [-h] [-s] [-q {dq|lq|mq|hq|vhq}] [-i input-sample-rate] "
+ "[-o output-sample-rate] [<input-file>] <output-file>\n", name);
+ fprintf(stderr," -p enable profiling\n");
+ fprintf(stderr," -h create wav file\n");
+ fprintf(stderr," -s stereo\n");
+ fprintf(stderr," -q resampler quality\n");
+ fprintf(stderr," dq : default quality\n");
+ fprintf(stderr," lq : low quality\n");
+ fprintf(stderr," mq : medium quality\n");
+ fprintf(stderr," hq : high quality\n");
+ fprintf(stderr," vhq : very high quality\n");
+ fprintf(stderr," -i input file sample rate\n");
+ fprintf(stderr," -o output file sample rate\n");
+ return -1;
+}
+
+int main(int argc, char* argv[]) {
+
+ const char* const progname = argv[0];
+ bool profiling = false;
+ bool writeHeader = false;
+ int channels = 1;
+ int input_freq = 0;
+ int output_freq = 0;
+ AudioResampler::src_quality quality = AudioResampler::DEFAULT_QUALITY;
+
+ int ch;
+ while ((ch = getopt(argc, argv, "phsq:i:o:")) != -1) {
+ switch (ch) {
+ case 'p':
+ profiling = true;
+ break;
+ case 'h':
+ writeHeader = true;
+ break;
+ case 's':
+ channels = 2;
+ break;
+ case 'q':
+ if (!strcmp(optarg, "dq"))
+ quality = AudioResampler::DEFAULT_QUALITY;
+ else if (!strcmp(optarg, "lq"))
+ quality = AudioResampler::LOW_QUALITY;
+ else if (!strcmp(optarg, "mq"))
+ quality = AudioResampler::MED_QUALITY;
+ else if (!strcmp(optarg, "hq"))
+ quality = AudioResampler::HIGH_QUALITY;
+ else if (!strcmp(optarg, "vhq"))
+ quality = AudioResampler::VERY_HIGH_QUALITY;
+ else {
+ usage(progname);
+ return -1;
+ }
+ break;
+ case 'i':
+ input_freq = atoi(optarg);
+ break;
+ case 'o':
+ output_freq = atoi(optarg);
+ break;
+ case '?':
+ default:
+ usage(progname);
+ return -1;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ const char* file_in = NULL;
+ const char* file_out = NULL;
+ if (argc == 1) {
+ file_out = argv[0];
+ } else if (argc == 2) {
+ file_in = argv[0];
+ file_out = argv[1];
+ } else {
+ usage(progname);
+ return -1;
+ }
+
+ // ----------------------------------------------------------
+
+ size_t input_size;
+ void* input_vaddr;
+ if (argc == 2) {
+ struct stat st;
+ if (stat(file_in, &st) < 0) {
+ fprintf(stderr, "stat: %s\n", strerror(errno));
+ return -1;
+ }
+
+ int input_fd = open(file_in, O_RDONLY);
+ if (input_fd < 0) {
+ fprintf(stderr, "open: %s\n", strerror(errno));
+ return -1;
+ }
+
+ input_size = st.st_size;
+ input_vaddr = mmap(0, input_size, PROT_READ, MAP_PRIVATE, input_fd, 0);
+ if (input_vaddr == MAP_FAILED ) {
+ fprintf(stderr, "mmap: %s\n", strerror(errno));
+ return -1;
+ }
+ } else {
+ double k = 1000; // Hz / s
+ double time = (input_freq / 2) / k;
+ size_t input_frames = size_t(input_freq * time);
+ input_size = channels * sizeof(int16_t) * input_frames;
+ input_vaddr = malloc(input_size);
+ int16_t* in = (int16_t*)input_vaddr;
+ for (size_t i=0 ; i<input_frames ; i++) {
+ double t = double(i) / input_freq;
+ double y = sin(M_PI * k * t * t);
+ int16_t yi = floor(y * 32767.0 + 0.5);
+ for (size_t j=0 ; j<(size_t)channels ; j++) {
+ in[i*channels + j] = yi / (1+j);
+ }
+ }
+ }
+
+ // ----------------------------------------------------------
+
+ class Provider: public AudioBufferProvider {
+ int16_t* mAddr;
+ size_t mNumFrames;
+ public:
+ Provider(const void* addr, size_t size, int channels) {
+ mAddr = (int16_t*) addr;
+ mNumFrames = size / (channels*sizeof(int16_t));
+ }
+ virtual status_t getNextBuffer(Buffer* buffer,
+ int64_t pts = kInvalidPTS) {
+ buffer->frameCount = mNumFrames;
+ buffer->i16 = mAddr;
+ return NO_ERROR;
+ }
+ virtual void releaseBuffer(Buffer* buffer) {
+ }
+ } provider(input_vaddr, input_size, channels);
+
+ size_t input_frames = input_size / (channels * sizeof(int16_t));
+ size_t output_size = 2 * 4 * ((int64_t) input_frames * output_freq) / input_freq;
+ output_size &= ~7; // always stereo, 32-bits
+
+ void* output_vaddr = malloc(output_size);
+
+ if (profiling) {
+ AudioResampler* resampler = AudioResampler::create(16, channels,
+ output_freq, quality);
+
+ size_t out_frames = output_size/8;
+ resampler->setSampleRate(input_freq);
+ resampler->setVolume(0x1000, 0x1000);
+
+ memset(output_vaddr, 0, output_size);
+ timespec start, end;
+ clock_gettime(CLOCK_MONOTONIC, &start);
+ resampler->resample((int*) output_vaddr, out_frames, &provider);
+ resampler->resample((int*) output_vaddr, out_frames, &provider);
+ resampler->resample((int*) output_vaddr, out_frames, &provider);
+ resampler->resample((int*) output_vaddr, out_frames, &provider);
+ clock_gettime(CLOCK_MONOTONIC, &end);
+ int64_t start_ns = start.tv_sec * 1000000000LL + start.tv_nsec;
+ int64_t end_ns = end.tv_sec * 1000000000LL + end.tv_nsec;
+ int64_t time = (end_ns - start_ns)/4;
+ printf("%f Mspl/s\n", out_frames/(time/1e9)/1e6);
+
+ delete resampler;
+ }
+
+ AudioResampler* resampler = AudioResampler::create(16, channels,
+ output_freq, quality);
+ size_t out_frames = output_size/8;
+ resampler->setSampleRate(input_freq);
+ resampler->setVolume(0x1000, 0x1000);
+
+ memset(output_vaddr, 0, output_size);
+ resampler->resample((int*) output_vaddr, out_frames, &provider);
+
+ // down-mix (we just truncate and keep the left channel)
+ int32_t* out = (int32_t*) output_vaddr;
+ int16_t* convert = (int16_t*) malloc(out_frames * channels * sizeof(int16_t));
+ for (size_t i = 0; i < out_frames; i++) {
+ for (int j=0 ; j<channels ; j++) {
+ int32_t s = out[i * 2 + j] >> 12;
+ if (s > 32767) s = 32767;
+ else if (s < -32768) s = -32768;
+ convert[i * channels + j] = int16_t(s);
+ }
+ }
+
+ // write output to disk
+ int output_fd = open(file_out, O_WRONLY | O_CREAT | O_TRUNC,
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+ if (output_fd < 0) {
+ fprintf(stderr, "open: %s\n", strerror(errno));
+ return -1;
+ }
+
+ if (writeHeader) {
+ HeaderWav wav(out_frames * channels * sizeof(int16_t), channels, output_freq, 16);
+ write(output_fd, &wav, sizeof(wav));
+ }
+
+ write(output_fd, convert, out_frames * channels * sizeof(int16_t));
+ close(output_fd);
+
+ return 0;
+}
diff --git a/services/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index 3cae1f52..eff47c84 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -7,7 +7,20 @@ LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES:= \
- CameraService.cpp
+ CameraService.cpp \
+ CameraClient.cpp \
+ Camera2Client.cpp \
+ Camera2Device.cpp \
+ camera2/CameraMetadata.cpp \
+ camera2/Parameters.cpp \
+ camera2/FrameProcessor.cpp \
+ camera2/StreamingProcessor.cpp \
+ camera2/JpegProcessor.cpp \
+ camera2/CallbackProcessor.cpp \
+ camera2/ZslProcessor.cpp \
+ camera2/BurstCapture.cpp \
+ camera2/JpegCompressor.cpp \
+ camera2/CaptureSequencer.cpp
LOCAL_SHARED_LIBRARIES:= \
libui \
@@ -18,7 +31,14 @@ LOCAL_SHARED_LIBRARIES:= \
libmedia_native \
libcamera_client \
libgui \
- libhardware
+ libhardware \
+ libsync \
+ libcamera_metadata \
+ libjpeg
+
+LOCAL_C_INCLUDES += \
+ system/media/camera/include \
+ external/jpeg
LOCAL_MODULE:= libcameraservice
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
new file mode 100644
index 00000000..30335773
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -0,0 +1,1636 @@
+/*
+ * 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 "Camera2"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include <cutils/properties.h>
+#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
+#include "camera2/Parameters.h"
+#include "Camera2Client.h"
+
+#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
+#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
+
+namespace android {
+using namespace camera2;
+
+static int getCallingPid() {
+ return IPCThreadState::self()->getCallingPid();
+}
+
+static int getCallingUid() {
+ return IPCThreadState::self()->getCallingUid();
+}
+
+// Interface used by CameraService
+
+Camera2Client::Camera2Client(const sp<CameraService>& cameraService,
+ const sp<ICameraClient>& cameraClient,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid):
+ Client(cameraService, cameraClient,
+ cameraId, cameraFacing, clientPid, servicePid),
+ mSharedCameraClient(cameraClient),
+ mParameters(cameraId, cameraFacing)
+{
+ ATRACE_CALL();
+ ALOGI("Camera %d: Opened", cameraId);
+
+ mDevice = new Camera2Device(cameraId);
+
+ SharedParameters::Lock l(mParameters);
+ l.mParameters.state = Parameters::DISCONNECTED;
+}
+
+status_t Camera2Client::checkPid(const char* checkLocation) const {
+ int callingPid = getCallingPid();
+ if (callingPid == mClientPid) return NO_ERROR;
+
+ ALOGE("%s: attempt to use a locked camera from a different process"
+ " (old pid %d, new pid %d)", checkLocation, mClientPid, callingPid);
+ return PERMISSION_DENIED;
+}
+
+status_t Camera2Client::initialize(camera_module_t *module)
+{
+ ATRACE_CALL();
+ ALOGV("%s: Initializing client for camera %d", __FUNCTION__, mCameraId);
+ status_t res;
+
+ res = mDevice->initialize(module);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: unable to initialize device: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return NO_INIT;
+ }
+
+ res = mDevice->setNotifyCallback(this);
+
+ SharedParameters::Lock l(mParameters);
+
+ res = l.mParameters.initialize(&(mDevice->info()));
+ if (res != OK) {
+ ALOGE("%s: Camera %d: unable to build defaults: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return NO_INIT;
+ }
+
+ String8 threadName;
+
+ mStreamingProcessor = new StreamingProcessor(this);
+
+ mFrameProcessor = new FrameProcessor(this);
+ threadName = String8::format("C2-%d-FrameProc",
+ mCameraId);
+ mFrameProcessor->run(threadName.string());
+
+ mCaptureSequencer = new CaptureSequencer(this);
+ threadName = String8::format("C2-%d-CaptureSeq",
+ mCameraId);
+ mCaptureSequencer->run(threadName.string());
+
+ mJpegProcessor = new JpegProcessor(this, mCaptureSequencer);
+ threadName = String8::format("C2-%d-JpegProc",
+ mCameraId);
+ mJpegProcessor->run(threadName.string());
+
+ mZslProcessor = new ZslProcessor(this, mCaptureSequencer);
+ threadName = String8::format("C2-%d-ZslProc",
+ mCameraId);
+ mZslProcessor->run(threadName.string());
+
+ mCallbackProcessor = new CallbackProcessor(this);
+ threadName = String8::format("C2-%d-CallbkProc",
+ mCameraId);
+ mCallbackProcessor->run(threadName.string());
+
+ if (gLogLevel >= 1) {
+ ALOGD("%s: Default parameters converted from camera %d:", __FUNCTION__,
+ mCameraId);
+ ALOGD("%s", l.mParameters.paramsFlattened.string());
+ }
+
+ return OK;
+}
+
+Camera2Client::~Camera2Client() {
+ ATRACE_CALL();
+
+ mDestructionStarted = true;
+
+ disconnect();
+
+ ALOGI("Camera %d: Closed", mCameraId);
+}
+
+status_t Camera2Client::dump(int fd, const Vector<String16>& args) {
+ String8 result;
+ result.appendFormat("Client2[%d] (%p) PID: %d, dump:\n",
+ mCameraId,
+ getCameraClient()->asBinder().get(),
+ mClientPid);
+ result.append(" State: ");
+#define CASE_APPEND_ENUM(x) case x: result.append(#x "\n"); break;
+
+ const Parameters& p = mParameters.unsafeAccess();
+
+ result.append(Parameters::getStateName(p.state));
+
+ result.append("\n Current parameters:\n");
+ result.appendFormat(" Preview size: %d x %d\n",
+ p.previewWidth, p.previewHeight);
+ result.appendFormat(" Preview FPS range: %d - %d\n",
+ p.previewFpsRange[0], p.previewFpsRange[1]);
+ result.appendFormat(" Preview HAL pixel format: 0x%x\n",
+ p.previewFormat);
+ result.appendFormat(" Preview transform: %x\n",
+ p.previewTransform);
+ result.appendFormat(" Picture size: %d x %d\n",
+ p.pictureWidth, p.pictureHeight);
+ result.appendFormat(" Jpeg thumbnail size: %d x %d\n",
+ p.jpegThumbSize[0], p.jpegThumbSize[1]);
+ result.appendFormat(" Jpeg quality: %d, thumbnail quality: %d\n",
+ p.jpegQuality, p.jpegThumbQuality);
+ result.appendFormat(" Jpeg rotation: %d\n", p.jpegRotation);
+ result.appendFormat(" GPS tags %s\n",
+ p.gpsEnabled ? "enabled" : "disabled");
+ if (p.gpsEnabled) {
+ result.appendFormat(" GPS lat x long x alt: %f x %f x %f\n",
+ p.gpsCoordinates[0], p.gpsCoordinates[1],
+ p.gpsCoordinates[2]);
+ result.appendFormat(" GPS timestamp: %lld\n",
+ p.gpsTimestamp);
+ result.appendFormat(" GPS processing method: %s\n",
+ p.gpsProcessingMethod.string());
+ }
+
+ result.append(" White balance mode: ");
+ switch (p.wbMode) {
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_AUTO)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_INCANDESCENT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_FLUORESCENT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_DAYLIGHT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_TWILIGHT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_MODE_SHADE)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Effect mode: ");
+ switch (p.effectMode) {
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_OFF)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_MONO)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_NEGATIVE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_SOLARIZE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_SEPIA)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_POSTERIZE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MODE_AQUA)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Antibanding mode: ");
+ switch (p.antibandingMode) {
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Scene mode: ");
+ switch (p.sceneMode) {
+ case ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED:
+ result.append("AUTO\n"); break;
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_ACTION)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_PORTRAIT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_LANDSCAPE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_NIGHT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_THEATRE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_BEACH)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_SNOW)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_SUNSET)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_FIREWORKS)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_SPORTS)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_PARTY)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_SCENE_MODE_BARCODE)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Flash mode: ");
+ switch (p.flashMode) {
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_OFF)
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_AUTO)
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_ON)
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_TORCH)
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_RED_EYE)
+ CASE_APPEND_ENUM(Parameters::FLASH_MODE_INVALID)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Focus mode: ");
+ switch (p.focusMode) {
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_AUTO)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_MACRO)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_CONTINUOUS_VIDEO)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_CONTINUOUS_PICTURE)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_EDOF)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_INFINITY)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_FIXED)
+ CASE_APPEND_ENUM(Parameters::FOCUS_MODE_INVALID)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Focus state: ");
+ switch (p.focusState) {
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_INACTIVE)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED)
+ CASE_APPEND_ENUM(ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED)
+ default: result.append("UNKNOWN\n");
+ }
+
+ result.append(" Focusing areas:\n");
+ for (size_t i = 0; i < p.focusingAreas.size(); i++) {
+ result.appendFormat(" [ (%d, %d, %d, %d), weight %d ]\n",
+ p.focusingAreas[i].left,
+ p.focusingAreas[i].top,
+ p.focusingAreas[i].right,
+ p.focusingAreas[i].bottom,
+ p.focusingAreas[i].weight);
+ }
+
+ result.appendFormat(" Exposure compensation index: %d\n",
+ p.exposureCompensation);
+
+ result.appendFormat(" AE lock %s, AWB lock %s\n",
+ p.autoExposureLock ? "enabled" : "disabled",
+ p.autoWhiteBalanceLock ? "enabled" : "disabled" );
+
+ result.appendFormat(" Metering areas:\n");
+ for (size_t i = 0; i < p.meteringAreas.size(); i++) {
+ result.appendFormat(" [ (%d, %d, %d, %d), weight %d ]\n",
+ p.meteringAreas[i].left,
+ p.meteringAreas[i].top,
+ p.meteringAreas[i].right,
+ p.meteringAreas[i].bottom,
+ p.meteringAreas[i].weight);
+ }
+
+ result.appendFormat(" Zoom index: %d\n", p.zoom);
+ result.appendFormat(" Video size: %d x %d\n", p.videoWidth,
+ p.videoHeight);
+
+ result.appendFormat(" Recording hint is %s\n",
+ p.recordingHint ? "set" : "not set");
+
+ result.appendFormat(" Video stabilization is %s\n",
+ p.videoStabilization ? "enabled" : "disabled");
+
+ result.append(" Current streams:\n");
+ result.appendFormat(" Preview stream ID: %d\n",
+ getPreviewStreamId());
+ result.appendFormat(" Capture stream ID: %d\n",
+ getCaptureStreamId());
+ result.appendFormat(" Recording stream ID: %d\n",
+ getRecordingStreamId());
+
+ result.append(" Quirks for this camera:\n");
+ bool haveQuirk = false;
+ if (p.quirks.triggerAfWithAuto) {
+ result.appendFormat(" triggerAfWithAuto\n");
+ haveQuirk = true;
+ }
+ if (p.quirks.useZslFormat) {
+ result.appendFormat(" useZslFormat\n");
+ haveQuirk = true;
+ }
+ if (p.quirks.meteringCropRegion) {
+ result.appendFormat(" meteringCropRegion\n");
+ haveQuirk = true;
+ }
+ if (!haveQuirk) {
+ result.appendFormat(" none\n");
+ }
+
+ write(fd, result.string(), result.size());
+
+ mStreamingProcessor->dump(fd, args);
+
+ mCaptureSequencer->dump(fd, args);
+
+ mFrameProcessor->dump(fd, args);
+
+ mZslProcessor->dump(fd, args);
+
+ result = " Device dump:\n";
+ write(fd, result.string(), result.size());
+
+ status_t res = mDevice->dump(fd, args);
+ if (res != OK) {
+ result = String8::format(" Error dumping device: %s (%d)",
+ strerror(-res), res);
+ write(fd, result.string(), result.size());
+ }
+
+#undef CASE_APPEND_ENUM
+ return NO_ERROR;
+}
+
+// ICamera interface
+
+void Camera2Client::disconnect() {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+
+ // Allow both client and the media server to disconnect at all times
+ int callingPid = getCallingPid();
+ if (callingPid != mClientPid && callingPid != mServicePid) return;
+
+ if (mDevice == 0) return;
+
+ ALOGV("Camera %d: Shutting down", mCameraId);
+
+ stopPreviewL();
+
+ {
+ SharedParameters::Lock l(mParameters);
+ if (l.mParameters.state == Parameters::DISCONNECTED) return;
+ l.mParameters.state = Parameters::DISCONNECTED;
+ }
+
+ mStreamingProcessor->deletePreviewStream();
+ mStreamingProcessor->deleteRecordingStream();
+ mJpegProcessor->deleteStream();
+ mCallbackProcessor->deleteStream();
+ mZslProcessor->deleteStream();
+
+ mFrameProcessor->requestExit();
+ mCaptureSequencer->requestExit();
+ mJpegProcessor->requestExit();
+ mZslProcessor->requestExit();
+ mCallbackProcessor->requestExit();
+
+ ALOGV("Camera %d: Waiting for threads", mCameraId);
+
+ mFrameProcessor->join();
+ mCaptureSequencer->join();
+ mJpegProcessor->join();
+ mZslProcessor->join();
+ mCallbackProcessor->join();
+
+ ALOGV("Camera %d: Disconnecting device", mCameraId);
+
+ mDevice->disconnect();
+
+ mDevice.clear();
+
+ CameraService::Client::disconnect();
+}
+
+status_t Camera2Client::connect(const sp<ICameraClient>& client) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+
+ if (mClientPid != 0 && getCallingPid() != mClientPid) {
+ ALOGE("%s: Camera %d: Connection attempt from pid %d; "
+ "current locked to pid %d", __FUNCTION__,
+ mCameraId, getCallingPid(), mClientPid);
+ return BAD_VALUE;
+ }
+
+ mClientPid = getCallingPid();
+
+ mCameraClient = client;
+ mSharedCameraClient = client;
+
+ return OK;
+}
+
+status_t Camera2Client::lock() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ ALOGV("%s: Camera %d: Lock call from pid %d; current client pid %d",
+ __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
+
+ if (mClientPid == 0) {
+ mClientPid = getCallingPid();
+ return OK;
+ }
+
+ if (mClientPid != getCallingPid()) {
+ ALOGE("%s: Camera %d: Lock call from pid %d; currently locked to pid %d",
+ __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
+ return EBUSY;
+ }
+
+ return OK;
+}
+
+status_t Camera2Client::unlock() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ ALOGV("%s: Camera %d: Unlock call from pid %d; current client pid %d",
+ __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
+
+ if (mClientPid == getCallingPid()) {
+ SharedParameters::Lock l(mParameters);
+ if (l.mParameters.state == Parameters::RECORD ||
+ l.mParameters.state == Parameters::VIDEO_SNAPSHOT) {
+ ALOGD("Not allowed to unlock camera during recording.");
+ return INVALID_OPERATION;
+ }
+ mClientPid = 0;
+ mCameraClient.clear();
+ mSharedCameraClient.clear();
+ return OK;
+ }
+
+ ALOGE("%s: Camera %d: Unlock call from pid %d; currently locked to pid %d",
+ __FUNCTION__, mCameraId, getCallingPid(), mClientPid);
+ return EBUSY;
+}
+
+status_t Camera2Client::setPreviewDisplay(
+ const sp<Surface>& surface) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ sp<IBinder> binder;
+ sp<ANativeWindow> window;
+ if (surface != 0) {
+ binder = surface->asBinder();
+ window = surface;
+ }
+
+ return setPreviewWindowL(binder,window);
+}
+
+status_t Camera2Client::setPreviewTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ sp<IBinder> binder;
+ sp<ANativeWindow> window;
+ if (surfaceTexture != 0) {
+ binder = surfaceTexture->asBinder();
+ window = new SurfaceTextureClient(surfaceTexture);
+ }
+ return setPreviewWindowL(binder, window);
+}
+
+status_t Camera2Client::setPreviewWindowL(const sp<IBinder>& binder,
+ sp<ANativeWindow> window) {
+ ATRACE_CALL();
+ status_t res;
+
+ if (binder == mPreviewSurface) {
+ ALOGV("%s: Camera %d: New window is same as old window",
+ __FUNCTION__, mCameraId);
+ return NO_ERROR;
+ }
+
+ Parameters::State state;
+ {
+ SharedParameters::Lock l(mParameters);
+ state = l.mParameters.state;
+ }
+ switch (state) {
+ case Parameters::DISCONNECTED:
+ case Parameters::RECORD:
+ case Parameters::STILL_CAPTURE:
+ case Parameters::VIDEO_SNAPSHOT:
+ ALOGE("%s: Camera %d: Cannot set preview display while in state %s",
+ __FUNCTION__, mCameraId,
+ Parameters::getStateName(state));
+ return INVALID_OPERATION;
+ case Parameters::STOPPED:
+ case Parameters::WAITING_FOR_PREVIEW_WINDOW:
+ // OK
+ break;
+ case Parameters::PREVIEW:
+ // Already running preview - need to stop and create a new stream
+ mStreamingProcessor->stopStream();
+ state = Parameters::WAITING_FOR_PREVIEW_WINDOW;
+ break;
+ }
+
+ mPreviewSurface = binder;
+ res = mStreamingProcessor->setPreviewWindow(window);
+ if (res != OK) {
+ ALOGE("%s: Unable to set new preview window: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ if (state == Parameters::WAITING_FOR_PREVIEW_WINDOW) {
+ SharedParameters::Lock l(mParameters);
+ l.mParameters.state = state;
+ return startPreviewL(l.mParameters, false);
+ }
+
+ return OK;
+}
+
+void Camera2Client::setPreviewCallbackFlag(int flag) {
+ ATRACE_CALL();
+ ALOGV("%s: Camera %d: Flag 0x%x", __FUNCTION__, mCameraId, flag);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( checkPid(__FUNCTION__) != OK) return;
+
+ SharedParameters::Lock l(mParameters);
+ setPreviewCallbackFlagL(l.mParameters, flag);
+}
+
+void Camera2Client::setPreviewCallbackFlagL(Parameters &params, int flag) {
+ status_t res = OK;
+ if (flag & CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) {
+ ALOGV("%s: setting oneshot", __FUNCTION__);
+ params.previewCallbackOneShot = true;
+ }
+ if (params.previewCallbackFlags != (uint32_t)flag) {
+ params.previewCallbackFlags = flag;
+ switch(params.state) {
+ case Parameters::PREVIEW:
+ res = startPreviewL(params, true);
+ break;
+ case Parameters::RECORD:
+ case Parameters::VIDEO_SNAPSHOT:
+ res = startRecordingL(params, true);
+ break;
+ default:
+ break;
+ }
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to refresh request in state %s",
+ __FUNCTION__, mCameraId,
+ Parameters::getStateName(params.state));
+ }
+ }
+
+}
+
+status_t Camera2Client::startPreview() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+ SharedParameters::Lock l(mParameters);
+ return startPreviewL(l.mParameters, false);
+}
+
+status_t Camera2Client::startPreviewL(Parameters &params, bool restart) {
+ ATRACE_CALL();
+ status_t res;
+
+ ALOGV("%s: state == %d, restart = %d", __FUNCTION__, params.state, restart);
+
+ if ( (params.state == Parameters::PREVIEW ||
+ params.state == Parameters::RECORD ||
+ params.state == Parameters::VIDEO_SNAPSHOT)
+ && !restart) {
+ // Succeed attempt to re-enter a streaming state
+ ALOGI("%s: Camera %d: Preview already active, ignoring restart",
+ __FUNCTION__, mCameraId);
+ return OK;
+ }
+ if (params.state > Parameters::PREVIEW && !restart) {
+ ALOGE("%s: Can't start preview in state %s",
+ __FUNCTION__,
+ Parameters::getStateName(params.state));
+ return INVALID_OPERATION;
+ }
+
+ if (!mStreamingProcessor->haveValidPreviewWindow()) {
+ params.state = Parameters::WAITING_FOR_PREVIEW_WINDOW;
+ return OK;
+ }
+ params.state = Parameters::STOPPED;
+
+ res = mStreamingProcessor->updatePreviewStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update preview stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ Vector<uint8_t> outputStreams;
+ bool callbacksEnabled = params.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK;
+ if (callbacksEnabled) {
+ res = mCallbackProcessor->updateStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update callback stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ outputStreams.push(getCallbackStreamId());
+ }
+ if (params.zslMode && !params.recordingHint) {
+ res = mZslProcessor->updateStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update ZSL stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ outputStreams.push(getZslStreamId());
+ }
+
+ outputStreams.push(getPreviewStreamId());
+
+ if (!params.recordingHint) {
+ if (!restart) {
+ res = mStreamingProcessor->updatePreviewRequest(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't set up preview request: "
+ "%s (%d)", __FUNCTION__, mCameraId,
+ strerror(-res), res);
+ return res;
+ }
+ }
+ res = mStreamingProcessor->startStream(StreamingProcessor::PREVIEW,
+ outputStreams);
+ } else {
+ // With recording hint set, we're going to be operating under the
+ // assumption that the user will record video. To optimize recording
+ // startup time, create the necessary output streams for recording and
+ // video snapshot now if they don't already exist.
+ res = mJpegProcessor->updateStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't pre-configure still image "
+ "stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ if (!restart) {
+ res = mStreamingProcessor->updateRecordingRequest(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't set up preview request with "
+ "record hint: %s (%d)", __FUNCTION__, mCameraId,
+ strerror(-res), res);
+ return res;
+ }
+ }
+ res = mStreamingProcessor->startStream(StreamingProcessor::RECORD,
+ outputStreams);
+ }
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to start streaming preview: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ params.state = Parameters::PREVIEW;
+ return OK;
+}
+
+void Camera2Client::stopPreview() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return;
+ stopPreviewL();
+}
+
+void Camera2Client::stopPreviewL() {
+ ATRACE_CALL();
+ status_t res;
+ const nsecs_t kStopCaptureTimeout = 3000000000LL; // 3 seconds
+ Parameters::State state;
+ {
+ SharedParameters::Lock l(mParameters);
+ state = l.mParameters.state;
+ }
+
+ switch (state) {
+ case Parameters::DISCONNECTED:
+ ALOGE("%s: Camera %d: Call before initialized",
+ __FUNCTION__, mCameraId);
+ break;
+ case Parameters::STOPPED:
+ case Parameters::VIDEO_SNAPSHOT:
+ case Parameters::STILL_CAPTURE:
+ mCaptureSequencer->waitUntilIdle(kStopCaptureTimeout);
+ // no break
+ case Parameters::RECORD:
+ case Parameters::PREVIEW:
+ mStreamingProcessor->stopStream();
+ res = mDevice->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Waiting to stop streaming failed: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ }
+ // no break
+ case Parameters::WAITING_FOR_PREVIEW_WINDOW: {
+ SharedParameters::Lock l(mParameters);
+ l.mParameters.state = Parameters::STOPPED;
+ commandStopFaceDetectionL(l.mParameters);
+ break;
+ }
+ default:
+ ALOGE("%s: Camera %d: Unknown state %d", __FUNCTION__, mCameraId,
+ state);
+ }
+}
+
+bool Camera2Client::previewEnabled() {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return false;
+
+ SharedParameters::Lock l(mParameters);
+ return l.mParameters.state == Parameters::PREVIEW;
+}
+
+status_t Camera2Client::storeMetaDataInBuffers(bool enabled) {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ SharedParameters::Lock l(mParameters);
+ switch (l.mParameters.state) {
+ case Parameters::RECORD:
+ case Parameters::VIDEO_SNAPSHOT:
+ ALOGE("%s: Camera %d: Can't be called in state %s",
+ __FUNCTION__, mCameraId,
+ Parameters::getStateName(l.mParameters.state));
+ return INVALID_OPERATION;
+ default:
+ // OK
+ break;
+ }
+
+ l.mParameters.storeMetadataInBuffers = enabled;
+
+ return OK;
+}
+
+status_t Camera2Client::startRecording() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+ SharedParameters::Lock l(mParameters);
+
+ return startRecordingL(l.mParameters, false);
+}
+
+status_t Camera2Client::startRecordingL(Parameters &params, bool restart) {
+ status_t res;
+
+ ALOGV("%s: state == %d, restart = %d", __FUNCTION__, params.state, restart);
+
+ switch (params.state) {
+ case Parameters::STOPPED:
+ res = startPreviewL(params, false);
+ if (res != OK) return res;
+ break;
+ case Parameters::PREVIEW:
+ // Ready to go
+ break;
+ case Parameters::RECORD:
+ case Parameters::VIDEO_SNAPSHOT:
+ // OK to call this when recording is already on, just skip unless
+ // we're looking to restart
+ if (!restart) return OK;
+ break;
+ default:
+ ALOGE("%s: Camera %d: Can't start recording in state %s",
+ __FUNCTION__, mCameraId,
+ Parameters::getStateName(params.state));
+ return INVALID_OPERATION;
+ };
+
+ if (!params.storeMetadataInBuffers) {
+ ALOGE("%s: Camera %d: Recording only supported in metadata mode, but "
+ "non-metadata recording mode requested!", __FUNCTION__,
+ mCameraId);
+ return INVALID_OPERATION;
+ }
+
+ if (!restart) {
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+ mStreamingProcessor->updateRecordingRequest(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update recording request: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ }
+
+ res = mStreamingProcessor->updateRecordingStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update recording stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ Vector<uint8_t> outputStreams;
+ bool callbacksEnabled = params.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK;
+ if (callbacksEnabled) {
+ res = mCallbackProcessor->updateStream(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update callback stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ outputStreams.push(getCallbackStreamId());
+ }
+ outputStreams.push(getPreviewStreamId());
+ outputStreams.push(getRecordingStreamId());
+
+ res = mStreamingProcessor->startStream(StreamingProcessor::RECORD,
+ outputStreams);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to start recording stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ if (params.state < Parameters::RECORD) {
+ params.state = Parameters::RECORD;
+ }
+
+ return OK;
+}
+
+void Camera2Client::stopRecording() {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock icl(mICameraLock);
+ SharedParameters::Lock l(mParameters);
+
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return;
+
+ switch (l.mParameters.state) {
+ case Parameters::RECORD:
+ // OK to stop
+ break;
+ case Parameters::STOPPED:
+ case Parameters::PREVIEW:
+ case Parameters::STILL_CAPTURE:
+ case Parameters::VIDEO_SNAPSHOT:
+ default:
+ ALOGE("%s: Camera %d: Can't stop recording in state %s",
+ __FUNCTION__, mCameraId,
+ Parameters::getStateName(l.mParameters.state));
+ return;
+ };
+
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+
+ res = startPreviewL(l.mParameters, true);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to return to preview",
+ __FUNCTION__, mCameraId);
+ }
+}
+
+bool Camera2Client::recordingEnabled() {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+
+ if ( checkPid(__FUNCTION__) != OK) return false;
+
+ return recordingEnabledL();
+}
+
+bool Camera2Client::recordingEnabledL() {
+ ATRACE_CALL();
+ SharedParameters::Lock l(mParameters);
+
+ return (l.mParameters.state == Parameters::RECORD
+ || l.mParameters.state == Parameters::VIDEO_SNAPSHOT);
+}
+
+void Camera2Client::releaseRecordingFrame(const sp<IMemory>& mem) {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ if ( checkPid(__FUNCTION__) != OK) return;
+
+ mStreamingProcessor->releaseRecordingFrame(mem);
+}
+
+status_t Camera2Client::autoFocus() {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ ALOGV("%s: Camera %d", __FUNCTION__, mCameraId);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ int triggerId;
+ bool notifyImmediately = false;
+ bool notifySuccess = false;
+ {
+ SharedParameters::Lock l(mParameters);
+ if (l.mParameters.state < Parameters::PREVIEW) {
+ return INVALID_OPERATION;
+ }
+
+ /**
+ * If the camera does not support auto-focus, it is a no-op and
+ * onAutoFocus(boolean, Camera) callback will be called immediately
+ * with a fake value of success set to true.
+ */
+ if (l.mParameters.focusMode == Parameters::FOCUS_MODE_FIXED) {
+ notifyImmediately = true;
+ notifySuccess = true;
+ }
+ /**
+ * If we're in CAF mode, and AF has already been locked, just fire back
+ * the callback right away; the HAL would not send a notification since
+ * no state change would happen on a AF trigger.
+ */
+ if ( (l.mParameters.focusMode == Parameters::FOCUS_MODE_CONTINUOUS_PICTURE ||
+ l.mParameters.focusMode == Parameters::FOCUS_MODE_CONTINUOUS_VIDEO) &&
+ l.mParameters.focusState == ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED ) {
+ notifyImmediately = true;
+ notifySuccess = true;
+ }
+ /**
+ * Send immediate notification back to client
+ */
+ if (notifyImmediately) {
+ SharedCameraClient::Lock l(mSharedCameraClient);
+ if (l.mCameraClient != 0) {
+ l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS,
+ notifySuccess ? 1 : 0, 0);
+ }
+ return OK;
+ }
+ /**
+ * Handle quirk mode for AF in scene modes
+ */
+ if (l.mParameters.quirks.triggerAfWithAuto &&
+ l.mParameters.sceneMode != ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED &&
+ l.mParameters.focusMode != Parameters::FOCUS_MODE_AUTO &&
+ !l.mParameters.focusingAreas[0].isEmpty()) {
+ ALOGV("%s: Quirk: Switching from focusMode %d to AUTO",
+ __FUNCTION__, l.mParameters.focusMode);
+ l.mParameters.shadowFocusMode = l.mParameters.focusMode;
+ l.mParameters.focusMode = Parameters::FOCUS_MODE_AUTO;
+ updateRequests(l.mParameters);
+ }
+
+ l.mParameters.currentAfTriggerId = ++l.mParameters.afTriggerCounter;
+ triggerId = l.mParameters.currentAfTriggerId;
+ }
+ syncWithDevice();
+
+ mDevice->triggerAutofocus(triggerId);
+
+ return OK;
+}
+
+status_t Camera2Client::cancelAutoFocus() {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ ALOGV("%s: Camera %d", __FUNCTION__, mCameraId);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ int triggerId;
+ {
+ SharedParameters::Lock l(mParameters);
+ triggerId = ++l.mParameters.afTriggerCounter;
+
+ // When using triggerAfWithAuto quirk, may need to reset focus mode to
+ // the real state at this point. No need to cancel explicitly if
+ // changing the AF mode.
+ if (l.mParameters.shadowFocusMode != Parameters::FOCUS_MODE_INVALID) {
+ ALOGV("%s: Quirk: Restoring focus mode to %d", __FUNCTION__,
+ l.mParameters.shadowFocusMode);
+ l.mParameters.focusMode = l.mParameters.shadowFocusMode;
+ l.mParameters.shadowFocusMode = Parameters::FOCUS_MODE_INVALID;
+ updateRequests(l.mParameters);
+
+ return OK;
+ }
+ }
+ syncWithDevice();
+
+ mDevice->triggerCancelAutofocus(triggerId);
+
+ return OK;
+}
+
+status_t Camera2Client::takePicture(int msgType) {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ {
+ SharedParameters::Lock l(mParameters);
+ switch (l.mParameters.state) {
+ case Parameters::DISCONNECTED:
+ case Parameters::STOPPED:
+ case Parameters::WAITING_FOR_PREVIEW_WINDOW:
+ ALOGE("%s: Camera %d: Cannot take picture without preview enabled",
+ __FUNCTION__, mCameraId);
+ return INVALID_OPERATION;
+ case Parameters::PREVIEW:
+ // Good to go for takePicture
+ res = commandStopFaceDetectionL(l.mParameters);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to stop face detection for still capture",
+ __FUNCTION__, mCameraId);
+ return res;
+ }
+ l.mParameters.state = Parameters::STILL_CAPTURE;
+ break;
+ case Parameters::RECORD:
+ // Good to go for video snapshot
+ l.mParameters.state = Parameters::VIDEO_SNAPSHOT;
+ break;
+ case Parameters::STILL_CAPTURE:
+ case Parameters::VIDEO_SNAPSHOT:
+ ALOGE("%s: Camera %d: Already taking a picture",
+ __FUNCTION__, mCameraId);
+ return INVALID_OPERATION;
+ }
+
+ ALOGV("%s: Camera %d: Starting picture capture", __FUNCTION__, mCameraId);
+
+ res = mJpegProcessor->updateStream(l.mParameters);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't set up still image stream: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ }
+
+ // Need HAL to have correct settings before (possibly) triggering precapture
+ syncWithDevice();
+
+ res = mCaptureSequencer->startCapture(msgType);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to start capture: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ }
+
+ return res;
+}
+
+status_t Camera2Client::setParameters(const String8& params) {
+ ATRACE_CALL();
+ ALOGV("%s: Camera %d", __FUNCTION__, mCameraId);
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ SharedParameters::Lock l(mParameters);
+
+ res = l.mParameters.set(params);
+ if (res != OK) return res;
+
+ res = updateRequests(l.mParameters);
+
+ return res;
+}
+
+String8 Camera2Client::getParameters() const {
+ ATRACE_CALL();
+ ALOGV("%s: Camera %d", __FUNCTION__, mCameraId);
+ Mutex::Autolock icl(mICameraLock);
+ if ( checkPid(__FUNCTION__) != OK) return String8();
+
+ SharedParameters::ReadLock l(mParameters);
+
+ return l.mParameters.get();
+}
+
+status_t Camera2Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
+ ATRACE_CALL();
+ Mutex::Autolock icl(mICameraLock);
+ status_t res;
+ if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+ ALOGV("%s: Camera %d: Command %d (%d, %d)", __FUNCTION__, mCameraId,
+ cmd, arg1, arg2);
+
+ switch (cmd) {
+ case CAMERA_CMD_START_SMOOTH_ZOOM:
+ return commandStartSmoothZoomL();
+ case CAMERA_CMD_STOP_SMOOTH_ZOOM:
+ return commandStopSmoothZoomL();
+ case CAMERA_CMD_SET_DISPLAY_ORIENTATION:
+ return commandSetDisplayOrientationL(arg1);
+ case CAMERA_CMD_ENABLE_SHUTTER_SOUND:
+ return commandEnableShutterSoundL(arg1 == 1);
+ case CAMERA_CMD_PLAY_RECORDING_SOUND:
+ return commandPlayRecordingSoundL();
+ case CAMERA_CMD_START_FACE_DETECTION:
+ return commandStartFaceDetectionL(arg1);
+ case CAMERA_CMD_STOP_FACE_DETECTION: {
+ SharedParameters::Lock l(mParameters);
+ return commandStopFaceDetectionL(l.mParameters);
+ }
+ case CAMERA_CMD_ENABLE_FOCUS_MOVE_MSG:
+ return commandEnableFocusMoveMsgL(arg1 == 1);
+ case CAMERA_CMD_PING:
+ return commandPingL();
+ case CAMERA_CMD_SET_VIDEO_BUFFER_COUNT:
+ return commandSetVideoBufferCountL(arg1);
+ default:
+ ALOGE("%s: Unknown command %d (arguments %d, %d)",
+ __FUNCTION__, cmd, arg1, arg2);
+ return BAD_VALUE;
+ }
+}
+
+status_t Camera2Client::commandStartSmoothZoomL() {
+ ALOGE("%s: Unimplemented!", __FUNCTION__);
+ return OK;
+}
+
+status_t Camera2Client::commandStopSmoothZoomL() {
+ ALOGE("%s: Unimplemented!", __FUNCTION__);
+ return OK;
+}
+
+status_t Camera2Client::commandSetDisplayOrientationL(int degrees) {
+ int transform = Parameters::degToTransform(degrees,
+ mCameraFacing == CAMERA_FACING_FRONT);
+ if (transform == -1) {
+ ALOGE("%s: Camera %d: Error setting %d as display orientation value",
+ __FUNCTION__, mCameraId, degrees);
+ return BAD_VALUE;
+ }
+ SharedParameters::Lock l(mParameters);
+ if (transform != l.mParameters.previewTransform &&
+ getPreviewStreamId() != NO_STREAM) {
+ mDevice->setStreamTransform(getPreviewStreamId(), transform);
+ }
+ l.mParameters.previewTransform = transform;
+ return OK;
+}
+
+status_t Camera2Client::commandEnableShutterSoundL(bool enable) {
+ SharedParameters::Lock l(mParameters);
+ if (enable) {
+ l.mParameters.playShutterSound = true;
+ return OK;
+ }
+
+ // Disabling shutter sound may not be allowed. In that case only
+ // allow the mediaserver process to disable the sound.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.camera.sound.forced", value, "0");
+ if (strncmp(value, "0", 2) != 0) {
+ // Disabling shutter sound is not allowed. Deny if the current
+ // process is not mediaserver.
+ if (getCallingPid() != getpid()) {
+ ALOGE("Failed to disable shutter sound. Permission denied (pid %d)",
+ getCallingPid());
+ return PERMISSION_DENIED;
+ }
+ }
+
+ l.mParameters.playShutterSound = false;
+ return OK;
+}
+
+status_t Camera2Client::commandPlayRecordingSoundL() {
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+ return OK;
+}
+
+status_t Camera2Client::commandStartFaceDetectionL(int type) {
+ ALOGV("%s: Camera %d: Starting face detection",
+ __FUNCTION__, mCameraId);
+ status_t res;
+ SharedParameters::Lock l(mParameters);
+ switch (l.mParameters.state) {
+ case Parameters::DISCONNECTED:
+ case Parameters::STOPPED:
+ case Parameters::WAITING_FOR_PREVIEW_WINDOW:
+ case Parameters::STILL_CAPTURE:
+ ALOGE("%s: Camera %d: Cannot start face detection without preview active",
+ __FUNCTION__, mCameraId);
+ return INVALID_OPERATION;
+ case Parameters::PREVIEW:
+ case Parameters::RECORD:
+ case Parameters::VIDEO_SNAPSHOT:
+ // Good to go for starting face detect
+ break;
+ }
+ // Ignoring type
+ if (l.mParameters.fastInfo.bestFaceDetectMode ==
+ ANDROID_STATISTICS_FACE_DETECT_MODE_OFF) {
+ ALOGE("%s: Camera %d: Face detection not supported",
+ __FUNCTION__, mCameraId);
+ return INVALID_OPERATION;
+ }
+ if (l.mParameters.enableFaceDetect) return OK;
+
+ l.mParameters.enableFaceDetect = true;
+
+ res = updateRequests(l.mParameters);
+
+ return res;
+}
+
+status_t Camera2Client::commandStopFaceDetectionL(Parameters &params) {
+ status_t res = OK;
+ ALOGV("%s: Camera %d: Stopping face detection",
+ __FUNCTION__, mCameraId);
+
+ if (!params.enableFaceDetect) return OK;
+
+ params.enableFaceDetect = false;
+
+ if (params.state == Parameters::PREVIEW
+ || params.state == Parameters::RECORD
+ || params.state == Parameters::VIDEO_SNAPSHOT) {
+ res = updateRequests(params);
+ }
+
+ return res;
+}
+
+status_t Camera2Client::commandEnableFocusMoveMsgL(bool enable) {
+ SharedParameters::Lock l(mParameters);
+ l.mParameters.enableFocusMoveMessages = enable;
+
+ return OK;
+}
+
+status_t Camera2Client::commandPingL() {
+ // Always ping back if access is proper and device is alive
+ SharedParameters::Lock l(mParameters);
+ if (l.mParameters.state != Parameters::DISCONNECTED) {
+ return OK;
+ } else {
+ return NO_INIT;
+ }
+}
+
+status_t Camera2Client::commandSetVideoBufferCountL(size_t count) {
+ if (recordingEnabledL()) {
+ ALOGE("%s: Camera %d: Error setting video buffer count after "
+ "recording was started", __FUNCTION__, mCameraId);
+ return INVALID_OPERATION;
+ }
+
+ return mStreamingProcessor->setRecordingBufferCount(count);
+}
+
+/** Device-related methods */
+
+void Camera2Client::notifyError(int errorCode, int arg1, int arg2) {
+ ALOGE("Error condition %d reported by HAL, arguments %d, %d", errorCode, arg1, arg2);
+}
+
+void Camera2Client::notifyShutter(int frameNumber, nsecs_t timestamp) {
+ ALOGV("%s: Shutter notification for frame %d at time %lld", __FUNCTION__,
+ frameNumber, timestamp);
+}
+
+void Camera2Client::notifyAutoFocus(uint8_t newState, int triggerId) {
+ ALOGV("%s: Autofocus state now %d, last trigger %d",
+ __FUNCTION__, newState, triggerId);
+ bool sendCompletedMessage = false;
+ bool sendMovingMessage = false;
+
+ bool success = false;
+ bool afInMotion = false;
+ {
+ SharedParameters::Lock l(mParameters);
+ l.mParameters.focusState = newState;
+ switch (l.mParameters.focusMode) {
+ case Parameters::FOCUS_MODE_AUTO:
+ case Parameters::FOCUS_MODE_MACRO:
+ // Don't send notifications upstream if they're not for the current AF
+ // trigger. For example, if cancel was called in between, or if we
+ // already sent a notification about this AF call.
+ if (triggerId != l.mParameters.currentAfTriggerId) break;
+ switch (newState) {
+ case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED:
+ success = true;
+ // no break
+ case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
+ sendCompletedMessage = true;
+ l.mParameters.currentAfTriggerId = -1;
+ break;
+ case ANDROID_CONTROL_AF_STATE_ACTIVE_SCAN:
+ // Just starting focusing, ignore
+ break;
+ case ANDROID_CONTROL_AF_STATE_INACTIVE:
+ case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN:
+ case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED:
+ default:
+ // Unexpected in AUTO/MACRO mode
+ ALOGE("%s: Unexpected AF state transition in AUTO/MACRO mode: %d",
+ __FUNCTION__, newState);
+ break;
+ }
+ break;
+ case Parameters::FOCUS_MODE_CONTINUOUS_VIDEO:
+ case Parameters::FOCUS_MODE_CONTINUOUS_PICTURE:
+ switch (newState) {
+ case ANDROID_CONTROL_AF_STATE_FOCUSED_LOCKED:
+ success = true;
+ // no break
+ case ANDROID_CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
+ // Don't send notifications upstream if they're not for
+ // the current AF trigger. For example, if cancel was
+ // called in between, or if we already sent a
+ // notification about this AF call.
+ // Send both a 'AF done' callback and a 'AF move' callback
+ if (triggerId != l.mParameters.currentAfTriggerId) break;
+ sendCompletedMessage = true;
+ afInMotion = false;
+ if (l.mParameters.enableFocusMoveMessages &&
+ l.mParameters.afInMotion) {
+ sendMovingMessage = true;
+ }
+ l.mParameters.currentAfTriggerId = -1;
+ break;
+ case ANDROID_CONTROL_AF_STATE_INACTIVE:
+ // Cancel was called, or we switched state; care if
+ // currently moving
+ afInMotion = false;
+ if (l.mParameters.enableFocusMoveMessages &&
+ l.mParameters.afInMotion) {
+ sendMovingMessage = true;
+ }
+ break;
+ case ANDROID_CONTROL_AF_STATE_PASSIVE_SCAN:
+ // Start passive scan, inform upstream
+ afInMotion = true;
+ // no break
+ case ANDROID_CONTROL_AF_STATE_PASSIVE_FOCUSED:
+ // Stop passive scan, inform upstream
+ if (l.mParameters.enableFocusMoveMessages) {
+ sendMovingMessage = true;
+ }
+ break;
+ }
+ l.mParameters.afInMotion = afInMotion;
+ break;
+ case Parameters::FOCUS_MODE_EDOF:
+ case Parameters::FOCUS_MODE_INFINITY:
+ case Parameters::FOCUS_MODE_FIXED:
+ default:
+ if (newState != ANDROID_CONTROL_AF_STATE_INACTIVE) {
+ ALOGE("%s: Unexpected AF state change %d "
+ "(ID %d) in focus mode %d",
+ __FUNCTION__, newState, triggerId,
+ l.mParameters.focusMode);
+ }
+ }
+ }
+ if (sendMovingMessage) {
+ SharedCameraClient::Lock l(mSharedCameraClient);
+ if (l.mCameraClient != 0) {
+ l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS_MOVE,
+ afInMotion ? 1 : 0, 0);
+ }
+ }
+ if (sendCompletedMessage) {
+ SharedCameraClient::Lock l(mSharedCameraClient);
+ if (l.mCameraClient != 0) {
+ l.mCameraClient->notifyCallback(CAMERA_MSG_FOCUS,
+ success ? 1 : 0, 0);
+ }
+ }
+}
+
+void Camera2Client::notifyAutoExposure(uint8_t newState, int triggerId) {
+ ALOGV("%s: Autoexposure state now %d, last trigger %d",
+ __FUNCTION__, newState, triggerId);
+ mCaptureSequencer->notifyAutoExposure(newState, triggerId);
+}
+
+void Camera2Client::notifyAutoWhitebalance(uint8_t newState, int triggerId) {
+ ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
+ __FUNCTION__, newState, triggerId);
+}
+
+int Camera2Client::getCameraId() const {
+ return mCameraId;
+}
+
+const sp<Camera2Device>& Camera2Client::getCameraDevice() {
+ return mDevice;
+}
+
+const sp<CameraService>& Camera2Client::getCameraService() {
+ return mCameraService;
+}
+
+camera2::SharedParameters& Camera2Client::getParameters() {
+ return mParameters;
+}
+
+int Camera2Client::getPreviewStreamId() const {
+ return mStreamingProcessor->getPreviewStreamId();
+}
+
+int Camera2Client::getCaptureStreamId() const {
+ return mJpegProcessor->getStreamId();
+}
+
+int Camera2Client::getCallbackStreamId() const {
+ return mCallbackProcessor->getStreamId();
+}
+
+int Camera2Client::getRecordingStreamId() const {
+ return mStreamingProcessor->getRecordingStreamId();
+}
+
+int Camera2Client::getZslStreamId() const {
+ return mZslProcessor->getStreamId();
+}
+
+status_t Camera2Client::registerFrameListener(int32_t minId, int32_t maxId,
+ wp<camera2::FrameProcessor::FilteredListener> listener) {
+ return mFrameProcessor->registerListener(minId, maxId, listener);
+}
+
+status_t Camera2Client::removeFrameListener(int32_t minId, int32_t maxId,
+ wp<camera2::FrameProcessor::FilteredListener> listener) {
+ return mFrameProcessor->removeListener(minId, maxId, listener);
+}
+
+status_t Camera2Client::stopStream() {
+ return mStreamingProcessor->stopStream();
+}
+
+Camera2Client::SharedCameraClient::Lock::Lock(SharedCameraClient &client):
+ mCameraClient(client.mCameraClient),
+ mSharedClient(client) {
+ mSharedClient.mCameraClientLock.lock();
+}
+
+Camera2Client::SharedCameraClient::Lock::~Lock() {
+ mSharedClient.mCameraClientLock.unlock();
+}
+
+Camera2Client::SharedCameraClient::SharedCameraClient(const sp<ICameraClient>&client):
+ mCameraClient(client) {
+}
+
+Camera2Client::SharedCameraClient& Camera2Client::SharedCameraClient::operator=(
+ const sp<ICameraClient>&client) {
+ Mutex::Autolock l(mCameraClientLock);
+ mCameraClient = client;
+ return *this;
+}
+
+void Camera2Client::SharedCameraClient::clear() {
+ Mutex::Autolock l(mCameraClientLock);
+ mCameraClient.clear();
+}
+
+const int32_t Camera2Client::kPreviewRequestIdStart;
+const int32_t Camera2Client::kPreviewRequestIdEnd;
+const int32_t Camera2Client::kRecordingRequestIdStart;
+const int32_t Camera2Client::kRecordingRequestIdEnd;
+const int32_t Camera2Client::kCaptureRequestIdStart;
+const int32_t Camera2Client::kCaptureRequestIdEnd;
+
+/** Utility methods */
+
+status_t Camera2Client::updateRequests(Parameters &params) {
+ status_t res;
+
+ ALOGV("%s: Camera %d: state = %d", __FUNCTION__, getCameraId(), params.state);
+
+ res = mStreamingProcessor->incrementStreamingIds();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to increment request IDs: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ res = mStreamingProcessor->updatePreviewRequest(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update preview request: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ res = mStreamingProcessor->updateRecordingRequest(params);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update recording request: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+
+ if (params.state == Parameters::PREVIEW) {
+ res = startPreviewL(params, true);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error streaming new preview request: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ } else if (params.state == Parameters::RECORD ||
+ params.state == Parameters::VIDEO_SNAPSHOT) {
+ res = startRecordingL(params, true);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error streaming new record request: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ return res;
+ }
+ }
+ return res;
+}
+
+
+size_t Camera2Client::calculateBufferSize(int width, int height,
+ int format, int stride) {
+ switch (format) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP: // NV16
+ return width * height * 2;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP: // NV21
+ return width * height * 3 / 2;
+ case HAL_PIXEL_FORMAT_YCbCr_422_I: // YUY2
+ return width * height * 2;
+ case HAL_PIXEL_FORMAT_YV12: { // YV12
+ size_t ySize = stride * height;
+ size_t uvStride = (stride / 2 + 0xF) & ~0xF;
+ size_t uvSize = uvStride * height / 2;
+ return ySize + uvSize * 2;
+ }
+ case HAL_PIXEL_FORMAT_RGB_565:
+ return width * height * 2;
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ return width * height * 4;
+ case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ return width * height * 2;
+ default:
+ ALOGE("%s: Unknown preview format: %x",
+ __FUNCTION__, format);
+ return 0;
+ }
+}
+
+status_t Camera2Client::syncWithDevice() {
+ ATRACE_CALL();
+ const nsecs_t kMaxSyncTimeout = 500000000; // 500 ms
+ status_t res;
+
+ int32_t activeRequestId = mStreamingProcessor->getActiveRequestId();
+ if (activeRequestId == 0) return OK;
+
+ res = mDevice->waitUntilRequestReceived(activeRequestId, kMaxSyncTimeout);
+ if (res == TIMED_OUT) {
+ ALOGE("%s: Camera %d: Timed out waiting sync with HAL",
+ __FUNCTION__, mCameraId);
+ } else if (res != OK) {
+ ALOGE("%s: Camera %d: Error while waiting to sync with HAL",
+ __FUNCTION__, mCameraId);
+ }
+ return res;
+}
+
+} // namespace android
diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h
new file mode 100644
index 00000000..55ead024
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Client.h
@@ -0,0 +1,228 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2CLIENT_H
+
+#include "Camera2Device.h"
+#include "CameraService.h"
+#include "camera2/Parameters.h"
+#include "camera2/FrameProcessor.h"
+#include "camera2/StreamingProcessor.h"
+#include "camera2/JpegProcessor.h"
+#include "camera2/ZslProcessor.h"
+#include "camera2/CaptureSequencer.h"
+#include "camera2/CallbackProcessor.h"
+
+namespace android {
+
+class IMemory;
+/**
+ * Implements the android.hardware.camera API on top of
+ * camera device HAL version 2.
+ */
+class Camera2Client :
+ public CameraService::Client,
+ public Camera2Device::NotificationListener
+{
+public:
+ /**
+ * ICamera interface (see ICamera for details)
+ */
+
+ virtual void disconnect();
+ virtual status_t connect(const sp<ICameraClient>& client);
+ virtual status_t lock();
+ virtual status_t unlock();
+ virtual status_t setPreviewDisplay(const sp<Surface>& surface);
+ virtual status_t setPreviewTexture(
+ const sp<ISurfaceTexture>& surfaceTexture);
+ virtual void setPreviewCallbackFlag(int flag);
+ virtual status_t startPreview();
+ virtual void stopPreview();
+ virtual bool previewEnabled();
+ virtual status_t storeMetaDataInBuffers(bool enabled);
+ virtual status_t startRecording();
+ virtual void stopRecording();
+ virtual bool recordingEnabled();
+ virtual void releaseRecordingFrame(const sp<IMemory>& mem);
+ virtual status_t autoFocus();
+ virtual status_t cancelAutoFocus();
+ virtual status_t takePicture(int msgType);
+ virtual status_t setParameters(const String8& params);
+ virtual String8 getParameters() const;
+ virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
+
+ /**
+ * Interface used by CameraService
+ */
+
+ Camera2Client(const sp<CameraService>& cameraService,
+ const sp<ICameraClient>& cameraClient,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid);
+ virtual ~Camera2Client();
+
+ status_t initialize(camera_module_t *module);
+
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
+ /**
+ * Interface used by Camera2Device
+ */
+
+ virtual void notifyError(int errorCode, int arg1, int arg2);
+ virtual void notifyShutter(int frameNumber, nsecs_t timestamp);
+ virtual void notifyAutoFocus(uint8_t newState, int triggerId);
+ virtual void notifyAutoExposure(uint8_t newState, int triggerId);
+ virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId);
+
+ /**
+ * Interface used by independent components of Camera2Client.
+ */
+
+ int getCameraId() const;
+ const sp<Camera2Device>& getCameraDevice();
+ const sp<CameraService>& getCameraService();
+ camera2::SharedParameters& getParameters();
+
+ int getPreviewStreamId() const;
+ int getCaptureStreamId() const;
+ int getCallbackStreamId() const;
+ int getRecordingStreamId() const;
+ int getZslStreamId() const;
+
+ status_t registerFrameListener(int32_t minId, int32_t maxId,
+ wp<camera2::FrameProcessor::FilteredListener> listener);
+ status_t removeFrameListener(int32_t minId, int32_t maxId,
+ wp<camera2::FrameProcessor::FilteredListener> listener);
+
+ status_t stopStream();
+
+ // Simple class to ensure that access to ICameraClient is serialized by
+ // requiring mCameraClientLock to be locked before access to mCameraClient
+ // is possible.
+ class SharedCameraClient {
+ public:
+ class Lock {
+ public:
+ Lock(SharedCameraClient &client);
+ ~Lock();
+ sp<ICameraClient> &mCameraClient;
+ private:
+ SharedCameraClient &mSharedClient;
+ };
+ SharedCameraClient(const sp<ICameraClient>& client);
+ SharedCameraClient& operator=(const sp<ICameraClient>& client);
+ void clear();
+ private:
+ sp<ICameraClient> mCameraClient;
+ mutable Mutex mCameraClientLock;
+ } mSharedCameraClient;
+
+ static size_t calculateBufferSize(int width, int height,
+ int format, int stride);
+
+ static const int32_t kPreviewRequestIdStart = 10000000;
+ static const int32_t kPreviewRequestIdEnd = 20000000;
+
+ static const int32_t kRecordingRequestIdStart = 20000000;
+ static const int32_t kRecordingRequestIdEnd = 30000000;
+
+ static const int32_t kCaptureRequestIdStart = 30000000;
+ static const int32_t kCaptureRequestIdEnd = 40000000;
+
+private:
+ /** ICamera interface-related private members */
+
+ // Mutex that must be locked by methods implementing the ICamera interface.
+ // Ensures serialization between incoming ICamera calls. All methods below
+ // that append 'L' to the name assume that mICameraLock is locked when
+ // they're called
+ mutable Mutex mICameraLock;
+
+ typedef camera2::Parameters Parameters;
+ typedef camera2::CameraMetadata CameraMetadata;
+
+ status_t setPreviewWindowL(const sp<IBinder>& binder,
+ sp<ANativeWindow> window);
+ status_t startPreviewL(Parameters &params, bool restart);
+ void stopPreviewL();
+ status_t startRecordingL(Parameters &params, bool restart);
+ bool recordingEnabledL();
+
+ // Individual commands for sendCommand()
+ status_t commandStartSmoothZoomL();
+ status_t commandStopSmoothZoomL();
+ status_t commandSetDisplayOrientationL(int degrees);
+ status_t commandEnableShutterSoundL(bool enable);
+ status_t commandPlayRecordingSoundL();
+ status_t commandStartFaceDetectionL(int type);
+ status_t commandStopFaceDetectionL(Parameters &params);
+ status_t commandEnableFocusMoveMsgL(bool enable);
+ status_t commandPingL();
+ status_t commandSetVideoBufferCountL(size_t count);
+
+ // Current camera device configuration
+ camera2::SharedParameters mParameters;
+
+ /** Camera device-related private members */
+
+ void setPreviewCallbackFlagL(Parameters &params, int flag);
+ status_t updateRequests(Parameters &params);
+
+ // Used with stream IDs
+ static const int NO_STREAM = -1;
+
+ sp<camera2::FrameProcessor> mFrameProcessor;
+
+ /* Preview/Recording related members */
+
+ sp<IBinder> mPreviewSurface;
+ sp<camera2::StreamingProcessor> mStreamingProcessor;
+
+ /** Preview callback related members */
+
+ sp<camera2::CallbackProcessor> mCallbackProcessor;
+
+ /* Still image capture related members */
+
+ sp<camera2::CaptureSequencer> mCaptureSequencer;
+ sp<camera2::JpegProcessor> mJpegProcessor;
+ sp<camera2::ZslProcessor> mZslProcessor;
+
+ /** Notification-related members */
+
+ bool mAfInMotion;
+
+ /** Camera2Device instance wrapping HAL2 entry */
+
+ sp<Camera2Device> mDevice;
+
+ /** Utility members */
+
+ // Wait until the camera device has received the latest control settings
+ status_t syncWithDevice();
+
+ // Verify that caller is the owner of the camera
+ status_t checkPid(const char *checkLocation) const;
+};
+
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp
new file mode 100644
index 00000000..d6445c1b
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Device.cpp
@@ -0,0 +1,1513 @@
+/*
+ * 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 "Camera2-Device"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+//#define LOG_NNDEBUG 0 // Per-frame verbose logging
+
+#ifdef LOG_NNDEBUG
+#define ALOGVV(...) ALOGV(__VA_ARGS__)
+#else
+#define ALOGVV(...) ((void)0)
+#endif
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <utils/Timers.h>
+#include "Camera2Device.h"
+
+namespace android {
+
+Camera2Device::Camera2Device(int id):
+ mId(id),
+ mDevice(NULL)
+{
+ ATRACE_CALL();
+ ALOGV("%s: Created device for camera %d", __FUNCTION__, id);
+}
+
+Camera2Device::~Camera2Device()
+{
+ ATRACE_CALL();
+ ALOGV("%s: Tearing down for camera id %d", __FUNCTION__, mId);
+ disconnect();
+}
+
+status_t Camera2Device::initialize(camera_module_t *module)
+{
+ ATRACE_CALL();
+ ALOGV("%s: Initializing device for camera %d", __FUNCTION__, mId);
+ if (mDevice != NULL) {
+ ALOGE("%s: Already initialized!", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ status_t res;
+ char name[10];
+ snprintf(name, sizeof(name), "%d", mId);
+
+ camera2_device_t *device;
+
+ res = module->common.methods->open(&module->common, name,
+ reinterpret_cast<hw_device_t**>(&device));
+
+ if (res != OK) {
+ ALOGE("%s: Could not open camera %d: %s (%d)", __FUNCTION__,
+ mId, strerror(-res), res);
+ return res;
+ }
+
+ if (device->common.version != CAMERA_DEVICE_API_VERSION_2_0) {
+ ALOGE("%s: Could not open camera %d: "
+ "Camera device is not version %x, reports %x instead",
+ __FUNCTION__, mId, CAMERA_DEVICE_API_VERSION_2_0,
+ device->common.version);
+ device->common.close(&device->common);
+ return BAD_VALUE;
+ }
+
+ camera_info info;
+ res = module->get_camera_info(mId, &info);
+ if (res != OK ) return res;
+
+ if (info.device_version != device->common.version) {
+ ALOGE("%s: HAL reporting mismatched camera_info version (%x)"
+ " and device version (%x).", __FUNCTION__,
+ device->common.version, info.device_version);
+ device->common.close(&device->common);
+ return BAD_VALUE;
+ }
+
+ res = mRequestQueue.setConsumerDevice(device);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to connect request queue to device: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+ res = mFrameQueue.setProducerDevice(device);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to connect frame queue to device: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+
+ res = device->ops->get_metadata_vendor_tag_ops(device, &mVendorTagOps);
+ if (res != OK ) {
+ ALOGE("%s: Camera %d: Unable to retrieve tag ops from device: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+ res = set_camera_metadata_vendor_tag_ops(mVendorTagOps);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set tag ops: %s (%d)",
+ __FUNCTION__, mId, strerror(-res), res);
+ device->common.close(&device->common);
+ return res;
+ }
+ res = device->ops->set_notify_callback(device, notificationCallback,
+ NULL);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to initialize notification callback!",
+ __FUNCTION__, mId);
+ device->common.close(&device->common);
+ return res;
+ }
+
+ mDeviceInfo = info.static_camera_characteristics;
+ mDevice = device;
+
+ return OK;
+}
+
+status_t Camera2Device::disconnect() {
+ ATRACE_CALL();
+ status_t res = OK;
+ if (mDevice) {
+ ALOGV("%s: Closing device for camera %d", __FUNCTION__, mId);
+
+ int inProgressCount = mDevice->ops->get_in_progress_count(mDevice);
+ if (inProgressCount > 0) {
+ ALOGW("%s: Closing camera device %d with %d requests in flight!",
+ __FUNCTION__, mId, inProgressCount);
+ }
+ mReprocessStreams.clear();
+ mStreams.clear();
+ res = mDevice->common.close(&mDevice->common);
+ if (res != OK) {
+ ALOGE("%s: Could not close camera %d: %s (%d)",
+ __FUNCTION__,
+ mId, strerror(-res), res);
+ }
+ mDevice = NULL;
+ ALOGV("%s: Shutdown complete", __FUNCTION__);
+ }
+ return res;
+}
+
+status_t Camera2Device::dump(int fd, const Vector<String16>& args) {
+ ATRACE_CALL();
+ String8 result;
+ int detailLevel = 0;
+ int n = args.size();
+ String16 detailOption("-d");
+ for (int i = 0; i + 1 < n; i++) {
+ if (args[i] == detailOption) {
+ String8 levelStr(args[i+1]);
+ detailLevel = atoi(levelStr.string());
+ }
+ }
+
+ result.appendFormat(" Camera2Device[%d] dump (detail level %d):\n",
+ mId, detailLevel);
+
+ if (detailLevel > 0) {
+ result = " Request queue contents:\n";
+ write(fd, result.string(), result.size());
+ mRequestQueue.dump(fd, args);
+
+ result = " Frame queue contents:\n";
+ write(fd, result.string(), result.size());
+ mFrameQueue.dump(fd, args);
+ }
+
+ result = " Active streams:\n";
+ write(fd, result.string(), result.size());
+ for (StreamList::iterator s = mStreams.begin(); s != mStreams.end(); s++) {
+ (*s)->dump(fd, args);
+ }
+
+ result = " HAL device dump:\n";
+ write(fd, result.string(), result.size());
+
+ status_t res;
+ res = mDevice->ops->dump(mDevice, fd);
+
+ return res;
+}
+
+const camera2::CameraMetadata& Camera2Device::info() const {
+ ALOGVV("%s: E", __FUNCTION__);
+
+ return mDeviceInfo;
+}
+
+status_t Camera2Device::capture(CameraMetadata &request) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+
+ mRequestQueue.enqueue(request.release());
+ return OK;
+}
+
+
+status_t Camera2Device::setStreamingRequest(const CameraMetadata &request) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ CameraMetadata streamRequest(request);
+ return mRequestQueue.setStreamSlot(streamRequest.release());
+}
+
+status_t Camera2Device::clearStreamingRequest() {
+ ATRACE_CALL();
+ return mRequestQueue.setStreamSlot(NULL);
+}
+
+status_t Camera2Device::waitUntilRequestReceived(int32_t requestId, nsecs_t timeout) {
+ ATRACE_CALL();
+ return mRequestQueue.waitForDequeue(requestId, timeout);
+}
+
+status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size, int *id) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: E", __FUNCTION__);
+
+ sp<StreamAdapter> stream = new StreamAdapter(mDevice);
+
+ res = stream->connectToDevice(consumer, width, height, format, size);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create stream (%d x %d, format %x):"
+ "%s (%d)",
+ __FUNCTION__, mId, width, height, format, strerror(-res), res);
+ return res;
+ }
+
+ *id = stream->getId();
+
+ mStreams.push_back(stream);
+ return OK;
+}
+
+status_t Camera2Device::createReprocessStreamFromStream(int outputId, int *id) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: E", __FUNCTION__);
+
+ bool found = false;
+ StreamList::iterator streamI;
+ for (streamI = mStreams.begin();
+ streamI != mStreams.end(); streamI++) {
+ if ((*streamI)->getId() == outputId) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Output stream %d doesn't exist; can't create "
+ "reprocess stream from it!", __FUNCTION__, mId, outputId);
+ return BAD_VALUE;
+ }
+
+ sp<ReprocessStreamAdapter> stream = new ReprocessStreamAdapter(mDevice);
+
+ res = stream->connectToDevice((*streamI));
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create reprocessing stream from "\
+ "stream %d: %s (%d)", __FUNCTION__, mId, outputId,
+ strerror(-res), res);
+ return res;
+ }
+
+ *id = stream->getId();
+
+ mReprocessStreams.push_back(stream);
+ return OK;
+}
+
+
+status_t Camera2Device::getStreamInfo(int id,
+ uint32_t *width, uint32_t *height, uint32_t *format) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ bool found = false;
+ StreamList::iterator streamI;
+ for (streamI = mStreams.begin();
+ streamI != mStreams.end(); streamI++) {
+ if ((*streamI)->getId() == id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Stream %d does not exist",
+ __FUNCTION__, mId, id);
+ return BAD_VALUE;
+ }
+
+ if (width) *width = (*streamI)->getWidth();
+ if (height) *height = (*streamI)->getHeight();
+ if (format) *format = (*streamI)->getFormat();
+
+ return OK;
+}
+
+status_t Camera2Device::setStreamTransform(int id,
+ int transform) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ bool found = false;
+ StreamList::iterator streamI;
+ for (streamI = mStreams.begin();
+ streamI != mStreams.end(); streamI++) {
+ if ((*streamI)->getId() == id) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Stream %d does not exist",
+ __FUNCTION__, mId, id);
+ return BAD_VALUE;
+ }
+
+ return (*streamI)->setTransform(transform);
+}
+
+status_t Camera2Device::deleteStream(int id) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ bool found = false;
+ for (StreamList::iterator streamI = mStreams.begin();
+ streamI != mStreams.end(); streamI++) {
+ if ((*streamI)->getId() == id) {
+ status_t res = (*streamI)->release();
+ if (res != OK) {
+ ALOGE("%s: Unable to release stream %d from HAL device: "
+ "%s (%d)", __FUNCTION__, id, strerror(-res), res);
+ return res;
+ }
+ mStreams.erase(streamI);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Unable to find stream %d to delete",
+ __FUNCTION__, mId, id);
+ return BAD_VALUE;
+ }
+ return OK;
+}
+
+status_t Camera2Device::deleteReprocessStream(int id) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ bool found = false;
+ for (ReprocessStreamList::iterator streamI = mReprocessStreams.begin();
+ streamI != mReprocessStreams.end(); streamI++) {
+ if ((*streamI)->getId() == id) {
+ status_t res = (*streamI)->release();
+ if (res != OK) {
+ ALOGE("%s: Unable to release reprocess stream %d from "
+ "HAL device: %s (%d)", __FUNCTION__, id,
+ strerror(-res), res);
+ return res;
+ }
+ mReprocessStreams.erase(streamI);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Unable to find stream %d to delete",
+ __FUNCTION__, mId, id);
+ return BAD_VALUE;
+ }
+ return OK;
+}
+
+
+status_t Camera2Device::createDefaultRequest(int templateId,
+ CameraMetadata *request) {
+ ATRACE_CALL();
+ status_t err;
+ ALOGV("%s: E", __FUNCTION__);
+ camera_metadata_t *rawRequest;
+ err = mDevice->ops->construct_default_request(
+ mDevice, templateId, &rawRequest);
+ request->acquire(rawRequest);
+ return err;
+}
+
+status_t Camera2Device::waitUntilDrained() {
+ ATRACE_CALL();
+ static const uint32_t kSleepTime = 50000; // 50 ms
+ static const uint32_t kMaxSleepTime = 10000000; // 10 s
+ ALOGV("%s: Camera %d: Starting wait", __FUNCTION__, mId);
+ if (mRequestQueue.getBufferCount() ==
+ CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS) return INVALID_OPERATION;
+
+ // TODO: Set up notifications from HAL, instead of sleeping here
+ uint32_t totalTime = 0;
+ while (mDevice->ops->get_in_progress_count(mDevice) > 0) {
+ usleep(kSleepTime);
+ totalTime += kSleepTime;
+ if (totalTime > kMaxSleepTime) {
+ ALOGE("%s: Waited %d us, %d requests still in flight", __FUNCTION__,
+ mDevice->ops->get_in_progress_count(mDevice), totalTime);
+ return TIMED_OUT;
+ }
+ }
+ ALOGV("%s: Camera %d: HAL is idle", __FUNCTION__, mId);
+ return OK;
+}
+
+status_t Camera2Device::setNotifyCallback(NotificationListener *listener) {
+ ATRACE_CALL();
+ status_t res;
+ res = mDevice->ops->set_notify_callback(mDevice, notificationCallback,
+ reinterpret_cast<void*>(listener) );
+ if (res != OK) {
+ ALOGE("%s: Unable to set notification callback!", __FUNCTION__);
+ }
+ return res;
+}
+
+void Camera2Device::notificationCallback(int32_t msg_type,
+ int32_t ext1,
+ int32_t ext2,
+ int32_t ext3,
+ void *user) {
+ ATRACE_CALL();
+ NotificationListener *listener = reinterpret_cast<NotificationListener*>(user);
+ ALOGV("%s: Notification %d, arguments %d, %d, %d", __FUNCTION__, msg_type,
+ ext1, ext2, ext3);
+ if (listener != NULL) {
+ switch (msg_type) {
+ case CAMERA2_MSG_ERROR:
+ listener->notifyError(ext1, ext2, ext3);
+ break;
+ case CAMERA2_MSG_SHUTTER: {
+ nsecs_t timestamp = (nsecs_t)ext2 | ((nsecs_t)(ext3) << 32 );
+ listener->notifyShutter(ext1, timestamp);
+ break;
+ }
+ case CAMERA2_MSG_AUTOFOCUS:
+ listener->notifyAutoFocus(ext1, ext2);
+ break;
+ case CAMERA2_MSG_AUTOEXPOSURE:
+ listener->notifyAutoExposure(ext1, ext2);
+ break;
+ case CAMERA2_MSG_AUTOWB:
+ listener->notifyAutoWhitebalance(ext1, ext2);
+ break;
+ default:
+ ALOGE("%s: Unknown notification %d (arguments %d, %d, %d)!",
+ __FUNCTION__, msg_type, ext1, ext2, ext3);
+ }
+ }
+}
+
+status_t Camera2Device::waitForNextFrame(nsecs_t timeout) {
+ return mFrameQueue.waitForBuffer(timeout);
+}
+
+status_t Camera2Device::getNextFrame(CameraMetadata *frame) {
+ ATRACE_CALL();
+ status_t res;
+ camera_metadata_t *rawFrame;
+ res = mFrameQueue.dequeue(&rawFrame);
+ if (rawFrame == NULL) {
+ return NOT_ENOUGH_DATA;
+ } else if (res == OK) {
+ frame->acquire(rawFrame);
+ }
+ return res;
+}
+
+status_t Camera2Device::triggerAutofocus(uint32_t id) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: Triggering autofocus, id %d", __FUNCTION__, id);
+ res = mDevice->ops->trigger_action(mDevice,
+ CAMERA2_TRIGGER_AUTOFOCUS, id, 0);
+ if (res != OK) {
+ ALOGE("%s: Error triggering autofocus (id %d)",
+ __FUNCTION__, id);
+ }
+ return res;
+}
+
+status_t Camera2Device::triggerCancelAutofocus(uint32_t id) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: Canceling autofocus, id %d", __FUNCTION__, id);
+ res = mDevice->ops->trigger_action(mDevice,
+ CAMERA2_TRIGGER_CANCEL_AUTOFOCUS, id, 0);
+ if (res != OK) {
+ ALOGE("%s: Error canceling autofocus (id %d)",
+ __FUNCTION__, id);
+ }
+ return res;
+}
+
+status_t Camera2Device::triggerPrecaptureMetering(uint32_t id) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: Triggering precapture metering, id %d", __FUNCTION__, id);
+ res = mDevice->ops->trigger_action(mDevice,
+ CAMERA2_TRIGGER_PRECAPTURE_METERING, id, 0);
+ if (res != OK) {
+ ALOGE("%s: Error triggering precapture metering (id %d)",
+ __FUNCTION__, id);
+ }
+ return res;
+}
+
+status_t Camera2Device::pushReprocessBuffer(int reprocessStreamId,
+ buffer_handle_t *buffer, wp<BufferReleasedListener> listener) {
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ bool found = false;
+ status_t res = OK;
+ for (ReprocessStreamList::iterator streamI = mReprocessStreams.begin();
+ streamI != mReprocessStreams.end(); streamI++) {
+ if ((*streamI)->getId() == reprocessStreamId) {
+ res = (*streamI)->pushIntoStream(buffer, listener);
+ if (res != OK) {
+ ALOGE("%s: Unable to push buffer to reprocess stream %d: %s (%d)",
+ __FUNCTION__, reprocessStreamId, strerror(-res), res);
+ return res;
+ }
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ ALOGE("%s: Camera %d: Unable to find reprocess stream %d",
+ __FUNCTION__, mId, reprocessStreamId);
+ res = BAD_VALUE;
+ }
+ return res;
+}
+
+/**
+ * Camera2Device::NotificationListener
+ */
+
+Camera2Device::NotificationListener::~NotificationListener() {
+}
+
+/**
+ * Camera2Device::MetadataQueue
+ */
+
+Camera2Device::MetadataQueue::MetadataQueue():
+ mDevice(NULL),
+ mFrameCount(0),
+ mLatestRequestId(0),
+ mCount(0),
+ mStreamSlotCount(0),
+ mSignalConsumer(true)
+{
+ ATRACE_CALL();
+ camera2_request_queue_src_ops::dequeue_request = consumer_dequeue;
+ camera2_request_queue_src_ops::request_count = consumer_buffer_count;
+ camera2_request_queue_src_ops::free_request = consumer_free;
+
+ camera2_frame_queue_dst_ops::dequeue_frame = producer_dequeue;
+ camera2_frame_queue_dst_ops::cancel_frame = producer_cancel;
+ camera2_frame_queue_dst_ops::enqueue_frame = producer_enqueue;
+}
+
+Camera2Device::MetadataQueue::~MetadataQueue() {
+ ATRACE_CALL();
+ Mutex::Autolock l(mMutex);
+ freeBuffers(mEntries.begin(), mEntries.end());
+ freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
+}
+
+// Connect to camera2 HAL as consumer (input requests/reprocessing)
+status_t Camera2Device::MetadataQueue::setConsumerDevice(camera2_device_t *d) {
+ ATRACE_CALL();
+ status_t res;
+ res = d->ops->set_request_queue_src_ops(d,
+ this);
+ if (res != OK) return res;
+ mDevice = d;
+ return OK;
+}
+
+status_t Camera2Device::MetadataQueue::setProducerDevice(camera2_device_t *d) {
+ ATRACE_CALL();
+ status_t res;
+ res = d->ops->set_frame_queue_dst_ops(d,
+ this);
+ return res;
+}
+
+// Real interfaces
+status_t Camera2Device::MetadataQueue::enqueue(camera_metadata_t *buf) {
+ ATRACE_CALL();
+ ALOGVV("%s: E", __FUNCTION__);
+ Mutex::Autolock l(mMutex);
+
+ mCount++;
+ mEntries.push_back(buf);
+
+ return signalConsumerLocked();
+}
+
+int Camera2Device::MetadataQueue::getBufferCount() {
+ ATRACE_CALL();
+ Mutex::Autolock l(mMutex);
+ if (mStreamSlotCount > 0) {
+ return CAMERA2_REQUEST_QUEUE_IS_BOTTOMLESS;
+ }
+ return mCount;
+}
+
+status_t Camera2Device::MetadataQueue::dequeue(camera_metadata_t **buf,
+ bool incrementCount)
+{
+ ATRACE_CALL();
+ ALOGVV("%s: E", __FUNCTION__);
+ status_t res;
+ Mutex::Autolock l(mMutex);
+
+ if (mCount == 0) {
+ if (mStreamSlotCount == 0) {
+ ALOGVV("%s: Empty", __FUNCTION__);
+ *buf = NULL;
+ mSignalConsumer = true;
+ return OK;
+ }
+ ALOGVV("%s: Streaming %d frames to queue", __FUNCTION__,
+ mStreamSlotCount);
+
+ for (List<camera_metadata_t*>::iterator slotEntry = mStreamSlot.begin();
+ slotEntry != mStreamSlot.end();
+ slotEntry++ ) {
+ size_t entries = get_camera_metadata_entry_count(*slotEntry);
+ size_t dataBytes = get_camera_metadata_data_count(*slotEntry);
+
+ camera_metadata_t *copy =
+ allocate_camera_metadata(entries, dataBytes);
+ append_camera_metadata(copy, *slotEntry);
+ mEntries.push_back(copy);
+ }
+ mCount = mStreamSlotCount;
+ }
+ ALOGVV("MetadataQueue: deque (%d buffers)", mCount);
+ camera_metadata_t *b = *(mEntries.begin());
+ mEntries.erase(mEntries.begin());
+
+ if (incrementCount) {
+ ATRACE_INT("cam2_request", mFrameCount);
+ camera_metadata_entry_t frameCount;
+ res = find_camera_metadata_entry(b,
+ ANDROID_REQUEST_FRAME_COUNT,
+ &frameCount);
+ if (res != OK) {
+ ALOGE("%s: Unable to add frame count: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ } else {
+ *frameCount.data.i32 = mFrameCount;
+ }
+ mFrameCount++;
+ }
+
+ // Check for request ID, and if present, signal waiters.
+ camera_metadata_entry_t requestId;
+ res = find_camera_metadata_entry(b,
+ ANDROID_REQUEST_ID,
+ &requestId);
+ if (res == OK) {
+ mLatestRequestId = requestId.data.i32[0];
+ mNewRequestId.signal();
+ }
+
+ *buf = b;
+ mCount--;
+
+ return OK;
+}
+
+status_t Camera2Device::MetadataQueue::waitForBuffer(nsecs_t timeout)
+{
+ Mutex::Autolock l(mMutex);
+ status_t res;
+ while (mCount == 0) {
+ res = notEmpty.waitRelative(mMutex,timeout);
+ if (res != OK) return res;
+ }
+ return OK;
+}
+
+status_t Camera2Device::MetadataQueue::waitForDequeue(int32_t id,
+ nsecs_t timeout) {
+ Mutex::Autolock l(mMutex);
+ status_t res;
+ while (mLatestRequestId != id) {
+ nsecs_t startTime = systemTime();
+
+ res = mNewRequestId.waitRelative(mMutex, timeout);
+ if (res != OK) return res;
+
+ timeout -= (systemTime() - startTime);
+ }
+
+ return OK;
+}
+
+status_t Camera2Device::MetadataQueue::setStreamSlot(camera_metadata_t *buf)
+{
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock l(mMutex);
+ if (buf == NULL) {
+ freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
+ mStreamSlotCount = 0;
+ return OK;
+ }
+ camera_metadata_t *buf2 = clone_camera_metadata(buf);
+ if (!buf2) {
+ ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__);
+ return NO_MEMORY;
+ }
+
+ if (mStreamSlotCount > 1) {
+ List<camera_metadata_t*>::iterator deleter = ++mStreamSlot.begin();
+ freeBuffers(++mStreamSlot.begin(), mStreamSlot.end());
+ mStreamSlotCount = 1;
+ }
+ if (mStreamSlotCount == 1) {
+ free_camera_metadata( *(mStreamSlot.begin()) );
+ *(mStreamSlot.begin()) = buf2;
+ } else {
+ mStreamSlot.push_front(buf2);
+ mStreamSlotCount = 1;
+ }
+ return signalConsumerLocked();
+}
+
+status_t Camera2Device::MetadataQueue::setStreamSlot(
+ const List<camera_metadata_t*> &bufs)
+{
+ ATRACE_CALL();
+ ALOGV("%s: E", __FUNCTION__);
+ Mutex::Autolock l(mMutex);
+ status_t res;
+
+ if (mStreamSlotCount > 0) {
+ freeBuffers(mStreamSlot.begin(), mStreamSlot.end());
+ }
+ mStreamSlotCount = 0;
+ for (List<camera_metadata_t*>::const_iterator r = bufs.begin();
+ r != bufs.end(); r++) {
+ camera_metadata_t *r2 = clone_camera_metadata(*r);
+ if (!r2) {
+ ALOGE("%s: Unable to clone metadata buffer!", __FUNCTION__);
+ return NO_MEMORY;
+ }
+ mStreamSlot.push_back(r2);
+ mStreamSlotCount++;
+ }
+ return signalConsumerLocked();
+}
+
+status_t Camera2Device::MetadataQueue::dump(int fd,
+ const Vector<String16>& args) {
+ ATRACE_CALL();
+ String8 result;
+ status_t notLocked;
+ notLocked = mMutex.tryLock();
+ if (notLocked) {
+ result.append(" (Unable to lock queue mutex)\n");
+ }
+ result.appendFormat(" Current frame number: %d\n", mFrameCount);
+ if (mStreamSlotCount == 0) {
+ result.append(" Stream slot: Empty\n");
+ write(fd, result.string(), result.size());
+ } else {
+ result.appendFormat(" Stream slot: %d entries\n",
+ mStreamSlot.size());
+ int i = 0;
+ for (List<camera_metadata_t*>::iterator r = mStreamSlot.begin();
+ r != mStreamSlot.end(); r++) {
+ result = String8::format(" Stream slot buffer %d:\n", i);
+ write(fd, result.string(), result.size());
+ dump_indented_camera_metadata(*r, fd, 2, 10);
+ i++;
+ }
+ }
+ if (mEntries.size() == 0) {
+ result = " Main queue is empty\n";
+ write(fd, result.string(), result.size());
+ } else {
+ result = String8::format(" Main queue has %d entries:\n",
+ mEntries.size());
+ int i = 0;
+ for (List<camera_metadata_t*>::iterator r = mEntries.begin();
+ r != mEntries.end(); r++) {
+ result = String8::format(" Queue entry %d:\n", i);
+ write(fd, result.string(), result.size());
+ dump_indented_camera_metadata(*r, fd, 2, 10);
+ i++;
+ }
+ }
+
+ if (notLocked == 0) {
+ mMutex.unlock();
+ }
+
+ return OK;
+}
+
+status_t Camera2Device::MetadataQueue::signalConsumerLocked() {
+ ATRACE_CALL();
+ status_t res = OK;
+ notEmpty.signal();
+ if (mSignalConsumer && mDevice != NULL) {
+ mSignalConsumer = false;
+
+ mMutex.unlock();
+ ALOGV("%s: Signaling consumer", __FUNCTION__);
+ res = mDevice->ops->notify_request_queue_not_empty(mDevice);
+ mMutex.lock();
+ }
+ return res;
+}
+
+status_t Camera2Device::MetadataQueue::freeBuffers(
+ List<camera_metadata_t*>::iterator start,
+ List<camera_metadata_t*>::iterator end)
+{
+ ATRACE_CALL();
+ while (start != end) {
+ free_camera_metadata(*start);
+ start = mStreamSlot.erase(start);
+ }
+ return OK;
+}
+
+Camera2Device::MetadataQueue* Camera2Device::MetadataQueue::getInstance(
+ const camera2_request_queue_src_ops_t *q)
+{
+ const MetadataQueue* cmq = static_cast<const MetadataQueue*>(q);
+ return const_cast<MetadataQueue*>(cmq);
+}
+
+Camera2Device::MetadataQueue* Camera2Device::MetadataQueue::getInstance(
+ const camera2_frame_queue_dst_ops_t *q)
+{
+ const MetadataQueue* cmq = static_cast<const MetadataQueue*>(q);
+ return const_cast<MetadataQueue*>(cmq);
+}
+
+int Camera2Device::MetadataQueue::consumer_buffer_count(
+ const camera2_request_queue_src_ops_t *q)
+{
+ MetadataQueue *queue = getInstance(q);
+ return queue->getBufferCount();
+}
+
+int Camera2Device::MetadataQueue::consumer_dequeue(
+ const camera2_request_queue_src_ops_t *q,
+ camera_metadata_t **buffer)
+{
+ MetadataQueue *queue = getInstance(q);
+ return queue->dequeue(buffer, true);
+}
+
+int Camera2Device::MetadataQueue::consumer_free(
+ const camera2_request_queue_src_ops_t *q,
+ camera_metadata_t *old_buffer)
+{
+ ATRACE_CALL();
+ MetadataQueue *queue = getInstance(q);
+ free_camera_metadata(old_buffer);
+ return OK;
+}
+
+int Camera2Device::MetadataQueue::producer_dequeue(
+ const camera2_frame_queue_dst_ops_t *q,
+ size_t entries, size_t bytes,
+ camera_metadata_t **buffer)
+{
+ ATRACE_CALL();
+ camera_metadata_t *new_buffer =
+ allocate_camera_metadata(entries, bytes);
+ if (new_buffer == NULL) return NO_MEMORY;
+ *buffer = new_buffer;
+ return OK;
+}
+
+int Camera2Device::MetadataQueue::producer_cancel(
+ const camera2_frame_queue_dst_ops_t *q,
+ camera_metadata_t *old_buffer)
+{
+ ATRACE_CALL();
+ free_camera_metadata(old_buffer);
+ return OK;
+}
+
+int Camera2Device::MetadataQueue::producer_enqueue(
+ const camera2_frame_queue_dst_ops_t *q,
+ camera_metadata_t *filled_buffer)
+{
+ MetadataQueue *queue = getInstance(q);
+ return queue->enqueue(filled_buffer);
+}
+
+/**
+ * Camera2Device::StreamAdapter
+ */
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ (type *)((char*)(ptr) - offsetof(type, member))
+#endif
+
+Camera2Device::StreamAdapter::StreamAdapter(camera2_device_t *d):
+ mState(RELEASED),
+ mDevice(d),
+ mId(-1),
+ mWidth(0), mHeight(0), mFormat(0), mSize(0), mUsage(0),
+ mMaxProducerBuffers(0), mMaxConsumerBuffers(0),
+ mTotalBuffers(0),
+ mFormatRequested(0),
+ mActiveBuffers(0),
+ mFrameCount(0),
+ mLastTimestamp(0)
+{
+ camera2_stream_ops::dequeue_buffer = dequeue_buffer;
+ camera2_stream_ops::enqueue_buffer = enqueue_buffer;
+ camera2_stream_ops::cancel_buffer = cancel_buffer;
+ camera2_stream_ops::set_crop = set_crop;
+}
+
+Camera2Device::StreamAdapter::~StreamAdapter() {
+ ATRACE_CALL();
+ if (mState != RELEASED) {
+ release();
+ }
+}
+
+status_t Camera2Device::StreamAdapter::connectToDevice(
+ sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: E", __FUNCTION__);
+
+ if (mState != RELEASED) return INVALID_OPERATION;
+ if (consumer == NULL) {
+ ALOGE("%s: Null consumer passed to stream adapter", __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ ALOGV("%s: New stream parameters %d x %d, format 0x%x, size %d",
+ __FUNCTION__, width, height, format, size);
+
+ mConsumerInterface = consumer;
+ mWidth = width;
+ mHeight = height;
+ mSize = (format == HAL_PIXEL_FORMAT_BLOB) ? size : 0;
+ mFormatRequested = format;
+
+ // Allocate device-side stream interface
+
+ uint32_t id;
+ uint32_t formatActual;
+ uint32_t usage;
+ uint32_t maxBuffers = 2;
+ res = mDevice->ops->allocate_stream(mDevice,
+ mWidth, mHeight, mFormatRequested, getStreamOps(),
+ &id, &formatActual, &usage, &maxBuffers);
+ if (res != OK) {
+ ALOGE("%s: Device stream allocation failed: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ ALOGV("%s: Allocated stream id %d, actual format 0x%x, "
+ "usage 0x%x, producer wants %d buffers", __FUNCTION__,
+ id, formatActual, usage, maxBuffers);
+
+ mId = id;
+ mFormat = formatActual;
+ mUsage = usage;
+ mMaxProducerBuffers = maxBuffers;
+
+ mState = ALLOCATED;
+
+ // Configure consumer-side ANativeWindow interface
+ res = native_window_api_connect(mConsumerInterface.get(),
+ NATIVE_WINDOW_API_CAMERA);
+ if (res != OK) {
+ ALOGE("%s: Unable to connect to native window for stream %d",
+ __FUNCTION__, mId);
+
+ return res;
+ }
+
+ mState = CONNECTED;
+
+ res = native_window_set_usage(mConsumerInterface.get(), mUsage);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure usage %08x for stream %d",
+ __FUNCTION__, mUsage, mId);
+ return res;
+ }
+
+ res = native_window_set_scaling_mode(mConsumerInterface.get(),
+ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure stream scaling: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ res = setTransform(0);
+ if (res != OK) {
+ return res;
+ }
+
+ if (mFormat == HAL_PIXEL_FORMAT_BLOB) {
+ res = native_window_set_buffers_geometry(mConsumerInterface.get(),
+ mSize, 1, mFormat);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure compressed stream buffer geometry"
+ " %d x %d, size %d for stream %d",
+ __FUNCTION__, mWidth, mHeight, mSize, mId);
+ return res;
+ }
+ } else {
+ res = native_window_set_buffers_geometry(mConsumerInterface.get(),
+ mWidth, mHeight, mFormat);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure stream buffer geometry"
+ " %d x %d, format 0x%x for stream %d",
+ __FUNCTION__, mWidth, mHeight, mFormat, mId);
+ return res;
+ }
+ }
+
+ int maxConsumerBuffers;
+ res = mConsumerInterface->query(mConsumerInterface.get(),
+ NATIVE_WINDOW_MIN_UNDEQUEUED_BUFFERS, &maxConsumerBuffers);
+ if (res != OK) {
+ ALOGE("%s: Unable to query consumer undequeued"
+ " buffer count for stream %d", __FUNCTION__, mId);
+ return res;
+ }
+ mMaxConsumerBuffers = maxConsumerBuffers;
+
+ ALOGV("%s: Consumer wants %d buffers", __FUNCTION__,
+ mMaxConsumerBuffers);
+
+ mTotalBuffers = mMaxConsumerBuffers + mMaxProducerBuffers;
+ mActiveBuffers = 0;
+ mFrameCount = 0;
+ mLastTimestamp = 0;
+
+ res = native_window_set_buffer_count(mConsumerInterface.get(),
+ mTotalBuffers);
+ if (res != OK) {
+ ALOGE("%s: Unable to set buffer count for stream %d",
+ __FUNCTION__, mId);
+ return res;
+ }
+
+ // Register allocated buffers with HAL device
+ buffer_handle_t *buffers = new buffer_handle_t[mTotalBuffers];
+ ANativeWindowBuffer **anwBuffers = new ANativeWindowBuffer*[mTotalBuffers];
+ uint32_t bufferIdx = 0;
+ for (; bufferIdx < mTotalBuffers; bufferIdx++) {
+ res = native_window_dequeue_buffer_and_wait(mConsumerInterface.get(),
+ &anwBuffers[bufferIdx]);
+ if (res != OK) {
+ ALOGE("%s: Unable to dequeue buffer %d for initial registration for "
+ "stream %d", __FUNCTION__, bufferIdx, mId);
+ goto cleanUpBuffers;
+ }
+
+ buffers[bufferIdx] = anwBuffers[bufferIdx]->handle;
+ ALOGV("%s: Buffer %p allocated", __FUNCTION__, (void*)buffers[bufferIdx]);
+ }
+
+ ALOGV("%s: Registering %d buffers with camera HAL", __FUNCTION__, mTotalBuffers);
+ res = mDevice->ops->register_stream_buffers(mDevice,
+ mId,
+ mTotalBuffers,
+ buffers);
+ if (res != OK) {
+ ALOGE("%s: Unable to register buffers with HAL device for stream %d",
+ __FUNCTION__, mId);
+ } else {
+ mState = ACTIVE;
+ }
+
+cleanUpBuffers:
+ ALOGV("%s: Cleaning up %d buffers", __FUNCTION__, bufferIdx);
+ for (uint32_t i = 0; i < bufferIdx; i++) {
+ res = mConsumerInterface->cancelBuffer(mConsumerInterface.get(),
+ anwBuffers[i], -1);
+ if (res != OK) {
+ ALOGE("%s: Unable to cancel buffer %d after registration",
+ __FUNCTION__, i);
+ }
+ }
+ delete[] anwBuffers;
+ delete[] buffers;
+
+ return res;
+}
+
+status_t Camera2Device::StreamAdapter::release() {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: Releasing stream %d", __FUNCTION__, mId);
+ if (mState >= ALLOCATED) {
+ res = mDevice->ops->release_stream(mDevice, mId);
+ if (res != OK) {
+ ALOGE("%s: Unable to release stream %d",
+ __FUNCTION__, mId);
+ return res;
+ }
+ }
+ if (mState >= CONNECTED) {
+ res = native_window_api_disconnect(mConsumerInterface.get(),
+ NATIVE_WINDOW_API_CAMERA);
+
+ /* this is not an error. if client calling process dies,
+ the window will also die and all calls to it will return
+ DEAD_OBJECT, thus it's already "disconnected" */
+ if (res == DEAD_OBJECT) {
+ ALOGW("%s: While disconnecting stream %d from native window, the"
+ " native window died from under us", __FUNCTION__, mId);
+ }
+ else if (res != OK) {
+ ALOGE("%s: Unable to disconnect stream %d from native window (error %d %s)",
+ __FUNCTION__, mId, res, strerror(-res));
+ return res;
+ }
+ }
+ mId = -1;
+ mState = RELEASED;
+ return OK;
+}
+
+status_t Camera2Device::StreamAdapter::setTransform(int transform) {
+ ATRACE_CALL();
+ status_t res;
+ if (mState < CONNECTED) {
+ ALOGE("%s: Cannot set transform on unconnected stream", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+ res = native_window_set_buffers_transform(mConsumerInterface.get(),
+ transform);
+ if (res != OK) {
+ ALOGE("%s: Unable to configure stream transform to %x: %s (%d)",
+ __FUNCTION__, transform, strerror(-res), res);
+ }
+ return res;
+}
+
+status_t Camera2Device::StreamAdapter::dump(int fd,
+ const Vector<String16>& args) {
+ ATRACE_CALL();
+ String8 result = String8::format(" Stream %d: %d x %d, format 0x%x\n",
+ mId, mWidth, mHeight, mFormat);
+ result.appendFormat(" size %d, usage 0x%x, requested format 0x%x\n",
+ mSize, mUsage, mFormatRequested);
+ result.appendFormat(" total buffers: %d, dequeued buffers: %d\n",
+ mTotalBuffers, mActiveBuffers);
+ result.appendFormat(" frame count: %d, last timestamp %lld\n",
+ mFrameCount, mLastTimestamp);
+ write(fd, result.string(), result.size());
+ return OK;
+}
+
+const camera2_stream_ops *Camera2Device::StreamAdapter::getStreamOps() {
+ return static_cast<camera2_stream_ops *>(this);
+}
+
+ANativeWindow* Camera2Device::StreamAdapter::toANW(
+ const camera2_stream_ops_t *w) {
+ return static_cast<const StreamAdapter*>(w)->mConsumerInterface.get();
+}
+
+int Camera2Device::StreamAdapter::dequeue_buffer(const camera2_stream_ops_t *w,
+ buffer_handle_t** buffer) {
+ ATRACE_CALL();
+ int res;
+ StreamAdapter* stream =
+ const_cast<StreamAdapter*>(static_cast<const StreamAdapter*>(w));
+ if (stream->mState != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, stream->mState);
+ return INVALID_OPERATION;
+ }
+
+ ANativeWindow *a = toANW(w);
+ ANativeWindowBuffer* anb;
+ res = native_window_dequeue_buffer_and_wait(a, &anb);
+ if (res != OK) {
+ ALOGE("Stream %d dequeue: Error from native_window: %s (%d)", stream->mId,
+ strerror(-res), res);
+ return res;
+ }
+
+ *buffer = &(anb->handle);
+ stream->mActiveBuffers++;
+
+ ALOGVV("Stream %d dequeue: Buffer %p dequeued", stream->mId, (void*)(**buffer));
+ return res;
+}
+
+int Camera2Device::StreamAdapter::enqueue_buffer(const camera2_stream_ops_t* w,
+ int64_t timestamp,
+ buffer_handle_t* buffer) {
+ ATRACE_CALL();
+ StreamAdapter *stream =
+ const_cast<StreamAdapter*>(static_cast<const StreamAdapter*>(w));
+ stream->mFrameCount++;
+ ALOGVV("Stream %d enqueue: Frame %d (%p) captured at %lld ns",
+ stream->mId, stream->mFrameCount, (void*)(*buffer), timestamp);
+ int state = stream->mState;
+ if (state != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state);
+ return INVALID_OPERATION;
+ }
+ ANativeWindow *a = toANW(w);
+ status_t err;
+
+ err = native_window_set_buffers_timestamp(a, timestamp);
+ if (err != OK) {
+ ALOGE("%s: Error setting timestamp on native window: %s (%d)",
+ __FUNCTION__, strerror(-err), err);
+ return err;
+ }
+ err = a->queueBuffer(a,
+ container_of(buffer, ANativeWindowBuffer, handle), -1);
+ if (err != OK) {
+ ALOGE("%s: Error queueing buffer to native window: %s (%d)",
+ __FUNCTION__, strerror(-err), err);
+ return err;
+ }
+
+ stream->mActiveBuffers--;
+ stream->mLastTimestamp = timestamp;
+ return OK;
+}
+
+int Camera2Device::StreamAdapter::cancel_buffer(const camera2_stream_ops_t* w,
+ buffer_handle_t* buffer) {
+ ATRACE_CALL();
+ StreamAdapter *stream =
+ const_cast<StreamAdapter*>(static_cast<const StreamAdapter*>(w));
+ ALOGVV("Stream %d cancel: Buffer %p",
+ stream->mId, (void*)(*buffer));
+ if (stream->mState != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, stream->mState);
+ return INVALID_OPERATION;
+ }
+
+ ANativeWindow *a = toANW(w);
+ int err = a->cancelBuffer(a,
+ container_of(buffer, ANativeWindowBuffer, handle), -1);
+ if (err != OK) {
+ ALOGE("%s: Error canceling buffer to native window: %s (%d)",
+ __FUNCTION__, strerror(-err), err);
+ return err;
+ }
+
+ stream->mActiveBuffers--;
+ return OK;
+}
+
+int Camera2Device::StreamAdapter::set_crop(const camera2_stream_ops_t* w,
+ int left, int top, int right, int bottom) {
+ ATRACE_CALL();
+ int state = static_cast<const StreamAdapter*>(w)->mState;
+ if (state != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state);
+ return INVALID_OPERATION;
+ }
+ ANativeWindow *a = toANW(w);
+ android_native_rect_t crop = { left, top, right, bottom };
+ return native_window_set_crop(a, &crop);
+}
+
+/**
+ * Camera2Device::ReprocessStreamAdapter
+ */
+
+#ifndef container_of
+#define container_of(ptr, type, member) \
+ (type *)((char*)(ptr) - offsetof(type, member))
+#endif
+
+Camera2Device::ReprocessStreamAdapter::ReprocessStreamAdapter(camera2_device_t *d):
+ mState(RELEASED),
+ mDevice(d),
+ mId(-1),
+ mWidth(0), mHeight(0), mFormat(0),
+ mActiveBuffers(0),
+ mFrameCount(0)
+{
+ ATRACE_CALL();
+ camera2_stream_in_ops::acquire_buffer = acquire_buffer;
+ camera2_stream_in_ops::release_buffer = release_buffer;
+}
+
+Camera2Device::ReprocessStreamAdapter::~ReprocessStreamAdapter() {
+ ATRACE_CALL();
+ if (mState != RELEASED) {
+ release();
+ }
+}
+
+status_t Camera2Device::ReprocessStreamAdapter::connectToDevice(
+ const sp<StreamAdapter> &outputStream) {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: E", __FUNCTION__);
+
+ if (mState != RELEASED) return INVALID_OPERATION;
+ if (outputStream == NULL) {
+ ALOGE("%s: Null base stream passed to reprocess stream adapter",
+ __FUNCTION__);
+ return BAD_VALUE;
+ }
+
+ mBaseStream = outputStream;
+ mWidth = outputStream->getWidth();
+ mHeight = outputStream->getHeight();
+ mFormat = outputStream->getFormat();
+
+ ALOGV("%s: New reprocess stream parameters %d x %d, format 0x%x",
+ __FUNCTION__, mWidth, mHeight, mFormat);
+
+ // Allocate device-side stream interface
+
+ uint32_t id;
+ res = mDevice->ops->allocate_reprocess_stream_from_stream(mDevice,
+ outputStream->getId(), getStreamOps(),
+ &id);
+ if (res != OK) {
+ ALOGE("%s: Device reprocess stream allocation failed: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ ALOGV("%s: Allocated reprocess stream id %d based on stream %d",
+ __FUNCTION__, id, outputStream->getId());
+
+ mId = id;
+
+ mState = ACTIVE;
+
+ return OK;
+}
+
+status_t Camera2Device::ReprocessStreamAdapter::release() {
+ ATRACE_CALL();
+ status_t res;
+ ALOGV("%s: Releasing stream %d", __FUNCTION__, mId);
+ if (mState >= ACTIVE) {
+ res = mDevice->ops->release_reprocess_stream(mDevice, mId);
+ if (res != OK) {
+ ALOGE("%s: Unable to release stream %d",
+ __FUNCTION__, mId);
+ return res;
+ }
+ }
+
+ List<QueueEntry>::iterator s;
+ for (s = mQueue.begin(); s != mQueue.end(); s++) {
+ sp<BufferReleasedListener> listener = s->releaseListener.promote();
+ if (listener != 0) listener->onBufferReleased(s->handle);
+ }
+ for (s = mInFlightQueue.begin(); s != mInFlightQueue.end(); s++) {
+ sp<BufferReleasedListener> listener = s->releaseListener.promote();
+ if (listener != 0) listener->onBufferReleased(s->handle);
+ }
+ mQueue.clear();
+ mInFlightQueue.clear();
+
+ mState = RELEASED;
+ return OK;
+}
+
+status_t Camera2Device::ReprocessStreamAdapter::pushIntoStream(
+ buffer_handle_t *handle, const wp<BufferReleasedListener> &releaseListener) {
+ ATRACE_CALL();
+ // TODO: Some error checking here would be nice
+ ALOGV("%s: Pushing buffer %p to stream", __FUNCTION__, (void*)(*handle));
+
+ QueueEntry entry;
+ entry.handle = handle;
+ entry.releaseListener = releaseListener;
+ mQueue.push_back(entry);
+ return OK;
+}
+
+status_t Camera2Device::ReprocessStreamAdapter::dump(int fd,
+ const Vector<String16>& args) {
+ ATRACE_CALL();
+ String8 result =
+ String8::format(" Reprocess stream %d: %d x %d, fmt 0x%x\n",
+ mId, mWidth, mHeight, mFormat);
+ result.appendFormat(" acquired buffers: %d\n",
+ mActiveBuffers);
+ result.appendFormat(" frame count: %d\n",
+ mFrameCount);
+ write(fd, result.string(), result.size());
+ return OK;
+}
+
+const camera2_stream_in_ops *Camera2Device::ReprocessStreamAdapter::getStreamOps() {
+ return static_cast<camera2_stream_in_ops *>(this);
+}
+
+int Camera2Device::ReprocessStreamAdapter::acquire_buffer(
+ const camera2_stream_in_ops_t *w,
+ buffer_handle_t** buffer) {
+ ATRACE_CALL();
+ int res;
+ ReprocessStreamAdapter* stream =
+ const_cast<ReprocessStreamAdapter*>(
+ static_cast<const ReprocessStreamAdapter*>(w));
+ if (stream->mState != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, stream->mState);
+ return INVALID_OPERATION;
+ }
+
+ if (stream->mQueue.empty()) {
+ *buffer = NULL;
+ return OK;
+ }
+
+ QueueEntry &entry = *(stream->mQueue.begin());
+
+ *buffer = entry.handle;
+
+ stream->mInFlightQueue.push_back(entry);
+ stream->mQueue.erase(stream->mQueue.begin());
+
+ stream->mActiveBuffers++;
+
+ ALOGV("Stream %d acquire: Buffer %p acquired", stream->mId,
+ (void*)(**buffer));
+ return OK;
+}
+
+int Camera2Device::ReprocessStreamAdapter::release_buffer(
+ const camera2_stream_in_ops_t* w,
+ buffer_handle_t* buffer) {
+ ATRACE_CALL();
+ ReprocessStreamAdapter *stream =
+ const_cast<ReprocessStreamAdapter*>(
+ static_cast<const ReprocessStreamAdapter*>(w) );
+ stream->mFrameCount++;
+ ALOGV("Reprocess stream %d release: Frame %d (%p)",
+ stream->mId, stream->mFrameCount, (void*)*buffer);
+ int state = stream->mState;
+ if (state != ACTIVE) {
+ ALOGE("%s: Called when in bad state: %d", __FUNCTION__, state);
+ return INVALID_OPERATION;
+ }
+ stream->mActiveBuffers--;
+
+ List<QueueEntry>::iterator s;
+ for (s = stream->mInFlightQueue.begin(); s != stream->mInFlightQueue.end(); s++) {
+ if ( s->handle == buffer ) break;
+ }
+ if (s == stream->mInFlightQueue.end()) {
+ ALOGE("%s: Can't find buffer %p in in-flight list!", __FUNCTION__,
+ buffer);
+ return INVALID_OPERATION;
+ }
+
+ sp<BufferReleasedListener> listener = s->releaseListener.promote();
+ if (listener != 0) {
+ listener->onBufferReleased(s->handle);
+ } else {
+ ALOGE("%s: Can't free buffer - missing listener", __FUNCTION__);
+ }
+ stream->mInFlightQueue.erase(s);
+
+ return OK;
+}
+
+}; // namespace android
diff --git a/services/camera/libcameraservice/Camera2Device.h b/services/camera/libcameraservice/Camera2Device.h
new file mode 100644
index 00000000..41df2e4b
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Device.h
@@ -0,0 +1,476 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2DEVICE_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2DEVICE_H
+
+#include <utils/Condition.h>
+#include <utils/Errors.h>
+#include <utils/List.h>
+#include <utils/Mutex.h>
+#include <utils/RefBase.h>
+#include <utils/String8.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+
+#include "hardware/camera2.h"
+#include "camera2/CameraMetadata.h"
+
+namespace android {
+
+class Camera2Device : public virtual RefBase {
+ public:
+ typedef camera2::CameraMetadata CameraMetadata;
+
+ Camera2Device(int id);
+
+ ~Camera2Device();
+
+ status_t initialize(camera_module_t *module);
+ status_t disconnect();
+
+ status_t dump(int fd, const Vector<String16>& args);
+
+ /**
+ * The device's static characteristics metadata buffer
+ */
+ const CameraMetadata& info() const;
+
+ /**
+ * Submit request for capture. The Camera2Device takes ownership of the
+ * passed-in buffer.
+ */
+ status_t capture(CameraMetadata &request);
+
+ /**
+ * Submit request for streaming. The Camera2Device makes a copy of the
+ * passed-in buffer and the caller retains ownership.
+ */
+ status_t setStreamingRequest(const CameraMetadata &request);
+
+ /**
+ * Clear the streaming request slot.
+ */
+ status_t clearStreamingRequest();
+
+ /**
+ * Wait until a request with the given ID has been dequeued by the
+ * HAL. Returns TIMED_OUT if the timeout duration is reached. Returns
+ * immediately if the latest request received by the HAL has this id.
+ */
+ status_t waitUntilRequestReceived(int32_t requestId, nsecs_t timeout);
+
+ /**
+ * Create an output stream of the requested size and format.
+ *
+ * If format is CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, then the HAL device selects
+ * an appropriate format; it can be queried with getStreamInfo.
+ *
+ * If format is HAL_PIXEL_FORMAT_COMPRESSED, the size parameter must be
+ * equal to the size in bytes of the buffers to allocate for the stream. For
+ * other formats, the size parameter is ignored.
+ */
+ status_t createStream(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size,
+ int *id);
+
+ /**
+ * Create an input reprocess stream that uses buffers from an existing
+ * output stream.
+ */
+ status_t createReprocessStreamFromStream(int outputId, int *id);
+
+ /**
+ * Get information about a given stream.
+ */
+ status_t getStreamInfo(int id,
+ uint32_t *width, uint32_t *height, uint32_t *format);
+
+ /**
+ * Set stream gralloc buffer transform
+ */
+ status_t setStreamTransform(int id, int transform);
+
+ /**
+ * Delete stream. Must not be called if there are requests in flight which
+ * reference that stream.
+ */
+ status_t deleteStream(int id);
+
+ /**
+ * Delete reprocess stream. Must not be called if there are requests in
+ * flight which reference that stream.
+ */
+ status_t deleteReprocessStream(int id);
+
+ /**
+ * Create a metadata buffer with fields that the HAL device believes are
+ * best for the given use case
+ */
+ status_t createDefaultRequest(int templateId, CameraMetadata *request);
+
+ /**
+ * Wait until all requests have been processed. Returns INVALID_OPERATION if
+ * the streaming slot is not empty, or TIMED_OUT if the requests haven't
+ * finished processing in 10 seconds.
+ */
+ status_t waitUntilDrained();
+
+ /**
+ * Abstract class for HAL notification listeners
+ */
+ class NotificationListener {
+ public:
+ // Refer to the Camera2 HAL definition for notification definitions
+ virtual void notifyError(int errorCode, int arg1, int arg2) = 0;
+ virtual void notifyShutter(int frameNumber, nsecs_t timestamp) = 0;
+ virtual void notifyAutoFocus(uint8_t newState, int triggerId) = 0;
+ virtual void notifyAutoExposure(uint8_t newState, int triggerId) = 0;
+ virtual void notifyAutoWhitebalance(uint8_t newState, int triggerId) = 0;
+ protected:
+ virtual ~NotificationListener();
+ };
+
+ /**
+ * Connect HAL notifications to a listener. Overwrites previous
+ * listener. Set to NULL to stop receiving notifications.
+ */
+ status_t setNotifyCallback(NotificationListener *listener);
+
+ /**
+ * Wait for a new frame to be produced, with timeout in nanoseconds.
+ * Returns TIMED_OUT when no frame produced within the specified duration
+ */
+ status_t waitForNextFrame(nsecs_t timeout);
+
+ /**
+ * Get next metadata frame from the frame queue. Returns NULL if the queue
+ * is empty; caller takes ownership of the metadata buffer.
+ */
+ status_t getNextFrame(CameraMetadata *frame);
+
+ /**
+ * Trigger auto-focus. The latest ID used in a trigger autofocus or cancel
+ * autofocus call will be returned by the HAL in all subsequent AF
+ * notifications.
+ */
+ status_t triggerAutofocus(uint32_t id);
+
+ /**
+ * Cancel auto-focus. The latest ID used in a trigger autofocus/cancel
+ * autofocus call will be returned by the HAL in all subsequent AF
+ * notifications.
+ */
+ status_t triggerCancelAutofocus(uint32_t id);
+
+ /**
+ * Trigger pre-capture metering. The latest ID used in a trigger pre-capture
+ * call will be returned by the HAL in all subsequent AE and AWB
+ * notifications.
+ */
+ status_t triggerPrecaptureMetering(uint32_t id);
+
+ /**
+ * Abstract interface for clients that want to listen to reprocess buffer
+ * release events
+ */
+ struct BufferReleasedListener: public virtual RefBase {
+ virtual void onBufferReleased(buffer_handle_t *handle) = 0;
+ };
+
+ /**
+ * Push a buffer to be reprocessed into a reprocessing stream, and
+ * provide a listener to call once the buffer is returned by the HAL
+ */
+ status_t pushReprocessBuffer(int reprocessStreamId,
+ buffer_handle_t *buffer, wp<BufferReleasedListener> listener);
+
+ private:
+ const int mId;
+ camera2_device_t *mDevice;
+
+ CameraMetadata mDeviceInfo;
+ vendor_tag_query_ops_t *mVendorTagOps;
+
+ /**
+ * Queue class for both sending requests to a camera2 device, and for
+ * receiving frames from a camera2 device.
+ */
+ class MetadataQueue: public camera2_request_queue_src_ops_t,
+ public camera2_frame_queue_dst_ops_t {
+ public:
+ MetadataQueue();
+ ~MetadataQueue();
+
+ // Interface to camera2 HAL device, either for requests (device is
+ // consumer) or for frames (device is producer)
+ const camera2_request_queue_src_ops_t* getToConsumerInterface();
+ void setFromConsumerInterface(camera2_device_t *d);
+
+ // Connect queue consumer endpoint to a camera2 device
+ status_t setConsumerDevice(camera2_device_t *d);
+ // Connect queue producer endpoint to a camera2 device
+ status_t setProducerDevice(camera2_device_t *d);
+
+ const camera2_frame_queue_dst_ops_t* getToProducerInterface();
+
+ // Real interfaces. On enqueue, queue takes ownership of buffer pointer
+ // On dequeue, user takes ownership of buffer pointer.
+ status_t enqueue(camera_metadata_t *buf);
+ status_t dequeue(camera_metadata_t **buf, bool incrementCount = false);
+ int getBufferCount();
+ status_t waitForBuffer(nsecs_t timeout);
+ // Wait until a buffer with the given ID is dequeued. Will return
+ // immediately if the latest buffer dequeued has that ID.
+ status_t waitForDequeue(int32_t id, nsecs_t timeout);
+
+ // Set repeating buffer(s); if the queue is empty on a dequeue call, the
+ // queue copies the contents of the stream slot into the queue, and then
+ // dequeues the first new entry. The metadata buffers passed in are
+ // copied.
+ status_t setStreamSlot(camera_metadata_t *buf);
+ status_t setStreamSlot(const List<camera_metadata_t*> &bufs);
+
+ status_t dump(int fd, const Vector<String16>& args);
+
+ private:
+ status_t signalConsumerLocked();
+ status_t freeBuffers(List<camera_metadata_t*>::iterator start,
+ List<camera_metadata_t*>::iterator end);
+
+ camera2_device_t *mDevice;
+
+ Mutex mMutex;
+ Condition notEmpty;
+
+ int mFrameCount;
+ int32_t mLatestRequestId;
+ Condition mNewRequestId;
+
+ int mCount;
+ List<camera_metadata_t*> mEntries;
+ int mStreamSlotCount;
+ List<camera_metadata_t*> mStreamSlot;
+
+ bool mSignalConsumer;
+
+ static MetadataQueue* getInstance(
+ const camera2_frame_queue_dst_ops_t *q);
+ static MetadataQueue* getInstance(
+ const camera2_request_queue_src_ops_t *q);
+
+ static int consumer_buffer_count(
+ const camera2_request_queue_src_ops_t *q);
+
+ static int consumer_dequeue(const camera2_request_queue_src_ops_t *q,
+ camera_metadata_t **buffer);
+
+ static int consumer_free(const camera2_request_queue_src_ops_t *q,
+ camera_metadata_t *old_buffer);
+
+ static int producer_dequeue(const camera2_frame_queue_dst_ops_t *q,
+ size_t entries, size_t bytes,
+ camera_metadata_t **buffer);
+
+ static int producer_cancel(const camera2_frame_queue_dst_ops_t *q,
+ camera_metadata_t *old_buffer);
+
+ static int producer_enqueue(const camera2_frame_queue_dst_ops_t *q,
+ camera_metadata_t *filled_buffer);
+
+ }; // class MetadataQueue
+
+ MetadataQueue mRequestQueue;
+ MetadataQueue mFrameQueue;
+
+ /**
+ * Adapter from an ANativeWindow interface to camera2 device stream ops.
+ * Also takes care of allocating/deallocating stream in device interface
+ */
+ class StreamAdapter: public camera2_stream_ops, public virtual RefBase {
+ public:
+ StreamAdapter(camera2_device_t *d);
+
+ ~StreamAdapter();
+
+ /**
+ * Create a HAL device stream of the requested size and format.
+ *
+ * If format is CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, then the HAL device
+ * selects an appropriate format; it can be queried with getFormat.
+ *
+ * If format is HAL_PIXEL_FORMAT_COMPRESSED, the size parameter must
+ * be equal to the size in bytes of the buffers to allocate for the
+ * stream. For other formats, the size parameter is ignored.
+ */
+ status_t connectToDevice(sp<ANativeWindow> consumer,
+ uint32_t width, uint32_t height, int format, size_t size);
+
+ status_t release();
+
+ status_t setTransform(int transform);
+
+ // Get stream parameters.
+ // Only valid after a successful connectToDevice call.
+ int getId() const { return mId; }
+ uint32_t getWidth() const { return mWidth; }
+ uint32_t getHeight() const { return mHeight; }
+ uint32_t getFormat() const { return mFormat; }
+
+ // Dump stream information
+ status_t dump(int fd, const Vector<String16>& args);
+
+ private:
+ enum {
+ ERROR = -1,
+ RELEASED = 0,
+ ALLOCATED,
+ CONNECTED,
+ ACTIVE
+ } mState;
+
+ sp<ANativeWindow> mConsumerInterface;
+ camera2_device_t *mDevice;
+
+ uint32_t mId;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mFormat;
+ size_t mSize;
+ uint32_t mUsage;
+ uint32_t mMaxProducerBuffers;
+ uint32_t mMaxConsumerBuffers;
+ uint32_t mTotalBuffers;
+ int mFormatRequested;
+
+ /** Debugging information */
+ uint32_t mActiveBuffers;
+ uint32_t mFrameCount;
+ int64_t mLastTimestamp;
+
+ const camera2_stream_ops *getStreamOps();
+
+ static ANativeWindow* toANW(const camera2_stream_ops_t *w);
+
+ static int dequeue_buffer(const camera2_stream_ops_t *w,
+ buffer_handle_t** buffer);
+
+ static int enqueue_buffer(const camera2_stream_ops_t* w,
+ int64_t timestamp,
+ buffer_handle_t* buffer);
+
+ static int cancel_buffer(const camera2_stream_ops_t* w,
+ buffer_handle_t* buffer);
+
+ static int set_crop(const camera2_stream_ops_t* w,
+ int left, int top, int right, int bottom);
+ }; // class StreamAdapter
+
+ typedef List<sp<StreamAdapter> > StreamList;
+ StreamList mStreams;
+
+ /**
+ * Adapter from an ANativeWindow interface to camera2 device stream ops.
+ * Also takes care of allocating/deallocating stream in device interface
+ */
+ class ReprocessStreamAdapter: public camera2_stream_in_ops, public virtual RefBase {
+ public:
+ ReprocessStreamAdapter(camera2_device_t *d);
+
+ ~ReprocessStreamAdapter();
+
+ /**
+ * Create a HAL device reprocess stream based on an existing output stream.
+ */
+ status_t connectToDevice(const sp<StreamAdapter> &outputStream);
+
+ status_t release();
+
+ /**
+ * Push buffer into stream for reprocessing. Takes ownership until it notifies
+ * that the buffer has been released
+ */
+ status_t pushIntoStream(buffer_handle_t *handle,
+ const wp<BufferReleasedListener> &releaseListener);
+
+ /**
+ * Get stream parameters.
+ * Only valid after a successful connectToDevice call.
+ */
+ int getId() const { return mId; }
+ uint32_t getWidth() const { return mWidth; }
+ uint32_t getHeight() const { return mHeight; }
+ uint32_t getFormat() const { return mFormat; }
+
+ // Dump stream information
+ status_t dump(int fd, const Vector<String16>& args);
+
+ private:
+ enum {
+ ERROR = -1,
+ RELEASED = 0,
+ ACTIVE
+ } mState;
+
+ sp<ANativeWindow> mConsumerInterface;
+ wp<StreamAdapter> mBaseStream;
+
+ struct QueueEntry {
+ buffer_handle_t *handle;
+ wp<BufferReleasedListener> releaseListener;
+ };
+
+ List<QueueEntry> mQueue;
+
+ List<QueueEntry> mInFlightQueue;
+
+ camera2_device_t *mDevice;
+
+ uint32_t mId;
+ uint32_t mWidth;
+ uint32_t mHeight;
+ uint32_t mFormat;
+
+ /** Debugging information */
+ uint32_t mActiveBuffers;
+ uint32_t mFrameCount;
+ int64_t mLastTimestamp;
+
+ const camera2_stream_in_ops *getStreamOps();
+
+ static int acquire_buffer(const camera2_stream_in_ops_t *w,
+ buffer_handle_t** buffer);
+
+ static int release_buffer(const camera2_stream_in_ops_t* w,
+ buffer_handle_t* buffer);
+
+ }; // class ReprocessStreamAdapter
+
+ typedef List<sp<ReprocessStreamAdapter> > ReprocessStreamList;
+ ReprocessStreamList mReprocessStreams;
+
+ // Receives HAL notifications and routes them to the NotificationListener
+ static void notificationCallback(int32_t msg_type,
+ int32_t ext1,
+ int32_t ext2,
+ int32_t ext3,
+ void *user);
+
+}; // class Camera2Device
+
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/CameraClient.cpp b/services/camera/libcameraservice/CameraClient.cpp
new file mode 100644
index 00000000..b930c02f
--- /dev/null
+++ b/services/camera/libcameraservice/CameraClient.cpp
@@ -0,0 +1,959 @@
+/*
+ * 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 "CameraClient"
+//#define LOG_NDEBUG 0
+
+#include <cutils/properties.h>
+#include <gui/SurfaceTextureClient.h>
+#include <gui/Surface.h>
+
+#include "CameraClient.h"
+#include "CameraHardwareInterface.h"
+#include "CameraService.h"
+
+namespace android {
+
+#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
+#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
+
+static int getCallingPid() {
+ return IPCThreadState::self()->getCallingPid();
+}
+
+static int getCallingUid() {
+ return IPCThreadState::self()->getCallingUid();
+}
+
+CameraClient::CameraClient(const sp<CameraService>& cameraService,
+ const sp<ICameraClient>& cameraClient,
+ int cameraId, int cameraFacing, int clientPid, int servicePid):
+ Client(cameraService, cameraClient,
+ cameraId, cameraFacing, clientPid, servicePid)
+{
+ int callingPid = getCallingPid();
+ LOG1("CameraClient::CameraClient E (pid %d, id %d)", callingPid, cameraId);
+
+ mHardware = NULL;
+ mMsgEnabled = 0;
+ mSurface = 0;
+ mPreviewWindow = 0;
+ mDestructionStarted = false;
+
+ // Callback is disabled by default
+ mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
+ mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
+ mPlayShutterSound = true;
+ LOG1("CameraClient::CameraClient X (pid %d, id %d)", callingPid, cameraId);
+}
+
+status_t CameraClient::initialize(camera_module_t *module) {
+ int callingPid = getCallingPid();
+ LOG1("CameraClient::initialize E (pid %d, id %d)", callingPid, mCameraId);
+
+ char camera_device_name[10];
+ status_t res;
+ snprintf(camera_device_name, sizeof(camera_device_name), "%d", mCameraId);
+
+ mHardware = new CameraHardwareInterface(camera_device_name);
+ res = mHardware->initialize(&module->common);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: unable to initialize device: %s (%d)",
+ __FUNCTION__, mCameraId, strerror(-res), res);
+ mHardware.clear();
+ return NO_INIT;
+ }
+
+ mHardware->setCallbacks(notifyCallback,
+ dataCallback,
+ dataCallbackTimestamp,
+ (void *)mCameraId);
+
+ // Enable zoom, error, focus, and metadata messages by default
+ enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS |
+ CAMERA_MSG_PREVIEW_METADATA | CAMERA_MSG_FOCUS_MOVE);
+
+ LOG1("CameraClient::initialize X (pid %d, id %d)", callingPid, mCameraId);
+ return OK;
+}
+
+
+// tear down the client
+CameraClient::~CameraClient() {
+ // this lock should never be NULL
+ Mutex* lock = mCameraService->getClientLockById(mCameraId);
+ lock->lock();
+ mDestructionStarted = true;
+ // client will not be accessed from callback. should unlock to prevent dead-lock in disconnect
+ lock->unlock();
+ int callingPid = getCallingPid();
+ LOG1("CameraClient::~CameraClient E (pid %d, this %p)", callingPid, this);
+
+ disconnect();
+ LOG1("CameraClient::~CameraClient X (pid %d, this %p)", callingPid, this);
+}
+
+status_t CameraClient::dump(int fd, const Vector<String16>& args) {
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+
+ size_t len = snprintf(buffer, SIZE, "Client[%d] (%p) PID: %d\n",
+ mCameraId,
+ getCameraClient()->asBinder().get(),
+ mClientPid);
+ len = (len > SIZE - 1) ? SIZE - 1 : len;
+ write(fd, buffer, len);
+ return mHardware->dump(fd, args);
+}
+
+// ----------------------------------------------------------------------------
+
+status_t CameraClient::checkPid() const {
+ int callingPid = getCallingPid();
+ if (callingPid == mClientPid) return NO_ERROR;
+
+ ALOGW("attempt to use a locked camera from a different process"
+ " (old pid %d, new pid %d)", mClientPid, callingPid);
+ return EBUSY;
+}
+
+status_t CameraClient::checkPidAndHardware() const {
+ status_t result = checkPid();
+ if (result != NO_ERROR) return result;
+ if (mHardware == 0) {
+ ALOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
+ return INVALID_OPERATION;
+ }
+ return NO_ERROR;
+}
+
+status_t CameraClient::lock() {
+ int callingPid = getCallingPid();
+ LOG1("lock (pid %d)", callingPid);
+ Mutex::Autolock lock(mLock);
+
+ // lock camera to this client if the the camera is unlocked
+ if (mClientPid == 0) {
+ mClientPid = callingPid;
+ return NO_ERROR;
+ }
+
+ // returns NO_ERROR if the client already owns the camera, EBUSY otherwise
+ return checkPid();
+}
+
+status_t CameraClient::unlock() {
+ int callingPid = getCallingPid();
+ LOG1("unlock (pid %d)", callingPid);
+ Mutex::Autolock lock(mLock);
+
+ // allow anyone to use camera (after they lock the camera)
+ status_t result = checkPid();
+ if (result == NO_ERROR) {
+ if (mHardware->recordingEnabled()) {
+ ALOGE("Not allowed to unlock camera during recording.");
+ return INVALID_OPERATION;
+ }
+ mClientPid = 0;
+ LOG1("clear mCameraClient (pid %d)", callingPid);
+ // we need to remove the reference to ICameraClient so that when the app
+ // goes away, the reference count goes to 0.
+ mCameraClient.clear();
+ }
+ return result;
+}
+
+// connect a new client to the camera
+status_t CameraClient::connect(const sp<ICameraClient>& client) {
+ int callingPid = getCallingPid();
+ LOG1("connect E (pid %d)", callingPid);
+ Mutex::Autolock lock(mLock);
+
+ if (mClientPid != 0 && checkPid() != NO_ERROR) {
+ ALOGW("Tried to connect to a locked camera (old pid %d, new pid %d)",
+ mClientPid, callingPid);
+ return EBUSY;
+ }
+
+ if (mCameraClient != 0 && (client->asBinder() == mCameraClient->asBinder())) {
+ LOG1("Connect to the same client");
+ return NO_ERROR;
+ }
+
+ mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
+ mClientPid = callingPid;
+ mCameraClient = client;
+
+ LOG1("connect X (pid %d)", callingPid);
+ return NO_ERROR;
+}
+
+static void disconnectWindow(const sp<ANativeWindow>& window) {
+ if (window != 0) {
+ status_t result = native_window_api_disconnect(window.get(),
+ NATIVE_WINDOW_API_CAMERA);
+ if (result != NO_ERROR) {
+ ALOGW("native_window_api_disconnect failed: %s (%d)", strerror(-result),
+ result);
+ }
+ }
+}
+
+void CameraClient::disconnect() {
+ int callingPid = getCallingPid();
+ LOG1("disconnect E (pid %d)", callingPid);
+ Mutex::Autolock lock(mLock);
+
+ // Allow both client and the media server to disconnect at all times
+ if (callingPid != mClientPid && callingPid != mServicePid) {
+ ALOGW("different client - don't disconnect");
+ return;
+ }
+
+ if (mClientPid <= 0) {
+ LOG1("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid);
+ return;
+ }
+
+ // Make sure disconnect() is done once and once only, whether it is called
+ // from the user directly, or called by the destructor.
+ if (mHardware == 0) return;
+
+ LOG1("hardware teardown");
+ // Before destroying mHardware, we must make sure it's in the
+ // idle state.
+ // Turn off all messages.
+ disableMsgType(CAMERA_MSG_ALL_MSGS);
+ mHardware->stopPreview();
+ mHardware->cancelPicture();
+ // Release the hardware resources.
+ mHardware->release();
+
+ // Release the held ANativeWindow resources.
+ if (mPreviewWindow != 0) {
+ disconnectWindow(mPreviewWindow);
+ mPreviewWindow = 0;
+ mHardware->setPreviewWindow(mPreviewWindow);
+ }
+ mHardware.clear();
+
+ CameraService::Client::disconnect();
+
+ LOG1("disconnect X (pid %d)", callingPid);
+}
+
+// ----------------------------------------------------------------------------
+
+status_t CameraClient::setPreviewWindow(const sp<IBinder>& binder,
+ const sp<ANativeWindow>& window) {
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ // return if no change in surface.
+ if (binder == mSurface) {
+ return NO_ERROR;
+ }
+
+ if (window != 0) {
+ result = native_window_api_connect(window.get(), NATIVE_WINDOW_API_CAMERA);
+ if (result != NO_ERROR) {
+ ALOGE("native_window_api_connect failed: %s (%d)", strerror(-result),
+ result);
+ return result;
+ }
+ }
+
+ // If preview has been already started, register preview buffers now.
+ if (mHardware->previewEnabled()) {
+ if (window != 0) {
+ native_window_set_scaling_mode(window.get(),
+ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
+ native_window_set_buffers_transform(window.get(), mOrientation);
+ result = mHardware->setPreviewWindow(window);
+ }
+ }
+
+ if (result == NO_ERROR) {
+ // Everything has succeeded. Disconnect the old window and remember the
+ // new window.
+ disconnectWindow(mPreviewWindow);
+ mSurface = binder;
+ mPreviewWindow = window;
+ } else {
+ // Something went wrong after we connected to the new window, so
+ // disconnect here.
+ disconnectWindow(window);
+ }
+
+ return result;
+}
+
+// set the Surface that the preview will use
+status_t CameraClient::setPreviewDisplay(const sp<Surface>& surface) {
+ LOG1("setPreviewDisplay(%p) (pid %d)", surface.get(), getCallingPid());
+
+ sp<IBinder> binder(surface != 0 ? surface->asBinder() : 0);
+ sp<ANativeWindow> window(surface);
+ return setPreviewWindow(binder, window);
+}
+
+// set the SurfaceTexture that the preview will use
+status_t CameraClient::setPreviewTexture(
+ const sp<ISurfaceTexture>& surfaceTexture) {
+ LOG1("setPreviewTexture(%p) (pid %d)", surfaceTexture.get(),
+ getCallingPid());
+
+ sp<IBinder> binder;
+ sp<ANativeWindow> window;
+ if (surfaceTexture != 0) {
+ binder = surfaceTexture->asBinder();
+ window = new SurfaceTextureClient(surfaceTexture);
+ }
+ return setPreviewWindow(binder, window);
+}
+
+// set the preview callback flag to affect how the received frames from
+// preview are handled.
+void CameraClient::setPreviewCallbackFlag(int callback_flag) {
+ LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, getCallingPid());
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return;
+
+ mPreviewCallbackFlag = callback_flag;
+ if (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) {
+ enableMsgType(CAMERA_MSG_PREVIEW_FRAME);
+ } else {
+ disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
+ }
+}
+
+// start preview mode
+status_t CameraClient::startPreview() {
+ LOG1("startPreview (pid %d)", getCallingPid());
+ return startCameraMode(CAMERA_PREVIEW_MODE);
+}
+
+// start recording mode
+status_t CameraClient::startRecording() {
+ LOG1("startRecording (pid %d)", getCallingPid());
+ return startCameraMode(CAMERA_RECORDING_MODE);
+}
+
+// start preview or recording
+status_t CameraClient::startCameraMode(camera_mode mode) {
+ LOG1("startCameraMode(%d)", mode);
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ switch(mode) {
+ case CAMERA_PREVIEW_MODE:
+ if (mSurface == 0 && mPreviewWindow == 0) {
+ LOG1("mSurface is not set yet.");
+ // still able to start preview in this case.
+ }
+ return startPreviewMode();
+ case CAMERA_RECORDING_MODE:
+ if (mSurface == 0 && mPreviewWindow == 0) {
+ ALOGE("mSurface or mPreviewWindow must be set before startRecordingMode.");
+ return INVALID_OPERATION;
+ }
+ return startRecordingMode();
+ default:
+ return UNKNOWN_ERROR;
+ }
+}
+
+status_t CameraClient::startPreviewMode() {
+ LOG1("startPreviewMode");
+ status_t result = NO_ERROR;
+
+ // if preview has been enabled, nothing needs to be done
+ if (mHardware->previewEnabled()) {
+ return NO_ERROR;
+ }
+
+ if (mPreviewWindow != 0) {
+ native_window_set_scaling_mode(mPreviewWindow.get(),
+ NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
+ native_window_set_buffers_transform(mPreviewWindow.get(),
+ mOrientation);
+ }
+ mHardware->setPreviewWindow(mPreviewWindow);
+ result = mHardware->startPreview();
+
+ return result;
+}
+
+status_t CameraClient::startRecordingMode() {
+ LOG1("startRecordingMode");
+ status_t result = NO_ERROR;
+
+ // if recording has been enabled, nothing needs to be done
+ if (mHardware->recordingEnabled()) {
+ return NO_ERROR;
+ }
+
+ // if preview has not been started, start preview first
+ if (!mHardware->previewEnabled()) {
+ result = startPreviewMode();
+ if (result != NO_ERROR) {
+ return result;
+ }
+ }
+
+ // start recording mode
+ enableMsgType(CAMERA_MSG_VIDEO_FRAME);
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+ result = mHardware->startRecording();
+ if (result != NO_ERROR) {
+ ALOGE("mHardware->startRecording() failed with status %d", result);
+ }
+ return result;
+}
+
+// stop preview mode
+void CameraClient::stopPreview() {
+ LOG1("stopPreview (pid %d)", getCallingPid());
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return;
+
+
+ disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
+ mHardware->stopPreview();
+
+ mPreviewBuffer.clear();
+}
+
+// stop recording mode
+void CameraClient::stopRecording() {
+ LOG1("stopRecording (pid %d)", getCallingPid());
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return;
+
+ disableMsgType(CAMERA_MSG_VIDEO_FRAME);
+ mHardware->stopRecording();
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+
+ mPreviewBuffer.clear();
+}
+
+// release a recording frame
+void CameraClient::releaseRecordingFrame(const sp<IMemory>& mem) {
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return;
+ mHardware->releaseRecordingFrame(mem);
+}
+
+status_t CameraClient::storeMetaDataInBuffers(bool enabled)
+{
+ LOG1("storeMetaDataInBuffers: %s", enabled? "true": "false");
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) {
+ return UNKNOWN_ERROR;
+ }
+ return mHardware->storeMetaDataInBuffers(enabled);
+}
+
+bool CameraClient::previewEnabled() {
+ LOG1("previewEnabled (pid %d)", getCallingPid());
+
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return false;
+ return mHardware->previewEnabled();
+}
+
+bool CameraClient::recordingEnabled() {
+ LOG1("recordingEnabled (pid %d)", getCallingPid());
+
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return false;
+ return mHardware->recordingEnabled();
+}
+
+status_t CameraClient::autoFocus() {
+ LOG1("autoFocus (pid %d)", getCallingPid());
+
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ return mHardware->autoFocus();
+}
+
+status_t CameraClient::cancelAutoFocus() {
+ LOG1("cancelAutoFocus (pid %d)", getCallingPid());
+
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ return mHardware->cancelAutoFocus();
+}
+
+// take a picture - image is returned in callback
+status_t CameraClient::takePicture(int msgType) {
+ LOG1("takePicture (pid %d): 0x%x", getCallingPid(), msgType);
+
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ if ((msgType & CAMERA_MSG_RAW_IMAGE) &&
+ (msgType & CAMERA_MSG_RAW_IMAGE_NOTIFY)) {
+ ALOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY"
+ " cannot be both enabled");
+ return BAD_VALUE;
+ }
+
+ // We only accept picture related message types
+ // and ignore other types of messages for takePicture().
+ int picMsgType = msgType
+ & (CAMERA_MSG_SHUTTER |
+ CAMERA_MSG_POSTVIEW_FRAME |
+ CAMERA_MSG_RAW_IMAGE |
+ CAMERA_MSG_RAW_IMAGE_NOTIFY |
+ CAMERA_MSG_COMPRESSED_IMAGE);
+
+ enableMsgType(picMsgType);
+
+ return mHardware->takePicture();
+}
+
+// set preview/capture parameters - key/value pairs
+status_t CameraClient::setParameters(const String8& params) {
+ LOG1("setParameters (pid %d) (%s)", getCallingPid(), params.string());
+
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ CameraParameters p(params);
+ return mHardware->setParameters(p);
+}
+
+// get preview/capture parameters - key/value pairs
+String8 CameraClient::getParameters() const {
+ Mutex::Autolock lock(mLock);
+ if (checkPidAndHardware() != NO_ERROR) return String8();
+
+ String8 params(mHardware->getParameters().flatten());
+ LOG1("getParameters (pid %d) (%s)", getCallingPid(), params.string());
+ return params;
+}
+
+// enable shutter sound
+status_t CameraClient::enableShutterSound(bool enable) {
+ LOG1("enableShutterSound (pid %d)", getCallingPid());
+
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ if (enable) {
+ mPlayShutterSound = true;
+ return OK;
+ }
+
+ // Disabling shutter sound may not be allowed. In that case only
+ // allow the mediaserver process to disable the sound.
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.camera.sound.forced", value, "0");
+ if (strcmp(value, "0") != 0) {
+ // Disabling shutter sound is not allowed. Deny if the current
+ // process is not mediaserver.
+ if (getCallingPid() != getpid()) {
+ ALOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid());
+ return PERMISSION_DENIED;
+ }
+ }
+
+ mPlayShutterSound = false;
+ return OK;
+}
+
+status_t CameraClient::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
+ LOG1("sendCommand (pid %d)", getCallingPid());
+ int orientation;
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPidAndHardware();
+ if (result != NO_ERROR) return result;
+
+ if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
+ // Mirror the preview if the camera is front-facing.
+ orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
+ if (orientation == -1) return BAD_VALUE;
+
+ if (mOrientation != orientation) {
+ mOrientation = orientation;
+ if (mPreviewWindow != 0) {
+ native_window_set_buffers_transform(mPreviewWindow.get(),
+ mOrientation);
+ }
+ }
+ return OK;
+ } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) {
+ switch (arg1) {
+ case 0:
+ return enableShutterSound(false);
+ case 1:
+ return enableShutterSound(true);
+ default:
+ return BAD_VALUE;
+ }
+ return OK;
+ } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) {
+ mCameraService->playSound(CameraService::SOUND_RECORDING);
+ } else if (cmd == CAMERA_CMD_SET_VIDEO_BUFFER_COUNT) {
+ // Silently ignore this command
+ return INVALID_OPERATION;
+ } else if (cmd == CAMERA_CMD_PING) {
+ // If mHardware is 0, checkPidAndHardware will return error.
+ return OK;
+ }
+
+ return mHardware->sendCommand(cmd, arg1, arg2);
+}
+
+// ----------------------------------------------------------------------------
+
+void CameraClient::enableMsgType(int32_t msgType) {
+ android_atomic_or(msgType, &mMsgEnabled);
+ mHardware->enableMsgType(msgType);
+}
+
+void CameraClient::disableMsgType(int32_t msgType) {
+ android_atomic_and(~msgType, &mMsgEnabled);
+ mHardware->disableMsgType(msgType);
+}
+
+#define CHECK_MESSAGE_INTERVAL 10 // 10ms
+bool CameraClient::lockIfMessageWanted(int32_t msgType) {
+ int sleepCount = 0;
+ while (mMsgEnabled & msgType) {
+ if (mLock.tryLock() == NO_ERROR) {
+ if (sleepCount > 0) {
+ LOG1("lockIfMessageWanted(%d): waited for %d ms",
+ msgType, sleepCount * CHECK_MESSAGE_INTERVAL);
+ }
+ return true;
+ }
+ if (sleepCount++ == 0) {
+ LOG1("lockIfMessageWanted(%d): enter sleep", msgType);
+ }
+ usleep(CHECK_MESSAGE_INTERVAL * 1000);
+ }
+ ALOGW("lockIfMessageWanted(%d): dropped unwanted message", msgType);
+ return false;
+}
+
+// Callback messages can be dispatched to internal handlers or pass to our
+// client's callback functions, depending on the message type.
+//
+// notifyCallback:
+// CAMERA_MSG_SHUTTER handleShutter
+// (others) c->notifyCallback
+// dataCallback:
+// CAMERA_MSG_PREVIEW_FRAME handlePreviewData
+// CAMERA_MSG_POSTVIEW_FRAME handlePostview
+// CAMERA_MSG_RAW_IMAGE handleRawPicture
+// CAMERA_MSG_COMPRESSED_IMAGE handleCompressedPicture
+// (others) c->dataCallback
+// dataCallbackTimestamp
+// (others) c->dataCallbackTimestamp
+//
+// NOTE: the *Callback functions grab mLock of the client before passing
+// control to handle* functions. So the handle* functions must release the
+// lock before calling the ICameraClient's callbacks, so those callbacks can
+// invoke methods in the Client class again (For example, the preview frame
+// callback may want to releaseRecordingFrame). The handle* functions must
+// release the lock after all accesses to member variables, so it must be
+// handled very carefully.
+
+void CameraClient::notifyCallback(int32_t msgType, int32_t ext1,
+ int32_t ext2, void* user) {
+ LOG2("notifyCallback(%d)", msgType);
+
+ Mutex* lock = getClientLockFromCookie(user);
+ if (lock == NULL) return;
+ Mutex::Autolock alock(*lock);
+
+ CameraClient* client =
+ static_cast<CameraClient*>(getClientFromCookie(user));
+ if (client == NULL) return;
+
+ if (!client->lockIfMessageWanted(msgType)) return;
+
+ switch (msgType) {
+ case CAMERA_MSG_SHUTTER:
+ // ext1 is the dimension of the yuv picture.
+ client->handleShutter();
+ break;
+ default:
+ client->handleGenericNotify(msgType, ext1, ext2);
+ break;
+ }
+}
+
+void CameraClient::dataCallback(int32_t msgType,
+ const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) {
+ LOG2("dataCallback(%d)", msgType);
+
+ Mutex* lock = getClientLockFromCookie(user);
+ if (lock == NULL) return;
+ Mutex::Autolock alock(*lock);
+
+ CameraClient* client =
+ static_cast<CameraClient*>(getClientFromCookie(user));
+ if (client == NULL) return;
+
+ if (!client->lockIfMessageWanted(msgType)) return;
+ if (dataPtr == 0 && metadata == NULL) {
+ ALOGE("Null data returned in data callback");
+ client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
+ return;
+ }
+
+ switch (msgType & ~CAMERA_MSG_PREVIEW_METADATA) {
+ case CAMERA_MSG_PREVIEW_FRAME:
+ client->handlePreviewData(msgType, dataPtr, metadata);
+ break;
+ case CAMERA_MSG_POSTVIEW_FRAME:
+ client->handlePostview(dataPtr);
+ break;
+ case CAMERA_MSG_RAW_IMAGE:
+ client->handleRawPicture(dataPtr);
+ break;
+ case CAMERA_MSG_COMPRESSED_IMAGE:
+ client->handleCompressedPicture(dataPtr);
+ break;
+ default:
+ client->handleGenericData(msgType, dataPtr, metadata);
+ break;
+ }
+}
+
+void CameraClient::dataCallbackTimestamp(nsecs_t timestamp,
+ int32_t msgType, const sp<IMemory>& dataPtr, void* user) {
+ LOG2("dataCallbackTimestamp(%d)", msgType);
+
+ Mutex* lock = getClientLockFromCookie(user);
+ if (lock == NULL) return;
+ Mutex::Autolock alock(*lock);
+
+ CameraClient* client =
+ static_cast<CameraClient*>(getClientFromCookie(user));
+ if (client == NULL) return;
+
+ if (!client->lockIfMessageWanted(msgType)) return;
+
+ if (dataPtr == 0) {
+ ALOGE("Null data returned in data with timestamp callback");
+ client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
+ return;
+ }
+
+ client->handleGenericDataTimestamp(timestamp, msgType, dataPtr);
+}
+
+// snapshot taken callback
+void CameraClient::handleShutter(void) {
+ if (mPlayShutterSound) {
+ mCameraService->playSound(CameraService::SOUND_SHUTTER);
+ }
+
+ sp<ICameraClient> c = mCameraClient;
+ if (c != 0) {
+ mLock.unlock();
+ c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
+ if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return;
+ }
+ disableMsgType(CAMERA_MSG_SHUTTER);
+
+ mLock.unlock();
+}
+
+// preview callback - frame buffer update
+void CameraClient::handlePreviewData(int32_t msgType,
+ const sp<IMemory>& mem,
+ camera_frame_metadata_t *metadata) {
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
+
+ // local copy of the callback flags
+ int flags = mPreviewCallbackFlag;
+
+ // is callback enabled?
+ if (!(flags & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
+ // If the enable bit is off, the copy-out and one-shot bits are ignored
+ LOG2("frame callback is disabled");
+ mLock.unlock();
+ return;
+ }
+
+ // hold a strong pointer to the client
+ sp<ICameraClient> c = mCameraClient;
+
+ // clear callback flags if no client or one-shot mode
+ if (c == 0 || (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK)) {
+ LOG2("Disable preview callback");
+ mPreviewCallbackFlag &= ~(CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK |
+ CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK |
+ CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK);
+ disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
+ }
+
+ if (c != 0) {
+ // Is the received frame copied out or not?
+ if (flags & CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
+ LOG2("frame is copied");
+ copyFrameAndPostCopiedFrame(msgType, c, heap, offset, size, metadata);
+ } else {
+ LOG2("frame is forwarded");
+ mLock.unlock();
+ c->dataCallback(msgType, mem, metadata);
+ }
+ } else {
+ mLock.unlock();
+ }
+}
+
+// picture callback - postview image ready
+void CameraClient::handlePostview(const sp<IMemory>& mem) {
+ disableMsgType(CAMERA_MSG_POSTVIEW_FRAME);
+
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem, NULL);
+ }
+}
+
+// picture callback - raw image ready
+void CameraClient::handleRawPicture(const sp<IMemory>& mem) {
+ disableMsgType(CAMERA_MSG_RAW_IMAGE);
+
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
+
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem, NULL);
+ }
+}
+
+// picture callback - compressed picture ready
+void CameraClient::handleCompressedPicture(const sp<IMemory>& mem) {
+ disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE);
+
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL);
+ }
+}
+
+
+void CameraClient::handleGenericNotify(int32_t msgType,
+ int32_t ext1, int32_t ext2) {
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->notifyCallback(msgType, ext1, ext2);
+ }
+}
+
+void CameraClient::handleGenericData(int32_t msgType,
+ const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata) {
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->dataCallback(msgType, dataPtr, metadata);
+ }
+}
+
+void CameraClient::handleGenericDataTimestamp(nsecs_t timestamp,
+ int32_t msgType, const sp<IMemory>& dataPtr) {
+ sp<ICameraClient> c = mCameraClient;
+ mLock.unlock();
+ if (c != 0) {
+ c->dataCallbackTimestamp(timestamp, msgType, dataPtr);
+ }
+}
+
+void CameraClient::copyFrameAndPostCopiedFrame(
+ int32_t msgType, const sp<ICameraClient>& client,
+ const sp<IMemoryHeap>& heap, size_t offset, size_t size,
+ camera_frame_metadata_t *metadata) {
+ LOG2("copyFrameAndPostCopiedFrame");
+ // It is necessary to copy out of pmem before sending this to
+ // the callback. For efficiency, reuse the same MemoryHeapBase
+ // provided it's big enough. Don't allocate the memory or
+ // perform the copy if there's no callback.
+ // hold the preview lock while we grab a reference to the preview buffer
+ sp<MemoryHeapBase> previewBuffer;
+
+ if (mPreviewBuffer == 0) {
+ mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
+ } else if (size > mPreviewBuffer->virtualSize()) {
+ mPreviewBuffer.clear();
+ mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
+ }
+ if (mPreviewBuffer == 0) {
+ ALOGE("failed to allocate space for preview buffer");
+ mLock.unlock();
+ return;
+ }
+ previewBuffer = mPreviewBuffer;
+
+ memcpy(previewBuffer->base(), (uint8_t *)heap->base() + offset, size);
+
+ sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
+ if (frame == 0) {
+ ALOGE("failed to allocate space for frame callback");
+ mLock.unlock();
+ return;
+ }
+
+ mLock.unlock();
+ client->dataCallback(msgType, frame, metadata);
+}
+
+int CameraClient::getOrientation(int degrees, bool mirror) {
+ if (!mirror) {
+ if (degrees == 0) return 0;
+ else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
+ else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
+ else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
+ } else { // Do mirror (horizontal flip)
+ if (degrees == 0) { // FLIP_H and ROT_0
+ return HAL_TRANSFORM_FLIP_H;
+ } else if (degrees == 90) { // FLIP_H and ROT_90
+ return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;
+ } else if (degrees == 180) { // FLIP_H and ROT_180
+ return HAL_TRANSFORM_FLIP_V;
+ } else if (degrees == 270) { // FLIP_H and ROT_270
+ return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
+ }
+ }
+ ALOGE("Invalid setDisplayOrientation degrees=%d", degrees);
+ return -1;
+}
+
+}; // namespace android
diff --git a/services/camera/libcameraservice/CameraClient.h b/services/camera/libcameraservice/CameraClient.h
new file mode 100644
index 00000000..2f31c4e7
--- /dev/null
+++ b/services/camera/libcameraservice/CameraClient.h
@@ -0,0 +1,156 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERACLIENT_H
+#define ANDROID_SERVERS_CAMERA_CAMERACLIENT_H
+
+#include "CameraService.h"
+
+namespace android {
+
+class MemoryHeapBase;
+class CameraHardwareInterface;
+
+class CameraClient : public CameraService::Client
+{
+public:
+ // ICamera interface (see ICamera for details)
+ virtual void disconnect();
+ virtual status_t connect(const sp<ICameraClient>& client);
+ virtual status_t lock();
+ virtual status_t unlock();
+ virtual status_t setPreviewDisplay(const sp<Surface>& surface);
+ virtual status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
+ virtual void setPreviewCallbackFlag(int flag);
+ virtual status_t startPreview();
+ virtual void stopPreview();
+ virtual bool previewEnabled();
+ virtual status_t storeMetaDataInBuffers(bool enabled);
+ virtual status_t startRecording();
+ virtual void stopRecording();
+ virtual bool recordingEnabled();
+ virtual void releaseRecordingFrame(const sp<IMemory>& mem);
+ virtual status_t autoFocus();
+ virtual status_t cancelAutoFocus();
+ virtual status_t takePicture(int msgType);
+ virtual status_t setParameters(const String8& params);
+ virtual String8 getParameters() const;
+ virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
+
+ // Interface used by CameraService
+ CameraClient(const sp<CameraService>& cameraService,
+ const sp<ICameraClient>& cameraClient,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid);
+ ~CameraClient();
+
+ status_t initialize(camera_module_t *module);
+
+ status_t dump(int fd, const Vector<String16>& args);
+
+private:
+
+ // check whether the calling process matches mClientPid.
+ status_t checkPid() const;
+ status_t checkPidAndHardware() const; // also check mHardware != 0
+
+ // these are internal functions used to set up preview buffers
+ status_t registerPreviewBuffers();
+
+ // camera operation mode
+ enum camera_mode {
+ CAMERA_PREVIEW_MODE = 0, // frame automatically released
+ CAMERA_RECORDING_MODE = 1, // frame has to be explicitly released by releaseRecordingFrame()
+ };
+ // these are internal functions used for preview/recording
+ status_t startCameraMode(camera_mode mode);
+ status_t startPreviewMode();
+ status_t startRecordingMode();
+
+ // internal function used by sendCommand to enable/disable shutter sound.
+ status_t enableShutterSound(bool enable);
+
+ // these are static callback functions
+ static void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user);
+ static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
+ camera_frame_metadata_t *metadata, void* user);
+ static void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr, void* user);
+ // handlers for messages
+ void handleShutter(void);
+ void handlePreviewData(int32_t msgType, const sp<IMemory>& mem,
+ camera_frame_metadata_t *metadata);
+ void handlePostview(const sp<IMemory>& mem);
+ void handleRawPicture(const sp<IMemory>& mem);
+ void handleCompressedPicture(const sp<IMemory>& mem);
+ void handleGenericNotify(int32_t msgType, int32_t ext1, int32_t ext2);
+ void handleGenericData(int32_t msgType, const sp<IMemory>& dataPtr,
+ camera_frame_metadata_t *metadata);
+ void handleGenericDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
+
+ void copyFrameAndPostCopiedFrame(
+ int32_t msgType,
+ const sp<ICameraClient>& client,
+ const sp<IMemoryHeap>& heap,
+ size_t offset, size_t size,
+ camera_frame_metadata_t *metadata);
+
+ int getOrientation(int orientation, bool mirror);
+
+ status_t setPreviewWindow(
+ const sp<IBinder>& binder,
+ const sp<ANativeWindow>& window);
+
+
+ // these are initialized in the constructor.
+ sp<CameraHardwareInterface> mHardware; // cleared after disconnect()
+ int mPreviewCallbackFlag;
+ int mOrientation; // Current display orientation
+ bool mPlayShutterSound;
+
+ // Ensures atomicity among the public methods
+ mutable Mutex mLock;
+ // This is a binder of Surface or SurfaceTexture.
+ sp<IBinder> mSurface;
+ sp<ANativeWindow> mPreviewWindow;
+
+ // If the user want us to return a copy of the preview frame (instead
+ // of the original one), we allocate mPreviewBuffer and reuse it if possible.
+ sp<MemoryHeapBase> mPreviewBuffer;
+
+ // We need to avoid the deadlock when the incoming command thread and
+ // the CameraHardwareInterface callback thread both want to grab mLock.
+ // An extra flag is used to tell the callback thread that it should stop
+ // trying to deliver the callback messages if the client is not
+ // interested in it anymore. For example, if the client is calling
+ // stopPreview(), the preview frame messages do not need to be delivered
+ // anymore.
+
+ // This function takes the same parameter as the enableMsgType() and
+ // disableMsgType() functions in CameraHardwareInterface.
+ void enableMsgType(int32_t msgType);
+ void disableMsgType(int32_t msgType);
+ volatile int32_t mMsgEnabled;
+
+ // This function keeps trying to grab mLock, or give up if the message
+ // is found to be disabled. It returns true if mLock is grabbed.
+ bool lockIfMessageWanted(int32_t msgType);
+};
+
+}
+
+#endif
diff --git a/services/camera/libcameraservice/CameraHardwareInterface.h b/services/camera/libcameraservice/CameraHardwareInterface.h
index 87a08020..05ac9fa1 100644
--- a/services/camera/libcameraservice/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/CameraHardwareInterface.h
@@ -569,7 +569,7 @@ private:
int rc;
ANativeWindow *a = anw(w);
ANativeWindowBuffer* anb;
- rc = a->dequeueBuffer(a, &anb);
+ rc = native_window_dequeue_buffer_and_wait(a, &anb);
if (!rc) {
*buffer = &anb->handle;
*stride = anb->stride;
@@ -587,8 +587,7 @@ private:
buffer_handle_t* buffer)
{
ANativeWindow *a = anw(w);
- return a->lockBuffer(a,
- container_of(buffer, ANativeWindowBuffer, handle));
+ return 0;
}
static int __enqueue_buffer(struct preview_stream_ops* w,
@@ -596,7 +595,7 @@ private:
{
ANativeWindow *a = anw(w);
return a->queueBuffer(a,
- container_of(buffer, ANativeWindowBuffer, handle));
+ container_of(buffer, ANativeWindowBuffer, handle), -1);
}
static int __cancel_buffer(struct preview_stream_ops* w,
@@ -604,7 +603,7 @@ private:
{
ANativeWindow *a = anw(w);
return a->cancelBuffer(a,
- container_of(buffer, ANativeWindowBuffer, handle));
+ container_of(buffer, ANativeWindowBuffer, handle), -1);
}
static int __set_buffer_count(struct preview_stream_ops* w, int count)
diff --git a/services/camera/libcameraservice/CameraHardwareStub.cpp b/services/camera/libcameraservice/CameraHardwareStub.cpp
deleted file mode 100644
index cdfb2f5e..00000000
--- a/services/camera/libcameraservice/CameraHardwareStub.cpp
+++ /dev/null
@@ -1,410 +0,0 @@
-/*
-**
-** Copyright 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.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT 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 "CameraHardwareStub"
-#include <utils/Log.h>
-
-#include "CameraHardwareStub.h"
-#include <utils/threads.h>
-#include <fcntl.h>
-#include <sys/mman.h>
-
-#include "CannedJpeg.h"
-
-namespace android {
-
-CameraHardwareStub::CameraHardwareStub()
- : mParameters(),
- mPreviewHeap(0),
- mRawHeap(0),
- mFakeCamera(0),
- mPreviewFrameSize(0),
- mNotifyCb(0),
- mDataCb(0),
- mDataCbTimestamp(0),
- mCallbackCookie(0),
- mMsgEnabled(0),
- mCurrentPreviewFrame(0)
-{
- initDefaultParameters();
-}
-
-void CameraHardwareStub::initDefaultParameters()
-{
- CameraParameters p;
-
- p.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "320x240");
- p.setPreviewSize(320, 240);
- p.setPreviewFrameRate(15);
- p.setPreviewFormat(CameraParameters::PIXEL_FORMAT_YUV420SP);
-
- p.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, "320x240");
- p.setPictureSize(320, 240);
- p.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
-
- if (setParameters(p) != NO_ERROR) {
- ALOGE("Failed to set default parameters?!");
- }
-}
-
-void CameraHardwareStub::initHeapLocked()
-{
- // Create raw heap.
- int picture_width, picture_height;
- mParameters.getPictureSize(&picture_width, &picture_height);
- mRawHeap = new MemoryHeapBase(picture_width * picture_height * 3 / 2);
-
- int preview_width, preview_height;
- mParameters.getPreviewSize(&preview_width, &preview_height);
- ALOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height);
-
- // Note that we enforce yuv420sp in setParameters().
- int how_big = preview_width * preview_height * 3 / 2;
-
- // If we are being reinitialized to the same size as before, no
- // work needs to be done.
- if (how_big == mPreviewFrameSize)
- return;
-
- mPreviewFrameSize = how_big;
-
- // Make a new mmap'ed heap that can be shared across processes.
- // use code below to test with pmem
- mPreviewHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
- // Make an IMemory for each frame so that we can reuse them in callbacks.
- for (int i = 0; i < kBufferCount; i++) {
- mBuffers[i] = new MemoryBase(mPreviewHeap, i * mPreviewFrameSize, mPreviewFrameSize);
- }
-
- // Recreate the fake camera to reflect the current size.
- delete mFakeCamera;
- mFakeCamera = new FakeCamera(preview_width, preview_height);
-}
-
-CameraHardwareStub::~CameraHardwareStub()
-{
- delete mFakeCamera;
- mFakeCamera = 0; // paranoia
-}
-
-status_t CameraHardwareStub::setPreviewWindow(const sp<ANativeWindow>& buf)
-{
- return NO_ERROR;
-}
-
-sp<IMemoryHeap> CameraHardwareStub::getRawHeap() const
-{
- return mRawHeap;
-}
-
-void CameraHardwareStub::setCallbacks(notify_callback notify_cb,
- data_callback data_cb,
- data_callback_timestamp data_cb_timestamp,
- void* user)
-{
- Mutex::Autolock lock(mLock);
- mNotifyCb = notify_cb;
- mDataCb = data_cb;
- mDataCbTimestamp = data_cb_timestamp;
- mCallbackCookie = user;
-}
-
-void CameraHardwareStub::enableMsgType(int32_t msgType)
-{
- Mutex::Autolock lock(mLock);
- mMsgEnabled |= msgType;
-}
-
-void CameraHardwareStub::disableMsgType(int32_t msgType)
-{
- Mutex::Autolock lock(mLock);
- mMsgEnabled &= ~msgType;
-}
-
-bool CameraHardwareStub::msgTypeEnabled(int32_t msgType)
-{
- Mutex::Autolock lock(mLock);
- return (mMsgEnabled & msgType);
-}
-
-// ---------------------------------------------------------------------------
-
-int CameraHardwareStub::previewThread()
-{
- mLock.lock();
- // the attributes below can change under our feet...
-
- int previewFrameRate = mParameters.getPreviewFrameRate();
-
- // Find the offset within the heap of the current buffer.
- ssize_t offset = mCurrentPreviewFrame * mPreviewFrameSize;
-
- sp<MemoryHeapBase> heap = mPreviewHeap;
-
- // this assumes the internal state of fake camera doesn't change
- // (or is thread safe)
- FakeCamera* fakeCamera = mFakeCamera;
-
- sp<MemoryBase> buffer = mBuffers[mCurrentPreviewFrame];
-
- mLock.unlock();
-
- // TODO: here check all the conditions that could go wrong
- if (buffer != 0) {
- // Calculate how long to wait between frames.
- int delay = (int)(1000000.0f / float(previewFrameRate));
-
- // This is always valid, even if the client died -- the memory
- // is still mapped in our process.
- void *base = heap->base();
-
- // Fill the current frame with the fake camera.
- uint8_t *frame = ((uint8_t *)base) + offset;
- fakeCamera->getNextFrameAsYuv420(frame);
-
- //ALOGV("previewThread: generated frame to buffer %d", mCurrentPreviewFrame);
-
- // Notify the client of a new frame.
- if (mMsgEnabled & CAMERA_MSG_PREVIEW_FRAME)
- mDataCb(CAMERA_MSG_PREVIEW_FRAME, buffer, NULL, mCallbackCookie);
-
- // Advance the buffer pointer.
- mCurrentPreviewFrame = (mCurrentPreviewFrame + 1) % kBufferCount;
-
- // Wait for it...
- usleep(delay);
- }
-
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::startPreview()
-{
- Mutex::Autolock lock(mLock);
- if (mPreviewThread != 0) {
- // already running
- return INVALID_OPERATION;
- }
- mPreviewThread = new PreviewThread(this);
- return NO_ERROR;
-}
-
-void CameraHardwareStub::stopPreview()
-{
- sp<PreviewThread> previewThread;
-
- { // scope for the lock
- Mutex::Autolock lock(mLock);
- previewThread = mPreviewThread;
- }
-
- // don't hold the lock while waiting for the thread to quit
- if (previewThread != 0) {
- previewThread->requestExitAndWait();
- }
-
- Mutex::Autolock lock(mLock);
- mPreviewThread.clear();
-}
-
-bool CameraHardwareStub::previewEnabled() {
- return mPreviewThread != 0;
-}
-
-status_t CameraHardwareStub::startRecording()
-{
- return UNKNOWN_ERROR;
-}
-
-void CameraHardwareStub::stopRecording()
-{
-}
-
-bool CameraHardwareStub::recordingEnabled()
-{
- return false;
-}
-
-void CameraHardwareStub::releaseRecordingFrame(const sp<IMemory>& mem)
-{
-}
-
-// ---------------------------------------------------------------------------
-
-int CameraHardwareStub::beginAutoFocusThread(void *cookie)
-{
- CameraHardwareStub *c = (CameraHardwareStub *)cookie;
- return c->autoFocusThread();
-}
-
-int CameraHardwareStub::autoFocusThread()
-{
- if (mMsgEnabled & CAMERA_MSG_FOCUS)
- mNotifyCb(CAMERA_MSG_FOCUS, true, 0, mCallbackCookie);
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::autoFocus()
-{
- Mutex::Autolock lock(mLock);
- if (createThread(beginAutoFocusThread, this) == false)
- return UNKNOWN_ERROR;
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::cancelAutoFocus()
-{
- return NO_ERROR;
-}
-
-/*static*/ int CameraHardwareStub::beginPictureThread(void *cookie)
-{
- CameraHardwareStub *c = (CameraHardwareStub *)cookie;
- return c->pictureThread();
-}
-
-int CameraHardwareStub::pictureThread()
-{
- if (mMsgEnabled & CAMERA_MSG_SHUTTER)
- mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);
-
- if (mMsgEnabled & CAMERA_MSG_RAW_IMAGE) {
- //FIXME: use a canned YUV image!
- // In the meantime just make another fake camera picture.
- int w, h;
- mParameters.getPictureSize(&w, &h);
- sp<MemoryBase> mem = new MemoryBase(mRawHeap, 0, w * h * 3 / 2);
- FakeCamera cam(w, h);
- cam.getNextFrameAsYuv420((uint8_t *)mRawHeap->base());
- mDataCb(CAMERA_MSG_RAW_IMAGE, mem, NULL, mCallbackCookie);
- }
-
- if (mMsgEnabled & CAMERA_MSG_COMPRESSED_IMAGE) {
- sp<MemoryHeapBase> heap = new MemoryHeapBase(kCannedJpegSize);
- sp<MemoryBase> mem = new MemoryBase(heap, 0, kCannedJpegSize);
- memcpy(heap->base(), kCannedJpeg, kCannedJpegSize);
- mDataCb(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL, mCallbackCookie);
- }
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::takePicture()
-{
- stopPreview();
- if (createThread(beginPictureThread, this) == false)
- return UNKNOWN_ERROR;
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::cancelPicture()
-{
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::dump(int fd, const Vector<String16>& args) const
-{
- const size_t SIZE = 256;
- char buffer[SIZE];
- String8 result;
- AutoMutex lock(&mLock);
- if (mFakeCamera != 0) {
- mFakeCamera->dump(fd);
- mParameters.dump(fd, args);
- snprintf(buffer, 255, " preview frame(%d), size (%d), running(%s)\n", mCurrentPreviewFrame, mPreviewFrameSize, mPreviewRunning?"true": "false");
- result.append(buffer);
- } else {
- result.append("No camera client yet.\n");
- }
- write(fd, result.string(), result.size());
- return NO_ERROR;
-}
-
-status_t CameraHardwareStub::setParameters(const CameraParameters& params)
-{
- Mutex::Autolock lock(mLock);
- // XXX verify params
-
- if (strcmp(params.getPreviewFormat(),
- CameraParameters::PIXEL_FORMAT_YUV420SP) != 0) {
- ALOGE("Only yuv420sp preview is supported");
- return -1;
- }
-
- if (strcmp(params.getPictureFormat(),
- CameraParameters::PIXEL_FORMAT_JPEG) != 0) {
- ALOGE("Only jpeg still pictures are supported");
- return -1;
- }
-
- int w, h;
- params.getPictureSize(&w, &h);
- if (w != kCannedJpegWidth && h != kCannedJpegHeight) {
- ALOGE("Still picture size must be size of canned JPEG (%dx%d)",
- kCannedJpegWidth, kCannedJpegHeight);
- return -1;
- }
-
- mParameters = params;
- initHeapLocked();
-
- return NO_ERROR;
-}
-
-CameraParameters CameraHardwareStub::getParameters() const
-{
- Mutex::Autolock lock(mLock);
- return mParameters;
-}
-
-status_t CameraHardwareStub::sendCommand(int32_t command, int32_t arg1,
- int32_t arg2)
-{
- return BAD_VALUE;
-}
-
-void CameraHardwareStub::release()
-{
-}
-
-sp<CameraHardwareInterface> CameraHardwareStub::createInstance()
-{
- return new CameraHardwareStub();
-}
-
-static CameraInfo sCameraInfo[] = {
- {
- CAMERA_FACING_BACK,
- 90, /* orientation */
- }
-};
-
-extern "C" int HAL_getNumberOfCameras()
-{
- return sizeof(sCameraInfo) / sizeof(sCameraInfo[0]);
-}
-
-extern "C" void HAL_getCameraInfo(int cameraId, struct CameraInfo* cameraInfo)
-{
- memcpy(cameraInfo, &sCameraInfo[cameraId], sizeof(CameraInfo));
-}
-
-extern "C" sp<CameraHardwareInterface> HAL_openCameraHardware(int cameraId)
-{
- return CameraHardwareStub::createInstance();
-}
-
-}; // namespace android
diff --git a/services/camera/libcameraservice/CameraHardwareStub.h b/services/camera/libcameraservice/CameraHardwareStub.h
deleted file mode 100644
index c6d87567..00000000
--- a/services/camera/libcameraservice/CameraHardwareStub.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
-**
-** Copyright 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.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT 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_HARDWARE_CAMERA_HARDWARE_STUB_H
-#define ANDROID_HARDWARE_CAMERA_HARDWARE_STUB_H
-
-#include "FakeCamera.h"
-#include <utils/threads.h>
-#include <camera/CameraHardwareInterface.h>
-#include <binder/MemoryBase.h>
-#include <binder/MemoryHeapBase.h>
-#include <utils/threads.h>
-
-namespace android {
-
-class CameraHardwareStub : public CameraHardwareInterface {
-public:
- virtual status_t setPreviewWindow(const sp<ANativeWindow>& buf);
- virtual sp<IMemoryHeap> getRawHeap() const;
-
- virtual void setCallbacks(notify_callback notify_cb,
- data_callback data_cb,
- data_callback_timestamp data_cb_timestamp,
- void* user);
-
- virtual void enableMsgType(int32_t msgType);
- virtual void disableMsgType(int32_t msgType);
- virtual bool msgTypeEnabled(int32_t msgType);
-
- virtual status_t startPreview();
- virtual void stopPreview();
- virtual bool previewEnabled();
-
- virtual status_t startRecording();
- virtual void stopRecording();
- virtual bool recordingEnabled();
- virtual void releaseRecordingFrame(const sp<IMemory>& mem);
-
- virtual status_t autoFocus();
- virtual status_t cancelAutoFocus();
- virtual status_t takePicture();
- virtual status_t cancelPicture();
- virtual status_t dump(int fd, const Vector<String16>& args) const;
- virtual status_t setParameters(const CameraParameters& params);
- virtual CameraParameters getParameters() const;
- virtual status_t sendCommand(int32_t command, int32_t arg1,
- int32_t arg2);
- virtual void release();
-
- static sp<CameraHardwareInterface> createInstance();
-
-private:
- CameraHardwareStub();
- virtual ~CameraHardwareStub();
-
- static const int kBufferCount = 4;
-
- class PreviewThread : public Thread {
- CameraHardwareStub* mHardware;
- public:
- PreviewThread(CameraHardwareStub* hw) :
- Thread(false), mHardware(hw) { }
- virtual void onFirstRef() {
- run("CameraPreviewThread", PRIORITY_URGENT_DISPLAY);
- }
- virtual bool threadLoop() {
- mHardware->previewThread();
- // loop until we need to quit
- return true;
- }
- };
-
- void initDefaultParameters();
- void initHeapLocked();
-
- int previewThread();
-
- static int beginAutoFocusThread(void *cookie);
- int autoFocusThread();
-
- static int beginPictureThread(void *cookie);
- int pictureThread();
-
- mutable Mutex mLock;
-
- CameraParameters mParameters;
-
- sp<MemoryHeapBase> mPreviewHeap;
- sp<MemoryHeapBase> mRawHeap;
- sp<MemoryBase> mBuffers[kBufferCount];
-
- FakeCamera *mFakeCamera;
- bool mPreviewRunning;
- int mPreviewFrameSize;
-
- // protected by mLock
- sp<PreviewThread> mPreviewThread;
-
- notify_callback mNotifyCb;
- data_callback mDataCb;
- data_callback_timestamp mDataCbTimestamp;
- void *mCallbackCookie;
-
- int32_t mMsgEnabled;
-
- // only used from PreviewThread
- int mCurrentPreviewFrame;
-};
-
-}; // namespace android
-
-#endif
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 385be505..124d24d4 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -38,14 +38,15 @@
#include <utils/String16.h>
#include "CameraService.h"
-#include "CameraHardwareInterface.h"
+#include "CameraClient.h"
+#include "Camera2Client.h"
namespace android {
// ----------------------------------------------------------------------------
// Logging support -- this is for debugging only
// Use "adb shell dumpsys media.camera -v 1" to change it.
-static volatile int32_t gLogLevel = 0;
+volatile int32_t gLogLevel = 0;
#define LOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
#define LOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
@@ -133,7 +134,6 @@ status_t CameraService::getCameraInfo(int cameraId,
sp<ICamera> CameraService::connect(
const sp<ICameraClient>& cameraClient, int cameraId) {
int callingPid = getCallingPid();
- sp<CameraHardwareInterface> hardware = NULL;
LOG1("CameraService::connect E (pid %d, id %d)", callingPid, cameraId);
@@ -186,18 +186,35 @@ sp<ICamera> CameraService::connect(
return NULL;
}
- char camera_device_name[10];
- snprintf(camera_device_name, sizeof(camera_device_name), "%d", cameraId);
+ int deviceVersion;
+ if (mModule->common.module_api_version == CAMERA_MODULE_API_VERSION_2_0) {
+ deviceVersion = info.device_version;
+ } else {
+ deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
+ }
+
+ switch(deviceVersion) {
+ case CAMERA_DEVICE_API_VERSION_1_0:
+ client = new CameraClient(this, cameraClient, cameraId,
+ info.facing, callingPid, getpid());
+ break;
+ case CAMERA_DEVICE_API_VERSION_2_0:
+ client = new Camera2Client(this, cameraClient, cameraId,
+ info.facing, callingPid, getpid());
+ break;
+ default:
+ ALOGE("Unknown camera device HAL version: %d", deviceVersion);
+ return NULL;
+ }
- hardware = new CameraHardwareInterface(camera_device_name);
- if (hardware->initialize(&mModule->common) != OK) {
- hardware.clear();
+ if (client->initialize(mModule) != OK) {
return NULL;
}
- client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid);
+ cameraClient->asBinder()->linkToDeath(this);
+
mClient[cameraId] = client;
- LOG1("CameraService::connect X (id %d)", cameraId);
+ LOG1("CameraService::connect X (id %d, this pid is %d)", cameraId, getpid());
return client;
}
@@ -205,12 +222,29 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) {
int callingPid = getCallingPid();
LOG1("CameraService::removeClient E (pid %d)", callingPid);
- for (int i = 0; i < mNumberOfCameras; i++) {
- // Declare this before the lock to make absolutely sure the
- // destructor won't be called with the lock held.
- sp<Client> client;
+ // Declare this before the lock to make absolutely sure the
+ // destructor won't be called with the lock held.
+ Mutex::Autolock lock(mServiceLock);
+
+ int outIndex;
+ sp<Client> client = findClientUnsafe(cameraClient->asBinder(), outIndex);
+
+ if (client != 0) {
+ // Found our camera, clear and leave.
+ LOG1("removeClient: clear camera %d", outIndex);
+ mClient[outIndex].clear();
+
+ client->unlinkToDeath(this);
+ }
- Mutex::Autolock lock(mServiceLock);
+ LOG1("CameraService::removeClient X (pid %d)", callingPid);
+}
+
+sp<CameraService::Client> CameraService::findClientUnsafe(
+ const wp<IBinder>& cameraClient, int& outIndex) {
+ sp<Client> client;
+
+ for (int i = 0; i < mNumberOfCameras; i++) {
// This happens when we have already disconnected (or this is
// just another unused camera).
@@ -220,20 +254,21 @@ void CameraService::removeClient(const sp<ICameraClient>& cameraClient) {
// Client::~Client() -> disconnect() -> removeClient().
client = mClient[i].promote();
- if (client == 0) {
+ // Clean up stale client entry
+ if (client == NULL) {
mClient[i].clear();
continue;
}
- if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
- // Found our camera, clear and leave.
- LOG1("removeClient: clear camera %d", i);
- mClient[i].clear();
- break;
+ if (cameraClient == client->getCameraClient()->asBinder()) {
+ // Found our camera
+ outIndex = i;
+ return client;
}
}
- LOG1("CameraService::removeClient X (pid %d)", callingPid);
+ outIndex = -1;
+ return NULL;
}
CameraService::Client* CameraService::getClientByIdUnsafe(int cameraId) {
@@ -246,6 +281,21 @@ Mutex* CameraService::getClientLockById(int cameraId) {
return &mClientLock[cameraId];
}
+sp<CameraService::Client> CameraService::getClientByRemote(
+ const wp<IBinder>& cameraClient) {
+
+ // Declare this before the lock to make absolutely sure the
+ // destructor won't be called with the lock held.
+ sp<Client> client;
+
+ Mutex::Autolock lock(mServiceLock);
+
+ int outIndex;
+ client = findClientUnsafe(cameraClient, outIndex);
+
+ return client;
+}
+
status_t CameraService::onTransact(
uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) {
// Permission checks
@@ -277,10 +327,14 @@ status_t CameraService::onTransact(
// the hardware first.
void CameraService::setCameraBusy(int cameraId) {
android_atomic_write(1, &mBusy[cameraId]);
+
+ ALOGV("setCameraBusy cameraId=%d", cameraId);
}
void CameraService::setCameraFree(int cameraId) {
android_atomic_write(0, &mBusy[cameraId]);
+
+ ALOGV("setCameraFree cameraId=%d", cameraId);
}
// We share the media players for shutter and recording sound for all clients.
@@ -335,34 +389,18 @@ void CameraService::playSound(sound_kind kind) {
CameraService::Client::Client(const sp<CameraService>& cameraService,
const sp<ICameraClient>& cameraClient,
- const sp<CameraHardwareInterface>& hardware,
- int cameraId, int cameraFacing, int clientPid) {
+ int cameraId, int cameraFacing, int clientPid, int servicePid) {
int callingPid = getCallingPid();
LOG1("Client::Client E (pid %d, id %d)", callingPid, cameraId);
mCameraService = cameraService;
mCameraClient = cameraClient;
- mHardware = hardware;
mCameraId = cameraId;
mCameraFacing = cameraFacing;
mClientPid = clientPid;
- mMsgEnabled = 0;
- mSurface = 0;
- mPreviewWindow = 0;
+ mServicePid = servicePid;
mDestructionStarted = false;
- mHardware->setCallbacks(notifyCallback,
- dataCallback,
- dataCallbackTimestamp,
- (void *)cameraId);
-
- // Enable zoom, error, focus, and metadata messages by default
- enableMsgType(CAMERA_MSG_ERROR | CAMERA_MSG_ZOOM | CAMERA_MSG_FOCUS |
- CAMERA_MSG_PREVIEW_METADATA | CAMERA_MSG_FOCUS_MOVE);
-
- // Callback is disabled by default
- mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
- mOrientation = getOrientation(0, mCameraFacing == CAMERA_FACING_FRONT);
- mPlayShutterSound = true;
+
cameraService->setCameraBusy(cameraId);
cameraService->loadSound();
LOG1("Client::Client X (pid %d, id %d)", callingPid, cameraId);
@@ -370,582 +408,10 @@ CameraService::Client::Client(const sp<CameraService>& cameraService,
// tear down the client
CameraService::Client::~Client() {
- // this lock should never be NULL
- Mutex* lock = mCameraService->getClientLockById(mCameraId);
- lock->lock();
- mDestructionStarted = true;
- // client will not be accessed from callback. should unlock to prevent dead-lock in disconnect
- lock->unlock();
- int callingPid = getCallingPid();
- LOG1("Client::~Client E (pid %d, this %p)", callingPid, this);
-
- // set mClientPid to let disconnet() tear down the hardware
- mClientPid = callingPid;
- disconnect();
mCameraService->releaseSound();
- LOG1("Client::~Client X (pid %d, this %p)", callingPid, this);
-}
-
-// ----------------------------------------------------------------------------
-
-status_t CameraService::Client::checkPid() const {
- int callingPid = getCallingPid();
- if (callingPid == mClientPid) return NO_ERROR;
-
- ALOGW("attempt to use a locked camera from a different process"
- " (old pid %d, new pid %d)", mClientPid, callingPid);
- return EBUSY;
-}
-status_t CameraService::Client::checkPidAndHardware() const {
- status_t result = checkPid();
- if (result != NO_ERROR) return result;
- if (mHardware == 0) {
- ALOGE("attempt to use a camera after disconnect() (pid %d)", getCallingPid());
- return INVALID_OPERATION;
- }
- return NO_ERROR;
-}
-
-status_t CameraService::Client::lock() {
- int callingPid = getCallingPid();
- LOG1("lock (pid %d)", callingPid);
- Mutex::Autolock ilock(mICameraLock);
- Mutex::Autolock lock(mLock);
-
- // lock camera to this client if the the camera is unlocked
- if (mClientPid == 0) {
- mClientPid = callingPid;
- return NO_ERROR;
- }
-
- // returns NO_ERROR if the client already owns the camera, EBUSY otherwise
- return checkPid();
-}
-
-status_t CameraService::Client::unlock() {
- int callingPid = getCallingPid();
- LOG1("unlock (pid %d)", callingPid);
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
-
- // allow anyone to use camera (after they lock the camera)
- status_t result = checkPid();
- if (result == NO_ERROR) {
- if (mHardware->recordingEnabled()) {
- ALOGE("Not allowed to unlock camera during recording.");
- return INVALID_OPERATION;
- }
- mClientPid = 0;
- LOG1("clear mCameraClient (pid %d)", callingPid);
- // we need to remove the reference to ICameraClient so that when the app
- // goes away, the reference count goes to 0.
- mCameraClient.clear();
- }
- return result;
-}
-
-// connect a new client to the camera
-status_t CameraService::Client::connect(const sp<ICameraClient>& client) {
- int callingPid = getCallingPid();
- LOG1("connect E (pid %d)", callingPid);
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
-
- if (mClientPid != 0 && checkPid() != NO_ERROR) {
- ALOGW("Tried to connect to a locked camera (old pid %d, new pid %d)",
- mClientPid, callingPid);
- return EBUSY;
- }
-
- if (mCameraClient != 0 && (client->asBinder() == mCameraClient->asBinder())) {
- LOG1("Connect to the same client");
- return NO_ERROR;
- }
-
- mPreviewCallbackFlag = CAMERA_FRAME_CALLBACK_FLAG_NOOP;
- mClientPid = callingPid;
- mCameraClient = client;
-
- LOG1("connect X (pid %d)", callingPid);
- return NO_ERROR;
-}
-
-static void disconnectWindow(const sp<ANativeWindow>& window) {
- if (window != 0) {
- status_t result = native_window_api_disconnect(window.get(),
- NATIVE_WINDOW_API_CAMERA);
- if (result != NO_ERROR) {
- ALOGW("native_window_api_disconnect failed: %s (%d)", strerror(-result),
- result);
- }
- }
-}
-
-void CameraService::Client::disconnect() {
- int callingPid = getCallingPid();
- LOG1("disconnect E (pid %d)", callingPid);
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
-
- if (checkPid() != NO_ERROR) {
- ALOGW("different client - don't disconnect");
- return;
- }
-
- if (mClientPid <= 0) {
- LOG1("camera is unlocked (mClientPid = %d), don't tear down hardware", mClientPid);
- return;
- }
-
- // Make sure disconnect() is done once and once only, whether it is called
- // from the user directly, or called by the destructor.
- if (mHardware == 0) return;
-
- LOG1("hardware teardown");
- // Before destroying mHardware, we must make sure it's in the
- // idle state.
- // Turn off all messages.
- disableMsgType(CAMERA_MSG_ALL_MSGS);
- mHardware->stopPreview();
- mHardware->cancelPicture();
- // Release the hardware resources.
- mHardware->release();
-
- // Release the held ANativeWindow resources.
- if (mPreviewWindow != 0) {
- disconnectWindow(mPreviewWindow);
- mPreviewWindow = 0;
- mHardware->setPreviewWindow(mPreviewWindow);
- }
- mHardware.clear();
-
- mCameraService->removeClient(mCameraClient);
- mCameraService->setCameraFree(mCameraId);
-
- LOG1("disconnect X (pid %d)", callingPid);
-}
-
-// ----------------------------------------------------------------------------
-
-status_t CameraService::Client::setPreviewWindow(const sp<IBinder>& binder,
- const sp<ANativeWindow>& window) {
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- // return if no change in surface.
- if (binder == mSurface) {
- return NO_ERROR;
- }
-
- if (window != 0) {
- result = native_window_api_connect(window.get(), NATIVE_WINDOW_API_CAMERA);
- if (result != NO_ERROR) {
- ALOGE("native_window_api_connect failed: %s (%d)", strerror(-result),
- result);
- return result;
- }
- }
-
- // If preview has been already started, register preview buffers now.
- if (mHardware->previewEnabled()) {
- if (window != 0) {
- native_window_set_scaling_mode(window.get(),
- NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
- native_window_set_buffers_transform(window.get(), mOrientation);
- result = mHardware->setPreviewWindow(window);
- }
- }
-
- if (result == NO_ERROR) {
- // Everything has succeeded. Disconnect the old window and remember the
- // new window.
- disconnectWindow(mPreviewWindow);
- mSurface = binder;
- mPreviewWindow = window;
- } else {
- // Something went wrong after we connected to the new window, so
- // disconnect here.
- disconnectWindow(window);
- }
-
- return result;
-}
-
-// set the Surface that the preview will use
-status_t CameraService::Client::setPreviewDisplay(const sp<Surface>& surface) {
- LOG1("setPreviewDisplay(%p) (pid %d)", surface.get(), getCallingPid());
-
- sp<IBinder> binder(surface != 0 ? surface->asBinder() : 0);
- sp<ANativeWindow> window(surface);
- return setPreviewWindow(binder, window);
-}
-
-// set the SurfaceTexture that the preview will use
-status_t CameraService::Client::setPreviewTexture(
- const sp<ISurfaceTexture>& surfaceTexture) {
- LOG1("setPreviewTexture(%p) (pid %d)", surfaceTexture.get(),
- getCallingPid());
-
- sp<IBinder> binder;
- sp<ANativeWindow> window;
- if (surfaceTexture != 0) {
- binder = surfaceTexture->asBinder();
- window = new SurfaceTextureClient(surfaceTexture);
- }
- return setPreviewWindow(binder, window);
-}
-
-// set the preview callback flag to affect how the received frames from
-// preview are handled.
-void CameraService::Client::setPreviewCallbackFlag(int callback_flag) {
- LOG1("setPreviewCallbackFlag(%d) (pid %d)", callback_flag, getCallingPid());
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return;
-
- mPreviewCallbackFlag = callback_flag;
- if (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) {
- enableMsgType(CAMERA_MSG_PREVIEW_FRAME);
- } else {
- disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
- }
-}
-
-// start preview mode
-status_t CameraService::Client::startPreview() {
- LOG1("startPreview (pid %d)", getCallingPid());
- return startCameraMode(CAMERA_PREVIEW_MODE);
-}
-
-// start recording mode
-status_t CameraService::Client::startRecording() {
- LOG1("startRecording (pid %d)", getCallingPid());
- return startCameraMode(CAMERA_RECORDING_MODE);
-}
-
-// start preview or recording
-status_t CameraService::Client::startCameraMode(camera_mode mode) {
- LOG1("startCameraMode(%d)", mode);
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- switch(mode) {
- case CAMERA_PREVIEW_MODE:
- if (mSurface == 0 && mPreviewWindow == 0) {
- LOG1("mSurface is not set yet.");
- // still able to start preview in this case.
- }
- return startPreviewMode();
- case CAMERA_RECORDING_MODE:
- if (mSurface == 0 && mPreviewWindow == 0) {
- ALOGE("mSurface or mPreviewWindow must be set before startRecordingMode.");
- return INVALID_OPERATION;
- }
- return startRecordingMode();
- default:
- return UNKNOWN_ERROR;
- }
-}
-
-status_t CameraService::Client::startPreviewMode() {
- LOG1("startPreviewMode");
- status_t result = NO_ERROR;
-
- // if preview has been enabled, nothing needs to be done
- if (mHardware->previewEnabled()) {
- return NO_ERROR;
- }
-
- if (mPreviewWindow != 0) {
- native_window_set_scaling_mode(mPreviewWindow.get(),
- NATIVE_WINDOW_SCALING_MODE_SCALE_TO_WINDOW);
- native_window_set_buffers_transform(mPreviewWindow.get(),
- mOrientation);
- }
- mHardware->setPreviewWindow(mPreviewWindow);
- result = mHardware->startPreview();
-
- return result;
-}
-
-status_t CameraService::Client::startRecordingMode() {
- LOG1("startRecordingMode");
- status_t result = NO_ERROR;
-
- // if recording has been enabled, nothing needs to be done
- if (mHardware->recordingEnabled()) {
- return NO_ERROR;
- }
-
- // if preview has not been started, start preview first
- if (!mHardware->previewEnabled()) {
- result = startPreviewMode();
- if (result != NO_ERROR) {
- return result;
- }
- }
-
- // start recording mode
- enableMsgType(CAMERA_MSG_VIDEO_FRAME);
- mCameraService->playSound(SOUND_RECORDING);
- result = mHardware->startRecording();
- if (result != NO_ERROR) {
- ALOGE("mHardware->startRecording() failed with status %d", result);
- }
- return result;
-}
-
-// stop preview mode
-void CameraService::Client::stopPreview() {
- LOG1("stopPreview (pid %d)", getCallingPid());
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return;
-
-
- disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
- mHardware->stopPreview();
-
- mPreviewBuffer.clear();
-}
-
-// stop recording mode
-void CameraService::Client::stopRecording() {
- LOG1("stopRecording (pid %d)", getCallingPid());
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return;
-
- disableMsgType(CAMERA_MSG_VIDEO_FRAME);
- mHardware->stopRecording();
- mCameraService->playSound(SOUND_RECORDING);
-
- mPreviewBuffer.clear();
-}
-
-// release a recording frame
-void CameraService::Client::releaseRecordingFrame(const sp<IMemory>& mem) {
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return;
- mHardware->releaseRecordingFrame(mem);
-}
-
-status_t CameraService::Client::storeMetaDataInBuffers(bool enabled)
-{
- LOG1("storeMetaDataInBuffers: %s", enabled? "true": "false");
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) {
- return UNKNOWN_ERROR;
- }
- return mHardware->storeMetaDataInBuffers(enabled);
-}
-
-bool CameraService::Client::previewEnabled() {
- LOG1("previewEnabled (pid %d)", getCallingPid());
-
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return false;
- return mHardware->previewEnabled();
-}
-
-bool CameraService::Client::recordingEnabled() {
- LOG1("recordingEnabled (pid %d)", getCallingPid());
-
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return false;
- return mHardware->recordingEnabled();
-}
-
-status_t CameraService::Client::autoFocus() {
- LOG1("autoFocus (pid %d)", getCallingPid());
-
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- return mHardware->autoFocus();
-}
-
-status_t CameraService::Client::cancelAutoFocus() {
- LOG1("cancelAutoFocus (pid %d)", getCallingPid());
-
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- return mHardware->cancelAutoFocus();
-}
-
-// take a picture - image is returned in callback
-status_t CameraService::Client::takePicture(int msgType) {
- LOG1("takePicture (pid %d): 0x%x", getCallingPid(), msgType);
-
- Mutex::Autolock iLock(mICameraLock);
- int picMsgType = 0;
- { // scope for lock
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- if ((msgType & CAMERA_MSG_RAW_IMAGE) &&
- (msgType & CAMERA_MSG_RAW_IMAGE_NOTIFY)) {
- ALOGE("CAMERA_MSG_RAW_IMAGE and CAMERA_MSG_RAW_IMAGE_NOTIFY"
- " cannot be both enabled");
- return BAD_VALUE;
- }
-
- // We only accept picture related message types
- // and ignore other types of messages for takePicture().
- picMsgType = msgType
- & (CAMERA_MSG_SHUTTER |
- CAMERA_MSG_POSTVIEW_FRAME |
- CAMERA_MSG_RAW_IMAGE |
- CAMERA_MSG_RAW_IMAGE_NOTIFY |
- CAMERA_MSG_COMPRESSED_IMAGE);
-
- }
- enableMsgType(picMsgType);
-
- return mHardware->takePicture();
-}
-
-// set preview/capture parameters - key/value pairs
-status_t CameraService::Client::setParameters(const String8& params) {
- LOG1("setParameters (pid %d) (%s)", getCallingPid(), params.string());
-
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- CameraParameters p(params);
- return mHardware->setParameters(p);
-}
-
-// get preview/capture parameters - key/value pairs
-String8 CameraService::Client::getParameters() const {
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- if (checkPidAndHardware() != NO_ERROR) return String8();
-
- String8 params(mHardware->getParameters().flatten());
- LOG1("getParameters (pid %d) (%s)", getCallingPid(), params.string());
- return params;
-}
-
-// enable shutter sound
-status_t CameraService::Client::enableShutterSound(bool enable) {
- LOG1("enableShutterSound (pid %d)", getCallingPid());
-
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- if (enable) {
- mPlayShutterSound = true;
- return OK;
- }
-
- // Disabling shutter sound may not be allowed. In that case only
- // allow the mediaserver process to disable the sound.
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.camera.sound.forced", value, "0");
- if (strcmp(value, "0") != 0) {
- // Disabling shutter sound is not allowed. Deny if the current
- // process is not mediaserver.
- if (getCallingPid() != getpid()) {
- ALOGE("Failed to disable shutter sound. Permission denied (pid %d)", getCallingPid());
- return PERMISSION_DENIED;
- }
- }
-
- mPlayShutterSound = false;
- return OK;
-}
-
-status_t CameraService::Client::sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) {
- LOG1("sendCommand (pid %d)", getCallingPid());
- int orientation;
- Mutex::Autolock iLock(mICameraLock);
- Mutex::Autolock lock(mLock);
- status_t result = checkPidAndHardware();
- if (result != NO_ERROR) return result;
-
- if (cmd == CAMERA_CMD_SET_DISPLAY_ORIENTATION) {
- // Mirror the preview if the camera is front-facing.
- orientation = getOrientation(arg1, mCameraFacing == CAMERA_FACING_FRONT);
- if (orientation == -1) return BAD_VALUE;
-
- if (mOrientation != orientation) {
- mOrientation = orientation;
- if (mPreviewWindow != 0) {
- native_window_set_buffers_transform(mPreviewWindow.get(),
- mOrientation);
- }
- }
- return OK;
- } else if (cmd == CAMERA_CMD_ENABLE_SHUTTER_SOUND) {
- switch (arg1) {
- case 0:
- enableShutterSound(false);
- break;
- case 1:
- enableShutterSound(true);
- break;
- default:
- return BAD_VALUE;
- }
- return OK;
- } else if (cmd == CAMERA_CMD_PLAY_RECORDING_SOUND) {
- mCameraService->playSound(SOUND_RECORDING);
- } else if (cmd == CAMERA_CMD_PING) {
- // If mHardware is 0, checkPidAndHardware will return error.
- return OK;
- }
-
- return mHardware->sendCommand(cmd, arg1, arg2);
-}
-
-// ----------------------------------------------------------------------------
-
-void CameraService::Client::enableMsgType(int32_t msgType) {
- android_atomic_or(msgType, &mMsgEnabled);
- mHardware->enableMsgType(msgType);
-}
-
-void CameraService::Client::disableMsgType(int32_t msgType) {
- android_atomic_and(~msgType, &mMsgEnabled);
- mHardware->disableMsgType(msgType);
-}
-
-#define CHECK_MESSAGE_INTERVAL 10 // 10ms
-bool CameraService::Client::lockIfMessageWanted(int32_t msgType) {
- int sleepCount = 0;
- while (mMsgEnabled & msgType) {
- if (mLock.tryLock() == NO_ERROR) {
- if (sleepCount > 0) {
- LOG1("lockIfMessageWanted(%d): waited for %d ms",
- msgType, sleepCount * CHECK_MESSAGE_INTERVAL);
- }
- return true;
- }
- if (sleepCount++ == 0) {
- LOG1("lockIfMessageWanted(%d): enter sleep", msgType);
- }
- usleep(CHECK_MESSAGE_INTERVAL * 1000);
- }
- ALOGW("lockIfMessageWanted(%d): dropped unwanted message", msgType);
- return false;
+ // unconditionally disconnect. function is idempotent
+ Client::disconnect();
}
// ----------------------------------------------------------------------------
@@ -967,311 +433,13 @@ CameraService::Client* CameraService::Client::getClientFromCookie(void* user) {
// destruction already started, so should not be accessed
if (client->mDestructionStarted) return NULL;
- // The checks below are not necessary and are for debugging only.
- if (client->mCameraService.get() != gCameraService) {
- ALOGE("mismatch service!");
- return NULL;
- }
-
- if (client->mHardware == 0) {
- ALOGE("mHardware == 0: callback after disconnect()?");
- return NULL;
- }
-
return client;
}
-// Callback messages can be dispatched to internal handlers or pass to our
-// client's callback functions, depending on the message type.
-//
-// notifyCallback:
-// CAMERA_MSG_SHUTTER handleShutter
-// (others) c->notifyCallback
-// dataCallback:
-// CAMERA_MSG_PREVIEW_FRAME handlePreviewData
-// CAMERA_MSG_POSTVIEW_FRAME handlePostview
-// CAMERA_MSG_RAW_IMAGE handleRawPicture
-// CAMERA_MSG_COMPRESSED_IMAGE handleCompressedPicture
-// (others) c->dataCallback
-// dataCallbackTimestamp
-// (others) c->dataCallbackTimestamp
-//
-// NOTE: the *Callback functions grab mLock of the client before passing
-// control to handle* functions. So the handle* functions must release the
-// lock before calling the ICameraClient's callbacks, so those callbacks can
-// invoke methods in the Client class again (For example, the preview frame
-// callback may want to releaseRecordingFrame). The handle* functions must
-// release the lock after all accesses to member variables, so it must be
-// handled very carefully.
-
-void CameraService::Client::notifyCallback(int32_t msgType, int32_t ext1,
- int32_t ext2, void* user) {
- LOG2("notifyCallback(%d)", msgType);
-
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- Client* client = getClientFromCookie(user);
- if (client == NULL) return;
-
- if (!client->lockIfMessageWanted(msgType)) return;
-
- switch (msgType) {
- case CAMERA_MSG_SHUTTER:
- // ext1 is the dimension of the yuv picture.
- client->handleShutter();
- break;
- default:
- client->handleGenericNotify(msgType, ext1, ext2);
- break;
- }
-}
-
-void CameraService::Client::dataCallback(int32_t msgType,
- const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata, void* user) {
- LOG2("dataCallback(%d)", msgType);
-
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- Client* client = getClientFromCookie(user);
- if (client == NULL) return;
-
- if (!client->lockIfMessageWanted(msgType)) return;
- if (dataPtr == 0 && metadata == NULL) {
- ALOGE("Null data returned in data callback");
- client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
- return;
- }
-
- switch (msgType & ~CAMERA_MSG_PREVIEW_METADATA) {
- case CAMERA_MSG_PREVIEW_FRAME:
- client->handlePreviewData(msgType, dataPtr, metadata);
- break;
- case CAMERA_MSG_POSTVIEW_FRAME:
- client->handlePostview(dataPtr);
- break;
- case CAMERA_MSG_RAW_IMAGE:
- client->handleRawPicture(dataPtr);
- break;
- case CAMERA_MSG_COMPRESSED_IMAGE:
- client->handleCompressedPicture(dataPtr);
- break;
- default:
- client->handleGenericData(msgType, dataPtr, metadata);
- break;
- }
-}
-
-void CameraService::Client::dataCallbackTimestamp(nsecs_t timestamp,
- int32_t msgType, const sp<IMemory>& dataPtr, void* user) {
- LOG2("dataCallbackTimestamp(%d)", msgType);
-
- Mutex* lock = getClientLockFromCookie(user);
- if (lock == NULL) return;
- Mutex::Autolock alock(*lock);
-
- Client* client = getClientFromCookie(user);
- if (client == NULL) return;
-
- if (!client->lockIfMessageWanted(msgType)) return;
-
- if (dataPtr == 0) {
- ALOGE("Null data returned in data with timestamp callback");
- client->handleGenericNotify(CAMERA_MSG_ERROR, UNKNOWN_ERROR, 0);
- return;
- }
-
- client->handleGenericDataTimestamp(timestamp, msgType, dataPtr);
-}
-
-// snapshot taken callback
-void CameraService::Client::handleShutter(void) {
- if (mPlayShutterSound) {
- mCameraService->playSound(SOUND_SHUTTER);
- }
-
- sp<ICameraClient> c = mCameraClient;
- if (c != 0) {
- mLock.unlock();
- c->notifyCallback(CAMERA_MSG_SHUTTER, 0, 0);
- if (!lockIfMessageWanted(CAMERA_MSG_SHUTTER)) return;
- }
- disableMsgType(CAMERA_MSG_SHUTTER);
-
- mLock.unlock();
-}
-
-// preview callback - frame buffer update
-void CameraService::Client::handlePreviewData(int32_t msgType,
- const sp<IMemory>& mem,
- camera_frame_metadata_t *metadata) {
- ssize_t offset;
- size_t size;
- sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
-
- // local copy of the callback flags
- int flags = mPreviewCallbackFlag;
-
- // is callback enabled?
- if (!(flags & CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK)) {
- // If the enable bit is off, the copy-out and one-shot bits are ignored
- LOG2("frame callback is disabled");
- mLock.unlock();
- return;
- }
-
- // hold a strong pointer to the client
- sp<ICameraClient> c = mCameraClient;
-
- // clear callback flags if no client or one-shot mode
- if (c == 0 || (mPreviewCallbackFlag & CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK)) {
- LOG2("Disable preview callback");
- mPreviewCallbackFlag &= ~(CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK |
- CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK |
- CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK);
- disableMsgType(CAMERA_MSG_PREVIEW_FRAME);
- }
-
- if (c != 0) {
- // Is the received frame copied out or not?
- if (flags & CAMERA_FRAME_CALLBACK_FLAG_COPY_OUT_MASK) {
- LOG2("frame is copied");
- copyFrameAndPostCopiedFrame(msgType, c, heap, offset, size, metadata);
- } else {
- LOG2("frame is forwarded");
- mLock.unlock();
- c->dataCallback(msgType, mem, metadata);
- }
- } else {
- mLock.unlock();
- }
-}
-
-// picture callback - postview image ready
-void CameraService::Client::handlePostview(const sp<IMemory>& mem) {
- disableMsgType(CAMERA_MSG_POSTVIEW_FRAME);
-
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->dataCallback(CAMERA_MSG_POSTVIEW_FRAME, mem, NULL);
- }
-}
-
-// picture callback - raw image ready
-void CameraService::Client::handleRawPicture(const sp<IMemory>& mem) {
- disableMsgType(CAMERA_MSG_RAW_IMAGE);
-
- ssize_t offset;
- size_t size;
- sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
-
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->dataCallback(CAMERA_MSG_RAW_IMAGE, mem, NULL);
- }
-}
-
-// picture callback - compressed picture ready
-void CameraService::Client::handleCompressedPicture(const sp<IMemory>& mem) {
- disableMsgType(CAMERA_MSG_COMPRESSED_IMAGE);
-
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE, mem, NULL);
- }
-}
-
-
-void CameraService::Client::handleGenericNotify(int32_t msgType,
- int32_t ext1, int32_t ext2) {
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->notifyCallback(msgType, ext1, ext2);
- }
-}
-
-void CameraService::Client::handleGenericData(int32_t msgType,
- const sp<IMemory>& dataPtr, camera_frame_metadata_t *metadata) {
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->dataCallback(msgType, dataPtr, metadata);
- }
-}
-
-void CameraService::Client::handleGenericDataTimestamp(nsecs_t timestamp,
- int32_t msgType, const sp<IMemory>& dataPtr) {
- sp<ICameraClient> c = mCameraClient;
- mLock.unlock();
- if (c != 0) {
- c->dataCallbackTimestamp(timestamp, msgType, dataPtr);
- }
-}
-
-void CameraService::Client::copyFrameAndPostCopiedFrame(
- int32_t msgType, const sp<ICameraClient>& client,
- const sp<IMemoryHeap>& heap, size_t offset, size_t size,
- camera_frame_metadata_t *metadata) {
- LOG2("copyFrameAndPostCopiedFrame");
- // It is necessary to copy out of pmem before sending this to
- // the callback. For efficiency, reuse the same MemoryHeapBase
- // provided it's big enough. Don't allocate the memory or
- // perform the copy if there's no callback.
- // hold the preview lock while we grab a reference to the preview buffer
- sp<MemoryHeapBase> previewBuffer;
-
- if (mPreviewBuffer == 0) {
- mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
- } else if (size > mPreviewBuffer->virtualSize()) {
- mPreviewBuffer.clear();
- mPreviewBuffer = new MemoryHeapBase(size, 0, NULL);
- }
- if (mPreviewBuffer == 0) {
- ALOGE("failed to allocate space for preview buffer");
- mLock.unlock();
- return;
- }
- previewBuffer = mPreviewBuffer;
-
- memcpy(previewBuffer->base(), (uint8_t *)heap->base() + offset, size);
-
- sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size);
- if (frame == 0) {
- ALOGE("failed to allocate space for frame callback");
- mLock.unlock();
- return;
- }
-
- mLock.unlock();
- client->dataCallback(msgType, frame, metadata);
-}
-
-int CameraService::Client::getOrientation(int degrees, bool mirror) {
- if (!mirror) {
- if (degrees == 0) return 0;
- else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
- else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
- else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
- } else { // Do mirror (horizontal flip)
- if (degrees == 0) { // FLIP_H and ROT_0
- return HAL_TRANSFORM_FLIP_H;
- } else if (degrees == 90) { // FLIP_H and ROT_90
- return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;
- } else if (degrees == 180) { // FLIP_H and ROT_180
- return HAL_TRANSFORM_FLIP_V;
- } else if (degrees == 270) { // FLIP_H and ROT_270
- return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
- }
- }
- ALOGE("Invalid setDisplayOrientation degrees=%d", degrees);
- return -1;
+// NOTE: function is idempotent
+void CameraService::Client::disconnect() {
+ mCameraService->removeClient(mCameraClient);
+ mCameraService->setCameraFree(mCameraId);
}
// ----------------------------------------------------------------------------
@@ -1293,41 +461,81 @@ static bool tryLock(Mutex& mutex)
}
status_t CameraService::dump(int fd, const Vector<String16>& args) {
- static const char* kDeadlockedString = "CameraService may be deadlocked\n";
-
- const size_t SIZE = 256;
- char buffer[SIZE];
String8 result;
if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
- snprintf(buffer, SIZE, "Permission Denial: "
+ result.appendFormat("Permission Denial: "
"can't dump CameraService from pid=%d, uid=%d\n",
getCallingPid(),
getCallingUid());
- result.append(buffer);
write(fd, result.string(), result.size());
} else {
bool locked = tryLock(mServiceLock);
// failed to lock - CameraService is probably deadlocked
if (!locked) {
- String8 result(kDeadlockedString);
+ result.append("CameraService may be deadlocked\n");
write(fd, result.string(), result.size());
}
bool hasClient = false;
+ if (!mModule) {
+ result = String8::format("No camera module available!\n");
+ write(fd, result.string(), result.size());
+ return NO_ERROR;
+ }
+
+ result = String8::format("Camera module HAL API version: 0x%x\n",
+ mModule->common.hal_api_version);
+ result.appendFormat("Camera module API version: 0x%x\n",
+ mModule->common.module_api_version);
+ result.appendFormat("Camera module name: %s\n",
+ mModule->common.name);
+ result.appendFormat("Camera module author: %s\n",
+ mModule->common.author);
+ result.appendFormat("Number of camera devices: %d\n\n", mNumberOfCameras);
+ write(fd, result.string(), result.size());
for (int i = 0; i < mNumberOfCameras; i++) {
+ result = String8::format("Camera %d static information:\n", i);
+ camera_info info;
+
+ status_t rc = mModule->get_camera_info(i, &info);
+ if (rc != OK) {
+ result.appendFormat(" Error reading static information!\n");
+ write(fd, result.string(), result.size());
+ } else {
+ result.appendFormat(" Facing: %s\n",
+ info.facing == CAMERA_FACING_BACK ? "BACK" : "FRONT");
+ result.appendFormat(" Orientation: %d\n", info.orientation);
+ int deviceVersion;
+ if (mModule->common.module_api_version <
+ CAMERA_MODULE_API_VERSION_2_0) {
+ deviceVersion = CAMERA_DEVICE_API_VERSION_1_0;
+ } else {
+ deviceVersion = info.device_version;
+ }
+ result.appendFormat(" Device version: 0x%x\n", deviceVersion);
+ if (deviceVersion >= CAMERA_DEVICE_API_VERSION_2_0) {
+ result.appendFormat(" Device static metadata:\n");
+ write(fd, result.string(), result.size());
+ dump_indented_camera_metadata(info.static_camera_characteristics,
+ fd, 2, 4);
+ } else {
+ write(fd, result.string(), result.size());
+ }
+ }
+
sp<Client> client = mClient[i].promote();
- if (client == 0) continue;
+ if (client == 0) {
+ result = String8::format(" Device is closed, no client instance\n");
+ write(fd, result.string(), result.size());
+ continue;
+ }
hasClient = true;
- sprintf(buffer, "Client[%d] (%p) PID: %d\n",
- i,
- client->getCameraClient()->asBinder().get(),
- client->mClientPid);
- result.append(buffer);
+ result = String8::format(" Device is open. Client instance dump:\n");
write(fd, result.string(), result.size());
- client->mHardware->dump(fd, args);
+ client->dump(fd, args);
}
if (!hasClient) {
- result.append("No camera client yet.\n");
+ result = String8::format("\nNo active camera clients yet.\n");
write(fd, result.string(), result.size());
}
@@ -1336,16 +544,42 @@ status_t CameraService::dump(int fd, const Vector<String16>& args) {
// change logging level
int n = args.size();
for (int i = 0; i + 1 < n; i++) {
- if (args[i] == String16("-v")) {
+ String16 verboseOption("-v");
+ if (args[i] == verboseOption) {
String8 levelStr(args[i+1]);
int level = atoi(levelStr.string());
- sprintf(buffer, "Set Log Level to %d", level);
- result.append(buffer);
+ result = String8::format("\nSetting log level to %d.\n", level);
setLogLevel(level);
+ write(fd, result.string(), result.size());
}
}
+
}
return NO_ERROR;
}
+/*virtual*/void CameraService::binderDied(
+ const wp<IBinder> &who) {
+
+ /**
+ * While tempting to promote the wp<IBinder> into a sp,
+ * it's actually not supported by the binder driver
+ */
+
+ ALOGV("java clients' binder died");
+
+ sp<Client> cameraClient = getClientByRemote(who);
+
+ if (cameraClient == 0) {
+ ALOGV("java clients' binder death already cleaned up (normal case)");
+ return;
+ }
+
+ ALOGW("Disconnecting camera client %p since the binder for it "
+ "died (this pid %d)", cameraClient.get(), getCallingPid());
+
+ cameraClient->disconnect();
+
+}
+
}; // namespace android
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 95ac1970..4dab340d 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -27,17 +27,19 @@
namespace android {
+extern volatile int32_t gLogLevel;
+
class MemoryHeapBase;
class MediaPlayer;
-class CameraHardwareInterface;
class CameraService :
public BinderService<CameraService>,
- public BnCameraService
+ public BnCameraService,
+ public IBinder::DeathRecipient
{
- class Client;
friend class BinderService<CameraService>;
public:
+ class Client;
static char const* getServiceName() { return "media.camera"; }
CameraService();
@@ -53,6 +55,8 @@ public:
virtual Client* getClientByIdUnsafe(int cameraId);
virtual Mutex* getClientLockById(int cameraId);
+ virtual sp<Client> getClientByRemote(const wp<IBinder>& cameraClient);
+
virtual status_t dump(int fd, const Vector<String16>& args);
virtual status_t onTransact(uint32_t code, const Parcel& data,
Parcel* reply, uint32_t flags);
@@ -68,114 +72,59 @@ public:
void playSound(sound_kind kind);
void releaseSound();
-private:
- Mutex mServiceLock;
- wp<Client> mClient[MAX_CAMERAS]; // protected by mServiceLock
- Mutex mClientLock[MAX_CAMERAS]; // prevent Client destruction inside callbacks
- int mNumberOfCameras;
-
- // atomics to record whether the hardware is allocated to some client.
- volatile int32_t mBusy[MAX_CAMERAS];
- void setCameraBusy(int cameraId);
- void setCameraFree(int cameraId);
-
- // sounds
- MediaPlayer* newMediaPlayer(const char *file);
-
- Mutex mSoundLock;
- sp<MediaPlayer> mSoundPlayer[NUM_SOUNDS];
- int mSoundRef; // reference count (release all MediaPlayer when 0)
-
class Client : public BnCamera
{
public:
// ICamera interface (see ICamera for details)
- virtual void disconnect();
- virtual status_t connect(const sp<ICameraClient>& client);
- virtual status_t lock();
- virtual status_t unlock();
- virtual status_t setPreviewDisplay(const sp<Surface>& surface);
- virtual status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture);
- virtual void setPreviewCallbackFlag(int flag);
- virtual status_t startPreview();
- virtual void stopPreview();
- virtual bool previewEnabled();
- virtual status_t storeMetaDataInBuffers(bool enabled);
- virtual status_t startRecording();
- virtual void stopRecording();
- virtual bool recordingEnabled();
- virtual void releaseRecordingFrame(const sp<IMemory>& mem);
- virtual status_t autoFocus();
- virtual status_t cancelAutoFocus();
- virtual status_t takePicture(int msgType);
- virtual status_t setParameters(const String8& params);
- virtual String8 getParameters() const;
- virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2);
- private:
- friend class CameraService;
- Client(const sp<CameraService>& cameraService,
- const sp<ICameraClient>& cameraClient,
- const sp<CameraHardwareInterface>& hardware,
- int cameraId,
- int cameraFacing,
- int clientPid);
- ~Client();
+ virtual void disconnect();
+ virtual status_t connect(const sp<ICameraClient>& client) = 0;
+ virtual status_t lock() = 0;
+ virtual status_t unlock() = 0;
+ virtual status_t setPreviewDisplay(const sp<Surface>& surface) = 0;
+ virtual status_t setPreviewTexture(const sp<ISurfaceTexture>& surfaceTexture) = 0;
+ virtual void setPreviewCallbackFlag(int flag) = 0;
+ virtual status_t startPreview() = 0;
+ virtual void stopPreview() = 0;
+ virtual bool previewEnabled() = 0;
+ virtual status_t storeMetaDataInBuffers(bool enabled) = 0;
+ virtual status_t startRecording() = 0;
+ virtual void stopRecording() = 0;
+ virtual bool recordingEnabled() = 0;
+ virtual void releaseRecordingFrame(const sp<IMemory>& mem) = 0;
+ virtual status_t autoFocus() = 0;
+ virtual status_t cancelAutoFocus() = 0;
+ virtual status_t takePicture(int msgType) = 0;
+ virtual status_t setParameters(const String8& params) = 0;
+ virtual String8 getParameters() const = 0;
+ virtual status_t sendCommand(int32_t cmd, int32_t arg1, int32_t arg2) = 0;
+
+ // Interface used by CameraService
+ Client(const sp<CameraService>& cameraService,
+ const sp<ICameraClient>& cameraClient,
+ int cameraId,
+ int cameraFacing,
+ int clientPid,
+ int servicePid);
+ ~Client();
// return our camera client
- const sp<ICameraClient>& getCameraClient() { return mCameraClient; }
-
- // check whether the calling process matches mClientPid.
- status_t checkPid() const;
- status_t checkPidAndHardware() const; // also check mHardware != 0
-
- // these are internal functions used to set up preview buffers
- status_t registerPreviewBuffers();
-
- // camera operation mode
- enum camera_mode {
- CAMERA_PREVIEW_MODE = 0, // frame automatically released
- CAMERA_RECORDING_MODE = 1, // frame has to be explicitly released by releaseRecordingFrame()
- };
- // these are internal functions used for preview/recording
- status_t startCameraMode(camera_mode mode);
- status_t startPreviewMode();
- status_t startRecordingMode();
-
- // internal function used by sendCommand to enable/disable shutter sound.
- status_t enableShutterSound(bool enable);
-
- // these are static callback functions
- static void notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2, void* user);
- static void dataCallback(int32_t msgType, const sp<IMemory>& dataPtr,
- camera_frame_metadata_t *metadata, void* user);
- static void dataCallbackTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr, void* user);
+ const sp<ICameraClient>& getCameraClient() {
+ return mCameraClient;
+ }
+
+ virtual status_t initialize(camera_module_t *module) = 0;
+
+ virtual status_t dump(int fd, const Vector<String16>& args) = 0;
+
+ protected:
static Mutex* getClientLockFromCookie(void* user);
// convert client from cookie. Client lock should be acquired before getting Client.
static Client* getClientFromCookie(void* user);
- // handlers for messages
- void handleShutter(void);
- void handlePreviewData(int32_t msgType, const sp<IMemory>& mem,
- camera_frame_metadata_t *metadata);
- void handlePostview(const sp<IMemory>& mem);
- void handleRawPicture(const sp<IMemory>& mem);
- void handleCompressedPicture(const sp<IMemory>& mem);
- void handleGenericNotify(int32_t msgType, int32_t ext1, int32_t ext2);
- void handleGenericData(int32_t msgType, const sp<IMemory>& dataPtr,
- camera_frame_metadata_t *metadata);
- void handleGenericDataTimestamp(nsecs_t timestamp, int32_t msgType, const sp<IMemory>& dataPtr);
-
- void copyFrameAndPostCopiedFrame(
- int32_t msgType,
- const sp<ICameraClient>& client,
- const sp<IMemoryHeap>& heap,
- size_t offset, size_t size,
- camera_frame_metadata_t *metadata);
-
- int getOrientation(int orientation, bool mirror);
-
- status_t setPreviewWindow(
- const sp<IBinder>& binder,
- const sp<ANativeWindow>& window);
+
+ // the instance is in the middle of destruction. When this is set,
+ // the instance should not be accessed from callback.
+ // CameraService's mClientLock should be acquired to access this.
+ bool mDestructionStarted;
// these are initialized in the constructor.
sp<CameraService> mCameraService; // immutable after constructor
@@ -183,51 +132,35 @@ private:
int mCameraId; // immutable after constructor
int mCameraFacing; // immutable after constructor
pid_t mClientPid;
- sp<CameraHardwareInterface> mHardware; // cleared after disconnect()
- int mPreviewCallbackFlag;
- int mOrientation; // Current display orientation
- bool mPlayShutterSound;
-
- // Ensures atomicity among the public methods
- mutable Mutex mLock;
- // A lock to synchronize access through the ICamera binder
- // interface. The entire binder call should be done with mICameraLock
- // locked, to serialize ICamera access, even when mLock is disabled for
- // calls to the HAL.
- mutable Mutex mICameraLock;
- // This is a binder of Surface or SurfaceTexture.
- sp<IBinder> mSurface;
- sp<ANativeWindow> mPreviewWindow;
-
- // If the user want us to return a copy of the preview frame (instead
- // of the original one), we allocate mPreviewBuffer and reuse it if possible.
- sp<MemoryHeapBase> mPreviewBuffer;
-
- // the instance is in the middle of destruction. When this is set,
- // the instance should not be accessed from callback.
- // CameraService's mClientLock should be acquired to access this.
- bool mDestructionStarted;
+ pid_t mServicePid; // immutable after constructor
- // We need to avoid the deadlock when the incoming command thread and
- // the CameraHardwareInterface callback thread both want to grab mLock.
- // An extra flag is used to tell the callback thread that it should stop
- // trying to deliver the callback messages if the client is not
- // interested in it anymore. For example, if the client is calling
- // stopPreview(), the preview frame messages do not need to be delivered
- // anymore.
-
- // This function takes the same parameter as the enableMsgType() and
- // disableMsgType() functions in CameraHardwareInterface.
- void enableMsgType(int32_t msgType);
- void disableMsgType(int32_t msgType);
- volatile int32_t mMsgEnabled;
-
- // This function keeps trying to grab mLock, or give up if the message
- // is found to be disabled. It returns true if mLock is grabbed.
- bool lockIfMessageWanted(int32_t msgType);
};
+private:
+ Mutex mServiceLock;
+ wp<Client> mClient[MAX_CAMERAS]; // protected by mServiceLock
+ Mutex mClientLock[MAX_CAMERAS]; // prevent Client destruction inside callbacks
+ int mNumberOfCameras;
+
+ // needs to be called with mServiceLock held
+ sp<Client> findClientUnsafe(const wp<IBinder>& cameraClient, int& outIndex);
+
+ // atomics to record whether the hardware is allocated to some client.
+ volatile int32_t mBusy[MAX_CAMERAS];
+ void setCameraBusy(int cameraId);
+ void setCameraFree(int cameraId);
+
+ // sounds
+ MediaPlayer* newMediaPlayer(const char *file);
+
+ Mutex mSoundLock;
+ sp<MediaPlayer> mSoundPlayer[NUM_SOUNDS];
+ int mSoundRef; // reference count (release all MediaPlayer when 0)
+
camera_module_t *mModule;
+
+ // IBinder::DeathRecipient implementation
+ virtual void binderDied(const wp<IBinder> &who);
};
} // namespace android
diff --git a/services/camera/libcameraservice/CannedJpeg.h b/services/camera/libcameraservice/CannedJpeg.h
deleted file mode 100644
index 6dd99c1e..00000000
--- a/services/camera/libcameraservice/CannedJpeg.h
+++ /dev/null
@@ -1,750 +0,0 @@
-/*
- * Copyright (C) 2010 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.
- */
-
-const int kCannedJpegWidth = 320;
-const int kCannedJpegHeight = 240;
-const int kCannedJpegSize = 8733;
-
-const char kCannedJpeg[] = {
- 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01,
- 0x01, 0x01, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xe1, 0x00, 0x66,
- 0x45, 0x78, 0x69, 0x66, 0x00, 0x00, 0x49, 0x49, 0x2a, 0x00, 0x08, 0x00,
- 0x00, 0x00, 0x04, 0x00, 0x1a, 0x01, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x3e, 0x00, 0x00, 0x00, 0x1b, 0x01, 0x05, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x46, 0x00, 0x00, 0x00, 0x28, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x02, 0x00, 0x00, 0x00, 0x31, 0x01, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00,
- 0x4e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00,
- 0x01, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
- 0x50, 0x61, 0x69, 0x6e, 0x74, 0x2e, 0x4e, 0x45, 0x54, 0x20, 0x76, 0x33,
- 0x2e, 0x33, 0x36, 0x00, 0xff, 0xdb, 0x00, 0x43, 0x00, 0x03, 0x02, 0x02,
- 0x03, 0x02, 0x02, 0x03, 0x03, 0x03, 0x03, 0x04, 0x03, 0x03, 0x04, 0x05,
- 0x08, 0x05, 0x05, 0x04, 0x04, 0x05, 0x0a, 0x07, 0x07, 0x06, 0x08, 0x0c,
- 0x0a, 0x0c, 0x0c, 0x0b, 0x0a, 0x0b, 0x0b, 0x0d, 0x0e, 0x12, 0x10, 0x0d,
- 0x0e, 0x11, 0x0e, 0x0b, 0x0b, 0x10, 0x16, 0x10, 0x11, 0x13, 0x14, 0x15,
- 0x15, 0x15, 0x0c, 0x0f, 0x17, 0x18, 0x16, 0x14, 0x18, 0x12, 0x14, 0x15,
- 0x14, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x03, 0x04, 0x04, 0x05, 0x04, 0x05,
- 0x09, 0x05, 0x05, 0x09, 0x14, 0x0d, 0x0b, 0x0d, 0x14, 0x14, 0x14, 0x14,
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14,
- 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0x14, 0xff, 0xc0,
- 0x00, 0x11, 0x08, 0x00, 0xf0, 0x01, 0x40, 0x03, 0x01, 0x22, 0x00, 0x02,
- 0x11, 0x01, 0x03, 0x11, 0x01, 0xff, 0xc4, 0x00, 0x1f, 0x00, 0x00, 0x01,
- 0x05, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x10, 0x00, 0x02, 0x01, 0x03, 0x03,
- 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00, 0x01, 0x7d, 0x01,
- 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13,
- 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23,
- 0x42, 0xb1, 0xc1, 0x15, 0x52, 0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82,
- 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25, 0x26, 0x27, 0x28, 0x29,
- 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45, 0x46,
- 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a,
- 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76,
- 0x77, 0x78, 0x79, 0x7a, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a,
- 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4,
- 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
- 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca,
- 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3,
- 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5,
- 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xc4, 0x00, 0x1f, 0x01, 0x00, 0x03,
- 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
- 0x0a, 0x0b, 0xff, 0xc4, 0x00, 0xb5, 0x11, 0x00, 0x02, 0x01, 0x02, 0x04,
- 0x04, 0x03, 0x04, 0x07, 0x05, 0x04, 0x04, 0x00, 0x01, 0x02, 0x77, 0x00,
- 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51,
- 0x07, 0x61, 0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1,
- 0xb1, 0xc1, 0x09, 0x23, 0x33, 0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a,
- 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18, 0x19, 0x1a, 0x26, 0x27,
- 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
- 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
- 0x5a, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75,
- 0x76, 0x77, 0x78, 0x79, 0x7a, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88,
- 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0xa2,
- 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5,
- 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8,
- 0xc9, 0xca, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2,
- 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5,
- 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xff, 0xda, 0x00, 0x0c, 0x03, 0x01, 0x00,
- 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00, 0xf9, 0xd2, 0xa3, 0x95, 0xbb,
- 0x54, 0x84, 0xe0, 0x66, 0xa0, 0x27, 0x27, 0x35, 0xed, 0x9e, 0x50, 0x95,
- 0x2c, 0x4b, 0xc6, 0x6a, 0x35, 0x1b, 0x8e, 0x2a, 0x70, 0x30, 0x28, 0x00,
- 0xa8, 0xe5, 0x6e, 0x71, 0x52, 0x31, 0xda, 0x33, 0x50, 0x13, 0x93, 0x40,
- 0x09, 0x52, 0xc6, 0xb8, 0x19, 0xf5, 0xa6, 0x2a, 0xee, 0x6c, 0x54, 0xd4,
- 0x00, 0x54, 0x52, 0x36, 0x5b, 0x1e, 0x95, 0x23, 0xb6, 0xd5, 0xcd, 0x41,
- 0x40, 0x05, 0x4c, 0x8b, 0xb5, 0x7d, 0xea, 0x34, 0x5d, 0xcd, 0xed, 0x53,
- 0x50, 0x01, 0x50, 0xbb, 0x6e, 0x6f, 0x6a, 0x91, 0xdb, 0x6a, 0xfb, 0xd4,
- 0x34, 0x00, 0x54, 0xe8, 0xbb, 0x57, 0x15, 0x1c, 0x6b, 0x96, 0xcf, 0xa5,
- 0x4b, 0x40, 0x05, 0x42, 0xcd, 0xb9, 0xb3, 0x4f, 0x91, 0xb0, 0x31, 0xeb,
- 0x51, 0x50, 0x02, 0x81, 0x93, 0x53, 0xa8, 0xda, 0x31, 0x51, 0xc4, 0xbc,
- 0xe6, 0xa4, 0xa0, 0x00, 0x9c, 0x0a, 0x81, 0x8e, 0xe3, 0x9a, 0x92, 0x56,
- 0xe3, 0x15, 0x15, 0x00, 0x28, 0x19, 0x38, 0xa9, 0xc0, 0xc0, 0xc5, 0x47,
- 0x12, 0xf7, 0xa9, 0x28, 0x00, 0x27, 0x00, 0x9a, 0x80, 0x9c, 0x9c, 0xd3,
- 0xe5, 0x6e, 0xd5, 0x1d, 0x00, 0x2a, 0x8d, 0xc7, 0x15, 0x3d, 0x32, 0x35,
- 0xc0, 0xcf, 0xad, 0x3e, 0x80, 0x11, 0x8e, 0xd1, 0x9a, 0x82, 0x9f, 0x23,
- 0x64, 0xe3, 0xd2, 0x99, 0x40, 0x0e, 0x45, 0xdc, 0xde, 0xd5, 0x35, 0x36,
- 0x35, 0xc2, 0xfb, 0x9a, 0x75, 0x00, 0x35, 0xdb, 0x6a, 0xfb, 0xd4, 0x34,
- 0xe9, 0x1b, 0x73, 0x7b, 0x0a, 0x6d, 0x00, 0x3e, 0x35, 0xcb, 0x7b, 0x0a,
- 0x96, 0x91, 0x17, 0x6a, 0xd2, 0xd0, 0x03, 0x64, 0x6c, 0x2f, 0xb9, 0xa8,
- 0x69, 0xce, 0xdb, 0x9a, 0x9b, 0xd6, 0x80, 0x1f, 0x12, 0xe4, 0xe7, 0xd2,
- 0xa5, 0xa4, 0x51, 0xb4, 0x62, 0x97, 0xa5, 0x00, 0x67, 0xc9, 0xad, 0xd8,
- 0x91, 0x81, 0x72, 0x9f, 0x9d, 0x47, 0xfd, 0xb3, 0x65, 0xff, 0x00, 0x3f,
- 0x29, 0x5f, 0xa0, 0x1f, 0xf0, 0xe9, 0x6f, 0x09, 0x7f, 0xd0, 0xfb, 0xad,
- 0x7f, 0xe0, 0x24, 0x34, 0x7f, 0xc3, 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43,
- 0xee, 0xb5, 0xff, 0x00, 0x80, 0x90, 0xd7, 0x3f, 0xb7, 0x87, 0x73, 0x6f,
- 0x63, 0x33, 0xe0, 0x28, 0xf5, 0x9b, 0x11, 0xc9, 0xb9, 0x4c, 0xfd, 0x69,
- 0xff, 0x00, 0xdb, 0x96, 0x1f, 0xf3, 0xf5, 0x1f, 0xe7, 0x5f, 0x7d, 0x7f,
- 0xc3, 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee, 0xb5, 0xff, 0x00, 0x80,
- 0x90, 0xd1, 0xff, 0x00, 0x0e, 0x96, 0xf0, 0x97, 0xfd, 0x0f, 0xba, 0xd7,
- 0xfe, 0x02, 0x43, 0x47, 0xb7, 0x87, 0x70, 0xf6, 0x33, 0x3e, 0x02, 0x93,
- 0x5b, 0xb1, 0x3c, 0x0b, 0x94, 0xc7, 0xd6, 0x99, 0xfd, 0xb3, 0x65, 0xff,
- 0x00, 0x3f, 0x29, 0xf9, 0xd7, 0xe8, 0x07, 0xfc, 0x3a, 0x5b, 0xc2, 0x5f,
- 0xf4, 0x3e, 0xeb, 0x5f, 0xf8, 0x09, 0x0d, 0x1f, 0xf0, 0xe9, 0x6f, 0x09,
- 0x7f, 0xd0, 0xfb, 0xad, 0x7f, 0xe0, 0x24, 0x34, 0xbd, 0xbc, 0x03, 0xd8,
- 0xcc, 0xf8, 0x0e, 0x3d, 0x6a, 0xc1, 0x47, 0x37, 0x29, 0x9f, 0xad, 0x3b,
- 0xfb, 0x72, 0xc3, 0xfe, 0x7e, 0xa3, 0xfc, 0xeb, 0xef, 0xaf, 0xf8, 0x74,
- 0xb7, 0x84, 0xbf, 0xe8, 0x7d, 0xd6, 0xbf, 0xf0, 0x12, 0x1a, 0x3f, 0xe1,
- 0xd2, 0xde, 0x12, 0xff, 0x00, 0xa1, 0xf7, 0x5a, 0xff, 0x00, 0xc0, 0x48,
- 0x69, 0xfb, 0x78, 0x77, 0x0f, 0x63, 0x33, 0xe0, 0x19, 0x35, 0xbb, 0x26,
- 0x3c, 0x5c, 0xa6, 0x3e, 0xb4, 0xdf, 0xed, 0x9b, 0x2f, 0xf9, 0xf9, 0x4a,
- 0xfd, 0x00, 0xff, 0x00, 0x87, 0x4b, 0x78, 0x4b, 0xfe, 0x87, 0xdd, 0x6b,
- 0xff, 0x00, 0x01, 0x21, 0xa3, 0xfe, 0x1d, 0x2d, 0xe1, 0x2f, 0xfa, 0x1f,
- 0x75, 0xaf, 0xfc, 0x04, 0x86, 0x97, 0xb7, 0x80, 0x7b, 0x19, 0x9f, 0x01,
- 0xa6, 0xb5, 0x60, 0xab, 0xff, 0x00, 0x1f, 0x51, 0xe7, 0xeb, 0x4e, 0xfe,
- 0xdc, 0xb0, 0xff, 0x00, 0x9f, 0xa8, 0xff, 0x00, 0x3a, 0xfb, 0xeb, 0xfe,
- 0x1d, 0x2d, 0xe1, 0x2f, 0xfa, 0x1f, 0x75, 0xaf, 0xfc, 0x04, 0x86, 0x8f,
- 0xf8, 0x74, 0xb7, 0x84, 0xbf, 0xe8, 0x7d, 0xd6, 0xbf, 0xf0, 0x12, 0x1a,
- 0x3d, 0xbc, 0x03, 0xd8, 0xcc, 0xf8, 0x05, 0xf5, 0xab, 0x26, 0x6f, 0xf8,
- 0xf9, 0x4c, 0x7d, 0x69, 0xbf, 0xdb, 0x36, 0x5f, 0xf3, 0xf2, 0x9f, 0x9d,
- 0x7e, 0x80, 0x7f, 0xc3, 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee, 0xb5,
- 0xff, 0x00, 0x80, 0x90, 0xd1, 0xff, 0x00, 0x0e, 0x96, 0xf0, 0x97, 0xfd,
- 0x0f, 0xba, 0xd7, 0xfe, 0x02, 0x43, 0x47, 0xb7, 0x80, 0x7b, 0x19, 0x9f,
- 0x02, 0x26, 0xb5, 0x60, 0xab, 0x8f, 0xb5, 0x47, 0xf9, 0xd2, 0xff, 0x00,
- 0x6e, 0x58, 0x7f, 0xcf, 0xd4, 0x7f, 0x9d, 0x7d, 0xf5, 0xff, 0x00, 0x0e,
- 0x96, 0xf0, 0x97, 0xfd, 0x0f, 0xba, 0xd7, 0xfe, 0x02, 0x43, 0x47, 0xfc,
- 0x3a, 0x5b, 0xc2, 0x5f, 0xf4, 0x3e, 0xeb, 0x5f, 0xf8, 0x09, 0x0d, 0x1e,
- 0xde, 0x01, 0xec, 0x66, 0x7c, 0x00, 0xda, 0xd5, 0x93, 0x1c, 0xfd, 0xa5,
- 0x3f, 0x3a, 0x4f, 0xed, 0x8b, 0x2f, 0xf9, 0xf9, 0x4f, 0xce, 0xbf, 0x40,
- 0x3f, 0xe1, 0xd2, 0xde, 0x12, 0xff, 0x00, 0xa1, 0xf7, 0x5a, 0xff, 0x00,
- 0xc0, 0x48, 0x68, 0xff, 0x00, 0x87, 0x4b, 0x78, 0x4b, 0xfe, 0x87, 0xdd,
- 0x6b, 0xff, 0x00, 0x01, 0x21, 0xa7, 0xed, 0xe1, 0xdc, 0x3d, 0x8c, 0xcf,
- 0x81, 0x57, 0x5a, 0xb0, 0x51, 0x8f, 0xb5, 0x47, 0xf9, 0xd1, 0xfd, 0xb9,
- 0x61, 0xff, 0x00, 0x3f, 0x49, 0xf9, 0xd7, 0xdf, 0x5f, 0xf0, 0xe9, 0x6f,
- 0x09, 0x7f, 0xd0, 0xfb, 0xad, 0x7f, 0xe0, 0x24, 0x34, 0x7f, 0xc3, 0xa5,
- 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee, 0xb5, 0xff, 0x00, 0x80, 0x90, 0xd2,
- 0xf6, 0xf0, 0x0f, 0x63, 0x33, 0xe0, 0x06, 0xd6, 0xac, 0x98, 0xe7, 0xed,
- 0x29, 0xf9, 0xd2, 0x0d, 0x62, 0xcb, 0xfe, 0x7e, 0x53, 0xf3, 0xaf, 0xd0,
- 0x0f, 0xf8, 0x74, 0xb7, 0x84, 0xbf, 0xe8, 0x7d, 0xd6, 0xbf, 0xf0, 0x12,
- 0x1a, 0x3f, 0xe1, 0xd2, 0xde, 0x12, 0xff, 0x00, 0xa1, 0xf7, 0x5a, 0xff,
- 0x00, 0xc0, 0x48, 0x69, 0xfb, 0x78, 0x77, 0x0f, 0x63, 0x33, 0xe0, 0x51,
- 0xad, 0xd8, 0x01, 0x8f, 0xb5, 0x47, 0xf9, 0xd0, 0x75, 0xcb, 0x0c, 0x7f,
- 0xc7, 0xca, 0x7e, 0x75, 0xf7, 0xd7, 0xfc, 0x3a, 0x5b, 0xc2, 0x5f, 0xf4,
- 0x3e, 0xeb, 0x5f, 0xf8, 0x09, 0x0d, 0x1f, 0xf0, 0xe9, 0x6f, 0x09, 0x7f,
- 0xd0, 0xfb, 0xad, 0x7f, 0xe0, 0x24, 0x34, 0x7b, 0x78, 0x77, 0x0f, 0x63,
- 0x33, 0xf3, 0xfc, 0xeb, 0x36, 0x44, 0xff, 0x00, 0xc7, 0xca, 0x7e, 0x74,
- 0xa3, 0x58, 0xb1, 0x24, 0x66, 0xe5, 0x31, 0xf5, 0xaf, 0xbf, 0xff, 0x00,
- 0xe1, 0xd2, 0xde, 0x12, 0xff, 0x00, 0xa1, 0xf7, 0x5a, 0xff, 0x00, 0xc0,
- 0x48, 0x68, 0xff, 0x00, 0x87, 0x4b, 0x78, 0x4b, 0xfe, 0x87, 0xdd, 0x6b,
- 0xff, 0x00, 0x01, 0x21, 0xa3, 0xdb, 0xc3, 0xb8, 0x7b, 0x19, 0x9f, 0x02,
- 0xff, 0x00, 0x6d, 0xd8, 0x7f, 0xcf, 0xd4, 0x7f, 0x9d, 0x07, 0x5c, 0xb1,
- 0x03, 0x8b, 0x94, 0xcf, 0xd6, 0xbe, 0xfa, 0xff, 0x00, 0x87, 0x4b, 0x78,
- 0x4b, 0xfe, 0x87, 0xdd, 0x6b, 0xff, 0x00, 0x01, 0x21, 0xa3, 0xfe, 0x1d,
- 0x2d, 0xe1, 0x2f, 0xfa, 0x1f, 0x75, 0xaf, 0xfc, 0x04, 0x86, 0x8f, 0x6f,
- 0x0e, 0xe1, 0xec, 0x66, 0x7e, 0x7f, 0xff, 0x00, 0x6c, 0xd9, 0x7f, 0xcf,
- 0xca, 0x7e, 0x74, 0xab, 0xac, 0x58, 0xe7, 0x9b, 0x94, 0xc7, 0xd6, 0xbe,
- 0xff, 0x00, 0xff, 0x00, 0x87, 0x4b, 0x78, 0x4b, 0xfe, 0x87, 0xdd, 0x6b,
- 0xff, 0x00, 0x01, 0x21, 0xa3, 0xfe, 0x1d, 0x2d, 0xe1, 0x2f, 0xfa, 0x1f,
- 0x75, 0xaf, 0xfc, 0x04, 0x86, 0x8f, 0x6f, 0x0e, 0xe1, 0xec, 0x66, 0x7c,
- 0x0b, 0xfd, 0xb9, 0x61, 0xff, 0x00, 0x3f, 0x51, 0xfe, 0x74, 0x8d, 0xae,
- 0x58, 0xed, 0x38, 0xb9, 0x4c, 0xfd, 0x6b, 0xef, 0xbf, 0xf8, 0x74, 0xb7,
- 0x84, 0xbf, 0xe8, 0x7d, 0xd6, 0xbf, 0xf0, 0x12, 0x1a, 0x3f, 0xe1, 0xd2,
- 0xde, 0x12, 0xff, 0x00, 0xa1, 0xf7, 0x5a, 0xff, 0x00, 0xc0, 0x48, 0x68,
- 0xf6, 0xf0, 0xee, 0x1e, 0xc6, 0x67, 0xe7, 0xff, 0x00, 0xf6, 0xc5, 0x97,
- 0xfc, 0xfc, 0xa7, 0xe7, 0x4e, 0x4d, 0x62, 0xc7, 0x77, 0x37, 0x29, 0xf9,
- 0xd7, 0xdf, 0xdf, 0xf0, 0xe9, 0x6f, 0x09, 0x7f, 0xd0, 0xfb, 0xad, 0x7f,
- 0xe0, 0x24, 0x34, 0x7f, 0xc3, 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee,
- 0xb5, 0xff, 0x00, 0x80, 0x90, 0xd1, 0xed, 0xe1, 0xdc, 0x3d, 0x8c, 0xcf,
- 0x81, 0x7f, 0xb7, 0x2c, 0x3f, 0xe7, 0xea, 0x3f, 0xce, 0x91, 0xf5, 0xcb,
- 0x1c, 0x71, 0x72, 0x9f, 0x9d, 0x7d, 0xf7, 0xff, 0x00, 0x0e, 0x96, 0xf0,
- 0x97, 0xfd, 0x0f, 0xba, 0xd7, 0xfe, 0x02, 0x43, 0x47, 0xfc, 0x3a, 0x5b,
- 0xc2, 0x5f, 0xf4, 0x3e, 0xeb, 0x5f, 0xf8, 0x09, 0x0d, 0x1e, 0xde, 0x1d,
- 0xc3, 0xd8, 0xcc, 0xfc, 0xff, 0x00, 0xfe, 0xd9, 0xb2, 0xff, 0x00, 0x9f,
- 0x94, 0xfc, 0xe9, 0xd1, 0xeb, 0x36, 0x20, 0xe4, 0xdc, 0xa7, 0xe7, 0x5f,
- 0x7f, 0x7f, 0xc3, 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee, 0xb5, 0xff,
- 0x00, 0x80, 0x90, 0xd1, 0xff, 0x00, 0x0e, 0x96, 0xf0, 0x97, 0xfd, 0x0f,
- 0xba, 0xd7, 0xfe, 0x02, 0x43, 0x47, 0xb7, 0x87, 0x70, 0xf6, 0x33, 0x3e,
- 0x05, 0xfe, 0xdc, 0xb0, 0xff, 0x00, 0x9f, 0xa8, 0xff, 0x00, 0x3a, 0x6c,
- 0x9a, 0xdd, 0x89, 0x18, 0x17, 0x29, 0xf9, 0xd7, 0xdf, 0x9f, 0xf0, 0xe9,
- 0x6f, 0x09, 0x7f, 0xd0, 0xfb, 0xad, 0x7f, 0xe0, 0x24, 0x34, 0x7f, 0xc3,
- 0xa5, 0xbc, 0x25, 0xff, 0x00, 0x43, 0xee, 0xb5, 0xff, 0x00, 0x80, 0x90,
- 0xd1, 0xed, 0xe1, 0xdc, 0x3d, 0x8c, 0xcf, 0xbc, 0xa8, 0xa2, 0x8a, 0xf3,
- 0x0e, 0xf0, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a,
- 0x28, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a,
- 0x28, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0xa0, 0xbb, 0xbd, 0xb7, 0xb0,
- 0x88, 0x49, 0x73, 0x3c, 0x56, 0xf1, 0x96, 0x0a, 0x1e, 0x57, 0x0a, 0x09,
- 0x3d, 0x06, 0x4f, 0x7a, 0x9e, 0x95, 0xd3, 0x76, 0xea, 0x01, 0x45, 0x14,
- 0x53, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a, 0x82, 0xda, 0xf6, 0xde,
- 0xf0, 0xca, 0x2d, 0xe7, 0x8a, 0x73, 0x13, 0x98, 0xe4, 0xf2, 0xdc, 0x36,
- 0xc6, 0x1d, 0x54, 0xe3, 0xa1, 0xf6, 0xa4, 0xda, 0x4e, 0xcc, 0x09, 0xe8,
- 0xa2, 0x8a, 0x60, 0x14, 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x14,
- 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x14,
- 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x02, 0xb8,
- 0x51, 0x45, 0x14, 0x05, 0xc2, 0x8a, 0x28, 0xa0, 0x2e, 0x14, 0x51, 0x45,
- 0x01, 0x70, 0xa2, 0x8a, 0x28, 0x18, 0x51, 0x45, 0x14, 0x0a, 0xe1, 0x45,
- 0x14, 0x50, 0x17, 0x0a, 0x28, 0xa2, 0x80, 0xb9, 0xca, 0xfc, 0x4a, 0xf0,
- 0x52, 0x78, 0xef, 0xc2, 0xb7, 0x1a, 0x76, 0xef, 0x2e, 0xe5, 0x4f, 0x9d,
- 0x6c, 0xe4, 0xe0, 0x09, 0x00, 0x38, 0xcf, 0xb1, 0xc9, 0x1f, 0x8e, 0x7b,
- 0x57, 0x3d, 0xf0, 0x5b, 0xc7, 0x53, 0x6b, 0xba, 0x6c, 0xda, 0x16, 0xaa,
- 0x5a, 0x3d, 0x73, 0x4a, 0xfd, 0xd4, 0x8b, 0x2f, 0xdf, 0x91, 0x01, 0xc0,
- 0x27, 0xdc, 0x1e, 0x0f, 0xe0, 0x7b, 0xd7, 0xa3, 0x5c, 0xdc, 0xc5, 0x67,
- 0x04, 0x93, 0xcf, 0x2a, 0x43, 0x0c, 0x60, 0xb3, 0xc9, 0x23, 0x05, 0x55,
- 0x1e, 0xa4, 0x9e, 0x95, 0xf3, 0x47, 0xc4, 0x8f, 0x1f, 0xe9, 0x36, 0xdf,
- 0x10, 0xed, 0x3c, 0x41, 0xe1, 0x39, 0x99, 0xaf, 0xa1, 0xe2, 0xea, 0x42,
- 0x98, 0x82, 0x72, 0x38, 0xe3, 0x90, 0x4e, 0x46, 0x41, 0xe9, 0x9c, 0x0c,
- 0x7a, 0xd7, 0xc4, 0x67, 0x98, 0x9a, 0x59, 0x3e, 0x26, 0x9e, 0x64, 0xa6,
- 0x93, 0x7e, 0xec, 0xe3, 0x7d, 0x65, 0x1e, 0xe9, 0x77, 0x8b, 0xd7, 0xd3,
- 0x4b, 0x99, 0x4d, 0xa8, 0xbe, 0x63, 0xe9, 0xca, 0x2b, 0xe4, 0x3d, 0x73,
- 0xe3, 0x3f, 0x8b, 0xb5, 0xc6, 0x6d, 0xfa, 0xb4, 0x96, 0x71, 0x9e, 0x91,
- 0x59, 0x0f, 0x28, 0x0f, 0xc4, 0x7c, 0xdf, 0x99, 0xae, 0x56, 0xe7, 0x5a,
- 0xd4, 0x6f, 0x18, 0xb5, 0xc5, 0xfd, 0xd4, 0xec, 0x7b, 0xc9, 0x33, 0x31,
- 0xfd, 0x4d, 0x78, 0x75, 0xf8, 0xfb, 0x0b, 0x07, 0x6a, 0x14, 0x65, 0x25,
- 0xe6, 0xd2, 0xff, 0x00, 0x32, 0x1d, 0x75, 0xd1, 0x1f, 0x73, 0x51, 0x5f,
- 0x0b, 0xdb, 0xea, 0xf7, 0xf6, 0xad, 0xba, 0x0b, 0xdb, 0x88, 0x58, 0x77,
- 0x8e, 0x56, 0x53, 0xfa, 0x1a, 0xe9, 0xf4, 0x5f, 0x8b, 0xfe, 0x2e, 0xd0,
- 0xd9, 0x7c, 0xad, 0x66, 0x7b, 0x84, 0x1f, 0xf2, 0xce, 0xec, 0xf9, 0xc0,
- 0xff, 0x00, 0xdf, 0x59, 0x23, 0xf0, 0x34, 0xa8, 0x71, 0xf6, 0x1a, 0x4e,
- 0xd5, 0xa8, 0x4a, 0x2b, 0xc9, 0xa7, 0xfe, 0x40, 0xab, 0xae, 0xa8, 0xfa,
- 0x13, 0xe2, 0xff, 0x00, 0x8f, 0xcf, 0x82, 0xfc, 0x3e, 0x21, 0xb3, 0x6d,
- 0xda, 0xcd, 0xfe, 0x62, 0xb5, 0x45, 0xe5, 0x97, 0xb1, 0x7c, 0x7b, 0x67,
- 0x8f, 0x72, 0x3d, 0xea, 0x5f, 0x84, 0x7e, 0x05, 0x6f, 0x04, 0x78, 0x60,
- 0x2d, 0xd1, 0x2d, 0xa9, 0xde, 0xb0, 0x9e, 0xe8, 0x93, 0x9d, 0xad, 0x8e,
- 0x17, 0xf0, 0x1d, 0x4f, 0xa9, 0x35, 0xe2, 0x5e, 0x13, 0xf8, 0x89, 0x61,
- 0xac, 0xfc, 0x49, 0x8f, 0xc4, 0x3e, 0x30, 0x76, 0xcc, 0x68, 0x16, 0xd8,
- 0x43, 0x19, 0x68, 0x61, 0x61, 0xd0, 0x91, 0x92, 0x40, 0x1c, 0x9e, 0x33,
- 0xc9, 0xcd, 0x7d, 0x3b, 0x63, 0x7f, 0x6d, 0xaa, 0x5a, 0x45, 0x75, 0x69,
- 0x3c, 0x77, 0x36, 0xd2, 0x8d, 0xc9, 0x2c, 0x4c, 0x19, 0x58, 0x7b, 0x11,
- 0x5e, 0xde, 0x4d, 0x8b, 0xa3, 0x9d, 0xe3, 0x2a, 0x66, 0x1c, 0xe9, 0xf2,
- 0x5e, 0x30, 0x8f, 0x58, 0xae, 0xb2, 0x6b, 0xbc, 0xbf, 0x05, 0xa1, 0x50,
- 0x6a, 0x6f, 0x98, 0xb1, 0x45, 0x14, 0x57, 0xdc, 0x9b, 0x5c, 0x28, 0xa2,
- 0x8a, 0x02, 0xe1, 0x45, 0x14, 0x50, 0x17, 0x0a, 0x28, 0xa2, 0x80, 0xb8,
- 0x51, 0x45, 0x14, 0x05, 0xc2, 0x8a, 0x28, 0xa0, 0x2e, 0x14, 0x51, 0x45,
- 0x01, 0x70, 0xa2, 0x8a, 0x28, 0x0b, 0x8d, 0xcd, 0x19, 0xa6, 0xe4, 0x51,
- 0x91, 0x55, 0x62, 0x47, 0x66, 0x8c, 0xd3, 0x72, 0x28, 0xc8, 0xa2, 0xc0,
- 0x3b, 0x34, 0x66, 0x9b, 0x91, 0x46, 0x45, 0x16, 0x01, 0xd9, 0xa3, 0x34,
- 0xdc, 0x8a, 0x32, 0x28, 0xb0, 0x0e, 0xcd, 0x19, 0xa6, 0xe4, 0x52, 0xe4,
- 0x51, 0x60, 0xb8, 0xb9, 0xa3, 0x34, 0xdc, 0x8a, 0x32, 0x28, 0xb0, 0x0e,
- 0xdd, 0x46, 0x69, 0xb9, 0x14, 0x64, 0x51, 0x60, 0x1d, 0x9a, 0xa7, 0xac,
- 0x6b, 0x16, 0x9a, 0x0e, 0x9b, 0x71, 0xa8, 0x5f, 0x4c, 0x20, 0xb5, 0x81,
- 0x37, 0xbb, 0x9e, 0xc3, 0xd0, 0x7a, 0x93, 0xd0, 0x0a, 0xb5, 0x91, 0x5f,
- 0x39, 0xfe, 0xd1, 0x1e, 0x37, 0x7d, 0x4b, 0x5a, 0x4f, 0x0f, 0x5b, 0x48,
- 0x45, 0xa5, 0x96, 0x1e, 0x70, 0xa7, 0xef, 0xca, 0x46, 0x40, 0x3f, 0xee,
- 0x83, 0xf9, 0x93, 0xe9, 0x5e, 0x06, 0x79, 0x9a, 0xc3, 0x27, 0xc1, 0x4b,
- 0x12, 0xd5, 0xe5, 0xb4, 0x57, 0x76, 0xff, 0x00, 0xab, 0xbf, 0x24, 0x44,
- 0xe5, 0xca, 0xae, 0x72, 0xbf, 0x12, 0xbe, 0x2a, 0xea, 0x3e, 0x3e, 0xbd,
- 0x78, 0xd5, 0x9e, 0xd3, 0x48, 0x46, 0xfd, 0xd5, 0xa2, 0x9f, 0xbd, 0xe8,
- 0xcf, 0xea, 0x7f, 0x41, 0xdb, 0xd4, 0xc3, 0xe0, 0x5f, 0x85, 0x1a, 0xd7,
- 0x8f, 0xed, 0xe6, 0xb9, 0xb1, 0xf2, 0x2d, 0xed, 0x22, 0x6d, 0x86, 0x7b,
- 0x96, 0x21, 0x59, 0xb1, 0x9c, 0x0c, 0x02, 0x4f, 0x51, 0xf9, 0xd7, 0x19,
- 0x5e, 0xcd, 0xf0, 0x73, 0xe3, 0x16, 0x97, 0xe1, 0x0d, 0x06, 0x4d, 0x23,
- 0x57, 0x49, 0x63, 0x44, 0x95, 0xa5, 0x86, 0x78, 0x53, 0x78, 0x21, 0xba,
- 0xab, 0x0e, 0xb9, 0xcf, 0x7f, 0x7f, 0x6a, 0xfc, 0x1b, 0x2e, 0xa9, 0x87,
- 0xcd, 0xb3, 0x2f, 0x69, 0x9c, 0xd5, 0x6a, 0x2e, 0xfa, 0xde, 0xda, 0xf4,
- 0x57, 0xe8, 0xbf, 0xe1, 0x8e, 0x48, 0xda, 0x52, 0xf7, 0x8f, 0x30, 0xf1,
- 0x57, 0x85, 0x75, 0x0f, 0x06, 0xeb, 0x12, 0x69, 0xba, 0x94, 0x42, 0x3b,
- 0x84, 0x01, 0x83, 0x21, 0xca, 0xba, 0x9e, 0x8c, 0xa7, 0xb8, 0xac, 0x8a,
- 0xed, 0x3e, 0x2c, 0xf8, 0xee, 0x1f, 0x1f, 0xf8, 0x9c, 0x5e, 0xda, 0xc2,
- 0xf0, 0xda, 0x41, 0x08, 0x82, 0x2f, 0x33, 0x01, 0xd8, 0x02, 0x49, 0x63,
- 0xe9, 0xc9, 0x3c, 0x57, 0x17, 0x5e, 0x26, 0x3e, 0x9e, 0x1e, 0x96, 0x2a,
- 0xa4, 0x30, 0xb2, 0xe6, 0xa6, 0x9b, 0xb3, 0xee, 0x88, 0x76, 0xbe, 0x81,
- 0x5a, 0x1a, 0x06, 0x83, 0x7b, 0xe2, 0x7d, 0x5e, 0xdf, 0x4d, 0xd3, 0xe2,
- 0xf3, 0xae, 0xa7, 0x38, 0x55, 0xce, 0x00, 0x00, 0x64, 0x92, 0x7b, 0x00,
- 0x39, 0xac, 0xfa, 0xea, 0x3e, 0x1b, 0x78, 0xc1, 0x7c, 0x0d, 0xe2, 0xcb,
- 0x5d, 0x52, 0x58, 0x4c, 0xf6, 0xe1, 0x5a, 0x39, 0x51, 0x3e, 0xf6, 0xd6,
- 0x18, 0x24, 0x7b, 0x8e, 0x0d, 0x67, 0x83, 0x85, 0x1a, 0x98, 0x8a, 0x70,
- 0xc4, 0x4b, 0x96, 0x0d, 0xae, 0x67, 0xd9, 0x5f, 0x50, 0x56, 0xbe, 0xa6,
- 0x97, 0x8d, 0x7e, 0x0e, 0xeb, 0xde, 0x06, 0xd3, 0x17, 0x50, 0xbb, 0x36,
- 0xf7, 0x56, 0x99, 0x0b, 0x24, 0x96, 0xae, 0x4f, 0x96, 0x4f, 0x4d, 0xc0,
- 0x81, 0xc1, 0x3c, 0x66, 0xa9, 0xfc, 0x3e, 0xf8, 0x93, 0xaa, 0x78, 0x03,
- 0x50, 0x0f, 0x6c, 0xe6, 0x7b, 0x07, 0x6f, 0xdf, 0xd9, 0x3b, 0x7c, 0x8e,
- 0x3d, 0x47, 0xa3, 0x7b, 0xfe, 0x79, 0xaf, 0x45, 0xf8, 0xad, 0xf1, 0xb3,
- 0x47, 0xf1, 0x27, 0x85, 0x26, 0xd2, 0x34, 0x84, 0x9a, 0x67, 0xbb, 0x2b,
- 0xe6, 0xcb, 0x34, 0x7b, 0x04, 0x6a, 0x18, 0x36, 0x07, 0xa9, 0xc8, 0x1e,
- 0xd5, 0xe1, 0x95, 0xf4, 0x39, 0xab, 0xc2, 0x65, 0x79, 0x84, 0x67, 0x93,
- 0x55, 0x6d, 0x24, 0x9d, 0xd3, 0xbd, 0x9f, 0x55, 0x7e, 0xaa, 0xd6, 0xbe,
- 0xfb, 0xd8, 0xb9, 0x5a, 0x32, 0xf7, 0x59, 0xf6, 0xef, 0x86, 0xbc, 0x49,
- 0x63, 0xe2, 0xbd, 0x1a, 0xdf, 0x53, 0xd3, 0xe5, 0xf3, 0x2d, 0xe6, 0x1d,
- 0xfe, 0xf2, 0x1e, 0xea, 0xc3, 0xb1, 0x15, 0xa9, 0x9a, 0xf9, 0x7b, 0xe0,
- 0x27, 0x8d, 0xe4, 0xf0, 0xef, 0x8a, 0x53, 0x4a, 0x9e, 0x43, 0xfd, 0x9f,
- 0xa9, 0x30, 0x8f, 0x69, 0x3c, 0x24, 0xdf, 0xc0, 0xc3, 0xeb, 0xf7, 0x7f,
- 0x11, 0xe9, 0x5f, 0x4f, 0xe4, 0x57, 0xee, 0x3c, 0x3f, 0x9b, 0xc7, 0x39,
- 0xc1, 0x2a, 0xed, 0x5a, 0x6b, 0x49, 0x2f, 0x3f, 0xf2, 0x7b, 0xfe, 0x1d,
- 0x0e, 0xb8, 0x4f, 0x99, 0x5c, 0x76, 0x4d, 0x19, 0xa6, 0xe4, 0x51, 0x91,
- 0x5f, 0x4b, 0x62, 0xc7, 0x64, 0xd1, 0x9a, 0x6e, 0x45, 0x19, 0x14, 0x58,
- 0x2e, 0x3b, 0x34, 0x66, 0x9b, 0x91, 0x46, 0x45, 0x16, 0x0b, 0x8e, 0xcd,
- 0x19, 0xa6, 0xe4, 0x51, 0x91, 0x45, 0x80, 0x76, 0x68, 0xcd, 0x37, 0x34,
- 0x64, 0x51, 0x60, 0xb8, 0xec, 0xd1, 0x9a, 0x6e, 0x45, 0x19, 0x14, 0x58,
- 0x07, 0x64, 0xd1, 0x9a, 0x6e, 0x45, 0x19, 0x14, 0x58, 0x06, 0x6e, 0xa3,
- 0x75, 0x37, 0x34, 0x66, 0xae, 0xc4, 0x5c, 0x76, 0xea, 0x37, 0x53, 0x73,
- 0x46, 0x68, 0xb0, 0x5c, 0x76, 0xea, 0x37, 0x53, 0x73, 0x46, 0x68, 0xb0,
- 0x5c, 0x76, 0xea, 0x37, 0x53, 0x72, 0x28, 0xcd, 0x16, 0x0b, 0x8e, 0xdd,
- 0x46, 0xea, 0x6e, 0x68, 0xcd, 0x16, 0x0b, 0x8e, 0xdd, 0x46, 0xea, 0x6e,
- 0x68, 0xcd, 0x16, 0x0b, 0x8e, 0xdd, 0x46, 0xea, 0xc4, 0xf1, 0x57, 0x8c,
- 0x34, 0xaf, 0x06, 0x69, 0xff, 0x00, 0x6b, 0xd5, 0x2e, 0x44, 0x28, 0xc7,
- 0x08, 0x8a, 0x37, 0x3c, 0x87, 0xd1, 0x47, 0x7f, 0xe5, 0x5c, 0x0d, 0x9f,
- 0xed, 0x1f, 0xe1, 0xcb, 0x8b, 0xc1, 0x14, 0xd6, 0x97, 0xf6, 0xb0, 0x93,
- 0x81, 0x3b, 0xa2, 0xb0, 0x1e, 0xe4, 0x06, 0x27, 0xf2, 0xcd, 0x78, 0xf8,
- 0xac, 0xdf, 0x2f, 0xc0, 0xd4, 0x54, 0x71, 0x35, 0xa3, 0x19, 0x3e, 0x8d,
- 0xfe, 0x7d, 0xbe, 0x64, 0xb9, 0x25, 0xb9, 0xeb, 0x05, 0xf6, 0x82, 0x4f,
- 0x41, 0x5f, 0x10, 0xeb, 0x7a, 0x93, 0xeb, 0x3a, 0xcd, 0xf5, 0xfc, 0x84,
- 0x97, 0xb9, 0x9d, 0xe6, 0x39, 0xff, 0x00, 0x69, 0x89, 0xfe, 0xb5, 0xf6,
- 0xad, 0x8e, 0xa1, 0x6b, 0xab, 0x58, 0xc5, 0x75, 0x69, 0x34, 0x77, 0x36,
- 0xb3, 0x2e, 0xe4, 0x91, 0x0e, 0x55, 0x85, 0x78, 0x5f, 0xfc, 0x2d, 0x5f,
- 0x87, 0x3f, 0xf4, 0x25, 0x27, 0xfe, 0x00, 0xdb, 0xff, 0x00, 0x8d, 0x7c,
- 0x67, 0x18, 0xe1, 0xa8, 0x63, 0x61, 0x87, 0x55, 0x31, 0x31, 0xa7, 0x1f,
- 0x79, 0xab, 0xdd, 0xf3, 0x7c, 0x3a, 0xab, 0x76, 0xfd, 0x4c, 0xea, 0x59,
- 0xdb, 0x53, 0xc4, 0x68, 0xaf, 0x6e, 0xff, 0x00, 0x85, 0xab, 0xf0, 0xe7,
- 0xfe, 0x84, 0xa4, 0xff, 0x00, 0xc0, 0x1b, 0x7f, 0xf1, 0xa3, 0xfe, 0x16,
- 0xaf, 0xc3, 0x9f, 0xfa, 0x12, 0x93, 0xff, 0x00, 0x00, 0x6d, 0xff, 0x00,
- 0xc6, 0xbf, 0x33, 0xfe, 0xc5, 0xc0, 0xff, 0x00, 0xd0, 0x7c, 0x3e, 0xe9,
- 0x7f, 0x91, 0x8f, 0x2a, 0xee, 0x78, 0x8d, 0x15, 0xed, 0xdf, 0xf0, 0xb5,
- 0x7e, 0x1c, 0xff, 0x00, 0xd0, 0x94, 0x9f, 0xf8, 0x03, 0x6f, 0xfe, 0x34,
- 0x7f, 0xc2, 0xd5, 0xf8, 0x73, 0xff, 0x00, 0x42, 0x52, 0x7f, 0xe0, 0x0d,
- 0xbf, 0xf8, 0xd1, 0xfd, 0x8b, 0x81, 0xff, 0x00, 0xa0, 0xf8, 0x7d, 0xd2,
- 0xff, 0x00, 0x20, 0xe5, 0x5d, 0xcf, 0x11, 0xa2, 0xbd, 0xbb, 0xfe, 0x16,
- 0xaf, 0xc3, 0x9f, 0xfa, 0x12, 0x93, 0xff, 0x00, 0x00, 0x6d, 0xff, 0x00,
- 0xc6, 0x8f, 0xf8, 0x5a, 0xbf, 0x0e, 0x7f, 0xe8, 0x4a, 0x4f, 0xfc, 0x01,
- 0xb7, 0xff, 0x00, 0x1a, 0x3f, 0xb1, 0x70, 0x3f, 0xf4, 0x1f, 0x0f, 0xba,
- 0x5f, 0xe4, 0x1c, 0xab, 0xb9, 0xe2, 0x34, 0x57, 0xb7, 0x7f, 0xc2, 0xd5,
- 0xf8, 0x73, 0xff, 0x00, 0x42, 0x52, 0x7f, 0xe0, 0x0d, 0xbf, 0xf8, 0xd1,
- 0xff, 0x00, 0x0b, 0x57, 0xe1, 0xcf, 0xfd, 0x09, 0x49, 0xff, 0x00, 0x80,
- 0x36, 0xff, 0x00, 0xe3, 0x47, 0xf6, 0x2e, 0x07, 0xfe, 0x83, 0xe1, 0xf7,
- 0x4b, 0xfc, 0x83, 0x95, 0x77, 0x3c, 0x52, 0x09, 0xde, 0xda, 0x78, 0xe6,
- 0x89, 0x8a, 0x49, 0x1b, 0x07, 0x56, 0x1d, 0x41, 0x07, 0x20, 0xd7, 0xdb,
- 0xfa, 0x5d, 0xf0, 0xd4, 0x74, 0xdb, 0x4b, 0xb0, 0x30, 0x27, 0x85, 0x25,
- 0x03, 0xfd, 0xe5, 0x07, 0xfa, 0xd7, 0x85, 0xff, 0x00, 0xc2, 0xd5, 0xf8,
- 0x73, 0xff, 0x00, 0x42, 0x52, 0x7f, 0xe0, 0x0d, 0xbf, 0xf8, 0xd7, 0xb6,
- 0x69, 0x1a, 0x95, 0xa5, 0xc7, 0x87, 0xec, 0xaf, 0xe1, 0x55, 0xb3, 0xb1,
- 0x7b, 0x54, 0x99, 0x11, 0xf0, 0x82, 0x28, 0xca, 0x02, 0x01, 0xec, 0x30,
- 0x3f, 0x0e, 0x2b, 0xf4, 0x7e, 0x0e, 0xc2, 0xd0, 0xc1, 0xce, 0xbc, 0x69,
- 0x62, 0x63, 0x51, 0x34, 0x9b, 0x4a, 0xfa, 0x5a, 0xfa, 0xeb, 0xea, 0x6d,
- 0x4e, 0xca, 0xfa, 0x9a, 0x5b, 0xa8, 0xdd, 0x5e, 0x57, 0xab, 0xfe, 0xd1,
- 0x3e, 0x1b, 0xd3, 0xaf, 0x1a, 0x0b, 0x68, 0x6e, 0xf5, 0x15, 0x53, 0x83,
- 0x34, 0x28, 0xaa, 0x87, 0xe9, 0xb8, 0x82, 0x7f, 0x2a, 0xeb, 0xbc, 0x1b,
- 0xf1, 0x07, 0x45, 0xf1, 0xcd, 0xbb, 0xbe, 0x99, 0x70, 0x7c, 0xe8, 0xc6,
- 0x64, 0xb6, 0x98, 0x6d, 0x91, 0x07, 0xa9, 0x1d, 0xc7, 0xb8, 0xc8, 0xaf,
- 0xb7, 0xc3, 0xe7, 0x19, 0x76, 0x2a, 0xb7, 0xd5, 0xe8, 0x56, 0x8c, 0xa7,
- 0xd9, 0x3f, 0xcb, 0xbf, 0xc8, 0xd1, 0x49, 0x3d, 0x2e, 0x74, 0xdb, 0xa8,
- 0xcd, 0x37, 0x34, 0x64, 0x57, 0xb2, 0x55, 0xc7, 0x6e, 0xa3, 0x75, 0x37,
- 0x34, 0x66, 0x8b, 0x05, 0xc7, 0x6e, 0xa3, 0x75, 0x37, 0x34, 0x66, 0x8b,
- 0x05, 0xc7, 0x6e, 0xa3, 0x75, 0x37, 0x34, 0x66, 0x8b, 0x05, 0xc7, 0x6e,
- 0xa3, 0x75, 0x37, 0x34, 0x64, 0x51, 0x60, 0xb8, 0xed, 0xd4, 0x6e, 0xa6,
- 0xe4, 0x51, 0x9a, 0x2c, 0x17, 0x1b, 0x9a, 0x33, 0x51, 0xee, 0xa3, 0x75,
- 0x55, 0x88, 0xb9, 0x26, 0x68, 0xcd, 0x47, 0xba, 0x8d, 0xd4, 0x58, 0x2e,
- 0x49, 0x9a, 0x33, 0x51, 0xee, 0xa3, 0x75, 0x16, 0x15, 0xc9, 0x32, 0x28,
- 0xa8, 0xf7, 0x51, 0xba, 0x8b, 0x0e, 0xe4, 0x99, 0xa3, 0x35, 0x1e, 0xea,
- 0x37, 0x51, 0x60, 0xb9, 0x26, 0x68, 0xcd, 0x47, 0xba, 0x8c, 0xd3, 0xb0,
- 0x5c, 0xf9, 0x7b, 0xe3, 0xb6, 0xaf, 0x3e, 0xa5, 0xf1, 0x0e, 0xf2, 0xde,
- 0x47, 0x26, 0x1b, 0x24, 0x48, 0x62, 0x4e, 0xc0, 0x15, 0x0c, 0x4f, 0xe2,
- 0x58, 0xfe, 0x95, 0xe7, 0x95, 0xda, 0x7c, 0x64, 0xff, 0x00, 0x92, 0x97,
- 0xad, 0xff, 0x00, 0xbf, 0x1f, 0xfe, 0x8a, 0x4a, 0xe2, 0xeb, 0xf9, 0x47,
- 0x3a, 0x9c, 0xaa, 0x66, 0x78, 0x99, 0x49, 0xdd, 0xf3, 0xcb, 0xf0, 0x6d,
- 0x23, 0x92, 0x5b, 0x9e, 0xf7, 0xfb, 0x34, 0xeb, 0x13, 0xcd, 0x67, 0xac,
- 0xe9, 0xb2, 0x39, 0x6b, 0x78, 0x1a, 0x39, 0xa2, 0x04, 0xfd, 0xd2, 0xdb,
- 0x83, 0x0f, 0xc7, 0x68, 0xfd, 0x6b, 0xc1, 0x2b, 0xda, 0xff, 0x00, 0x66,
- 0x73, 0x8b, 0xed, 0x7f, 0xfe, 0xb9, 0xc3, 0xfc, 0xde, 0xbc, 0x52, 0xbd,
- 0x8c, 0xd2, 0x72, 0x9e, 0x4b, 0x97, 0x39, 0x3b, 0xdb, 0xda, 0xaf, 0x92,
- 0x92, 0xb1, 0x4f, 0xe1, 0x41, 0x45, 0x14, 0x57, 0xc6, 0x90, 0x14, 0x51,
- 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x14, 0x51, 0x45, 0x00, 0x15, 0xef,
- 0x7f, 0x13, 0xf5, 0x89, 0xf4, 0xef, 0x82, 0xbe, 0x19, 0xb6, 0x81, 0xca,
- 0x0b, 0xc8, 0x2d, 0x62, 0x94, 0x83, 0xd5, 0x04, 0x3b, 0x88, 0xfc, 0x48,
- 0x15, 0xe0, 0x95, 0xed, 0x7f, 0x17, 0x0f, 0xfc, 0x5a, 0x5f, 0x05, 0xff,
- 0x00, 0xd7, 0x38, 0x3f, 0xf4, 0x45, 0x7d, 0x96, 0x47, 0x39, 0x43, 0x03,
- 0x98, 0x4a, 0x2e, 0xcf, 0x91, 0x7e, 0x32, 0xb3, 0xfc, 0x0a, 0x8e, 0xcc,
- 0xf1, 0x4a, 0xe9, 0xbe, 0x1a, 0x6a, 0xf3, 0xe8, 0xbe, 0x3a, 0xd1, 0x67,
- 0x81, 0xca, 0x99, 0x2e, 0x52, 0x07, 0x00, 0xfd, 0xe4, 0x76, 0x0a, 0xc0,
- 0xfe, 0x07, 0xf4, 0xae, 0x66, 0xb6, 0x3c, 0x1b, 0xff, 0x00, 0x23, 0x7e,
- 0x87, 0xff, 0x00, 0x5f, 0xd0, 0x7f, 0xe8, 0xc5, 0xaf, 0x9b, 0xc0, 0xce,
- 0x54, 0xf1, 0x54, 0xa7, 0x07, 0x66, 0xa4, 0xbf, 0x31, 0x2d, 0xcf, 0xb4,
- 0x33, 0x46, 0x6a, 0x3d, 0xd4, 0x6e, 0xaf, 0xeb, 0x9b, 0x1d, 0x57, 0x24,
- 0xcd, 0x19, 0xa8, 0xf7, 0x51, 0xba, 0x8b, 0x0e, 0xe4, 0x99, 0xa3, 0x35,
- 0x1e, 0xea, 0x37, 0x51, 0x60, 0xb9, 0x26, 0x68, 0xcd, 0x47, 0xba, 0x8d,
- 0xd4, 0x58, 0x2e, 0x49, 0x9a, 0x33, 0x51, 0xee, 0xa3, 0x75, 0x16, 0x15,
- 0xc9, 0x33, 0x46, 0x6a, 0x3d, 0xd4, 0x6e, 0xa2, 0xc3, 0xb8, 0xdd, 0xd4,
- 0x9b, 0xa9, 0xbb, 0xa8, 0xdd, 0x5a, 0x19, 0xdc, 0x7e, 0xea, 0x4d, 0xd4,
- 0xdd, 0xd4, 0x6e, 0xa0, 0x57, 0x1f, 0xba, 0x8d, 0xd4, 0xcd, 0xd4, 0x6e,
- 0xa0, 0x77, 0x1f, 0xba, 0x8d, 0xd4, 0xcd, 0xd4, 0x6e, 0xa4, 0x2b, 0x8f,
- 0xdd, 0x49, 0xba, 0x9b, 0xba, 0x8d, 0xd4, 0xc2, 0xe3, 0xb7, 0x52, 0xee,
- 0xa6, 0x6e, 0xa3, 0x75, 0x20, 0xb9, 0xf2, 0x9f, 0xc6, 0x3f, 0xf9, 0x29,
- 0x5a, 0xdf, 0xfb, 0xf1, 0xff, 0x00, 0xe8, 0xb4, 0xae, 0x32, 0xbb, 0x2f,
- 0x8c, 0x5c, 0xfc, 0x49, 0xd6, 0xff, 0x00, 0xdf, 0x8f, 0xff, 0x00, 0x45,
- 0xa5, 0x71, 0xb5, 0xfc, 0x99, 0x9c, 0x7f, 0xc8, 0xcb, 0x13, 0xfe, 0x39,
- 0xff, 0x00, 0xe9, 0x4c, 0xc1, 0xee, 0x7b, 0x57, 0xec, 0xd2, 0x71, 0x7d,
- 0xaf, 0x7f, 0xd7, 0x38, 0x7f, 0x9b, 0xd7, 0x8a, 0xd7, 0xb4, 0x7e, 0xcd,
- 0x67, 0x17, 0xda, 0xf7, 0xfd, 0x73, 0x87, 0xf9, 0xbd, 0x78, 0xbd, 0x7b,
- 0x19, 0x97, 0xfc, 0x89, 0x32, 0xef, 0xfb, 0x8b, 0xff, 0x00, 0xa5, 0x21,
- 0xbd, 0x90, 0x51, 0x45, 0x15, 0xf2, 0x02, 0x0a, 0x28, 0xa2, 0x80, 0x0a,
- 0x28, 0xa2, 0x80, 0x0a, 0x28, 0xa2, 0x80, 0x0a, 0xf6, 0xaf, 0x8b, 0x47,
- 0x3f, 0x09, 0x7c, 0x17, 0xff, 0x00, 0x5c, 0xe0, 0xff, 0x00, 0xd1, 0x15,
- 0xe2, 0xb5, 0xed, 0x1f, 0x16, 0x4f, 0xfc, 0x5a, 0x6f, 0x06, 0x7f, 0xd7,
- 0x38, 0x3f, 0xf4, 0x45, 0x7d, 0x7e, 0x4d, 0xff, 0x00, 0x22, 0xfc, 0xc3,
- 0xfc, 0x11, 0xff, 0x00, 0xd2, 0x90, 0xd6, 0xcc, 0xf1, 0x7a, 0xd8, 0xf0,
- 0x67, 0xfc, 0x8e, 0x1a, 0x17, 0xfd, 0x7f, 0xc1, 0xff, 0x00, 0xa3, 0x16,
- 0xb1, 0xeb, 0x63, 0xc1, 0xdf, 0xf2, 0x37, 0x68, 0x7f, 0xf5, 0xfd, 0x07,
- 0xfe, 0x8c, 0x5a, 0xf9, 0xbc, 0x27, 0xfb, 0xcd, 0x3f, 0xf1, 0x2f, 0xcc,
- 0x48, 0xfb, 0x2b, 0x75, 0x1b, 0xa9, 0x9b, 0xa8, 0xdd, 0x5f, 0xd8, 0x16,
- 0x37, 0xb8, 0xfd, 0xd4, 0x6e, 0xa6, 0x6e, 0xa3, 0x75, 0x20, 0xb8, 0xed,
- 0xd4, 0xbb, 0xa9, 0x9b, 0xa8, 0xdd, 0x4c, 0x2e, 0x3f, 0x75, 0x26, 0xea,
- 0x6e, 0xea, 0x37, 0x52, 0x0b, 0x8f, 0xdd, 0x49, 0xba, 0x9b, 0xba, 0x8d,
- 0xd4, 0xec, 0x3b, 0x8f, 0xdd, 0x49, 0xba, 0x9b, 0xba, 0x8d, 0xd4, 0x0a,
- 0xe4, 0x74, 0x53, 0x33, 0x4b, 0x93, 0x57, 0x63, 0x3b, 0x8e, 0xa2, 0x9b,
- 0x9a, 0x4c, 0xd1, 0x60, 0xb8, 0xfa, 0x29, 0x99, 0xa3, 0x34, 0x58, 0x2e,
- 0x3f, 0x34, 0x53, 0x33, 0x4b, 0x93, 0x45, 0x82, 0xe3, 0xa8, 0xcd, 0x33,
- 0x34, 0x66, 0x8b, 0x05, 0xc7, 0xd1, 0x4d, 0xc9, 0xa3, 0x26, 0x8b, 0x05,
- 0xcf, 0x96, 0x3e, 0x30, 0x7f, 0xc9, 0x48, 0xd6, 0xbf, 0xdf, 0x8f, 0xff,
- 0x00, 0x45, 0xa5, 0x71, 0xb5, 0xdd, 0xfc, 0x6c, 0xd3, 0xa6, 0xb1, 0xf8,
- 0x85, 0x7f, 0x2c, 0x8a, 0x44, 0x77, 0x4b, 0x1c, 0xd1, 0xb7, 0x66, 0x1b,
- 0x02, 0x9f, 0xd5, 0x4d, 0x70, 0x95, 0xfc, 0x97, 0x9d, 0x42, 0x50, 0xcc,
- 0xf1, 0x31, 0x92, 0xb7, 0xbf, 0x2f, 0xfd, 0x29, 0x90, 0x7b, 0x3f, 0xec,
- 0xdb, 0xff, 0x00, 0x1f, 0xba, 0xef, 0xfd, 0x73, 0x87, 0xf9, 0xbd, 0x78,
- 0xc5, 0x7b, 0x87, 0xec, 0xe3, 0xa7, 0x4d, 0x1c, 0x3a, 0xd5, 0xf3, 0x29,
- 0x58, 0x24, 0x31, 0xc2, 0x8d, 0xfd, 0xe2, 0x37, 0x16, 0xfc, 0xb2, 0x3f,
- 0x3a, 0xf0, 0xfa, 0xf6, 0x73, 0x58, 0x4a, 0x19, 0x26, 0x5b, 0xcc, 0xad,
- 0x7f, 0x6a, 0xff, 0x00, 0xf2, 0x64, 0x01, 0x45, 0x14, 0x57, 0xc6, 0x00,
- 0x51, 0x45, 0x14, 0x00, 0x51, 0x45, 0x14, 0x00, 0x51, 0x45, 0x14, 0x00,
- 0x57, 0xb3, 0xfc, 0x57, 0xff, 0x00, 0x92, 0x51, 0xe0, 0xdf, 0xfa, 0xe7,
- 0x07, 0xfe, 0x88, 0xaf, 0x18, 0xaf, 0x70, 0xf8, 0x9b, 0xa7, 0x4d, 0x79,
- 0xf0, 0x77, 0xc3, 0x37, 0x11, 0x29, 0x74, 0xb5, 0x8a, 0xd9, 0xe4, 0xc7,
- 0x65, 0x30, 0xed, 0xcf, 0xe6, 0x40, 0xfc, 0x6b, 0xec, 0xf2, 0x38, 0x4a,
- 0x78, 0x0c, 0xc1, 0x45, 0x5f, 0xdc, 0x5f, 0x84, 0xae, 0xc0, 0xf0, 0xfa,
- 0xd8, 0xf0, 0x6f, 0xfc, 0x8d, 0xfa, 0x1f, 0xfd, 0x7f, 0x41, 0xff, 0x00,
- 0xa3, 0x16, 0xb1, 0xeb, 0xa2, 0xf8, 0x79, 0xa7, 0x4d, 0xaa, 0x78, 0xdf,
- 0x45, 0x86, 0x15, 0x2c, 0xcb, 0x75, 0x1c, 0xad, 0x8e, 0xca, 0x8c, 0x18,
- 0x9f, 0xc8, 0x57, 0xcd, 0x60, 0x61, 0x29, 0xe2, 0xe9, 0x46, 0x2a, 0xed,
- 0xca, 0x3f, 0x9a, 0x03, 0xeb, 0x9c, 0xd1, 0x4c, 0xcd, 0x2e, 0x4d, 0x7f,
- 0x60, 0x58, 0xbb, 0x8e, 0xa2, 0x99, 0x9a, 0x33, 0x45, 0x82, 0xe3, 0xe8,
- 0xa6, 0x66, 0x8c, 0xd1, 0x60, 0xb8, 0xfa, 0x29, 0x99, 0xa5, 0xc9, 0xa2,
- 0xc1, 0x71, 0xd9, 0xa2, 0x9b, 0x93, 0x49, 0x9a, 0x2c, 0x17, 0x1f, 0x45,
- 0x33, 0x34, 0x66, 0x8b, 0x05, 0xc6, 0x6e, 0xa3, 0x75, 0x30, 0x90, 0x3a,
- 0x9c, 0x51, 0x9a, 0xd2, 0xc6, 0x57, 0x1f, 0xba, 0x8d, 0xd4, 0xda, 0x4c,
- 0xd1, 0x60, 0xb8, 0xfd, 0xd4, 0x6e, 0xa6, 0x02, 0x0f, 0x43, 0x9a, 0x37,
- 0x01, 0xdf, 0x14, 0x58, 0x2e, 0x3f, 0x75, 0x1b, 0xa9, 0xb4, 0x94, 0x58,
- 0x2e, 0x3f, 0x75, 0x1b, 0xa9, 0xb4, 0x80, 0x83, 0xd0, 0xe6, 0x8b, 0x05,
- 0xc7, 0xee, 0xa3, 0x75, 0x30, 0x90, 0x3a, 0x9c, 0x51, 0x9a, 0x2c, 0x17,
- 0x31, 0x3c, 0x5d, 0xe0, 0xcd, 0x2f, 0xc6, 0xb6, 0x2b, 0x6f, 0xa8, 0xc4,
- 0x4b, 0x26, 0x4c, 0x53, 0xc6, 0x71, 0x24, 0x64, 0xf5, 0xc1, 0xfe, 0x87,
- 0x8a, 0xe0, 0x6d, 0x3f, 0x67, 0x7d, 0x32, 0x2b, 0xb0, 0xf7, 0x1a, 0xad,
- 0xcc, 0xf6, 0xe0, 0xe7, 0xca, 0x58, 0xd5, 0x09, 0x1e, 0x85, 0xb2, 0x7f,
- 0x95, 0x7a, 0xd5, 0x25, 0x78, 0x38, 0xcc, 0x87, 0x2c, 0xcc, 0x2b, 0x2a,
- 0xf8, 0x9a, 0x2a, 0x52, 0xef, 0xaa, 0xfb, 0xec, 0xd5, 0xfe, 0x77, 0x0b,
- 0x95, 0xf4, 0xad, 0x32, 0xd3, 0x44, 0xb0, 0x86, 0xca, 0xc6, 0x05, 0xb7,
- 0xb6, 0x88, 0x61, 0x23, 0x4e, 0x83, 0xfc, 0x4f, 0xbd, 0x7c, 0x6b, 0x5f,
- 0x69, 0x57, 0xc5, 0xb5, 0xf9, 0x8f, 0x88, 0xb0, 0x8d, 0x38, 0xe0, 0xe1,
- 0x05, 0x64, 0xb9, 0xec, 0x97, 0xfd, 0xb8, 0x34, 0x14, 0x51, 0x45, 0x7e,
- 0x32, 0x30, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a, 0x28, 0x00, 0xa2, 0x8a,
- 0x28, 0x00, 0xaf, 0xad, 0xfc, 0x2b, 0x04, 0x57, 0x9e, 0x06, 0xd1, 0xad,
- 0xe7, 0x8d, 0x66, 0x86, 0x4d, 0x3a, 0x04, 0x78, 0xdc, 0x65, 0x58, 0x18,
- 0xd7, 0x20, 0x8a, 0xf9, 0x22, 0xbe, 0xba, 0xf0, 0x67, 0xfc, 0x89, 0xfa,
- 0x17, 0xfd, 0x78, 0x41, 0xff, 0x00, 0xa2, 0xd6, 0xbf, 0x5c, 0xf0, 0xee,
- 0x2a, 0x58, 0x9c, 0x42, 0x7b, 0x72, 0xaf, 0xcc, 0x47, 0x05, 0xab, 0x7e,
- 0xcf, 0x7a, 0x4d, 0xdd, 0xdb, 0x4b, 0x65, 0xa8, 0x4f, 0x63, 0x13, 0x1c,
- 0xf9, 0x25, 0x04, 0x80, 0x7b, 0x02, 0x48, 0x3f, 0x9e, 0x6b, 0xaf, 0xf0,
- 0x57, 0xc3, 0xcd, 0x27, 0xc0, 0xd1, 0xb9, 0xb3, 0x47, 0x9a, 0xee, 0x41,
- 0xb6, 0x4b, 0xa9, 0xb0, 0x5c, 0x8f, 0x41, 0xe8, 0x3d, 0x87, 0xe3, 0x5d,
- 0x36, 0x69, 0x6b, 0xf5, 0x7c, 0x37, 0x0f, 0xe5, 0x78, 0x3a, 0xff, 0x00,
- 0x59, 0xa1, 0x41, 0x46, 0x7d, 0xf5, 0xd3, 0xd1, 0x6c, 0xbe, 0x49, 0x0a,
- 0xe3, 0xb7, 0x51, 0xba, 0x99, 0x9a, 0x03, 0x03, 0xde, 0xbd, 0xfb, 0x05,
- 0xc7, 0xee, 0xa3, 0x75, 0x30, 0x90, 0x06, 0x4f, 0x14, 0x51, 0x60, 0xb8,
- 0xfd, 0xd4, 0x6e, 0xa6, 0xd1, 0x45, 0x82, 0xe3, 0xb7, 0x51, 0xba, 0x98,
- 0x08, 0x3d, 0x0e, 0x68, 0x24, 0x0e, 0xf4, 0x58, 0x2e, 0x3f, 0x75, 0x1b,
- 0xa9, 0x94, 0xb4, 0x58, 0x2e, 0x3b, 0x75, 0x1b, 0xa9, 0x99, 0xa0, 0x10,
- 0x7a, 0x1a, 0x2c, 0x17, 0x31, 0x62, 0xbd, 0x91, 0x46, 0xf7, 0x90, 0x3e,
- 0xd3, 0xf7, 0x1b, 0xa9, 0xad, 0x58, 0xa5, 0x13, 0x46, 0xae, 0xbd, 0x08,
- 0xac, 0x3f, 0x38, 0xff, 0x00, 0x71, 0x3f, 0xef, 0x91, 0x56, 0x52, 0xf1,
- 0xe3, 0x48, 0x55, 0x42, 0x80, 0x7a, 0x80, 0x3d, 0xeb, 0xb2, 0x70, 0xbe,
- 0xc7, 0x9d, 0x4e, 0xaf, 0x2e, 0xec, 0xd6, 0xcd, 0x36, 0x59, 0x44, 0x31,
- 0xb3, 0xb7, 0x41, 0x49, 0xba, 0xb3, 0x1e, 0xf2, 0x49, 0x12, 0x65, 0x60,
- 0x08, 0x1d, 0x01, 0x1e, 0xf5, 0x84, 0x61, 0xcc, 0x75, 0x4e, 0xa7, 0x22,
- 0x1b, 0x2d, 0xec, 0x8c, 0x0b, 0xa4, 0x81, 0x37, 0x1f, 0xb8, 0xbd, 0x7e,
- 0xb4, 0xb1, 0x5e, 0xc8, 0xa0, 0x3b, 0xb8, 0x7d, 0xa7, 0xee, 0x37, 0x5f,
- 0xad, 0x57, 0xf3, 0x8f, 0xf7, 0x13, 0xfe, 0xf9, 0x14, 0x79, 0xc7, 0xfb,
- 0x89, 0xff, 0x00, 0x7c, 0x8a, 0xeb, 0xe5, 0x56, 0xb5, 0x8e, 0x0e, 0x77,
- 0x7b, 0xdc, 0xdd, 0x8e, 0x41, 0x2a, 0x2b, 0xaf, 0x42, 0x33, 0x4e, 0xac,
- 0xa8, 0xef, 0x1d, 0x3c, 0x85, 0x00, 0x05, 0x3d, 0x40, 0x1e, 0xe6, 0xb4,
- 0x77, 0x57, 0x24, 0xa3, 0xca, 0x77, 0xc2, 0x7c, 0xe8, 0x74, 0x92, 0x08,
- 0xd1, 0x99, 0x8f, 0x00, 0x66, 0xb2, 0xa5, 0xbd, 0x91, 0x81, 0x74, 0x70,
- 0x99, 0x38, 0xd8, 0x3a, 0xfd, 0x69, 0xd2, 0x5e, 0x3b, 0xf9, 0xea, 0x40,
- 0x2a, 0x3a, 0x02, 0x3d, 0xc5, 0x55, 0xf3, 0x8f, 0xf7, 0x13, 0xfe, 0xf9,
- 0x15, 0xbc, 0x21, 0x6d, 0xce, 0x6a, 0x95, 0x6f, 0xa2, 0x64, 0xf1, 0x5e,
- 0x48, 0xa3, 0x7b, 0x48, 0x1f, 0x69, 0xfb, 0x8d, 0xd4, 0xd6, 0xac, 0x52,
- 0x89, 0xa3, 0x57, 0x5e, 0x86, 0xb0, 0xfc, 0xe3, 0xfd, 0xc4, 0xff, 0x00,
- 0xbe, 0x45, 0x59, 0x4b, 0xc7, 0x8d, 0x61, 0x0a, 0x14, 0x03, 0xd4, 0x01,
- 0xef, 0x44, 0xe1, 0x7d, 0x85, 0x4e, 0xaf, 0x2e, 0xec, 0xd6, 0xcd, 0x15,
- 0x1e, 0xea, 0x5d, 0xd5, 0xcd, 0x63, 0xba, 0xe3, 0xeb, 0xc0, 0xbc, 0x71,
- 0xf0, 0x57, 0x55, 0x83, 0x57, 0x9e, 0xe7, 0x44, 0x85, 0x6f, 0x6c, 0xa6,
- 0x72, 0xe2, 0x25, 0x70, 0xaf, 0x16, 0x4e, 0x76, 0xe0, 0x91, 0x91, 0xe9,
- 0x8a, 0xf7, 0xad, 0xd4, 0x66, 0xbe, 0x7f, 0x39, 0xc8, 0xf0, 0x99, 0xe5,
- 0x18, 0xd2, 0xc4, 0xdd, 0x72, 0xbb, 0xa6, 0xb7, 0x5d, 0xfb, 0xef, 0xe8,
- 0x17, 0xb1, 0xf2, 0xc5, 0xff, 0x00, 0xc3, 0x5f, 0x12, 0xe9, 0x96, 0x53,
- 0x5d, 0xdd, 0x69, 0x52, 0x43, 0x6f, 0x0a, 0x97, 0x92, 0x42, 0xe8, 0x42,
- 0x81, 0xd4, 0xf0, 0x6b, 0x99, 0xaf, 0xaa, 0xfe, 0x21, 0x9c, 0xf8, 0x1f,
- 0x5c, 0xff, 0x00, 0xaf, 0x47, 0xfe, 0x55, 0xf2, 0xa5, 0x7e, 0x01, 0xc5,
- 0x59, 0x1e, 0x1f, 0x22, 0xc4, 0x53, 0xa3, 0x87, 0x93, 0x92, 0x94, 0x6f,
- 0xef, 0x5b, 0xbd, 0xba, 0x24, 0x5a, 0x77, 0x0a, 0xe9, 0xec, 0xbe, 0x19,
- 0xf8, 0x9b, 0x51, 0xb3, 0x86, 0xea, 0xdb, 0x49, 0x92, 0x5b, 0x79, 0x90,
- 0x49, 0x1b, 0x87, 0x40, 0x19, 0x48, 0xc8, 0x3d, 0x6b, 0x98, 0xaf, 0xac,
- 0x3c, 0x08, 0x71, 0xe0, 0xad, 0x0b, 0xfe, 0xbc, 0xa1, 0xff, 0x00, 0xd0,
- 0x05, 0x57, 0x0a, 0xe4, 0x58, 0x7c, 0xf6, 0xbd, 0x5a, 0x58, 0x89, 0x4a,
- 0x2a, 0x2a, 0xfe, 0xed, 0xbb, 0xdb, 0xaa, 0x60, 0xdd, 0x8f, 0x9e, 0xdb,
- 0xe1, 0x4f, 0x8a, 0xd1, 0x4b, 0x1d, 0x1a, 0x50, 0x00, 0xc9, 0x3e, 0x62,
- 0x7f, 0xf1, 0x55, 0xc9, 0xd7, 0xd9, 0x17, 0x4d, 0xfe, 0x8d, 0x37, 0xfb,
- 0x87, 0xf9, 0x57, 0xc6, 0xf5, 0xd1, 0xc5, 0x9c, 0x3d, 0x86, 0xc8, 0x5d,
- 0x05, 0x87, 0x9c, 0xa5, 0xcf, 0xcd, 0x7e, 0x6b, 0x74, 0xb6, 0xd6, 0x4b,
- 0xb8, 0x27, 0x70, 0xae, 0x87, 0x47, 0xf0, 0x07, 0x88, 0x35, 0xfb, 0x04,
- 0xbd, 0xb0, 0xd3, 0x64, 0xb9, 0xb5, 0x72, 0x42, 0xc8, 0xae, 0xa0, 0x12,
- 0x0e, 0x0f, 0x53, 0xeb, 0x5c, 0xf5, 0x7d, 0x27, 0xf0, 0x54, 0xe3, 0xe1,
- 0xed, 0x8f, 0xfd, 0x74, 0x97, 0xff, 0x00, 0x43, 0x35, 0xe7, 0x70, 0xbe,
- 0x4f, 0x43, 0x3c, 0xc6, 0xcb, 0x0d, 0x5e, 0x4d, 0x25, 0x16, 0xf4, 0xb5,
- 0xee, 0x9a, 0x5d, 0x53, 0xee, 0x0d, 0xd8, 0xf3, 0x1f, 0x0d, 0x7c, 0x12,
- 0xd7, 0xb5, 0x3d, 0x42, 0x31, 0xa9, 0x40, 0x34, 0xdb, 0x20, 0xc0, 0xc8,
- 0xee, 0xea, 0xce, 0x47, 0x70, 0xa0, 0x13, 0xcf, 0xb9, 0xe2, 0xbe, 0x87,
- 0xb7, 0x82, 0x3b, 0x4b, 0x78, 0xa0, 0x89, 0x42, 0x45, 0x12, 0x84, 0x45,
- 0x1d, 0x80, 0x18, 0x02, 0x97, 0x34, 0x9b, 0xab, 0xfa, 0x07, 0x25, 0xe1,
- 0xfc, 0x1e, 0x45, 0x09, 0x47, 0x0d, 0x76, 0xe5, 0xbb, 0x7a, 0xbd, 0x36,
- 0x5a, 0x24, 0xad, 0xf2, 0x22, 0xf7, 0x24, 0xcd, 0x19, 0xa8, 0xf7, 0x51,
- 0xba, 0xbe, 0x96, 0xc1, 0x71, 0xd2, 0x48, 0x22, 0x46, 0x76, 0xe0, 0x0e,
- 0x6b, 0x2a, 0x5b, 0xd9, 0x18, 0x17, 0x47, 0x11, 0xe4, 0xe3, 0x60, 0xeb,
- 0xf5, 0xa7, 0x49, 0x78, 0xef, 0xe7, 0xa9, 0x00, 0xa8, 0xe8, 0x08, 0xf7,
- 0x02, 0xaa, 0xf9, 0xc7, 0xfb, 0x89, 0xff, 0x00, 0x7c, 0x8a, 0xe9, 0x84,
- 0x2d, 0xb9, 0xc5, 0x56, 0xaf, 0x36, 0x89, 0x93, 0xc5, 0x7b, 0x22, 0x8d,
- 0xef, 0x20, 0x7d, 0xa7, 0xee, 0x37, 0x53, 0x5a, 0xd1, 0x4a, 0x26, 0x8d,
- 0x5d, 0x7a, 0x1a, 0xc2, 0xf3, 0x8f, 0xf7, 0x13, 0xfe, 0xf9, 0x15, 0x65,
- 0x2f, 0x1e, 0x34, 0x84, 0x28, 0x50, 0x09, 0xe4, 0x01, 0xef, 0x44, 0xe1,
- 0x7d, 0x85, 0x4e, 0xaf, 0x2e, 0xec, 0xd6, 0xa6, 0xcb, 0x28, 0x86, 0x36,
- 0x76, 0xe8, 0x29, 0x37, 0x56, 0x63, 0xde, 0x3c, 0x89, 0x30, 0x60, 0xa4,
- 0x0e, 0x80, 0x8f, 0x7a, 0xc2, 0x30, 0xe6, 0x3a, 0xa7, 0x53, 0x91, 0x0d,
- 0x96, 0xf6, 0x46, 0x05, 0xd2, 0x40, 0x9b, 0x8f, 0xdc, 0x5e, 0xa3, 0xde,
- 0x96, 0x2b, 0xd9, 0x14, 0x07, 0x77, 0x0f, 0xb4, 0xfd, 0xc6, 0xeb, 0xf5,
- 0xaa, 0xfe, 0x71, 0xfe, 0xe2, 0x7f, 0xdf, 0x22, 0x8f, 0x38, 0xff, 0x00,
- 0x71, 0x3f, 0xef, 0x91, 0x5d, 0x7c, 0xaa, 0xd6, 0xb1, 0xc1, 0xce, 0xef,
- 0x7b, 0x9b, 0xb1, 0xc8, 0x25, 0x45, 0x75, 0xe8, 0x46, 0x69, 0xd5, 0x95,
- 0x1d, 0xe3, 0xa0, 0x81, 0x46, 0x02, 0x9e, 0xa0, 0x0f, 0x72, 0x2b, 0x4b,
- 0x35, 0xc9, 0x28, 0xf2, 0x9d, 0xf0, 0xa9, 0xce, 0x85, 0x92, 0x41, 0x1a,
- 0x33, 0xb7, 0x40, 0x32, 0x6b, 0x2a, 0x5b, 0xd9, 0x1c, 0x17, 0x47, 0x09,
- 0x93, 0x8d, 0x83, 0xaf, 0xd6, 0x9d, 0x25, 0xe3, 0xbf, 0x9e, 0xa4, 0x02,
- 0xa3, 0xa0, 0x23, 0xdc, 0x55, 0x5f, 0x38, 0xff, 0x00, 0x71, 0x3f, 0xef,
- 0x91, 0x5b, 0xc2, 0x16, 0xdc, 0xe6, 0xa9, 0x57, 0x9b, 0x44, 0xc8, 0xea,
- 0x70, 0xa4, 0x88, 0x30, 0x09, 0xff, 0x00, 0xf5, 0xd3, 0x4d, 0xbb, 0x09,
- 0x84, 0x59, 0x1b, 0xbd, 0x7b, 0x56, 0x95, 0xb4, 0x66, 0x18, 0x42, 0x13,
- 0x92, 0x3d, 0x2a, 0xe5, 0x2b, 0x23, 0x2a, 0x70, 0x72, 0x6d, 0x32, 0x7a,
- 0xc8, 0x2a, 0x40, 0x9f, 0x20, 0x8f, 0xff, 0x00, 0x5d, 0x6a, 0xe6, 0xa3,
- 0xb9, 0x8c, 0xcf, 0x09, 0x40, 0x40, 0x27, 0xd6, 0xb1, 0x83, 0xe5, 0x3a,
- 0x6a, 0x47, 0x99, 0x5c, 0xc7, 0xa2, 0xa5, 0x5b, 0x76, 0x69, 0x8c, 0x59,
- 0x1b, 0xbf, 0x4a, 0x3e, 0xce, 0xde, 0x7f, 0x95, 0x91, 0xbb, 0xd7, 0xb5,
- 0x74, 0xdd, 0x1c, 0x3c, 0xac, 0x7a, 0xa9, 0x2d, 0x6f, 0x80, 0x7f, 0xcb,
- 0x1a, 0xd6, 0xa8, 0x6d, 0xe3, 0x30, 0xc2, 0xa8, 0x48, 0x24, 0x77, 0x15,
- 0x26, 0x6b, 0x9a, 0x6f, 0x99, 0x9d, 0xf4, 0xe3, 0xca, 0x8c, 0xb6, 0x52,
- 0x1a, 0xe3, 0x20, 0xff, 0x00, 0x96, 0x15, 0x5e, 0xb6, 0x2e, 0x23, 0x33,
- 0x44, 0xc8, 0x08, 0x04, 0xd6, 0x67, 0xd9, 0xdb, 0xcf, 0xf2, 0xb2, 0x37,
- 0x7a, 0xf6, 0xad, 0xa1, 0x24, 0xd1, 0xcb, 0x52, 0x0e, 0x2d, 0x58, 0x8a,
- 0xa7, 0x0a, 0x48, 0x83, 0x00, 0x9f, 0xff, 0x00, 0x5d, 0x34, 0xdb, 0xb2,
- 0xcc, 0x22, 0xc8, 0xdd, 0xeb, 0xda, 0xb4, 0xad, 0xa3, 0x30, 0xc2, 0xaa,
- 0x4e, 0x48, 0xf4, 0xa2, 0x52, 0xb2, 0x0a, 0x70, 0x72, 0x6d, 0x32, 0x7a,
- 0x29, 0xa4, 0xd1, 0x9a, 0xe5, 0xb1, 0xde, 0x3a, 0x8a, 0x6e, 0x73, 0x41,
- 0x34, 0x58, 0x0e, 0x7f, 0xe2, 0x1f, 0xfc, 0x88, 0xfa, 0xe7, 0xfd, 0x7a,
- 0xbf, 0xf2, 0xaf, 0x95, 0xab, 0xeb, 0x2f, 0x18, 0x58, 0x4b, 0xaa, 0xf8,
- 0x57, 0x56, 0xb4, 0x80, 0x6e, 0x9a, 0x6b, 0x69, 0x15, 0x17, 0xd5, 0xb6,
- 0x9c, 0x0f, 0xce, 0xbe, 0x4e, 0x65, 0x2a, 0x48, 0x20, 0x82, 0x38, 0x20,
- 0xf6, 0xaf, 0xc1, 0x7c, 0x46, 0x84, 0x96, 0x32, 0x84, 0xed, 0xa3, 0x8b,
- 0x5f, 0x73, 0xff, 0x00, 0x82, 0x8d, 0x20, 0x25, 0x7d, 0x5d, 0xe0, 0x5f,
- 0xf9, 0x12, 0xf4, 0x2f, 0xfa, 0xf2, 0x87, 0xff, 0x00, 0x40, 0x15, 0xf2,
- 0x9a, 0x23, 0x48, 0xea, 0x88, 0xa5, 0x9d, 0x8e, 0x02, 0x81, 0x92, 0x4d,
- 0x7d, 0x69, 0xe1, 0x8b, 0x19, 0x34, 0xbf, 0x0d, 0xe9, 0x76, 0x73, 0x71,
- 0x2c, 0x16, 0xd1, 0xc6, 0xe3, 0xd0, 0x85, 0x00, 0xd5, 0x78, 0x73, 0x09,
- 0x3c, 0x56, 0x22, 0x76, 0xd1, 0x45, 0x2f, 0xc7, 0xfe, 0x00, 0x4c, 0xd0,
- 0xba, 0xff, 0x00, 0x8f, 0x69, 0xbf, 0xdc, 0x3f, 0xca, 0xbe, 0x39, 0xaf,
- 0xb1, 0xe5, 0x5f, 0x32, 0x27, 0x4c, 0xe3, 0x72, 0x91, 0x9a, 0xf9, 0x03,
- 0x50, 0xb1, 0x9b, 0x4c, 0xbe, 0xb8, 0xb4, 0x9d, 0x0a, 0x4d, 0x04, 0x86,
- 0x37, 0x53, 0xd8, 0x83, 0x8a, 0xed, 0xf1, 0x22, 0x12, 0xff, 0x00, 0x65,
- 0x9d, 0xb4, 0xf7, 0xd7, 0xfe, 0x92, 0x10, 0x2b, 0xd7, 0xd2, 0x5f, 0x05,
- 0xbf, 0xe4, 0x9f, 0x58, 0xff, 0x00, 0xd7, 0x49, 0x7f, 0xf4, 0x33, 0x5f,
- 0x36, 0xd7, 0xd3, 0x9f, 0x0a, 0x74, 0xe9, 0xb4, 0xbf, 0x01, 0xe9, 0x91,
- 0x4e, 0xa5, 0x24, 0x75, 0x69, 0x76, 0x9e, 0xa0, 0x33, 0x12, 0x3f, 0x42,
- 0x2b, 0xc3, 0xf0, 0xf6, 0x12, 0x96, 0x69, 0x52, 0x49, 0x68, 0xa0, 0xff,
- 0x00, 0x19, 0x44, 0x72, 0xd8, 0xeb, 0xe8, 0xa6, 0xe6, 0x8c, 0xd7, 0xf4,
- 0x3d, 0x8c, 0x87, 0x51, 0x4d, 0xcd, 0x19, 0xa2, 0xc0, 0x65, 0xb2, 0x90,
- 0xd7, 0x19, 0x04, 0x7f, 0xfb, 0x42, 0xab, 0xd6, 0xc5, 0xc4, 0x66, 0x68,
- 0x59, 0x07, 0x04, 0xfa, 0xd6, 0x67, 0xd9, 0xdb, 0xcf, 0xf2, 0xb2, 0x37,
- 0x7a, 0xf6, 0xae, 0xa8, 0x4a, 0xe8, 0xe0, 0xa9, 0x07, 0x16, 0xac, 0x45,
- 0x53, 0x85, 0x24, 0x41, 0x80, 0x4f, 0xff, 0x00, 0xae, 0x9a, 0x6d, 0xd9,
- 0x66, 0x11, 0x64, 0x6e, 0xf5, 0xed, 0x5a, 0x76, 0xd1, 0x98, 0x21, 0x0a,
- 0x48, 0x27, 0xda, 0x89, 0x4a, 0xc8, 0x29, 0xc1, 0xc9, 0xb4, 0xc9, 0xab,
- 0x20, 0xa9, 0x02, 0x7c, 0x82, 0x3f, 0xfd, 0x75, 0xab, 0x9a, 0x8a, 0xe6,
- 0x33, 0x34, 0x45, 0x41, 0xc1, 0xf7, 0xac, 0x60, 0xf9, 0x4e, 0x9a, 0x91,
- 0xe6, 0x46, 0x45, 0x15, 0x28, 0xb7, 0x66, 0x98, 0xc5, 0x91, 0xb8, 0x77,
- 0xed, 0x47, 0xd9, 0xdb, 0xcf, 0xf2, 0xb2, 0x37, 0x7a, 0xf6, 0xae, 0x9b,
- 0xa3, 0x87, 0x95, 0x8f, 0x55, 0x25, 0xad, 0xf0, 0x0f, 0xf9, 0x63, 0x5a,
- 0xd5, 0x0d, 0xba, 0x18, 0x61, 0x54, 0x24, 0x12, 0x3d, 0x2a, 0x4c, 0xd7,
- 0x34, 0xdf, 0x33, 0x3b, 0xe9, 0xc7, 0x95, 0x19, 0x6c, 0xa4, 0x35, 0xc6,
- 0x41, 0xff, 0x00, 0x2c, 0x2a, 0xbd, 0x6c, 0x5c, 0x46, 0x66, 0x85, 0x90,
- 0x1c, 0x13, 0xeb, 0x59, 0x9f, 0x67, 0x6f, 0x3f, 0xca, 0xc8, 0xdd, 0xfa,
- 0x56, 0xd0, 0x92, 0x68, 0xe5, 0xa9, 0x06, 0x9a, 0xb1, 0xa0, 0xd6, 0xc1,
- 0xae, 0x04, 0xb9, 0x39, 0x1d, 0xaa, 0x6a, 0x28, 0xae, 0x76, 0xdb, 0x3a,
- 0xd2, 0xb6, 0xc1, 0x45, 0x14, 0x52, 0x19, 0x0a, 0xdb, 0x05, 0xb8, 0x32,
- 0xe4, 0xe4, 0xf6, 0xa3, 0xec, 0xc3, 0xed, 0x1e, 0x6e, 0x4e, 0x7d, 0x2a,
- 0x6a, 0x2a, 0xb9, 0x99, 0x3c, 0xa8, 0x28, 0xa2, 0x8a, 0x92, 0x82, 0xa1,
- 0xfb, 0x30, 0xfb, 0x47, 0x9b, 0x93, 0x9f, 0x4a, 0x9a, 0x8a, 0x69, 0xd8,
- 0x4d, 0x5f, 0x72, 0x16, 0xb6, 0x0d, 0x70, 0x25, 0xc9, 0xc8, 0xed, 0x53,
- 0x51, 0x45, 0x0d, 0xb6, 0x09, 0x5b, 0x60, 0xa2, 0x8a, 0x29, 0x0c, 0x28,
- 0xa2, 0x8a, 0x00, 0x2b, 0x83, 0xf1, 0x57, 0xc1, 0xdd, 0x1b, 0xc4, 0xb7,
- 0xaf, 0x79, 0x1b, 0xcb, 0xa7, 0x5d, 0x48, 0x73, 0x21, 0x80, 0x02, 0x8e,
- 0x7d, 0x4a, 0x9e, 0xff, 0x00, 0x42, 0x2b, 0xbc, 0xa2, 0xbc, 0xfc, 0x76,
- 0x5f, 0x85, 0xcc, 0xa9, 0xfb, 0x1c, 0x5d, 0x35, 0x38, 0xf9, 0xfe, 0x8f,
- 0x75, 0xf2, 0x1a, 0x6d, 0x1c, 0x3f, 0x84, 0xbe, 0x11, 0xe8, 0xde, 0x16,
- 0xbb, 0x4b, 0xc2, 0xd2, 0x5f, 0xde, 0x27, 0x29, 0x24, 0xf8, 0xda, 0x87,
- 0xd5, 0x54, 0x77, 0xf7, 0x39, 0xae, 0xe2, 0x8a, 0x29, 0xe0, 0xb0, 0x18,
- 0x5c, 0xba, 0x97, 0xb1, 0xc2, 0x53, 0x50, 0x8f, 0x97, 0xeb, 0xd5, 0xfc,
- 0xc2, 0xed, 0x85, 0x71, 0xfe, 0x31, 0xf8, 0x5f, 0xa4, 0x78, 0xc6, 0x6f,
- 0xb4, 0xcd, 0xe6, 0x5a, 0x5e, 0xe3, 0x06, 0xe2, 0x0c, 0x65, 0xc7, 0x6d,
- 0xc0, 0xf5, 0xfe, 0x7e, 0xf5, 0xd8, 0x51, 0x55, 0x8c, 0xc1, 0x61, 0xf1,
- 0xf4, 0x9d, 0x0c, 0x54, 0x14, 0xe2, 0xfa, 0x3f, 0xeb, 0x46, 0x17, 0x68,
- 0xf3, 0xbf, 0x0f, 0x7c, 0x11, 0xd1, 0x74, 0x6b, 0xc4, 0xb9, 0xb9, 0x96,
- 0x5d, 0x49, 0xd0, 0xe5, 0x63, 0x94, 0x05, 0x8f, 0x3e, 0xa5, 0x47, 0x5f,
- 0xc4, 0xe3, 0xda, 0xbd, 0x13, 0xa5, 0x14, 0x56, 0x38, 0x1c, 0xb7, 0x07,
- 0x96, 0x41, 0xd3, 0xc1, 0xd3, 0x50, 0x4f, 0x7b, 0x75, 0xf5, 0x7b, 0xb0,
- 0x6d, 0xb0, 0xa2, 0x8a, 0x2b, 0xd3, 0x10, 0x51, 0x45, 0x14, 0x00, 0x54,
- 0x3f, 0x66, 0x1f, 0x68, 0xf3, 0x72, 0x73, 0xe9, 0x53, 0x51, 0x4d, 0x3b,
- 0x09, 0xab, 0xee, 0x42, 0xd6, 0xc1, 0xae, 0x04, 0xb9, 0x39, 0x1d, 0xaa,
- 0x6a, 0x28, 0xa1, 0xb6, 0xc1, 0x2b, 0x6c, 0x14, 0x51, 0x45, 0x21, 0x90,
- 0xad, 0xb0, 0x5b, 0x83, 0x2e, 0x4e, 0x4f, 0x6a, 0x3e, 0xcc, 0x3e, 0xd1,
- 0xe6, 0xe4, 0xe7, 0xd2, 0xa6, 0xa2, 0xab, 0x99, 0x93, 0xca, 0x82, 0x8a,
- 0x28, 0xa9, 0x28, 0x2a, 0x1f, 0xb3, 0x0f, 0xb4, 0x79, 0xb9, 0x39, 0xf4,
- 0xa9, 0xa8, 0xa6, 0x9d, 0x84, 0xd5, 0xf7, 0x3e, 0x20, 0xff, 0x00, 0x87,
- 0xa6, 0xf8, 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xa3,
- 0xfe, 0x1e, 0x9b, 0xe1, 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a, 0x8a,
- 0xbe, 0x17, 0xfe, 0xc6, 0xb2, 0xff, 0x00, 0x9f, 0x64, 0xa7, 0x47, 0xa2,
- 0x59, 0x31, 0xe6, 0xd9, 0x31, 0x45, 0x8e, 0x9e, 0x44, 0x7d, 0xcd, 0xff,
- 0x00, 0x0f, 0x4d, 0xf0, 0xb7, 0xfd, 0x08, 0xfa, 0xc7, 0xfe, 0x05, 0x45,
- 0x47, 0xfc, 0x3d, 0x37, 0xc2, 0xdf, 0xf4, 0x23, 0xeb, 0x1f, 0xf8, 0x15,
- 0x15, 0x7c, 0x3b, 0xfd, 0x87, 0x61, 0xff, 0x00, 0x3e, 0xb1, 0xfe, 0x54,
- 0xd9, 0x34, 0x6b, 0x05, 0x1c, 0x5b, 0x47, 0x9f, 0xa5, 0x16, 0x0e, 0x44,
- 0x7d, 0xc9, 0xff, 0x00, 0x0f, 0x4d, 0xf0, 0xb7, 0xfd, 0x08, 0xfa, 0xc7,
- 0xfe, 0x05, 0x45, 0x47, 0xfc, 0x3d, 0x37, 0xc2, 0xdf, 0xf4, 0x23, 0xeb,
- 0x1f, 0xf8, 0x15, 0x15, 0x7c, 0x2f, 0xfd, 0x8d, 0x65, 0xff, 0x00, 0x3e,
- 0xc9, 0xf9, 0x53, 0xe3, 0xd1, 0x2c, 0x4f, 0x26, 0xd9, 0x31, 0xf4, 0xa2,
- 0xc1, 0xc8, 0x8f, 0xb9, 0x7f, 0xe1, 0xe9, 0xbe, 0x16, 0xff, 0x00, 0xa1,
- 0x1f, 0x58, 0xff, 0x00, 0xc0, 0xa8, 0xa8, 0xff, 0x00, 0x87, 0xa6, 0xf8,
- 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xaf, 0x87, 0x7f,
- 0xb0, 0xec, 0x3f, 0xe7, 0xd6, 0x3f, 0xca, 0x99, 0x26, 0x8d, 0x62, 0x38,
- 0x16, 0xc9, 0x9a, 0x2c, 0x1c, 0x88, 0xfb, 0x97, 0xfe, 0x1e, 0x9b, 0xe1,
- 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a, 0x8a, 0x8f, 0xf8, 0x7a, 0x6f,
- 0x85, 0xbf, 0xe8, 0x47, 0xd6, 0x3f, 0xf0, 0x2a, 0x2a, 0xf8, 0x5f, 0xfb,
- 0x1a, 0xcb, 0xfe, 0x7d, 0x93, 0xf2, 0xa9, 0x23, 0xd1, 0x2c, 0x48, 0xc9,
- 0xb6, 0x4f, 0xca, 0x8b, 0x07, 0x22, 0x3e, 0xe4, 0xff, 0x00, 0x87, 0xa6,
- 0xf8, 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xa3, 0xfe,
- 0x1e, 0x9b, 0xe1, 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a, 0x8a, 0xbe,
- 0x1d, 0xfe, 0xc3, 0xb0, 0xff, 0x00, 0x9f, 0x58, 0xff, 0x00, 0x2a, 0x64,
- 0x9a, 0x35, 0x88, 0x38, 0x16, 0xc9, 0xf9, 0x51, 0x60, 0xe4, 0x47, 0xdc,
- 0xbf, 0xf0, 0xf4, 0xdf, 0x0b, 0x7f, 0xd0, 0x8f, 0xac, 0x7f, 0xe0, 0x54,
- 0x54, 0x7f, 0xc3, 0xd3, 0x7c, 0x2d, 0xff, 0x00, 0x42, 0x3e, 0xb1, 0xff,
- 0x00, 0x81, 0x51, 0x57, 0xc2, 0xff, 0x00, 0xd8, 0xd6, 0x5f, 0xf3, 0xec,
- 0x9f, 0x95, 0x48, 0x9a, 0x1d, 0x89, 0x19, 0x36, 0xc9, 0xf9, 0x51, 0x60,
- 0xe4, 0x47, 0xdc, 0x9f, 0xf0, 0xf4, 0xdf, 0x0b, 0x7f, 0xd0, 0x8f, 0xac,
- 0x7f, 0xe0, 0x54, 0x54, 0x7f, 0xc3, 0xd3, 0x7c, 0x2d, 0xff, 0x00, 0x42,
- 0x3e, 0xb1, 0xff, 0x00, 0x81, 0x51, 0x57, 0xc3, 0xbf, 0xd8, 0x76, 0x1f,
- 0xf3, 0xeb, 0x1f, 0xe5, 0x51, 0xbe, 0x8d, 0x63, 0x9c, 0x0b, 0x64, 0xfc,
- 0xa8, 0xb0, 0x72, 0x23, 0xee, 0x6f, 0xf8, 0x7a, 0x6f, 0x85, 0xbf, 0xe8,
- 0x47, 0xd6, 0x3f, 0xf0, 0x2a, 0x2a, 0x3f, 0xe1, 0xe9, 0xbe, 0x16, 0xff,
- 0x00, 0xa1, 0x1f, 0x58, 0xff, 0x00, 0xc0, 0xa8, 0xab, 0xe1, 0x7f, 0xec,
- 0x7b, 0x2f, 0xf9, 0xf6, 0x4f, 0xca, 0x9b, 0x2e, 0x9d, 0xa7, 0xdb, 0xed,
- 0x53, 0x67, 0xe6, 0xc8, 0xc0, 0x90, 0xb1, 0xae, 0x4e, 0x3d, 0x68, 0xb0,
- 0x72, 0x23, 0xee, 0xaf, 0xf8, 0x7a, 0x6f, 0x85, 0xbf, 0xe8, 0x47, 0xd6,
- 0x3f, 0xf0, 0x2a, 0x2a, 0x3f, 0xe1, 0xe9, 0xbe, 0x16, 0xff, 0x00, 0xa1,
- 0x1f, 0x58, 0xff, 0x00, 0xc0, 0xa8, 0xab, 0xe1, 0x1f, 0x23, 0x4b, 0xd8,
- 0x1b, 0xec, 0x44, 0x8d, 0xbb, 0x9b, 0x09, 0xf7, 0x06, 0x48, 0xc9, 0xe7,
- 0xd8, 0xfe, 0x54, 0x3d, 0x9e, 0x9e, 0x2e, 0x04, 0x66, 0xcb, 0x60, 0x27,
- 0x68, 0x72, 0xbf, 0x29, 0x3f, 0x5c, 0xd1, 0x60, 0xe4, 0x47, 0xdd, 0xdf,
- 0xf0, 0xf4, 0xdf, 0x0b, 0x7f, 0xd0, 0x8f, 0xac, 0x7f, 0xe0, 0x54, 0x54,
- 0x7f, 0xc3, 0xd3, 0x7c, 0x2d, 0xff, 0x00, 0x42, 0x3e, 0xb1, 0xff, 0x00,
- 0x81, 0x51, 0x57, 0xc1, 0x82, 0xdf, 0x4e, 0x1b, 0xb7, 0xd9, 0x98, 0x88,
- 0x19, 0xda, 0xeb, 0xc9, 0xe7, 0x1c, 0x73, 0xea, 0x45, 0x4d, 0x1d, 0x9e,
- 0x9a, 0x46, 0x0d, 0x91, 0x12, 0x02, 0x41, 0x8c, 0xaf, 0xcd, 0x9c, 0x67,
- 0xd7, 0xd2, 0x8b, 0x07, 0x22, 0x3e, 0xed, 0xff, 0x00, 0x87, 0xa6, 0xf8,
- 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xa3, 0xfe, 0x1e,
- 0x9b, 0xe1, 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a, 0x8a, 0xbe, 0x16,
- 0xb7, 0xd3, 0xf4, 0xeb, 0x86, 0x65, 0xfb, 0x1f, 0x96, 0xea, 0x01, 0x2b,
- 0x22, 0xe0, 0xe0, 0xf7, 0xa7, 0x36, 0x8f, 0x62, 0x49, 0xc5, 0xb2, 0x62,
- 0x8b, 0x07, 0x22, 0x3e, 0xe7, 0xff, 0x00, 0x87, 0xa6, 0xf8, 0x5b, 0xfe,
- 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xa3, 0xfe, 0x1e, 0x9b, 0xe1,
- 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a, 0x8a, 0xbe, 0x17, 0xfe, 0xc6,
- 0xb2, 0x3f, 0xf2, 0xec, 0x95, 0x30, 0xd0, 0xec, 0x40, 0xff, 0x00, 0x8f,
- 0x64, 0xa2, 0xc1, 0xc8, 0x8f, 0xb8, 0xbf, 0xe1, 0xe9, 0xbe, 0x16, 0xff,
- 0x00, 0xa1, 0x1f, 0x58, 0xff, 0x00, 0xc0, 0xa8, 0xa8, 0xff, 0x00, 0x87,
- 0xa6, 0xf8, 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2, 0xaf,
- 0x87, 0x7f, 0xb1, 0x2c, 0x07, 0xfc, 0xba, 0xc7, 0xf9, 0x54, 0x27, 0x47,
- 0xb2, 0x27, 0xfe, 0x3d, 0x92, 0x8b, 0x07, 0x22, 0x3e, 0xe8, 0xff, 0x00,
- 0x87, 0xa6, 0xf8, 0x5b, 0xfe, 0x84, 0x7d, 0x63, 0xff, 0x00, 0x02, 0xa2,
- 0xa3, 0xfe, 0x1e, 0x9b, 0xe1, 0x6f, 0xfa, 0x11, 0xf5, 0x8f, 0xfc, 0x0a,
- 0x8a, 0xbe, 0x17, 0x1a, 0x2d, 0x91, 0x38, 0xfb, 0x32, 0x54, 0xdf, 0xd8,
- 0x76, 0x1f, 0xf3, 0xea, 0x9f, 0x95, 0x16, 0x0e, 0x44, 0x7d, 0xc5, 0xff,
- 0x00, 0x0f, 0x4d, 0xf0, 0xb7, 0xfd, 0x08, 0xfa, 0xc7, 0xfe, 0x05, 0x45,
- 0x47, 0xfc, 0x3d, 0x37, 0xc2, 0xdf, 0xf4, 0x23, 0xeb, 0x1f, 0xf8, 0x15,
- 0x15, 0x7c, 0x3a, 0x74, 0x4b, 0x00, 0x33, 0xf6, 0x58, 0xff, 0x00, 0x2a,
- 0x84, 0xe8, 0xd6, 0x5f, 0xf3, 0xec, 0x94, 0x58, 0x39, 0x11, 0xf7, 0x47,
- 0xfc, 0x3d, 0x37, 0xc2, 0xdf, 0xf4, 0x23, 0xeb, 0x1f, 0xf8, 0x15, 0x15,
- 0x1f, 0xf0, 0xf4, 0xdf, 0x0b, 0x7f, 0xd0, 0x8f, 0xac, 0x7f, 0xe0, 0x54,
- 0x55, 0xf0, 0xc2, 0xe8, 0xb6, 0x4c, 0x40, 0xfb, 0x32, 0x54, 0xbf, 0xd8,
- 0x76, 0x1f, 0xf3, 0xea, 0x94, 0x58, 0x39, 0x11, 0xf7, 0x17, 0xfc, 0x3d,
- 0x37, 0xc2, 0xdf, 0xf4, 0x23, 0xeb, 0x1f, 0xf8, 0x15, 0x15, 0x1f, 0xf0,
- 0xf4, 0xdf, 0x0b, 0x7f, 0xd0, 0x8f, 0xac, 0x7f, 0xe0, 0x54, 0x55, 0xf0,
- 0xe3, 0x68, 0xb6, 0x0a, 0x09, 0xfb, 0x2c, 0x7f, 0x95, 0x45, 0xfd, 0x8d,
- 0x65, 0xff, 0x00, 0x3e, 0xc9, 0x45, 0x83, 0x91, 0x1f, 0x74, 0x7f, 0xc3,
- 0xd3, 0x7c, 0x2d, 0xff, 0x00, 0x42, 0x3e, 0xb1, 0xff, 0x00, 0x81, 0x51,
- 0x51, 0xff, 0x00, 0x0f, 0x4d, 0xf0, 0xb7, 0xfd, 0x08, 0xfa, 0xc7, 0xfe,
- 0x05, 0x45, 0x5f, 0x0c, 0x26, 0x89, 0x64, 0xcd, 0xff, 0x00, 0x1e, 0xc9,
- 0x52, 0xff, 0x00, 0x61, 0xd8, 0x7f, 0xcf, 0xac, 0x7f, 0x95, 0x16, 0x0e,
- 0x44, 0x7d, 0xc5, 0xff, 0x00, 0x0f, 0x4d, 0xf0, 0xb7, 0xfd, 0x08, 0xfa,
- 0xc7, 0xfe, 0x05, 0x45, 0x47, 0xfc, 0x3d, 0x37, 0xc2, 0xdf, 0xf4, 0x23,
- 0xeb, 0x1f, 0xf8, 0x15, 0x15, 0x7c, 0x38, 0xfa, 0x2d, 0x82, 0xaf, 0xfc,
- 0x7a, 0xc7, 0xf9, 0x54, 0x5f, 0xd8, 0xd6, 0x5f, 0xf3, 0xec, 0x94, 0x58,
- 0x39, 0x11, 0x72, 0xa7, 0x45, 0xda, 0xb8, 0xa8, 0xe3, 0x5c, 0xb6, 0x7d,
- 0x2a, 0x5a, 0xa2, 0xc2, 0xa1, 0x66, 0xdc, 0xd9, 0xa7, 0xc8, 0xd8, 0x18,
- 0xf5, 0xa8, 0xa8, 0x01, 0x40, 0xc9, 0xa9, 0xd4, 0x6d, 0x18, 0xa8, 0xe2,
- 0x5e, 0x73, 0x52, 0x50, 0x00, 0x4e, 0x05, 0x40, 0xc7, 0x71, 0xcd, 0x49,
- 0x2b, 0x71, 0x8a, 0x8a, 0x80, 0x14, 0x0c, 0x9c, 0x54, 0xe0, 0x60, 0x62,
- 0xa3, 0x89, 0x7b, 0xd4, 0x94, 0x00, 0x13, 0x80, 0x4d, 0x40, 0x4e, 0x4e,
- 0x69, 0xf2, 0xb7, 0x6a, 0x8e, 0x80, 0x15, 0x46, 0xe3, 0x8a, 0x9e, 0x99,
- 0x1a, 0xe0, 0x67, 0xd6, 0x9f, 0x40, 0x08, 0xc7, 0x68, 0xcd, 0x41, 0x4f,
- 0x91, 0xb2, 0x71, 0xe9, 0x4c, 0xa0, 0x07, 0x22, 0xee, 0x6f, 0x6a, 0x27,
- 0xb5, 0x59, 0xa4, 0x49, 0x37, 0xbc, 0x6e, 0xbc, 0x06, 0x43, 0x8c, 0x8f,
- 0x43, 0xed, 0x52, 0x46, 0xb8, 0x5f, 0x73, 0x4e, 0xa0, 0x0a, 0xa6, 0xca,
- 0x38, 0xa2, 0x95, 0x41, 0x6f, 0xde, 0x2e, 0xc3, 0xcf, 0x6c, 0x93, 0xff,
- 0x00, 0xb3, 0x1a, 0x87, 0xec, 0x60, 0xca, 0xae, 0xd2, 0x48, 0xe1, 0x4e,
- 0x42, 0x12, 0x36, 0x83, 0xf9, 0x55, 0xa9, 0x1b, 0x73, 0x7b, 0x0a, 0x6d,
- 0x00, 0x57, 0x8b, 0x49, 0xb7, 0x0c, 0xfb, 0x53, 0xcb, 0x0c, 0x00, 0x21,
- 0x38, 0xe8, 0x72, 0x0f, 0xd6, 0xa6, 0x5d, 0x39, 0x17, 0x90, 0xf2, 0x79,
- 0x99, 0x2c, 0x64, 0x27, 0x2c, 0x4e, 0xdc, 0x7e, 0x82, 0xac, 0xa2, 0xed,
- 0x5a, 0x5a, 0x00, 0xad, 0x1d, 0xaa, 0xdb, 0x16, 0x6f, 0x31, 0xe5, 0x91,
- 0xc0, 0x05, 0xe4, 0x39, 0x38, 0x1d, 0xbf, 0x5a, 0x5a, 0x73, 0xb6, 0xe6,
- 0xa6, 0xf5, 0xa0, 0x07, 0xc4, 0xb9, 0x39, 0xf4, 0xa9, 0x69, 0x14, 0x6d,
- 0x18, 0xa5, 0xe9, 0x40, 0x0c, 0x95, 0xb0, 0x31, 0x51, 0x52, 0xb1, 0xdc,
- 0x49, 0xa0, 0x0c, 0x9c, 0x50, 0x03, 0xe2, 0x5e, 0xf5, 0x25, 0x00, 0x60,
- 0x62, 0x82, 0x70, 0x33, 0x40, 0x11, 0xca, 0xdd, 0xaa, 0x3a, 0x52, 0x72,
- 0x73, 0x42, 0x8d, 0xc4, 0x0a, 0x00, 0x92, 0x25, 0xc0, 0xcd, 0x3e, 0x8e,
- 0x94, 0x8c, 0x76, 0x82, 0x68, 0x02, 0x39, 0x5b, 0x27, 0x1e, 0x94, 0xca,
- 0x3a, 0xd3, 0x91, 0x77, 0x35, 0x00, 0x49, 0x1a, 0xe1, 0x7d, 0xcd, 0x3a,
- 0x8a, 0x47, 0x6d, 0xab, 0x40, 0x11, 0xc8, 0xd9, 0x6f, 0x61, 0x4c, 0xa2,
- 0x9d, 0x1a, 0xee, 0x6f, 0x61, 0x40, 0x1f, 0xff, 0xd9
-};
diff --git a/services/camera/libcameraservice/FakeCamera.cpp b/services/camera/libcameraservice/FakeCamera.cpp
deleted file mode 100644
index f3a6a67e..00000000
--- a/services/camera/libcameraservice/FakeCamera.cpp
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
-**
-** Copyright 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.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT 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 "FakeCamera"
-#include <utils/Log.h>
-
-#include <string.h>
-#include <stdlib.h>
-#include <utils/String8.h>
-
-#include "FakeCamera.h"
-
-
-namespace android {
-
-// TODO: All this rgb to yuv should probably be in a util class.
-
-// TODO: I think something is wrong in this class because the shadow is kBlue
-// and the square color should alternate between kRed and kGreen. However on the
-// emulator screen these are all shades of gray. Y seems ok but the U and V are
-// probably not.
-
-static int tables_initialized = 0;
-uint8_t *gYTable, *gCbTable, *gCrTable;
-
-static int
-clamp(int x)
-{
- if (x > 255) return 255;
- if (x < 0) return 0;
- return x;
-}
-
-/* the equation used by the video code to translate YUV to RGB looks like this
- *
- * Y = (Y0 - 16)*k0
- * Cb = Cb0 - 128
- * Cr = Cr0 - 128
- *
- * G = ( Y - k1*Cr - k2*Cb )
- * R = ( Y + k3*Cr )
- * B = ( Y + k4*Cb )
- *
- */
-
-static const double k0 = 1.164;
-static const double k1 = 0.813;
-static const double k2 = 0.391;
-static const double k3 = 1.596;
-static const double k4 = 2.018;
-
-/* let's try to extract the value of Y
- *
- * G + k1/k3*R + k2/k4*B = Y*( 1 + k1/k3 + k2/k4 )
- *
- * Y = ( G + k1/k3*R + k2/k4*B ) / (1 + k1/k3 + k2/k4)
- * Y0 = ( G0 + k1/k3*R0 + k2/k4*B0 ) / ((1 + k1/k3 + k2/k4)*k0) + 16
- *
- * let define:
- * kYr = k1/k3
- * kYb = k2/k4
- * kYy = k0 * ( 1 + kYr + kYb )
- *
- * we have:
- * Y = ( G + kYr*R + kYb*B )
- * Y0 = clamp[ Y/kYy + 16 ]
- */
-
-static const double kYr = k1/k3;
-static const double kYb = k2/k4;
-static const double kYy = k0*( 1. + kYr + kYb );
-
-static void
-initYtab( void )
-{
- const int imax = (int)( (kYr + kYb)*(31 << 2) + (61 << 3) + 0.1 );
- int i;
-
- gYTable = (uint8_t *)malloc(imax);
-
- for(i=0; i<imax; i++) {
- int x = (int)(i/kYy + 16.5);
- if (x < 16) x = 16;
- else if (x > 235) x = 235;
- gYTable[i] = (uint8_t) x;
- }
-}
-
-/*
- * the source is RGB565, so adjust for 8-bit range of input values:
- *
- * G = (pixels >> 3) & 0xFC;
- * R = (pixels >> 8) & 0xF8;
- * B = (pixels & 0x1f) << 3;
- *
- * R2 = (pixels >> 11) R = R2*8
- * B2 = (pixels & 0x1f) B = B2*8
- *
- * kYr*R = kYr2*R2 => kYr2 = kYr*8
- * kYb*B = kYb2*B2 => kYb2 = kYb*8
- *
- * we want to use integer multiplications:
- *
- * SHIFT1 = 9
- *
- * (ALPHA*R2) >> SHIFT1 == R*kYr => ALPHA = kYr*8*(1 << SHIFT1)
- *
- * ALPHA = kYr*(1 << (SHIFT1+3))
- * BETA = kYb*(1 << (SHIFT1+3))
- */
-
-static const int SHIFT1 = 9;
-static const int ALPHA = (int)( kYr*(1 << (SHIFT1+3)) + 0.5 );
-static const int BETA = (int)( kYb*(1 << (SHIFT1+3)) + 0.5 );
-
-/*
- * now let's try to get the values of Cb and Cr
- *
- * R-B = (k3*Cr - k4*Cb)
- *
- * k3*Cr = k4*Cb + (R-B)
- * k4*Cb = k3*Cr - (R-B)
- *
- * R-G = (k1+k3)*Cr + k2*Cb
- * = (k1+k3)*Cr + k2/k4*(k3*Cr - (R-B)/k0)
- * = (k1 + k3 + k2*k3/k4)*Cr - k2/k4*(R-B)
- *
- * kRr*Cr = (R-G) + kYb*(R-B)
- *
- * Cr = ((R-G) + kYb*(R-B))/kRr
- * Cr0 = clamp(Cr + 128)
- */
-
-static const double kRr = (k1 + k3 + k2*k3/k4);
-
-static void
-initCrtab( void )
-{
- uint8_t *pTable;
- int i;
-
- gCrTable = (uint8_t *)malloc(768*2);
-
- pTable = gCrTable + 384;
- for(i=-384; i<384; i++)
- pTable[i] = (uint8_t) clamp( i/kRr + 128.5 );
-}
-
-/*
- * B-G = (k2 + k4)*Cb + k1*Cr
- * = (k2 + k4)*Cb + k1/k3*(k4*Cb + (R-B))
- * = (k2 + k4 + k1*k4/k3)*Cb + k1/k3*(R-B)
- *
- * kBb*Cb = (B-G) - kYr*(R-B)
- *
- * Cb = ((B-G) - kYr*(R-B))/kBb
- * Cb0 = clamp(Cb + 128)
- *
- */
-
-static const double kBb = (k2 + k4 + k1*k4/k3);
-
-static void
-initCbtab( void )
-{
- uint8_t *pTable;
- int i;
-
- gCbTable = (uint8_t *)malloc(768*2);
-
- pTable = gCbTable + 384;
- for(i=-384; i<384; i++)
- pTable[i] = (uint8_t) clamp( i/kBb + 128.5 );
-}
-
-/*
- * SHIFT2 = 16
- *
- * DELTA = kYb*(1 << SHIFT2)
- * GAMMA = kYr*(1 << SHIFT2)
- */
-
-static const int SHIFT2 = 16;
-static const int DELTA = kYb*(1 << SHIFT2);
-static const int GAMMA = kYr*(1 << SHIFT2);
-
-int32_t ccrgb16toyuv_wo_colorkey(uint8_t *rgb16, uint8_t *yuv420,
- uint32_t *param, uint8_t *table[])
-{
- uint16_t *inputRGB = (uint16_t*)rgb16;
- uint8_t *outYUV = yuv420;
- int32_t width_dst = param[0];
- int32_t height_dst = param[1];
- int32_t pitch_dst = param[2];
- int32_t mheight_dst = param[3];
- int32_t pitch_src = param[4];
- uint8_t *y_tab = table[0];
- uint8_t *cb_tab = table[1];
- uint8_t *cr_tab = table[2];
-
- int32_t size16 = pitch_dst*mheight_dst;
- int32_t i,j,count;
- int32_t ilimit,jlimit;
- uint8_t *tempY,*tempU,*tempV;
- uint16_t pixels;
- int tmp;
-uint32_t temp;
-
- tempY = outYUV;
- tempU = outYUV + (height_dst * pitch_dst);
- tempV = tempU + 1;
-
- jlimit = height_dst;
- ilimit = width_dst;
-
- for(j=0; j<jlimit; j+=1)
- {
- for (i=0; i<ilimit; i+=2)
- {
- int32_t G_ds = 0, B_ds = 0, R_ds = 0;
- uint8_t y0, y1, u, v;
-
- pixels = inputRGB[i];
- temp = (BETA*(pixels & 0x001F) + ALPHA*(pixels>>11) );
- y0 = y_tab[(temp>>SHIFT1) + ((pixels>>3) & 0x00FC)];
-
- G_ds += (pixels>>1) & 0x03E0;
- B_ds += (pixels<<5) & 0x03E0;
- R_ds += (pixels>>6) & 0x03E0;
-
- pixels = inputRGB[i+1];
- temp = (BETA*(pixels & 0x001F) + ALPHA*(pixels>>11) );
- y1 = y_tab[(temp>>SHIFT1) + ((pixels>>3) & 0x00FC)];
-
- G_ds += (pixels>>1) & 0x03E0;
- B_ds += (pixels<<5) & 0x03E0;
- R_ds += (pixels>>6) & 0x03E0;
-
- R_ds >>= 1;
- B_ds >>= 1;
- G_ds >>= 1;
-
- tmp = R_ds - B_ds;
-
- u = cb_tab[(((B_ds-G_ds)<<SHIFT2) - GAMMA*tmp)>>(SHIFT2+2)];
- v = cr_tab[(((R_ds-G_ds)<<SHIFT2) + DELTA*tmp)>>(SHIFT2+2)];
-
- tempY[0] = y0;
- tempY[1] = y1;
- tempY += 2;
-
- if ((j&1) == 0) {
- tempU[0] = u;
- tempV[0] = v;
- tempU += 2;
- tempV += 2;
- }
- }
-
- inputRGB += pitch_src;
- }
-
- return 1;
-}
-
-#define min(a,b) ((a)<(b)?(a):(b))
-#define max(a,b) ((a)>(b)?(a):(b))
-
-static void convert_rgb16_to_yuv420(uint8_t *rgb, uint8_t *yuv, int width, int height)
-{
- if (!tables_initialized) {
- initYtab();
- initCrtab();
- initCbtab();
- tables_initialized = 1;
- }
-
- uint32_t param[6];
- param[0] = (uint32_t) width;
- param[1] = (uint32_t) height;
- param[2] = (uint32_t) width;
- param[3] = (uint32_t) height;
- param[4] = (uint32_t) width;
- param[5] = (uint32_t) 0;
-
- uint8_t *table[3];
- table[0] = gYTable;
- table[1] = gCbTable + 384;
- table[2] = gCrTable + 384;
-
- ccrgb16toyuv_wo_colorkey(rgb, yuv, param, table);
-}
-
-const int FakeCamera::kRed;
-const int FakeCamera::kGreen;
-const int FakeCamera::kBlue;
-
-FakeCamera::FakeCamera(int width, int height)
- : mTmpRgb16Buffer(0)
-{
- setSize(width, height);
-}
-
-FakeCamera::~FakeCamera()
-{
- delete[] mTmpRgb16Buffer;
-}
-
-void FakeCamera::setSize(int width, int height)
-{
- mWidth = width;
- mHeight = height;
- mCounter = 0;
- mCheckX = 0;
- mCheckY = 0;
-
- // This will cause it to be reallocated on the next call
- // to getNextFrameAsYuv420().
- delete[] mTmpRgb16Buffer;
- mTmpRgb16Buffer = 0;
-}
-
-void FakeCamera::getNextFrameAsRgb565(uint16_t *buffer)
-{
- int size = mWidth / 10;
-
- drawCheckerboard(buffer, size);
-
- int x = ((mCounter*3)&255);
- if(x>128) x = 255 - x;
- int y = ((mCounter*5)&255);
- if(y>128) y = 255 - y;
-
- drawSquare(buffer, x*size/32, y*size/32, (size*5)>>1, (mCounter&0x100)?kRed:kGreen, kBlue);
-
- mCounter++;
-}
-
-void FakeCamera::getNextFrameAsYuv420(uint8_t *buffer)
-{
- if (mTmpRgb16Buffer == 0)
- mTmpRgb16Buffer = new uint16_t[mWidth * mHeight];
-
- getNextFrameAsRgb565(mTmpRgb16Buffer);
- convert_rgb16_to_yuv420((uint8_t*)mTmpRgb16Buffer, buffer, mWidth, mHeight);
-}
-
-void FakeCamera::drawSquare(uint16_t *dst, int x, int y, int size, int color, int shadow)
-{
- int square_xstop, square_ystop, shadow_xstop, shadow_ystop;
-
- square_xstop = min(mWidth, x+size);
- square_ystop = min(mHeight, y+size);
- shadow_xstop = min(mWidth, x+size+(size/4));
- shadow_ystop = min(mHeight, y+size+(size/4));
-
- // Do the shadow.
- uint16_t *sh = &dst[(y+(size/4))*mWidth];
- for (int j = y + (size/4); j < shadow_ystop; j++) {
- for (int i = x + (size/4); i < shadow_xstop; i++) {
- sh[i] &= shadow;
- }
- sh += mWidth;
- }
-
- // Draw the square.
- uint16_t *sq = &dst[y*mWidth];
- for (int j = y; j < square_ystop; j++) {
- for (int i = x; i < square_xstop; i++) {
- sq[i] = color;
- }
- sq += mWidth;
- }
-}
-
-void FakeCamera::drawCheckerboard(uint16_t *dst, int size)
-{
- bool black = true;
-
- if((mCheckX/size)&1)
- black = false;
- if((mCheckY/size)&1)
- black = !black;
-
- int county = mCheckY%size;
- int checkxremainder = mCheckX%size;
-
- for(int y=0;y<mHeight;y++) {
- int countx = checkxremainder;
- bool current = black;
- for(int x=0;x<mWidth;x++) {
- dst[y*mWidth+x] = current?0:0xffff;
- if(countx++ >= size) {
- countx=0;
- current = !current;
- }
- }
- if(county++ >= size) {
- county=0;
- black = !black;
- }
- }
- mCheckX += 3;
- mCheckY++;
-}
-
-
-void FakeCamera::dump(int fd) const
-{
- const size_t SIZE = 256;
- char buffer[SIZE];
- String8 result;
- snprintf(buffer, 255, " width x height (%d x %d), counter (%d), check x-y coordinate(%d, %d)\n", mWidth, mHeight, mCounter, mCheckX, mCheckY);
- result.append(buffer);
- ::write(fd, result.string(), result.size());
-}
-
-
-}; // namespace android
diff --git a/services/camera/libcameraservice/FakeCamera.h b/services/camera/libcameraservice/FakeCamera.h
deleted file mode 100644
index 724de207..00000000
--- a/services/camera/libcameraservice/FakeCamera.h
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-**
-** Copyright 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.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT 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_HARDWARE_FAKECAMERA_H
-#define ANDROID_HARDWARE_FAKECAMERA_H
-
-#include <sys/types.h>
-#include <stdint.h>
-
-namespace android {
-
-/*
- * FakeCamera is used in the CameraHardwareStub to provide a fake video feed
- * when the system does not have a camera in hardware.
- * The fake video is a moving black and white checkerboard background with a
- * bouncing gray square in the foreground.
- * This class is not thread-safe.
- *
- * TODO: Since the major methods provides a raw/uncompressed video feed, rename
- * this class to RawVideoSource.
- */
-
-class FakeCamera {
-public:
- FakeCamera(int width, int height);
- ~FakeCamera();
-
- void setSize(int width, int height);
- void getNextFrameAsYuv420(uint8_t *buffer);
- // Write to the fd a string representing the current state.
- void dump(int fd) const;
-
-private:
- // TODO: remove the uint16_t buffer param everywhere since it is a field of
- // this class.
- void getNextFrameAsRgb565(uint16_t *buffer);
-
- void drawSquare(uint16_t *buffer, int x, int y, int size, int color, int shadow);
- void drawCheckerboard(uint16_t *buffer, int size);
-
- static const int kRed = 0xf800;
- static const int kGreen = 0x07c0;
- static const int kBlue = 0x003e;
-
- int mWidth, mHeight;
- int mCounter;
- int mCheckX, mCheckY;
- uint16_t *mTmpRgb16Buffer;
-};
-
-}; // namespace android
-
-#endif // ANDROID_HARDWARE_FAKECAMERA_H
diff --git a/services/camera/libcameraservice/camera2/BurstCapture.cpp b/services/camera/libcameraservice/camera2/BurstCapture.cpp
new file mode 100644
index 00000000..f56c50cf
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/BurstCapture.cpp
@@ -0,0 +1,112 @@
+/*
+ * 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 "Camera2-BurstCapture"
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include "BurstCapture.h"
+
+#include "../Camera2Client.h"
+#include "JpegCompressor.h"
+
+namespace android {
+namespace camera2 {
+
+BurstCapture::BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer):
+ mCaptureStreamId(NO_STREAM),
+ mClient(client),
+ mSequencer(sequencer)
+{
+}
+
+BurstCapture::~BurstCapture() {
+}
+
+status_t BurstCapture::start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId) {
+ ALOGE("Not completely implemented");
+ return INVALID_OPERATION;
+}
+
+void BurstCapture::onFrameAvailable() {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock l(mInputMutex);
+ if(!mInputChanged) {
+ mInputChanged = true;
+ mInputSignal.signal();
+ }
+}
+
+bool BurstCapture::threadLoop() {
+ status_t res;
+ {
+ Mutex::Autolock l(mInputMutex);
+ while(!mInputChanged) {
+ res = mInputSignal.waitRelative(mInputMutex, kWaitDuration);
+ if(res == TIMED_OUT) return true;
+ }
+ mInputChanged = false;
+ }
+
+ do {
+ sp<Camera2Client> client = mClient.promote();
+ if(client == 0) return false;
+ ALOGV("%s: Calling processFrameAvailable()", __FUNCTION__);
+ res = processFrameAvailable(client);
+ } while(res == OK);
+
+ return true;
+}
+
+CpuConsumer::LockedBuffer* BurstCapture::jpegEncode(
+ CpuConsumer::LockedBuffer *imgBuffer,
+ int quality)
+{
+ ALOGV("%s", __FUNCTION__);
+
+ CpuConsumer::LockedBuffer *imgEncoded = new CpuConsumer::LockedBuffer;
+ uint8_t *data = new uint8_t[ANDROID_JPEG_MAX_SIZE];
+ imgEncoded->data = data;
+ imgEncoded->width = imgBuffer->width;
+ imgEncoded->height = imgBuffer->height;
+ imgEncoded->stride = imgBuffer->stride;
+
+ Vector<CpuConsumer::LockedBuffer*> buffers;
+ buffers.push_back(imgBuffer);
+ buffers.push_back(imgEncoded);
+
+ sp<JpegCompressor> jpeg = new JpegCompressor();
+ status_t res = jpeg->start(buffers, 1);
+
+ bool success = jpeg->waitForDone(10 * 1e9);
+ if(success) {
+ return buffers[1];
+ }
+ else {
+ ALOGE("%s: JPEG encode timed out", __FUNCTION__);
+ return NULL; // TODO: maybe change function return value to status_t
+ }
+}
+
+status_t BurstCapture::processFrameAvailable(sp<Camera2Client> &client) {
+ ALOGE("Not implemented");
+ return INVALID_OPERATION;
+}
+
+} // namespace camera2
+} // namespace android
diff --git a/services/camera/libcameraservice/camera2/BurstCapture.h b/services/camera/libcameraservice/camera2/BurstCapture.h
new file mode 100644
index 00000000..dfc45eb3
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/BurstCapture.h
@@ -0,0 +1,71 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H
+#define ANDROID_SERVERS_CAMERA_BURST_CAPTURE_H
+
+#include "camera2/CameraMetadata.h"
+#include <binder/MemoryBase.h>
+#include <binder/MemoryHeapBase.h>
+#include <gui/CpuConsumer.h>
+#include "Camera2Device.h"
+
+namespace android {
+
+class Camera2Client;
+
+namespace camera2 {
+
+class CaptureSequencer;
+
+class BurstCapture : public virtual Thread,
+ public virtual CpuConsumer::FrameAvailableListener
+{
+public:
+ BurstCapture(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
+ virtual ~BurstCapture();
+
+ virtual void onFrameAvailable();
+ virtual status_t start(Vector<CameraMetadata> &metadatas, int32_t firstCaptureId);
+
+protected:
+ Mutex mInputMutex;
+ bool mInputChanged;
+ Condition mInputSignal;
+ int mCaptureStreamId;
+ wp<Camera2Client> mClient;
+ wp<CaptureSequencer> mSequencer;
+
+ // Should only be accessed by processing thread
+ enum {
+ NO_STREAM = -1
+ };
+
+ CpuConsumer::LockedBuffer* jpegEncode(
+ CpuConsumer::LockedBuffer *imgBuffer,
+ int quality);
+
+ virtual status_t processFrameAvailable(sp<Camera2Client> &client);
+
+private:
+ virtual bool threadLoop();
+ static const nsecs_t kWaitDuration = 10000000; // 10 ms
+};
+
+} // namespace camera2
+} // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.cpp b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
new file mode 100644
index 00000000..3e9c2555
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CallbackProcessor.cpp
@@ -0,0 +1,301 @@
+/*
+ * 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 "Camera2-CallbackProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include "CallbackProcessor.h"
+#include <gui/SurfaceTextureClient.h>
+#include "../Camera2Device.h"
+#include "../Camera2Client.h"
+
+
+namespace android {
+namespace camera2 {
+
+CallbackProcessor::CallbackProcessor(wp<Camera2Client> client):
+ Thread(false),
+ mClient(client),
+ mCallbackAvailable(false),
+ mCallbackStreamId(NO_STREAM) {
+}
+
+CallbackProcessor::~CallbackProcessor() {
+ ALOGV("%s: Exit", __FUNCTION__);
+ deleteStream();
+}
+
+void CallbackProcessor::onFrameAvailable() {
+ Mutex::Autolock l(mInputMutex);
+ if (!mCallbackAvailable) {
+ mCallbackAvailable = true;
+ mCallbackAvailableSignal.signal();
+ }
+}
+
+status_t CallbackProcessor::updateStream(const Parameters &params) {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ if (mCallbackConsumer == 0) {
+ // Create CPU buffer queue endpoint
+ mCallbackConsumer = new CpuConsumer(kCallbackHeapCount);
+ mCallbackConsumer->setFrameAvailableListener(this);
+ mCallbackConsumer->setName(String8("Camera2Client::CallbackConsumer"));
+ mCallbackWindow = new SurfaceTextureClient(
+ mCallbackConsumer->getProducerInterface());
+ }
+
+ if (mCallbackStreamId != NO_STREAM) {
+ // Check if stream parameters have to change
+ uint32_t currentWidth, currentHeight, currentFormat;
+ res = device->getStreamInfo(mCallbackStreamId,
+ &currentWidth, &currentHeight, &currentFormat);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error querying callback output stream info: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ if (currentWidth != (uint32_t)params.previewWidth ||
+ currentHeight != (uint32_t)params.previewHeight ||
+ currentFormat != (uint32_t)params.previewFormat) {
+ // Since size should only change while preview is not running,
+ // assuming that all existing use of old callback stream is
+ // completed.
+ ALOGV("%s: Camera %d: Deleting stream %d since the buffer dimensions changed",
+ __FUNCTION__, client->getCameraId(), mCallbackStreamId);
+ res = device->deleteStream(mCallbackStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old output stream "
+ "for callbacks: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ mCallbackStreamId = NO_STREAM;
+ }
+ }
+
+ if (mCallbackStreamId == NO_STREAM) {
+ ALOGV("Creating callback stream: %d %d format 0x%x",
+ params.previewWidth, params.previewHeight,
+ params.previewFormat);
+ res = device->createStream(mCallbackWindow,
+ params.previewWidth, params.previewHeight,
+ params.previewFormat, 0, &mCallbackStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't create output stream for callbacks: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ }
+
+ return OK;
+}
+
+status_t CallbackProcessor::deleteStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ if (mCallbackStreamId != NO_STREAM) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ device->deleteStream(mCallbackStreamId);
+
+ mCallbackHeap.clear();
+ mCallbackWindow.clear();
+ mCallbackConsumer.clear();
+
+ mCallbackStreamId = NO_STREAM;
+ }
+ return OK;
+}
+
+int CallbackProcessor::getStreamId() const {
+ Mutex::Autolock l(mInputMutex);
+ return mCallbackStreamId;
+}
+
+void CallbackProcessor::dump(int fd, const Vector<String16>& args) const {
+}
+
+bool CallbackProcessor::threadLoop() {
+ status_t res;
+
+ {
+ Mutex::Autolock l(mInputMutex);
+ while (!mCallbackAvailable) {
+ res = mCallbackAvailableSignal.waitRelative(mInputMutex,
+ kWaitDuration);
+ if (res == TIMED_OUT) return true;
+ }
+ mCallbackAvailable = false;
+ }
+
+ do {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+ res = processNewCallback(client);
+ } while (res == OK);
+
+ return true;
+}
+
+status_t CallbackProcessor::processNewCallback(sp<Camera2Client> &client) {
+ ATRACE_CALL();
+ status_t res;
+
+ int callbackHeapId;
+ sp<Camera2Heap> callbackHeap;
+ size_t heapIdx;
+
+ CpuConsumer::LockedBuffer imgBuffer;
+ ALOGV("%s: Getting buffer", __FUNCTION__);
+ res = mCallbackConsumer->lockNextBuffer(&imgBuffer);
+ if (res != OK) {
+ if (res != BAD_VALUE) {
+ ALOGE("%s: Camera %d: Error receiving next callback buffer: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ }
+ return res;
+ }
+ ALOGV("%s: Camera %d: Preview callback available", __FUNCTION__,
+ client->getCameraId());
+
+ {
+ SharedParameters::Lock l(client->getParameters());
+
+ if ( l.mParameters.state != Parameters::PREVIEW
+ && l.mParameters.state != Parameters::RECORD
+ && l.mParameters.state != Parameters::VIDEO_SNAPSHOT) {
+ ALOGV("%s: Camera %d: No longer streaming",
+ __FUNCTION__, client->getCameraId());
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
+
+ if (! (l.mParameters.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) ) {
+ ALOGV("%s: No longer enabled, dropping", __FUNCTION__);
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
+ if ((l.mParameters.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) &&
+ !l.mParameters.previewCallbackOneShot) {
+ ALOGV("%s: One shot mode, already sent, dropping", __FUNCTION__);
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
+
+ if (imgBuffer.format != l.mParameters.previewFormat) {
+ ALOGE("%s: Camera %d: Unexpected format for callback: "
+ "%x, expected %x", __FUNCTION__, client->getCameraId(),
+ imgBuffer.format, l.mParameters.previewFormat);
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return INVALID_OPERATION;
+ }
+
+ // In one-shot mode, stop sending callbacks after the first one
+ if (l.mParameters.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ONE_SHOT_MASK) {
+ ALOGV("%s: clearing oneshot", __FUNCTION__);
+ l.mParameters.previewCallbackOneShot = false;
+ }
+ }
+
+ size_t bufferSize = Camera2Client::calculateBufferSize(
+ imgBuffer.width, imgBuffer.height,
+ imgBuffer.format, imgBuffer.stride);
+ size_t currentBufferSize = (mCallbackHeap == 0) ?
+ 0 : (mCallbackHeap->mHeap->getSize() / kCallbackHeapCount);
+ if (bufferSize != currentBufferSize) {
+ mCallbackHeap.clear();
+ mCallbackHeap = new Camera2Heap(bufferSize, kCallbackHeapCount,
+ "Camera2Client::CallbackHeap");
+ if (mCallbackHeap->mHeap->getSize() == 0) {
+ ALOGE("%s: Camera %d: Unable to allocate memory for callbacks",
+ __FUNCTION__, client->getCameraId());
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return INVALID_OPERATION;
+ }
+
+ mCallbackHeapHead = 0;
+ mCallbackHeapFree = kCallbackHeapCount;
+ }
+
+ if (mCallbackHeapFree == 0) {
+ ALOGE("%s: Camera %d: No free callback buffers, dropping frame",
+ __FUNCTION__, client->getCameraId());
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
+
+ heapIdx = mCallbackHeapHead;
+
+ mCallbackHeapHead = (mCallbackHeapHead + 1) & kCallbackHeapCount;
+ mCallbackHeapFree--;
+
+ // TODO: Get rid of this memcpy by passing the gralloc queue all the way
+ // to app
+
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap =
+ mCallbackHeap->mBuffers[heapIdx]->getMemory(&offset,
+ &size);
+ uint8_t *data = (uint8_t*)heap->getBase() + offset;
+ memcpy(data, imgBuffer.data, bufferSize);
+
+ ALOGV("%s: Freeing buffer", __FUNCTION__);
+ mCallbackConsumer->unlockBuffer(imgBuffer);
+
+ // Call outside parameter lock to allow re-entrancy from notification
+ {
+ Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ if (l.mCameraClient != 0) {
+ ALOGV("%s: Camera %d: Invoking client data callback",
+ __FUNCTION__, client->getCameraId());
+ l.mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_FRAME,
+ mCallbackHeap->mBuffers[heapIdx], NULL);
+ }
+ }
+
+ // Only increment free if we're still using the same heap
+ mCallbackHeapFree++;
+
+ ALOGV("%s: exit", __FUNCTION__);
+
+ return OK;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/CallbackProcessor.h b/services/camera/libcameraservice/camera2/CallbackProcessor.h
new file mode 100644
index 00000000..c2a13724
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CallbackProcessor.h
@@ -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.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_CALLBACKPROCESSOR_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_CALLBACKPROCESSOR_H
+
+#include <utils/Thread.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/Mutex.h>
+#include <utils/Condition.h>
+#include <gui/CpuConsumer.h>
+#include "Parameters.h"
+#include "CameraMetadata.h"
+#include "Camera2Heap.h"
+
+namespace android {
+
+class Camera2Client;
+
+namespace camera2 {
+
+/***
+ * Still image capture output image processing
+ */
+class CallbackProcessor:
+ public Thread, public CpuConsumer::FrameAvailableListener {
+ public:
+ CallbackProcessor(wp<Camera2Client> client);
+ ~CallbackProcessor();
+
+ void onFrameAvailable();
+
+ status_t updateStream(const Parameters &params);
+ status_t deleteStream();
+ int getStreamId() const;
+
+ void dump(int fd, const Vector<String16>& args) const;
+ private:
+ static const nsecs_t kWaitDuration = 10000000; // 10 ms
+ wp<Camera2Client> mClient;
+
+ mutable Mutex mInputMutex;
+ bool mCallbackAvailable;
+ Condition mCallbackAvailableSignal;
+
+ enum {
+ NO_STREAM = -1
+ };
+
+ int mCallbackStreamId;
+ static const size_t kCallbackHeapCount = 6;
+ sp<CpuConsumer> mCallbackConsumer;
+ sp<ANativeWindow> mCallbackWindow;
+ sp<Camera2Heap> mCallbackHeap;
+ int mCallbackHeapId;
+ size_t mCallbackHeapHead, mCallbackHeapFree;
+
+ virtual bool threadLoop();
+
+ status_t processNewCallback(sp<Camera2Client> &client);
+
+};
+
+
+}; //namespace camera2
+}; //namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/Camera2Heap.h b/services/camera/libcameraservice/camera2/Camera2Heap.h
new file mode 100644
index 00000000..9c72d762
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/Camera2Heap.h
@@ -0,0 +1,55 @@
+/*
+ * 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 ANDROiD_SERVERS_CAMERA_CAMERA2HEAP_H
+#define ANDROiD_SERVERS_CAMERA_CAMERA2HEAP_H
+
+#include <binder/MemoryBase.h>
+#include <binder/MemoryHeapBase.h>
+
+namespace android {
+namespace camera2 {
+
+// Utility class for managing a set of IMemory blocks
+class Camera2Heap : public RefBase {
+ public:
+ Camera2Heap(size_t buf_size, uint_t num_buffers = 1,
+ const char *name = NULL) :
+ mBufSize(buf_size),
+ mNumBufs(num_buffers) {
+ mHeap = new MemoryHeapBase(buf_size * num_buffers, 0, name);
+ mBuffers = new sp<MemoryBase>[mNumBufs];
+ for (uint_t i = 0; i < mNumBufs; i++)
+ mBuffers[i] = new MemoryBase(mHeap,
+ i * mBufSize,
+ mBufSize);
+ }
+
+ virtual ~Camera2Heap()
+ {
+ delete [] mBuffers;
+ }
+
+ size_t mBufSize;
+ uint_t mNumBufs;
+ sp<MemoryHeapBase> mHeap;
+ sp<MemoryBase> *mBuffers;
+};
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/CameraMetadata.cpp b/services/camera/libcameraservice/camera2/CameraMetadata.cpp
new file mode 100644
index 00000000..835587db
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CameraMetadata.cpp
@@ -0,0 +1,296 @@
+/*
+ * 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 "Camera2-Metadata"
+#include <utils/Log.h>
+#include <utils/Errors.h>
+
+#include "CameraMetadata.h"
+
+namespace android {
+
+namespace camera2 {
+CameraMetadata::CameraMetadata() :
+ mBuffer(NULL) {
+}
+
+CameraMetadata::CameraMetadata(size_t entryCapacity, size_t dataCapacity)
+{
+ mBuffer = allocate_camera_metadata(entryCapacity, dataCapacity);
+}
+
+CameraMetadata::CameraMetadata(const CameraMetadata &other) {
+ mBuffer = clone_camera_metadata(other.mBuffer);
+}
+
+CameraMetadata &CameraMetadata::operator=(const CameraMetadata &other) {
+ return operator=(other.mBuffer);
+}
+
+CameraMetadata &CameraMetadata::operator=(const camera_metadata_t *buffer) {
+ if (CC_LIKELY(buffer != mBuffer)) {
+ camera_metadata_t *newBuffer = clone_camera_metadata(buffer);
+ clear();
+ mBuffer = newBuffer;
+ }
+ return *this;
+}
+
+CameraMetadata::~CameraMetadata() {
+ clear();
+}
+
+camera_metadata_t* CameraMetadata::release() {
+ camera_metadata_t *released = mBuffer;
+ mBuffer = NULL;
+ return released;
+}
+
+void CameraMetadata::clear() {
+ if (mBuffer) {
+ free_camera_metadata(mBuffer);
+ mBuffer = NULL;
+ }
+}
+
+void CameraMetadata::acquire(camera_metadata_t *buffer) {
+ clear();
+ mBuffer = buffer;
+}
+
+void CameraMetadata::acquire(CameraMetadata &other) {
+ acquire(other.release());
+}
+
+status_t CameraMetadata::append(const CameraMetadata &other) {
+ return append_camera_metadata(mBuffer, other.mBuffer);
+}
+
+size_t CameraMetadata::entryCount() const {
+ return (mBuffer == NULL) ? 0 :
+ get_camera_metadata_entry_count(mBuffer);
+}
+
+bool CameraMetadata::isEmpty() const {
+ return entryCount() == 0;
+}
+
+status_t CameraMetadata::sort() {
+ return sort_camera_metadata(mBuffer);
+}
+
+status_t CameraMetadata::checkType(uint32_t tag, uint8_t expectedType) {
+ int tagType = get_camera_metadata_tag_type(tag);
+ if ( CC_UNLIKELY(tagType == -1)) {
+ ALOGE("Update metadata entry: Unknown tag %d", tag);
+ return INVALID_OPERATION;
+ }
+ if ( CC_UNLIKELY(tagType != expectedType) ) {
+ ALOGE("Mismatched tag type when updating entry %s (%d) of type %s; "
+ "got type %s data instead ",
+ get_camera_metadata_tag_name(tag), tag,
+ camera_metadata_type_names[tagType],
+ camera_metadata_type_names[expectedType]);
+ return INVALID_OPERATION;
+ }
+ return OK;
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const int32_t *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_INT32)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const uint8_t *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_BYTE)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const float *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_FLOAT)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const int64_t *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_INT64)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const double *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_DOUBLE)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const camera_metadata_rational_t *data, size_t data_count) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_RATIONAL)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)data, data_count);
+}
+
+status_t CameraMetadata::update(uint32_t tag,
+ const String8 &string) {
+ status_t res;
+ if ( (res = checkType(tag, TYPE_BYTE)) != OK) {
+ return res;
+ }
+ return update(tag, (const void*)string.string(), string.size());
+}
+
+status_t CameraMetadata::update(uint32_t tag, const void *data,
+ size_t data_count) {
+ status_t res;
+ int type = get_camera_metadata_tag_type(tag);
+ if (type == -1) {
+ ALOGE("%s: Tag %d not found", __FUNCTION__, tag);
+ return BAD_VALUE;
+ }
+ size_t data_size = calculate_camera_metadata_entry_data_size(type,
+ data_count);
+
+ res = resizeIfNeeded(1, data_size);
+
+ if (res == OK) {
+ camera_metadata_entry_t entry;
+ res = find_camera_metadata_entry(mBuffer, tag, &entry);
+ if (res == NAME_NOT_FOUND) {
+ res = add_camera_metadata_entry(mBuffer,
+ tag, data, data_count);
+ } else if (res == OK) {
+ res = update_camera_metadata_entry(mBuffer,
+ entry.index, data, data_count, NULL);
+ }
+ }
+
+ if (res != OK) {
+ ALOGE("%s: Unable to update metadata entry %s.%s (%x): %s (%d)",
+ __FUNCTION__, get_camera_metadata_section_name(tag),
+ get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ }
+ return res;
+}
+
+camera_metadata_entry_t CameraMetadata::find(uint32_t tag) {
+ status_t res;
+ camera_metadata_entry entry;
+ res = find_camera_metadata_entry(mBuffer, tag, &entry);
+ if (CC_UNLIKELY( res != OK )) {
+ entry.count = 0;
+ entry.data.u8 = NULL;
+ }
+ return entry;
+}
+
+camera_metadata_ro_entry_t CameraMetadata::find(uint32_t tag) const {
+ status_t res;
+ camera_metadata_ro_entry entry;
+ res = find_camera_metadata_ro_entry(mBuffer, tag, &entry);
+ if (CC_UNLIKELY( res != OK )) {
+ entry.count = 0;
+ entry.data.u8 = NULL;
+ }
+ return entry;
+}
+
+status_t CameraMetadata::erase(uint32_t tag) {
+ camera_metadata_entry_t entry;
+ status_t res;
+ res = find_camera_metadata_entry(mBuffer, tag, &entry);
+ if (res == NAME_NOT_FOUND) {
+ return OK;
+ } else if (res != OK) {
+ ALOGE("%s: Error looking for entry %s.%s (%x): %s %d",
+ __FUNCTION__,
+ get_camera_metadata_section_name(tag),
+ get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ return res;
+ }
+ res = delete_camera_metadata_entry(mBuffer, entry.index);
+ if (res != OK) {
+ ALOGE("%s: Error deleting entry %s.%s (%x): %s %d",
+ __FUNCTION__,
+ get_camera_metadata_section_name(tag),
+ get_camera_metadata_tag_name(tag), tag, strerror(-res), res);
+ }
+ return res;
+}
+
+void CameraMetadata::dump(int fd, int verbosity, int indentation) const {
+ dump_indented_camera_metadata(mBuffer, fd, verbosity, indentation);
+}
+
+status_t CameraMetadata::resizeIfNeeded(size_t extraEntries, size_t extraData) {
+ if (mBuffer == NULL) {
+ mBuffer = allocate_camera_metadata(extraEntries * 2, extraData * 2);
+ if (mBuffer == NULL) {
+ ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__);
+ return NO_MEMORY;
+ }
+ } else {
+ size_t currentEntryCount = get_camera_metadata_entry_count(mBuffer);
+ size_t currentEntryCap = get_camera_metadata_entry_capacity(mBuffer);
+ size_t newEntryCount = currentEntryCount +
+ extraEntries;
+ newEntryCount = (newEntryCount > currentEntryCap) ?
+ newEntryCount * 2 : currentEntryCap;
+
+ size_t currentDataCount = get_camera_metadata_data_count(mBuffer);
+ size_t currentDataCap = get_camera_metadata_data_capacity(mBuffer);
+ size_t newDataCount = currentDataCount +
+ extraData;
+ newDataCount = (newDataCount > currentDataCap) ?
+ newDataCount * 2 : currentDataCap;
+
+ if (newEntryCount > currentEntryCap ||
+ newDataCount > currentDataCap) {
+ camera_metadata_t *oldBuffer = mBuffer;
+ mBuffer = allocate_camera_metadata(newEntryCount,
+ newDataCount);
+ if (mBuffer == NULL) {
+ ALOGE("%s: Can't allocate larger metadata buffer", __FUNCTION__);
+ return NO_MEMORY;
+ }
+ append_camera_metadata(mBuffer, oldBuffer);
+ free_camera_metadata(oldBuffer);
+ }
+ }
+ return OK;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/CameraMetadata.h b/services/camera/libcameraservice/camera2/CameraMetadata.h
new file mode 100644
index 00000000..aee6cd78
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CameraMetadata.h
@@ -0,0 +1,173 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2METADATA_CPP
+#define ANDROID_SERVERS_CAMERA_CAMERA2METADATA_CPP
+
+#include "system/camera_metadata.h"
+#include <utils/String8.h>
+#include <utils/Vector.h>
+
+namespace android {
+namespace camera2 {
+
+/**
+ * A convenience wrapper around the C-based camera_metadata_t library.
+ */
+class CameraMetadata {
+ public:
+ /** Creates an empty object; best used when expecting to acquire contents
+ * from elsewhere */
+ CameraMetadata();
+ /** Creates an object with space for entryCapacity entries, with
+ * dataCapacity extra storage */
+ CameraMetadata(size_t entryCapacity, size_t dataCapacity = 10);
+
+ ~CameraMetadata();
+
+ /** Takes ownership of passed-in buffer */
+ CameraMetadata(camera_metadata_t *buffer);
+ /** Clones the metadata */
+ CameraMetadata(const CameraMetadata &other);
+
+ /**
+ * Assignment clones metadata buffer.
+ */
+ CameraMetadata &operator=(const CameraMetadata &other);
+ CameraMetadata &operator=(const camera_metadata_t *buffer);
+
+ /**
+ * Release a raw metadata buffer to the caller. After this call,
+ * CameraMetadata no longer references the buffer, and the caller takes
+ * responsibility for freeing the raw metadata buffer (using
+ * free_camera_metadata()), or for handing it to another CameraMetadata
+ * instance.
+ */
+ camera_metadata_t* release();
+
+ /**
+ * Clear the metadata buffer and free all storage used by it
+ */
+ void clear();
+
+ /**
+ * Acquire a raw metadata buffer from the caller. After this call,
+ * the caller no longer owns the raw buffer, and must not free or manipulate it.
+ * If CameraMetadata already contains metadata, it is freed.
+ */
+ void acquire(camera_metadata_t* buffer);
+
+ /**
+ * Acquires raw buffer from other CameraMetadata object. After the call, the argument
+ * object no longer has any metadata.
+ */
+ void acquire(CameraMetadata &other);
+
+ /**
+ * Append metadata from another CameraMetadata object.
+ */
+ status_t append(const CameraMetadata &other);
+
+ /**
+ * Number of metadata entries.
+ */
+ size_t entryCount() const;
+
+ /**
+ * Is the buffer empty (no entires)
+ */
+ bool isEmpty() const;
+
+ /**
+ * Sort metadata buffer for faster find
+ */
+ status_t sort();
+
+ /**
+ * Update metadata entry. Will create entry if it doesn't exist already, and
+ * will reallocate the buffer if insufficient space exists. Overloaded for
+ * the various types of valid data.
+ */
+ status_t update(uint32_t tag,
+ const uint8_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const int32_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const float *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const int64_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const double *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const camera_metadata_rational_t *data, size_t data_count);
+ status_t update(uint32_t tag,
+ const String8 &string);
+
+ template<typename T>
+ status_t update(uint32_t tag, Vector<T> data) {
+ return update(tag, data.array(), data.size());
+ }
+
+ /**
+ * Get metadata entry by tag id
+ */
+ camera_metadata_entry find(uint32_t tag);
+
+ /**
+ * Get metadata entry by tag id, with no editing
+ */
+ camera_metadata_ro_entry find(uint32_t tag) const;
+
+ /**
+ * Delete metadata entry by tag
+ */
+ status_t erase(uint32_t tag);
+
+ /**
+ * Dump contents into FD for debugging. The verbosity levels are
+ * 0: Tag entry information only, no data values
+ * 1: Level 0 plus at most 16 data values per entry
+ * 2: All information
+ *
+ * The indentation parameter sets the number of spaces to add to the start
+ * each line of output.
+ */
+ void dump(int fd, int verbosity = 1, int indentation = 0) const;
+
+ private:
+ camera_metadata_t *mBuffer;
+
+ /**
+ * Check if tag has a given type
+ */
+ status_t checkType(uint32_t tag, uint8_t expectedType);
+
+ /**
+ * Base update entry method
+ */
+ status_t update(uint32_t tag, const void *data, size_t data_count);
+
+ /**
+ * Resize metadata buffer if needed by reallocating it and copying it over.
+ */
+ status_t resizeIfNeeded(size_t extraEntries, size_t extraData);
+
+};
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.cpp b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
new file mode 100644
index 00000000..072453b0
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.cpp
@@ -0,0 +1,673 @@
+/*
+ * 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 "Camera2-CaptureSequencer"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <utils/Vector.h>
+
+#include "CaptureSequencer.h"
+#include "BurstCapture.h"
+#include "../Camera2Device.h"
+#include "../Camera2Client.h"
+#include "Parameters.h"
+
+namespace android {
+namespace camera2 {
+
+/** Public members */
+
+CaptureSequencer::CaptureSequencer(wp<Camera2Client> client):
+ Thread(false),
+ mStartCapture(false),
+ mBusy(false),
+ mNewAEState(false),
+ mNewFrameReceived(false),
+ mNewCaptureReceived(false),
+ mShutterNotified(false),
+ mClient(client),
+ mCaptureState(IDLE),
+ mTriggerId(0),
+ mTimeoutCount(0),
+ mCaptureId(Camera2Client::kCaptureRequestIdStart),
+ mMsgType(0) {
+ ALOGV("%s", __FUNCTION__);
+}
+
+CaptureSequencer::~CaptureSequencer() {
+ ALOGV("%s: Exit", __FUNCTION__);
+}
+
+void CaptureSequencer::setZslProcessor(wp<ZslProcessor> processor) {
+ Mutex::Autolock l(mInputMutex);
+ mZslProcessor = processor;
+}
+
+status_t CaptureSequencer::startCapture(int msgType) {
+ ALOGV("%s", __FUNCTION__);
+ ATRACE_CALL();
+ Mutex::Autolock l(mInputMutex);
+ if (mBusy) {
+ ALOGE("%s: Already busy capturing!", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+ if (!mStartCapture) {
+ mMsgType = msgType;
+ mStartCapture = true;
+ mStartCaptureSignal.signal();
+ }
+ return OK;
+}
+
+status_t CaptureSequencer::waitUntilIdle(nsecs_t timeout) {
+ ATRACE_CALL();
+ ALOGV("%s: Waiting for idle", __FUNCTION__);
+ Mutex::Autolock l(mStateMutex);
+ status_t res = -1;
+ while (mCaptureState != IDLE) {
+ nsecs_t startTime = systemTime();
+
+ res = mStateChanged.waitRelative(mStateMutex, timeout);
+ if (res != OK) return res;
+
+ timeout -= (systemTime() - startTime);
+ }
+ ALOGV("%s: Now idle", __FUNCTION__);
+ return OK;
+}
+
+void CaptureSequencer::notifyAutoExposure(uint8_t newState, int triggerId) {
+ ATRACE_CALL();
+ Mutex::Autolock l(mInputMutex);
+ mAEState = newState;
+ mAETriggerId = triggerId;
+ if (!mNewAEState) {
+ mNewAEState = true;
+ mNewNotifySignal.signal();
+ }
+}
+
+void CaptureSequencer::onFrameAvailable(int32_t frameId,
+ const CameraMetadata &frame) {
+ ALOGV("%s: Listener found new frame", __FUNCTION__);
+ ATRACE_CALL();
+ Mutex::Autolock l(mInputMutex);
+ mNewFrameId = frameId;
+ mNewFrame = frame;
+ if (!mNewFrameReceived) {
+ mNewFrameReceived = true;
+ mNewFrameSignal.signal();
+ }
+}
+
+void CaptureSequencer::onCaptureAvailable(nsecs_t timestamp,
+ sp<MemoryBase> captureBuffer) {
+ ATRACE_CALL();
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock l(mInputMutex);
+ mCaptureTimestamp = timestamp;
+ mCaptureBuffer = captureBuffer;
+ if (!mNewCaptureReceived) {
+ mNewCaptureReceived = true;
+ mNewCaptureSignal.signal();
+ }
+}
+
+
+void CaptureSequencer::dump(int fd, const Vector<String16>& args) {
+ String8 result;
+ if (mCaptureRequest.entryCount() != 0) {
+ result = " Capture request:\n";
+ write(fd, result.string(), result.size());
+ mCaptureRequest.dump(fd, 2, 6);
+ } else {
+ result = " Capture request: undefined\n";
+ write(fd, result.string(), result.size());
+ }
+ result = String8::format(" Current capture state: %s\n",
+ kStateNames[mCaptureState]);
+ result.append(" Latest captured frame:\n");
+ write(fd, result.string(), result.size());
+ mNewFrame.dump(fd, 2, 6);
+}
+
+/** Private members */
+
+const char* CaptureSequencer::kStateNames[CaptureSequencer::NUM_CAPTURE_STATES+1] =
+{
+ "IDLE",
+ "START",
+ "ZSL_START",
+ "ZSL_WAITING",
+ "ZSL_REPROCESSING",
+ "STANDARD_START",
+ "STANDARD_PRECAPTURE_WAIT",
+ "STANDARD_CAPTURE",
+ "STANDARD_CAPTURE_WAIT",
+ "BURST_CAPTURE_START",
+ "BURST_CAPTURE_WAIT",
+ "DONE",
+ "ERROR",
+ "UNKNOWN"
+};
+
+const CaptureSequencer::StateManager
+ CaptureSequencer::kStateManagers[CaptureSequencer::NUM_CAPTURE_STATES-1] = {
+ &CaptureSequencer::manageIdle,
+ &CaptureSequencer::manageStart,
+ &CaptureSequencer::manageZslStart,
+ &CaptureSequencer::manageZslWaiting,
+ &CaptureSequencer::manageZslReprocessing,
+ &CaptureSequencer::manageStandardStart,
+ &CaptureSequencer::manageStandardPrecaptureWait,
+ &CaptureSequencer::manageStandardCapture,
+ &CaptureSequencer::manageStandardCaptureWait,
+ &CaptureSequencer::manageBurstCaptureStart,
+ &CaptureSequencer::manageBurstCaptureWait,
+ &CaptureSequencer::manageDone,
+};
+
+bool CaptureSequencer::threadLoop() {
+ status_t res;
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+
+ CaptureState currentState;
+ {
+ Mutex::Autolock l(mStateMutex);
+ currentState = mCaptureState;
+ }
+
+ currentState = (this->*kStateManagers[currentState])(client);
+
+ Mutex::Autolock l(mStateMutex);
+ if (currentState != mCaptureState) {
+ mCaptureState = currentState;
+ ATRACE_INT("cam2_capt_state", mCaptureState);
+ ALOGV("Camera %d: New capture state %s",
+ client->getCameraId(), kStateNames[mCaptureState]);
+ mStateChanged.signal();
+ }
+
+ if (mCaptureState == ERROR) {
+ ALOGE("Camera %d: Stopping capture sequencer due to error",
+ client->getCameraId());
+ return false;
+ }
+
+ return true;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageIdle(sp<Camera2Client> &client) {
+ status_t res;
+ Mutex::Autolock l(mInputMutex);
+ while (!mStartCapture) {
+ res = mStartCaptureSignal.waitRelative(mInputMutex,
+ kWaitDuration);
+ if (res == TIMED_OUT) break;
+ }
+ if (mStartCapture) {
+ mStartCapture = false;
+ mBusy = true;
+ return START;
+ }
+ return IDLE;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageDone(sp<Camera2Client> &client) {
+ status_t res = OK;
+ ATRACE_CALL();
+ mCaptureId++;
+ if (mCaptureId >= Camera2Client::kCaptureRequestIdEnd) {
+ mCaptureId = Camera2Client::kCaptureRequestIdStart;
+ }
+ {
+ Mutex::Autolock l(mInputMutex);
+ mBusy = false;
+ }
+
+ {
+ SharedParameters::Lock l(client->getParameters());
+ switch (l.mParameters.state) {
+ case Parameters::DISCONNECTED:
+ ALOGW("%s: Camera %d: Discarding image data during shutdown ",
+ __FUNCTION__, client->getCameraId());
+ res = INVALID_OPERATION;
+ break;
+ case Parameters::STILL_CAPTURE:
+ l.mParameters.state = Parameters::STOPPED;
+ break;
+ case Parameters::VIDEO_SNAPSHOT:
+ l.mParameters.state = Parameters::RECORD;
+ break;
+ default:
+ ALOGE("%s: Camera %d: Still image produced unexpectedly "
+ "in state %s!",
+ __FUNCTION__, client->getCameraId(),
+ Parameters::getStateName(l.mParameters.state));
+ res = INVALID_OPERATION;
+ }
+ }
+ sp<ZslProcessor> processor = mZslProcessor.promote();
+ if (processor != 0) {
+ processor->clearZslQueue();
+ }
+
+ if (mCaptureBuffer != 0 && res == OK) {
+ Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ ALOGV("%s: Sending still image to client", __FUNCTION__);
+ if (l.mCameraClient != 0) {
+ l.mCameraClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE,
+ mCaptureBuffer, NULL);
+ } else {
+ ALOGV("%s: No client!", __FUNCTION__);
+ }
+ }
+ mCaptureBuffer.clear();
+
+ return IDLE;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageStart(
+ sp<Camera2Client> &client) {
+ ALOGV("%s", __FUNCTION__);
+ status_t res;
+ ATRACE_CALL();
+ SharedParameters::Lock l(client->getParameters());
+ CaptureState nextState = DONE;
+
+ res = updateCaptureRequest(l.mParameters, client);
+ if (res != OK ) {
+ ALOGE("%s: Camera %d: Can't update still image capture request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return DONE;
+ }
+
+ if(l.mParameters.lightFx != Parameters::LIGHTFX_NONE &&
+ l.mParameters.state == Parameters::STILL_CAPTURE) {
+ nextState = BURST_CAPTURE_START;
+ }
+ else if (l.mParameters.zslMode &&
+ l.mParameters.state == Parameters::STILL_CAPTURE &&
+ l.mParameters.flashMode != Parameters::FLASH_MODE_ON) {
+ nextState = ZSL_START;
+ } else {
+ nextState = STANDARD_START;
+ }
+ mShutterNotified = false;
+
+ return nextState;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageZslStart(
+ sp<Camera2Client> &client) {
+ ALOGV("%s", __FUNCTION__);
+ status_t res;
+ sp<ZslProcessor> processor = mZslProcessor.promote();
+ if (processor == 0) {
+ ALOGE("%s: No ZSL queue to use!", __FUNCTION__);
+ return DONE;
+ }
+
+ client->registerFrameListener(mCaptureId, mCaptureId + 1,
+ this);
+
+ // TODO: Actually select the right thing here.
+ res = processor->pushToReprocess(mCaptureId);
+ if (res != OK) {
+ if (res == NOT_ENOUGH_DATA) {
+ ALOGV("%s: Camera %d: ZSL queue doesn't have good frame, "
+ "falling back to normal capture", __FUNCTION__,
+ client->getCameraId());
+ } else {
+ ALOGE("%s: Camera %d: Error in ZSL queue: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ }
+ return STANDARD_START;
+ }
+
+ SharedParameters::Lock l(client->getParameters());
+ /* warning: this also locks a SharedCameraClient */
+ shutterNotifyLocked(l.mParameters, client, mMsgType);
+ mShutterNotified = true;
+ mTimeoutCount = kMaxTimeoutsForCaptureEnd;
+ return STANDARD_CAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageZslWaiting(
+ sp<Camera2Client> &client) {
+ ALOGV("%s", __FUNCTION__);
+ return DONE;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageZslReprocessing(
+ sp<Camera2Client> &client) {
+ ALOGV("%s", __FUNCTION__);
+ return START;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageStandardStart(
+ sp<Camera2Client> &client) {
+ ATRACE_CALL();
+ client->registerFrameListener(mCaptureId, mCaptureId + 1,
+ this);
+ {
+ SharedParameters::Lock l(client->getParameters());
+ mTriggerId = l.mParameters.precaptureTriggerCounter++;
+ }
+ client->getCameraDevice()->triggerPrecaptureMetering(mTriggerId);
+
+ mAeInPrecapture = false;
+ mTimeoutCount = kMaxTimeoutsForPrecaptureStart;
+ return STANDARD_PRECAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageStandardPrecaptureWait(
+ sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+ Mutex::Autolock l(mInputMutex);
+ while (!mNewAEState) {
+ res = mNewNotifySignal.waitRelative(mInputMutex, kWaitDuration);
+ if (res == TIMED_OUT) {
+ mTimeoutCount--;
+ break;
+ }
+ }
+ if (mTimeoutCount <= 0) {
+ ALOGW("Timed out waiting for precapture %s",
+ mAeInPrecapture ? "end" : "start");
+ return STANDARD_CAPTURE;
+ }
+ if (mNewAEState) {
+ if (!mAeInPrecapture) {
+ // Waiting to see PRECAPTURE state
+ if (mAETriggerId == mTriggerId &&
+ mAEState == ANDROID_CONTROL_AE_STATE_PRECAPTURE) {
+ ALOGV("%s: Got precapture start", __FUNCTION__);
+ mAeInPrecapture = true;
+ mTimeoutCount = kMaxTimeoutsForPrecaptureEnd;
+ }
+ } else {
+ // Waiting to see PRECAPTURE state end
+ if (mAETriggerId == mTriggerId &&
+ mAEState != ANDROID_CONTROL_AE_STATE_PRECAPTURE) {
+ ALOGV("%s: Got precapture end", __FUNCTION__);
+ return STANDARD_CAPTURE;
+ }
+ }
+ mNewAEState = false;
+ }
+ return STANDARD_PRECAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageStandardCapture(
+ sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+ SharedParameters::Lock l(client->getParameters());
+ Vector<uint8_t> outputStreams;
+
+ outputStreams.push(client->getPreviewStreamId());
+ outputStreams.push(client->getCaptureStreamId());
+
+ if (l.mParameters.previewCallbackFlags &
+ CAMERA_FRAME_CALLBACK_FLAG_ENABLE_MASK) {
+ outputStreams.push(client->getCallbackStreamId());
+ }
+
+ if (l.mParameters.state == Parameters::VIDEO_SNAPSHOT) {
+ outputStreams.push(client->getRecordingStreamId());
+ }
+
+ res = mCaptureRequest.update(ANDROID_REQUEST_OUTPUT_STREAMS,
+ outputStreams);
+ if (res == OK) {
+ res = mCaptureRequest.update(ANDROID_REQUEST_ID,
+ &mCaptureId, 1);
+ }
+ if (res == OK) {
+ res = mCaptureRequest.sort();
+ }
+
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set up still capture request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return DONE;
+ }
+
+ CameraMetadata captureCopy = mCaptureRequest;
+ if (captureCopy.entryCount() == 0) {
+ ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
+ __FUNCTION__, client->getCameraId());
+ return DONE;
+ }
+
+ if (l.mParameters.state == Parameters::STILL_CAPTURE) {
+ res = client->stopStream();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to stop preview for still capture: "
+ "%s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return DONE;
+ }
+ }
+ // TODO: Capture should be atomic with setStreamingRequest here
+ res = client->getCameraDevice()->capture(captureCopy);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to submit still image capture request: "
+ "%s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return DONE;
+ }
+
+ mTimeoutCount = kMaxTimeoutsForCaptureEnd;
+ return STANDARD_CAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageStandardCaptureWait(
+ sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+ Mutex::Autolock l(mInputMutex);
+ while (!mNewFrameReceived) {
+ res = mNewFrameSignal.waitRelative(mInputMutex, kWaitDuration);
+ if (res == TIMED_OUT) {
+ mTimeoutCount--;
+ break;
+ }
+ }
+ if (mNewFrameReceived && !mShutterNotified) {
+ SharedParameters::Lock l(client->getParameters());
+ /* warning: this also locks a SharedCameraClient */
+ shutterNotifyLocked(l.mParameters, client, mMsgType);
+ mShutterNotified = true;
+ }
+ while (mNewFrameReceived && !mNewCaptureReceived) {
+ res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
+ if (res == TIMED_OUT) {
+ mTimeoutCount--;
+ break;
+ }
+ }
+ if (mTimeoutCount <= 0) {
+ ALOGW("Timed out waiting for capture to complete");
+ return DONE;
+ }
+ if (mNewFrameReceived && mNewCaptureReceived) {
+ if (mNewFrameId != mCaptureId) {
+ ALOGW("Mismatched capture frame IDs: Expected %d, got %d",
+ mCaptureId, mNewFrameId);
+ }
+ camera_metadata_entry_t entry;
+ entry = mNewFrame.find(ANDROID_SENSOR_TIMESTAMP);
+ if (entry.count == 0) {
+ ALOGE("No timestamp field in capture frame!");
+ }
+ if (entry.data.i64[0] != mCaptureTimestamp) {
+ ALOGW("Mismatched capture timestamps: Metadata frame %lld,"
+ " captured buffer %lld", entry.data.i64[0], mCaptureTimestamp);
+ }
+ client->removeFrameListener(mCaptureId, mCaptureId + 1, this);
+
+ mNewFrameReceived = false;
+ mNewCaptureReceived = false;
+ return DONE;
+ }
+ return STANDARD_CAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureStart(
+ sp<Camera2Client> &client) {
+ ALOGV("%s", __FUNCTION__);
+ status_t res;
+ ATRACE_CALL();
+
+ // check which burst mode is set, create respective burst object
+ {
+ SharedParameters::Lock l(client->getParameters());
+
+ res = updateCaptureRequest(l.mParameters, client);
+ if(res != OK) {
+ return DONE;
+ }
+
+ //
+ // check for burst mode type in mParameters here
+ //
+ mBurstCapture = new BurstCapture(client, this);
+ }
+
+ res = mCaptureRequest.update(ANDROID_REQUEST_ID, &mCaptureId, 1);
+ if (res == OK) {
+ res = mCaptureRequest.sort();
+ }
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set up still capture request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return DONE;
+ }
+
+ CameraMetadata captureCopy = mCaptureRequest;
+ if (captureCopy.entryCount() == 0) {
+ ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
+ __FUNCTION__, client->getCameraId());
+ return DONE;
+ }
+
+ Vector<CameraMetadata> requests;
+ requests.push(mCaptureRequest);
+ res = mBurstCapture->start(requests, mCaptureId);
+ mTimeoutCount = kMaxTimeoutsForCaptureEnd * 10;
+ return BURST_CAPTURE_WAIT;
+}
+
+CaptureSequencer::CaptureState CaptureSequencer::manageBurstCaptureWait(
+ sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+
+ while (!mNewCaptureReceived) {
+ res = mNewCaptureSignal.waitRelative(mInputMutex, kWaitDuration);
+ if (res == TIMED_OUT) {
+ mTimeoutCount--;
+ break;
+ }
+ }
+
+ if (mTimeoutCount <= 0) {
+ ALOGW("Timed out waiting for burst capture to complete");
+ return DONE;
+ }
+ if (mNewCaptureReceived) {
+ mNewCaptureReceived = false;
+ // TODO: update mCaptureId to last burst's capture ID + 1?
+ return DONE;
+ }
+
+ return BURST_CAPTURE_WAIT;
+}
+
+status_t CaptureSequencer::updateCaptureRequest(const Parameters &params,
+ sp<Camera2Client> &client) {
+ ATRACE_CALL();
+ status_t res;
+ if (mCaptureRequest.entryCount() == 0) {
+ res = client->getCameraDevice()->createDefaultRequest(
+ CAMERA2_TEMPLATE_STILL_CAPTURE,
+ &mCaptureRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create default still image request:"
+ " %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ }
+
+ res = params.updateRequest(&mCaptureRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update common entries of capture "
+ "request: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+
+ res = params.updateRequestJpeg(&mCaptureRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update JPEG entries of capture "
+ "request: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+
+ return OK;
+}
+
+/*static*/ void CaptureSequencer::shutterNotifyLocked(const Parameters &params,
+ sp<Camera2Client> client, int msgType) {
+ ATRACE_CALL();
+
+ if (params.state == Parameters::STILL_CAPTURE
+ && params.playShutterSound
+ && (msgType & CAMERA_MSG_SHUTTER)) {
+ client->getCameraService()->playSound(CameraService::SOUND_SHUTTER);
+ }
+
+ {
+ Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+
+ ALOGV("%s: Notifying of shutter close to client", __FUNCTION__);
+ if (l.mCameraClient != 0) {
+ // ShutterCallback
+ l.mCameraClient->notifyCallback(CAMERA_MSG_SHUTTER,
+ /*ext1*/0, /*ext2*/0);
+
+ // RawCallback with null buffer
+ l.mCameraClient->notifyCallback(CAMERA_MSG_RAW_IMAGE_NOTIFY,
+ /*ext1*/0, /*ext2*/0);
+ } else {
+ ALOGV("%s: No client!", __FUNCTION__);
+ }
+ }
+}
+
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/CaptureSequencer.h b/services/camera/libcameraservice/camera2/CaptureSequencer.h
new file mode 100644
index 00000000..c42df053
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/CaptureSequencer.h
@@ -0,0 +1,177 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2_CAPTURESEQUENCER_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_CAPTURESEQUENCER_H
+
+#include <binder/MemoryBase.h>
+#include <utils/Thread.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/Mutex.h>
+#include <utils/Condition.h>
+#include "CameraMetadata.h"
+#include "Parameters.h"
+#include "FrameProcessor.h"
+
+namespace android {
+
+class Camera2Client;
+
+namespace camera2 {
+
+class ZslProcessor;
+class BurstCapture;
+
+/**
+ * Manages the still image capture process for
+ * zero-shutter-lag, regular, and video snapshots.
+ */
+class CaptureSequencer:
+ virtual public Thread,
+ virtual public FrameProcessor::FilteredListener {
+ public:
+ CaptureSequencer(wp<Camera2Client> client);
+ ~CaptureSequencer();
+
+ // Get reference to the ZslProcessor, which holds the ZSL buffers and frames
+ void setZslProcessor(wp<ZslProcessor> processor);
+
+ // Begin still image capture
+ status_t startCapture(int msgType);
+
+ // Wait until current image capture completes; returns immediately if no
+ // capture is active. Returns TIMED_OUT if capture does not complete during
+ // the specified duration.
+ status_t waitUntilIdle(nsecs_t timeout);
+
+ // Notifications about AE state changes
+ void notifyAutoExposure(uint8_t newState, int triggerId);
+
+ // Notifications from the frame processor
+ virtual void onFrameAvailable(int32_t frameId, const CameraMetadata &frame);
+
+ // Notifications from the JPEG processor
+ void onCaptureAvailable(nsecs_t timestamp, sp<MemoryBase> captureBuffer);
+
+ void dump(int fd, const Vector<String16>& args);
+
+ private:
+ /**
+ * Accessed by other threads
+ */
+ Mutex mInputMutex;
+
+ bool mStartCapture;
+ bool mBusy;
+ Condition mStartCaptureSignal;
+
+ bool mNewAEState;
+ uint8_t mAEState;
+ int mAETriggerId;
+ Condition mNewNotifySignal;
+
+ bool mNewFrameReceived;
+ int32_t mNewFrameId;
+ CameraMetadata mNewFrame;
+ Condition mNewFrameSignal;
+
+ bool mNewCaptureReceived;
+ nsecs_t mCaptureTimestamp;
+ sp<MemoryBase> mCaptureBuffer;
+ Condition mNewCaptureSignal;
+
+ bool mShutterNotified;
+
+ /**
+ * Internal to CaptureSequencer
+ */
+ static const nsecs_t kWaitDuration = 100000000; // 100 ms
+ static const int kMaxTimeoutsForPrecaptureStart = 2; // 200 ms
+ static const int kMaxTimeoutsForPrecaptureEnd = 20; // 2 sec
+ static const int kMaxTimeoutsForCaptureEnd = 40; // 4 sec
+
+ wp<Camera2Client> mClient;
+ wp<ZslProcessor> mZslProcessor;
+ sp<BurstCapture> mBurstCapture;
+
+ enum CaptureState {
+ IDLE,
+ START,
+ ZSL_START,
+ ZSL_WAITING,
+ ZSL_REPROCESSING,
+ STANDARD_START,
+ STANDARD_PRECAPTURE_WAIT,
+ STANDARD_CAPTURE,
+ STANDARD_CAPTURE_WAIT,
+ BURST_CAPTURE_START,
+ BURST_CAPTURE_WAIT,
+ DONE,
+ ERROR,
+ NUM_CAPTURE_STATES
+ } mCaptureState;
+ static const char* kStateNames[];
+ Mutex mStateMutex; // Guards mCaptureState
+ Condition mStateChanged;
+
+ typedef CaptureState (CaptureSequencer::*StateManager)(sp<Camera2Client> &client);
+ static const StateManager kStateManagers[];
+
+ CameraMetadata mCaptureRequest;
+
+ int mTriggerId;
+ int mTimeoutCount;
+ bool mAeInPrecapture;
+
+ int32_t mCaptureId;
+ int mMsgType;
+
+ // Main internal methods
+
+ virtual bool threadLoop();
+
+ CaptureState manageIdle(sp<Camera2Client> &client);
+ CaptureState manageStart(sp<Camera2Client> &client);
+
+ CaptureState manageZslStart(sp<Camera2Client> &client);
+ CaptureState manageZslWaiting(sp<Camera2Client> &client);
+ CaptureState manageZslReprocessing(sp<Camera2Client> &client);
+
+ CaptureState manageStandardStart(sp<Camera2Client> &client);
+ CaptureState manageStandardPrecaptureWait(sp<Camera2Client> &client);
+ CaptureState manageStandardCapture(sp<Camera2Client> &client);
+ CaptureState manageStandardCaptureWait(sp<Camera2Client> &client);
+
+ CaptureState manageBurstCaptureStart(sp<Camera2Client> &client);
+ CaptureState manageBurstCaptureWait(sp<Camera2Client> &client);
+
+ CaptureState manageDone(sp<Camera2Client> &client);
+
+ // Utility methods
+
+ status_t updateCaptureRequest(const Parameters &params,
+ sp<Camera2Client> &client);
+
+ // Emit Shutter/Raw callback to java, and maybe play a shutter sound
+ static void shutterNotifyLocked(const Parameters &params,
+ sp<Camera2Client> client, int msgType);
+};
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.cpp b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
new file mode 100644
index 00000000..76e84ccd
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.cpp
@@ -0,0 +1,308 @@
+/*
+ * 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 "Camera2-FrameProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include "FrameProcessor.h"
+#include "../Camera2Device.h"
+#include "../Camera2Client.h"
+
+namespace android {
+namespace camera2 {
+
+FrameProcessor::FrameProcessor(wp<Camera2Client> client):
+ Thread(false), mClient(client), mLastFrameNumberOfFaces(0) {
+}
+
+FrameProcessor::~FrameProcessor() {
+ ALOGV("%s: Exit", __FUNCTION__);
+}
+
+status_t FrameProcessor::registerListener(int32_t minId,
+ int32_t maxId, wp<FilteredListener> listener) {
+ Mutex::Autolock l(mInputMutex);
+ ALOGV("%s: Registering listener for frame id range %d - %d",
+ __FUNCTION__, minId, maxId);
+ RangeListener rListener = { minId, maxId, listener };
+ mRangeListeners.push_back(rListener);
+ return OK;
+}
+
+status_t FrameProcessor::removeListener(int32_t minId,
+ int32_t maxId, wp<FilteredListener> listener) {
+ Mutex::Autolock l(mInputMutex);
+ List<RangeListener>::iterator item = mRangeListeners.begin();
+ while (item != mRangeListeners.end()) {
+ if (item->minId == minId &&
+ item->maxId == maxId &&
+ item->listener == listener) {
+ item = mRangeListeners.erase(item);
+ } else {
+ item++;
+ }
+ }
+ return OK;
+}
+
+void FrameProcessor::dump(int fd, const Vector<String16>& args) {
+ String8 result(" Latest received frame:\n");
+ write(fd, result.string(), result.size());
+ mLastFrame.dump(fd, 2, 6);
+}
+
+bool FrameProcessor::threadLoop() {
+ status_t res;
+
+ sp<Camera2Device> device;
+ {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+ device = client->getCameraDevice();
+ if (device == 0) return false;
+ }
+
+ res = device->waitForNextFrame(kWaitDuration);
+ if (res == OK) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+ processNewFrames(client);
+ } else if (res != TIMED_OUT) {
+ ALOGE("Camera2Client::FrameProcessor: Error waiting for new "
+ "frames: %s (%d)", strerror(-res), res);
+ }
+
+ return true;
+}
+
+void FrameProcessor::processNewFrames(sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+ CameraMetadata frame;
+ while ( (res = client->getCameraDevice()->getNextFrame(&frame)) == OK) {
+ camera_metadata_entry_t entry;
+
+ entry = frame.find(ANDROID_REQUEST_FRAME_COUNT);
+ if (entry.count == 0) {
+ ALOGE("%s: Camera %d: Error reading frame number",
+ __FUNCTION__, client->getCameraId());
+ break;
+ }
+ ATRACE_INT("cam2_frame", entry.data.i32[0]);
+
+ res = processFaceDetect(frame, client);
+ if (res != OK) break;
+
+ res = processListeners(frame, client);
+ if (res != OK) break;
+
+ if (!frame.isEmpty()) {
+ mLastFrame.acquire(frame);
+ }
+ }
+ if (res != NOT_ENOUGH_DATA) {
+ ALOGE("%s: Camera %d: Error getting next frame: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return;
+ }
+
+ return;
+}
+
+status_t FrameProcessor::processListeners(const CameraMetadata &frame,
+ sp<Camera2Client> &client) {
+ status_t res;
+ ATRACE_CALL();
+ camera_metadata_ro_entry_t entry;
+
+ entry = frame.find(ANDROID_REQUEST_ID);
+ if (entry.count == 0) {
+ ALOGE("%s: Camera %d: Error reading frame id",
+ __FUNCTION__, client->getCameraId());
+ return BAD_VALUE;
+ }
+ int32_t frameId = entry.data.i32[0];
+
+ List<sp<FilteredListener> > listeners;
+ {
+ Mutex::Autolock l(mInputMutex);
+
+ List<RangeListener>::iterator item = mRangeListeners.begin();
+ while (item != mRangeListeners.end()) {
+ if (frameId >= item->minId &&
+ frameId < item->maxId) {
+ sp<FilteredListener> listener = item->listener.promote();
+ if (listener == 0) {
+ item = mRangeListeners.erase(item);
+ continue;
+ } else {
+ listeners.push_back(listener);
+ }
+ }
+ item++;
+ }
+ }
+ ALOGV("Got %d range listeners out of %d", listeners.size(), mRangeListeners.size());
+ List<sp<FilteredListener> >::iterator item = listeners.begin();
+ for (; item != listeners.end(); item++) {
+ (*item)->onFrameAvailable(frameId, frame);
+ }
+ return OK;
+}
+
+status_t FrameProcessor::processFaceDetect(const CameraMetadata &frame,
+ sp<Camera2Client> &client) {
+ status_t res = BAD_VALUE;
+ ATRACE_CALL();
+ camera_metadata_ro_entry_t entry;
+ bool enableFaceDetect;
+ int maxFaces;
+ {
+ SharedParameters::Lock l(client->getParameters());
+ enableFaceDetect = l.mParameters.enableFaceDetect;
+ }
+ entry = frame.find(ANDROID_STATISTICS_FACE_DETECT_MODE);
+
+ // TODO: This should be an error once implementations are compliant
+ if (entry.count == 0) {
+ return OK;
+ }
+
+ uint8_t faceDetectMode = entry.data.u8[0];
+
+ camera_frame_metadata metadata;
+ Vector<camera_face_t> faces;
+ metadata.number_of_faces = 0;
+
+ if (enableFaceDetect && faceDetectMode != ANDROID_STATISTICS_FACE_DETECT_MODE_OFF) {
+ SharedParameters::Lock l(client->getParameters());
+ entry = frame.find(ANDROID_STATISTICS_FACE_RECTANGLES);
+ if (entry.count == 0) {
+ // No faces this frame
+ /* warning: locks SharedCameraClient */
+ callbackFaceDetection(client, metadata);
+ return OK;
+ }
+ metadata.number_of_faces = entry.count / 4;
+ if (metadata.number_of_faces >
+ l.mParameters.fastInfo.maxFaces) {
+ ALOGE("%s: Camera %d: More faces than expected! (Got %d, max %d)",
+ __FUNCTION__, client->getCameraId(),
+ metadata.number_of_faces, l.mParameters.fastInfo.maxFaces);
+ return res;
+ }
+ const int32_t *faceRects = entry.data.i32;
+
+ entry = frame.find(ANDROID_STATISTICS_FACE_SCORES);
+ if (entry.count == 0) {
+ ALOGE("%s: Camera %d: Unable to read face scores",
+ __FUNCTION__, client->getCameraId());
+ return res;
+ }
+ const uint8_t *faceScores = entry.data.u8;
+
+ const int32_t *faceLandmarks = NULL;
+ const int32_t *faceIds = NULL;
+
+ if (faceDetectMode == ANDROID_STATISTICS_FACE_DETECT_MODE_FULL) {
+ entry = frame.find(ANDROID_STATISTICS_FACE_LANDMARKS);
+ if (entry.count == 0) {
+ ALOGE("%s: Camera %d: Unable to read face landmarks",
+ __FUNCTION__, client->getCameraId());
+ return res;
+ }
+ faceLandmarks = entry.data.i32;
+
+ entry = frame.find(ANDROID_STATISTICS_FACE_IDS);
+
+ if (entry.count == 0) {
+ ALOGE("%s: Camera %d: Unable to read face IDs",
+ __FUNCTION__, client->getCameraId());
+ return res;
+ }
+ faceIds = entry.data.i32;
+ }
+
+ faces.setCapacity(metadata.number_of_faces);
+
+ size_t maxFaces = metadata.number_of_faces;
+ for (size_t i = 0; i < maxFaces; i++) {
+ if (faceScores[i] == 0) {
+ metadata.number_of_faces--;
+ continue;
+ }
+
+ camera_face_t face;
+
+ face.rect[0] = l.mParameters.arrayXToNormalized(faceRects[i*4 + 0]);
+ face.rect[1] = l.mParameters.arrayYToNormalized(faceRects[i*4 + 1]);
+ face.rect[2] = l.mParameters.arrayXToNormalized(faceRects[i*4 + 2]);
+ face.rect[3] = l.mParameters.arrayYToNormalized(faceRects[i*4 + 3]);
+
+ face.score = faceScores[i];
+ if (faceDetectMode == ANDROID_STATISTICS_FACE_DETECT_MODE_FULL) {
+ face.id = faceIds[i];
+ face.left_eye[0] =
+ l.mParameters.arrayXToNormalized(faceLandmarks[i*6 + 0]);
+ face.left_eye[1] =
+ l.mParameters.arrayYToNormalized(faceLandmarks[i*6 + 1]);
+ face.right_eye[0] =
+ l.mParameters.arrayXToNormalized(faceLandmarks[i*6 + 2]);
+ face.right_eye[1] =
+ l.mParameters.arrayYToNormalized(faceLandmarks[i*6 + 3]);
+ face.mouth[0] =
+ l.mParameters.arrayXToNormalized(faceLandmarks[i*6 + 4]);
+ face.mouth[1] =
+ l.mParameters.arrayYToNormalized(faceLandmarks[i*6 + 5]);
+ } else {
+ face.id = 0;
+ face.left_eye[0] = face.left_eye[1] = -2000;
+ face.right_eye[0] = face.right_eye[1] = -2000;
+ face.mouth[0] = face.mouth[1] = -2000;
+ }
+ faces.push_back(face);
+ }
+
+ metadata.faces = faces.editArray();
+ }
+
+ /* warning: locks SharedCameraClient */
+ callbackFaceDetection(client, metadata);
+
+ return OK;
+}
+
+void FrameProcessor::callbackFaceDetection(sp<Camera2Client> client,
+ /*in*/camera_frame_metadata &metadata) {
+
+ /* Filter out repeated 0-face callbacks, but not when the last frame was >0 */
+ if (metadata.number_of_faces != 0 || mLastFrameNumberOfFaces != metadata.number_of_faces) {
+ Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ if (l.mCameraClient != NULL) {
+ l.mCameraClient->dataCallback(CAMERA_MSG_PREVIEW_METADATA,
+ NULL, &metadata);
+ }
+ }
+
+ mLastFrameNumberOfFaces = metadata.number_of_faces;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/FrameProcessor.h b/services/camera/libcameraservice/camera2/FrameProcessor.h
new file mode 100644
index 00000000..3bd4e257
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/FrameProcessor.h
@@ -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.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_FRAMEPROCESSOR_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_FRAMEPROCESSOR_H
+
+#include <utils/Thread.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/KeyedVector.h>
+#include <utils/List.h>
+#include "CameraMetadata.h"
+
+struct camera_frame_metadata;
+
+namespace android {
+
+class Camera2Client;
+
+namespace camera2 {
+
+/* Output frame metadata processing thread. This thread waits for new
+ * frames from the device, and analyzes them as necessary.
+ */
+class FrameProcessor: public Thread {
+ public:
+ FrameProcessor(wp<Camera2Client> client);
+ ~FrameProcessor();
+
+ struct FilteredListener: virtual public RefBase {
+ virtual void onFrameAvailable(int32_t frameId,
+ const CameraMetadata &frame) = 0;
+ };
+
+ // Register a listener for a range of IDs [minId, maxId). Multiple listeners
+ // can be listening to the same range
+ status_t registerListener(int32_t minId, int32_t maxId, wp<FilteredListener> listener);
+ status_t removeListener(int32_t minId, int32_t maxId, wp<FilteredListener> listener);
+
+ void dump(int fd, const Vector<String16>& args);
+ private:
+ static const nsecs_t kWaitDuration = 10000000; // 10 ms
+ wp<Camera2Client> mClient;
+
+ virtual bool threadLoop();
+
+ Mutex mInputMutex;
+
+ struct RangeListener {
+ int32_t minId;
+ int32_t maxId;
+ wp<FilteredListener> listener;
+ };
+ List<RangeListener> mRangeListeners;
+
+ void processNewFrames(sp<Camera2Client> &client);
+
+ status_t processFaceDetect(const CameraMetadata &frame,
+ sp<Camera2Client> &client);
+
+ status_t processListeners(const CameraMetadata &frame,
+ sp<Camera2Client> &client);
+
+ CameraMetadata mLastFrame;
+ int mLastFrameNumberOfFaces;
+
+ // Emit FaceDetection event to java if faces changed
+ void callbackFaceDetection(sp<Camera2Client> client,
+ camera_frame_metadata &metadata);
+};
+
+
+}; //namespace camera2
+}; //namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/JpegCompressor.cpp b/services/camera/libcameraservice/camera2/JpegCompressor.cpp
new file mode 100644
index 00000000..702ef58b
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/JpegCompressor.cpp
@@ -0,0 +1,220 @@
+/*
+ * 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 "Camera2-JpegCompressor"
+
+#include <utils/Log.h>
+#include <ui/GraphicBufferMapper.h>
+
+#include "JpegCompressor.h"
+
+namespace android {
+namespace camera2 {
+
+JpegCompressor::JpegCompressor():
+ Thread(false),
+ mIsBusy(false),
+ mCaptureTime(0) {
+}
+
+JpegCompressor::~JpegCompressor() {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock lock(mMutex);
+}
+
+status_t JpegCompressor::start(Vector<CpuConsumer::LockedBuffer*> buffers,
+ nsecs_t captureTime) {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock busyLock(mBusyMutex);
+
+ if (mIsBusy) {
+ ALOGE("%s: Already processing a buffer!", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ mIsBusy = true;
+
+ mBuffers = buffers;
+ mCaptureTime = captureTime;
+
+ status_t res;
+ res = run("JpegCompressor");
+ if (res != OK) {
+ ALOGE("%s: Unable to start up compression thread: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ //delete mBuffers; // necessary?
+ }
+ return res;
+}
+
+status_t JpegCompressor::cancel() {
+ ALOGV("%s", __FUNCTION__);
+ requestExitAndWait();
+ return OK;
+}
+
+status_t JpegCompressor::readyToRun() {
+ ALOGV("%s", __FUNCTION__);
+ return OK;
+}
+
+bool JpegCompressor::threadLoop() {
+ ALOGV("%s", __FUNCTION__);
+
+ mAuxBuffer = mBuffers[0]; // input
+ mJpegBuffer = mBuffers[1]; // output
+
+ // Set up error management
+ mJpegErrorInfo = NULL;
+ JpegError error;
+ error.parent = this;
+
+ mCInfo.err = jpeg_std_error(&error);
+ mCInfo.err->error_exit = jpegErrorHandler;
+
+ jpeg_create_compress(&mCInfo);
+ if (checkError("Error initializing compression")) return false;
+
+ // Route compressed data straight to output stream buffer
+ JpegDestination jpegDestMgr;
+ jpegDestMgr.parent = this;
+ jpegDestMgr.init_destination = jpegInitDestination;
+ jpegDestMgr.empty_output_buffer = jpegEmptyOutputBuffer;
+ jpegDestMgr.term_destination = jpegTermDestination;
+
+ mCInfo.dest = &jpegDestMgr;
+
+ // Set up compression parameters
+ mCInfo.image_width = mAuxBuffer->width;
+ mCInfo.image_height = mAuxBuffer->height;
+ mCInfo.input_components = 1; // 3;
+ mCInfo.in_color_space = JCS_GRAYSCALE; // JCS_RGB
+
+ ALOGV("%s: image_width = %d, image_height = %d", __FUNCTION__, mCInfo.image_width, mCInfo.image_height);
+
+ jpeg_set_defaults(&mCInfo);
+ if (checkError("Error configuring defaults")) return false;
+
+ // Do compression
+ jpeg_start_compress(&mCInfo, TRUE);
+ if (checkError("Error starting compression")) return false;
+
+ size_t rowStride = mAuxBuffer->stride;// * 3;
+ const size_t kChunkSize = 32;
+ while (mCInfo.next_scanline < mCInfo.image_height) {
+ JSAMPROW chunk[kChunkSize];
+ for (size_t i = 0 ; i < kChunkSize; i++) {
+ chunk[i] = (JSAMPROW)
+ (mAuxBuffer->data + (i + mCInfo.next_scanline) * rowStride);
+ }
+ jpeg_write_scanlines(&mCInfo, chunk, kChunkSize);
+ if (checkError("Error while compressing")) return false;
+ if (exitPending()) {
+ ALOGV("%s: Cancel called, exiting early", __FUNCTION__);
+ cleanUp();
+ return false;
+ }
+ }
+
+ jpeg_finish_compress(&mCInfo);
+ if (checkError("Error while finishing compression")) return false;
+
+ cleanUp();
+ return false;
+}
+
+bool JpegCompressor::isBusy() {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock busyLock(mBusyMutex);
+ return mIsBusy;
+}
+
+// old function -- TODO: update for new buffer type
+bool JpegCompressor::isStreamInUse(uint32_t id) {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock lock(mBusyMutex);
+
+ if (mBuffers.size() && mIsBusy) {
+ for (size_t i = 0; i < mBuffers.size(); i++) {
+// if ( mBuffers[i].streamId == (int)id ) return true;
+ }
+ }
+ return false;
+}
+
+bool JpegCompressor::waitForDone(nsecs_t timeout) {
+ ALOGV("%s", __FUNCTION__);
+ Mutex::Autolock lock(mBusyMutex);
+ status_t res = OK;
+ if (mIsBusy) {
+ res = mDone.waitRelative(mBusyMutex, timeout);
+ }
+ return (res == OK);
+}
+
+bool JpegCompressor::checkError(const char *msg) {
+ ALOGV("%s", __FUNCTION__);
+ if (mJpegErrorInfo) {
+ char errBuffer[JMSG_LENGTH_MAX];
+ mJpegErrorInfo->err->format_message(mJpegErrorInfo, errBuffer);
+ ALOGE("%s: %s: %s",
+ __FUNCTION__, msg, errBuffer);
+ cleanUp();
+ mJpegErrorInfo = NULL;
+ return true;
+ }
+ return false;
+}
+
+void JpegCompressor::cleanUp() {
+ ALOGV("%s", __FUNCTION__);
+ jpeg_destroy_compress(&mCInfo);
+ Mutex::Autolock lock(mBusyMutex);
+ mIsBusy = false;
+ mDone.signal();
+}
+
+void JpegCompressor::jpegErrorHandler(j_common_ptr cinfo) {
+ ALOGV("%s", __FUNCTION__);
+ JpegError *error = static_cast<JpegError*>(cinfo->err);
+ error->parent->mJpegErrorInfo = cinfo;
+}
+
+void JpegCompressor::jpegInitDestination(j_compress_ptr cinfo) {
+ ALOGV("%s", __FUNCTION__);
+ JpegDestination *dest= static_cast<JpegDestination*>(cinfo->dest);
+ ALOGV("%s: Setting destination to %p, size %d",
+ __FUNCTION__, dest->parent->mJpegBuffer->data, kMaxJpegSize);
+ dest->next_output_byte = (JOCTET*)(dest->parent->mJpegBuffer->data);
+ dest->free_in_buffer = kMaxJpegSize;
+}
+
+boolean JpegCompressor::jpegEmptyOutputBuffer(j_compress_ptr cinfo) {
+ ALOGV("%s", __FUNCTION__);
+ ALOGE("%s: JPEG destination buffer overflow!",
+ __FUNCTION__);
+ return true;
+}
+
+void JpegCompressor::jpegTermDestination(j_compress_ptr cinfo) {
+ ALOGV("%s", __FUNCTION__);
+ ALOGV("%s: Done writing JPEG data. %d bytes left in buffer",
+ __FUNCTION__, cinfo->dest->free_in_buffer);
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/JpegCompressor.h b/services/camera/libcameraservice/camera2/JpegCompressor.h
new file mode 100644
index 00000000..945b1def
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/JpegCompressor.h
@@ -0,0 +1,107 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * This class simulates a hardware JPEG compressor. It receives image buffers
+ * in RGBA_8888 format, processes them in a worker thread, and then pushes them
+ * out to their destination stream.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_JPEGCOMPRESSOR_H
+#define ANDROID_SERVERS_CAMERA_JPEGCOMPRESSOR_H
+
+#include "utils/Thread.h"
+#include "utils/Mutex.h"
+#include "utils/Timers.h"
+#include "utils/Vector.h"
+//#include "Base.h"
+#include <stdio.h>
+#include <gui/CpuConsumer.h>
+
+extern "C" {
+#include <jpeglib.h>
+}
+
+
+namespace android {
+namespace camera2 {
+
+class JpegCompressor: private Thread, public virtual RefBase {
+ public:
+
+ JpegCompressor();
+ ~JpegCompressor();
+
+ // Start compressing COMPRESSED format buffers; JpegCompressor takes
+ // ownership of the Buffers vector.
+ status_t start(Vector<CpuConsumer::LockedBuffer*> buffers,
+ nsecs_t captureTime);
+
+ status_t cancel();
+
+ bool isBusy();
+ bool isStreamInUse(uint32_t id);
+
+ bool waitForDone(nsecs_t timeout);
+
+ // TODO: Measure this
+ static const size_t kMaxJpegSize = 300000;
+
+ private:
+ Mutex mBusyMutex;
+ Mutex mMutex;
+ bool mIsBusy;
+ Condition mDone;
+ nsecs_t mCaptureTime;
+
+ Vector<CpuConsumer::LockedBuffer*> mBuffers;
+ CpuConsumer::LockedBuffer *mJpegBuffer;
+ CpuConsumer::LockedBuffer *mAuxBuffer;
+ bool mFoundJpeg, mFoundAux;
+
+ jpeg_compress_struct mCInfo;
+
+ struct JpegError : public jpeg_error_mgr {
+ JpegCompressor *parent;
+ };
+ j_common_ptr mJpegErrorInfo;
+
+ struct JpegDestination : public jpeg_destination_mgr {
+ JpegCompressor *parent;
+ };
+
+ static void jpegErrorHandler(j_common_ptr cinfo);
+
+ static void jpegInitDestination(j_compress_ptr cinfo);
+ static boolean jpegEmptyOutputBuffer(j_compress_ptr cinfo);
+ static void jpegTermDestination(j_compress_ptr cinfo);
+
+ bool checkError(const char *msg);
+ void cleanUp();
+
+ /**
+ * Inherited Thread virtual overrides
+ */
+ private:
+ virtual status_t readyToRun();
+ virtual bool threadLoop();
+};
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/JpegProcessor.cpp b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
new file mode 100644
index 00000000..ffc072ba
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/JpegProcessor.cpp
@@ -0,0 +1,380 @@
+/*
+ * 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 "Camera2-JpegProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <netinet/in.h>
+
+#include <binder/MemoryBase.h>
+#include <binder/MemoryHeapBase.h>
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include "JpegProcessor.h"
+#include <gui/SurfaceTextureClient.h>
+#include "../Camera2Device.h"
+#include "../Camera2Client.h"
+
+
+namespace android {
+namespace camera2 {
+
+JpegProcessor::JpegProcessor(
+ wp<Camera2Client> client,
+ wp<CaptureSequencer> sequencer):
+ Thread(false),
+ mClient(client),
+ mSequencer(sequencer),
+ mCaptureAvailable(false),
+ mCaptureStreamId(NO_STREAM) {
+}
+
+JpegProcessor::~JpegProcessor() {
+ ALOGV("%s: Exit", __FUNCTION__);
+ deleteStream();
+}
+
+void JpegProcessor::onFrameAvailable() {
+ Mutex::Autolock l(mInputMutex);
+ if (!mCaptureAvailable) {
+ mCaptureAvailable = true;
+ mCaptureAvailableSignal.signal();
+ }
+}
+
+status_t JpegProcessor::updateStream(const Parameters &params) {
+ ATRACE_CALL();
+ ALOGV("%s", __FUNCTION__);
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ // Find out buffer size for JPEG
+ camera_metadata_ro_entry_t maxJpegSize =
+ params.staticInfo(ANDROID_JPEG_MAX_SIZE);
+ if (maxJpegSize.count == 0) {
+ ALOGE("%s: Camera %d: Can't find ANDROID_JPEG_MAX_SIZE!",
+ __FUNCTION__, client->getCameraId());
+ return INVALID_OPERATION;
+ }
+
+ if (mCaptureConsumer == 0) {
+ // Create CPU buffer queue endpoint
+ mCaptureConsumer = new CpuConsumer(1);
+ mCaptureConsumer->setFrameAvailableListener(this);
+ mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer"));
+ mCaptureWindow = new SurfaceTextureClient(
+ mCaptureConsumer->getProducerInterface());
+ // Create memory for API consumption
+ mCaptureHeap = new MemoryHeapBase(maxJpegSize.data.i32[0], 0,
+ "Camera2Client::CaptureHeap");
+ if (mCaptureHeap->getSize() == 0) {
+ ALOGE("%s: Camera %d: Unable to allocate memory for capture",
+ __FUNCTION__, client->getCameraId());
+ return NO_MEMORY;
+ }
+ }
+
+ if (mCaptureStreamId != NO_STREAM) {
+ // Check if stream parameters have to change
+ uint32_t currentWidth, currentHeight;
+ res = device->getStreamInfo(mCaptureStreamId,
+ &currentWidth, &currentHeight, 0);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error querying capture output stream info: "
+ "%s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ if (currentWidth != (uint32_t)params.pictureWidth ||
+ currentHeight != (uint32_t)params.pictureHeight) {
+ ALOGV("%s: Camera %d: Deleting stream %d since the buffer dimensions changed",
+ __FUNCTION__, client->getCameraId(), mCaptureStreamId);
+ res = device->deleteStream(mCaptureStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old output stream "
+ "for capture: %s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ mCaptureStreamId = NO_STREAM;
+ }
+ }
+
+ if (mCaptureStreamId == NO_STREAM) {
+ // Create stream for HAL production
+ res = device->createStream(mCaptureWindow,
+ params.pictureWidth, params.pictureHeight,
+ HAL_PIXEL_FORMAT_BLOB, maxJpegSize.data.i32[0],
+ &mCaptureStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't create output stream for capture: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+
+ }
+ return OK;
+}
+
+status_t JpegProcessor::deleteStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ if (mCaptureStreamId != NO_STREAM) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ device->deleteStream(mCaptureStreamId);
+
+ mCaptureHeap.clear();
+ mCaptureWindow.clear();
+ mCaptureConsumer.clear();
+
+ mCaptureStreamId = NO_STREAM;
+ }
+ return OK;
+}
+
+int JpegProcessor::getStreamId() const {
+ Mutex::Autolock l(mInputMutex);
+ return mCaptureStreamId;
+}
+
+void JpegProcessor::dump(int fd, const Vector<String16>& args) const {
+}
+
+bool JpegProcessor::threadLoop() {
+ status_t res;
+
+ {
+ Mutex::Autolock l(mInputMutex);
+ while (!mCaptureAvailable) {
+ res = mCaptureAvailableSignal.waitRelative(mInputMutex,
+ kWaitDuration);
+ if (res == TIMED_OUT) return true;
+ }
+ mCaptureAvailable = false;
+ }
+
+ do {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+ res = processNewCapture(client);
+ } while (res == OK);
+
+ return true;
+}
+
+status_t JpegProcessor::processNewCapture(sp<Camera2Client> &client) {
+ ATRACE_CALL();
+ status_t res;
+ sp<Camera2Heap> captureHeap;
+
+ CpuConsumer::LockedBuffer imgBuffer;
+
+ res = mCaptureConsumer->lockNextBuffer(&imgBuffer);
+ if (res != OK) {
+ if (res != BAD_VALUE) {
+ ALOGE("%s: Camera %d: Error receiving still image buffer: "
+ "%s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ }
+ return res;
+ }
+
+ ALOGV("%s: Camera %d: Still capture available", __FUNCTION__,
+ client->getCameraId());
+
+ if (imgBuffer.format != HAL_PIXEL_FORMAT_BLOB) {
+ ALOGE("%s: Camera %d: Unexpected format for still image: "
+ "%x, expected %x", __FUNCTION__, client->getCameraId(),
+ imgBuffer.format,
+ HAL_PIXEL_FORMAT_BLOB);
+ mCaptureConsumer->unlockBuffer(imgBuffer);
+ return OK;
+ }
+
+ // Find size of JPEG image
+ size_t jpegSize = findJpegSize(imgBuffer.data, imgBuffer.width);
+ if (jpegSize == 0) { // failed to find size, default to whole buffer
+ jpegSize = imgBuffer.width;
+ }
+ size_t heapSize = mCaptureHeap->getSize();
+ if (jpegSize > heapSize) {
+ ALOGW("%s: JPEG image is larger than expected, truncating "
+ "(got %d, expected at most %d bytes)",
+ __FUNCTION__, jpegSize, heapSize);
+ jpegSize = heapSize;
+ }
+
+ // TODO: Optimize this to avoid memcopy
+ sp<MemoryBase> captureBuffer = new MemoryBase(mCaptureHeap, 0, jpegSize);
+ void* captureMemory = mCaptureHeap->getBase();
+ memcpy(captureMemory, imgBuffer.data, jpegSize);
+
+ mCaptureConsumer->unlockBuffer(imgBuffer);
+
+ sp<CaptureSequencer> sequencer = mSequencer.promote();
+ if (sequencer != 0) {
+ sequencer->onCaptureAvailable(imgBuffer.timestamp, captureBuffer);
+ }
+
+ return OK;
+}
+
+/*
+ * JPEG FILE FORMAT OVERVIEW.
+ * http://www.jpeg.org/public/jfif.pdf
+ * (JPEG is the image compression algorithm, actual file format is called JFIF)
+ *
+ * "Markers" are 2-byte patterns used to distinguish parts of JFIF files. The
+ * first byte is always 0xFF, and the second byte is between 0x01 and 0xFE
+ * (inclusive). Because every marker begins with the same byte, they are
+ * referred to by the second byte's value.
+ *
+ * JFIF files all begin with the Start of Image (SOI) marker, which is 0xD8.
+ * Following it, "segment" sections begin with other markers, followed by a
+ * 2-byte length (in network byte order), then the segment data.
+ *
+ * For our purposes we will ignore the data, and just use the length to skip to
+ * the next segment. This is necessary because the data inside segments are
+ * allowed to contain the End of Image marker (0xFF 0xD9), preventing us from
+ * naievely scanning until the end.
+ *
+ * After all the segments are processed, the jpeg compressed image stream begins.
+ * This can be considered an opaque format with one requirement: all 0xFF bytes
+ * in this stream must be followed with a 0x00 byte. This prevents any of the
+ * image data to be interpreted as a segment. The only exception to this is at
+ * the end of the image stream there is an End of Image (EOI) marker, which is
+ * 0xFF followed by a non-zero (0xD9) byte.
+ */
+
+const uint8_t MARK = 0xFF; // First byte of marker
+const uint8_t SOI = 0xD8; // Start of Image
+const uint8_t EOI = 0xD9; // End of Image
+const size_t MARKER_LENGTH = 2; // length of a marker
+
+#pragma pack(push)
+#pragma pack(1)
+typedef struct segment {
+ uint8_t marker[MARKER_LENGTH];
+ uint16_t length;
+} segment_t;
+#pragma pack(pop)
+
+/* HELPER FUNCTIONS */
+
+// check for Start of Image marker
+bool checkJpegStart(uint8_t* buf) {
+ return buf[0] == MARK && buf[1] == SOI;
+}
+// check for End of Image marker
+bool checkJpegEnd(uint8_t *buf) {
+ return buf[0] == MARK && buf[1] == EOI;
+}
+// check for arbitrary marker, returns marker type (second byte)
+// returns 0 if no marker found. Note: 0x00 is not a valid marker type
+uint8_t checkJpegMarker(uint8_t *buf) {
+ if (buf[0] == MARK && buf[1] > 0 && buf[1] < 0xFF) {
+ return buf[1];
+ }
+ return 0;
+}
+
+// Return the size of the JPEG, 0 indicates failure
+size_t JpegProcessor::findJpegSize(uint8_t* jpegBuffer, size_t maxSize) {
+ size_t size;
+
+ // First check for JPEG transport header at the end of the buffer
+ uint8_t *header = jpegBuffer + (maxSize - sizeof(struct camera2_jpeg_blob));
+ struct camera2_jpeg_blob *blob = (struct camera2_jpeg_blob*)(header);
+ if (blob->jpeg_blob_id == CAMERA2_JPEG_BLOB_ID) {
+ size = blob->jpeg_size;
+ if (size > 0 && size <= maxSize - sizeof(struct camera2_jpeg_blob)) {
+ // Verify SOI and EOI markers
+ size_t offset = size - MARKER_LENGTH;
+ uint8_t *end = jpegBuffer + offset;
+ if (checkJpegStart(jpegBuffer) && checkJpegEnd(end)) {
+ ALOGV("Found JPEG transport header, img size %d", size);
+ return size;
+ } else {
+ ALOGW("Found JPEG transport header with bad Image Start/End");
+ }
+ } else {
+ ALOGW("Found JPEG transport header with bad size %d", size);
+ }
+ }
+
+ // Check Start of Image
+ if ( !checkJpegStart(jpegBuffer) ) {
+ ALOGE("Could not find start of JPEG marker");
+ return 0;
+ }
+
+ // Read JFIF segment markers, skip over segment data
+ size = 0;
+ while (size <= maxSize - MARKER_LENGTH) {
+ segment_t *segment = (segment_t*)(jpegBuffer + size);
+ uint8_t type = checkJpegMarker(segment->marker);
+ if (type == 0) { // invalid marker, no more segments, begin JPEG data
+ ALOGV("JPEG stream found beginning at offset %d", size);
+ break;
+ }
+ if (type == EOI || size > maxSize - sizeof(segment_t)) {
+ ALOGE("Got premature End before JPEG data, offset %d", size);
+ return 0;
+ }
+ size_t length = ntohs(segment->length);
+ ALOGV("JFIF Segment, type %x length %x", type, length);
+ size += length + MARKER_LENGTH;
+ }
+
+ // Find End of Image
+ // Scan JPEG buffer until End of Image (EOI)
+ bool foundEnd = false;
+ for (size; size <= maxSize - MARKER_LENGTH; size++) {
+ if ( checkJpegEnd(jpegBuffer + size) ) {
+ foundEnd = true;
+ size += MARKER_LENGTH;
+ break;
+ }
+ }
+ if (!foundEnd) {
+ ALOGE("Could not find end of JPEG marker");
+ return 0;
+ }
+
+ if (size > maxSize) {
+ ALOGW("JPEG size %d too large, reducing to maxSize %d", size, maxSize);
+ size = maxSize;
+ }
+ ALOGV("Final JPEG size %d", size);
+ return size;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/JpegProcessor.h b/services/camera/libcameraservice/camera2/JpegProcessor.h
new file mode 100644
index 00000000..836bd02b
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/JpegProcessor.h
@@ -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.
+ */
+
+#ifndef ANDROID_SERVERS_CAMERA_CAMERA2_JPEGPROCESSOR_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_JPEGPROCESSOR_H
+
+#include <utils/Thread.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/Mutex.h>
+#include <utils/Condition.h>
+#include <gui/CpuConsumer.h>
+#include "Parameters.h"
+#include "CameraMetadata.h"
+
+namespace android {
+
+class Camera2Client;
+class MemoryHeapBase;
+
+namespace camera2 {
+
+class CaptureSequencer;
+
+/***
+ * Still image capture output image processing
+ */
+class JpegProcessor:
+ public Thread, public CpuConsumer::FrameAvailableListener {
+ public:
+ JpegProcessor(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
+ ~JpegProcessor();
+
+ void onFrameAvailable();
+
+ status_t updateStream(const Parameters &params);
+ status_t deleteStream();
+ int getStreamId() const;
+
+ void dump(int fd, const Vector<String16>& args) const;
+ private:
+ static const nsecs_t kWaitDuration = 10000000; // 10 ms
+ wp<Camera2Client> mClient;
+ wp<CaptureSequencer> mSequencer;
+
+ mutable Mutex mInputMutex;
+ bool mCaptureAvailable;
+ Condition mCaptureAvailableSignal;
+
+ enum {
+ NO_STREAM = -1
+ };
+
+ int mCaptureStreamId;
+ sp<CpuConsumer> mCaptureConsumer;
+ sp<ANativeWindow> mCaptureWindow;
+ sp<MemoryHeapBase> mCaptureHeap;
+
+ virtual bool threadLoop();
+
+ status_t processNewCapture(sp<Camera2Client> &client);
+ size_t findJpegSize(uint8_t* jpegBuffer, size_t maxSize);
+
+};
+
+
+}; //namespace camera2
+}; //namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/Parameters.cpp b/services/camera/libcameraservice/camera2/Parameters.cpp
new file mode 100644
index 00000000..278a19cb
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/Parameters.cpp
@@ -0,0 +1,2431 @@
+/*
+ * 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 "Camera2-Parameters"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <utils/Vector.h>
+#include <utils/SortedVector.h>
+
+#include <math.h>
+#include <stdlib.h>
+#include <cutils/properties.h>
+
+#include "Parameters.h"
+#include "system/camera.h"
+
+namespace android {
+namespace camera2 {
+
+Parameters::Parameters(int cameraId,
+ int cameraFacing) :
+ cameraId(cameraId),
+ cameraFacing(cameraFacing),
+ info(NULL) {
+}
+
+Parameters::~Parameters() {
+}
+
+status_t Parameters::initialize(const CameraMetadata *info) {
+ status_t res;
+
+ if (info->entryCount() == 0) {
+ ALOGE("%s: No static information provided!", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ Parameters::info = info;
+
+ res = buildFastInfo();
+ if (res != OK) return res;
+
+ res = buildQuirks();
+ if (res != OK) return res;
+
+ camera_metadata_ro_entry_t availableProcessedSizes =
+ staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, 2);
+ if (!availableProcessedSizes.count) return NO_INIT;
+
+ // TODO: Pick more intelligently
+ previewWidth = availableProcessedSizes.data.i32[0];
+ previewHeight = availableProcessedSizes.data.i32[1];
+ videoWidth = previewWidth;
+ videoHeight = previewHeight;
+
+ params.setPreviewSize(previewWidth, previewHeight);
+ params.setVideoSize(videoWidth, videoHeight);
+ params.set(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO,
+ String8::format("%dx%d",
+ previewWidth, previewHeight));
+ {
+ String8 supportedPreviewSizes;
+ for (size_t i=0; i < availableProcessedSizes.count; i += 2) {
+ if (i != 0) supportedPreviewSizes += ",";
+ supportedPreviewSizes += String8::format("%dx%d",
+ availableProcessedSizes.data.i32[i],
+ availableProcessedSizes.data.i32[i+1]);
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES,
+ supportedPreviewSizes);
+ params.set(CameraParameters::KEY_SUPPORTED_VIDEO_SIZES,
+ supportedPreviewSizes);
+ }
+
+ camera_metadata_ro_entry_t availableFpsRanges =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, 2);
+ if (!availableFpsRanges.count) return NO_INIT;
+
+ previewFpsRange[0] = availableFpsRanges.data.i32[0];
+ previewFpsRange[1] = availableFpsRanges.data.i32[1];
+
+ params.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,
+ String8::format("%d,%d",
+ previewFpsRange[0] * kFpsToApiScale,
+ previewFpsRange[1] * kFpsToApiScale));
+
+ {
+ String8 supportedPreviewFpsRange;
+ for (size_t i=0; i < availableFpsRanges.count; i += 2) {
+ if (i != 0) supportedPreviewFpsRange += ",";
+ supportedPreviewFpsRange += String8::format("(%d,%d)",
+ availableFpsRanges.data.i32[i] * kFpsToApiScale,
+ availableFpsRanges.data.i32[i+1] * kFpsToApiScale);
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE,
+ supportedPreviewFpsRange);
+ }
+
+ previewFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
+ params.set(CameraParameters::KEY_PREVIEW_FORMAT,
+ formatEnumToString(previewFormat)); // NV21
+
+ previewTransform = degToTransform(0,
+ cameraFacing == CAMERA_FACING_FRONT);
+
+ camera_metadata_ro_entry_t availableFormats =
+ staticInfo(ANDROID_SCALER_AVAILABLE_FORMATS);
+
+ {
+ String8 supportedPreviewFormats;
+ bool addComma = false;
+ for (size_t i=0; i < availableFormats.count; i++) {
+ if (addComma) supportedPreviewFormats += ",";
+ addComma = true;
+ switch (availableFormats.data.i32[i]) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_YUV422SP;
+ break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_YUV420SP;
+ break;
+ case HAL_PIXEL_FORMAT_YCbCr_422_I:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_YUV422I;
+ break;
+ case HAL_PIXEL_FORMAT_YV12:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_YUV420P;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_565:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_RGB565;
+ break;
+ case HAL_PIXEL_FORMAT_RGBA_8888:
+ supportedPreviewFormats +=
+ CameraParameters::PIXEL_FORMAT_RGBA8888;
+ break;
+ // Not advertizing JPEG, RAW_SENSOR, etc, for preview formats
+ case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ case HAL_PIXEL_FORMAT_BLOB:
+ addComma = false;
+ break;
+
+ default:
+ ALOGW("%s: Camera %d: Unknown preview format: %x",
+ __FUNCTION__, cameraId, availableFormats.data.i32[i]);
+ addComma = false;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FORMATS,
+ supportedPreviewFormats);
+ }
+
+ // PREVIEW_FRAME_RATE / SUPPORTED_PREVIEW_FRAME_RATES are deprecated, but
+ // still have to do something sane for them
+
+ // NOTE: Not scaled like FPS range values are.
+ previewFps = fpsFromRange(previewFpsRange[0], previewFpsRange[1]);
+ params.set(CameraParameters::KEY_PREVIEW_FRAME_RATE,
+ previewFps);
+
+ {
+ SortedVector<int32_t> sortedPreviewFrameRates;
+
+ String8 supportedPreviewFrameRates;
+ for (size_t i=0; i < availableFpsRanges.count; i += 2) {
+ // from the [min, max] fps range use the max value
+ int fps = fpsFromRange(availableFpsRanges.data.i32[i],
+ availableFpsRanges.data.i32[i+1]);
+
+ // de-dupe frame rates
+ if (sortedPreviewFrameRates.indexOf(fps) == NAME_NOT_FOUND) {
+ sortedPreviewFrameRates.add(fps);
+ }
+ else {
+ continue;
+ }
+
+ if (sortedPreviewFrameRates.size() > 1) {
+ supportedPreviewFrameRates += ",";
+ }
+
+ supportedPreviewFrameRates += String8::format("%d",
+ fps);
+
+ ALOGV("%s: Supported preview frame rates: %s",
+ __FUNCTION__, supportedPreviewFrameRates.string());
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES,
+ supportedPreviewFrameRates);
+ }
+
+ camera_metadata_ro_entry_t availableJpegSizes =
+ staticInfo(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, 2);
+ if (!availableJpegSizes.count) return NO_INIT;
+
+ // TODO: Pick maximum
+ pictureWidth = availableJpegSizes.data.i32[0];
+ pictureHeight = availableJpegSizes.data.i32[1];
+
+ params.setPictureSize(pictureWidth,
+ pictureHeight);
+
+ {
+ String8 supportedPictureSizes;
+ for (size_t i=0; i < availableJpegSizes.count; i += 2) {
+ if (i != 0) supportedPictureSizes += ",";
+ supportedPictureSizes += String8::format("%dx%d",
+ availableJpegSizes.data.i32[i],
+ availableJpegSizes.data.i32[i+1]);
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES,
+ supportedPictureSizes);
+ }
+
+ params.setPictureFormat(CameraParameters::PIXEL_FORMAT_JPEG);
+ params.set(CameraParameters::KEY_SUPPORTED_PICTURE_FORMATS,
+ CameraParameters::PIXEL_FORMAT_JPEG);
+
+ camera_metadata_ro_entry_t availableJpegThumbnailSizes =
+ staticInfo(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, 4);
+ if (!availableJpegThumbnailSizes.count) return NO_INIT;
+
+ // TODO: Pick default thumbnail size sensibly
+ jpegThumbSize[0] = availableJpegThumbnailSizes.data.i32[0];
+ jpegThumbSize[1] = availableJpegThumbnailSizes.data.i32[1];
+
+ params.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH,
+ jpegThumbSize[0]);
+ params.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT,
+ jpegThumbSize[1]);
+
+ {
+ String8 supportedJpegThumbSizes;
+ for (size_t i=0; i < availableJpegThumbnailSizes.count; i += 2) {
+ if (i != 0) supportedJpegThumbSizes += ",";
+ supportedJpegThumbSizes += String8::format("%dx%d",
+ availableJpegThumbnailSizes.data.i32[i],
+ availableJpegThumbnailSizes.data.i32[i+1]);
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_JPEG_THUMBNAIL_SIZES,
+ supportedJpegThumbSizes);
+ }
+
+ jpegThumbQuality = 90;
+ params.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY,
+ jpegThumbQuality);
+ jpegQuality = 90;
+ params.set(CameraParameters::KEY_JPEG_QUALITY,
+ jpegQuality);
+ jpegRotation = 0;
+ params.set(CameraParameters::KEY_ROTATION,
+ jpegRotation);
+
+ gpsEnabled = false;
+ gpsCoordinates[0] = 0.0;
+ gpsCoordinates[1] = 0.0;
+ gpsCoordinates[2] = 0.0;
+ gpsTimestamp = 0;
+ gpsProcessingMethod = "unknown";
+ // GPS fields in CameraParameters are not set by implementation
+
+ wbMode = ANDROID_CONTROL_AWB_MODE_AUTO;
+ params.set(CameraParameters::KEY_WHITE_BALANCE,
+ CameraParameters::WHITE_BALANCE_AUTO);
+
+ camera_metadata_ro_entry_t availableWhiteBalanceModes =
+ staticInfo(ANDROID_CONTROL_AWB_AVAILABLE_MODES);
+ {
+ String8 supportedWhiteBalance;
+ bool addComma = false;
+ for (size_t i=0; i < availableWhiteBalanceModes.count; i++) {
+ if (addComma) supportedWhiteBalance += ",";
+ addComma = true;
+ switch (availableWhiteBalanceModes.data.u8[i]) {
+ case ANDROID_CONTROL_AWB_MODE_AUTO:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_AUTO;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_INCANDESCENT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_INCANDESCENT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_FLUORESCENT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_FLUORESCENT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_DAYLIGHT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_DAYLIGHT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_TWILIGHT:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_TWILIGHT;
+ break;
+ case ANDROID_CONTROL_AWB_MODE_SHADE:
+ supportedWhiteBalance +=
+ CameraParameters::WHITE_BALANCE_SHADE;
+ break;
+ // Skipping values not mappable to v1 API
+ case ANDROID_CONTROL_AWB_MODE_OFF:
+ addComma = false;
+ break;
+ default:
+ ALOGW("%s: Camera %d: Unknown white balance value: %d",
+ __FUNCTION__, cameraId,
+ availableWhiteBalanceModes.data.u8[i]);
+ addComma = false;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE,
+ supportedWhiteBalance);
+ }
+
+ effectMode = ANDROID_CONTROL_EFFECT_MODE_OFF;
+ params.set(CameraParameters::KEY_EFFECT,
+ CameraParameters::EFFECT_NONE);
+
+ camera_metadata_ro_entry_t availableEffects =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_EFFECTS);
+ if (!availableEffects.count) return NO_INIT;
+ {
+ String8 supportedEffects;
+ bool addComma = false;
+ for (size_t i=0; i < availableEffects.count; i++) {
+ if (addComma) supportedEffects += ",";
+ addComma = true;
+ switch (availableEffects.data.u8[i]) {
+ case ANDROID_CONTROL_EFFECT_MODE_OFF:
+ supportedEffects +=
+ CameraParameters::EFFECT_NONE;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_MONO:
+ supportedEffects +=
+ CameraParameters::EFFECT_MONO;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_NEGATIVE:
+ supportedEffects +=
+ CameraParameters::EFFECT_NEGATIVE;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_SOLARIZE:
+ supportedEffects +=
+ CameraParameters::EFFECT_SOLARIZE;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_SEPIA:
+ supportedEffects +=
+ CameraParameters::EFFECT_SEPIA;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_POSTERIZE:
+ supportedEffects +=
+ CameraParameters::EFFECT_POSTERIZE;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD:
+ supportedEffects +=
+ CameraParameters::EFFECT_WHITEBOARD;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD:
+ supportedEffects +=
+ CameraParameters::EFFECT_BLACKBOARD;
+ break;
+ case ANDROID_CONTROL_EFFECT_MODE_AQUA:
+ supportedEffects +=
+ CameraParameters::EFFECT_AQUA;
+ break;
+ default:
+ ALOGW("%s: Camera %d: Unknown effect value: %d",
+ __FUNCTION__, cameraId, availableEffects.data.u8[i]);
+ addComma = false;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_EFFECTS, supportedEffects);
+ }
+
+ antibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO;
+ params.set(CameraParameters::KEY_ANTIBANDING,
+ CameraParameters::ANTIBANDING_AUTO);
+
+ camera_metadata_ro_entry_t availableAntibandingModes =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES);
+ if (!availableAntibandingModes.count) return NO_INIT;
+ {
+ String8 supportedAntibanding;
+ bool addComma = false;
+ for (size_t i=0; i < availableAntibandingModes.count; i++) {
+ if (addComma) supportedAntibanding += ",";
+ addComma = true;
+ switch (availableAntibandingModes.data.u8[i]) {
+ case ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF:
+ supportedAntibanding +=
+ CameraParameters::ANTIBANDING_OFF;
+ break;
+ case ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ:
+ supportedAntibanding +=
+ CameraParameters::ANTIBANDING_50HZ;
+ break;
+ case ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ:
+ supportedAntibanding +=
+ CameraParameters::ANTIBANDING_60HZ;
+ break;
+ case ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO:
+ supportedAntibanding +=
+ CameraParameters::ANTIBANDING_AUTO;
+ break;
+ default:
+ ALOGW("%s: Camera %d: Unknown antibanding value: %d",
+ __FUNCTION__, cameraId,
+ availableAntibandingModes.data.u8[i]);
+ addComma = false;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_ANTIBANDING,
+ supportedAntibanding);
+ }
+
+ sceneMode = ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
+ params.set(CameraParameters::KEY_SCENE_MODE,
+ CameraParameters::SCENE_MODE_AUTO);
+
+ camera_metadata_ro_entry_t availableSceneModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_SCENE_MODES);
+ if (!availableSceneModes.count) return NO_INIT;
+ {
+ String8 supportedSceneModes(CameraParameters::SCENE_MODE_AUTO);
+ bool addComma = true;
+ bool noSceneModes = false;
+ for (size_t i=0; i < availableSceneModes.count; i++) {
+ if (addComma) supportedSceneModes += ",";
+ addComma = true;
+ switch (availableSceneModes.data.u8[i]) {
+ case ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED:
+ noSceneModes = true;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY:
+ // Not in old API
+ addComma = false;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_ACTION:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_ACTION;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_PORTRAIT:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_PORTRAIT;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_LANDSCAPE:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_LANDSCAPE;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_NIGHT:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_NIGHT;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_NIGHT_PORTRAIT;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_THEATRE:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_THEATRE;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_BEACH:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_BEACH;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_SNOW:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_SNOW;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_SUNSET:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_SUNSET;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_STEADYPHOTO;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_FIREWORKS:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_FIREWORKS;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_SPORTS:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_SPORTS;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_PARTY:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_PARTY;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_CANDLELIGHT;
+ break;
+ case ANDROID_CONTROL_SCENE_MODE_BARCODE:
+ supportedSceneModes +=
+ CameraParameters::SCENE_MODE_BARCODE;
+ break;
+ default:
+ ALOGW("%s: Camera %d: Unknown scene mode value: %d",
+ __FUNCTION__, cameraId,
+ availableSceneModes.data.u8[i]);
+ addComma = false;
+ break;
+ }
+ }
+ if (!noSceneModes) {
+ params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES,
+ supportedSceneModes);
+ }
+ }
+
+ camera_metadata_ro_entry_t flashAvailable =
+ staticInfo(ANDROID_FLASH_INFO_AVAILABLE, 1, 1);
+ if (!flashAvailable.count) return NO_INIT;
+
+ camera_metadata_ro_entry_t availableAeModes =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_MODES);
+ if (!availableAeModes.count) return NO_INIT;
+
+ if (flashAvailable.data.u8[0]) {
+ flashMode = Parameters::FLASH_MODE_OFF;
+ params.set(CameraParameters::KEY_FLASH_MODE,
+ CameraParameters::FLASH_MODE_OFF);
+
+ String8 supportedFlashModes(CameraParameters::FLASH_MODE_OFF);
+ supportedFlashModes = supportedFlashModes +
+ "," + CameraParameters::FLASH_MODE_AUTO +
+ "," + CameraParameters::FLASH_MODE_ON +
+ "," + CameraParameters::FLASH_MODE_TORCH;
+ for (size_t i=0; i < availableAeModes.count; i++) {
+ if (availableAeModes.data.u8[i] ==
+ ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE) {
+ supportedFlashModes = supportedFlashModes + "," +
+ CameraParameters::FLASH_MODE_RED_EYE;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES,
+ supportedFlashModes);
+ } else {
+ flashMode = Parameters::FLASH_MODE_OFF;
+ params.set(CameraParameters::KEY_FLASH_MODE,
+ CameraParameters::FLASH_MODE_OFF);
+ params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES,
+ CameraParameters::FLASH_MODE_OFF);
+ }
+
+ camera_metadata_ro_entry_t minFocusDistance =
+ staticInfo(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE, 1, 1);
+ if (!minFocusDistance.count) return NO_INIT;
+
+ camera_metadata_ro_entry_t availableAfModes =
+ staticInfo(ANDROID_CONTROL_AF_AVAILABLE_MODES);
+ if (!availableAfModes.count) return NO_INIT;
+
+ if (minFocusDistance.data.f[0] == 0) {
+ // Fixed-focus lens
+ focusMode = Parameters::FOCUS_MODE_FIXED;
+ params.set(CameraParameters::KEY_FOCUS_MODE,
+ CameraParameters::FOCUS_MODE_FIXED);
+ params.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES,
+ CameraParameters::FOCUS_MODE_FIXED);
+ } else {
+ focusMode = Parameters::FOCUS_MODE_AUTO;
+ params.set(CameraParameters::KEY_FOCUS_MODE,
+ CameraParameters::FOCUS_MODE_AUTO);
+ String8 supportedFocusModes(CameraParameters::FOCUS_MODE_INFINITY);
+ bool addComma = true;
+
+ for (size_t i=0; i < availableAfModes.count; i++) {
+ if (addComma) supportedFocusModes += ",";
+ addComma = true;
+ switch (availableAfModes.data.u8[i]) {
+ case ANDROID_CONTROL_AF_MODE_AUTO:
+ supportedFocusModes +=
+ CameraParameters::FOCUS_MODE_AUTO;
+ break;
+ case ANDROID_CONTROL_AF_MODE_MACRO:
+ supportedFocusModes +=
+ CameraParameters::FOCUS_MODE_MACRO;
+ break;
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO:
+ supportedFocusModes +=
+ CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO;
+ break;
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE:
+ supportedFocusModes +=
+ CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE;
+ break;
+ case ANDROID_CONTROL_AF_MODE_EDOF:
+ supportedFocusModes +=
+ CameraParameters::FOCUS_MODE_EDOF;
+ break;
+ // Not supported in old API
+ case ANDROID_CONTROL_AF_MODE_OFF:
+ addComma = false;
+ break;
+ default:
+ ALOGW("%s: Camera %d: Unknown AF mode value: %d",
+ __FUNCTION__, cameraId, availableAfModes.data.u8[i]);
+ addComma = false;
+ break;
+ }
+ }
+ params.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES,
+ supportedFocusModes);
+ }
+ focusState = ANDROID_CONTROL_AF_STATE_INACTIVE;
+ shadowFocusMode = FOCUS_MODE_INVALID;
+
+ camera_metadata_ro_entry_t max3aRegions =
+ staticInfo(ANDROID_CONTROL_MAX_REGIONS, 1, 1);
+ if (!max3aRegions.count) return NO_INIT;
+
+ int32_t maxNumFocusAreas = 0;
+ if (focusMode != Parameters::FOCUS_MODE_FIXED) {
+ maxNumFocusAreas = max3aRegions.data.i32[0];
+ }
+ params.set(CameraParameters::KEY_MAX_NUM_FOCUS_AREAS, maxNumFocusAreas);
+ params.set(CameraParameters::KEY_FOCUS_AREAS,
+ "(0,0,0,0,0)");
+ focusingAreas.clear();
+ focusingAreas.add(Parameters::Area(0,0,0,0,0));
+
+ camera_metadata_ro_entry_t availableFocalLengths =
+ staticInfo(ANDROID_LENS_INFO_AVAILABLE_FOCAL_LENGTHS);
+ if (!availableFocalLengths.count) return NO_INIT;
+
+ float minFocalLength = availableFocalLengths.data.f[0];
+ params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, minFocalLength);
+
+ camera_metadata_ro_entry_t sensorSize =
+ staticInfo(ANDROID_SENSOR_INFO_PHYSICAL_SIZE, 2, 2);
+ if (!sensorSize.count) return NO_INIT;
+
+ // The fields of view here assume infinity focus, maximum wide angle
+ float horizFov = 180 / M_PI *
+ 2 * atanf(sensorSize.data.f[0] / (2 * minFocalLength));
+ float vertFov = 180 / M_PI *
+ 2 * atanf(sensorSize.data.f[1] / (2 * minFocalLength));
+ params.setFloat(CameraParameters::KEY_HORIZONTAL_VIEW_ANGLE, horizFov);
+ params.setFloat(CameraParameters::KEY_VERTICAL_VIEW_ANGLE, vertFov);
+
+ exposureCompensation = 0;
+ params.set(CameraParameters::KEY_EXPOSURE_COMPENSATION,
+ exposureCompensation);
+
+ camera_metadata_ro_entry_t exposureCompensationRange =
+ staticInfo(ANDROID_CONTROL_AE_COMPENSATION_RANGE, 2, 2);
+ if (!exposureCompensationRange.count) return NO_INIT;
+
+ params.set(CameraParameters::KEY_MAX_EXPOSURE_COMPENSATION,
+ exposureCompensationRange.data.i32[1]);
+ params.set(CameraParameters::KEY_MIN_EXPOSURE_COMPENSATION,
+ exposureCompensationRange.data.i32[0]);
+
+ camera_metadata_ro_entry_t exposureCompensationStep =
+ staticInfo(ANDROID_CONTROL_AE_COMPENSATION_STEP, 1, 1);
+ if (!exposureCompensationStep.count) return NO_INIT;
+
+ params.setFloat(CameraParameters::KEY_EXPOSURE_COMPENSATION_STEP,
+ (float)exposureCompensationStep.data.r[0].numerator /
+ exposureCompensationStep.data.r[0].denominator);
+
+ autoExposureLock = false;
+ params.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK,
+ CameraParameters::FALSE);
+ params.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED,
+ CameraParameters::TRUE);
+
+ autoWhiteBalanceLock = false;
+ params.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK,
+ CameraParameters::FALSE);
+ params.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED,
+ CameraParameters::TRUE);
+
+ meteringAreas.add(Parameters::Area(0, 0, 0, 0, 0));
+ params.set(CameraParameters::KEY_MAX_NUM_METERING_AREAS,
+ max3aRegions.data.i32[0]);
+ params.set(CameraParameters::KEY_METERING_AREAS,
+ "(0,0,0,0,0)");
+
+ zoom = 0;
+ params.set(CameraParameters::KEY_ZOOM, zoom);
+ params.set(CameraParameters::KEY_MAX_ZOOM, NUM_ZOOM_STEPS - 1);
+
+ camera_metadata_ro_entry_t maxDigitalZoom =
+ staticInfo(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM, /*minCount*/1, /*maxCount*/1);
+ if (!maxDigitalZoom.count) return NO_INIT;
+
+ {
+ String8 zoomRatios;
+ float zoom = 1.f;
+ float zoomIncrement = (maxDigitalZoom.data.f[0] - zoom) /
+ (NUM_ZOOM_STEPS-1);
+ bool addComma = false;
+ for (size_t i=0; i < NUM_ZOOM_STEPS; i++) {
+ if (addComma) zoomRatios += ",";
+ addComma = true;
+ zoomRatios += String8::format("%d", static_cast<int>(zoom * 100));
+ zoom += zoomIncrement;
+ }
+ params.set(CameraParameters::KEY_ZOOM_RATIOS, zoomRatios);
+ }
+
+ params.set(CameraParameters::KEY_ZOOM_SUPPORTED,
+ CameraParameters::TRUE);
+ params.set(CameraParameters::KEY_SMOOTH_ZOOM_SUPPORTED,
+ CameraParameters::FALSE);
+
+ params.set(CameraParameters::KEY_FOCUS_DISTANCES,
+ "Infinity,Infinity,Infinity");
+
+ params.set(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW,
+ fastInfo.maxFaces);
+ params.set(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW,
+ 0);
+
+ params.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT,
+ CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE);
+
+ recordingHint = false;
+ params.set(CameraParameters::KEY_RECORDING_HINT,
+ CameraParameters::FALSE);
+
+ params.set(CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED,
+ CameraParameters::TRUE);
+
+ videoStabilization = false;
+ params.set(CameraParameters::KEY_VIDEO_STABILIZATION,
+ CameraParameters::FALSE);
+
+ camera_metadata_ro_entry_t availableVideoStabilizationModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES);
+ if (!availableVideoStabilizationModes.count) return NO_INIT;
+
+ if (availableVideoStabilizationModes.count > 1) {
+ params.set(CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED,
+ CameraParameters::TRUE);
+ } else {
+ params.set(CameraParameters::KEY_VIDEO_STABILIZATION_SUPPORTED,
+ CameraParameters::FALSE);
+ }
+
+ // Set up initial state for non-Camera.Parameters state variables
+
+ storeMetadataInBuffers = true;
+ playShutterSound = true;
+ enableFaceDetect = false;
+
+ enableFocusMoveMessages = false;
+ afTriggerCounter = 1;
+ currentAfTriggerId = -1;
+ afInMotion = false;
+
+ precaptureTriggerCounter = 1;
+
+ previewCallbackFlags = 0;
+ previewCallbackOneShot = false;
+
+ char value[PROPERTY_VALUE_MAX];
+ property_get("camera.disable_zsl_mode", value, "0");
+ if (!strcmp(value,"1")) {
+ ALOGI("Camera %d: Disabling ZSL mode", cameraId);
+ zslMode = false;
+ } else {
+ zslMode = true;
+ }
+
+ lightFx = LIGHTFX_NONE;
+
+ state = STOPPED;
+
+ paramsFlattened = params.flatten();
+
+ return OK;
+}
+
+String8 Parameters::get() const {
+ return paramsFlattened;
+}
+
+status_t Parameters::buildFastInfo() {
+
+ camera_metadata_ro_entry_t activeArraySize =
+ staticInfo(ANDROID_SENSOR_INFO_ACTIVE_ARRAY_SIZE, 2, 2);
+ if (!activeArraySize.count) return NO_INIT;
+ int32_t arrayWidth = activeArraySize.data.i32[0];
+ int32_t arrayHeight = activeArraySize.data.i32[1];
+
+ camera_metadata_ro_entry_t availableFaceDetectModes =
+ staticInfo(ANDROID_STATISTICS_INFO_AVAILABLE_FACE_DETECT_MODES);
+ if (!availableFaceDetectModes.count) return NO_INIT;
+
+ uint8_t bestFaceDetectMode =
+ ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
+ for (size_t i = 0 ; i < availableFaceDetectModes.count; i++) {
+ switch (availableFaceDetectModes.data.u8[i]) {
+ case ANDROID_STATISTICS_FACE_DETECT_MODE_OFF:
+ break;
+ case ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE:
+ if (bestFaceDetectMode !=
+ ANDROID_STATISTICS_FACE_DETECT_MODE_FULL) {
+ bestFaceDetectMode =
+ ANDROID_STATISTICS_FACE_DETECT_MODE_SIMPLE;
+ }
+ break;
+ case ANDROID_STATISTICS_FACE_DETECT_MODE_FULL:
+ bestFaceDetectMode =
+ ANDROID_STATISTICS_FACE_DETECT_MODE_FULL;
+ break;
+ default:
+ ALOGE("%s: Camera %d: Unknown face detect mode %d:",
+ __FUNCTION__, cameraId,
+ availableFaceDetectModes.data.u8[i]);
+ return NO_INIT;
+ }
+ }
+
+ camera_metadata_ro_entry_t maxFacesDetected =
+ staticInfo(ANDROID_STATISTICS_INFO_MAX_FACE_COUNT, 1, 1);
+ if (!maxFacesDetected.count) return NO_INIT;
+
+ int32_t maxFaces = maxFacesDetected.data.i32[0];
+
+ camera_metadata_ro_entry_t availableSceneModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_SCENE_MODES);
+ camera_metadata_ro_entry_t sceneModeOverrides =
+ staticInfo(ANDROID_CONTROL_SCENE_MODE_OVERRIDES);
+ camera_metadata_ro_entry_t minFocusDistance =
+ staticInfo(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ bool fixedLens = (minFocusDistance.data.f[0] == 0);
+
+ if (sceneModeOverrides.count > 0) {
+ // sceneModeOverrides is defined to have 3 entries for each scene mode,
+ // which are AE, AWB, and AF override modes the HAL wants for that scene
+ // mode.
+ const size_t kModesPerSceneMode = 3;
+ if (sceneModeOverrides.count !=
+ availableSceneModes.count * kModesPerSceneMode) {
+ ALOGE("%s: Camera %d: Scene mode override list is an "
+ "unexpected size: %d (expected %d)", __FUNCTION__,
+ cameraId, sceneModeOverrides.count,
+ availableSceneModes.count);
+ return NO_INIT;
+ }
+ for (size_t i = 0; i < availableSceneModes.count; i++) {
+ DeviceInfo::OverrideModes modes;
+ uint8_t aeMode =
+ sceneModeOverrides.data.u8[i * kModesPerSceneMode + 0];
+ switch(aeMode) {
+ case ANDROID_CONTROL_AE_MODE_ON:
+ modes.flashMode = FLASH_MODE_OFF;
+ break;
+ case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH:
+ modes.flashMode = FLASH_MODE_AUTO;
+ break;
+ case ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH:
+ modes.flashMode = FLASH_MODE_ON;
+ break;
+ case ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE:
+ modes.flashMode = FLASH_MODE_RED_EYE;
+ break;
+ default:
+ ALOGE("%s: Unknown override AE mode: %d", __FUNCTION__,
+ aeMode);
+ modes.flashMode = FLASH_MODE_INVALID;
+ break;
+ }
+ modes.wbMode =
+ sceneModeOverrides.data.u8[i * kModesPerSceneMode + 1];
+ uint8_t afMode =
+ sceneModeOverrides.data.u8[i * kModesPerSceneMode + 2];
+ switch(afMode) {
+ case ANDROID_CONTROL_AF_MODE_OFF:
+ modes.focusMode = fixedLens ?
+ FOCUS_MODE_FIXED : FOCUS_MODE_INFINITY;
+ break;
+ case ANDROID_CONTROL_AF_MODE_AUTO:
+ case ANDROID_CONTROL_AF_MODE_MACRO:
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO:
+ case ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE:
+ case ANDROID_CONTROL_AF_MODE_EDOF:
+ modes.focusMode = static_cast<focusMode_t>(afMode);
+ break;
+ default:
+ ALOGE("%s: Unknown override AF mode: %d", __FUNCTION__,
+ afMode);
+ modes.focusMode = FOCUS_MODE_INVALID;
+ break;
+ }
+ fastInfo.sceneModeOverrides.add(availableSceneModes.data.u8[i],
+ modes);
+ }
+ }
+
+ fastInfo.arrayWidth = arrayWidth;
+ fastInfo.arrayHeight = arrayHeight;
+ fastInfo.bestFaceDetectMode = bestFaceDetectMode;
+ fastInfo.maxFaces = maxFaces;
+ return OK;
+}
+
+status_t Parameters::buildQuirks() {
+ camera_metadata_ro_entry_t entry;
+ entry = info->find(ANDROID_QUIRKS_TRIGGER_AF_WITH_AUTO);
+ quirks.triggerAfWithAuto = (entry.count != 0 && entry.data.u8[0] == 1);
+ ALOGV_IF(quirks.triggerAfWithAuto, "Camera %d: Quirk triggerAfWithAuto enabled",
+ cameraId);
+
+ entry = info->find(ANDROID_QUIRKS_USE_ZSL_FORMAT);
+ quirks.useZslFormat = (entry.count != 0 && entry.data.u8[0] == 1);
+ ALOGV_IF(quirks.useZslFormat, "Camera %d: Quirk useZslFormat enabled",
+ cameraId);
+
+ entry = info->find(ANDROID_QUIRKS_METERING_CROP_REGION);
+ quirks.meteringCropRegion = (entry.count != 0 && entry.data.u8[0] == 1);
+ ALOGV_IF(quirks.meteringCropRegion, "Camera %d: Quirk meteringCropRegion"
+ " enabled", cameraId);
+
+ return OK;
+}
+
+camera_metadata_ro_entry_t Parameters::staticInfo(uint32_t tag,
+ size_t minCount, size_t maxCount) const {
+ status_t res;
+ camera_metadata_ro_entry_t entry = info->find(tag);
+
+ if (CC_UNLIKELY( entry.count == 0 )) {
+ const char* tagSection = get_camera_metadata_section_name(tag);
+ if (tagSection == NULL) tagSection = "<unknown>";
+ const char* tagName = get_camera_metadata_tag_name(tag);
+ if (tagName == NULL) tagName = "<unknown>";
+
+ ALOGE("Error finding static metadata entry '%s.%s' (%x)",
+ tagSection, tagName, tag);
+ } else if (CC_UNLIKELY(
+ (minCount != 0 && entry.count < minCount) ||
+ (maxCount != 0 && entry.count > maxCount) ) ) {
+ const char* tagSection = get_camera_metadata_section_name(tag);
+ if (tagSection == NULL) tagSection = "<unknown>";
+ const char* tagName = get_camera_metadata_tag_name(tag);
+ if (tagName == NULL) tagName = "<unknown>";
+ ALOGE("Malformed static metadata entry '%s.%s' (%x):"
+ "Expected between %d and %d values, but got %d values",
+ tagSection, tagName, tag, minCount, maxCount, entry.count);
+ }
+
+ return entry;
+}
+
+status_t Parameters::set(const String8& paramString) {
+ status_t res;
+
+ CameraParameters newParams(paramString);
+
+ // TODO: Currently ignoring any changes to supposedly read-only parameters
+ // such as supported preview sizes, etc. Should probably produce an error if
+ // they're changed.
+
+ /** Extract and verify new parameters */
+
+ size_t i;
+
+ Parameters validatedParams(*this);
+
+ // PREVIEW_SIZE
+ newParams.getPreviewSize(&validatedParams.previewWidth,
+ &validatedParams.previewHeight);
+
+ if (validatedParams.previewWidth != previewWidth ||
+ validatedParams.previewHeight != previewHeight) {
+ if (state >= PREVIEW) {
+ ALOGE("%s: Preview size cannot be updated when preview "
+ "is active! (Currently %d x %d, requested %d x %d",
+ __FUNCTION__,
+ previewWidth, previewHeight,
+ validatedParams.previewWidth, validatedParams.previewHeight);
+ return BAD_VALUE;
+ }
+ camera_metadata_ro_entry_t availablePreviewSizes =
+ staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES);
+ for (i = 0; i < availablePreviewSizes.count; i += 2 ) {
+ if ((availablePreviewSizes.data.i32[i] ==
+ validatedParams.previewWidth) &&
+ (availablePreviewSizes.data.i32[i+1] ==
+ validatedParams.previewHeight)) break;
+ }
+ if (i == availablePreviewSizes.count) {
+ ALOGE("%s: Requested preview size %d x %d is not supported",
+ __FUNCTION__, validatedParams.previewWidth,
+ validatedParams.previewHeight);
+ return BAD_VALUE;
+ }
+ }
+
+ // RECORDING_HINT (always supported)
+ validatedParams.recordingHint = boolFromString(
+ newParams.get(CameraParameters::KEY_RECORDING_HINT) );
+ bool recordingHintChanged = validatedParams.recordingHint != recordingHint;
+ ALOGV_IF(recordingHintChanged, "%s: Recording hint changed to %d",
+ __FUNCTION__, recordingHintChanged);
+
+ // PREVIEW_FPS_RANGE
+ bool fpsRangeChanged = false;
+ newParams.getPreviewFpsRange(&validatedParams.previewFpsRange[0],
+ &validatedParams.previewFpsRange[1]);
+ validatedParams.previewFpsRange[0] /= kFpsToApiScale;
+ validatedParams.previewFpsRange[1] /= kFpsToApiScale;
+
+ if (validatedParams.previewFpsRange[0] != previewFpsRange[0] ||
+ validatedParams.previewFpsRange[1] != previewFpsRange[1]) {
+ fpsRangeChanged = true;
+ camera_metadata_ro_entry_t availablePreviewFpsRanges =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, 2);
+ for (i = 0; i < availablePreviewFpsRanges.count; i += 2) {
+ if ((availablePreviewFpsRanges.data.i32[i] ==
+ validatedParams.previewFpsRange[0]) &&
+ (availablePreviewFpsRanges.data.i32[i+1] ==
+ validatedParams.previewFpsRange[1]) ) {
+ break;
+ }
+ }
+ if (i == availablePreviewFpsRanges.count) {
+ ALOGE("%s: Requested preview FPS range %d - %d is not supported",
+ __FUNCTION__, validatedParams.previewFpsRange[0],
+ validatedParams.previewFpsRange[1]);
+ return BAD_VALUE;
+ }
+ validatedParams.previewFps =
+ fpsFromRange(validatedParams.previewFpsRange[0],
+ validatedParams.previewFpsRange[1]);
+ newParams.setPreviewFrameRate(validatedParams.previewFps);
+ }
+
+ // PREVIEW_FORMAT
+ validatedParams.previewFormat =
+ formatStringToEnum(newParams.getPreviewFormat());
+ if (validatedParams.previewFormat != previewFormat) {
+ if (state >= PREVIEW) {
+ ALOGE("%s: Preview format cannot be updated when preview "
+ "is active!", __FUNCTION__);
+ return BAD_VALUE;
+ }
+ camera_metadata_ro_entry_t availableFormats =
+ staticInfo(ANDROID_SCALER_AVAILABLE_FORMATS);
+ for (i = 0; i < availableFormats.count; i++) {
+ if (availableFormats.data.i32[i] == validatedParams.previewFormat)
+ break;
+ }
+ if (i == availableFormats.count) {
+ ALOGE("%s: Requested preview format %s (0x%x) is not supported",
+ __FUNCTION__, newParams.getPreviewFormat(),
+ validatedParams.previewFormat);
+ return BAD_VALUE;
+ }
+ }
+
+ // PREVIEW_FRAME_RATE
+ // Deprecated, only use if the preview fps range is unchanged this time.
+ // The single-value FPS is the same as the minimum of the range.
+ if (!fpsRangeChanged) {
+ validatedParams.previewFps = newParams.getPreviewFrameRate();
+ if (validatedParams.previewFps != previewFps || recordingHintChanged) {
+ camera_metadata_ro_entry_t availableFrameRates =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
+ /**
+ * If recording hint is set, find the range that encompasses
+ * previewFps with the largest min index.
+ *
+ * If recording hint is not set, find the range with previewFps
+ * with the smallest min index.
+ *
+ * Either way, in case of multiple ranges, break the tie by
+ * selecting the smaller range.
+ */
+ int targetFps = validatedParams.previewFps;
+ // all ranges which have targetFps
+ Vector<Range> candidateRanges;
+ for (i = 0; i < availableFrameRates.count; i+=2) {
+ Range r = {
+ availableFrameRates.data.i32[i],
+ availableFrameRates.data.i32[i+1]
+ };
+
+ if (r.min <= targetFps && targetFps <= r.max) {
+ candidateRanges.push(r);
+ }
+ }
+ if (candidateRanges.isEmpty()) {
+ ALOGE("%s: Requested preview frame rate %d is not supported",
+ __FUNCTION__, validatedParams.previewFps);
+ return BAD_VALUE;
+ }
+ // most applicable range with targetFps
+ Range bestRange = candidateRanges[0];
+ for (i = 1; i < candidateRanges.size(); ++i) {
+ Range r = candidateRanges[i];
+
+ // Find by largest minIndex in recording mode
+ if (validatedParams.recordingHint) {
+ if (r.min > bestRange.min) {
+ bestRange = r;
+ }
+ else if (r.min == bestRange.min && r.max < bestRange.max) {
+ bestRange = r;
+ }
+ }
+ // Find by smallest minIndex in preview mode
+ else {
+ if (r.min < bestRange.min) {
+ bestRange = r;
+ }
+ else if (r.min == bestRange.min && r.max < bestRange.max) {
+ bestRange = r;
+ }
+ }
+ }
+
+ validatedParams.previewFpsRange[0] =
+ bestRange.min;
+ validatedParams.previewFpsRange[1] =
+ bestRange.max;
+
+ ALOGV("%s: New preview FPS range: %d, %d, recordingHint = %d",
+ __FUNCTION__,
+ validatedParams.previewFpsRange[0],
+ validatedParams.previewFpsRange[1],
+ validatedParams.recordingHint);
+ }
+ newParams.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,
+ String8::format("%d,%d",
+ validatedParams.previewFpsRange[0] * kFpsToApiScale,
+ validatedParams.previewFpsRange[1] * kFpsToApiScale));
+
+ }
+
+ // PICTURE_SIZE
+ newParams.getPictureSize(&validatedParams.pictureWidth,
+ &validatedParams.pictureHeight);
+ if (validatedParams.pictureWidth == pictureWidth ||
+ validatedParams.pictureHeight == pictureHeight) {
+ camera_metadata_ro_entry_t availablePictureSizes =
+ staticInfo(ANDROID_SCALER_AVAILABLE_JPEG_SIZES);
+ for (i = 0; i < availablePictureSizes.count; i+=2) {
+ if ((availablePictureSizes.data.i32[i] ==
+ validatedParams.pictureWidth) &&
+ (availablePictureSizes.data.i32[i+1] ==
+ validatedParams.pictureHeight)) break;
+ }
+ if (i == availablePictureSizes.count) {
+ ALOGE("%s: Requested picture size %d x %d is not supported",
+ __FUNCTION__, validatedParams.pictureWidth,
+ validatedParams.pictureHeight);
+ return BAD_VALUE;
+ }
+ }
+
+ // JPEG_THUMBNAIL_WIDTH/HEIGHT
+ validatedParams.jpegThumbSize[0] =
+ newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
+ validatedParams.jpegThumbSize[1] =
+ newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT);
+ if (validatedParams.jpegThumbSize[0] != jpegThumbSize[0] ||
+ validatedParams.jpegThumbSize[1] != jpegThumbSize[1]) {
+ camera_metadata_ro_entry_t availableJpegThumbSizes =
+ staticInfo(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES);
+ for (i = 0; i < availableJpegThumbSizes.count; i+=2) {
+ if ((availableJpegThumbSizes.data.i32[i] ==
+ validatedParams.jpegThumbSize[0]) &&
+ (availableJpegThumbSizes.data.i32[i+1] ==
+ validatedParams.jpegThumbSize[1])) break;
+ }
+ if (i == availableJpegThumbSizes.count) {
+ ALOGE("%s: Requested JPEG thumbnail size %d x %d is not supported",
+ __FUNCTION__, validatedParams.jpegThumbSize[0],
+ validatedParams.jpegThumbSize[1]);
+ return BAD_VALUE;
+ }
+ }
+
+ // JPEG_THUMBNAIL_QUALITY
+ int quality = newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY);
+ // also makes sure quality fits in uint8_t
+ if (quality < 0 || quality > 100) {
+ ALOGE("%s: Requested JPEG thumbnail quality %d is not supported",
+ __FUNCTION__, quality);
+ return BAD_VALUE;
+ }
+ validatedParams.jpegThumbQuality = quality;
+
+ // JPEG_QUALITY
+ quality = newParams.getInt(CameraParameters::KEY_JPEG_QUALITY);
+ // also makes sure quality fits in uint8_t
+ if (quality < 0 || quality > 100) {
+ ALOGE("%s: Requested JPEG quality %d is not supported",
+ __FUNCTION__, quality);
+ return BAD_VALUE;
+ }
+ validatedParams.jpegQuality = quality;
+
+ // ROTATION
+ validatedParams.jpegRotation =
+ newParams.getInt(CameraParameters::KEY_ROTATION);
+ if (validatedParams.jpegRotation != 0 &&
+ validatedParams.jpegRotation != 90 &&
+ validatedParams.jpegRotation != 180 &&
+ validatedParams.jpegRotation != 270) {
+ ALOGE("%s: Requested picture rotation angle %d is not supported",
+ __FUNCTION__, validatedParams.jpegRotation);
+ return BAD_VALUE;
+ }
+
+ // GPS
+
+ const char *gpsLatStr =
+ newParams.get(CameraParameters::KEY_GPS_LATITUDE);
+ if (gpsLatStr != NULL) {
+ const char *gpsLongStr =
+ newParams.get(CameraParameters::KEY_GPS_LONGITUDE);
+ const char *gpsAltitudeStr =
+ newParams.get(CameraParameters::KEY_GPS_ALTITUDE);
+ const char *gpsTimeStr =
+ newParams.get(CameraParameters::KEY_GPS_TIMESTAMP);
+ const char *gpsProcMethodStr =
+ newParams.get(CameraParameters::KEY_GPS_PROCESSING_METHOD);
+ if (gpsLongStr == NULL ||
+ gpsAltitudeStr == NULL ||
+ gpsTimeStr == NULL ||
+ gpsProcMethodStr == NULL) {
+ ALOGE("%s: Incomplete set of GPS parameters provided",
+ __FUNCTION__);
+ return BAD_VALUE;
+ }
+ char *endPtr;
+ errno = 0;
+ validatedParams.gpsCoordinates[0] = strtod(gpsLatStr, &endPtr);
+ if (errno || endPtr == gpsLatStr) {
+ ALOGE("%s: Malformed GPS latitude: %s", __FUNCTION__, gpsLatStr);
+ return BAD_VALUE;
+ }
+ errno = 0;
+ validatedParams.gpsCoordinates[1] = strtod(gpsLongStr, &endPtr);
+ if (errno || endPtr == gpsLongStr) {
+ ALOGE("%s: Malformed GPS longitude: %s", __FUNCTION__, gpsLongStr);
+ return BAD_VALUE;
+ }
+ errno = 0;
+ validatedParams.gpsCoordinates[2] = strtod(gpsAltitudeStr, &endPtr);
+ if (errno || endPtr == gpsAltitudeStr) {
+ ALOGE("%s: Malformed GPS altitude: %s", __FUNCTION__,
+ gpsAltitudeStr);
+ return BAD_VALUE;
+ }
+ errno = 0;
+ validatedParams.gpsTimestamp = strtoll(gpsTimeStr, &endPtr, 10);
+ if (errno || endPtr == gpsTimeStr) {
+ ALOGE("%s: Malformed GPS timestamp: %s", __FUNCTION__, gpsTimeStr);
+ return BAD_VALUE;
+ }
+ validatedParams.gpsProcessingMethod = gpsProcMethodStr;
+
+ validatedParams.gpsEnabled = true;
+ } else {
+ validatedParams.gpsEnabled = false;
+ }
+
+ // EFFECT
+ validatedParams.effectMode = effectModeStringToEnum(
+ newParams.get(CameraParameters::KEY_EFFECT) );
+ if (validatedParams.effectMode != effectMode) {
+ camera_metadata_ro_entry_t availableEffectModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_EFFECTS);
+ for (i = 0; i < availableEffectModes.count; i++) {
+ if (validatedParams.effectMode == availableEffectModes.data.u8[i]) break;
+ }
+ if (i == availableEffectModes.count) {
+ ALOGE("%s: Requested effect mode \"%s\" is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_EFFECT) );
+ return BAD_VALUE;
+ }
+ }
+
+ // ANTIBANDING
+ validatedParams.antibandingMode = abModeStringToEnum(
+ newParams.get(CameraParameters::KEY_ANTIBANDING) );
+ if (validatedParams.antibandingMode != antibandingMode) {
+ camera_metadata_ro_entry_t availableAbModes =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES);
+ for (i = 0; i < availableAbModes.count; i++) {
+ if (validatedParams.antibandingMode == availableAbModes.data.u8[i])
+ break;
+ }
+ if (i == availableAbModes.count) {
+ ALOGE("%s: Requested antibanding mode \"%s\" is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_ANTIBANDING));
+ return BAD_VALUE;
+ }
+ }
+
+ // SCENE_MODE
+ validatedParams.sceneMode = sceneModeStringToEnum(
+ newParams.get(CameraParameters::KEY_SCENE_MODE) );
+ if (validatedParams.sceneMode != sceneMode &&
+ validatedParams.sceneMode !=
+ ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED) {
+ camera_metadata_ro_entry_t availableSceneModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_SCENE_MODES);
+ for (i = 0; i < availableSceneModes.count; i++) {
+ if (validatedParams.sceneMode == availableSceneModes.data.u8[i])
+ break;
+ }
+ if (i == availableSceneModes.count) {
+ ALOGE("%s: Requested scene mode \"%s\" is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_SCENE_MODE));
+ return BAD_VALUE;
+ }
+ }
+ bool sceneModeSet =
+ validatedParams.sceneMode != ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
+
+ // FLASH_MODE
+ if (sceneModeSet) {
+ validatedParams.flashMode =
+ fastInfo.sceneModeOverrides.
+ valueFor(validatedParams.sceneMode).flashMode;
+ } else {
+ validatedParams.flashMode = FLASH_MODE_INVALID;
+ }
+ if (validatedParams.flashMode == FLASH_MODE_INVALID) {
+ validatedParams.flashMode = flashModeStringToEnum(
+ newParams.get(CameraParameters::KEY_FLASH_MODE) );
+ }
+
+ if (validatedParams.flashMode != flashMode) {
+ camera_metadata_ro_entry_t flashAvailable =
+ staticInfo(ANDROID_FLASH_INFO_AVAILABLE, 1, 1);
+ if (!flashAvailable.data.u8[0] &&
+ validatedParams.flashMode != Parameters::FLASH_MODE_OFF) {
+ ALOGE("%s: Requested flash mode \"%s\" is not supported: "
+ "No flash on device", __FUNCTION__,
+ newParams.get(CameraParameters::KEY_FLASH_MODE));
+ return BAD_VALUE;
+ } else if (validatedParams.flashMode == Parameters::FLASH_MODE_RED_EYE) {
+ camera_metadata_ro_entry_t availableAeModes =
+ staticInfo(ANDROID_CONTROL_AE_AVAILABLE_MODES);
+ for (i = 0; i < availableAeModes.count; i++) {
+ if (validatedParams.flashMode == availableAeModes.data.u8[i])
+ break;
+ }
+ if (i == availableAeModes.count) {
+ ALOGE("%s: Requested flash mode \"%s\" is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_FLASH_MODE));
+ return BAD_VALUE;
+ }
+ } else if (validatedParams.flashMode == -1) {
+ ALOGE("%s: Requested flash mode \"%s\" is unknown",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_FLASH_MODE));
+ return BAD_VALUE;
+ }
+ // Update in case of override
+ newParams.set(CameraParameters::KEY_FLASH_MODE,
+ flashModeEnumToString(validatedParams.flashMode));
+ }
+
+ // WHITE_BALANCE
+ if (sceneModeSet) {
+ validatedParams.wbMode =
+ fastInfo.sceneModeOverrides.
+ valueFor(validatedParams.sceneMode).wbMode;
+ } else {
+ validatedParams.wbMode = ANDROID_CONTROL_AWB_MODE_OFF;
+ }
+ if (validatedParams.wbMode == ANDROID_CONTROL_AWB_MODE_OFF) {
+ validatedParams.wbMode = wbModeStringToEnum(
+ newParams.get(CameraParameters::KEY_WHITE_BALANCE) );
+ }
+ if (validatedParams.wbMode != wbMode) {
+ camera_metadata_ro_entry_t availableWbModes =
+ staticInfo(ANDROID_CONTROL_AWB_AVAILABLE_MODES);
+ for (i = 0; i < availableWbModes.count; i++) {
+ if (validatedParams.wbMode == availableWbModes.data.u8[i]) break;
+ }
+ if (i == availableWbModes.count) {
+ ALOGE("%s: Requested white balance mode %s is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_WHITE_BALANCE));
+ return BAD_VALUE;
+ }
+ // Update in case of override
+ newParams.set(CameraParameters::KEY_WHITE_BALANCE,
+ wbModeEnumToString(validatedParams.wbMode));
+ }
+
+ // FOCUS_MODE
+ if (sceneModeSet) {
+ validatedParams.focusMode =
+ fastInfo.sceneModeOverrides.
+ valueFor(validatedParams.sceneMode).focusMode;
+ } else {
+ validatedParams.focusMode = FOCUS_MODE_INVALID;
+ }
+ if (validatedParams.focusMode == FOCUS_MODE_INVALID) {
+ validatedParams.focusMode = focusModeStringToEnum(
+ newParams.get(CameraParameters::KEY_FOCUS_MODE) );
+ }
+ if (validatedParams.focusMode != focusMode) {
+ validatedParams.currentAfTriggerId = -1;
+ if (validatedParams.focusMode != Parameters::FOCUS_MODE_FIXED) {
+ camera_metadata_ro_entry_t minFocusDistance =
+ staticInfo(ANDROID_LENS_INFO_MINIMUM_FOCUS_DISTANCE);
+ if (minFocusDistance.data.f[0] == 0) {
+ ALOGE("%s: Requested focus mode \"%s\" is not available: "
+ "fixed focus lens",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_FOCUS_MODE));
+ return BAD_VALUE;
+ } else if (validatedParams.focusMode !=
+ Parameters::FOCUS_MODE_INFINITY) {
+ camera_metadata_ro_entry_t availableFocusModes =
+ staticInfo(ANDROID_CONTROL_AF_AVAILABLE_MODES);
+ for (i = 0; i < availableFocusModes.count; i++) {
+ if (validatedParams.focusMode ==
+ availableFocusModes.data.u8[i]) break;
+ }
+ if (i == availableFocusModes.count) {
+ ALOGE("%s: Requested focus mode \"%s\" is not supported",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_FOCUS_MODE));
+ return BAD_VALUE;
+ }
+ }
+ }
+ validatedParams.focusState = ANDROID_CONTROL_AF_STATE_INACTIVE;
+ // Always reset shadow focus mode to avoid reverting settings
+ validatedParams.shadowFocusMode = FOCUS_MODE_INVALID;
+ // Update in case of override
+ newParams.set(CameraParameters::KEY_FOCUS_MODE,
+ focusModeEnumToString(validatedParams.focusMode));
+ } else {
+ validatedParams.currentAfTriggerId = currentAfTriggerId;
+ }
+
+ // FOCUS_AREAS
+ res = parseAreas(newParams.get(CameraParameters::KEY_FOCUS_AREAS),
+ &validatedParams.focusingAreas);
+ size_t max3aRegions =
+ (size_t)staticInfo(ANDROID_CONTROL_MAX_REGIONS, 1, 1).data.i32[0];
+ if (res == OK) res = validateAreas(validatedParams.focusingAreas,
+ max3aRegions, AREA_KIND_FOCUS);
+ if (res != OK) {
+ ALOGE("%s: Requested focus areas are malformed: %s",
+ __FUNCTION__, newParams.get(CameraParameters::KEY_FOCUS_AREAS));
+ return BAD_VALUE;
+ }
+
+ // EXPOSURE_COMPENSATION
+ validatedParams.exposureCompensation =
+ newParams.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
+ camera_metadata_ro_entry_t exposureCompensationRange =
+ staticInfo(ANDROID_CONTROL_AE_COMPENSATION_RANGE);
+ if ((validatedParams.exposureCompensation <
+ exposureCompensationRange.data.i32[0]) ||
+ (validatedParams.exposureCompensation >
+ exposureCompensationRange.data.i32[1])) {
+ ALOGE("%s: Requested exposure compensation index is out of bounds: %d",
+ __FUNCTION__, validatedParams.exposureCompensation);
+ return BAD_VALUE;
+ }
+
+ // AUTO_EXPOSURE_LOCK (always supported)
+ validatedParams.autoExposureLock = boolFromString(
+ newParams.get(CameraParameters::KEY_AUTO_EXPOSURE_LOCK));
+
+ // AUTO_WHITEBALANCE_LOCK (always supported)
+ validatedParams.autoWhiteBalanceLock = boolFromString(
+ newParams.get(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK));
+
+ // METERING_AREAS
+ res = parseAreas(newParams.get(CameraParameters::KEY_METERING_AREAS),
+ &validatedParams.meteringAreas);
+ if (res == OK) {
+ res = validateAreas(validatedParams.meteringAreas, max3aRegions,
+ AREA_KIND_METERING);
+ }
+ if (res != OK) {
+ ALOGE("%s: Requested metering areas are malformed: %s",
+ __FUNCTION__,
+ newParams.get(CameraParameters::KEY_METERING_AREAS));
+ return BAD_VALUE;
+ }
+
+ // ZOOM
+ validatedParams.zoom = newParams.getInt(CameraParameters::KEY_ZOOM);
+ if (validatedParams.zoom < 0
+ || validatedParams.zoom >= (int)NUM_ZOOM_STEPS) {
+ ALOGE("%s: Requested zoom level %d is not supported",
+ __FUNCTION__, validatedParams.zoom);
+ return BAD_VALUE;
+ }
+
+ // VIDEO_SIZE
+ newParams.getVideoSize(&validatedParams.videoWidth,
+ &validatedParams.videoHeight);
+ if (validatedParams.videoWidth != videoWidth ||
+ validatedParams.videoHeight != videoHeight) {
+ if (state == RECORD) {
+ ALOGE("%s: Video size cannot be updated when recording is active!",
+ __FUNCTION__);
+ return BAD_VALUE;
+ }
+ camera_metadata_ro_entry_t availableVideoSizes =
+ staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES);
+ for (i = 0; i < availableVideoSizes.count; i += 2 ) {
+ if ((availableVideoSizes.data.i32[i] ==
+ validatedParams.videoWidth) &&
+ (availableVideoSizes.data.i32[i+1] ==
+ validatedParams.videoHeight)) break;
+ }
+ if (i == availableVideoSizes.count) {
+ ALOGE("%s: Requested video size %d x %d is not supported",
+ __FUNCTION__, validatedParams.videoWidth,
+ validatedParams.videoHeight);
+ return BAD_VALUE;
+ }
+ }
+
+ // VIDEO_STABILIZATION
+ validatedParams.videoStabilization = boolFromString(
+ newParams.get(CameraParameters::KEY_VIDEO_STABILIZATION) );
+ camera_metadata_ro_entry_t availableVideoStabilizationModes =
+ staticInfo(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES);
+ if (validatedParams.videoStabilization &&
+ availableVideoStabilizationModes.count == 1) {
+ ALOGE("%s: Video stabilization not supported", __FUNCTION__);
+ }
+
+ /** Update internal parameters */
+
+ *this = validatedParams;
+
+ // Need to flatten again in case of overrides
+ paramsFlattened = newParams.flatten();
+ params = newParams;
+
+ return OK;
+}
+
+status_t Parameters::updateRequest(CameraMetadata *request) const {
+ ATRACE_CALL();
+ status_t res;
+
+ uint8_t metadataMode = ANDROID_REQUEST_METADATA_MODE_FULL;
+ res = request->update(ANDROID_REQUEST_METADATA_MODE,
+ &metadataMode, 1);
+ if (res != OK) return res;
+
+ res = request->update(ANDROID_CONTROL_AE_TARGET_FPS_RANGE,
+ previewFpsRange, 2);
+ if (res != OK) return res;
+
+ uint8_t reqWbLock = autoWhiteBalanceLock ?
+ ANDROID_CONTROL_AWB_LOCK_ON : ANDROID_CONTROL_AWB_LOCK_OFF;
+ res = request->update(ANDROID_CONTROL_AWB_LOCK,
+ &reqWbLock, 1);
+
+ res = request->update(ANDROID_CONTROL_EFFECT_MODE,
+ &effectMode, 1);
+ if (res != OK) return res;
+ res = request->update(ANDROID_CONTROL_AE_ANTIBANDING_MODE,
+ &antibandingMode, 1);
+ if (res != OK) return res;
+
+ // android.hardware.Camera requires that when face detect is enabled, the
+ // camera is in a face-priority mode. HAL2 splits this into separate parts
+ // (face detection statistics and face priority scene mode). Map from other
+ // to the other.
+ bool sceneModeActive =
+ sceneMode != (uint8_t)ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
+ uint8_t reqControlMode = ANDROID_CONTROL_MODE_AUTO;
+ if (enableFaceDetect || sceneModeActive) {
+ reqControlMode = ANDROID_CONTROL_MODE_USE_SCENE_MODE;
+ }
+ res = request->update(ANDROID_CONTROL_MODE,
+ &reqControlMode, 1);
+ if (res != OK) return res;
+
+ uint8_t reqSceneMode =
+ sceneModeActive ? sceneMode :
+ enableFaceDetect ? (uint8_t)ANDROID_CONTROL_SCENE_MODE_FACE_PRIORITY :
+ (uint8_t)ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED;
+ res = request->update(ANDROID_CONTROL_SCENE_MODE,
+ &reqSceneMode, 1);
+ if (res != OK) return res;
+
+ uint8_t reqFlashMode = ANDROID_FLASH_MODE_OFF;
+ uint8_t reqAeMode = ANDROID_CONTROL_AE_MODE_OFF;
+ switch (flashMode) {
+ case Parameters::FLASH_MODE_OFF:
+ reqAeMode = ANDROID_CONTROL_AE_MODE_ON; break;
+ case Parameters::FLASH_MODE_AUTO:
+ reqAeMode = ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH; break;
+ case Parameters::FLASH_MODE_ON:
+ reqAeMode = ANDROID_CONTROL_AE_MODE_ON_ALWAYS_FLASH; break;
+ case Parameters::FLASH_MODE_TORCH:
+ reqAeMode = ANDROID_CONTROL_AE_MODE_ON;
+ reqFlashMode = ANDROID_FLASH_MODE_TORCH;
+ break;
+ case Parameters::FLASH_MODE_RED_EYE:
+ reqAeMode = ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE; break;
+ default:
+ ALOGE("%s: Camera %d: Unknown flash mode %d", __FUNCTION__,
+ cameraId, flashMode);
+ return BAD_VALUE;
+ }
+ res = request->update(ANDROID_FLASH_MODE,
+ &reqFlashMode, 1);
+ if (res != OK) return res;
+ res = request->update(ANDROID_CONTROL_AE_MODE,
+ &reqAeMode, 1);
+ if (res != OK) return res;
+
+ uint8_t reqAeLock = autoExposureLock ?
+ ANDROID_CONTROL_AE_LOCK_ON : ANDROID_CONTROL_AE_LOCK_OFF;
+ res = request->update(ANDROID_CONTROL_AE_LOCK,
+ &reqAeLock, 1);
+ if (res != OK) return res;
+
+ res = request->update(ANDROID_CONTROL_AWB_MODE,
+ &wbMode, 1);
+ if (res != OK) return res;
+
+ float reqFocusDistance = 0; // infinity focus in diopters
+ uint8_t reqFocusMode = ANDROID_CONTROL_AF_MODE_OFF;
+ switch (focusMode) {
+ case Parameters::FOCUS_MODE_AUTO:
+ case Parameters::FOCUS_MODE_MACRO:
+ case Parameters::FOCUS_MODE_CONTINUOUS_VIDEO:
+ case Parameters::FOCUS_MODE_CONTINUOUS_PICTURE:
+ case Parameters::FOCUS_MODE_EDOF:
+ reqFocusMode = focusMode;
+ break;
+ case Parameters::FOCUS_MODE_INFINITY:
+ case Parameters::FOCUS_MODE_FIXED:
+ reqFocusMode = ANDROID_CONTROL_AF_MODE_OFF;
+ break;
+ default:
+ ALOGE("%s: Camera %d: Unknown focus mode %d", __FUNCTION__,
+ cameraId, focusMode);
+ return BAD_VALUE;
+ }
+ res = request->update(ANDROID_LENS_FOCUS_DISTANCE,
+ &reqFocusDistance, 1);
+ if (res != OK) return res;
+ res = request->update(ANDROID_CONTROL_AF_MODE,
+ &reqFocusMode, 1);
+ if (res != OK) return res;
+
+ size_t reqFocusingAreasSize = focusingAreas.size() * 5;
+ int32_t *reqFocusingAreas = new int32_t[reqFocusingAreasSize];
+ for (size_t i = 0; i < reqFocusingAreasSize; i += 5) {
+ if (focusingAreas[i].weight != 0) {
+ reqFocusingAreas[i + 0] =
+ normalizedXToArray(focusingAreas[i].left);
+ reqFocusingAreas[i + 1] =
+ normalizedYToArray(focusingAreas[i].top);
+ reqFocusingAreas[i + 2] =
+ normalizedXToArray(focusingAreas[i].right);
+ reqFocusingAreas[i + 3] =
+ normalizedYToArray(focusingAreas[i].bottom);
+ } else {
+ reqFocusingAreas[i + 0] = 0;
+ reqFocusingAreas[i + 1] = 0;
+ reqFocusingAreas[i + 2] = 0;
+ reqFocusingAreas[i + 3] = 0;
+ }
+ reqFocusingAreas[i + 4] = focusingAreas[i].weight;
+ }
+ res = request->update(ANDROID_CONTROL_AF_REGIONS,
+ reqFocusingAreas, reqFocusingAreasSize);
+ if (res != OK) return res;
+ delete[] reqFocusingAreas;
+
+ res = request->update(ANDROID_CONTROL_AE_EXPOSURE_COMPENSATION,
+ &exposureCompensation, 1);
+ if (res != OK) return res;
+
+ size_t reqMeteringAreasSize = meteringAreas.size() * 5;
+ int32_t *reqMeteringAreas = new int32_t[reqMeteringAreasSize];
+ for (size_t i = 0; i < reqMeteringAreasSize; i += 5) {
+ if (meteringAreas[i].weight != 0) {
+ reqMeteringAreas[i + 0] =
+ normalizedXToArray(meteringAreas[i].left);
+ reqMeteringAreas[i + 1] =
+ normalizedYToArray(meteringAreas[i].top);
+ reqMeteringAreas[i + 2] =
+ normalizedXToArray(meteringAreas[i].right);
+ reqMeteringAreas[i + 3] =
+ normalizedYToArray(meteringAreas[i].bottom);
+ } else {
+ reqMeteringAreas[i + 0] = 0;
+ reqMeteringAreas[i + 1] = 0;
+ reqMeteringAreas[i + 2] = 0;
+ reqMeteringAreas[i + 3] = 0;
+ }
+ reqMeteringAreas[i + 4] = meteringAreas[i].weight;
+ }
+ res = request->update(ANDROID_CONTROL_AE_REGIONS,
+ reqMeteringAreas, reqMeteringAreasSize);
+ if (res != OK) return res;
+
+ delete[] reqMeteringAreas;
+
+ /* don't include jpeg thumbnail size - it's valid for
+ it to be set to (0,0), meaning 'no thumbnail' */
+ CropRegion crop = calculateCropRegion( (CropRegion::Outputs)(
+ CropRegion::OUTPUT_PREVIEW |
+ CropRegion::OUTPUT_VIDEO |
+ CropRegion::OUTPUT_PICTURE ));
+ int32_t reqCropRegion[3] = {
+ static_cast<int32_t>(crop.left),
+ static_cast<int32_t>(crop.top),
+ static_cast<int32_t>(crop.width)
+ };
+ res = request->update(ANDROID_SCALER_CROP_REGION,
+ reqCropRegion, 3);
+ if (res != OK) return res;
+
+ uint8_t reqVstabMode = videoStabilization ?
+ ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_ON :
+ ANDROID_CONTROL_VIDEO_STABILIZATION_MODE_OFF;
+ res = request->update(ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
+ &reqVstabMode, 1);
+ if (res != OK) return res;
+
+ uint8_t reqFaceDetectMode = enableFaceDetect ?
+ fastInfo.bestFaceDetectMode :
+ (uint8_t)ANDROID_STATISTICS_FACE_DETECT_MODE_OFF;
+ res = request->update(ANDROID_STATISTICS_FACE_DETECT_MODE,
+ &reqFaceDetectMode, 1);
+ if (res != OK) return res;
+
+ return OK;
+}
+
+status_t Parameters::updateRequestJpeg(CameraMetadata *request) const {
+ status_t res;
+
+ res = request->update(ANDROID_JPEG_THUMBNAIL_SIZE,
+ jpegThumbSize, 2);
+ if (res != OK) return res;
+ res = request->update(ANDROID_JPEG_THUMBNAIL_QUALITY,
+ &jpegThumbQuality, 1);
+ if (res != OK) return res;
+ res = request->update(ANDROID_JPEG_QUALITY,
+ &jpegQuality, 1);
+ if (res != OK) return res;
+ res = request->update(
+ ANDROID_JPEG_ORIENTATION,
+ &jpegRotation, 1);
+ if (res != OK) return res;
+
+ if (gpsEnabled) {
+ res = request->update(
+ ANDROID_JPEG_GPS_COORDINATES,
+ gpsCoordinates, 3);
+ if (res != OK) return res;
+ res = request->update(
+ ANDROID_JPEG_GPS_TIMESTAMP,
+ &gpsTimestamp, 1);
+ if (res != OK) return res;
+ res = request->update(
+ ANDROID_JPEG_GPS_PROCESSING_METHOD,
+ gpsProcessingMethod);
+ if (res != OK) return res;
+ } else {
+ res = request->erase(ANDROID_JPEG_GPS_COORDINATES);
+ if (res != OK) return res;
+ res = request->erase(ANDROID_JPEG_GPS_TIMESTAMP);
+ if (res != OK) return res;
+ res = request->erase(ANDROID_JPEG_GPS_PROCESSING_METHOD);
+ if (res != OK) return res;
+ }
+ return OK;
+}
+
+
+const char* Parameters::getStateName(State state) {
+#define CASE_ENUM_TO_CHAR(x) case x: return(#x); break;
+ switch(state) {
+ CASE_ENUM_TO_CHAR(DISCONNECTED)
+ CASE_ENUM_TO_CHAR(STOPPED)
+ CASE_ENUM_TO_CHAR(WAITING_FOR_PREVIEW_WINDOW)
+ CASE_ENUM_TO_CHAR(PREVIEW)
+ CASE_ENUM_TO_CHAR(RECORD)
+ CASE_ENUM_TO_CHAR(STILL_CAPTURE)
+ CASE_ENUM_TO_CHAR(VIDEO_SNAPSHOT)
+ default:
+ return "Unknown state!";
+ break;
+ }
+#undef CASE_ENUM_TO_CHAR
+}
+
+int Parameters::formatStringToEnum(const char *format) {
+ return
+ !format ?
+ HAL_PIXEL_FORMAT_YCrCb_420_SP :
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_YUV422SP) ?
+ HAL_PIXEL_FORMAT_YCbCr_422_SP : // NV16
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_YUV420SP) ?
+ HAL_PIXEL_FORMAT_YCrCb_420_SP : // NV21
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_YUV422I) ?
+ HAL_PIXEL_FORMAT_YCbCr_422_I : // YUY2
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_YUV420P) ?
+ HAL_PIXEL_FORMAT_YV12 : // YV12
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_RGB565) ?
+ HAL_PIXEL_FORMAT_RGB_565 : // RGB565
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_RGBA8888) ?
+ HAL_PIXEL_FORMAT_RGBA_8888 : // RGB8888
+ !strcmp(format, CameraParameters::PIXEL_FORMAT_BAYER_RGGB) ?
+ HAL_PIXEL_FORMAT_RAW_SENSOR : // Raw sensor data
+ -1;
+}
+
+const char* Parameters::formatEnumToString(int format) {
+ const char *fmt;
+ switch(format) {
+ case HAL_PIXEL_FORMAT_YCbCr_422_SP: // NV16
+ fmt = CameraParameters::PIXEL_FORMAT_YUV422SP;
+ break;
+ case HAL_PIXEL_FORMAT_YCrCb_420_SP: // NV21
+ fmt = CameraParameters::PIXEL_FORMAT_YUV420SP;
+ break;
+ case HAL_PIXEL_FORMAT_YCbCr_422_I: // YUY2
+ fmt = CameraParameters::PIXEL_FORMAT_YUV422I;
+ break;
+ case HAL_PIXEL_FORMAT_YV12: // YV12
+ fmt = CameraParameters::PIXEL_FORMAT_YUV420P;
+ break;
+ case HAL_PIXEL_FORMAT_RGB_565: // RGB565
+ fmt = CameraParameters::PIXEL_FORMAT_RGB565;
+ break;
+ case HAL_PIXEL_FORMAT_RGBA_8888: // RGBA8888
+ fmt = CameraParameters::PIXEL_FORMAT_RGBA8888;
+ break;
+ case HAL_PIXEL_FORMAT_RAW_SENSOR:
+ ALOGW("Raw sensor preview format requested.");
+ fmt = CameraParameters::PIXEL_FORMAT_BAYER_RGGB;
+ break;
+ default:
+ ALOGE("%s: Unknown preview format: %x",
+ __FUNCTION__, format);
+ fmt = NULL;
+ break;
+ }
+ return fmt;
+}
+
+int Parameters::wbModeStringToEnum(const char *wbMode) {
+ return
+ !wbMode ?
+ ANDROID_CONTROL_AWB_MODE_AUTO :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_AUTO) ?
+ ANDROID_CONTROL_AWB_MODE_AUTO :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_INCANDESCENT) ?
+ ANDROID_CONTROL_AWB_MODE_INCANDESCENT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_FLUORESCENT) ?
+ ANDROID_CONTROL_AWB_MODE_FLUORESCENT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT) ?
+ ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_DAYLIGHT) ?
+ ANDROID_CONTROL_AWB_MODE_DAYLIGHT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT) ?
+ ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_TWILIGHT) ?
+ ANDROID_CONTROL_AWB_MODE_TWILIGHT :
+ !strcmp(wbMode, CameraParameters::WHITE_BALANCE_SHADE) ?
+ ANDROID_CONTROL_AWB_MODE_SHADE :
+ -1;
+}
+
+const char* Parameters::wbModeEnumToString(uint8_t wbMode) {
+ switch (wbMode) {
+ case ANDROID_CONTROL_AWB_MODE_AUTO:
+ return CameraParameters::WHITE_BALANCE_AUTO;
+ case ANDROID_CONTROL_AWB_MODE_INCANDESCENT:
+ return CameraParameters::WHITE_BALANCE_INCANDESCENT;
+ case ANDROID_CONTROL_AWB_MODE_FLUORESCENT:
+ return CameraParameters::WHITE_BALANCE_FLUORESCENT;
+ case ANDROID_CONTROL_AWB_MODE_WARM_FLUORESCENT:
+ return CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT;
+ case ANDROID_CONTROL_AWB_MODE_DAYLIGHT:
+ return CameraParameters::WHITE_BALANCE_DAYLIGHT;
+ case ANDROID_CONTROL_AWB_MODE_CLOUDY_DAYLIGHT:
+ return CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT;
+ case ANDROID_CONTROL_AWB_MODE_TWILIGHT:
+ return CameraParameters::WHITE_BALANCE_TWILIGHT;
+ case ANDROID_CONTROL_AWB_MODE_SHADE:
+ return CameraParameters::WHITE_BALANCE_SHADE;
+ default:
+ ALOGE("%s: Unknown AWB mode enum: %d",
+ __FUNCTION__, wbMode);
+ return "unknown";
+ }
+}
+
+int Parameters::effectModeStringToEnum(const char *effectMode) {
+ return
+ !effectMode ?
+ ANDROID_CONTROL_EFFECT_MODE_OFF :
+ !strcmp(effectMode, CameraParameters::EFFECT_NONE) ?
+ ANDROID_CONTROL_EFFECT_MODE_OFF :
+ !strcmp(effectMode, CameraParameters::EFFECT_MONO) ?
+ ANDROID_CONTROL_EFFECT_MODE_MONO :
+ !strcmp(effectMode, CameraParameters::EFFECT_NEGATIVE) ?
+ ANDROID_CONTROL_EFFECT_MODE_NEGATIVE :
+ !strcmp(effectMode, CameraParameters::EFFECT_SOLARIZE) ?
+ ANDROID_CONTROL_EFFECT_MODE_SOLARIZE :
+ !strcmp(effectMode, CameraParameters::EFFECT_SEPIA) ?
+ ANDROID_CONTROL_EFFECT_MODE_SEPIA :
+ !strcmp(effectMode, CameraParameters::EFFECT_POSTERIZE) ?
+ ANDROID_CONTROL_EFFECT_MODE_POSTERIZE :
+ !strcmp(effectMode, CameraParameters::EFFECT_WHITEBOARD) ?
+ ANDROID_CONTROL_EFFECT_MODE_WHITEBOARD :
+ !strcmp(effectMode, CameraParameters::EFFECT_BLACKBOARD) ?
+ ANDROID_CONTROL_EFFECT_MODE_BLACKBOARD :
+ !strcmp(effectMode, CameraParameters::EFFECT_AQUA) ?
+ ANDROID_CONTROL_EFFECT_MODE_AQUA :
+ -1;
+}
+
+int Parameters::abModeStringToEnum(const char *abMode) {
+ return
+ !abMode ?
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO :
+ !strcmp(abMode, CameraParameters::ANTIBANDING_AUTO) ?
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE_AUTO :
+ !strcmp(abMode, CameraParameters::ANTIBANDING_OFF) ?
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE_OFF :
+ !strcmp(abMode, CameraParameters::ANTIBANDING_50HZ) ?
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE_50HZ :
+ !strcmp(abMode, CameraParameters::ANTIBANDING_60HZ) ?
+ ANDROID_CONTROL_AE_ANTIBANDING_MODE_60HZ :
+ -1;
+}
+
+int Parameters::sceneModeStringToEnum(const char *sceneMode) {
+ return
+ !sceneMode ?
+ ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_AUTO) ?
+ ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_ACTION) ?
+ ANDROID_CONTROL_SCENE_MODE_ACTION :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_PORTRAIT) ?
+ ANDROID_CONTROL_SCENE_MODE_PORTRAIT :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_LANDSCAPE) ?
+ ANDROID_CONTROL_SCENE_MODE_LANDSCAPE :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_NIGHT) ?
+ ANDROID_CONTROL_SCENE_MODE_NIGHT :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_NIGHT_PORTRAIT) ?
+ ANDROID_CONTROL_SCENE_MODE_NIGHT_PORTRAIT :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_THEATRE) ?
+ ANDROID_CONTROL_SCENE_MODE_THEATRE :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_BEACH) ?
+ ANDROID_CONTROL_SCENE_MODE_BEACH :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_SNOW) ?
+ ANDROID_CONTROL_SCENE_MODE_SNOW :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_SUNSET) ?
+ ANDROID_CONTROL_SCENE_MODE_SUNSET :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_STEADYPHOTO) ?
+ ANDROID_CONTROL_SCENE_MODE_STEADYPHOTO :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_FIREWORKS) ?
+ ANDROID_CONTROL_SCENE_MODE_FIREWORKS :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_SPORTS) ?
+ ANDROID_CONTROL_SCENE_MODE_SPORTS :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_PARTY) ?
+ ANDROID_CONTROL_SCENE_MODE_PARTY :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_CANDLELIGHT) ?
+ ANDROID_CONTROL_SCENE_MODE_CANDLELIGHT :
+ !strcmp(sceneMode, CameraParameters::SCENE_MODE_BARCODE) ?
+ ANDROID_CONTROL_SCENE_MODE_BARCODE:
+ -1;
+}
+
+Parameters::Parameters::flashMode_t Parameters::flashModeStringToEnum(
+ const char *flashMode) {
+ return
+ !flashMode ?
+ Parameters::FLASH_MODE_INVALID :
+ !strcmp(flashMode, CameraParameters::FLASH_MODE_OFF) ?
+ Parameters::FLASH_MODE_OFF :
+ !strcmp(flashMode, CameraParameters::FLASH_MODE_AUTO) ?
+ Parameters::FLASH_MODE_AUTO :
+ !strcmp(flashMode, CameraParameters::FLASH_MODE_ON) ?
+ Parameters::FLASH_MODE_ON :
+ !strcmp(flashMode, CameraParameters::FLASH_MODE_RED_EYE) ?
+ Parameters::FLASH_MODE_RED_EYE :
+ !strcmp(flashMode, CameraParameters::FLASH_MODE_TORCH) ?
+ Parameters::FLASH_MODE_TORCH :
+ Parameters::FLASH_MODE_INVALID;
+}
+
+const char *Parameters::flashModeEnumToString(flashMode_t flashMode) {
+ switch (flashMode) {
+ case FLASH_MODE_OFF:
+ return CameraParameters::FLASH_MODE_OFF;
+ case FLASH_MODE_AUTO:
+ return CameraParameters::FLASH_MODE_AUTO;
+ case FLASH_MODE_ON:
+ return CameraParameters::FLASH_MODE_ON;
+ case FLASH_MODE_RED_EYE:
+ return CameraParameters::FLASH_MODE_RED_EYE;
+ case FLASH_MODE_TORCH:
+ return CameraParameters::FLASH_MODE_TORCH;
+ default:
+ ALOGE("%s: Unknown flash mode enum %d",
+ __FUNCTION__, flashMode);
+ return "unknown";
+ }
+}
+
+Parameters::Parameters::focusMode_t Parameters::focusModeStringToEnum(
+ const char *focusMode) {
+ return
+ !focusMode ?
+ Parameters::FOCUS_MODE_INVALID :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_AUTO) ?
+ Parameters::FOCUS_MODE_AUTO :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_INFINITY) ?
+ Parameters::FOCUS_MODE_INFINITY :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_MACRO) ?
+ Parameters::FOCUS_MODE_MACRO :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_FIXED) ?
+ Parameters::FOCUS_MODE_FIXED :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_EDOF) ?
+ Parameters::FOCUS_MODE_EDOF :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO) ?
+ Parameters::FOCUS_MODE_CONTINUOUS_VIDEO :
+ !strcmp(focusMode, CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE) ?
+ Parameters::FOCUS_MODE_CONTINUOUS_PICTURE :
+ Parameters::FOCUS_MODE_INVALID;
+}
+
+const char *Parameters::focusModeEnumToString(focusMode_t focusMode) {
+ switch (focusMode) {
+ case FOCUS_MODE_AUTO:
+ return CameraParameters::FOCUS_MODE_AUTO;
+ case FOCUS_MODE_MACRO:
+ return CameraParameters::FOCUS_MODE_MACRO;
+ case FOCUS_MODE_CONTINUOUS_VIDEO:
+ return CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO;
+ case FOCUS_MODE_CONTINUOUS_PICTURE:
+ return CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE;
+ case FOCUS_MODE_EDOF:
+ return CameraParameters::FOCUS_MODE_EDOF;
+ case FOCUS_MODE_INFINITY:
+ return CameraParameters::FOCUS_MODE_INFINITY;
+ case FOCUS_MODE_FIXED:
+ return CameraParameters::FOCUS_MODE_FIXED;
+ default:
+ ALOGE("%s: Unknown focus mode enum: %d",
+ __FUNCTION__, focusMode);
+ return "unknown";
+ }
+}
+
+status_t Parameters::parseAreas(const char *areasCStr,
+ Vector<Parameters::Area> *areas) {
+ static const size_t NUM_FIELDS = 5;
+ areas->clear();
+ if (areasCStr == NULL) {
+ // If no key exists, use default (0,0,0,0,0)
+ areas->push();
+ return OK;
+ }
+ String8 areasStr(areasCStr);
+ ssize_t areaStart = areasStr.find("(", 0) + 1;
+ while (areaStart != 0) {
+ const char* area = areasStr.string() + areaStart;
+ char *numEnd;
+ int vals[NUM_FIELDS];
+ for (size_t i = 0; i < NUM_FIELDS; i++) {
+ errno = 0;
+ vals[i] = strtol(area, &numEnd, 10);
+ if (errno || numEnd == area) return BAD_VALUE;
+ area = numEnd + 1;
+ }
+ areas->push(Parameters::Area(
+ vals[0], vals[1], vals[2], vals[3], vals[4]) );
+ areaStart = areasStr.find("(", areaStart) + 1;
+ }
+ return OK;
+}
+
+status_t Parameters::validateAreas(const Vector<Parameters::Area> &areas,
+ size_t maxRegions,
+ AreaKind areaKind) const {
+ // Definition of valid area can be found in
+ // include/camera/CameraParameters.h
+ if (areas.size() == 0) return BAD_VALUE;
+ if (areas.size() == 1) {
+ if (areas[0].left == 0 &&
+ areas[0].top == 0 &&
+ areas[0].right == 0 &&
+ areas[0].bottom == 0 &&
+ areas[0].weight == 0) {
+ // Single (0,0,0,0,0) entry is always valid (== driver decides)
+ return OK;
+ }
+ }
+
+ // fixed focus can only set (0,0,0,0,0) focus area
+ if (areaKind == AREA_KIND_FOCUS && focusMode == FOCUS_MODE_FIXED) {
+ return BAD_VALUE;
+ }
+
+ if (areas.size() > maxRegions) {
+ ALOGE("%s: Too many areas requested: %d",
+ __FUNCTION__, areas.size());
+ return BAD_VALUE;
+ }
+
+ for (Vector<Parameters::Area>::const_iterator a = areas.begin();
+ a != areas.end(); a++) {
+ if (a->weight < 1 || a->weight > 1000) return BAD_VALUE;
+ if (a->left < -1000 || a->left > 1000) return BAD_VALUE;
+ if (a->top < -1000 || a->top > 1000) return BAD_VALUE;
+ if (a->right < -1000 || a->right > 1000) return BAD_VALUE;
+ if (a->bottom < -1000 || a->bottom > 1000) return BAD_VALUE;
+ if (a->left >= a->right) return BAD_VALUE;
+ if (a->top >= a->bottom) return BAD_VALUE;
+ }
+ return OK;
+}
+
+bool Parameters::boolFromString(const char *boolStr) {
+ return !boolStr ? false :
+ !strcmp(boolStr, CameraParameters::TRUE) ? true :
+ false;
+}
+
+int Parameters::degToTransform(int degrees, bool mirror) {
+ if (!mirror) {
+ if (degrees == 0) return 0;
+ else if (degrees == 90) return HAL_TRANSFORM_ROT_90;
+ else if (degrees == 180) return HAL_TRANSFORM_ROT_180;
+ else if (degrees == 270) return HAL_TRANSFORM_ROT_270;
+ } else { // Do mirror (horizontal flip)
+ if (degrees == 0) { // FLIP_H and ROT_0
+ return HAL_TRANSFORM_FLIP_H;
+ } else if (degrees == 90) { // FLIP_H and ROT_90
+ return HAL_TRANSFORM_FLIP_H | HAL_TRANSFORM_ROT_90;
+ } else if (degrees == 180) { // FLIP_H and ROT_180
+ return HAL_TRANSFORM_FLIP_V;
+ } else if (degrees == 270) { // FLIP_H and ROT_270
+ return HAL_TRANSFORM_FLIP_V | HAL_TRANSFORM_ROT_90;
+ }
+ }
+ ALOGE("%s: Bad input: %d", __FUNCTION__, degrees);
+ return -1;
+}
+
+int Parameters::cropXToArray(int x) const {
+ ALOG_ASSERT(x >= 0, "Crop-relative X coordinate = '%d' is out of bounds"
+ "(lower = 0)", x);
+
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ ALOG_ASSERT(x < previewCrop.width, "Crop-relative X coordinate = '%d' "
+ "is out of bounds (upper = %d)", x, previewCrop.width);
+
+ int ret = x + previewCrop.left;
+
+ ALOG_ASSERT( (ret >= 0 && ret < fastInfo.arrayWidth),
+ "Calculated pixel array value X = '%d' is out of bounds (upper = %d)",
+ ret, fastInfo.arrayWidth);
+ return ret;
+}
+
+int Parameters::cropYToArray(int y) const {
+ ALOG_ASSERT(y >= 0, "Crop-relative Y coordinate = '%d' is out of bounds "
+ "(lower = 0)", y);
+
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ ALOG_ASSERT(y < previewCrop.height, "Crop-relative Y coordinate = '%d' is "
+ "out of bounds (upper = %d)", y, previewCrop.height);
+
+ int ret = y + previewCrop.top;
+
+ ALOG_ASSERT( (ret >= 0 && ret < fastInfo.arrayHeight),
+ "Calculated pixel array value Y = '%d' is out of bounds (upper = %d)",
+ ret, fastInfo.arrayHeight);
+
+ return ret;
+
+}
+
+int Parameters::normalizedXToCrop(int x) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return (x + 1000) * (previewCrop.width - 1) / 2000;
+}
+
+int Parameters::normalizedYToCrop(int y) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return (y + 1000) * (previewCrop.height - 1) / 2000;
+}
+
+int Parameters::arrayXToCrop(int x) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return x - previewCrop.left;
+}
+
+int Parameters::arrayYToCrop(int y) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return y - previewCrop.top;
+}
+
+int Parameters::cropXToNormalized(int x) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return x * 2000 / (previewCrop.width - 1) - 1000;
+}
+
+int Parameters::cropYToNormalized(int y) const {
+ CropRegion previewCrop = calculateCropRegion(CropRegion::OUTPUT_PREVIEW);
+ return y * 2000 / (previewCrop.height - 1) - 1000;
+}
+
+int Parameters::arrayXToNormalized(int width) const {
+ int ret = cropXToNormalized(arrayXToCrop(width));
+
+ ALOG_ASSERT(ret >= -1000, "Calculated normalized value out of "
+ "lower bounds %d", ret);
+ ALOG_ASSERT(ret <= 1000, "Calculated normalized value out of "
+ "upper bounds %d", ret);
+
+ // Work-around for HAL pre-scaling the coordinates themselves
+ if (quirks.meteringCropRegion) {
+ return width * 2000 / (fastInfo.arrayWidth - 1) - 1000;
+ }
+
+ return ret;
+}
+
+int Parameters::arrayYToNormalized(int height) const {
+ int ret = cropYToNormalized(arrayYToCrop(height));
+
+ ALOG_ASSERT(ret >= -1000, "Calculated normalized value out of lower bounds"
+ " %d", ret);
+ ALOG_ASSERT(ret <= 1000, "Calculated normalized value out of upper bounds"
+ " %d", ret);
+
+ // Work-around for HAL pre-scaling the coordinates themselves
+ if (quirks.meteringCropRegion) {
+ return height * 2000 / (fastInfo.arrayHeight - 1) - 1000;
+ }
+
+ return ret;
+}
+
+int Parameters::normalizedXToArray(int x) const {
+
+ // Work-around for HAL pre-scaling the coordinates themselves
+ if (quirks.meteringCropRegion) {
+ return (x + 1000) * (fastInfo.arrayWidth - 1) / 2000;
+ }
+
+ return cropXToArray(normalizedXToCrop(x));
+}
+
+int Parameters::normalizedYToArray(int y) const {
+ // Work-around for HAL pre-scaling the coordinates themselves
+ if (quirks.meteringCropRegion) {
+ return (y + 1000) * (fastInfo.arrayHeight - 1) / 2000;
+ }
+
+ return cropYToArray(normalizedYToCrop(y));
+}
+
+Parameters::CropRegion Parameters::calculateCropRegion(
+ Parameters::CropRegion::Outputs outputs) const {
+
+ float zoomLeft, zoomTop, zoomWidth, zoomHeight;
+
+ // Need to convert zoom index into a crop rectangle. The rectangle is
+ // chosen to maximize its area on the sensor
+
+ camera_metadata_ro_entry_t maxDigitalZoom =
+ staticInfo(ANDROID_SCALER_AVAILABLE_MAX_DIGITAL_ZOOM);
+ // For each zoom step by how many pixels more do we change the zoom
+ float zoomIncrement = (maxDigitalZoom.data.f[0] - 1) /
+ (NUM_ZOOM_STEPS-1);
+ // The desired activeAreaWidth/cropAreaWidth ratio (or height if h>w)
+ // via interpolating zoom step into a zoom ratio
+ float zoomRatio = 1 + zoomIncrement * zoom;
+ ALOG_ASSERT( (zoomRatio >= 1.f && zoomRatio <= maxDigitalZoom.data.f[0]),
+ "Zoom ratio calculated out of bounds. Expected 1 - %f, actual: %f",
+ maxDigitalZoom.data.f[0], zoomRatio);
+
+ ALOGV("Zoom maxDigital=%f, increment=%f, ratio=%f, previewWidth=%d, "
+ "previewHeight=%d, activeWidth=%d, activeHeight=%d",
+ maxDigitalZoom.data.f[0], zoomIncrement, zoomRatio, previewWidth,
+ previewHeight, fastInfo.arrayWidth, fastInfo.arrayHeight);
+
+ /*
+ * Assumption: On the HAL side each stream buffer calculates its crop
+ * rectangle as follows:
+ * cropRect = (zoomLeft, zoomRight,
+ * zoomWidth, zoomHeight * zoomWidth / outputWidth);
+ *
+ * Note that if zoomWidth > bufferWidth, the new cropHeight > zoomHeight
+ * (we can then get into trouble if the cropHeight > arrayHeight).
+ * By selecting the zoomRatio based on the smallest outputRatio, we
+ * guarantee this will never happen.
+ */
+
+ // Enumerate all possible output sizes, select the one with the smallest
+ // aspect ratio
+ float minOutputWidth, minOutputHeight, minOutputRatio;
+ {
+ float outputSizes[][2] = {
+ { static_cast<float>(previewWidth),
+ static_cast<float>(previewHeight) },
+ { static_cast<float>(videoWidth),
+ static_cast<float>(videoHeight) },
+ { static_cast<float>(jpegThumbSize[0]),
+ static_cast<float>(jpegThumbSize[1]) },
+ { static_cast<float>(pictureWidth),
+ static_cast<float>(pictureHeight) },
+ };
+
+ minOutputWidth = outputSizes[0][0];
+ minOutputHeight = outputSizes[0][1];
+ minOutputRatio = minOutputWidth / minOutputHeight;
+ for (unsigned int i = 0;
+ i < sizeof(outputSizes) / sizeof(outputSizes[0]);
+ ++i) {
+
+ // skip over outputs we don't want to consider for the crop region
+ if ( !((1 << i) & outputs) ) {
+ continue;
+ }
+
+ float outputWidth = outputSizes[i][0];
+ float outputHeight = outputSizes[i][1];
+ float outputRatio = outputWidth / outputHeight;
+
+ if (minOutputRatio > outputRatio) {
+ minOutputRatio = outputRatio;
+ minOutputWidth = outputWidth;
+ minOutputHeight = outputHeight;
+ }
+
+ // and then use this output ratio instead of preview output ratio
+ ALOGV("Enumerating output ratio %f = %f / %f, min is %f",
+ outputRatio, outputWidth, outputHeight, minOutputRatio);
+ }
+ }
+
+ /* Ensure that the width/height never go out of bounds
+ * by scaling across a diffent dimension if an out-of-bounds
+ * possibility exists.
+ *
+ * e.g. if the previewratio < arrayratio and e.g. zoomratio = 1.0, then by
+ * calculating the zoomWidth from zoomHeight we'll actually get a
+ * zoomheight > arrayheight
+ */
+ float arrayRatio = 1.f * fastInfo.arrayWidth / fastInfo.arrayHeight;
+ if (minOutputRatio >= arrayRatio) {
+ // Adjust the height based on the width
+ zoomWidth = fastInfo.arrayWidth / zoomRatio;
+ zoomHeight = zoomWidth *
+ minOutputHeight / minOutputWidth;
+
+ } else {
+ // Adjust the width based on the height
+ zoomHeight = fastInfo.arrayHeight / zoomRatio;
+ zoomWidth = zoomHeight *
+ minOutputWidth / minOutputHeight;
+ }
+ // centering the zoom area within the active area
+ zoomLeft = (fastInfo.arrayWidth - zoomWidth) / 2;
+ zoomTop = (fastInfo.arrayHeight - zoomHeight) / 2;
+
+ ALOGV("Crop region calculated (x=%d,y=%d,w=%f,h=%f) for zoom=%d",
+ (int32_t)zoomLeft, (int32_t)zoomTop, zoomWidth, zoomHeight, this->zoom);
+
+
+ CropRegion crop = { zoomLeft, zoomTop, zoomWidth, zoomHeight };
+ return crop;
+}
+
+int32_t Parameters::fpsFromRange(int32_t min, int32_t max) const {
+ return max;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/Parameters.h b/services/camera/libcameraservice/camera2/Parameters.h
new file mode 100644
index 00000000..dc2cdcf9
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/Parameters.h
@@ -0,0 +1,365 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2PARAMETERS_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2PARAMETERS_H
+
+#include <system/graphics.h>
+
+#include <utils/Errors.h>
+#include <utils/Mutex.h>
+#include <utils/String8.h>
+#include <utils/Vector.h>
+#include <utils/KeyedVector.h>
+#include <camera/CameraParameters.h>
+
+#include "CameraMetadata.h"
+
+namespace android {
+namespace camera2 {
+
+/**
+ * Current camera state; this is the full state of the Camera under the old
+ * camera API (contents of the CameraParameters object in a more-efficient
+ * format, plus other state). The enum values are mostly based off the
+ * corresponding camera2 enums, not the camera1 strings. A few are defined here
+ * if they don't cleanly map to camera2 values.
+ */
+struct Parameters {
+ /**
+ * Parameters and other state
+ */
+ int cameraId;
+ int cameraFacing;
+
+ int previewWidth, previewHeight;
+ int32_t previewFpsRange[2];
+ int previewFps; // deprecated, here only for tracking changes
+ int previewFormat;
+
+ int previewTransform; // set by CAMERA_CMD_SET_DISPLAY_ORIENTATION
+
+ int pictureWidth, pictureHeight;
+
+ int32_t jpegThumbSize[2];
+ uint8_t jpegQuality, jpegThumbQuality;
+ int32_t jpegRotation;
+
+ bool gpsEnabled;
+ double gpsCoordinates[3];
+ int64_t gpsTimestamp;
+ String8 gpsProcessingMethod;
+
+ uint8_t wbMode;
+ uint8_t effectMode;
+ uint8_t antibandingMode;
+ uint8_t sceneMode;
+
+ enum flashMode_t {
+ FLASH_MODE_OFF = 0,
+ FLASH_MODE_AUTO,
+ FLASH_MODE_ON,
+ FLASH_MODE_TORCH,
+ FLASH_MODE_RED_EYE = ANDROID_CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE,
+ FLASH_MODE_INVALID = -1
+ } flashMode;
+
+ enum focusMode_t {
+ FOCUS_MODE_AUTO = ANDROID_CONTROL_AF_MODE_AUTO,
+ FOCUS_MODE_MACRO = ANDROID_CONTROL_AF_MODE_MACRO,
+ FOCUS_MODE_CONTINUOUS_VIDEO = ANDROID_CONTROL_AF_MODE_CONTINUOUS_VIDEO,
+ FOCUS_MODE_CONTINUOUS_PICTURE = ANDROID_CONTROL_AF_MODE_CONTINUOUS_PICTURE,
+ FOCUS_MODE_EDOF = ANDROID_CONTROL_AF_MODE_EDOF,
+ FOCUS_MODE_INFINITY,
+ FOCUS_MODE_FIXED,
+ FOCUS_MODE_INVALID = -1
+ } focusMode;
+
+ uint8_t focusState; // Latest focus state from HAL
+
+ // For use with triggerAfWithAuto quirk
+ focusMode_t shadowFocusMode;
+
+ struct Area {
+ int left, top, right, bottom;
+ int weight;
+ Area() {}
+ Area(int left, int top, int right, int bottom, int weight):
+ left(left), top(top), right(right), bottom(bottom),
+ weight(weight) {}
+ bool isEmpty() const {
+ return (left == 0) && (top == 0) && (right == 0) && (bottom == 0);
+ }
+ };
+ Vector<Area> focusingAreas;
+
+ int32_t exposureCompensation;
+ bool autoExposureLock;
+ bool autoWhiteBalanceLock;
+
+ Vector<Area> meteringAreas;
+
+ int zoom;
+
+ int videoWidth, videoHeight;
+
+ bool recordingHint;
+ bool videoStabilization;
+
+ enum lightFxMode_t {
+ LIGHTFX_NONE = 0,
+ LIGHTFX_LOWLIGHT,
+ LIGHTFX_HDR
+ } lightFx;
+
+ CameraParameters params;
+ String8 paramsFlattened;
+
+ // These parameters are also part of the camera API-visible state, but not
+ // directly listed in Camera.Parameters
+ bool storeMetadataInBuffers;
+ bool playShutterSound;
+ bool enableFaceDetect;
+
+ bool enableFocusMoveMessages;
+ int afTriggerCounter;
+ int currentAfTriggerId;
+ bool afInMotion;
+
+ int precaptureTriggerCounter;
+
+ uint32_t previewCallbackFlags;
+ bool previewCallbackOneShot;
+
+ bool zslMode;
+
+ // Overall camera state
+ enum State {
+ DISCONNECTED,
+ STOPPED,
+ WAITING_FOR_PREVIEW_WINDOW,
+ PREVIEW,
+ RECORD,
+ STILL_CAPTURE,
+ VIDEO_SNAPSHOT
+ } state;
+
+ // Number of zoom steps to simulate
+ static const unsigned int NUM_ZOOM_STEPS = 30;
+
+ // Full static camera info, object owned by someone else, such as
+ // Camera2Device.
+ const CameraMetadata *info;
+
+ // Fast-access static device information; this is a subset of the
+ // information available through the staticInfo() method, used for
+ // frequently-accessed values or values that have to be calculated from the
+ // static information.
+ struct DeviceInfo {
+ int32_t arrayWidth;
+ int32_t arrayHeight;
+ uint8_t bestFaceDetectMode;
+ int32_t maxFaces;
+ struct OverrideModes {
+ flashMode_t flashMode;
+ uint8_t wbMode;
+ focusMode_t focusMode;
+ OverrideModes():
+ flashMode(FLASH_MODE_INVALID),
+ wbMode(ANDROID_CONTROL_AWB_MODE_OFF),
+ focusMode(FOCUS_MODE_INVALID) {
+ }
+ };
+ DefaultKeyedVector<uint8_t, OverrideModes> sceneModeOverrides;
+ } fastInfo;
+
+ // Quirks information; these are short-lived flags to enable workarounds for
+ // incomplete HAL implementations
+ struct Quirks {
+ bool triggerAfWithAuto;
+ bool useZslFormat;
+ bool meteringCropRegion;
+ } quirks;
+
+ /**
+ * Parameter manipulation and setup methods
+ */
+
+ Parameters(int cameraId, int cameraFacing);
+ ~Parameters();
+
+ // Sets up default parameters
+ status_t initialize(const CameraMetadata *info);
+
+ // Build fast-access device static info from static info
+ status_t buildFastInfo();
+ // Query for quirks from static info
+ status_t buildQuirks();
+
+ // Get entry from camera static characteristics information. min/maxCount
+ // are used for error checking the number of values in the entry. 0 for
+ // max/minCount means to do no bounds check in that direction. In case of
+ // error, the entry data pointer is null and the count is 0.
+ camera_metadata_ro_entry_t staticInfo(uint32_t tag,
+ size_t minCount=0, size_t maxCount=0) const;
+
+ // Validate and update camera parameters based on new settings
+ status_t set(const String8 &paramString);
+
+ // Retrieve the current settings
+ String8 get() const;
+
+ // Update passed-in request for common parameters
+ status_t updateRequest(CameraMetadata *request) const;
+
+ // Add/update JPEG entries in metadata
+ status_t updateRequestJpeg(CameraMetadata *request) const;
+
+ // Calculate the crop region rectangle based on current stream sizes
+ struct CropRegion {
+ float left;
+ float top;
+ float width;
+ float height;
+
+ enum Outputs {
+ OUTPUT_PREVIEW = 0x01,
+ OUTPUT_VIDEO = 0x02,
+ OUTPUT_JPEG_THUMBNAIL = 0x04,
+ OUTPUT_PICTURE = 0x08,
+ };
+ };
+ CropRegion calculateCropRegion(CropRegion::Outputs outputs) const;
+
+ // Static methods for debugging and converting between camera1 and camera2
+ // parameters
+
+ static const char *getStateName(State state);
+
+ static int formatStringToEnum(const char *format);
+ static const char *formatEnumToString(int format);
+
+ static int wbModeStringToEnum(const char *wbMode);
+ static const char* wbModeEnumToString(uint8_t wbMode);
+ static int effectModeStringToEnum(const char *effectMode);
+ static int abModeStringToEnum(const char *abMode);
+ static int sceneModeStringToEnum(const char *sceneMode);
+ static flashMode_t flashModeStringToEnum(const char *flashMode);
+ static const char* flashModeEnumToString(flashMode_t flashMode);
+ static focusMode_t focusModeStringToEnum(const char *focusMode);
+ static const char* focusModeEnumToString(focusMode_t focusMode);
+ static status_t parseAreas(const char *areasCStr,
+ Vector<Area> *areas);
+
+ enum AreaKind
+ {
+ AREA_KIND_FOCUS,
+ AREA_KIND_METERING
+ };
+ status_t validateAreas(const Vector<Area> &areas,
+ size_t maxRegions,
+ AreaKind areaKind) const;
+ static bool boolFromString(const char *boolStr);
+
+ // Map from camera orientation + facing to gralloc transform enum
+ static int degToTransform(int degrees, bool mirror);
+
+ // API specifies FPS ranges are done in fixed point integer, with LSB = 0.001.
+ // Note that this doesn't apply to the (deprecated) single FPS value.
+ static const int kFpsToApiScale = 1000;
+
+ // Transform between (-1000,-1000)-(1000,1000) normalized coords from camera
+ // API and HAL2 (0,0)-(activePixelArray.width/height) coordinates
+ int arrayXToNormalized(int width) const;
+ int arrayYToNormalized(int height) const;
+ int normalizedXToArray(int x) const;
+ int normalizedYToArray(int y) const;
+
+ struct Range {
+ int min;
+ int max;
+ };
+
+ int32_t fpsFromRange(int32_t min, int32_t max) const;
+
+private:
+
+ // Convert between HAL2 sensor array coordinates and
+ // viewfinder crop-region relative array coordinates
+ int cropXToArray(int x) const;
+ int cropYToArray(int y) const;
+ int arrayXToCrop(int x) const;
+ int arrayYToCrop(int y) const;
+
+ // Convert between viewfinder crop-region relative array coordinates
+ // and camera API (-1000,1000)-(1000,1000) normalized coords
+ int cropXToNormalized(int x) const;
+ int cropYToNormalized(int y) const;
+ int normalizedXToCrop(int x) const;
+ int normalizedYToCrop(int y) const;
+};
+
+// This class encapsulates the Parameters class so that it can only be accessed
+// by constructing a Lock object, which locks the SharedParameter's mutex.
+class SharedParameters {
+ public:
+ SharedParameters(int cameraId, int cameraFacing):
+ mParameters(cameraId, cameraFacing) {
+ }
+
+ template<typename S, typename P>
+ class BaseLock {
+ public:
+ BaseLock(S &p):
+ mParameters(p.mParameters),
+ mSharedParameters(p) {
+ mSharedParameters.mLock.lock();
+ }
+
+ ~BaseLock() {
+ mSharedParameters.mLock.unlock();
+ }
+ P &mParameters;
+ private:
+ // Disallow copying, default construction
+ BaseLock();
+ BaseLock(const BaseLock &);
+ BaseLock &operator=(const BaseLock &);
+ S &mSharedParameters;
+ };
+ typedef BaseLock<SharedParameters, Parameters> Lock;
+ typedef BaseLock<const SharedParameters, const Parameters> ReadLock;
+
+ // Access static info, read-only and immutable, so no lock needed
+ camera_metadata_ro_entry_t staticInfo(uint32_t tag,
+ size_t minCount=0, size_t maxCount=0) const {
+ return mParameters.staticInfo(tag, minCount, maxCount);
+ }
+
+ // Only use for dumping or other debugging
+ const Parameters &unsafeAccess() {
+ return mParameters;
+ }
+ private:
+ Parameters mParameters;
+ mutable Mutex mLock;
+};
+
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.cpp b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
new file mode 100644
index 00000000..207f7807
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/StreamingProcessor.cpp
@@ -0,0 +1,657 @@
+/*
+ * 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 "Camera2-StreamingProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+#include <gui/SurfaceTextureClient.h>
+#include <media/hardware/MetadataBufferType.h>
+
+#include "StreamingProcessor.h"
+#include "Camera2Heap.h"
+#include "../Camera2Client.h"
+#include "../Camera2Device.h"
+
+namespace android {
+namespace camera2 {
+
+StreamingProcessor::StreamingProcessor(wp<Camera2Client> client):
+ mClient(client),
+ mActiveRequest(NONE),
+ mPreviewRequestId(Camera2Client::kPreviewRequestIdStart),
+ mPreviewStreamId(NO_STREAM),
+ mRecordingRequestId(Camera2Client::kRecordingRequestIdStart),
+ mRecordingStreamId(NO_STREAM),
+ mRecordingHeapCount(kDefaultRecordingHeapCount)
+{
+
+}
+
+StreamingProcessor::~StreamingProcessor() {
+ deletePreviewStream();
+ deleteRecordingStream();
+}
+
+status_t StreamingProcessor::setPreviewWindow(sp<ANativeWindow> window) {
+ ATRACE_CALL();
+ status_t res;
+
+ res = deletePreviewStream();
+ if (res != OK) return res;
+
+ Mutex::Autolock m(mMutex);
+
+ mPreviewWindow = window;
+
+ return OK;
+}
+
+bool StreamingProcessor::haveValidPreviewWindow() const {
+ Mutex::Autolock m(mMutex);
+ return mPreviewWindow != 0;
+}
+
+status_t StreamingProcessor::updatePreviewRequest(const Parameters &params) {
+ ATRACE_CALL();
+ status_t res;
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+
+ Mutex::Autolock m(mMutex);
+ if (mPreviewRequest.entryCount() == 0) {
+ res = client->getCameraDevice()->createDefaultRequest(CAMERA2_TEMPLATE_PREVIEW,
+ &mPreviewRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create default preview request: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ }
+
+ res = params.updateRequest(&mPreviewRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update common entries of preview "
+ "request: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+
+ res = mPreviewRequest.update(ANDROID_REQUEST_ID,
+ &mPreviewRequestId, 1);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update request id for preview: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+
+ return OK;
+}
+
+status_t StreamingProcessor::updatePreviewStream(const Parameters &params) {
+ ATRACE_CALL();
+ Mutex::Autolock m(mMutex);
+
+ status_t res;
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ if (mPreviewStreamId != NO_STREAM) {
+ // Check if stream parameters have to change
+ uint32_t currentWidth, currentHeight;
+ res = device->getStreamInfo(mPreviewStreamId,
+ &currentWidth, &currentHeight, 0);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error querying preview stream info: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ if (currentWidth != (uint32_t)params.previewWidth ||
+ currentHeight != (uint32_t)params.previewHeight) {
+ ALOGV("%s: Camera %d: Preview size switch: %d x %d -> %d x %d",
+ __FUNCTION__, client->getCameraId(), currentWidth, currentHeight,
+ params.previewWidth, params.previewHeight);
+ res = device->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error waiting for preview to drain: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ res = device->deleteStream(mPreviewStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old output stream "
+ "for preview: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ mPreviewStreamId = NO_STREAM;
+ }
+ }
+
+ if (mPreviewStreamId == NO_STREAM) {
+ res = device->createStream(mPreviewWindow,
+ params.previewWidth, params.previewHeight,
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, 0,
+ &mPreviewStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create preview stream: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ }
+
+ res = device->setStreamTransform(mPreviewStreamId,
+ params.previewTransform);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set preview stream transform: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+
+ return OK;
+}
+
+status_t StreamingProcessor::deletePreviewStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock m(mMutex);
+
+ if (mPreviewStreamId != NO_STREAM) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ ALOGV("%s: for cameraId %d on streamId %d",
+ __FUNCTION__, client->getCameraId(), mPreviewStreamId);
+
+ res = device->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Error waiting for preview to drain: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+ res = device->deleteStream(mPreviewStreamId);
+ if (res != OK) {
+ ALOGE("%s: Unable to delete old preview stream: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+ mPreviewStreamId = NO_STREAM;
+ }
+ return OK;
+}
+
+int StreamingProcessor::getPreviewStreamId() const {
+ Mutex::Autolock m(mMutex);
+ return mPreviewStreamId;
+}
+
+status_t StreamingProcessor::setRecordingBufferCount(size_t count) {
+ ATRACE_CALL();
+ // 32 is the current upper limit on the video buffer count for BufferQueue
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ if (count > 32) {
+ ALOGE("%s: Camera %d: Error setting %d as video buffer count value",
+ __FUNCTION__, client->getCameraId(), count);
+ return BAD_VALUE;
+ }
+
+ Mutex::Autolock m(mMutex);
+
+ // Need to reallocate memory for heap
+ if (mRecordingHeapCount != count) {
+ if (mRecordingHeap != 0) {
+ mRecordingHeap.clear();
+ mRecordingHeap = NULL;
+ }
+ mRecordingHeapCount = count;
+ }
+
+ return OK;
+}
+
+status_t StreamingProcessor::updateRecordingRequest(const Parameters &params) {
+ ATRACE_CALL();
+ status_t res;
+ Mutex::Autolock m(mMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+
+ if (mRecordingRequest.entryCount() == 0) {
+ res = client->getCameraDevice()->createDefaultRequest(CAMERA2_TEMPLATE_VIDEO_RECORD,
+ &mRecordingRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to create default recording request:"
+ " %s (%d)", __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ }
+
+ res = params.updateRequest(&mRecordingRequest);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update common entries of recording "
+ "request: %s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+
+ res = mRecordingRequest.update(ANDROID_REQUEST_ID,
+ &mRecordingRequestId, 1);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update request id for request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+
+ return OK;
+}
+
+status_t StreamingProcessor::updateRecordingStream(const Parameters &params) {
+ ATRACE_CALL();
+ status_t res;
+ Mutex::Autolock m(mMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ if (mRecordingConsumer == 0) {
+ // Create CPU buffer queue endpoint. We need one more buffer here so that we can
+ // always acquire and free a buffer when the heap is full; otherwise the consumer
+ // will have buffers in flight we'll never clear out.
+ mRecordingConsumer = new BufferItemConsumer(
+ GRALLOC_USAGE_HW_VIDEO_ENCODER,
+ mRecordingHeapCount + 1,
+ true);
+ mRecordingConsumer->setFrameAvailableListener(this);
+ mRecordingConsumer->setName(String8("Camera2-RecordingConsumer"));
+ mRecordingWindow = new SurfaceTextureClient(
+ mRecordingConsumer->getProducerInterface());
+ // Allocate memory later, since we don't know buffer size until receipt
+ }
+
+ if (mRecordingStreamId != NO_STREAM) {
+ // Check if stream parameters have to change
+ uint32_t currentWidth, currentHeight;
+ res = device->getStreamInfo(mRecordingStreamId,
+ &currentWidth, &currentHeight, 0);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error querying recording output stream info: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ if (currentWidth != (uint32_t)params.videoWidth ||
+ currentHeight != (uint32_t)params.videoHeight) {
+ // TODO: Should wait to be sure previous recording has finished
+ res = device->deleteStream(mRecordingStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old output stream "
+ "for recording: %s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ mRecordingStreamId = NO_STREAM;
+ }
+ }
+
+ if (mRecordingStreamId == NO_STREAM) {
+ mRecordingFrameCount = 0;
+ res = device->createStream(mRecordingWindow,
+ params.videoWidth, params.videoHeight,
+ CAMERA2_HAL_PIXEL_FORMAT_OPAQUE, 0, &mRecordingStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't create output stream for recording: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ }
+
+ return OK;
+}
+
+status_t StreamingProcessor::deleteRecordingStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock m(mMutex);
+
+ if (mRecordingStreamId != NO_STREAM) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ res = device->waitUntilDrained();
+ if (res != OK) {
+ ALOGE("%s: Error waiting for HAL to drain: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+ res = device->deleteStream(mRecordingStreamId);
+ if (res != OK) {
+ ALOGE("%s: Unable to delete recording stream: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+ mRecordingStreamId = NO_STREAM;
+ }
+ return OK;
+}
+
+int StreamingProcessor::getRecordingStreamId() const {
+ return mRecordingStreamId;
+}
+
+status_t StreamingProcessor::startStream(StreamType type,
+ const Vector<uint8_t> &outputStreams) {
+ ATRACE_CALL();
+ status_t res;
+
+ if (type == NONE) return INVALID_OPERATION;
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+
+ ALOGV("%s: Camera %d: type = %d", __FUNCTION__, client->getCameraId(), type);
+
+ Mutex::Autolock m(mMutex);
+
+ CameraMetadata &request = (type == PREVIEW) ?
+ mPreviewRequest : mRecordingRequest;
+
+ res = request.update(
+ ANDROID_REQUEST_OUTPUT_STREAMS,
+ outputStreams);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set up preview request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+
+ res = request.sort();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error sorting preview request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+
+ res = client->getCameraDevice()->setStreamingRequest(request);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to set preview request to start preview: "
+ "%s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ mActiveRequest = type;
+
+ return OK;
+}
+
+status_t StreamingProcessor::stopStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock m(mMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return INVALID_OPERATION;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ res = device->clearStreamingRequest();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't clear stream request: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ mActiveRequest = NONE;
+
+ return OK;
+}
+
+int32_t StreamingProcessor::getActiveRequestId() const {
+ Mutex::Autolock m(mMutex);
+ switch (mActiveRequest) {
+ case NONE:
+ return 0;
+ case PREVIEW:
+ return mPreviewRequestId;
+ case RECORD:
+ return mRecordingRequestId;
+ default:
+ ALOGE("%s: Unexpected mode %d", __FUNCTION__, mActiveRequest);
+ return 0;
+ }
+}
+
+status_t StreamingProcessor::incrementStreamingIds() {
+ ATRACE_CALL();
+ Mutex::Autolock m(mMutex);
+
+ status_t res;
+ mPreviewRequestId++;
+ if (mPreviewRequestId >= Camera2Client::kPreviewRequestIdEnd) {
+ mPreviewRequestId = Camera2Client::kPreviewRequestIdStart;
+ }
+ mRecordingRequestId++;
+ if (mRecordingRequestId >= Camera2Client::kRecordingRequestIdEnd) {
+ mRecordingRequestId = Camera2Client::kRecordingRequestIdStart;
+ }
+ return OK;
+}
+
+void StreamingProcessor::onFrameAvailable() {
+ ATRACE_CALL();
+ status_t res;
+ sp<Camera2Heap> recordingHeap;
+ size_t heapIdx = 0;
+ nsecs_t timestamp;
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return;
+
+ {
+ /* acquire SharedParameters before mMutex so we don't dead lock
+ with Camera2Client code calling into StreamingProcessor */
+ SharedParameters::Lock l(client->getParameters());
+ Mutex::Autolock m(mMutex);
+ BufferItemConsumer::BufferItem imgBuffer;
+ res = mRecordingConsumer->acquireBuffer(&imgBuffer);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error receiving recording buffer: %s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return;
+ }
+ timestamp = imgBuffer.mTimestamp;
+
+ mRecordingFrameCount++;
+ ALOGV("OnRecordingFrame: Frame %d", mRecordingFrameCount);
+
+ // TODO: Signal errors here upstream
+ if (l.mParameters.state != Parameters::RECORD &&
+ l.mParameters.state != Parameters::VIDEO_SNAPSHOT) {
+ ALOGV("%s: Camera %d: Discarding recording image buffers "
+ "received after recording done", __FUNCTION__,
+ client->getCameraId());
+ mRecordingConsumer->releaseBuffer(imgBuffer);
+ return;
+ }
+
+ if (mRecordingHeap == 0) {
+ const size_t bufferSize = 4 + sizeof(buffer_handle_t);
+ ALOGV("%s: Camera %d: Creating recording heap with %d buffers of "
+ "size %d bytes", __FUNCTION__, client->getCameraId(),
+ mRecordingHeapCount, bufferSize);
+
+ mRecordingHeap = new Camera2Heap(bufferSize, mRecordingHeapCount,
+ "Camera2Client::RecordingHeap");
+ if (mRecordingHeap->mHeap->getSize() == 0) {
+ ALOGE("%s: Camera %d: Unable to allocate memory for recording",
+ __FUNCTION__, client->getCameraId());
+ mRecordingConsumer->releaseBuffer(imgBuffer);
+ return;
+ }
+ for (size_t i = 0; i < mRecordingBuffers.size(); i++) {
+ if (mRecordingBuffers[i].mBuf !=
+ BufferItemConsumer::INVALID_BUFFER_SLOT) {
+ ALOGE("%s: Camera %d: Non-empty recording buffers list!",
+ __FUNCTION__, client->getCameraId());
+ }
+ }
+ mRecordingBuffers.clear();
+ mRecordingBuffers.setCapacity(mRecordingHeapCount);
+ mRecordingBuffers.insertAt(0, mRecordingHeapCount);
+
+ mRecordingHeapHead = 0;
+ mRecordingHeapFree = mRecordingHeapCount;
+ }
+
+ if ( mRecordingHeapFree == 0) {
+ ALOGE("%s: Camera %d: No free recording buffers, dropping frame",
+ __FUNCTION__, client->getCameraId());
+ mRecordingConsumer->releaseBuffer(imgBuffer);
+ return;
+ }
+
+ heapIdx = mRecordingHeapHead;
+ mRecordingHeapHead = (mRecordingHeapHead + 1) % mRecordingHeapCount;
+ mRecordingHeapFree--;
+
+ ALOGV("%s: Camera %d: Timestamp %lld",
+ __FUNCTION__, client->getCameraId(), timestamp);
+
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap =
+ mRecordingHeap->mBuffers[heapIdx]->getMemory(&offset,
+ &size);
+
+ uint8_t *data = (uint8_t*)heap->getBase() + offset;
+ uint32_t type = kMetadataBufferTypeGrallocSource;
+ *((uint32_t*)data) = type;
+ *((buffer_handle_t*)(data + 4)) = imgBuffer.mGraphicBuffer->handle;
+ ALOGV("%s: Camera %d: Sending out buffer_handle_t %p",
+ __FUNCTION__, client->getCameraId(),
+ imgBuffer.mGraphicBuffer->handle);
+ mRecordingBuffers.replaceAt(imgBuffer, heapIdx);
+ recordingHeap = mRecordingHeap;
+ }
+
+ // Call outside locked parameters to allow re-entrancy from notification
+ Camera2Client::SharedCameraClient::Lock l(client->mSharedCameraClient);
+ if (l.mCameraClient != 0) {
+ l.mCameraClient->dataCallbackTimestamp(timestamp,
+ CAMERA_MSG_VIDEO_FRAME,
+ recordingHeap->mBuffers[heapIdx]);
+ }
+}
+
+void StreamingProcessor::releaseRecordingFrame(const sp<IMemory>& mem) {
+ ATRACE_CALL();
+ status_t res;
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return;
+
+ Mutex::Autolock m(mMutex);
+ // Make sure this is for the current heap
+ ssize_t offset;
+ size_t size;
+ sp<IMemoryHeap> heap = mem->getMemory(&offset, &size);
+ if (heap->getHeapID() != mRecordingHeap->mHeap->getHeapID()) {
+ ALOGW("%s: Camera %d: Mismatched heap ID, ignoring release "
+ "(got %x, expected %x)", __FUNCTION__, client->getCameraId(),
+ heap->getHeapID(), mRecordingHeap->mHeap->getHeapID());
+ return;
+ }
+ uint8_t *data = (uint8_t*)heap->getBase() + offset;
+ uint32_t type = *(uint32_t*)data;
+ if (type != kMetadataBufferTypeGrallocSource) {
+ ALOGE("%s: Camera %d: Recording frame type invalid (got %x, expected %x)",
+ __FUNCTION__, client->getCameraId(), type,
+ kMetadataBufferTypeGrallocSource);
+ return;
+ }
+
+ // Release the buffer back to the recording queue
+
+ buffer_handle_t imgHandle = *(buffer_handle_t*)(data + 4);
+
+ size_t itemIndex;
+ for (itemIndex = 0; itemIndex < mRecordingBuffers.size(); itemIndex++) {
+ const BufferItemConsumer::BufferItem item =
+ mRecordingBuffers[itemIndex];
+ if (item.mBuf != BufferItemConsumer::INVALID_BUFFER_SLOT &&
+ item.mGraphicBuffer->handle == imgHandle) {
+ break;
+ }
+ }
+ if (itemIndex == mRecordingBuffers.size()) {
+ ALOGE("%s: Camera %d: Can't find buffer_handle_t %p in list of "
+ "outstanding buffers", __FUNCTION__, client->getCameraId(),
+ imgHandle);
+ return;
+ }
+
+ ALOGV("%s: Camera %d: Freeing buffer_handle_t %p", __FUNCTION__,
+ client->getCameraId(), imgHandle);
+
+ res = mRecordingConsumer->releaseBuffer(mRecordingBuffers[itemIndex]);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to free recording frame "
+ "(buffer_handle_t: %p): %s (%d)", __FUNCTION__,
+ client->getCameraId(), imgHandle, strerror(-res), res);
+ return;
+ }
+ mRecordingBuffers.replaceAt(itemIndex);
+
+ mRecordingHeapFree++;
+}
+
+
+status_t StreamingProcessor::dump(int fd, const Vector<String16>& args) {
+ String8 result;
+
+ result.append(" Current requests:\n");
+ if (mPreviewRequest.entryCount() != 0) {
+ result.append(" Preview request:\n");
+ write(fd, result.string(), result.size());
+ mPreviewRequest.dump(fd, 2, 6);
+ } else {
+ result.append(" Preview request: undefined\n");
+ write(fd, result.string(), result.size());
+ }
+
+ if (mRecordingRequest.entryCount() != 0) {
+ result = " Recording request:\n";
+ write(fd, result.string(), result.size());
+ mRecordingRequest.dump(fd, 2, 6);
+ } else {
+ result = " Recording request: undefined\n";
+ write(fd, result.string(), result.size());
+ }
+
+ return OK;
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/StreamingProcessor.h b/services/camera/libcameraservice/camera2/StreamingProcessor.h
new file mode 100644
index 00000000..96b100f0
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/StreamingProcessor.h
@@ -0,0 +1,118 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2_STREAMINGPROCESSOR_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_STREAMINGPROCESSOR_H
+
+#include <utils/Mutex.h>
+#include <utils/String16.h>
+#include <gui/BufferItemConsumer.h>
+
+#include "Parameters.h"
+#include "CameraMetadata.h"
+
+namespace android {
+
+class Camera2Client;
+class IMemory;
+
+namespace camera2 {
+
+class Camera2Heap;
+
+/**
+ * Management and processing for preview and recording streams
+ */
+class StreamingProcessor: public BufferItemConsumer::FrameAvailableListener {
+ public:
+ StreamingProcessor(wp<Camera2Client> client);
+ ~StreamingProcessor();
+
+ status_t setPreviewWindow(sp<ANativeWindow> window);
+
+ bool haveValidPreviewWindow() const;
+
+ status_t updatePreviewRequest(const Parameters &params);
+ status_t updatePreviewStream(const Parameters &params);
+ status_t deletePreviewStream();
+ int getPreviewStreamId() const;
+
+ status_t setRecordingBufferCount(size_t count);
+ status_t updateRecordingRequest(const Parameters &params);
+ status_t updateRecordingStream(const Parameters &params);
+ status_t deleteRecordingStream();
+ int getRecordingStreamId() const;
+
+ enum StreamType {
+ NONE,
+ PREVIEW,
+ RECORD
+ };
+ status_t startStream(StreamType type,
+ const Vector<uint8_t> &outputStreams);
+
+ status_t stopStream();
+
+ // Returns the request ID for the currently streaming request
+ // Returns 0 if there is no active request.
+ status_t getActiveRequestId() const;
+ status_t incrementStreamingIds();
+
+ // Callback for new recording frames from HAL
+ virtual void onFrameAvailable();
+ // Callback from stagefright which returns used recording frames
+ void releaseRecordingFrame(const sp<IMemory>& mem);
+
+ status_t dump(int fd, const Vector<String16>& args);
+
+ private:
+ mutable Mutex mMutex;
+
+ enum {
+ NO_STREAM = -1
+ };
+
+ wp<Camera2Client> mClient;
+
+ StreamType mActiveRequest;
+
+ // Preview-related members
+ int32_t mPreviewRequestId;
+ int mPreviewStreamId;
+ CameraMetadata mPreviewRequest;
+ sp<ANativeWindow> mPreviewWindow;
+
+ // Recording-related members
+ int32_t mRecordingRequestId;
+ int mRecordingStreamId;
+ int mRecordingFrameCount;
+ sp<BufferItemConsumer> mRecordingConsumer;
+ sp<ANativeWindow> mRecordingWindow;
+ CameraMetadata mRecordingRequest;
+ sp<camera2::Camera2Heap> mRecordingHeap;
+
+ static const size_t kDefaultRecordingHeapCount = 8;
+ size_t mRecordingHeapCount;
+ Vector<BufferItemConsumer::BufferItem> mRecordingBuffers;
+ size_t mRecordingHeapHead, mRecordingHeapFree;
+
+};
+
+
+}; // namespace camera2
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.cpp b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
new file mode 100644
index 00000000..1937955a
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.cpp
@@ -0,0 +1,538 @@
+/*
+ * 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 "Camera2-ZslProcessor"
+#define ATRACE_TAG ATRACE_TAG_CAMERA
+//#define LOG_NDEBUG 0
+//#define LOG_NNDEBUG 0
+
+#ifdef LOG_NNDEBUG
+#define ALOGVV(...) ALOGV(__VA_ARGS__)
+#else
+#define ALOGVV(...) ((void)0)
+#endif
+
+#include <utils/Log.h>
+#include <utils/Trace.h>
+
+#include "ZslProcessor.h"
+#include <gui/SurfaceTextureClient.h>
+#include "../Camera2Device.h"
+#include "../Camera2Client.h"
+
+
+namespace android {
+namespace camera2 {
+
+ZslProcessor::ZslProcessor(
+ wp<Camera2Client> client,
+ wp<CaptureSequencer> sequencer):
+ Thread(false),
+ mState(RUNNING),
+ mClient(client),
+ mSequencer(sequencer),
+ mZslBufferAvailable(false),
+ mZslStreamId(NO_STREAM),
+ mZslReprocessStreamId(NO_STREAM),
+ mFrameListHead(0),
+ mZslQueueHead(0),
+ mZslQueueTail(0) {
+ mZslQueue.insertAt(0, kZslBufferDepth);
+ mFrameList.insertAt(0, kFrameListDepth);
+ sp<CaptureSequencer> captureSequencer = mSequencer.promote();
+ if (captureSequencer != 0) captureSequencer->setZslProcessor(this);
+}
+
+ZslProcessor::~ZslProcessor() {
+ ALOGV("%s: Exit", __FUNCTION__);
+ deleteStream();
+}
+
+void ZslProcessor::onFrameAvailable() {
+ Mutex::Autolock l(mInputMutex);
+ if (!mZslBufferAvailable) {
+ mZslBufferAvailable = true;
+ mZslBufferAvailableSignal.signal();
+ }
+}
+
+void ZslProcessor::onFrameAvailable(int32_t frameId, const CameraMetadata &frame) {
+ Mutex::Autolock l(mInputMutex);
+ camera_metadata_ro_entry_t entry;
+ entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
+ nsecs_t timestamp = entry.data.i64[0];
+ ALOGVV("Got preview frame for timestamp %lld", timestamp);
+
+ if (mState != RUNNING) return;
+
+ mFrameList.editItemAt(mFrameListHead) = frame;
+ mFrameListHead = (mFrameListHead + 1) % kFrameListDepth;
+
+ findMatchesLocked();
+}
+
+void ZslProcessor::onBufferReleased(buffer_handle_t *handle) {
+ Mutex::Autolock l(mInputMutex);
+
+ // Verify that the buffer is in our queue
+ size_t i = 0;
+ for (; i < mZslQueue.size(); i++) {
+ if (&(mZslQueue[i].buffer.mGraphicBuffer->handle) == handle) break;
+ }
+ if (i == mZslQueue.size()) {
+ ALOGW("%s: Released buffer %p not found in queue",
+ __FUNCTION__, handle);
+ }
+
+ // Erase entire ZSL queue since we've now completed the capture and preview
+ // is stopped.
+ clearZslQueueLocked();
+
+ mState = RUNNING;
+}
+
+status_t ZslProcessor::updateStream(const Parameters &params) {
+ ATRACE_CALL();
+ ALOGV("%s: Configuring ZSL streams", __FUNCTION__);
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ if (mZslConsumer == 0) {
+ // Create CPU buffer queue endpoint
+ mZslConsumer = new BufferItemConsumer(
+ GRALLOC_USAGE_HW_CAMERA_ZSL,
+ kZslBufferDepth,
+ true);
+ mZslConsumer->setFrameAvailableListener(this);
+ mZslConsumer->setName(String8("Camera2Client::ZslConsumer"));
+ mZslWindow = new SurfaceTextureClient(
+ mZslConsumer->getProducerInterface());
+ }
+
+ if (mZslStreamId != NO_STREAM) {
+ // Check if stream parameters have to change
+ uint32_t currentWidth, currentHeight;
+ res = device->getStreamInfo(mZslStreamId,
+ &currentWidth, &currentHeight, 0);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Error querying capture output stream info: "
+ "%s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ if (currentWidth != (uint32_t)params.fastInfo.arrayWidth ||
+ currentHeight != (uint32_t)params.fastInfo.arrayHeight) {
+ res = device->deleteReprocessStream(mZslReprocessStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old reprocess stream "
+ "for ZSL: %s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ ALOGV("%s: Camera %d: Deleting stream %d since the buffer dimensions changed",
+ __FUNCTION__, client->getCameraId(), mZslStreamId);
+ res = device->deleteStream(mZslStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to delete old output stream "
+ "for ZSL: %s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ return res;
+ }
+ mZslStreamId = NO_STREAM;
+ }
+ }
+
+ if (mZslStreamId == NO_STREAM) {
+ // Create stream for HAL production
+ // TODO: Sort out better way to select resolution for ZSL
+ int streamType = params.quirks.useZslFormat ?
+ (int)CAMERA2_HAL_PIXEL_FORMAT_ZSL :
+ (int)HAL_PIXEL_FORMAT_IMPLEMENTATION_DEFINED;
+ res = device->createStream(mZslWindow,
+ params.fastInfo.arrayWidth, params.fastInfo.arrayHeight,
+ streamType, 0,
+ &mZslStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't create output stream for ZSL: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ res = device->createReprocessStreamFromStream(mZslStreamId,
+ &mZslReprocessStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Can't create reprocess stream for ZSL: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ }
+ client->registerFrameListener(Camera2Client::kPreviewRequestIdStart,
+ Camera2Client::kPreviewRequestIdEnd,
+ this);
+
+ return OK;
+}
+
+status_t ZslProcessor::deleteStream() {
+ ATRACE_CALL();
+ status_t res;
+
+ Mutex::Autolock l(mInputMutex);
+
+ if (mZslStreamId != NO_STREAM) {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return OK;
+ sp<Camera2Device> device = client->getCameraDevice();
+
+ res = device->deleteReprocessStream(mZslReprocessStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Cannot delete ZSL reprocessing stream %d: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ mZslReprocessStreamId, strerror(-res), res);
+ return res;
+ }
+
+ mZslReprocessStreamId = NO_STREAM;
+ res = device->deleteStream(mZslStreamId);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Cannot delete ZSL output stream %d: "
+ "%s (%d)", __FUNCTION__, client->getCameraId(),
+ mZslStreamId, strerror(-res), res);
+ return res;
+ }
+
+ mZslWindow.clear();
+ mZslConsumer.clear();
+
+ mZslStreamId = NO_STREAM;
+ }
+ return OK;
+}
+
+int ZslProcessor::getStreamId() const {
+ Mutex::Autolock l(mInputMutex);
+ return mZslStreamId;
+}
+
+int ZslProcessor::getReprocessStreamId() const {
+ Mutex::Autolock l(mInputMutex);
+ return mZslReprocessStreamId;
+}
+
+status_t ZslProcessor::pushToReprocess(int32_t requestId) {
+ ALOGV("%s: Send in reprocess request with id %d",
+ __FUNCTION__, requestId);
+ Mutex::Autolock l(mInputMutex);
+ status_t res;
+ sp<Camera2Client> client = mClient.promote();
+
+ if (client == 0) return INVALID_OPERATION;
+
+ IF_ALOGV() {
+ dumpZslQueue(-1);
+ }
+
+ if (mZslQueueTail != mZslQueueHead) {
+ CameraMetadata request;
+ size_t index = mZslQueueTail;
+ while (index != mZslQueueHead) {
+ if (!mZslQueue[index].frame.isEmpty()) {
+ request = mZslQueue[index].frame;
+ break;
+ }
+ index = (index + 1) % kZslBufferDepth;
+ }
+ if (index == mZslQueueHead) {
+ ALOGV("%s: ZSL queue has no valid frames to send yet.",
+ __FUNCTION__);
+ return NOT_ENOUGH_DATA;
+ }
+ // Verify that the frame is reasonable for reprocessing
+
+ camera_metadata_entry_t entry;
+ entry = request.find(ANDROID_CONTROL_AE_STATE);
+ if (entry.count == 0) {
+ ALOGE("%s: ZSL queue frame has no AE state field!",
+ __FUNCTION__);
+ return BAD_VALUE;
+ }
+ if (entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_CONVERGED &&
+ entry.data.u8[0] != ANDROID_CONTROL_AE_STATE_LOCKED) {
+ ALOGV("%s: ZSL queue frame AE state is %d, need full capture",
+ __FUNCTION__, entry.data.u8[0]);
+ return NOT_ENOUGH_DATA;
+ }
+
+ buffer_handle_t *handle =
+ &(mZslQueue[index].buffer.mGraphicBuffer->handle);
+
+ uint8_t requestType = ANDROID_REQUEST_TYPE_REPROCESS;
+ res = request.update(ANDROID_REQUEST_TYPE,
+ &requestType, 1);
+ uint8_t inputStreams[1] = { mZslReprocessStreamId };
+ if (res == OK) request.update(ANDROID_REQUEST_INPUT_STREAMS,
+ inputStreams, 1);
+ uint8_t outputStreams[1] = { client->getCaptureStreamId() };
+ if (res == OK) request.update(ANDROID_REQUEST_OUTPUT_STREAMS,
+ outputStreams, 1);
+ res = request.update(ANDROID_REQUEST_ID,
+ &requestId, 1);
+
+ if (res != OK ) {
+ ALOGE("%s: Unable to update frame to a reprocess request", __FUNCTION__);
+ return INVALID_OPERATION;
+ }
+
+ res = client->stopStream();
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to stop preview for ZSL capture: "
+ "%s (%d)",
+ __FUNCTION__, client->getCameraId(), strerror(-res), res);
+ return INVALID_OPERATION;
+ }
+ // TODO: have push-and-clear be atomic
+ res = client->getCameraDevice()->pushReprocessBuffer(mZslReprocessStreamId,
+ handle, this);
+ if (res != OK) {
+ ALOGE("%s: Unable to push buffer for reprocessing: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ // Update JPEG settings
+ {
+ SharedParameters::Lock l(client->getParameters());
+ res = l.mParameters.updateRequestJpeg(&request);
+ if (res != OK) {
+ ALOGE("%s: Camera %d: Unable to update JPEG entries of ZSL "
+ "capture request: %s (%d)", __FUNCTION__,
+ client->getCameraId(),
+ strerror(-res), res);
+ return res;
+ }
+ }
+
+ mLatestCapturedRequest = request;
+ res = client->getCameraDevice()->capture(request);
+ if (res != OK ) {
+ ALOGE("%s: Unable to send ZSL reprocess request to capture: %s (%d)",
+ __FUNCTION__, strerror(-res), res);
+ return res;
+ }
+
+ mState = LOCKED;
+ } else {
+ ALOGV("%s: No ZSL buffers yet", __FUNCTION__);
+ return NOT_ENOUGH_DATA;
+ }
+ return OK;
+}
+
+status_t ZslProcessor::clearZslQueue() {
+ Mutex::Autolock l(mInputMutex);
+ // If in middle of capture, can't clear out queue
+ if (mState == LOCKED) return OK;
+
+ return clearZslQueueLocked();
+}
+
+status_t ZslProcessor::clearZslQueueLocked() {
+ for (size_t i = 0; i < mZslQueue.size(); i++) {
+ if (mZslQueue[i].buffer.mTimestamp != 0) {
+ mZslConsumer->releaseBuffer(mZslQueue[i].buffer);
+ }
+ mZslQueue.replaceAt(i);
+ }
+ mZslQueueHead = 0;
+ mZslQueueTail = 0;
+ return OK;
+}
+
+void ZslProcessor::dump(int fd, const Vector<String16>& args) const {
+ Mutex::Autolock l(mInputMutex);
+ if (!mLatestCapturedRequest.isEmpty()) {
+ String8 result(" Latest ZSL capture request:\n");
+ write(fd, result.string(), result.size());
+ mLatestCapturedRequest.dump(fd, 2, 6);
+ } else {
+ String8 result(" Latest ZSL capture request: none yet\n");
+ write(fd, result.string(), result.size());
+ }
+ dumpZslQueue(fd);
+}
+
+bool ZslProcessor::threadLoop() {
+ status_t res;
+
+ {
+ Mutex::Autolock l(mInputMutex);
+ while (!mZslBufferAvailable) {
+ res = mZslBufferAvailableSignal.waitRelative(mInputMutex,
+ kWaitDuration);
+ if (res == TIMED_OUT) return true;
+ }
+ mZslBufferAvailable = false;
+ }
+
+ do {
+ sp<Camera2Client> client = mClient.promote();
+ if (client == 0) return false;
+ res = processNewZslBuffer(client);
+ } while (res == OK);
+
+ return true;
+}
+
+status_t ZslProcessor::processNewZslBuffer(sp<Camera2Client> &client) {
+ ATRACE_CALL();
+ status_t res;
+
+ ALOGVV("Trying to get next buffer");
+ BufferItemConsumer::BufferItem item;
+ res = mZslConsumer->acquireBuffer(&item);
+ if (res != OK) {
+ if (res != BufferItemConsumer::NO_BUFFER_AVAILABLE) {
+ ALOGE("%s: Camera %d: Error receiving ZSL image buffer: "
+ "%s (%d)", __FUNCTION__,
+ client->getCameraId(), strerror(-res), res);
+ } else {
+ ALOGVV(" No buffer");
+ }
+ return res;
+ }
+
+ Mutex::Autolock l(mInputMutex);
+
+ if (mState == LOCKED) {
+ ALOGVV("In capture, discarding new ZSL buffers");
+ mZslConsumer->releaseBuffer(item);
+ return OK;
+ }
+
+ ALOGVV("Got ZSL buffer: head: %d, tail: %d", mZslQueueHead, mZslQueueTail);
+
+ if ( (mZslQueueHead + 1) % kZslBufferDepth == mZslQueueTail) {
+ ALOGVV("Releasing oldest buffer");
+ mZslConsumer->releaseBuffer(mZslQueue[mZslQueueTail].buffer);
+ mZslQueue.replaceAt(mZslQueueTail);
+ mZslQueueTail = (mZslQueueTail + 1) % kZslBufferDepth;
+ }
+
+ ZslPair &queueHead = mZslQueue.editItemAt(mZslQueueHead);
+
+ queueHead.buffer = item;
+ queueHead.frame.release();
+
+ mZslQueueHead = (mZslQueueHead + 1) % kZslBufferDepth;
+
+ ALOGVV(" Acquired buffer, timestamp %lld", queueHead.buffer.mTimestamp);
+
+ findMatchesLocked();
+
+ return OK;
+}
+
+void ZslProcessor::findMatchesLocked() {
+ ALOGVV("Scanning");
+ for (size_t i = 0; i < mZslQueue.size(); i++) {
+ ZslPair &queueEntry = mZslQueue.editItemAt(i);
+ nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
+ IF_ALOGV() {
+ camera_metadata_entry_t entry;
+ nsecs_t frameTimestamp = 0;
+ if (!queueEntry.frame.isEmpty()) {
+ entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
+ frameTimestamp = entry.data.i64[0];
+ }
+ ALOGVV(" %d: b: %lld\tf: %lld", i,
+ bufferTimestamp, frameTimestamp );
+ }
+ if (queueEntry.frame.isEmpty() && bufferTimestamp != 0) {
+ // Have buffer, no matching frame. Look for one
+ for (size_t j = 0; j < mFrameList.size(); j++) {
+ bool match = false;
+ CameraMetadata &frame = mFrameList.editItemAt(j);
+ if (!frame.isEmpty()) {
+ camera_metadata_entry_t entry;
+ entry = frame.find(ANDROID_SENSOR_TIMESTAMP);
+ if (entry.count == 0) {
+ ALOGE("%s: Can't find timestamp in frame!",
+ __FUNCTION__);
+ continue;
+ }
+ nsecs_t frameTimestamp = entry.data.i64[0];
+ if (bufferTimestamp == frameTimestamp) {
+ ALOGVV("%s: Found match %lld", __FUNCTION__,
+ frameTimestamp);
+ match = true;
+ } else {
+ int64_t delta = abs(bufferTimestamp - frameTimestamp);
+ if ( delta < 1000000) {
+ ALOGVV("%s: Found close match %lld (delta %lld)",
+ __FUNCTION__, bufferTimestamp, delta);
+ match = true;
+ }
+ }
+ }
+ if (match) {
+ queueEntry.frame.acquire(frame);
+ break;
+ }
+ }
+ }
+ }
+}
+
+void ZslProcessor::dumpZslQueue(int fd) const {
+ String8 header("ZSL queue contents:");
+ String8 indent(" ");
+ ALOGV("%s", header.string());
+ if (fd != -1) {
+ header = indent + header + "\n";
+ write(fd, header.string(), header.size());
+ }
+ for (size_t i = 0; i < mZslQueue.size(); i++) {
+ const ZslPair &queueEntry = mZslQueue[i];
+ nsecs_t bufferTimestamp = queueEntry.buffer.mTimestamp;
+ camera_metadata_ro_entry_t entry;
+ nsecs_t frameTimestamp = 0;
+ int frameAeState = -1;
+ if (!queueEntry.frame.isEmpty()) {
+ entry = queueEntry.frame.find(ANDROID_SENSOR_TIMESTAMP);
+ if (entry.count > 0) frameTimestamp = entry.data.i64[0];
+ entry = queueEntry.frame.find(ANDROID_CONTROL_AE_STATE);
+ if (entry.count > 0) frameAeState = entry.data.u8[0];
+ }
+ String8 result =
+ String8::format(" %d: b: %lld\tf: %lld, AE state: %d", i,
+ bufferTimestamp, frameTimestamp, frameAeState);
+ ALOGV("%s", result.string());
+ if (fd != -1) {
+ result = indent + result + "\n";
+ write(fd, result.string(), result.size());
+ }
+
+ }
+}
+
+}; // namespace camera2
+}; // namespace android
diff --git a/services/camera/libcameraservice/camera2/ZslProcessor.h b/services/camera/libcameraservice/camera2/ZslProcessor.h
new file mode 100644
index 00000000..c80e7f4d
--- /dev/null
+++ b/services/camera/libcameraservice/camera2/ZslProcessor.h
@@ -0,0 +1,126 @@
+/*
+ * 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 ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSOR_H
+#define ANDROID_SERVERS_CAMERA_CAMERA2_ZSLPROCESSOR_H
+
+#include <utils/Thread.h>
+#include <utils/String16.h>
+#include <utils/Vector.h>
+#include <utils/Mutex.h>
+#include <utils/Condition.h>
+#include <gui/BufferItemConsumer.h>
+#include "Parameters.h"
+#include "FrameProcessor.h"
+#include "CameraMetadata.h"
+#include "Camera2Heap.h"
+#include "../Camera2Device.h"
+
+namespace android {
+
+class Camera2Client;
+
+namespace camera2 {
+
+class CaptureSequencer;
+
+/***
+ * ZSL queue processing
+ */
+class ZslProcessor:
+ virtual public Thread,
+ virtual public BufferItemConsumer::FrameAvailableListener,
+ virtual public FrameProcessor::FilteredListener,
+ virtual public Camera2Device::BufferReleasedListener {
+ public:
+ ZslProcessor(wp<Camera2Client> client, wp<CaptureSequencer> sequencer);
+ ~ZslProcessor();
+
+ // From mZslConsumer
+ virtual void onFrameAvailable();
+ // From FrameProcessor
+ virtual void onFrameAvailable(int32_t frameId, const CameraMetadata &frame);
+
+ virtual void onBufferReleased(buffer_handle_t *handle);
+
+ status_t updateStream(const Parameters &params);
+ status_t deleteStream();
+ int getStreamId() const;
+ int getReprocessStreamId() const;
+
+ status_t pushToReprocess(int32_t requestId);
+ status_t clearZslQueue();
+
+ void dump(int fd, const Vector<String16>& args) const;
+ private:
+ static const nsecs_t kWaitDuration = 10000000; // 10 ms
+
+ enum {
+ RUNNING,
+ LOCKED
+ } mState;
+
+ wp<Camera2Client> mClient;
+ wp<CaptureSequencer> mSequencer;
+
+ mutable Mutex mInputMutex;
+ bool mZslBufferAvailable;
+ Condition mZslBufferAvailableSignal;
+
+ enum {
+ NO_STREAM = -1
+ };
+
+ int mZslStreamId;
+ int mZslReprocessStreamId;
+ sp<BufferItemConsumer> mZslConsumer;
+ sp<ANativeWindow> mZslWindow;
+
+ struct ZslPair {
+ BufferItemConsumer::BufferItem buffer;
+ CameraMetadata frame;
+ };
+
+ static const size_t kZslBufferDepth = 4;
+ static const size_t kFrameListDepth = kZslBufferDepth * 2;
+ Vector<CameraMetadata> mFrameList;
+ size_t mFrameListHead;
+
+ ZslPair mNextPair;
+
+ Vector<ZslPair> mZslQueue;
+ size_t mZslQueueHead;
+ size_t mZslQueueTail;
+
+ CameraMetadata mLatestCapturedRequest;
+
+ virtual bool threadLoop();
+
+ status_t processNewZslBuffer(sp<Camera2Client> &client);
+
+ // Match up entries from frame list to buffers in ZSL queue
+ void findMatchesLocked();
+
+ status_t clearZslQueueLocked();
+
+ void dumpZslQueue(int id) const;
+};
+
+
+}; //namespace camera2
+}; //namespace android
+
+#endif
diff --git a/tools/resampler_tools/Android.mk b/tools/resampler_tools/Android.mk
new file mode 100644
index 00000000..e8cbe397
--- /dev/null
+++ b/tools/resampler_tools/Android.mk
@@ -0,0 +1,17 @@
+# Copyright 2005 The Android Open Source Project
+#
+# Android.mk for resampler_tools
+#
+
+
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ fir.cpp
+
+LOCAL_MODULE := fir
+
+include $(BUILD_HOST_EXECUTABLE)
+
+
diff --git a/tools/resampler_tools/fir.cpp b/tools/resampler_tools/fir.cpp
new file mode 100644
index 00000000..cc3d509a
--- /dev/null
+++ b/tools/resampler_tools/fir.cpp
@@ -0,0 +1,281 @@
+/*
+ * Copyright (C) 2007 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 <math.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+
+static double sinc(double x) {
+ if (fabs(x) == 0.0f) return 1.0f;
+ return sin(x) / x;
+}
+
+static double sqr(double x) {
+ return x*x;
+}
+
+static double I0(double x) {
+ // from the Numerical Recipes in C p. 237
+ double ax,ans,y;
+ ax=fabs(x);
+ if (ax < 3.75) {
+ y=x/3.75;
+ y*=y;
+ ans=1.0+y*(3.5156229+y*(3.0899424+y*(1.2067492
+ +y*(0.2659732+y*(0.360768e-1+y*0.45813e-2)))));
+ } else {
+ y=3.75/ax;
+ ans=(exp(ax)/sqrt(ax))*(0.39894228+y*(0.1328592e-1
+ +y*(0.225319e-2+y*(-0.157565e-2+y*(0.916281e-2
+ +y*(-0.2057706e-1+y*(0.2635537e-1+y*(-0.1647633e-1
+ +y*0.392377e-2))))))));
+ }
+ return ans;
+}
+
+static double kaiser(int k, int N, double beta) {
+ if (k < 0 || k > N)
+ return 0;
+ return I0(beta * sqrt(1.0 - sqr((2.0*k)/N - 1.0))) / I0(beta);
+}
+
+
+static void usage(char* name) {
+ fprintf(stderr,
+ "usage: %s [-h] [-d] [-s sample_rate] [-c cut-off_frequency] [-n half_zero_crossings] [-f {float|fixed}] [-b beta] [-v dBFS] [-l lerp]\n"
+ " %s [-h] [-d] [-s sample_rate] [-c cut-off_frequency] [-n half_zero_crossings] [-f {float|fixed}] [-b beta] [-v dBFS] -p M/N\n"
+ " -h this help message\n"
+ " -d debug, print comma-separated coefficient table\n"
+ " -p generate poly-phase filter coefficients, with sample increment M/N\n"
+ " -s sample rate (48000)\n"
+ " -c cut-off frequency (20478)\n"
+ " -n number of zero-crossings on one side (8)\n"
+ " -l number of lerping bits (4)\n"
+ " -f output format, can be fixed-point or floating-point (fixed)\n"
+ " -b kaiser window parameter beta (7.865 [-80dB])\n"
+ " -v attenuation in dBFS (0)\n",
+ name, name
+ );
+ exit(0);
+}
+
+int main(int argc, char** argv)
+{
+ // nc is the number of bits to store the coefficients
+ const int nc = 32;
+
+ bool polyphase = false;
+ unsigned int polyM = 160;
+ unsigned int polyN = 147;
+ bool debug = false;
+ double Fs = 48000;
+ double Fc = 20478;
+ double atten = 1;
+ int format = 0;
+
+
+ // in order to keep the errors associated with the linear
+ // interpolation of the coefficients below the quantization error
+ // we must satisfy:
+ // 2^nz >= 2^(nc/2)
+ //
+ // for 16 bit coefficients that would be 256
+ //
+ // note that increasing nz only increases memory requirements,
+ // but doesn't increase the amount of computation to do.
+ //
+ //
+ // see:
+ // Smith, J.O. Digital Audio Resampling Home Page
+ // https://ccrma.stanford.edu/~jos/resample/, 2011-03-29
+ //
+ int nz = 4;
+
+ // | 0.1102*(A - 8.7) A > 50
+ // beta = | 0.5842*(A - 21)^0.4 + 0.07886*(A - 21) 21 <= A <= 50
+ // | 0 A < 21
+ // with A is the desired stop-band attenuation in dBFS
+ //
+ // for eg:
+ //
+ // 30 dB 2.210
+ // 40 dB 3.384
+ // 50 dB 4.538
+ // 60 dB 5.658
+ // 70 dB 6.764
+ // 80 dB 7.865
+ // 90 dB 8.960
+ // 100 dB 10.056
+ double beta = 7.865;
+
+
+ // 2*nzc = (A - 8) / (2.285 * dw)
+ // with dw the transition width = 2*pi*dF/Fs
+ //
+ int nzc = 8;
+
+ //
+ // Example:
+ // 44.1 KHz to 48 KHz resampling
+ // 100 dB rejection above 28 KHz
+ // (the spectrum will fold around 24 KHz and we want 100 dB rejection
+ // at the point where the folding reaches 20 KHz)
+ // ...___|_____
+ // | \|
+ // | ____/|\____
+ // |/alias| \
+ // ------/------+------\---------> KHz
+ // 20 24 28
+
+ // Transition band 8 KHz, or dw = 1.0472
+ //
+ // beta = 10.056
+ // nzc = 20
+ //
+
+ int ch;
+ while ((ch = getopt(argc, argv, ":hds:c:n:f:l:b:p:v:")) != -1) {
+ switch (ch) {
+ case 'd':
+ debug = true;
+ break;
+ case 'p':
+ if (sscanf(optarg, "%u/%u", &polyM, &polyN) != 2) {
+ usage(argv[0]);
+ }
+ polyphase = true;
+ break;
+ case 's':
+ Fs = atof(optarg);
+ break;
+ case 'c':
+ Fc = atof(optarg);
+ break;
+ case 'n':
+ nzc = atoi(optarg);
+ break;
+ case 'l':
+ nz = atoi(optarg);
+ break;
+ case 'f':
+ if (!strcmp(optarg,"fixed")) format = 0;
+ else if (!strcmp(optarg,"float")) format = 1;
+ else usage(argv[0]);
+ break;
+ case 'b':
+ beta = atof(optarg);
+ break;
+ case 'v':
+ atten = pow(10, -fabs(atof(optarg))*0.05 );
+ break;
+ case 'h':
+ default:
+ usage(argv[0]);
+ break;
+ }
+ }
+
+ // cut off frequency ratio Fc/Fs
+ double Fcr = Fc / Fs;
+
+
+ // total number of coefficients (one side)
+ const int M = (1 << nz);
+ const int N = M * nzc;
+
+ // generate the right half of the filter
+ if (!debug) {
+ printf("// cmd-line: ");
+ for (int i=1 ; i<argc ; i++) {
+ printf("%s ", argv[i]);
+ }
+ printf("\n");
+ if (!polyphase) {
+ printf("const int32_t RESAMPLE_FIR_SIZE = %d;\n", N);
+ printf("const int32_t RESAMPLE_FIR_LERP_INT_BITS = %d;\n", nz);
+ printf("const int32_t RESAMPLE_FIR_NUM_COEF = %d;\n", nzc);
+ } else {
+ printf("const int32_t RESAMPLE_FIR_SIZE = %d;\n", 2*nzc*polyN);
+ printf("const int32_t RESAMPLE_FIR_NUM_COEF = %d;\n", 2*nzc);
+ }
+ if (!format) {
+ printf("const int32_t RESAMPLE_FIR_COEF_BITS = %d;\n", nc);
+ }
+ printf("\n");
+ printf("static %s resampleFIR[] = {", !format ? "int32_t" : "float");
+ }
+
+ if (!polyphase) {
+ for (int i=0 ; i<=M ; i++) { // an extra set of coefs for interpolation
+ for (int j=0 ; j<nzc ; j++) {
+ int ix = j*M + i;
+ double x = (2.0 * M_PI * ix * Fcr) / (1 << nz);
+ double y = kaiser(ix+N, 2*N, beta) * sinc(x) * 2.0 * Fcr;
+ y *= atten;
+
+ if (!debug) {
+ if (j == 0)
+ printf("\n ");
+ }
+
+ if (!format) {
+ int64_t yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
+ if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;
+ printf("0x%08x, ", int32_t(yi));
+ } else {
+ printf("%.9g%s ", y, debug ? "," : "f,");
+ }
+ }
+ }
+ } else {
+ for (int j=0 ; j<polyN ; j++) {
+ // calculate the phase
+ double p = ((polyM*j) % polyN) / double(polyN);
+ if (!debug) printf("\n ");
+ else printf("\n");
+ // generate a FIR per phase
+ for (int i=-nzc ; i<nzc ; i++) {
+ double x = 2.0 * M_PI * Fcr * (i + p);
+ double y = kaiser(i+N, 2*N, beta) * sinc(x) * 2.0 * Fcr;;
+ y *= atten;
+ if (!format) {
+ int64_t yi = floor(y * ((1ULL<<(nc-1))) + 0.5);
+ if (yi >= (1LL<<(nc-1))) yi = (1LL<<(nc-1))-1;
+ printf("0x%08x", int32_t(yi));
+ } else {
+ printf("%.9g%s", y, debug ? "" : "f");
+ }
+
+ if (debug && (i==nzc-1)) {
+ } else {
+ printf(", ");
+ }
+ }
+ }
+ }
+
+ if (!debug) {
+ printf("\n};");
+ }
+ printf("\n");
+ return 0;
+}
+
+// http://www.csee.umbc.edu/help/sound/AFsp-V2R1/html/audio/ResampAudio.html
+
+