am 3ca352c4: am 24893fef: Merge "MPEG2TSWriter: Write a proper CRC in PAT and PMT"

* commit '3ca352c4cd01f6df3b691f835efc68a5771e724e':
  MPEG2TSWriter: Write a proper CRC in PAT and PMT
diff --git a/camera/CameraParameters.cpp b/camera/CameraParameters.cpp
index 059a8a5..872512a 100644
--- a/camera/CameraParameters.cpp
+++ b/camera/CameraParameters.cpp
@@ -155,6 +155,7 @@
 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 8687fab..1247588 100644
--- a/cmds/stagefright/Android.mk
+++ b/cmds/stagefright/Android.mk
@@ -104,7 +104,7 @@
 
 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 f3370a5..bfe20cc 100644
--- a/cmds/stagefright/codec.cpp
+++ b/cmds/stagefright/codec.cpp
@@ -35,6 +35,7 @@
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/NuMediaExtractor.h>
 #include <gui/SurfaceComposerClient.h>
+#include <ui/DisplayInfo.h>
 
 static void usage(const char *me) {
     fprintf(stderr, "usage: %s [-a] use audio\n"
@@ -378,8 +379,10 @@
         composerClient = new SurfaceComposerClient;
         CHECK_EQ(composerClient->initCheck(), (status_t)OK);
 
-        ssize_t displayWidth = composerClient->getDisplayWidth(0);
-        ssize_t displayHeight = composerClient->getDisplayHeight(0);
+        DisplayInfo info;
+        SurfaceComposerClient::getDisplayInfo(0, &info);
+        ssize_t displayWidth = info.w;
+        ssize_t displayHeight = info.h;
 
         ALOGV("display is %ld x %ld\n", displayWidth, displayHeight);
 
diff --git a/cmds/stagefright/stream.cpp b/cmds/stagefright/stream.cpp
index efa1445..ac88d1f 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>
@@ -35,6 +36,7 @@
 #include <gui/SurfaceComposerClient.h>
 
 #include <fcntl.h>
+#include <ui/DisplayInfo.h>
 
 using namespace android;
 
@@ -304,8 +306,10 @@
     sp<SurfaceComposerClient> composerClient = new SurfaceComposerClient;
     CHECK_EQ(composerClient->initCheck(), (status_t)OK);
 
-    ssize_t displayWidth = composerClient->getDisplayWidth(0);
-    ssize_t displayHeight = composerClient->getDisplayHeight(0);
+    DisplayInfo info;
+    SurfaceComposerClient::getDisplayInfo(0, &info);
+    ssize_t displayWidth = info.w;
+    ssize_t displayHeight = info.h;
 
     ALOGV("display is %d x %d\n", displayWidth, displayHeight);
 
@@ -339,8 +343,16 @@
 
     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/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c b/drm/libdrmframework/plugins/forward-lock/internal-format/converter/FwdLockConv.c
index 299116d..bb97abc 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 @@
     }
     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 e20c0c3..6449d89 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_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/include/camera/CameraParameters.h b/include/camera/CameraParameters.h
index 36248a0..4d5aa36 100644
--- a/include/camera/CameraParameters.h
+++ b/include/camera/CameraParameters.h
@@ -606,6 +606,8 @@
     // 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/media/AudioRecord.h b/include/media/AudioRecord.h
index ef77692..156c592 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -17,21 +17,14 @@
 #ifndef AUDIORECORD_H_
 #define AUDIORECORD_H_
 
-#include <stdint.h>
-#include <sys/types.h>
-
-#include <media/IAudioFlinger.h>
-#include <media/IAudioRecord.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>
+#include <media/IAudioRecord.h>
+#include <system/audio.h>
+#include <utils/RefBase.h>
+#include <utils/Errors.h>
+#include <utils/threads.h>
 
 namespace android {
 
@@ -46,11 +39,10 @@
     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 @@
         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 @@
         };
     };
 
-    /* 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 @@
      *          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 @@
      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 @@
      * 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 @@
 
 
     /* 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 @@
             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 @@
      */
             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 @@
      * 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 @@
             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 @@
      */
             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 @@
             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;
 
+    bool                    mActive;            // protected by mLock
+
+    // 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_track_cblk_t*     mCblk;
     audio_format_t          mFormat;
     uint8_t                 mChannelCount;
     audio_source_t          mInputSource;
     status_t                mStatus;
     uint32_t                mLatency;
-
-    volatile int32_t        mActive;
-
-    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;
+    audio_channel_mask_t    mChannelMask;
+    audio_io_handle_t       mInput;                     // returned by AudioSystem::getInput()
     int                     mSessionId;
+
+    // may be changed if IAudioRecord object is re-created
+    sp<IAudioRecord>        mAudioRecord;
+    sp<IMemory>             mCblkMemory;
+    audio_track_cblk_t*     mCblk;
+
     int                     mPreviousPriority;          // before start()
     SchedPolicy             mPreviousSchedulingGroup;
 };
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index e2662f2..932482b 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -110,8 +110,8 @@
 
     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 +126,7 @@
     // 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 +189,7 @@
     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 +201,7 @@
     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 +219,8 @@
     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,
@@ -277,7 +277,7 @@
     // 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 639d6d2..4488ce4 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -135,7 +135,7 @@
      * 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 @@
                         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 @@
                         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 @@
      * 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,10 +472,8 @@
     private:
         friend class AudioTrack;
         virtual bool        threadLoop();
-        virtual status_t    readyToRun();
-        virtual void        onFirstRef();
         AudioTrack& mReceiver;
-        ~AudioTrackThread();
+        virtual ~AudioTrackThread();
         Mutex               mMyLock;    // Thread::mLock is private
         Condition           mMyCond;    // Thread::mThreadExitedCondition is private
         bool                mPaused;    // whether thread is currently paused
@@ -487,7 +485,7 @@
             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 @@
     uint8_t                 mChannelCount;
     uint8_t                 mMuted;
     uint8_t                 mReserved;
-    uint32_t                mChannelMask;
+    audio_channel_mask_t    mChannelMask;
     status_t                mStatus;
     uint32_t                mLatency;
 
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 86e228b..bdd0142 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -48,7 +48,7 @@
     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 @@
                                 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 @@
                                 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 @@
      * 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 @@
     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,
diff --git a/include/media/IAudioPolicyService.h b/include/media/IAudioPolicyService.h
index e160d70..fb556af 100644
--- a/include/media/IAudioPolicyService.h
+++ b/include/media/IAudioPolicyService.h
@@ -51,7 +51,7 @@
     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 @@
     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 @@
                                           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,
diff --git a/include/media/IAudioRecord.h b/include/media/IAudioRecord.h
index ebc03ea..d6e3141 100644
--- a/include/media/IAudioRecord.h
+++ b/include/media/IAudioRecord.h
@@ -37,7 +37,7 @@
     /* 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/Visualizer.h b/include/media/Visualizer.h
index fdec5ee..aa58905 100644
--- a/include/media/Visualizer.h
+++ b/include/media/Visualizer.h
@@ -142,8 +142,6 @@
     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 534afce..0df77c1 100644
--- a/include/media/mediametadataretriever.h
+++ b/include/media/mediametadataretriever.h
@@ -55,6 +55,7 @@
     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 1fad383..f7cebc5 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -99,6 +99,8 @@
     // 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.
diff --git a/include/media/stagefright/CameraSource.h b/include/media/stagefright/CameraSource.h
index 5a35358..6d6b8a9 100644
--- a/include/media/stagefright/CameraSource.h
+++ b/include/media/stagefright/CameraSource.h
@@ -137,6 +137,7 @@
 
     int32_t  mCameraFlags;
     Size     mVideoSize;
+    int32_t  mNumInputBuffers;
     int32_t  mVideoFrameRate;
     int32_t  mColorFormat;
     status_t mInitCheck;
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index 3c25a14..e91904c 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -111,6 +111,7 @@
     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/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 81350ca..bb9e595 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -98,9 +98,13 @@
         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 @@
             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);
@@ -342,8 +345,6 @@
 
     status_t configureCodec(const sp<MetaData> &meta);
 
-    void restorePatchedDataPointer(BufferInfo *info);
-
     status_t applyRotation();
     status_t waitForBufferFilled_l();
 
diff --git a/include/media/stagefright/foundation/hexdump.h b/include/media/stagefright/foundation/hexdump.h
index f6083a9..8360c5a 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 cde551b..f23c337 100644
--- a/include/media/stagefright/timedtext/TimedTextDriver.h
+++ b/include/media/stagefright/timedtext/TimedTextDriver.h
@@ -64,6 +64,7 @@
 
     enum State {
         UNINITIALIZED,
+        PREPARED,
         PLAYING,
         PAUSED,
     };
diff --git a/libvideoeditor/lvpp/Android.mk b/libvideoeditor/lvpp/Android.mk
index c018d74..0ed7e6c 100755
--- a/libvideoeditor/lvpp/Android.mk
+++ b/libvideoeditor/lvpp/Android.mk
@@ -59,6 +59,7 @@
     libstagefright            \
     libstagefright_foundation \
     libstagefright_omx        \
+    libsync                   \
     libui                     \
     libutils                  \
     libvideoeditor_osal       \
diff --git a/libvideoeditor/lvpp/NativeWindowRenderer.cpp b/libvideoeditor/lvpp/NativeWindowRenderer.cpp
index b2c2675..2e15ff9 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 @@
     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 @@
     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 4aa4eb3..b1cfc8e 100755
--- a/libvideoeditor/lvpp/PreviewRenderer.cpp
+++ b/libvideoeditor/lvpp/PreviewRenderer.cpp
@@ -97,13 +97,12 @@
 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 @@
     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 797686c..c111ba8 100755
--- a/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
+++ b/libvideoeditor/lvpp/VideoEditorAudioPlayer.cpp
@@ -534,9 +534,7 @@
     } 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/vss/stagefrightshells/src/VideoEditor3gpReader.cpp b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
index 5026073..f735c0b 100755
--- a/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
+++ b/libvideoeditor/vss/stagefrightshells/src/VideoEditor3gpReader.cpp
@@ -1483,11 +1483,15 @@
                     (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/media/libeffects/factory/EffectsFactory.c b/media/libeffects/factory/EffectsFactory.c
index 59cd9e3..f158929 100644
--- a/media/libeffects/factory/EffectsFactory.c
+++ b/media/libeffects/factory/EffectsFactory.c
@@ -214,7 +214,7 @@
     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 @@
     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/wrapper/Bundle/EffectBundle.cpp b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
index 40dffd4..1a45e35 100644
--- a/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
+++ b/media/libeffects/lvm/wrapper/Bundle/EffectBundle.cpp
@@ -180,16 +180,16 @@
     }
     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;
@@ -494,7 +494,7 @@
         return  -EINVAL;
     }
 
-    memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+    *pDescriptor = *desc;
 
     return 0;
 } /* end EffectGetDescriptor */
@@ -965,7 +965,7 @@
               || 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:
@@ -1041,7 +1041,7 @@
 
 void Effect_getConfig(EffectContext *pContext, effect_config_t *pConfig)
 {
-    memcpy(pConfig, &pContext->config, sizeof(effect_config_t));
+    *pConfig = pContext->config;
 }   /* end Effect_getConfig */
 
 //----------------------------------------------------------------------------
@@ -3272,7 +3272,7 @@
             return -EINVAL;
     }
 
-    memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+    *pDescriptor = *desc;
 
     return 0;
 }   /* end Effect_getDescriptor */
diff --git a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
index 9599dcc..941d651 100755
--- a/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
+++ b/media/libeffects/lvm/wrapper/Reverb/EffectReverb.cpp
@@ -206,7 +206,7 @@
         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 @@
 
     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 @@
     }
 
     //ALOGV("\tReverb_setConfig calling memcpy");
-    memcpy(&pContext->config, pConfig, sizeof(effect_config_t));
+    pContext->config = *pConfig;
 
 
     switch (pConfig->inputCfg.samplingRate) {
@@ -715,7 +715,7 @@
 
 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 @@
         }
     }
 
-    memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+    *pDescriptor = *desc;
 
     return 0;
 }   /* end Reverb_getDescriptor */
diff --git a/media/libeffects/preprocessing/PreProcessing.cpp b/media/libeffects/preprocessing/PreProcessing.cpp
index cfa7f51..5709837 100755
--- a/media/libeffects/preprocessing/PreProcessing.cpp
+++ b/media/libeffects/preprocessing/PreProcessing.cpp
@@ -1700,7 +1700,7 @@
         return -EINVAL;
     }
 
-    memcpy(pDescriptor, sDescriptors[effect->procId], sizeof(effect_descriptor_t));
+    *pDescriptor = *sDescriptors[effect->procId];
 
     return 0;
 }
@@ -1834,7 +1834,7 @@
     if (index >= PREPROC_NUM_EFFECTS) {
         return -EINVAL;
     }
-    memcpy(pDescriptor, sDescriptors[index], sizeof(effect_descriptor_t));
+    *pDescriptor = *sDescriptors[index];
     return 0;
 }
 
@@ -1905,7 +1905,7 @@
 
     ALOGV("PreProcessingLib_GetDescriptor() got fx %s", desc->name);
 
-    memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+    *pDescriptor = *desc;
     return 0;
 }
 
diff --git a/media/libeffects/testlibs/EffectEqualizer.cpp b/media/libeffects/testlibs/EffectEqualizer.cpp
index 35a4a61..90ebe1f 100644
--- a/media/libeffects/testlibs/EffectEqualizer.cpp
+++ b/media/libeffects/testlibs/EffectEqualizer.cpp
@@ -136,7 +136,7 @@
     if (index > 0) {
         return -EINVAL;
     }
-    memcpy(pDescriptor, &gEqualizerDescriptor, sizeof(effect_descriptor_t));
+    *pDescriptor = gEqualizerDescriptor;
     return 0;
 } /* end EffectQueryNext */
 
@@ -204,7 +204,7 @@
     }
 
     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 @@
     }
     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 @@
 
 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 @@
         return -EINVAL;
     }
 
-    memcpy(pDescriptor, &android::gEqualizerDescriptor, sizeof(effect_descriptor_t));
+    *pDescriptor = android::gEqualizerDescriptor;
 
     return 0;
 }
diff --git a/media/libeffects/testlibs/EffectReverb.c b/media/libeffects/testlibs/EffectReverb.c
index 8351712..a87a834 100644
--- a/media/libeffects/testlibs/EffectReverb.c
+++ b/media/libeffects/testlibs/EffectReverb.c
@@ -194,7 +194,7 @@
 
     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 @@
         }
     }
 
-    memcpy(pDescriptor, desc, sizeof(effect_descriptor_t));
+    *pDescriptor = *desc;
 
     return 0;
 }   /* end Reverb_getDescriptor */
@@ -546,7 +546,7 @@
         return -EINVAL;
     }
 
-    memcpy(&pRvbModule->config, pConfig, sizeof(effect_config_t));
+    pRvbModule->config = *pConfig;
 
     pReverb->m_nSamplingRate = pRvbModule->config.outputCfg.samplingRate;
 
@@ -644,7 +644,7 @@
 
 void Reverb_getConfig(reverb_module_t *pRvbModule, effect_config_t *pConfig)
 {
-    memcpy(pConfig, &pRvbModule->config, sizeof(effect_config_t));
+    *pConfig = pRvbModule->config;
 }
 
 /*----------------------------------------------------------------------------
diff --git a/media/libeffects/visualizer/EffectVisualizer.cpp b/media/libeffects/visualizer/EffectVisualizer.cpp
index d3c69f4..44baf93 100644
--- a/media/libeffects/visualizer/EffectVisualizer.cpp
+++ b/media/libeffects/visualizer/EffectVisualizer.cpp
@@ -106,7 +106,7 @@
             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 @@
 
 void Visualizer_getConfig(VisualizerContext *pContext, effect_config_t *pConfig)
 {
-    memcpy(pConfig, &pContext->mConfig, sizeof(effect_config_t));
+    *pConfig = pContext->mConfig;
 }
 
 
@@ -190,7 +190,7 @@
     if (index > 0) {
         return -EINVAL;
     }
-    memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+    *pDescriptor = gVisualizerDescriptor;
     return 0;
 }
 
@@ -253,7 +253,7 @@
     }
 
     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 @@
         return -EINVAL;
     }
 
-    memcpy(pDescriptor, &gVisualizerDescriptor, sizeof(effect_descriptor_t));
+    *pDescriptor = gVisualizerDescriptor;
 
     return 0;
 }   /* end Visualizer_getDescriptor */
diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp
index 34451ca..680604b 100644
--- a/media/libmedia/AudioEffect.cpp
+++ b/media/libmedia/AudioEffect.cpp
@@ -122,19 +122,12 @@
     mSessionId = sessionId;
 
     memset(&mDescriptor, 0, sizeof(effect_descriptor_t));
-    memcpy(&mDescriptor.type, EFFECT_UUID_NULL, sizeof(effect_uuid_t));
-    memcpy(&mDescriptor.uuid, EFFECT_UUID_NULL, sizeof(effect_uuid_t));
-
-    if (type != NULL) {
-        memcpy(&mDescriptor.type, type, sizeof(effect_uuid_t));
-    }
-    if (uuid != NULL) {
-        memcpy(&mDescriptor.uuid, uuid, sizeof(effect_uuid_t));
-    }
+    mDescriptor.type = *(type != NULL ? type : EFFECT_UUID_NULL);
+    mDescriptor.uuid = *(uuid != NULL ? uuid : EFFECT_UUID_NULL);
 
     mIEffectClient = new EffectClient(this);
 
-    iEffect = audioFlinger->createEffect(getpid(), (effect_descriptor_t *)&mDescriptor,
+    iEffect = audioFlinger->createEffect(getpid(), &mDescriptor,
             mIEffectClient, priority, io, mSessionId, &mStatus, &mId, &enabled);
 
     if (iEffect == 0 || (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS)) {
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 0562f8e..5060525 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -18,29 +18,19 @@
 //#define LOG_NDEBUG 0
 #define LOG_TAG "AudioRecord"
 
-#include <stdint.h>
+#include <sys/resource.h>
 #include <sys/types.h>
 
-#include <sched.h>
-#include <sys/resource.h>
+#include <binder/IPCThreadState.h>
+#include <cutils/atomic.h>
+#include <cutils/compiler.h>
+#include <media/AudioRecord.h>
+#include <media/AudioSystem.h>
+#include <system/audio.h>
+#include <utils/Log.h>
 
 #include <private/media/AudioTrackShared.h>
 
-#include <media/AudioSystem.h>
-#include <media/AudioRecord.h>
-#include <media/mediarecorder.h>
-
-#include <binder/IServiceManager.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>
-
 namespace android {
 // ---------------------------------------------------------------------------
 
@@ -49,18 +39,23 @@
         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 @@
     size <<= 1;
 
     if (audio_is_linear_pcm(format)) {
+        int channelCount = popcount(channelMask);
         size /= channelCount * audio_bytes_per_sample(format);
     }
 
@@ -87,9 +83,8 @@
         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 @@
       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 @@
         // 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 @@
         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 @@
         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 @@
                                                     sampleRate,
                                                     format,
                                                     channelMask,
-                                                    (audio_in_acoustics_t)flags,
                                                     mSessionId);
     if (input == 0) {
         ALOGE("Could not get audio input for record source %d", inputSource);
@@ -207,7 +201,8 @@
     }
 
     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 @@
     mFrameCount = mCblk->frameCount;
     mChannelCount = (uint8_t)channelCount;
     mChannelMask = channelMask;
-    mActive = 0;
+    mActive = false;
     mCbf = cbf;
     mNotificationFrames = notificationFrames;
     mRemainingFrames = notificationFrames;
@@ -229,7 +224,6 @@
     mNewPosition = 0;
     mUpdatePeriod = 0;
     mInputSource = inputSource;
-    mFlags = flags;
     mInput = input;
     AudioSystem::acquireAudioSessionId(mSessionId);
 
@@ -282,41 +276,19 @@
 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 @@
                                             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 @@
 {
     if (mCbf == NULL) return INVALID_OPERATION;
 
+    AutoMutex lock(mLock);
     mMarkerPosition = marker;
     mMarkerReached = false;
 
@@ -407,6 +373,7 @@
 {
     if (marker == NULL) return BAD_VALUE;
 
+    AutoMutex lock(mLock);
     *marker = mMarkerPosition;
 
     return NO_ERROR;
@@ -418,6 +385,8 @@
 
     uint32_t curPosition;
     getPosition(&curPosition);
+
+    AutoMutex lock(mLock);
     mNewPosition = curPosition + updatePeriod;
     mUpdatePeriod = updatePeriod;
 
@@ -428,6 +397,7 @@
 {
     if (updatePeriod == NULL) return BAD_VALUE;
 
+    AutoMutex lock(mLock);
     *updatePeriod = mUpdatePeriod;
 
     return NO_ERROR;
@@ -445,10 +415,8 @@
 
 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 @@
 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 @@
         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::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 @@
                 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 @@
                                 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 @@
 
 // -------------------------------------------------------------------------
 
-bool AudioRecord::processAudioBuffer(const sp<ClientRecordThread>& thread)
+bool AudioRecord::processAudioBuffer(const sp<AudioRecordThread>& thread)
 {
     Buffer audioBuffer;
     uint32_t frames = mRemainingFrames;
@@ -690,22 +665,32 @@
     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 @@
 
 
     // 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 @@
             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 @@
 
 // =========================================================================
 
-AudioRecord::ClientRecordThread::ClientRecordThread(AudioRecord& receiver, bool bCanCallJava)
-    : Thread(bCanCallJava), mReceiver(receiver)
+AudioRecord::AudioRecordThread::AudioRecordThread(AudioRecord& receiver, bool bCanCallJava)
+    : Thread(bCanCallJava), mReceiver(receiver), mPaused(true)
 {
 }
 
-bool AudioRecord::ClientRecordThread::threadLoop()
+AudioRecord::AudioRecordThread::~AudioRecordThread()
 {
-    return mReceiver.processAudioBuffer(this);
 }
 
-status_t AudioRecord::ClientRecordThread::readyToRun()
+bool AudioRecord::AudioRecordThread::threadLoop()
 {
-    AutoMutex(mReceiver.mLock);
-    while (mReceiver.mReadyToRun == WOULD_BLOCK) {
-        mReceiver.mCondition.wait(mReceiver.mLock);
+    {
+        AutoMutex _l(mMyLock);
+        if (mPaused) {
+            mMyCond.wait(mMyLock);
+            // caller will check for exitPending()
+            return true;
+        }
     }
-    return mReceiver.mReadyToRun;
+    if (!mReceiver.processAudioBuffer(this)) {
+        pause();
+    }
+    return true;
+}
+
+void AudioRecord::AudioRecordThread::requestExit()
+{
+    // must be in this order to avoid a race condition
+    Thread::requestExit();
+    resume();
+}
+
+void AudioRecord::AudioRecordThread::pause()
+{
+    AutoMutex _l(mMyLock);
+    mPaused = true;
+}
+
+void AudioRecord::AudioRecordThread::resume()
+{
+    AutoMutex _l(mMyLock);
+    if (mPaused) {
+        mPaused = false;
+        mMyCond.signal();
+    }
 }
 
 // -------------------------------------------------------------------------
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 4c41ba5..6e0c620 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -41,7 +41,7 @@
 // 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 @@
     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 @@
 
         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 @@
         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_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 @@
 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 @@
     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,
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index e5a60f5..0ca035f 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -54,6 +54,11 @@
         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 @@
         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 @@
       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 @@
         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 @@
         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 @@
     }
 
     if (!audio_is_output_channel(channelMask)) {
-        ALOGE("Invalid channel mask");
+        ALOGE("Invalid channel mask %#x", channelMask);
         return BAD_VALUE;
     }
     uint32_t channelCount = popcount(channelMask);
@@ -272,34 +278,29 @@
     mFlags = flags;
     mCbf = cbf;
 
-    if (cbf != NULL) {
-        mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
-        mAudioTrackThread->run("AudioTrack", ANDROID_PRIORITY_AUDIO, 0 /*stack*/);
-    }
-
     // create the IAudioTrack
     status_t status = createTrack_l(streamType,
                                   sampleRate,
                                   format,
-                                  (uint32_t)channelMask,
+                                  channelMask,
                                   frameCount,
                                   flags,
                                   sharedBuffer,
                                   output);
-
     if (status != NO_ERROR) {
-        if (mAudioTrackThread != 0) {
-            mAudioTrackThread->requestExit();
-            mAudioTrackThread.clear();
-        }
         return status;
     }
 
+    if (cbf != NULL) {
+        mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
+        mAudioTrackThread->run("AudioTrack", ANDROID_PRIORITY_AUDIO);
+    }
+
     mStatus = NO_ERROR;
 
     mStreamType = streamType;
     mFormat = format;
-    mChannelMask = (uint32_t)channelMask;
+    mChannelMask = channelMask;
     mChannelCount = channelCount;
     mSharedBuffer = sharedBuffer;
     mMuted = false;
@@ -367,7 +368,6 @@
 void AudioTrack::start()
 {
     sp<AudioTrackThread> t = mAudioTrackThread;
-    status_t status = NO_ERROR;
 
     ALOGV("start %p", this);
 
@@ -395,6 +395,7 @@
         }
 
         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 +745,7 @@
         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,
@@ -1472,15 +1473,6 @@
     return true;
 }
 
-status_t AudioTrack::AudioTrackThread::readyToRun()
-{
-    return NO_ERROR;
-}
-
-void AudioTrack::AudioTrackThread::onFirstRef()
-{
-}
-
 void AudioTrack::AudioTrackThread::requestExit()
 {
     // must be in this order to avoid a race condition
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index e8dd438..71e7c31 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -32,7 +32,7 @@
     CREATE_TRACK = IBinder::FIRST_CALL_TRANSACTION,
     OPEN_RECORD,
     SAMPLE_RATE,
-    CHANNEL_COUNT,
+    CHANNEL_COUNT,  // obsolete
     FORMAT,
     FRAME_COUNT,
     LATENCY,
@@ -86,7 +86,7 @@
                                 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 +135,10 @@
                                 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 +152,7 @@
         data.writeInt32(channelMask);
         data.writeInt32(frameCount);
         data.writeInt32(flags);
+        data.writeInt32((int32_t) tid);
         int lSessionId = 0;
         if (sessionId != NULL) {
             lSessionId = *sessionId;
@@ -182,6 +184,7 @@
         return reply.readInt32();
     }
 
+#if 0
     virtual int channelCount(audio_io_handle_t output) const
     {
         Parcel data, reply;
@@ -190,6 +193,7 @@
         remote()->transact(CHANNEL_COUNT, data, &reply);
         return reply.readInt32();
     }
+#endif
 
     virtual audio_format_t format(audio_io_handle_t output) const
     {
@@ -347,13 +351,14 @@
         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();
     }
@@ -698,7 +703,7 @@
             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 +713,7 @@
             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 +725,14 @@
             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 +743,13 @@
             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 +854,8 @@
             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: {
diff --git a/media/libmedia/IAudioPolicyService.cpp b/media/libmedia/IAudioPolicyService.cpp
index 7aab8d6..31c5d27 100644
--- a/media/libmedia/IAudioPolicyService.cpp
+++ b/media/libmedia/IAudioPolicyService.cpp
@@ -123,7 +123,7 @@
                                         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 +131,7 @@
         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 +175,7 @@
                                     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 +183,7 @@
         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 +274,7 @@
         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 +283,7 @@
         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,
@@ -417,14 +415,14 @@
                     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 +462,12 @@
             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;
diff --git a/media/libmedia/IAudioRecord.cpp b/media/libmedia/IAudioRecord.cpp
index 57a80a9..0d06e98 100644
--- a/media/libmedia/IAudioRecord.cpp
+++ b/media/libmedia/IAudioRecord.cpp
@@ -42,7 +42,7 @@
     {
     }
 
-    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 @@
         } 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/Visualizer.cpp b/media/libmedia/Visualizer.cpp
index de0bf7d..8196e10 100644
--- a/media/libmedia/Visualizer.cpp
+++ b/media/libmedia/Visualizer.cpp
@@ -353,13 +353,4 @@
     return false;
 }
 
-status_t Visualizer::CaptureThread::readyToRun()
-{
-    return NO_ERROR;
-}
-
-void Visualizer::CaptureThread::onFirstRef()
-{
-}
-
 }; // namespace android
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index 727fd0d..e49c218 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -1410,7 +1410,6 @@
 
     uint32_t encoder_flags = 0;
     if (mIsMetaDataStoredInVideoBuffers) {
-        encoder_flags |= OMXCodec::kHardwareCodecsOnly;
         encoder_flags |= OMXCodec::kStoreMetaDataInVideoBuffers;
     }
 
diff --git a/media/libmediaplayerservice/nuplayer/Android.mk b/media/libmediaplayerservice/nuplayer/Android.mk
index f97ba57..f469054 100644
--- a/media/libmediaplayerservice/nuplayer/Android.mk
+++ b/media/libmediaplayerservice/nuplayer/Android.mk
@@ -11,6 +11,9 @@
         NuPlayerStreamListener.cpp      \
         RTSPSource.cpp                  \
         StreamingSource.cpp             \
+        mp4/MP4Source.cpp               \
+        mp4/Parser.cpp                  \
+        mp4/TrackFragment.cpp           \
 
 LOCAL_C_INCLUDES := \
 	$(TOP)/frameworks/av/media/libstagefright/httplive            \
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.cpp b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
index 99569c9..f0c3240 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.cpp
@@ -128,7 +128,7 @@
     return OK;
 }
 
-sp<MetaData> NuPlayer::GenericSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::GenericSource::getFormatMeta(bool audio) {
     sp<MediaSource> source = audio ? mAudioTrack.mSource : mVideoTrack.mSource;
 
     if (source == NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/GenericSource.h b/media/libmediaplayerservice/nuplayer/GenericSource.h
index aaa5876..e50b855 100644
--- a/media/libmediaplayerservice/nuplayer/GenericSource.h
+++ b/media/libmediaplayerservice/nuplayer/GenericSource.h
@@ -43,7 +43,6 @@
 
     virtual status_t feedMoreTSData();
 
-    virtual sp<MetaData> getFormat(bool audio);
     virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
 
     virtual status_t getDuration(int64_t *durationUs);
@@ -53,6 +52,8 @@
 protected:
     virtual ~GenericSource();
 
+    virtual sp<MetaData> getFormatMeta(bool audio);
+
 private:
     struct Track {
         sp<MediaSource> mSource;
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
index 22b8847..1e98f35 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.cpp
@@ -81,7 +81,7 @@
     mTSParser = new ATSParser;
 }
 
-sp<MetaData> NuPlayer::HTTPLiveSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::HTTPLiveSource::getFormatMeta(bool audio) {
     ATSParser::SourceType type =
         audio ? ATSParser::AUDIO : ATSParser::VIDEO;
 
diff --git a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
index f22af5b..9950a9e 100644
--- a/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
+++ b/media/libmediaplayerservice/nuplayer/HTTPLiveSource.h
@@ -37,7 +37,6 @@
 
     virtual status_t feedMoreTSData();
 
-    virtual sp<MetaData> getFormat(bool audio);
     virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
 
     virtual status_t getDuration(int64_t *durationUs);
@@ -47,6 +46,8 @@
 protected:
     virtual ~HTTPLiveSource();
 
+    virtual sp<MetaData> getFormatMeta(bool audio);
+
 private:
     enum Flags {
         // Don't log any URLs.
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 86e122f..a02732b 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 {
 
 ////////////////////////////////////////////////////////////////////////////////
@@ -81,7 +86,14 @@
 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();
 }
 
@@ -258,7 +270,9 @@
             ALOGV("scanning sources haveAudio=%d, haveVideo=%d",
                  mAudioDecoder != NULL, mVideoDecoder != NULL);
 
-            instantiateDecoder(false, &mVideoDecoder);
+            if (mNativeWindow != NULL) {
+                instantiateDecoder(false, &mVideoDecoder);
+            }
 
             if (mAudioSink != NULL) {
                 instantiateDecoder(true, &mAudioDecoder);
@@ -279,7 +293,8 @@
                 break;
             }
 
-            if (mAudioDecoder == NULL || mVideoDecoder == NULL) {
+            if (mAudioDecoder == NULL && mAudioSink != NULL ||
+                mVideoDecoder == NULL && mNativeWindow != NULL) {
                 msg->post(100000ll);
                 mScanSourcesPending = true;
             }
@@ -500,6 +515,8 @@
                 CHECK(msg->findInt32("audio", &audio));
 
                 ALOGV("renderer %s flush completed.", audio ? "audio" : "video");
+            } else if (what == Renderer::kWhatVideoRenderingStart) {
+                notifyListener(MEDIA_INFO, MEDIA_INFO_RENDERING_START, 0);
             }
             break;
         }
@@ -674,16 +691,16 @@
         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 +711,7 @@
                        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 +942,19 @@
     }
 }
 
+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;
+}
+
 }  // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.h b/media/libmediaplayerservice/nuplayer/NuPlayer.h
index 25766e0..996806e 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.h
@@ -60,14 +60,16 @@
 
     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 {
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 0e53662..22f699e 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -20,15 +20,11 @@
 
 #include "NuPlayerDecoder.h"
 
-#include "ESDS.h"
-
 #include <media/stagefright/foundation/ABuffer.h>
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/ACodec.h>
 #include <media/stagefright/MediaDefs.h>
-#include <media/stagefright/MetaData.h>
-#include <media/stagefright/Utils.h>
 
 namespace android {
 
@@ -42,16 +38,24 @@
 NuPlayer::Decoder::~Decoder() {
 }
 
-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 @@
     // 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 @@
     }
 }
 
-sp<AMessage> NuPlayer::Decoder::makeFormat(const sp<MetaData> &meta) {
-    CHECK(mCSD.isEmpty());
-
-    sp<AMessage> msg;
-    CHECK_EQ(convertMetaDataToMessage(meta, &msg), (status_t)OK);
-
-    mCSDIndex = 0;
-    for (size_t i = 0;; ++i) {
-        sp<ABuffer> csd;
-        if (!msg->findBuffer(StringPrintf("csd-%d", i).c_str(), &csd)) {
-            break;
-        }
-
-        mCSD.push(csd);
-    }
-
-    return msg;
-}
-
 void NuPlayer::Decoder::onFillThisBuffer(const sp<AMessage> &msg) {
     sp<AMessage> reply;
     CHECK(msg->findMessage("reply", &reply));
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
index 3ab1fcf..a876148 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.h
@@ -30,7 +30,7 @@
     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/NuPlayerRenderer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
index 1f13955..8a75f83 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.cpp
@@ -47,6 +47,7 @@
       mHasVideo(false),
       mSyncQueues(false),
       mPaused(false),
+      mVideoRenderingStarted(false),
       mLastPositionUpdateUs(-1ll),
       mVideoLateByUs(0ll) {
 }
@@ -387,9 +388,20 @@
     mVideoQueue.erase(mVideoQueue.begin());
     entry = NULL;
 
+    if (!mVideoRenderingStarted) {
+        mVideoRenderingStarted = true;
+        notifyVideoRenderingStart();
+    }
+
     notifyPosition();
 }
 
+void NuPlayer::Renderer::notifyVideoRenderingStart() {
+    sp<AMessage> notify = mNotify->dup();
+    notify->setInt32("what", kWhatVideoRenderingStart);
+    notify->post();
+}
+
 void NuPlayer::Renderer::notifyEOS(bool audio, status_t finalResult) {
     sp<AMessage> notify = mNotify->dup();
     notify->setInt32("what", kWhatEOS);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
index 268628b..e4368c7 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerRenderer.h
@@ -45,9 +45,10 @@
     void resume();
 
     enum {
-        kWhatEOS                = 'eos ',
-        kWhatFlushComplete      = 'fluC',
-        kWhatPosition           = 'posi',
+        kWhatEOS                 = 'eos ',
+        kWhatFlushComplete       = 'fluC',
+        kWhatPosition            = 'posi',
+        kWhatVideoRenderingStart = 'vdrd',
     };
 
 protected:
@@ -99,6 +100,7 @@
     bool mSyncQueues;
 
     bool mPaused;
+    bool mVideoRenderingStarted;
 
     int64_t mLastPositionUpdateUs;
     int64_t mVideoLateByUs;
@@ -120,6 +122,7 @@
     void notifyFlushComplete(bool audio);
     void notifyPosition();
     void notifyVideoLateBy(int64_t lateByUs);
+    void notifyVideoRenderingStart();
 
     void flushQueue(List<QueueEntry> *queue);
     bool dropBufferWhileFlushing(bool audio, const sp<AMessage> &msg);
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
index 531b29f..66aeff3 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerSource.h
@@ -34,7 +34,7 @@
     // an error or ERROR_END_OF_STREAM if not.
     virtual status_t feedMoreTSData() = 0;
 
-    virtual sp<MetaData> getFormat(bool audio) = 0;
+    virtual sp<AMessage> getFormat(bool audio);
 
     virtual status_t dequeueAccessUnit(
             bool audio, sp<ABuffer> *accessUnit) = 0;
@@ -54,6 +54,8 @@
 protected:
     virtual ~Source() {}
 
+    virtual sp<MetaData> getFormatMeta(bool audio) { return NULL; }
+
 private:
     DISALLOW_EVIL_CONSTRUCTORS(Source);
 };
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
index c910488..4a704e3 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.cpp
@@ -95,7 +95,7 @@
     return mFinalResult;
 }
 
-sp<MetaData> NuPlayer::RTSPSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::RTSPSource::getFormatMeta(bool audio) {
     sp<AnotherPacketSource> source = getSource(audio);
 
     if (source == NULL) {
diff --git a/media/libmediaplayerservice/nuplayer/RTSPSource.h b/media/libmediaplayerservice/nuplayer/RTSPSource.h
index e11e304..c8409e5 100644
--- a/media/libmediaplayerservice/nuplayer/RTSPSource.h
+++ b/media/libmediaplayerservice/nuplayer/RTSPSource.h
@@ -40,7 +40,6 @@
 
     virtual status_t feedMoreTSData();
 
-    virtual sp<MetaData> getFormat(bool audio);
     virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
 
     virtual status_t getDuration(int64_t *durationUs);
@@ -52,6 +51,8 @@
 protected:
     virtual ~RTSPSource();
 
+    virtual sp<MetaData> getFormatMeta(bool audio);
+
 private:
     enum {
         kWhatNotify          = 'noti',
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
index 7c9bc5e..b696aa4 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.cpp
@@ -107,7 +107,7 @@
     return OK;
 }
 
-sp<MetaData> NuPlayer::StreamingSource::getFormat(bool audio) {
+sp<MetaData> NuPlayer::StreamingSource::getFormatMeta(bool audio) {
     ATSParser::SourceType type =
         audio ? ATSParser::AUDIO : ATSParser::VIDEO;
 
diff --git a/media/libmediaplayerservice/nuplayer/StreamingSource.h b/media/libmediaplayerservice/nuplayer/StreamingSource.h
index ca00ef9..3971e2a 100644
--- a/media/libmediaplayerservice/nuplayer/StreamingSource.h
+++ b/media/libmediaplayerservice/nuplayer/StreamingSource.h
@@ -33,12 +33,13 @@
 
     virtual status_t feedMoreTSData();
 
-    virtual sp<MetaData> getFormat(bool audio);
     virtual status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
 
 protected:
     virtual ~StreamingSource();
 
+    virtual sp<MetaData> getFormatMeta(bool audio);
+
 private:
     sp<IStreamSource> mSource;
     status_t mFinalResult;
diff --git a/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp
new file mode 100644
index 0000000..25c91e9
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.cpp
@@ -0,0 +1,132 @@
+/*
+ * 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 "Parser.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 Parser::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;
+    }
+
+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 Parser),
+      mEOS(false) {
+    mLooper->registerHandler(mParser);
+}
+
+MP4Source::~MP4Source() {
+}
+
+void MP4Source::start() {
+    mLooper->start(false /* runOnCallingThread */);
+    mParser->start(new StreamSource(mSource));
+}
+
+status_t MP4Source::feedMoreTSData() {
+    return mEOS ? ERROR_END_OF_STREAM : (status_t)OK;
+}
+
+sp<AMessage> MP4Source::getFormat(bool audio) {
+    return mParser->getFormat(audio);
+}
+
+status_t MP4Source::dequeueAccessUnit(
+        bool audio, sp<ABuffer> *accessUnit) {
+    return mParser->dequeueAccessUnit(audio, accessUnit);
+}
+
+}  // namespace android
diff --git a/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h
new file mode 100644
index 0000000..57430aa
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/MP4Source.h
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef MP4_SOURCE_H
+#define MP4_SOURCE_H
+
+#include "NuPlayerSource.h"
+
+namespace android {
+
+struct Parser;
+
+struct MP4Source : public NuPlayer::Source {
+    MP4Source(const sp<IStreamSource> &source);
+
+    virtual void start();
+
+    virtual status_t feedMoreTSData();
+
+    virtual sp<AMessage> getFormat(bool audio);
+
+    virtual status_t dequeueAccessUnit(
+            bool audio, sp<ABuffer> *accessUnit);
+
+protected:
+    virtual ~MP4Source();
+
+private:
+    sp<IStreamSource> mSource;
+    sp<ALooper> mLooper;
+    sp<Parser> mParser;
+    bool mEOS;
+
+    DISALLOW_EVIL_CONSTRUCTORS(MP4Source);
+};
+
+}  // namespace android
+
+#endif // MP4_SOURCE_H
diff --git a/media/libmediaplayerservice/nuplayer/mp4/Parser.cpp b/media/libmediaplayerservice/nuplayer/mp4/Parser.cpp
new file mode 100644
index 0000000..7938fa4
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/Parser.cpp
@@ -0,0 +1,1663 @@
+/*
+ * 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 "Parser"
+#include <utils/Log.h>
+
+#include "Parser.h"
+#include "TrackFragment.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/foundation/hexdump.h>
+#include <media/stagefright/MediaDefs.h>
+#include <media/stagefright/MediaErrors.h>
+#include <media/stagefright/Utils.h>
+
+#include "../NuPlayerStreamListener.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 Parser::DispatchEntry Parser::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'),
+        &Parser::parseTrackHeader
+    },
+
+    { FOURCC('m', 'v', 'e', 'x'), FOURCC('m', 'o', 'o', 'v'), NULL },
+
+    { FOURCC('t', 'r', 'e', 'x'), FOURCC('m', 'v', 'e', 'x'),
+        &Parser::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'),
+        &Parser::parseMediaHeader
+    },
+
+    { FOURCC('h', 'd', 'l', 'r'), FOURCC('m', 'd', 'i', 'a'),
+        &Parser::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'),
+        &Parser::parseSampleSizes },
+
+    { FOURCC('s', 't', 'z', '2'), FOURCC('s', 't', 'b', 'l'),
+        &Parser::parseCompactSampleSizes },
+
+    { FOURCC('s', 't', 's', 'c'), FOURCC('s', 't', 'b', 'l'),
+        &Parser::parseSampleToChunk },
+
+    { FOURCC('s', 't', 'c', 'o'), FOURCC('s', 't', 'b', 'l'),
+        &Parser::parseChunkOffsets },
+
+    { FOURCC('c', 'o', '6', '4'), FOURCC('s', 't', 'b', 'l'),
+        &Parser::parseChunkOffsets64 },
+
+    { FOURCC('a', 'v', 'c', 'C'), FOURCC('a', 'v', 'c', '1'),
+        &Parser::parseAVCCodecSpecificData },
+
+    { FOURCC('e', 's', 'd', 's'), FOURCC('m', 'p', '4', 'a'),
+        &Parser::parseESDSCodecSpecificData },
+
+    { FOURCC('e', 's', 'd', 's'), FOURCC('m', 'p', '4', 'v'),
+        &Parser::parseESDSCodecSpecificData },
+
+    { FOURCC('m', 'd', 'a', 't'), 0, &Parser::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'),
+        &Parser::parseTrackFragmentHeader
+    },
+    { FOURCC('t', 'r', 'u', 'n'), FOURCC('t', 'r', 'a', 'f'),
+        &Parser::parseTrackFragmentRun
+    },
+
+    { FOURCC('m', 'f', 'r', 'a'), 0, NULL },
+};
+
+struct FileSource : public Parser::Source {
+    FileSource(const char *filename)
+        : mFile(fopen(filename, "rb")) {
+            CHECK(mFile != NULL);
+        }
+
+    virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+        fseek(mFile, offset, SEEK_SET);
+        return fread(data, 1, size, mFile);
+    }
+
+    private:
+    FILE *mFile;
+
+    DISALLOW_EVIL_CONSTRUCTORS(FileSource);
+};
+
+Parser::Parser()
+    : mBufferPos(0),
+      mSuspended(false) {
+}
+
+Parser::~Parser() {
+}
+
+void Parser::start(const char *filename) {
+    sp<AMessage> msg = new AMessage(kWhatStart, id());
+    msg->setObject("source", new FileSource(filename));
+    msg->post();
+}
+
+void Parser::start(const sp<Source> &source) {
+    sp<AMessage> msg = new AMessage(kWhatStart, id());
+    msg->setObject("source", source);
+    msg->post();
+}
+
+sp<AMessage> Parser::getFormat(bool audio) {
+    sp<AMessage> msg = new AMessage(kWhatGetFormat, id());
+    msg->setInt32("audio", audio);
+
+    sp<AMessage> response;
+    status_t err = msg->postAndAwaitResponse(&response);
+
+    if (err != OK) {
+        return NULL;
+    }
+
+    if (response->findInt32("err", &err) && err != OK) {
+        return NULL;
+    }
+
+    sp<AMessage> format;
+    CHECK(response->findMessage("format", &format));
+
+    ALOGV("returning format %s", format->debugString().c_str());
+    return format;
+}
+
+status_t Parser::dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit) {
+    sp<AMessage> msg = new AMessage(kWhatDequeueAccessUnit, id());
+    msg->setInt32("audio", audio);
+
+    sp<AMessage> response;
+    status_t err = msg->postAndAwaitResponse(&response);
+
+    if (err != OK) {
+        return err;
+    }
+
+    if (response->findInt32("err", &err) && err != OK) {
+        return err;
+    }
+
+    CHECK(response->findBuffer("accessUnit", accessUnit));
+
+    return OK;
+}
+
+ssize_t Parser::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 Parser::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(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) {
+                ALOGI("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) {
+                ALOGI("%s", "Reached EOF");
+            } 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);
+
+                response->setMessage(
+                        "format", info->mSampleDescs.itemAt(0).mFormat);
+
+                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;
+        }
+
+        default:
+            TRESPASS();
+    }
+}
+
+status_t Parser::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', '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(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 Parser::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 Parser::resumeIfNecessary() {
+    if (!mSuspended) {
+        return;
+    }
+
+    ALOGI("resuming.");
+
+    mSuspended = false;
+    (new AMessage(kWhatProceed, id()))->post();
+}
+
+status_t Parser::getSample(
+        TrackInfo *info, sp<TrackFragment> *fragment, SampleInfo *sampleInfo) {
+    for (;;) {
+        if (info->mFragments.empty()) {
+            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 Parser::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) {
+            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;
+
+        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 Parser::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 Parser::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 Parser::enter(uint32_t type, uint64_t size) {
+    Container container;
+    container.mType = type;
+    container.mExtendsToEOF = (size == 0);
+    container.mBytesRemaining = size;
+
+    mStack.push(container);
+}
+
+bool Parser::fitsContainer(uint64_t size) const {
+    CHECK(!mStack.isEmpty());
+    const Container &container = mStack.itemAt(mStack.size() - 1);
+
+    return container.mExtendsToEOF || size <= container.mBytesRemaining;
+}
+
+uint16_t Parser::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 Parser::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 Parser::readU64(size_t offset) {
+    return (((uint64_t)readU32(offset)) << 32) | readU32(offset + 4);
+}
+
+void Parser::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();
+                }
+
+                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 Parser::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;
+
+    info->mStaticFragment = new StaticTrackFragment;
+
+    mCurrentTrackID = trackID;
+
+    return OK;
+}
+
+status_t Parser::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 Parser::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 Parser::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 Parser::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 Parser::parseSampleSizes(
+        uint32_t type, size_t offset, uint64_t size) {
+    return editTrack(mCurrentTrackID)->mStaticFragment->parseSampleSizes(
+            this, type, offset, size);
+}
+
+status_t Parser::parseCompactSampleSizes(
+        uint32_t type, size_t offset, uint64_t size) {
+    return editTrack(mCurrentTrackID)->mStaticFragment->parseCompactSampleSizes(
+            this, type, offset, size);
+}
+
+status_t Parser::parseSampleToChunk(
+        uint32_t type, size_t offset, uint64_t size) {
+    return editTrack(mCurrentTrackID)->mStaticFragment->parseSampleToChunk(
+            this, type, offset, size);
+}
+
+status_t Parser::parseChunkOffsets(
+        uint32_t type, size_t offset, uint64_t size) {
+    return editTrack(mCurrentTrackID)->mStaticFragment->parseChunkOffsets(
+            this, type, offset, size);
+}
+
+status_t Parser::parseChunkOffsets64(
+        uint32_t type, size_t offset, uint64_t size) {
+    return editTrack(mCurrentTrackID)->mStaticFragment->parseChunkOffsets64(
+            this, type, offset, size);
+}
+
+status_t Parser::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 Parser::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 Parser::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) {
+        ALOGI("suspending for now.");
+        mSuspended = true;
+    }
+
+    return OK;
+}
+
+status_t Parser::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;
+}
+
+Parser::TrackInfo *Parser::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.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 Parser::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)) {
+        CHECK(!mStack.isEmpty());
+
+        // This should point to the start of the data inside the 'mdat' box
+        // following the current 'moof' box.
+
+        mTrackFragmentHeaderInfo.mBaseDataOffset =
+            mBufferPos + mStack.itemAt(mStack.size() - 1).mBytesRemaining + 8;
+    }
+
+    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 Parser::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 Parser::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/libmediaplayerservice/nuplayer/mp4/Parser.h b/media/libmediaplayerservice/nuplayer/mp4/Parser.h
new file mode 100644
index 0000000..50c96bb
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/mp4/Parser.h
@@ -0,0 +1,252 @@
+/*
+ * 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 <utils/Vector.h>
+
+namespace android {
+
+struct ABuffer;
+
+struct Parser : public AHandler {
+    struct Source : public RefBase {
+        Source() {}
+
+        virtual ssize_t readAt(off64_t offset, void *data, size_t size) = 0;
+
+        protected:
+        virtual ~Source() {}
+
+        private:
+        DISALLOW_EVIL_CONSTRUCTORS(Source);
+    };
+
+    Parser();
+
+    void start(const char *filename);
+    void start(const sp<Source> &source);
+
+    sp<AMessage> getFormat(bool audio);
+    status_t dequeueAccessUnit(bool audio, sp<ABuffer> *accessUnit);
+
+    virtual void onMessageReceived(const sp<AMessage> &msg);
+
+protected:
+    virtual ~Parser();
+
+private:
+    enum {
+        kWhatStart,
+        kWhatProceed,
+        kWhatReadMore,
+        kWhatGetFormat,
+        kWhatDequeueAccessUnit,
+    };
+
+    struct TrackFragment;
+    struct DynamicTrackFragment;
+    struct StaticTrackFragment;
+
+    struct DispatchEntry {
+        uint32_t mType;
+        uint32_t mParentType;
+        status_t (Parser::*mHandler)(uint32_t, size_t, uint64_t);
+    };
+
+    struct Container {
+        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 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!
+
+        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;
+
+        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;
+    sp<ABuffer> mBuffer;
+    Vector<Container> mStack;
+    KeyedVector<uint32_t, TrackInfo> mTracks;  // TrackInfo by trackID
+    Vector<MediaDataInfo> mMediaData;
+
+    uint32_t mCurrentTrackID;
+
+    TrackFragmentHeaderInfo mTrackFragmentHeaderInfo;
+
+    status_t onProceed();
+    status_t onDequeueAccessUnit(size_t trackIndex, sp<ABuffer> *accessUnit);
+
+    void enter(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);
+
+    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(Parser);
+};
+
+}  // namespace android
+
+#endif  // PARSER_H_
+
diff --git a/media/libmediaplayerservice/nuplayer/mp4/TrackFragment.cpp b/media/libmediaplayerservice/nuplayer/mp4/TrackFragment.cpp
new file mode 100644
index 0000000..a4c31ea
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/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 {
+
+Parser::DynamicTrackFragment::DynamicTrackFragment()
+    : mComplete(false),
+      mSampleIndex(0) {
+}
+
+Parser::DynamicTrackFragment::~DynamicTrackFragment() {
+}
+
+status_t Parser::DynamicTrackFragment::getSample(SampleInfo *info) {
+    if (mSampleIndex >= mSamples.size()) {
+        return mComplete ? ERROR_END_OF_STREAM : -EWOULDBLOCK;
+    }
+
+    *info = mSamples.itemAt(mSampleIndex);
+
+    return OK;
+}
+
+void Parser::DynamicTrackFragment::advance() {
+    ++mSampleIndex;
+}
+
+void Parser::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 Parser::DynamicTrackFragment::signalCompletion() {
+    mComplete = true;
+
+    return OK;
+}
+
+bool Parser::DynamicTrackFragment::complete() const {
+    return mComplete;
+}
+
+////////////////////////////////////////////////////////////////////////////////
+
+Parser::StaticTrackFragment::StaticTrackFragment()
+    : mSampleIndex(0),
+      mSampleCount(0),
+      mChunkIndex(0),
+      mSampleToChunkIndex(-1),
+      mSampleToChunkRemaining(0),
+      mPrevChunkIndex(0xffffffff),
+      mNextSampleOffset(0) {
+}
+
+Parser::StaticTrackFragment::~StaticTrackFragment() {
+}
+
+status_t Parser::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 Parser::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 Parser::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 Parser::StaticTrackFragment::signalCompletion() {
+    mSampleToChunkIndex = 0;
+
+    mSampleToChunkRemaining =
+        (mSampleToChunk == NULL)
+            ? 0
+            : U32_AT(mSampleToChunk->data() + 8 + 12 * mSampleToChunkIndex + 4);
+
+    updateSampleInfo();
+
+    return OK;
+}
+
+bool Parser::StaticTrackFragment::complete() const {
+    return true;
+}
+
+status_t Parser::StaticTrackFragment::parseSampleSizes(
+        Parser *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 Parser::StaticTrackFragment::parseCompactSampleSizes(
+        Parser *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 Parser::StaticTrackFragment::parseSampleToChunk(
+        Parser *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 Parser::StaticTrackFragment::parseChunkOffsets(
+        Parser *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 Parser::StaticTrackFragment::parseChunkOffsets64(
+        Parser *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/libmediaplayerservice/nuplayer/mp4/TrackFragment.h b/media/libmediaplayerservice/nuplayer/mp4/TrackFragment.h
new file mode 100644
index 0000000..1498aad
--- /dev/null
+++ b/media/libmediaplayerservice/nuplayer/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 "Parser.h"
+
+namespace android {
+
+struct Parser::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 Parser::DynamicTrackFragment : public Parser::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 Parser::StaticTrackFragment : public Parser::TrackFragment {
+    StaticTrackFragment();
+
+    virtual status_t getSample(SampleInfo *info);
+    virtual void advance();
+
+    virtual status_t signalCompletion();
+    virtual bool complete() const;
+
+    status_t parseSampleSizes(
+            Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+    status_t parseCompactSampleSizes(
+            Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+    status_t parseSampleToChunk(
+            Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+    status_t parseChunkOffsets(
+            Parser *parser, uint32_t type, size_t offset, uint64_t size);
+
+    status_t parseChunkOffsets64(
+            Parser *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/AACWriter.cpp b/media/libstagefright/AACWriter.cpp
index 284ba01..a6f7cfb 100644
--- a/media/libstagefright/AACWriter.cpp
+++ b/media/libstagefright/AACWriter.cpp
@@ -28,6 +28,8 @@
 #include <media/stagefright/MetaData.h>
 #include <media/mediarecorder.h>
 #include <sys/prctl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <fcntl.h>
 
 namespace android {
@@ -44,7 +46,7 @@
 
     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 @@
     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 @@
 
         buffer->release();
         buffer = NULL;
+
+        if (err != OK) {
+            break;
+        }
+
+        if (stoppedPrematurely) {
+            stoppedPrematurely = false;
+        }
+    }
+
+    if ((err == OK || err == ERROR_END_OF_STREAM) && stoppedPrematurely) {
+        err = ERROR_MALFORMED;
     }
 
     close(mFd);
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index c4743a1..c37d2ca 100644
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -595,7 +595,7 @@
     // 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 +653,7 @@
          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 +664,8 @@
 
 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;
     }
@@ -1357,7 +1358,8 @@
            || 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,
@@ -2188,7 +2190,8 @@
     // 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 +2199,6 @@
         }
 
         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 +2219,7 @@
         }
 
         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 +2234,7 @@
     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(),
@@ -2751,7 +2747,7 @@
         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 +2886,21 @@
 
     sp<IOMX> omx = client.interface();
 
-    Vector<String8> matchingCodecs;
-    Vector<uint32_t> matchingCodecQuirks;
+    Vector<OMXCodec::CodecNameAndQuirks> matchingCodecs;
 
     AString mime;
 
     AString componentName;
     uint32_t quirks;
     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 +2914,7 @@
                 encoder, // createEncoder
                 NULL,  // matchComponentName
                 0,     // flags
-                &matchingCodecs,
-                &matchingCodecQuirks);
+                &matchingCodecs);
     }
 
     sp<CodecObserver> observer = new CodecObserver;
@@ -2926,8 +2922,8 @@
 
     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 +3249,6 @@
             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);
         }
diff --git a/media/libstagefright/AMRWriter.cpp b/media/libstagefright/AMRWriter.cpp
index ca85640..8d5eec8 100644
--- a/media/libstagefright/AMRWriter.cpp
+++ b/media/libstagefright/AMRWriter.cpp
@@ -36,7 +36,7 @@
       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 @@
         if (n < (ssize_t)buffer->range_length()) {
             buffer->release();
             buffer = NULL;
-
+            err = ERROR_IO;
             break;
         }
 
-        // XXX: How to tell it is stopped prematurely?
+        if (err != OK) {
+            break;
+        }
+
         if (stoppedPrematurely) {
             stoppedPrematurely = false;
         }
@@ -267,8 +270,8 @@
         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 8ad1cb9..3fd0f85 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -81,6 +81,7 @@
         libssl \
         libstagefright_omx \
         libstagefright_yuv \
+        libsync \
         libui \
         libutils \
         libvorbisidec \
@@ -97,13 +98,9 @@
         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 +115,8 @@
 
 LOCAL_MODULE:= libstagefright
 
+LOCAL_MODULE_TAGS := optional
+
 include $(BUILD_SHARED_LIBRARY)
 
 include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 72d797e..ed142a4 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -48,7 +48,8 @@
 
 AudioSource::AudioSource(
         audio_source_t inputSource, uint32_t sampleRate, uint32_t channelCount)
-    : mStarted(false),
+    : mRecord(NULL),
+      mStarted(false),
       mSampleRate(sampleRate),
       mPrevSampleTimeUs(0),
       mNumFramesReceived(0),
@@ -61,7 +62,7 @@
     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 @@
             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);
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index 0f346d8..664d5dd 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -130,7 +130,7 @@
         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 @@
     : mQueueStarted(false),
       mUIDValid(false),
       mTimeSource(NULL),
+      mVideoRenderingStarted(false),
       mVideoRendererIsPreview(false),
       mAudioPlayer(NULL),
       mDisplayWidth(0),
@@ -468,6 +469,7 @@
 }
 
 void AwesomePlayer::reset_l() {
+    mVideoRenderingStarted = false;
     mActiveAudioTrackIndex = -1;
     mDisplayWidth = 0;
     mDisplayHeight = 0;
@@ -710,7 +712,6 @@
                              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);
@@ -770,7 +771,6 @@
                           cachedDurationUs / 1E6);
                     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);
@@ -1807,6 +1807,11 @@
     if (mVideoRenderer != NULL) {
         mSinceLastDropped++;
         mVideoRenderer->render(mVideoBuffer);
+        if (!mVideoRenderingStarted) {
+            mVideoRenderingStarted = true;
+            notifyListener_l(MEDIA_INFO, MEDIA_INFO_RENDERING_START);
+        }
+
     }
 
     mVideoBuffer->release();
@@ -2626,6 +2631,9 @@
             mFlags |= value;
             break;
         case CLEAR:
+            if ((value & CACHE_UNDERRUN) && (mFlags & CACHE_UNDERRUN)) {
+                notifyListener_l(MEDIA_INFO, MEDIA_INFO_BUFFERING_END);
+            }
             mFlags &= ~value;
             break;
         case ASSIGN:
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 3ddad93..efd7af7 100755
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -111,6 +111,10 @@
        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 @@
     const sp<Surface>& surface,
     bool storeMetaDataInVideoBuffers)
     : mCameraFlags(0),
+      mNumInputBuffers(0),
       mVideoFrameRate(-1),
       mCamera(0),
       mSurface(surface),
@@ -567,6 +572,18 @@
     // 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 @@
     }
 
     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/DataSource.cpp b/media/libstagefright/DataSource.cpp
index c75f100..1de808e 100644
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -17,7 +17,7 @@
 #include "include/AMRExtractor.h"
 
 #if CHROMIUM_AVAILABLE
-#include "include/DataUriSource.h"
+#include "include/chromium_http_stub.h"
 #endif
 
 #include "include/MP3Extractor.h"
@@ -173,7 +173,7 @@
 
 # if CHROMIUM_AVAILABLE
     } else if (!strncasecmp("data:", uri, 5)) {
-        source = new DataUriSource(uri);
+        source = createDataUriSource(uri);
 #endif
     } else {
         // Assume it's a filename.
diff --git a/media/libstagefright/FLACExtractor.cpp b/media/libstagefright/FLACExtractor.cpp
index 668d7f7..29bb056 100644
--- a/media/libstagefright/FLACExtractor.cpp
+++ b/media/libstagefright/FLACExtractor.cpp
@@ -350,7 +350,7 @@
         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);
             }
diff --git a/media/libstagefright/HTTPBase.cpp b/media/libstagefright/HTTPBase.cpp
index d7eea3f..40bfc55 100644
--- a/media/libstagefright/HTTPBase.cpp
+++ b/media/libstagefright/HTTPBase.cpp
@@ -21,7 +21,7 @@
 #include "include/HTTPBase.h"
 
 #if CHROMIUM_AVAILABLE
-#include "include/ChromiumHTTPDataSource.h"
+#include "include/chromium_http_stub.h"
 #endif
 
 #include <media/stagefright/foundation/ADebug.h>
@@ -46,7 +46,10 @@
 // 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/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 6108298..8b52e15 100755
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -42,6 +42,7 @@
 
 namespace android {
 
+static const int64_t kMinStreamableFileSizeInBytes = 5 * 1024 * 1024;
 static const int64_t kMax32BitFileSize = 0x007fffffffLL;
 static const uint8_t kNalUnitTypeSeqParamSet = 0x07;
 static const uint8_t kNalUnitTypePicParamSet = 0x08;
@@ -75,6 +76,128 @@
         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 @@
     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;
+    bool                mSamplesHaveSameSize;
+    ListTableEntries<uint32_t> *mStszTableEntries;
 
-    size_t              mNumStscTableEntries;
-    struct StscTableEntry {
+    ListTableEntries<uint32_t> *mStcoTableEntries;
+    ListTableEntries<off64_t> *mCo64TableEntries;
+    ListTableEntries<uint32_t> *mStscTableEntries;
+    ListTableEntries<uint32_t> *mStssTableEntries;
+    ListTableEntries<uint32_t> *mSttsTableEntries;
+    ListTableEntries<uint32_t> *mCttsTableEntries;
 
-        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;
-
-    struct CttsTableEntry {
-        CttsTableEntry(uint32_t count, int32_t timescaledDur)
-            : sampleCount(count), sampleDuration(timescaledDur) {}
-
-        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 @@
       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 @@
     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 @@
         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 @@
     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 @@
         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 @@
     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 @@
         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 @@
       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 @@
 
 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::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 @@
     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 @@
     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 @@
 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 @@
     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 @@
     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 @@
 
     sp<MetaData> meta_data;
 
-    mNumSamples = 0;
     status_t err = OK;
     MediaBuffer *buffer;
     while (!mDone && (err = mSource->read(&buffer)) == OK) {
@@ -1967,7 +2081,7 @@
         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 @@
             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 @@
             }
 
             // Update ctts time offset range
-            if (mNumSamples == 0) {
+            if (mStszTableEntries->count() == 0) {
                 mMinCttsOffsetTimeUs = currCttsOffsetTimeTicks;
                 mMaxCttsOffsetTimeUs = currCttsOffsetTimeTicks;
             } else {
@@ -2057,22 +2171,18 @@
         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 @@
 
         }
         if (mSamplesHaveSameSize) {
-            if (mNumSamples >= 2 && previousSampleSize != sampleSize) {
+            if (mStszTableEntries->count() >= 2 && previousSampleSize != sampleSize) {
                 mSamplesHaveSameSize = false;
             }
             previousSampleSize = sampleSize;
@@ -2093,7 +2203,7 @@
         lastTimestampUs = timestampUs;
 
         if (isSync != 0) {
-            addOneStssTableEntry(mNumSamples);
+            addOneStssTableEntry(mStszTableEntries->count());
         }
 
         if (mTrackingProgressStatus) {
@@ -2105,7 +2215,12 @@
         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 @@
                     }
                     ++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 @@
 
     // 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 @@
     // 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 @@
     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 @@
 }
 
 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 @@
 
     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::trackProgressStatus(int64_t timeUs, status_t err) {
     ALOGV("trackProgressStatus: %lld us", timeUs);
+
     if (mTrackEveryTimeDurationUs > 0 &&
         timeUs - mPreviousTrackTimeUs >= mTrackEveryTimeDurationUs) {
         ALOGV("Fire time tracking progress status at %lld us", timeUs);
@@ -2586,7 +2702,7 @@
     mOwner->writeInt32(0x07);          // version=0, flags=7
     mOwner->writeInt32(now);           // creation time
     mOwner->writeInt32(now);           // modification time
-    mOwner->writeInt32(mTrackId + 1);  // track id starts with 1
+    mOwner->writeInt32(mTrackId);      // track id starts with 1
     mOwner->writeInt32(0);             // reserved
     int64_t trakDurationUs = getDurationUs();
     int32_t mvhdTimeScale = mOwner->getTimeScale();
@@ -2743,21 +2859,11 @@
 void MPEG4Writer::Track::writeSttsBox() {
     mOwner->beginBox("stts");
     mOwner->writeInt32(0);  // version=0, flags=0
-    mOwner->writeInt32(mNumSttsTableEntries);
-
-    // Compensate for small start time difference from different media tracks
-    List<SttsTableEntry>::iterator it = mSttsTableEntries.begin();
-    CHECK(it != mSttsTableEntries.end() && it->sampleCount == 1);
-    mOwner->writeInt32(it->sampleCount);
-    mOwner->writeInt32(getStartTimeOffsetScaledTime() + it->sampleDuration);
-
-    int64_t totalCount = 1;
-    while (++it != mSttsTableEntries.end()) {
-        mOwner->writeInt32(it->sampleCount);
-        mOwner->writeInt32(it->sampleDuration);
-        totalCount += it->sampleCount;
-    }
-    CHECK_EQ(totalCount, mNumSamples);
+    uint32_t duration;
+    CHECK(mSttsTableEntries->get(duration, 1));
+    duration = htonl(duration);  // Back to host byte order
+    mSttsTableEntries->set(htonl(duration + getStartTimeOffsetScaledTime()), 1);
+    mSttsTableEntries->write(mOwner);
     mOwner->endBox();  // stts
 }
 
@@ -2772,101 +2878,52 @@
     }
 
     // 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/NuMediaExtractor.cpp b/media/libstagefright/NuMediaExtractor.cpp
index 29e1d21..64e5403 100644
--- a/media/libstagefright/NuMediaExtractor.cpp
+++ b/media/libstagefright/NuMediaExtractor.cpp
@@ -110,6 +110,12 @@
         // 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;
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index fde7ebf..5615d0f 100755
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -147,12 +147,13 @@
 // 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 @@
         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 @@
             ((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 @@
     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 @@
     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;
@@ -569,6 +568,8 @@
 
     if ((mFlags & kClientNeedsFramebuffer)
             && !strncmp(mComponentName, "OMX.SEC.", 8)) {
+        // This appears to no longer be needed???
+
         OMX_INDEXTYPE index;
 
         status_t err =
@@ -1214,7 +1215,8 @@
                || 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);
 
         err = mOMX->setParameter(
                 mNode, OMX_IndexParamVideoPortFormat,
@@ -1776,7 +1778,7 @@
     // 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 +1834,7 @@
     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 +1848,8 @@
 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 +1953,8 @@
     // 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 +1962,6 @@
         }
 
         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 +1982,7 @@
         }
 
         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 +1997,7 @@
     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 +2046,14 @@
 
 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 +2089,6 @@
 
             // 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 +3061,24 @@
         }
 
         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 +3180,6 @@
         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);
 
@@ -3635,11 +3599,6 @@
         }
         params->setInt64(kKeyTime, startTimeUs);
     }
-    status_t err = mSource->start(params.get());
-
-    if (err != OK) {
-        return err;
-    }
 
     mCodecSpecificDataIndex = 0;
     mInitialBufferSubmit = true;
@@ -3652,6 +3611,23 @@
     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) {
+            return err;
+        }
+
+        params->setInt32(kKeyNumBuffers, mPortBuffers[kPortIndexInput].size());
+        return mSource->start(params.get());
+    }
+
+    // Decoder case
+    if ((err = mSource->start(params.get())) != OK) {
+        return err;
+    }
     return init();
 }
 
@@ -4511,7 +4487,7 @@
         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 +4497,7 @@
             &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 +4584,6 @@
     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/StagefrightMetadataRetriever.cpp b/media/libstagefright/StagefrightMetadataRetriever.cpp
index 7951496..c9ef4d9 100644
--- a/media/libstagefright/StagefrightMetadataRetriever.cpp
+++ b/media/libstagefright/StagefrightMetadataRetriever.cpp
@@ -462,6 +462,7 @@
     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 +490,9 @@
 
                 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 +525,9 @@
 
         sprintf(tmp, "%d", videoHeight);
         mMetaData.add(METADATA_KEY_VIDEO_HEIGHT, String8(tmp));
+
+        sprintf(tmp, "%d", rotationAngle);
+        mMetaData.add(METADATA_KEY_VIDEO_ROTATION, String8(tmp));
     }
 
     if (numTracks == 1 && hasAudio && audioBitrate >= 0) {
diff --git a/media/libstagefright/SurfaceMediaSource.cpp b/media/libstagefright/SurfaceMediaSource.cpp
index 300d2fc..f1f444e 100644
--- a/media/libstagefright/SurfaceMediaSource.cpp
+++ b/media/libstagefright/SurfaceMediaSource.cpp
@@ -244,7 +244,8 @@
                 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;
@@ -333,7 +334,8 @@
             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();
diff --git a/media/libstagefright/chromium_http/Android.mk b/media/libstagefright/chromium_http/Android.mk
index 6ab2a00..2c6d84c 100644
--- a/media/libstagefright/chromium_http/Android.mk
+++ b/media/libstagefright/chromium_http/Android.mk
@@ -6,7 +6,8 @@
 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_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/chromium_http_stub.cpp b/media/libstagefright/chromium_http/chromium_http_stub.cpp
new file mode 100644
index 0000000..560a61f
--- /dev/null
+++ b/media/libstagefright/chromium_http/chromium_http_stub.cpp
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include <include/chromium_http_stub.h>
+#include <include/ChromiumHTTPDataSource.h>
+#include <include/DataUriSource.h>
+
+namespace android {
+
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags) {
+    return new ChromiumHTTPDataSource(flags);
+}
+
+DataSource *createDataUriSource(const char *uri) {
+    return new DataUriSource(uri);
+}
+
+}
diff --git a/media/libstagefright/chromium_http_stub.cpp b/media/libstagefright/chromium_http_stub.cpp
new file mode 100644
index 0000000..cbd8796
--- /dev/null
+++ b/media/libstagefright/chromium_http_stub.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <dlfcn.h>
+
+#include <media/stagefright/DataSource.h>
+
+#include "include/chromium_http_stub.h"
+#include "include/HTTPBase.h"
+
+namespace android {
+
+static bool gFirst = true;
+static void *gHandle;
+static Mutex gLibMutex;
+
+HTTPBase *(*gLib_createChromiumHTTPDataSource)(uint32_t flags);
+DataSource *(*gLib_createDataUriSource)(const char *uri);
+
+static bool load_libstagefright_chromium_http() {
+    Mutex::Autolock autoLock(gLibMutex);
+    void *sym;
+
+    if (!gFirst) {
+        return (gHandle != NULL);
+    }
+
+    gFirst = false;
+
+    gHandle = dlopen("libstagefright_chromium_http.so", RTLD_NOW);
+    if (gHandle == NULL) {
+        return false;
+    }
+
+    sym = dlsym(gHandle, "createChromiumHTTPDataSource");
+    if (sym == NULL) {
+        gHandle = NULL;
+        return false;
+    }
+    gLib_createChromiumHTTPDataSource = (HTTPBase *(*)(uint32_t))sym;
+
+    sym = dlsym(gHandle, "createDataUriSource");
+    if (sym == NULL) {
+        gHandle = NULL;
+        return false;
+    }
+    gLib_createDataUriSource = (DataSource *(*)(const char *))sym;
+
+    return true;
+}
+
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags) {
+    if (!load_libstagefright_chromium_http()) {
+        return NULL;
+    }
+
+    return gLib_createChromiumHTTPDataSource(flags);
+}
+
+DataSource *createDataUriSource(const char *uri) {
+    if (!load_libstagefright_chromium_http()) {
+        return NULL;
+    }
+
+    return gLib_createDataUriSource(uri);
+}
+
+}
diff --git a/media/libstagefright/codecs/aacdec/Android.mk b/media/libstagefright/codecs/aacdec/Android.mk
index 91457c5..4dc38a8 100644
--- a/media/libstagefright/codecs/aacdec/Android.mk
+++ b/media/libstagefright/codecs/aacdec/Android.mk
@@ -1,213 +1,28 @@
 LOCAL_PATH:= $(call my-dir)
 
-AAC_LIBRARY = fraunhofer
+include $(CLEAR_VARS)
 
-ifeq ($(AAC_LIBRARY), fraunhofer)
-  include $(CLEAR_VARS)
+LOCAL_SRC_FILES := \
+      SoftAAC2.cpp
 
-  LOCAL_SRC_FILES := \
-          SoftAAC2.cpp
+LOCAL_C_INCLUDES := \
+      frameworks/av/media/libstagefright/include \
+      frameworks/native/include/media/openmax \
+      external/aac/libAACdec/include \
+      external/aac/libPCMutils/include \
+      external/aac/libFDK/include \
+      external/aac/libMpegTPDec/include \
+      external/aac/libSBRdec/include \
+      external/aac/libSYS/include
 
-  LOCAL_C_INCLUDES := \
-          frameworks/av/media/libstagefright/include \
-          frameworks/native/include/media/openmax \
-          external/aac/libAACdec/include \
-          external/aac/libPCMutils/include \
-          external/aac/libFDK/include \
-          external/aac/libMpegTPDec/include \
-          external/aac/libSBRdec/include \
-          external/aac/libSYS/include
+LOCAL_CFLAGS :=
 
-  LOCAL_CFLAGS :=
+LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
 
-  LOCAL_STATIC_LIBRARIES := libFraunhoferAAC
+LOCAL_SHARED_LIBRARIES := \
+      libstagefright_omx libstagefright_foundation libutils libcutils
 
-  LOCAL_SHARED_LIBRARIES := \
-          libstagefright_omx libstagefright_foundation libutils libcutils
+LOCAL_MODULE := libstagefright_soft_aacdec
+LOCAL_MODULE_TAGS := optional
 
-  LOCAL_MODULE := libstagefright_soft_aacdec
-  LOCAL_MODULE_TAGS := optional
-
-  include $(BUILD_SHARED_LIBRARY)
-
-else # pv
-
-  LOCAL_SRC_FILES := \
-          analysis_sub_band.cpp \
-          apply_ms_synt.cpp \
-          apply_tns.cpp \
-          buf_getbits.cpp \
-          byte_align.cpp \
-          calc_auto_corr.cpp \
-          calc_gsfb_table.cpp \
-          calc_sbr_anafilterbank.cpp \
-          calc_sbr_envelope.cpp \
-          calc_sbr_synfilterbank.cpp \
-          check_crc.cpp \
-          dct16.cpp \
-          dct64.cpp \
-          decode_huff_cw_binary.cpp \
-          decode_noise_floorlevels.cpp \
-          deinterleave.cpp \
-          digit_reversal_tables.cpp \
-          dst16.cpp \
-          dst32.cpp \
-          dst8.cpp \
-          esc_iquant_scaling.cpp \
-          extractframeinfo.cpp \
-          fft_rx4_long.cpp \
-          fft_rx4_short.cpp \
-          fft_rx4_tables_fxp.cpp \
-          find_adts_syncword.cpp \
-          fwd_long_complex_rot.cpp \
-          fwd_short_complex_rot.cpp \
-          gen_rand_vector.cpp \
-          get_adif_header.cpp \
-          get_adts_header.cpp \
-          get_audio_specific_config.cpp \
-          get_dse.cpp \
-          get_ele_list.cpp \
-          get_ga_specific_config.cpp \
-          get_ics_info.cpp \
-          get_prog_config.cpp \
-          get_pulse_data.cpp \
-          get_sbr_bitstream.cpp \
-          get_sbr_startfreq.cpp \
-          get_sbr_stopfreq.cpp \
-          get_tns.cpp \
-          getfill.cpp \
-          getgroup.cpp \
-          getics.cpp \
-          getmask.cpp \
-          hcbtables_binary.cpp \
-          huffcb.cpp \
-          huffdecode.cpp \
-          hufffac.cpp \
-          huffspec_fxp.cpp \
-          idct16.cpp \
-          idct32.cpp \
-          idct8.cpp \
-          imdct_fxp.cpp \
-          infoinit.cpp \
-          init_sbr_dec.cpp \
-          intensity_right.cpp \
-          inv_long_complex_rot.cpp \
-          inv_short_complex_rot.cpp \
-          iquant_table.cpp \
-          long_term_prediction.cpp \
-          long_term_synthesis.cpp \
-          lt_decode.cpp \
-          mdct_fxp.cpp \
-          mdct_tables_fxp.cpp \
-          mdst.cpp \
-          mix_radix_fft.cpp \
-          ms_synt.cpp \
-          pns_corr.cpp \
-          pns_intensity_right.cpp \
-          pns_left.cpp \
-          ps_all_pass_filter_coeff.cpp \
-          ps_all_pass_fract_delay_filter.cpp \
-          ps_allocate_decoder.cpp \
-          ps_applied.cpp \
-          ps_bstr_decoding.cpp \
-          ps_channel_filtering.cpp \
-          ps_decode_bs_utils.cpp \
-          ps_decorrelate.cpp \
-          ps_fft_rx8.cpp \
-          ps_hybrid_analysis.cpp \
-          ps_hybrid_filter_bank_allocation.cpp \
-          ps_hybrid_synthesis.cpp \
-          ps_init_stereo_mixing.cpp \
-          ps_pwr_transient_detection.cpp \
-          ps_read_data.cpp \
-          ps_stereo_processing.cpp \
-          pulse_nc.cpp \
-          pv_div.cpp \
-          pv_log2.cpp \
-          pv_normalize.cpp \
-          pv_pow2.cpp \
-          pv_sine.cpp \
-          pv_sqrt.cpp \
-          pvmp4audiodecoderconfig.cpp \
-          pvmp4audiodecoderframe.cpp \
-          pvmp4audiodecodergetmemrequirements.cpp \
-          pvmp4audiodecoderinitlibrary.cpp \
-          pvmp4audiodecoderresetbuffer.cpp \
-          q_normalize.cpp \
-          qmf_filterbank_coeff.cpp \
-          sbr_aliasing_reduction.cpp \
-          sbr_applied.cpp \
-          sbr_code_book_envlevel.cpp \
-          sbr_crc_check.cpp \
-          sbr_create_limiter_bands.cpp \
-          sbr_dec.cpp \
-          sbr_decode_envelope.cpp \
-          sbr_decode_huff_cw.cpp \
-          sbr_downsample_lo_res.cpp \
-          sbr_envelope_calc_tbl.cpp \
-          sbr_envelope_unmapping.cpp \
-          sbr_extract_extended_data.cpp \
-          sbr_find_start_andstop_band.cpp \
-          sbr_generate_high_freq.cpp \
-          sbr_get_additional_data.cpp \
-          sbr_get_cpe.cpp \
-          sbr_get_dir_control_data.cpp \
-          sbr_get_envelope.cpp \
-          sbr_get_header_data.cpp \
-          sbr_get_noise_floor_data.cpp \
-          sbr_get_sce.cpp \
-          sbr_inv_filt_levelemphasis.cpp \
-          sbr_open.cpp \
-          sbr_read_data.cpp \
-          sbr_requantize_envelope_data.cpp \
-          sbr_reset_dec.cpp \
-          sbr_update_freq_scale.cpp \
-          set_mc_info.cpp \
-          sfb.cpp \
-          shellsort.cpp \
-          synthesis_sub_band.cpp \
-          tns_ar_filter.cpp \
-          tns_decode_coef.cpp \
-          tns_inv_filter.cpp \
-          trans4m_freq_2_time_fxp.cpp \
-          trans4m_time_2_freq_fxp.cpp \
-          unpack_idx.cpp \
-          window_tables_fxp.cpp \
-          pvmp4setaudioconfig.cpp \
-
-  LOCAL_CFLAGS := -DAAC_PLUS -DHQ_SBR -DPARAMETRICSTEREO -DOSCL_IMPORT_REF= -DOSCL_EXPORT_REF= -DOSCL_UNUSED_ARG=
-
-  LOCAL_C_INCLUDES := \
-          frameworks/av/media/libstagefright/include \
-
-  LOCAL_ARM_MODE := arm
-
-  LOCAL_MODULE := libstagefright_aacdec
-
-  include $(BUILD_STATIC_LIBRARY)
-
-  ################################################################################
-
-  include $(CLEAR_VARS)
-
-  LOCAL_SRC_FILES := \
-        SoftAAC.cpp
-
-  LOCAL_C_INCLUDES := \
-          frameworks/av/media/libstagefright/include \
-          frameworks/native/include/media/openmax
-
-  LOCAL_CFLAGS := -DOSCL_IMPORT_REF=
-
-  LOCAL_STATIC_LIBRARIES := \
-          libstagefright_aacdec
-
-  LOCAL_SHARED_LIBRARIES := \
-          libstagefright_omx libstagefright_foundation libutils
-
-  LOCAL_MODULE := libstagefright_soft_aacdec
-  LOCAL_MODULE_TAGS := optional
-
-  include $(BUILD_SHARED_LIBRARY)
-
-endif # $(AAC_LIBRARY)
+include $(BUILD_SHARED_LIBRARY)
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.cpp b/media/libstagefright/codecs/aacdec/SoftAAC.cpp
deleted file mode 100644
index 7c82484..0000000
--- a/media/libstagefright/codecs/aacdec/SoftAAC.cpp
+++ /dev/null
@@ -1,553 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-//#define LOG_NDEBUG 0
-#define LOG_TAG "SoftAAC"
-#include <utils/Log.h>
-
-#include "SoftAAC.h"
-
-#include "pvmp4audiodecoder_api.h"
-
-#include <media/stagefright/foundation/ADebug.h>
-#include <media/stagefright/foundation/hexdump.h>
-#include <media/stagefright/MediaErrors.h>
-
-namespace android {
-
-template<class T>
-static void InitOMXParams(T *params) {
-    params->nSize = sizeof(T);
-    params->nVersion.s.nVersionMajor = 1;
-    params->nVersion.s.nVersionMinor = 0;
-    params->nVersion.s.nRevision = 0;
-    params->nVersion.s.nStep = 0;
-}
-
-SoftAAC::SoftAAC(
-        const char *name,
-        const OMX_CALLBACKTYPE *callbacks,
-        OMX_PTR appData,
-        OMX_COMPONENTTYPE **component)
-    : SimpleSoftOMXComponent(name, callbacks, appData, component),
-      mConfig(new tPVMP4AudioDecoderExternal),
-      mIsADTS(false),
-      mDecoderBuf(NULL),
-      mInputBufferCount(0),
-      mUpsamplingFactor(2),
-      mAnchorTimeUs(0),
-      mNumSamplesOutput(0),
-      mSignalledError(false),
-      mOutputPortSettingsChange(NONE) {
-    initPorts();
-    CHECK_EQ(initDecoder(), (status_t)OK);
-}
-
-SoftAAC::~SoftAAC() {
-    free(mDecoderBuf);
-    mDecoderBuf = NULL;
-
-    delete mConfig;
-    mConfig = NULL;
-}
-
-void SoftAAC::initPorts() {
-    OMX_PARAM_PORTDEFINITIONTYPE def;
-    InitOMXParams(&def);
-
-    def.nPortIndex = 0;
-    def.eDir = OMX_DirInput;
-    def.nBufferCountMin = kNumInputBuffers;
-    def.nBufferCountActual = def.nBufferCountMin;
-    def.nBufferSize = 8192;
-    def.bEnabled = OMX_TRUE;
-    def.bPopulated = OMX_FALSE;
-    def.eDomain = OMX_PortDomainAudio;
-    def.bBuffersContiguous = OMX_FALSE;
-    def.nBufferAlignment = 1;
-
-    def.format.audio.cMIMEType = const_cast<char *>("audio/aac");
-    def.format.audio.pNativeRender = NULL;
-    def.format.audio.bFlagErrorConcealment = OMX_FALSE;
-    def.format.audio.eEncoding = OMX_AUDIO_CodingAAC;
-
-    addPort(def);
-
-    def.nPortIndex = 1;
-    def.eDir = OMX_DirOutput;
-    def.nBufferCountMin = kNumOutputBuffers;
-    def.nBufferCountActual = def.nBufferCountMin;
-    def.nBufferSize = 8192;
-    def.bEnabled = OMX_TRUE;
-    def.bPopulated = OMX_FALSE;
-    def.eDomain = OMX_PortDomainAudio;
-    def.bBuffersContiguous = OMX_FALSE;
-    def.nBufferAlignment = 2;
-
-    def.format.audio.cMIMEType = const_cast<char *>("audio/raw");
-    def.format.audio.pNativeRender = NULL;
-    def.format.audio.bFlagErrorConcealment = OMX_FALSE;
-    def.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
-
-    addPort(def);
-}
-
-status_t SoftAAC::initDecoder() {
-    memset(mConfig, 0, sizeof(tPVMP4AudioDecoderExternal));
-    mConfig->outputFormat = OUTPUTFORMAT_16PCM_INTERLEAVED;
-    mConfig->aacPlusEnabled = 1;
-
-    // The software decoder doesn't properly support mono output on
-    // AACplus files. Always output stereo.
-    mConfig->desiredChannels = 2;
-
-    UInt32 memRequirements = PVMP4AudioDecoderGetMemRequirements();
-    mDecoderBuf = malloc(memRequirements);
-
-    Int err = PVMP4AudioDecoderInitLibrary(mConfig, mDecoderBuf);
-    if (err != MP4AUDEC_SUCCESS) {
-        ALOGE("Failed to initialize MP4 audio decoder");
-        return UNKNOWN_ERROR;
-    }
-
-    return OK;
-}
-
-OMX_ERRORTYPE SoftAAC::internalGetParameter(
-        OMX_INDEXTYPE index, OMX_PTR params) {
-    switch (index) {
-        case OMX_IndexParamAudioAac:
-        {
-            OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
-                (OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
-
-            if (aacParams->nPortIndex != 0) {
-                return OMX_ErrorUndefined;
-            }
-
-            aacParams->nBitRate = 0;
-            aacParams->nAudioBandWidth = 0;
-            aacParams->nAACtools = 0;
-            aacParams->nAACERtools = 0;
-            aacParams->eAACProfile = OMX_AUDIO_AACObjectMain;
-
-            aacParams->eAACStreamFormat =
-                mIsADTS
-                    ? OMX_AUDIO_AACStreamFormatMP4ADTS
-                    : OMX_AUDIO_AACStreamFormatMP4FF;
-
-            aacParams->eChannelMode = OMX_AUDIO_ChannelModeStereo;
-
-            if (!isConfigured()) {
-                aacParams->nChannels = 1;
-                aacParams->nSampleRate = 44100;
-                aacParams->nFrameLength = 0;
-            } else {
-                aacParams->nChannels = mConfig->encodedChannels;
-                aacParams->nSampleRate = mConfig->samplingRate;
-                aacParams->nFrameLength = mConfig->frameLength;
-            }
-
-            return OMX_ErrorNone;
-        }
-
-        case OMX_IndexParamAudioPcm:
-        {
-            OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
-                (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
-
-            if (pcmParams->nPortIndex != 1) {
-                return OMX_ErrorUndefined;
-            }
-
-            pcmParams->eNumData = OMX_NumericalDataSigned;
-            pcmParams->eEndian = OMX_EndianBig;
-            pcmParams->bInterleaved = OMX_TRUE;
-            pcmParams->nBitPerSample = 16;
-            pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
-            pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
-            pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
-
-            if (!isConfigured()) {
-                pcmParams->nChannels = 1;
-                pcmParams->nSamplingRate = 44100;
-            } else {
-                pcmParams->nChannels = mConfig->desiredChannels;
-                pcmParams->nSamplingRate = mConfig->samplingRate;
-            }
-
-            return OMX_ErrorNone;
-        }
-
-        default:
-            return SimpleSoftOMXComponent::internalGetParameter(index, params);
-    }
-}
-
-OMX_ERRORTYPE SoftAAC::internalSetParameter(
-        OMX_INDEXTYPE index, const OMX_PTR params) {
-    switch (index) {
-        case OMX_IndexParamStandardComponentRole:
-        {
-            const OMX_PARAM_COMPONENTROLETYPE *roleParams =
-                (const OMX_PARAM_COMPONENTROLETYPE *)params;
-
-            if (strncmp((const char *)roleParams->cRole,
-                        "audio_decoder.aac",
-                        OMX_MAX_STRINGNAME_SIZE - 1)) {
-                return OMX_ErrorUndefined;
-            }
-
-            return OMX_ErrorNone;
-        }
-
-        case OMX_IndexParamAudioAac:
-        {
-            const OMX_AUDIO_PARAM_AACPROFILETYPE *aacParams =
-                (const OMX_AUDIO_PARAM_AACPROFILETYPE *)params;
-
-            if (aacParams->nPortIndex != 0) {
-                return OMX_ErrorUndefined;
-            }
-
-            if (aacParams->eAACStreamFormat == OMX_AUDIO_AACStreamFormatMP4FF) {
-                mIsADTS = false;
-            } else if (aacParams->eAACStreamFormat
-                        == OMX_AUDIO_AACStreamFormatMP4ADTS) {
-                mIsADTS = true;
-            } else {
-                return OMX_ErrorUndefined;
-            }
-
-            return OMX_ErrorNone;
-        }
-
-        case OMX_IndexParamAudioPcm:
-        {
-            const OMX_AUDIO_PARAM_PCMMODETYPE *pcmParams =
-                (OMX_AUDIO_PARAM_PCMMODETYPE *)params;
-
-            if (pcmParams->nPortIndex != 1) {
-                return OMX_ErrorUndefined;
-            }
-
-            return OMX_ErrorNone;
-        }
-
-        default:
-            return SimpleSoftOMXComponent::internalSetParameter(index, params);
-    }
-}
-
-bool SoftAAC::isConfigured() const {
-    return mInputBufferCount > 0;
-}
-
-void SoftAAC::onQueueFilled(OMX_U32 portIndex) {
-    if (mSignalledError || mOutputPortSettingsChange != NONE) {
-        return;
-    }
-
-    List<BufferInfo *> &inQueue = getPortQueue(0);
-    List<BufferInfo *> &outQueue = getPortQueue(1);
-
-    if (portIndex == 0 && mInputBufferCount == 0) {
-        ++mInputBufferCount;
-
-        BufferInfo *info = *inQueue.begin();
-        OMX_BUFFERHEADERTYPE *header = info->mHeader;
-
-        mConfig->pInputBuffer = header->pBuffer + header->nOffset;
-        mConfig->inputBufferCurrentLength = header->nFilledLen;
-        mConfig->inputBufferMaxLength = 0;
-
-        Int err = PVMP4AudioDecoderConfig(mConfig, mDecoderBuf);
-        if (err != MP4AUDEC_SUCCESS) {
-            mSignalledError = true;
-            notify(OMX_EventError, OMX_ErrorUndefined, err, NULL);
-            return;
-        }
-
-        inQueue.erase(inQueue.begin());
-        info->mOwnedByUs = false;
-        notifyEmptyBufferDone(header);
-
-        notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
-        mOutputPortSettingsChange = AWAITING_DISABLED;
-        return;
-    }
-
-    while (!inQueue.empty() && !outQueue.empty()) {
-        BufferInfo *inInfo = *inQueue.begin();
-        OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;
-
-        BufferInfo *outInfo = *outQueue.begin();
-        OMX_BUFFERHEADERTYPE *outHeader = outInfo->mHeader;
-
-        if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
-            inQueue.erase(inQueue.begin());
-            inInfo->mOwnedByUs = false;
-            notifyEmptyBufferDone(inHeader);
-
-            outHeader->nFilledLen = 0;
-            outHeader->nFlags = OMX_BUFFERFLAG_EOS;
-
-            outQueue.erase(outQueue.begin());
-            outInfo->mOwnedByUs = false;
-            notifyFillBufferDone(outHeader);
-            return;
-        }
-
-        if (inHeader->nOffset == 0) {
-            mAnchorTimeUs = inHeader->nTimeStamp;
-            mNumSamplesOutput = 0;
-        }
-
-        size_t adtsHeaderSize = 0;
-        if (mIsADTS) {
-            // skip 30 bits, aac_frame_length follows.
-            // ssssssss ssssiiip ppffffPc ccohCCll llllllll lll?????
-
-            const uint8_t *adtsHeader = inHeader->pBuffer + inHeader->nOffset;
-
-            bool signalError = false;
-            if (inHeader->nFilledLen < 7) {
-                ALOGE("Audio data too short to contain even the ADTS header. "
-                      "Got %ld bytes.", inHeader->nFilledLen);
-                hexdump(adtsHeader, inHeader->nFilledLen);
-                signalError = true;
-            } else {
-                bool protectionAbsent = (adtsHeader[1] & 1);
-
-                unsigned aac_frame_length =
-                    ((adtsHeader[3] & 3) << 11)
-                    | (adtsHeader[4] << 3)
-                    | (adtsHeader[5] >> 5);
-
-                if (inHeader->nFilledLen < aac_frame_length) {
-                    ALOGE("Not enough audio data for the complete frame. "
-                          "Got %ld bytes, frame size according to the ADTS "
-                          "header is %u bytes.",
-                          inHeader->nFilledLen, aac_frame_length);
-                    hexdump(adtsHeader, inHeader->nFilledLen);
-                    signalError = true;
-                } else {
-                    adtsHeaderSize = (protectionAbsent ? 7 : 9);
-
-                    mConfig->pInputBuffer =
-                        (UChar *)adtsHeader + adtsHeaderSize;
-
-                    mConfig->inputBufferCurrentLength =
-                        aac_frame_length - adtsHeaderSize;
-
-                    inHeader->nOffset += adtsHeaderSize;
-                    inHeader->nFilledLen -= adtsHeaderSize;
-                }
-            }
-
-            if (signalError) {
-                mSignalledError = true;
-
-                notify(OMX_EventError, OMX_ErrorStreamCorrupt,
-                       ERROR_MALFORMED, NULL);
-
-                return;
-            }
-        } else {
-            mConfig->pInputBuffer = inHeader->pBuffer + inHeader->nOffset;
-            mConfig->inputBufferCurrentLength = inHeader->nFilledLen;
-        }
-
-        mConfig->inputBufferMaxLength = 0;
-        mConfig->inputBufferUsedLength = 0;
-        mConfig->remainderBits = 0;
-
-        mConfig->pOutputBuffer =
-            reinterpret_cast<Int16 *>(outHeader->pBuffer + outHeader->nOffset);
-
-        mConfig->pOutputBuffer_plus = &mConfig->pOutputBuffer[2048];
-        mConfig->repositionFlag = false;
-
-        Int32 prevSamplingRate = mConfig->samplingRate;
-        Int decoderErr = PVMP4AudioDecodeFrame(mConfig, mDecoderBuf);
-
-        /*
-         * AAC+/eAAC+ streams can be signalled in two ways: either explicitly
-         * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual
-         * rate system and the sampling rate in the final output is actually
-         * doubled compared with the core AAC decoder sampling rate.
-         *
-         * Explicit signalling is done by explicitly defining SBR audio object
-         * type in the bitstream. Implicit signalling is done by embedding
-         * SBR content in AAC extension payload specific to SBR, and hence
-         * requires an AAC decoder to perform pre-checks on actual audio frames.
-         *
-         * Thus, we could not say for sure whether a stream is
-         * AAC+/eAAC+ until the first data frame is decoded.
-         */
-        if (decoderErr == MP4AUDEC_SUCCESS && mInputBufferCount <= 2) {
-            ALOGV("audio/extended audio object type: %d + %d",
-                mConfig->audioObjectType, mConfig->extendedAudioObjectType);
-            ALOGV("aac+ upsampling factor: %d desired channels: %d",
-                mConfig->aacPlusUpsamplingFactor, mConfig->desiredChannels);
-
-            if (mInputBufferCount == 1) {
-                mUpsamplingFactor = mConfig->aacPlusUpsamplingFactor;
-                // Check on the sampling rate to see whether it is changed.
-                if (mConfig->samplingRate != prevSamplingRate) {
-                    ALOGW("Sample rate was %d Hz, but now is %d Hz",
-                            prevSamplingRate, mConfig->samplingRate);
-
-                    // We'll hold onto the input buffer and will decode
-                    // it again once the output port has been reconfigured.
-
-                    // We're going to want to revisit this input buffer, but
-                    // may have already advanced the offset. Undo that if
-                    // necessary.
-                    inHeader->nOffset -= adtsHeaderSize;
-                    inHeader->nFilledLen += adtsHeaderSize;
-
-                    notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
-                    mOutputPortSettingsChange = AWAITING_DISABLED;
-                    return;
-                }
-            } else {  // mInputBufferCount == 2
-                if (mConfig->extendedAudioObjectType == MP4AUDIO_AAC_LC ||
-                    mConfig->extendedAudioObjectType == MP4AUDIO_LTP) {
-                    if (mUpsamplingFactor == 2) {
-                        // The stream turns out to be not aacPlus mode anyway
-                        ALOGW("Disable AAC+/eAAC+ since extended audio object "
-                             "type is %d",
-                             mConfig->extendedAudioObjectType);
-                        mConfig->aacPlusEnabled = 0;
-                    }
-                } else {
-                    if (mUpsamplingFactor == 1) {
-                        // aacPlus mode does not buy us anything, but to cause
-                        // 1. CPU load to increase, and
-                        // 2. a half speed of decoding
-                        ALOGW("Disable AAC+/eAAC+ since upsampling factor is 1");
-                        mConfig->aacPlusEnabled = 0;
-                    }
-                }
-            }
-        }
-
-        size_t numOutBytes =
-            mConfig->frameLength * sizeof(int16_t) * mConfig->desiredChannels;
-
-        if (decoderErr == MP4AUDEC_SUCCESS) {
-            CHECK_LE(mConfig->inputBufferUsedLength, inHeader->nFilledLen);
-
-            inHeader->nFilledLen -= mConfig->inputBufferUsedLength;
-            inHeader->nOffset += mConfig->inputBufferUsedLength;
-        } else {
-            ALOGW("AAC decoder returned error %d, substituting silence",
-                 decoderErr);
-
-            memset(outHeader->pBuffer + outHeader->nOffset, 0, numOutBytes);
-
-            // Discard input buffer.
-            inHeader->nFilledLen = 0;
-
-            // fall through
-        }
-
-        if (decoderErr == MP4AUDEC_SUCCESS || mNumSamplesOutput > 0) {
-            // We'll only output data if we successfully decoded it or
-            // we've previously decoded valid data, in the latter case
-            // (decode failed) we'll output a silent frame.
-
-            if (mUpsamplingFactor == 2) {
-                if (mConfig->desiredChannels == 1) {
-                    memcpy(&mConfig->pOutputBuffer[1024],
-                           &mConfig->pOutputBuffer[2048],
-                           numOutBytes * 2);
-                }
-                numOutBytes *= 2;
-            }
-
-            outHeader->nFilledLen = numOutBytes;
-            outHeader->nFlags = 0;
-
-            outHeader->nTimeStamp =
-                mAnchorTimeUs
-                    + (mNumSamplesOutput * 1000000ll) / mConfig->samplingRate;
-
-            mNumSamplesOutput += mConfig->frameLength * mUpsamplingFactor;
-
-            outInfo->mOwnedByUs = false;
-            outQueue.erase(outQueue.begin());
-            outInfo = NULL;
-            notifyFillBufferDone(outHeader);
-            outHeader = NULL;
-        }
-
-        if (inHeader->nFilledLen == 0) {
-            inInfo->mOwnedByUs = false;
-            inQueue.erase(inQueue.begin());
-            inInfo = NULL;
-            notifyEmptyBufferDone(inHeader);
-            inHeader = NULL;
-        }
-
-        if (decoderErr == MP4AUDEC_SUCCESS) {
-            ++mInputBufferCount;
-        }
-    }
-}
-
-void SoftAAC::onPortFlushCompleted(OMX_U32 portIndex) {
-    if (portIndex == 0) {
-        // Make sure that the next buffer output does not still
-        // depend on fragments from the last one decoded.
-        PVMP4AudioDecoderResetBuffer(mDecoderBuf);
-    }
-}
-
-void SoftAAC::onPortEnableCompleted(OMX_U32 portIndex, bool enabled) {
-    if (portIndex != 1) {
-        return;
-    }
-
-    switch (mOutputPortSettingsChange) {
-        case NONE:
-            break;
-
-        case AWAITING_DISABLED:
-        {
-            CHECK(!enabled);
-            mOutputPortSettingsChange = AWAITING_ENABLED;
-            break;
-        }
-
-        default:
-        {
-            CHECK_EQ((int)mOutputPortSettingsChange, (int)AWAITING_ENABLED);
-            CHECK(enabled);
-            mOutputPortSettingsChange = NONE;
-            break;
-        }
-    }
-}
-
-}  // namespace android
-
-android::SoftOMXComponent *createSoftOMXComponent(
-        const char *name, const OMX_CALLBACKTYPE *callbacks,
-        OMX_PTR appData, OMX_COMPONENTTYPE **component) {
-    return new android::SoftAAC(name, callbacks, appData, component);
-}
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC.h b/media/libstagefright/codecs/aacdec/SoftAAC.h
deleted file mode 100644
index 2e75005..0000000
--- a/media/libstagefright/codecs/aacdec/SoftAAC.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#ifndef SOFT_AAC_H_
-
-#define SOFT_AAC_H_
-
-#include "SimpleSoftOMXComponent.h"
-
-struct tPVMP4AudioDecoderExternal;
-
-namespace android {
-
-struct SoftAAC : public SimpleSoftOMXComponent {
-    SoftAAC(const char *name,
-            const OMX_CALLBACKTYPE *callbacks,
-            OMX_PTR appData,
-            OMX_COMPONENTTYPE **component);
-
-protected:
-    virtual ~SoftAAC();
-
-    virtual OMX_ERRORTYPE internalGetParameter(
-            OMX_INDEXTYPE index, OMX_PTR params);
-
-    virtual OMX_ERRORTYPE internalSetParameter(
-            OMX_INDEXTYPE index, const OMX_PTR params);
-
-    virtual void onQueueFilled(OMX_U32 portIndex);
-    virtual void onPortFlushCompleted(OMX_U32 portIndex);
-    virtual void onPortEnableCompleted(OMX_U32 portIndex, bool enabled);
-
-private:
-    enum {
-        kNumInputBuffers        = 4,
-        kNumOutputBuffers       = 4,
-    };
-
-    tPVMP4AudioDecoderExternal *mConfig;
-    bool mIsADTS;
-    void *mDecoderBuf;
-
-    size_t mInputBufferCount;
-    size_t mUpsamplingFactor;
-    int64_t mAnchorTimeUs;
-    int64_t mNumSamplesOutput;
-
-    bool mSignalledError;
-
-    enum {
-        NONE,
-        AWAITING_DISABLED,
-        AWAITING_ENABLED
-    } mOutputPortSettingsChange;
-
-    void initPorts();
-    status_t initDecoder();
-    bool isConfigured() const;
-
-    DISALLOW_EVIL_CONSTRUCTORS(SoftAAC);
-};
-
-}  // namespace android
-
-#endif  // SOFT_AAC_H_
diff --git a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
index ff95f9f..566b1db 100644
--- a/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
+++ b/media/libstagefright/codecs/aacdec/SoftAAC2.cpp
@@ -320,22 +320,39 @@
             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 +421,9 @@
         }
 
         // 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 +512,8 @@
             // (decode failed) we'll output a silent frame.
             if (mIsFirst) {
                 mIsFirst = false;
-                // the first decoded frame should be discarded to account for decoder delay
+                // the first decoded frame should be discarded to account
+                // for decoder delay
                 numOutBytes = 0;
             }
 
diff --git a/media/libstagefright/codecs/aacdec/aac_mem_funcs.h b/media/libstagefright/codecs/aacdec/aac_mem_funcs.h
deleted file mode 100644
index ce7cb12..0000000
--- a/media/libstagefright/codecs/aacdec/aac_mem_funcs.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: aac_mem_funcs.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-
-#include <string.h>
-
-#ifndef AAC_MEM_FUNCS_H
-#define AAC_MEM_FUNCS_H
-
-#define pv_memset(to, c, n)         memset(to, c, n)
-
-
-#define pv_memcpy(to, from, n)      memcpy(to, from, n)
-#define pv_memmove(to, from, n)     memmove(to, from, n)
-#define pv_memcmp(p, q, n)          memcmp(p, q, n)
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp b/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp
deleted file mode 100644
index 2786dcc..0000000
--- a/media/libstagefright/codecs/aacdec/analysis_sub_band.cpp
+++ /dev/null
@@ -1,289 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: analysis_sub_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 vec[],            Input vector, 32-bit
-    const Int32 *cosTerms,  Cosine Terms
-    Int   maxbands          number of bands used
-    Int32 *scratch_mem      Scratch memory
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "analysis_sub_band.h"
-#include "dst32.h"
-#include "idct32.h"
-#include "mdst.h"
-
-#include "aac_mem_funcs.h"
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-#ifdef HQ_SBR
-
-
-const Int32 exp_1_5_phi[32] =
-{
-
-    0x7FEA04B6,  0x7F380E1C, 0x7DD6176E, 0x7BC6209F,
-    0x790A29A4,  0x75A6326E, 0x719E3AF3, 0x6CF94326,
-    0x67BD4AFB,  0x61F15269, 0x5B9D5964, 0x54CA5FE4,
-    0x4D8165DE,  0x45CD6B4B, 0x3DB87023, 0x354E7460,
-    0x2C9977FB,  0x23A77AEF, 0x1A837D3A, 0x113A7ED6,
-    0x07D97FC2,  0xFE6E7FFE, 0xF5057F87, 0xEBAB7E60,
-    0xE26D7C89,  0xD9587A06, 0xD07976D9, 0xC7DB7308,
-    0xBF8C6E97,  0xB796698C, 0xB00563EF, 0xA8E25DC8,
-
-};
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void analysis_sub_band_LC(Int32 vec[64],
-                          Int32 cosine_total[],
-                          Int32 maxBand,
-                          Int32 scratch_mem[][64])
-{
-    Int32 i;
-    Int32 *cosine_term = &scratch_mem[0][0];
-    Int32 *sine_term   = &scratch_mem[0][32];
-
-    Int32 *pt_cos_t;
-
-
-    Int32 *pt_vec    =  &vec[0];
-    Int32 *pt_vec_32 =  &vec[32];
-
-    Int32 *pt_cos = cosine_term;
-    Int32 *pt_sin = sine_term;
-
-    for (i = 8; i != 0; i--)
-    {
-        Int32 tmp1 = *(pt_vec_32++);
-        Int32 tmp3 = *(pt_vec_32++);
-        Int32 tmp2 = *(pt_vec++);
-        Int32 tmp4 = *(pt_vec++);
-        *(pt_cos++) = (tmp1 - tmp2) >> 1;
-        *(pt_cos++) = (tmp3 - tmp4) >> 1;
-        *(pt_sin++) = (tmp1 + tmp2);
-        *(pt_sin++) = (tmp3 + tmp4);
-        tmp1 = *(pt_vec_32++);
-        tmp3 = *(pt_vec_32++);
-        tmp2 = *(pt_vec++);
-        tmp4 = *(pt_vec++);
-        *(pt_cos++) = (tmp1 - tmp2) >> 1;
-        *(pt_cos++) = (tmp3 - tmp4) >> 1;
-        *(pt_sin++) = (tmp1 + tmp2);
-        *(pt_sin++) = (tmp3 + tmp4);
-    }
-
-
-    idct_32(cosine_term, scratch_mem[1]);
-
-    dst_32(sine_term, scratch_mem[1]);
-
-    pt_cos  = cosine_term;
-    pt_sin  = sine_term;
-
-    pt_cos_t  = cosine_total;
-
-    for (i = 0; i < maxBand; i += 4)
-    {
-        *(pt_cos_t++) = (*(pt_cos++) + *(pt_sin++));
-        *(pt_cos_t++) = (-*(pt_cos++) + *(pt_sin++));
-        *(pt_cos_t++) = (-*(pt_cos++) - *(pt_sin++));
-        *(pt_cos_t++) = (*(pt_cos++) - *(pt_sin++));
-    }
-
-    pt_cos_t  = &cosine_total[maxBand];
-
-    for (i = (32 - maxBand); i != 0; i--)
-    {
-        *(pt_cos_t++) =   0;
-    }
-}
-
-
-#ifdef HQ_SBR
-
-
-void analysis_sub_band(Int32 vec[64],
-                       Int32 cosine_total[],
-                       Int32 sine_total[],
-                       Int32 maxBand,
-                       Int32 scratch_mem[][64])
-{
-    Int32 i;
-    Int32 *sine_term1   = &scratch_mem[0][0];
-    Int32 *sine_term2   = &scratch_mem[0][32];
-
-    Int32 temp1;
-    Int32 temp2;
-    Int32 temp3;
-    Int32 temp4;
-
-    const Int32 *pt_exp;
-    Int32 exp_1_5;
-
-    Int32 *pt_vec    =  &vec[0];
-    Int32 *pt_vec_32 =  &vec[32];
-
-    Int32 *pt_cos1 = pt_vec;
-    Int32 *pt_sin1 = sine_term1;
-    Int32 *pt_cos2 = pt_vec_32;
-    Int32 *pt_sin2 = sine_term2;
-
-
-    pv_memcpy(sine_term1, vec, 64*sizeof(*vec));
-
-    mdst_32(sine_term1, scratch_mem[1]);
-    mdst_32(sine_term2, scratch_mem[1]);
-
-    mdct_32(&vec[ 0]);
-    mdct_32(&vec[32]);
-
-    pt_cos1 = &vec[ 0];
-    pt_cos2 = &vec[32];
-
-
-    pt_sin1 = sine_term1;
-    pt_sin2 = sine_term2;
-
-    pt_vec     = cosine_total;
-    pt_vec_32  =   sine_total;
-    pt_exp  = exp_1_5_phi;
-
-    temp3 = (*(pt_cos1++) - *(pt_sin2++));
-    temp4 = (*(pt_sin1++) + *(pt_cos2++));
-
-    for (i = 0; i < maxBand; i += 2)
-    {
-
-        exp_1_5 = *(pt_exp++);
-        temp1    =  cmplx_mul32_by_16(temp3,  temp4, exp_1_5);
-        temp2    =  cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
-
-        *(pt_vec++)    =  shft_lft_1(temp1);
-        *(pt_vec_32++) =  shft_lft_1(temp2);
-
-        temp3 = (*(pt_cos1++) + *(pt_sin2++));
-        temp4 = (*(pt_sin1++) - *(pt_cos2++));
-
-        exp_1_5 = *(pt_exp++);
-        temp1    =  cmplx_mul32_by_16(temp3,  temp4, exp_1_5);
-        temp2    =  cmplx_mul32_by_16(temp4, -temp3, exp_1_5);
-
-        *(pt_vec++)    =  shft_lft_1(temp1);
-        *(pt_vec_32++) =  shft_lft_1(temp2);
-
-        temp3 = (*(pt_cos1++) - *(pt_sin2++));
-        temp4 = (*(pt_sin1++) + *(pt_cos2++));
-    }
-
-
-    pt_cos1  = &cosine_total[maxBand];  /* in the chance that maxband is not even */
-    pt_sin1  = &sine_total[maxBand];
-
-    for (i = (32 - maxBand); i != 0; i--)
-    {
-        *(pt_cos1++) =  0;
-        *(pt_sin1++) =  0;
-    }
-
-}
-
-
-#endif
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/analysis_sub_band.h b/media/libstagefright/codecs/aacdec/analysis_sub_band.h
deleted file mode 100644
index 815456c..0000000
--- a/media/libstagefright/codecs/aacdec/analysis_sub_band.h
+++ /dev/null
@@ -1,82 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/analysis_sub_band.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef ANALYSIS_SUB_BAND_H
-#define ANALYSIS_SUB_BAND_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    void analysis_sub_band_LC(Int32 vec[64],
-    Int32 cosine_total[],
-    Int32 maxBand,
-    Int32 scratch_mem[][64]);
-
-#ifdef HQ_SBR
-
-
-    void analysis_sub_band(Int32 vec[64],
-                           Int32 cosine_total[],
-                           Int32 sine_total[],
-                           Int32 maxBand,
-                           Int32 scratch_mem[][64]);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* ANALYSIS_SUB_BAND_H */
diff --git a/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp b/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp
deleted file mode 100644
index ab36c6a..0000000
--- a/media/libstagefright/codecs/aacdec/apply_ms_synt.cpp
+++ /dev/null
@@ -1,454 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/apply_ms_synt.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated pseudocode to correct capitalized format for the IF
- FOR and WHILE statements.
-
- Description: Delete local variable start_indx, since it is never used.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    pFrameInfo = Pointer to structure that holds information about each group.
-                 (long block flag, number of windows, scalefactor bands
-                  per group, etc.)
-                 [const pFrameInfo * const]
-
-    group      = Array that contains indexes of the
-                 first window in the next group.
-                 [const Int *, length 8]
-
-    mask_map   = Array that denotes whether M/S stereo is turned on for
-                 each grouped scalefactor band.
-                 [const Int *, length MAX_SFB]
-
-    codebook_map = Array that denotes which Huffman codebook was used for
-                   the encoding of each grouped scalefactor band.
-                   [const Int *, length MAX_SFB]
-
-    coefLeft = Array containing the fixed-point spectral coefficients
-                       for the left channel.
-                       [Int32 *, length 1024]
-
-    coefRight = Array containing the fixed-point spectral coefficients
-                        for the right channel.
-                        [Int32 *, length 1024]
-
-    q_formatLeft = The Q-format for the left channel's fixed-point spectral
-                   coefficients, on a per-scalefactor band, non-grouped basis.
-                   [Int *, length MAX_SFB]
-
-    q_formatRight = The Q-format for the right channel's fixed-point spectral
-                    coefficients, on a per-scalefactor band, non-grouped basis.
-                    [Int *, length MAX_SFB]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coefLeft  = Contains the new spectral information.
-
-    coefRight = Contains the new spectral information.
-
-    q_formatLeft      = Q-format may be updated with changed to fixed-point
-                        data in coefLeft.
-
-    q_formatRight     = Q-format may be updated with changed to fixed-point
-                        data in coefRight.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function steps through all of the tools that are applied on a
- scalefactor band basis.
-
- The use of M/S stereo is checked for.  For M/S decoding to take
- place, ms_mask_map must be TRUE for that particular SFB, AND the Huffman
- codebook used must be < NOISE_HCB.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.7.1   M/S stereo
-        Subpart 4.6.2     ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pCoefRight = coefRight;
-    pCoefLeft = coefLeft;
-
-    window_start = 0;
-    tot_sfb = 0;
-
-    coef_per_win = pFrameInfo->coef_per_win[0];
-
-    sfb_per_win = pFrameInfo->sfb_per_win[0];
-
-    DO
-
-        pBand     = pFrameInfo->win_sfb_top[window_start];
-
-        partition = *(pGroup);
-
-        pGroup = pGroup + 1;
-
-        band_start = 0;
-
-        wins_in_group = (partition - window_start);
-
-        FOR (sfb = sfb_per_win; sfb > 0; sfb--)
-
-            band_stop = *(pBand);
-
-            pBand = pBand + 1;
-
-            codebook = *(pCodebookMap);
-
-            pCodebookMap = pCodebookMap + 1;
-
-            mask_enabled = *(pMaskMap);
-
-            pMaskMap = pMaskMap + 1;
-
-            IF (codebook < NOISE_HCB)
-            THEN
-                IF (mask_enabled != FALSE)
-                THEN
-                    band_length = band_stop - band_start;
-
-                    CALL
-                        ms_synt(
-                            wins_in_group,
-                            coef_per_win,
-                            sfb_per_win,
-                            band_length,
-                           &(pCoefLeft[band_start]),
-                           &(pCoefRight[band_start]),
-                           &(q_formatLeft[tot_sfb]),
-                           &(q_formatRight[tot_sfb]) );
-
-                    MODIFYING
-                        &(pCoefLeft[band_start]),
-                        &(pCoefRight[band_start]),
-                        &(q_formatLeft[tot_sfb]),
-                        &(q_formatRight[tot_sfb])
-
-                    RETURNING
-                        None
-                ENDIF
-            ENDIF
-            band_start = band_stop;
-
-            tot_sfb = tot_sfb + 1;
-
-        ENDFOR
-
-        pCoefRight = pCoefRight + coef_per_win * wins_in_group;
-        pCoefLeft  = pCoefLeft  + coef_per_win * wins_in_group;
-
-        wins_in_group = wins_in_group - 1;
-
-        tot_sfb = tot_sfb + sfb_per_win * wins_in_group;
-
-        window_start = partition;
-
-    WHILE (partition < pFrameInfo->num_win);
-
-    return;
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "apply_ms_synt.h"
-#include "e_huffmanconst.h"
-#include "ms_synt.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void apply_ms_synt(
-    const FrameInfo * const pFrameInfo,
-    const Int        group[],
-    const Bool       mask_map[],
-    const Int        codebook_map[],
-    Int32      coefLeft[],
-    Int32      coefRight[],
-    Int        q_formatLeft[MAXBANDS],
-    Int        q_formatRight[MAXBANDS])
-
-{
-
-    Int32   *pCoefRight;
-
-    Int32   *pCoefLeft;
-
-    Int     tot_sfb;
-    Int     sfb;
-
-    Int     band_length;
-    Int     band_start;
-    Int     band_stop;
-    Int     coef_per_win;
-
-    Int     codebook;
-    Int     partition;
-    Int     window_start;
-
-    Int     sfb_per_win;
-    Int     wins_in_group;
-
-    const Int16 *pBand;
-    const Int   *pCodebookMap  = codebook_map;
-    const Int   *pGroup        = group;
-    const Bool  *pMaskMap      = mask_map;
-
-    Bool mask_enabled;
-
-    pCoefRight = coefRight;
-    pCoefLeft = coefLeft;
-
-    window_start = 0;
-    tot_sfb = 0;
-
-    /*
-     * Each window in the frame should have the same number of coef's,
-     * so coef_per_win is constant in all the loops
-     */
-    coef_per_win = pFrameInfo->coef_per_win[0];
-
-    /*
-     * Because the number of scalefactor bands per window should be
-     * constant for each frame, sfb_per_win can be determined outside
-     * of the loop.
-     *
-     * For 44.1 kHz sampling rate   sfb_per_win = 14 for short windows
-     *                              sfb_per_win = 49 for long  windows
-     */
-
-    sfb_per_win = pFrameInfo->sfb_per_win[0];
-
-    do
-    {
-        pBand     = pFrameInfo->win_sfb_top[window_start];
-
-        /*
-         * Partition is equal to the first window in the next group
-         *
-         * { Group 0    }{      Group 1      }{    Group 2 }{Group 3}
-         * [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
-         *
-         * pGroup[0] = 2
-         * pGroup[1] = 5
-         * pGroup[2] = 7
-         * pGroup[3] = 8
-         */
-
-        partition = *(pGroup++);
-
-        band_start = 0;
-
-        wins_in_group = (partition - window_start);
-
-        for (sfb = sfb_per_win; sfb > 0; sfb--)
-        {
-            /* band is offset table, band_stop is last coef in band */
-            band_stop = *(pBand++);
-
-            codebook = *(pCodebookMap++);
-
-            mask_enabled = *(pMaskMap++);
-
-            /*
-             * When a codebook < NOISE_HCB is found, apply M/S to that
-             * scalefactorband.
-             *
-             * Example...  sfb[3] == NOISE_HCB
-             *
-             * [ Group 1                                      ]
-             * [win 0                 ][win 1                 ]
-             * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7]
-             *
-             * The for(sfb) steps through the sfb's 0-7 in win 0.
-             *
-             * Finding sfb[3]'s codebook == NOISE_HCB, the code
-             * steps through all the windows in the group (they share
-             * the same scalefactors) and replaces that sfb with noise.
-             */
-
-            if (codebook < NOISE_HCB)
-            {
-                if (mask_enabled != FALSE)
-                {
-                    band_length = band_stop - band_start;
-
-                    ms_synt(
-                        wins_in_group,
-                        coef_per_win,
-                        sfb_per_win,
-                        band_length,
-                        &(pCoefLeft[band_start]),
-                        &(pCoefRight[band_start]),
-                        &(q_formatLeft[tot_sfb]),
-                        &(q_formatRight[tot_sfb]));
-                }
-            }
-            band_start = band_stop;
-
-            tot_sfb++;
-
-        } /* for (sfb) */
-
-        /*
-         * Increment pCoefRight and pCoefLeft by
-         * coef_per_win * the number of windows
-         */
-
-        pCoefRight += coef_per_win * wins_in_group;
-        pCoefLeft  += coef_per_win * wins_in_group--;
-
-        /*
-         * Increase tot_sfb by sfb_per_win times the number of windows minus 1.
-         * The minus 1 comes from the fact that tot_sfb is already pointing
-         * to the first sfb in the 2nd window of the group.
-         */
-        tot_sfb += sfb_per_win * wins_in_group;
-
-        window_start = partition;
-
-    }
-    while (partition < pFrameInfo->num_win);
-
-    /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */
-
-    return;
-
-} /* apply_ms_synt() */
-
-
diff --git a/media/libstagefright/codecs/aacdec/apply_ms_synt.h b/media/libstagefright/codecs/aacdec/apply_ms_synt.h
deleted file mode 100644
index ed7fb7a..0000000
--- a/media/libstagefright/codecs/aacdec/apply_ms_synt.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/apply_ms_synt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for apply_ms_synt().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef APPLY_MS_SYNT_H
-#define APPLY_MS_SYNT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void apply_ms_synt(
-    const FrameInfo * const pFrameInfo,
-    const Int        group[],
-    const Bool       mask_map[],
-    const Int        codebook_map[],
-    Int32      coefLeft[],
-    Int32      coefRight[],
-    Int        q_formatLeft[MAXBANDS],
-    Int        q_formatRight[MAXBANDS]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/apply_tns.cpp b/media/libstagefright/codecs/aacdec/apply_tns.cpp
deleted file mode 100644
index 96ecd27..0000000
--- a/media/libstagefright/codecs/aacdec/apply_tns.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: apply_tns.c
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    coef =       Array of input coefficients.
-                 [Int32 *, length 1024]
-
-    q_format   = Array of q-formats, one per scalefactor band, for the
-                 entire frame.  In the case of tns_inv_filter, only the
-                 first element is used, since the input to tns_inv_filter
-                 is all of the same q-format.
-                 [Int * const, length MAX_SFB]
-
-    pFrameInfo = Pointer to structure that holds information about each group.
-                 (long block flag, number of windows, scalefactor bands
-                  per group, etc.)
-                 [const FrameInfo * const]
-
-    pTNS_frame_info = pointer to structure containing the details on each
-                      TNS filter (order, filter coefficients,
-                      coefficient res., etc.)
-                      [TNS_frame_info * const]
-
-    inverse_flag   = TRUE  if inverse filter is to be applied.
-                     FALSE if forward filter is to be applied.
-                     [Bool]
-
-    scratch_Int_buffer = Pointer to scratch memory to store the
-                           filter's state memory.  Used by both
-                           tns_inv_filter.
-                           [Int *, length TNS_MAX_ORDER]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coef[]   = TNS altered data.
-    q_format = q-formats in TNS scalefactor bands may be modified.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    This function applies either the TNS forward or TNS inverse filter, based
-    on inverse_flag being FALSE or TRUE, respectively.
-
-    For the TNS forward filter, the data fed into tns_ar_filter is normalized
-    all to the same q-format.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    The input, coef, should use all 32-bits, else the scaling by tns_ar_filter
-    may eliminate the data.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.8 (Temporal Noise Shaping)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    NO PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tns_frame_info.h"
-#include "s_tnsfilt.h"
-#include "s_frameinfo.h"
-#include "tns_inv_filter.h"
-#include "tns_ar_filter.h"
-#include "apply_tns.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void apply_tns(
-    Int32                  coef[],
-    Int                    q_format[],
-    const FrameInfo      * const pFrameInfo,
-    TNS_frame_info * const pTNS_frame_info,
-    const Bool                   inverse_flag,
-    Int32                  scratch_Int_buffer[])
-{
-    Int num_tns_bands;
-    Int num_TNS_coef;
-
-    Int f;
-
-    Int tempInt;
-    Int tempInt2;
-
-    Int sfb_per_win;
-    Int sfbWidth;
-
-    Int coef_per_win;
-    Int min_q;
-    Int win;
-
-    Int32 *pCoef = coef;
-    Int32 *pTempCoef;
-
-    Int   *pStartQformat = q_format;
-
-    Int   *pQformat;
-    Int32 *pLpcCoef;
-
-    Int sfb_offset;
-
-    const Int16 *pWinSfbTop;
-
-    TNSfilt *pFilt;
-
-    coef_per_win = pFrameInfo->coef_per_win[0];
-    sfb_per_win  = pFrameInfo->sfb_per_win[0];
-
-    win = 0;
-
-    pLpcCoef = pTNS_frame_info->lpc_coef;
-
-    pFilt = pTNS_frame_info->filt;
-
-    do
-    {
-        for (f = pTNS_frame_info->n_filt[win]; f > 0; f--)
-        {
-            /* Skip to the next filter if the order is 0 */
-            tempInt = pFilt->order;
-
-            if (tempInt > 0)
-            {
-                /*
-                 * Do not call tns_ar_filter or tns_inv_filter
-                 * if the difference
-                 * between start_coef and stop_stop is <= 0.
-                 *
-                 */
-                num_TNS_coef = (pFilt->stop_coef - pFilt->start_coef);
-
-                if (num_TNS_coef > 0)
-                {
-                    if (inverse_flag != FALSE)
-                    {
-                        tns_inv_filter(
-                            &(pCoef[pFilt->start_coef]),
-                            num_TNS_coef,
-                            pFilt->direction,
-                            pLpcCoef,
-                            pFilt->q_lpc,
-                            pFilt->order,
-                            scratch_Int_buffer);
-                    }
-                    else
-                    {
-                        num_tns_bands = (pFilt->stop_band - pFilt->start_band);
-
-                        /*
-                         * pQformat is initialized only once.
-                         *
-                         * Here is how TNS is applied on scalefactor bands
-                         *
-                         * [0][1][2][3][4][5][6][7][8]
-                         *  |                        \
-                         * start_band               stop_band
-                         *
-                         * In this example, TNS would be applied to 8
-                         * scalefactor bands, 0-7.
-                         *
-                         * pQformat is initially set to &(pStartQformat[8])
-                         *
-                         * 1st LOOP
-                         *      Entry: pQformat = &(pStartQformat[8])
-                         *
-                         *      pQformat is pre-decremented 8 times in the
-                         *      search for min_q
-                         *
-                         *      Exit:  pQformat = &(pStartQformat[0])
-                         *
-                         * 2nd LOOP
-                         *      Entry: pQformat = &(pStartQformat[0])
-                         *
-                         *      pQformat is post-incremented 8 times in the
-                         *      normalization of the data loop.
-                         *
-                         *      Exit:  pQformat = &(pStartQformat[8]
-                         *
-                         *
-                         * shift_amt = tns_ar_filter(...)
-                         *
-                         * 3rd LOOP
-                         *      Entry: pQformat = &(pStartQformat[8])
-                         *
-                         *      pQformat is pre-decremented 8 times in the
-                         *      adjustment of the q-format to min_q - shift_amt
-                         *
-                         *      Exit:  pQformat = &(pStartQformat[0])
-                         *
-                         */
-
-                        pQformat =
-                            &(pStartQformat[pFilt->stop_band]);
-
-                        /*
-                         * Scan the array of q-formats and find the minimum over
-                         * the range where the filter is to be applied.
-                         *
-                         * At the end of this scan,
-                         * pQformat = &(q-format[pFilt->start_band]);
-                         *
-                         */
-
-                        min_q = INT16_MAX;
-
-                        for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
-                        {
-                            tempInt2 = *(--pQformat);
-
-                            if (tempInt2 < min_q)
-                            {
-                                min_q = tempInt2;
-                            }
-                        } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
-
-                        /*
-                         * Set up the pointers so we can index into coef[]
-                         * on a scalefactor band basis.
-                         */
-                        tempInt = pFilt->start_band;
-
-                        tempInt--;
-
-                        /* Initialize sfb_offset and pWinSfbTop */
-                        if (tempInt >= 0)
-                        {
-                            pWinSfbTop =
-                                &(pFrameInfo->win_sfb_top[win][tempInt]);
-
-                            sfb_offset = *(pWinSfbTop++);
-                        }
-                        else
-                        {
-                            pWinSfbTop = pFrameInfo->win_sfb_top[win];
-                            sfb_offset = 0;
-                        }
-
-                        pTempCoef = pCoef + pFilt->start_coef;
-
-                        /* Scale the data in the TNS bands to min_q q-format */
-                        for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
-                        {
-                            sfbWidth  = *(pWinSfbTop++) - sfb_offset;
-
-                            sfb_offset += sfbWidth;
-
-                            tempInt2 = *(pQformat++) - min_q;
-
-                            /*
-                             * This should zero out the data in one scalefactor
-                             * band if it is so much less than the neighboring
-                             * scalefactor bands.
-                             *
-                             * The only way this "should" happen is if one
-                             * scalefactor band contains zero data.
-                             *
-                             * Zero data can be of any q-format, but we always
-                             * set it very high to avoid the zero-data band being
-                             * picked as the one to normalize to in the scan for
-                             * min_q.
-                             *
-                             */
-                            if (tempInt2 > 31)
-                            {
-                                tempInt2 = 31;
-                            }
-
-                            for (sfbWidth >>= 2; sfbWidth > 0; sfbWidth--)
-                            {
-                                *(pTempCoef++) >>= tempInt2;
-                                *(pTempCoef++) >>= tempInt2;
-                                *(pTempCoef++) >>= tempInt2;
-                                *(pTempCoef++) >>= tempInt2;
-                            }
-
-                        } /* for(tempInt = num_bands; tempInt > 0; tempInt--)*/
-
-                        tempInt2 =
-                            tns_ar_filter(
-                                &(pCoef[pFilt->start_coef]),
-                                num_TNS_coef,
-                                pFilt->direction,
-                                pLpcCoef,
-                                pFilt->q_lpc,
-                                pFilt->order);
-
-                        /*
-                         * Update the q-format for all the scalefactor bands
-                         * taking into account the adjustment caused by
-                         * tns_ar_filter
-                         */
-
-                        min_q -= tempInt2;
-
-                        for (tempInt = num_tns_bands; tempInt > 0; tempInt--)
-                        {
-                            *(--pQformat) = min_q;
-                        }
-
-                    } /* if (inverse_flag != FALSE) */
-
-                } /* if (num_TNS_coef > 0) */
-
-                pLpcCoef += pFilt->order;
-
-            } /* if (tempInt > 0) */
-
-            pFilt++;
-
-        } /* for (f = pTNSinfo->n_filt; f > 0; f--) */
-
-        pCoef += coef_per_win;
-        pStartQformat += sfb_per_win;
-
-        win++;
-
-    }
-    while (win < pFrameInfo->num_win);
-
-    return;
-
-} /* apply_tns() */
diff --git a/media/libstagefright/codecs/aacdec/apply_tns.h b/media/libstagefright/codecs/aacdec/apply_tns.h
deleted file mode 100644
index 85fb851..0000000
--- a/media/libstagefright/codecs/aacdec/apply_tns.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/apply_tns.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated per review comments.
-
- Description: Changed function prototype to mirror changes made in apply_tns.c
-
- Description: The scratch memory was mistakenly declared here as type "Int32"
- It should have been "Int"
-
- Who:                       Date:
- Description:
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- apply_tns.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef APPLY_TNS_H
-#define APPLY_TNS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tns_frame_info.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void apply_tns(
-        Int32                  coef[],
-        Int                    q_format[],
-        const FrameInfo      * const pFrameInfo,
-        TNS_frame_info * const pTNS_frame_info,
-        const Bool                   inverse_flag,
-        Int32                  scratch_Int_buffer[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/bit_reversal_swap.h b/media/libstagefright/codecs/aacdec/bit_reversal_swap.h
deleted file mode 100644
index 2669f87..0000000
--- a/media/libstagefright/codecs/aacdec/bit_reversal_swap.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./include/bit_reversal_swap.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Changed definitions from Int to Int32 for Data[]
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function bit_reversal_swap()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BIT_REVERSAL_SWAP_H
-#define BIT_REVERSAL_SWAP_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int Index_64_a[];
-extern const Int Index_64_b[];
-
-extern const Int Index_512_a[];
-extern const Int Index_512_b[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void bit_reversal_swap(
-    Int32        Data[],
-    const Int *pIndex_a,
-    const Int *pIndex_b);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* BIT_REVERSAL_SWAP_H */
diff --git a/media/libstagefright/codecs/aacdec/buf_getbits.cpp b/media/libstagefright/codecs/aacdec/buf_getbits.cpp
deleted file mode 100644
index 34f4f60..0000000
--- a/media/libstagefright/codecs/aacdec/buf_getbits.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: buf_getbits.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:   hBitBuf Handle to Bitbuffer
-              n       Number of bits to read
-
- Return:      bits
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-            Reads n bits from Bitbuffer
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include    "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n)
-{
-
-    /* read bits from MSB side */
-    if (hBitBuf->buffered_bits <= 16)
-    {
-        hBitBuf->buffer_word    = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
-        hBitBuf->buffer_word   |= *(hBitBuf->char_ptr++);
-        hBitBuf->buffered_bits += 16;
-    }
-
-    hBitBuf->buffered_bits -= n;
-    hBitBuf->nrBitsRead    += n;
-
-    return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & ((1 << n) - 1));
-
-}
-
-
-UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf)
-{
-
-    /* read bits from MSB side */
-    if (hBitBuf->buffered_bits <= 16)
-    {
-        hBitBuf->buffer_word    = (hBitBuf->buffer_word << 16) | (*(hBitBuf->char_ptr++) << 8);
-        hBitBuf->buffer_word   |= *(hBitBuf->char_ptr++);
-        hBitBuf->buffered_bits += 16;
-    }
-
-    hBitBuf->buffered_bits--;
-    hBitBuf->nrBitsRead++;
-
-    return ((hBitBuf->buffer_word >> hBitBuf->buffered_bits) & 1);
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/buf_getbits.h b/media/libstagefright/codecs/aacdec/buf_getbits.h
deleted file mode 100644
index 1b5d252..0000000
--- a/media/libstagefright/codecs/aacdec/buf_getbits.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Filename: buf_getbits.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BUF_GETBITS_H
-#define BUF_GETBITS_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bit_buffer.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    UInt32 buf_getbits(BIT_BUFFER * hBitBuf, Int32 n);
-
-    UInt32 buf_get_1bit(BIT_BUFFER * hBitBuf);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/buffer_normalization.h b/media/libstagefright/codecs/aacdec/buffer_normalization.h
deleted file mode 100644
index 031216a..0000000
--- a/media/libstagefright/codecs/aacdec/buffer_normalization.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/buffer_normalization.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Changed definitions from Int to Int32 for IO_buffer[]
-
- Description:  Added copyrigth notice, added 'const' definitions to function
-
- Who:                          Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function buffer_normalization()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef BUFFER_NORMALIZATION_H
-#define BUFFER_NORMALIZATION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define     ALL_ZEROS_BUFFER     -100
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void buffer_normalization(
-    Int     q_format,
-    Int32   IO_buffer[],
-    const Int     buffer_size,
-    Int   * const pExp);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* BUFFER_NORMALIZATION_H */
diff --git a/media/libstagefright/codecs/aacdec/byte_align.cpp b/media/libstagefright/codecs/aacdec/byte_align.cpp
deleted file mode 100644
index e75c79e..0000000
--- a/media/libstagefright/codecs/aacdec/byte_align.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pInputStream = pointer to a BITS structure that holds information
-                   regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    pInputStream->usedBits is rounded up to a number that represents the next
-    byte boundary.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Makes the input stream structure pointed to align to the next byte boundary.
- If it is already at a byte boundary it is left alone.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-  This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-void byte_align(
-    BITS  *pInputStream)
-
-    MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
-                (pInputStream->usedBits + 7) % 8)
-
-    RETURN(nothing)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- STACK USAGE:
-
-     where:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*
- * A negative number was used for this mask so that it works on both
- * 16-bit or 32-bit machines. The mask must be cast to unsigned int to
- * work with TI compiler, ver 1.80.
- */
-#define BYTE_ALIGN_MASK    ((UInt)(-8))
-
-#define BYTE_ALIGN_ROUNDUP  7
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void byte_align(
-    BITS  *pInputStream)
-{
-    /*
-     * Round up to the next byte by adding 7 and masking off with
-     * FFF8 or FFFFFFF8. The masking operation is a faster way to
-     * perform modulo arithmetic if the number is a power of 2.
-     *
-     * This code is the same as
-     * pInputStream->usedBits += (pInputStream->usedBits + 7) % 8
-     */
-    pInputStream->usedBits += BYTE_ALIGN_ROUNDUP;
-    pInputStream->usedBits &= BYTE_ALIGN_MASK;
-
-    return;
-}
-
diff --git a/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp b/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp
deleted file mode 100644
index ee32398..0000000
--- a/media/libstagefright/codecs/aacdec/calc_auto_corr.cpp
+++ /dev/null
@@ -1,416 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_auto_corr.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include    "calc_auto_corr.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#include    "fxp_mul32.h"
-#include    "pv_normalize.h"
-
-#define N   2
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void calc_auto_corr_LC(struct ACORR_COEFS *ac,
-                       Int32  realBuf[][32],
-                       Int32  bd,
-                       Int32  len)
-{
-    Int32 j;
-    Int32 temp1;
-    Int32 temp3;
-    Int32 temp5;
-
-    int64_t temp_r01r;
-    int64_t temp_r02r;
-    int64_t temp_r11r;
-    int64_t temp_r12r;
-    int64_t temp_r22r;
-    int64_t max = 0;
-
-
-    temp1 = (realBuf[ 0][bd]) >> N;
-    temp3 = (realBuf[-1][bd]) >> N;
-    temp5 = (realBuf[-2][bd]) >> N;
-
-
-    temp_r11r = fxp_mac64_Q31(0, temp3, temp3);   /* [j-1]*[j-1]  */
-    temp_r12r = fxp_mac64_Q31(0, temp3, temp5);   /* [j-1]*[j-2]  */
-    temp_r22r = fxp_mac64_Q31(0, temp5, temp5);   /* [j-2]*[j-2]  */
-
-    temp_r01r = 0;
-    temp_r02r = 0;
-
-    for (j = 1; j < len; j++)
-    {
-        temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3);    /* [j  ]*[j-1]  */
-        temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5);    /* [j  ]*[j-2]  */
-        temp_r11r = fxp_mac64_Q31(temp_r11r, temp1, temp1);    /* [j-1]*[j-1]  */
-
-        temp5 = temp3;
-        temp3 = temp1;
-        temp1 = (realBuf[j][bd]) >> N;
-    }
-
-
-    temp_r22r += temp_r11r;
-    temp_r12r += temp_r01r;          /* [j-1]*[j-2]  */
-
-    temp_r22r  = fxp_mac64_Q31(temp_r22r, -temp3, temp3);
-
-    temp_r01r = fxp_mac64_Q31(temp_r01r, temp1, temp3);
-    temp_r02r = fxp_mac64_Q31(temp_r02r, temp1, temp5);
-
-    max  |= temp_r01r ^(temp_r01r >> 63);
-    max  |= temp_r02r ^(temp_r02r >> 63);
-    max  |= temp_r11r;
-    max  |= temp_r12r ^(temp_r12r >> 63);
-    max  |= temp_r22r;
-
-    if (max)
-    {
-        temp1 = (UInt32)(max >> 32);
-        if (temp1)
-        {
-            temp3 = 33 - pv_normalize(temp1);
-            ac->r01r = (Int32)(temp_r01r >> temp3);
-            ac->r02r = (Int32)(temp_r02r >> temp3);
-            ac->r11r = (Int32)(temp_r11r >> temp3);
-            ac->r12r = (Int32)(temp_r12r >> temp3);
-            ac->r22r = (Int32)(temp_r22r >> temp3);
-
-        }
-        else
-        {
-            temp3 = pv_normalize(((UInt32)max) >> 1) - 2;
-
-            if (temp3 > 0)
-            {
-                ac->r01r = (Int32)(temp_r01r << temp3);
-                ac->r02r = (Int32)(temp_r02r << temp3);
-                ac->r11r = (Int32)(temp_r11r << temp3);
-                ac->r12r = (Int32)(temp_r12r << temp3);
-                ac->r22r = (Int32)(temp_r22r << temp3);
-            }
-            else
-            {
-                temp3 = -temp3;
-                ac->r01r = (Int32)(temp_r01r >> temp3);
-                ac->r02r = (Int32)(temp_r02r >> temp3);
-                ac->r11r = (Int32)(temp_r11r >> temp3);
-                ac->r12r = (Int32)(temp_r12r >> temp3);
-                ac->r22r = (Int32)(temp_r22r >> temp3);
-            }
-
-        }
-
-        /*
-         *  ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
-         */
-        /* 1/(1 + 1e-6) == 1 - 1e-6 */
-        /* 2^-20 == 1e-6 */
-        ac->det  = fxp_mul32_Q30(ac->r12r, ac->r12r);
-
-        ac->det -= ac->det >> 20;
-
-        ac->det  = fxp_mul32_Q30(ac->r11r, ac->r22r) - ac->det;
-    }
-    else
-    {
-        pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
-    }
-
-
-}
-
-
-#ifdef HQ_SBR
-
-
-void calc_auto_corr(struct ACORR_COEFS *ac,
-                    Int32  realBuf[][32],
-                    Int32  imagBuf[][32],
-                    Int32  bd,
-                    Int32  len)
-{
-
-
-    Int32 j;
-    Int32 temp1;
-    Int32 temp2;
-    Int32 temp3;
-    Int32 temp4;
-    Int32 temp5;
-    Int32 temp6;
-
-    int64_t accu1 = 0;
-    int64_t accu2 = 0;
-    int64_t accu3 = 0;
-    int64_t accu4 = 0;
-    int64_t accu5 = 0;
-
-
-    int64_t temp_r12r;
-    int64_t temp_r12i;
-    int64_t temp_r22r;
-    int64_t max = 0;
-
-
-    temp1 = realBuf[0  ][bd] >> N;
-    temp2 = imagBuf[0  ][bd] >> N;
-    temp3 = realBuf[0-1][bd] >> N;
-    temp4 = imagBuf[0-1][bd] >> N;
-    temp5 = realBuf[0-2][bd] >> N;
-    temp6 = imagBuf[0-2][bd] >> N;
-
-    temp_r22r =  fxp_mac64_Q31(0, temp5, temp5);
-    temp_r22r =  fxp_mac64_Q31(temp_r22r, temp6, temp6);
-    temp_r12r =  fxp_mac64_Q31(0, temp3, temp5);
-    temp_r12r =  fxp_mac64_Q31(temp_r12r, temp4, temp6);
-    temp_r12i = -fxp_mac64_Q31(0, temp3, temp6);
-    temp_r12i =  fxp_mac64_Q31(temp_r12i, temp4, temp5);
-
-    for (j = 1; j < len; j++)
-    {
-        accu1  = fxp_mac64_Q31(accu1, temp3, temp3);
-        accu1  = fxp_mac64_Q31(accu1, temp4, temp4);
-        accu2  = fxp_mac64_Q31(accu2, temp1, temp3);
-        accu2  = fxp_mac64_Q31(accu2, temp2, temp4);
-        accu3  = fxp_mac64_Q31(accu3, temp2, temp3);
-        accu3  = fxp_mac64_Q31(accu3, -temp1, temp4);
-        accu4  = fxp_mac64_Q31(accu4, temp1, temp5);
-        accu4  = fxp_mac64_Q31(accu4, temp2, temp6);
-        accu5  = fxp_mac64_Q31(accu5, temp2, temp5);
-        accu5  = fxp_mac64_Q31(accu5, -temp1, temp6);
-
-        temp5 = temp3;
-        temp6 = temp4;
-        temp3 = temp1;
-        temp4 = temp2;
-        temp1 = realBuf[j][bd] >> N;
-        temp2 = imagBuf[j][bd] >> N;
-    }
-
-
-    temp_r22r += accu1;
-    temp_r12r += accu2;
-    temp_r12i += accu3;
-
-
-    accu1  = fxp_mac64_Q31(accu1, temp3, temp3);
-    accu1  = fxp_mac64_Q31(accu1, temp4, temp4);
-    accu2  = fxp_mac64_Q31(accu2, temp1, temp3);
-    accu2  = fxp_mac64_Q31(accu2, temp2, temp4);
-    accu3  = fxp_mac64_Q31(accu3, temp2, temp3);
-    accu3  = fxp_mac64_Q31(accu3, -temp1, temp4);
-    accu4  = fxp_mac64_Q31(accu4, temp1, temp5);
-    accu4  = fxp_mac64_Q31(accu4, temp2, temp6);
-    accu5  = fxp_mac64_Q31(accu5, temp2, temp5);
-    accu5  = fxp_mac64_Q31(accu5, -temp1, temp6);
-
-
-    max  |= accu5 ^(accu5 >> 63);
-    max  |= accu4 ^(accu4 >> 63);
-    max  |= accu3 ^(accu3 >> 63);
-    max  |= accu2 ^(accu2 >> 63);
-    max  |= accu1;
-    max  |= temp_r12r ^(temp_r12r >> 63);
-    max  |= temp_r12i ^(temp_r12i >> 63);
-    max  |= temp_r22r;
-
-    if (max)
-    {
-
-        temp1 = (UInt32)(max >> 32);
-        if (temp1)
-        {
-            temp1 = 34 - pv_normalize(temp1);
-            ac->r11r = (Int32)(accu1 >> temp1);
-            ac->r01r = (Int32)(accu2 >> temp1);
-            ac->r01i = (Int32)(accu3 >> temp1);
-            ac->r02r = (Int32)(accu4 >> temp1);
-            ac->r02i = (Int32)(accu5 >> temp1);
-            ac->r12r = (Int32)(temp_r12r >> temp1);
-            ac->r12i = (Int32)(temp_r12i >> temp1);
-            ac->r22r = (Int32)(temp_r22r >> temp1);
-        }
-        else
-        {
-            temp1 = pv_normalize(((UInt32)max) >> 1) - 3;
-
-            if (temp1 > 0)
-            {
-                ac->r11r = (Int32)(accu1 << temp1);
-                ac->r01r = (Int32)(accu2 << temp1);
-                ac->r01i = (Int32)(accu3 << temp1);
-                ac->r02r = (Int32)(accu4 << temp1);
-                ac->r02i = (Int32)(accu5 << temp1);
-                ac->r12r = (Int32)(temp_r12r << temp1);
-                ac->r12i = (Int32)(temp_r12i << temp1);
-                ac->r22r = (Int32)(temp_r22r << temp1);
-            }
-            else
-            {
-                temp1 = -temp1;
-                ac->r11r = (Int32)(accu1 >> temp1);
-                ac->r01r = (Int32)(accu2 >> temp1);
-                ac->r01i = (Int32)(accu3 >> temp1);
-                ac->r02r = (Int32)(accu4 >> temp1);
-                ac->r02i = (Int32)(accu5 >> temp1);
-                ac->r12r = (Int32)(temp_r12r >> temp1);
-                ac->r12i = (Int32)(temp_r12i >> temp1);
-                ac->r22r = (Int32)(temp_r22r >> temp1);
-            }
-
-        }
-
-        /*
-         *  ac->det = ac->r11r*ac->r22r - rel*(ac->r12r*ac->r12r);
-         */
-        /* 1/(1 + 1e-6) == 1 - 1e-6 */
-        /* 2^-20 == 1e-6 */
-
-        ac->det =   fxp_mul32_Q29(ac->r12i, ac->r12i);
-        ac->det =   fxp_mac32_Q29(ac->r12r, ac->r12r, ac->det);
-
-        ac->det -= ac->det >> 20;
-
-        ac->det =  -fxp_msu32_Q29(ac->r11r, ac->r22r, ac->det);
-
-    }
-    else
-    {
-        pv_memset((void *)ac, 0, sizeof(struct ACORR_COEFS));
-    }
-
-}
-
-#endif
-
-
-
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_auto_corr.h b/media/libstagefright/codecs/aacdec/calc_auto_corr.h
deleted file mode 100644
index 0f0dae2..0000000
--- a/media/libstagefright/codecs/aacdec/calc_auto_corr.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_auto_corr.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_AUTO_CORR_H
-#define CALC_AUTO_CORR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-struct ACORR_COEFS
-{
-    Int32  r11r;
-    Int32  r01r;
-    Int32  r02r;
-    Int32  r12r;
-    Int32  r22r;
-#ifdef HQ_SBR
-    Int32  r01i;
-    Int32  r02i;
-    Int32  r12i;
-#endif
-    Int32  det;
-};
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void calc_auto_corr_LC(struct ACORR_COEFS *ac,
-    Int32  realBuf[][32],
-    Int32  bd,
-    Int32  len);
-
-
-#ifdef HQ_SBR
-
-    void calc_auto_corr(struct ACORR_COEFS *ac,
-                        Int32  realBuf[][32],
-                        Int32  imagBuf[][32],
-                        Int32  bd,
-                        Int32  len);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp b/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp
deleted file mode 100644
index 4047502..0000000
--- a/media/libstagefright/codecs/aacdec/calc_gsfb_table.cpp
+++ /dev/null
@@ -1,267 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/calc_gsfb_table.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description: (1) Modified to bring in-line with PV standards
-              (2) Removed if(pFrameInfo->islong), only short windows will
-                  call this routine from getics.c
-
- Description: Modified per review comments
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pFrameInfo  = pointer to structure that holds information for current
-                  frame. Data type FrameInfo
-
-    group[]     = array that contains the grouping information of short
-                  windows (stop index of windows in each group).
-                  Data type Int
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    pFrameInfo -> frame_sfb_top   contains the cumulative bandwidth of
-                                    scalefactor bands in each group
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function is only invoked when short windows are present. It calculates
- the number of groups in one frame, and the scalefactor bandwidth of each
- scalefactor band in each group.
- All windows within one group share the same scalefactors and are interleaved
- on a scalefactor band basis. Within each group, the actual length of one
- scalefactor band equals to the number of windows times the number of
- coefficients in a regular scalefactor band.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall replace the contents of pFrameInfo->frame_sfb_top
- with the cumulative bandwidth of each scalefactor band in each group
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4       p54.    4.5.2.3.2   decoding process
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    offset      = 0;
-    group_idx   = 0;
-
-    DO
-        pFrameInfo->group_len[group_idx] = group[group_idx] - offset;
-        offset = group[group_idx];
-        group_idx++;
-
-    WHILE (offset < NUM_SHORT_WINDOWS);
-
-
-    pFrameInfo->num_groups = group_idx;
-
-    pFrameSfbTop = pFrameInfo->frame_sfb_top;
-    offset = 0;
-
-    FOR (group_idx = 0; group_idx < pFrameInfo->num_groups; group_idx++)
-
-        len = pFrameInfo->group_len[group_idx];
-
-        FOR (sfb = 0; sfb < pFrameInfo->sfb_per_win[group_idx]; sfb++)
-
-            offset += pFrameInfo->sfb_width_128[sfb] * len;
-            *pFrameSfbTop++ = offset;
-
-        ENDFOR
-
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void  calc_gsfb_table(
-    FrameInfo   *pFrameInfo,
-    Int         group[])
-{
-
-    Int      group_idx;
-    Int      offset;
-    Int     *pFrameSfbTop;
-    Int     *pSfbWidth128;
-    Int      sfb;
-    Int      nsfb;
-    Int      len;
-    Int      ngroups;
-
-    /* clear out the default values set by infoinit */
-    /* */
-    pv_memset(pFrameInfo->frame_sfb_top,
-              0,
-              MAXBANDS*sizeof(pFrameInfo->frame_sfb_top[0]));
-    /* */
-    /* first calculate the group length*/
-    offset      = 0;
-    ngroups     = 0;
-    do
-    {
-        pFrameInfo->group_len[ngroups] = group[ngroups] - offset;
-        offset = group[ngroups];
-        ngroups++;
-
-    }
-    while (offset < NUM_SHORT_WINDOWS);
-
-
-    /* calculate the cumulative scalefactor bandwidth for one frame */
-    pFrameInfo->num_groups = ngroups;
-
-    pFrameSfbTop = pFrameInfo->frame_sfb_top;
-    offset = 0;
-
-
-    for (group_idx = 0; group_idx < ngroups; group_idx++)
-    {
-        len  = pFrameInfo->group_len[  group_idx];
-        nsfb = pFrameInfo->sfb_per_win[group_idx];
-
-        pSfbWidth128 = pFrameInfo->sfb_width_128;
-
-        for (sfb = nsfb; sfb > 0; sfb--)
-        {
-            offset += *pSfbWidth128++ * len;
-            *pFrameSfbTop++ = offset;
-        }
-    }
-
-
-} /* calc_gsfb_table */
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp
deleted file mode 100644
index 5ec3f69..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.cpp
+++ /dev/null
@@ -1,360 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_anafilterbank.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "calc_sbr_anafilterbank.h"
-#include    "qmf_filterbank_coeff.h"
-#include    "analysis_sub_band.h"
-
-#include    "aac_mem_funcs.h"
-#include    "fxp_mul32.h"
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_anafilterbank_LC(Int32 * Sr,
-                               Int16 * X,
-                               Int32 scratch_mem[][64],
-                               Int32 maxBand)
-{
-
-    Int i;
-    Int32   *p_Y_1;
-    Int32   *p_Y_2;
-
-    Int16 * pt_X_1;
-    Int16 * pt_X_2;
-    Int32 realAccu1;
-    Int32 realAccu2;
-
-    Int32 tmp1;
-    Int32 tmp2;
-
-
-    const Int32 * pt_C;
-
-    p_Y_1 = scratch_mem[0];
-
-
-    p_Y_2 = p_Y_1 + 63;
-    pt_C   = &sbrDecoderFilterbankCoefficients_an_filt_LC[0];
-
-    pt_X_1 = X;
-
-
-    realAccu1  =  fxp_mul32_by_16(Qfmt27(-0.51075594183097F),   pt_X_1[-192]);
-
-    realAccu1  =  fxp_mac32_by_16(Qfmt27(-0.51075594183097F), -pt_X_1[-128], realAccu1);
-    realAccu1  =  fxp_mac32_by_16(Qfmt27(-0.01876919066980F),  pt_X_1[-256], realAccu1);
-    *(p_Y_1++) =  fxp_mac32_by_16(Qfmt27(-0.01876919066980F), -pt_X_1[ -64], realAccu1);
-
-
-    /* create array Y */
-
-    pt_X_1 = &X[-1];
-    pt_X_2 = &X[-319];
-
-
-    for (i = 15; i != 0; i--)
-    {
-        tmp1 = *(pt_X_1--);
-        tmp2 = *(pt_X_2++);
-
-        realAccu1  = fxp_mul32_by_16(*(pt_C), tmp1);
-        realAccu2  = fxp_mul32_by_16(*(pt_C++), tmp2);
-        tmp1 = pt_X_1[ -63];
-        tmp2 = pt_X_2[ +63];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -127];
-        tmp2 = pt_X_2[ +127];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -191];
-        tmp2 = pt_X_2[ +191];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -255];
-        tmp2 = pt_X_2[ +255];
-        *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
-        tmp1 = *(pt_X_1--);
-        tmp2 = *(pt_X_2++);
-        realAccu1  = fxp_mul32_by_16(*(pt_C), tmp1);
-        realAccu2  = fxp_mul32_by_16(*(pt_C++), tmp2);
-
-        tmp1 = pt_X_1[ -63];
-        tmp2 = pt_X_2[ +63];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -127];
-        tmp2 = pt_X_2[ +127];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -191];
-        tmp2 = pt_X_2[ +191];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -255];
-        tmp2 = pt_X_2[ +255];
-        *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
-    }
-
-
-    tmp1 = *(pt_X_1--);
-    tmp2 = *(pt_X_2++);
-    realAccu1  = fxp_mul32_by_16(*(pt_C), tmp1);
-    realAccu2  = fxp_mul32_by_16(*(pt_C++), tmp2);
-
-    tmp1 = pt_X_1[ -63];
-    tmp2 = pt_X_2[ +63];
-    realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-    realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-    tmp1 = pt_X_1[ -127];
-    tmp2 = pt_X_2[ +127];
-    realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-    realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-    tmp1 = pt_X_1[ -191];
-    tmp2 = pt_X_2[ +191];
-    realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-    realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-    tmp1 = pt_X_1[ -255];
-    tmp2 = pt_X_2[ +255];
-    *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-    *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-
-
-    pt_X_1 = X;
-
-    realAccu2  = fxp_mul32_by_16(Qfmt27(0.00370548843500F), X[ -32]);
-
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.00370548843500F), pt_X_1[-288], realAccu2);
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[ -96], realAccu2);
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.09949460091720F), pt_X_1[-224], realAccu2);
-    *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(1.20736865027288F), pt_X_1[-160], realAccu2);
-
-
-    analysis_sub_band_LC(scratch_mem[0],
-                         Sr,
-                         maxBand,
-                         (Int32(*)[64])scratch_mem[1]);
-
-}
-
-
-
-#ifdef HQ_SBR
-
-void calc_sbr_anafilterbank(Int32 * Sr,
-                            Int32 * Si,
-                            Int16 * X,
-                            Int32 scratch_mem[][64],
-                            Int32   maxBand)
-{
-    Int i;
-    Int32   *p_Y_1;
-    Int32   *p_Y_2;
-
-
-
-
-    const Int32 * pt_C;
-    Int16 * pt_X_1;
-    Int16 * pt_X_2;
-    Int32 realAccu1;
-    Int32 realAccu2;
-
-    Int32 tmp1;
-    Int32 tmp2;
-
-
-    p_Y_1 = scratch_mem[0];
-
-
-    p_Y_2 = p_Y_1 + 63;
-    pt_C   = &sbrDecoderFilterbankCoefficients_an_filt[0];
-
-    realAccu1  =  fxp_mul32_by_16(Qfmt27(-0.36115899F),   X[-192]);
-
-
-    realAccu1  =  fxp_mac32_by_16(Qfmt27(-0.36115899F),  -X[-128], realAccu1);
-    realAccu1  =  fxp_mac32_by_16(Qfmt27(-0.013271822F),  X[-256], realAccu1);
-    *(p_Y_1++) =  fxp_mac32_by_16(Qfmt27(-0.013271822F), -X[ -64], realAccu1);
-
-    /* create array Y */
-
-    pt_X_1 = &X[-1];
-    pt_X_2 = &X[-319];
-
-
-    for (i = 31; i != 0; i--)
-    {
-        tmp1 = *(pt_X_1--);
-        tmp2 = *(pt_X_2++);
-        realAccu1  = fxp_mul32_by_16(*(pt_C), tmp1);
-        realAccu2  = fxp_mul32_by_16(*(pt_C++), tmp2);
-        tmp1 = pt_X_1[ -63];
-        tmp2 = pt_X_2[  63];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -127];
-        tmp2 = pt_X_2[  127];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -191];
-        tmp2 = pt_X_2[  191];
-        realAccu1  = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        realAccu2  = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-        tmp1 = pt_X_1[ -255];
-        tmp2 = pt_X_2[  255];
-        *(p_Y_1++) = fxp_mac32_by_16(*(pt_C), tmp1, realAccu1);
-        *(p_Y_2--) = fxp_mac32_by_16(*(pt_C++), tmp2, realAccu2);
-    }
-
-
-    realAccu2  = fxp_mul32_by_16(Qfmt27(0.002620176F), X[ -32]);
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.002620176F), X[-288], realAccu2);
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.070353307F), X[ -96], realAccu2);
-    realAccu2  = fxp_mac32_by_16(Qfmt27(0.070353307F), X[-224], realAccu2);
-
-
-    *(p_Y_1++) = fxp_mac32_by_16(Qfmt27(0.85373856F), (X[-160]), realAccu2);
-
-
-    analysis_sub_band(scratch_mem[0],
-                      Sr,
-                      Si,
-                      maxBand,
-                      (Int32(*)[64])scratch_mem[1]);
-
-}
-
-
-#endif
-
-
-
-#endif   /*  AAC_PLUS */
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h b/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h
deleted file mode 100644
index c93848e..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_anafilterbank.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_anafilterbank.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_SBR_ANAFILTERBANK_H
-#define CALC_SBR_ANAFILTERBANK_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-#define ROUND_ANAFIL     0
-//#define ROUND_ANAFIL     0
-#define ROUND_ANAFIL_LC  (0)
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-
-    void calc_sbr_anafilterbank_LC(Int32 * Sr,
-    Int16 * X,
-    Int32 scratch_mem[][64],
-    Int32 maxBand);
-
-
-#ifdef HQ_SBR
-
-    void calc_sbr_anafilterbank(Int32 * Sr,
-                                Int32 * Si,
-                                Int16 * X,
-                                Int32 scratch_mem[][64],
-                                Int32 maxBand);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /*  CALC_SBR_ANAFILTERBANK_H */
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp
deleted file mode 100644
index 4fb3535..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.cpp
+++ /dev/null
@@ -1,2203 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: calc_sbr_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "calc_sbr_envelope.h"
-#include    "sbr_envelope_calc_tbl.h"
-#include    "sbr_create_limiter_bands.h"
-#include    "aac_mem_funcs.h"
-
-#include    "fxp_mul32.h"
-#include    "pv_normalize.h"
-
-#include    "sbr_aliasing_reduction.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#include    "pv_sqrt.h"
-
-#include    "pv_div.h"
-#include    "fxp_mul32.h"
-#include    "pv_normalize.h"
-
-#define Q30fmt(x)   (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Q28fmt(x)   (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F))
-#define Q15fmt(x)   (Int32)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void envelope_application_LC(Int32  *aBufR,
-    Int32  *nrg_gain_man,
-    Int32  *nrg_gain_exp,
-    Int32  *noise_level_man,
-    Int32  *noise_level_exp,
-    Int32  *nrg_tone_man,
-    Int32  *nrg_tone_exp,
-    Int32  band_nrg_tone_detector,
-    const Int32 *frame_info,
-    Int32  *harm_index,
-    Int32  *phase_index,
-    Int32  i,
-    Int32  lowSubband,
-    Int32  noSubbands,
-    Int32  noNoiseFlag);
-
-
-    void energy_estimation_LC(Int32 *aBufR,
-                              Int32 *nrg_est_man,
-                              Int32 *nrg_est_exp,
-                              const Int32 *frame_info,
-                              Int32 i,
-                              Int32 k,
-                              Int32 c,
-                              Int32 ui2);
-
-#ifdef HQ_SBR
-
-
-    void envelope_application(Int32  *aBufR,
-                              Int32  *aBufI,
-                              Int32  *nrg_gain_man,
-                              Int32  *nrg_gain_exp,
-                              Int32  *noise_level_man,
-                              Int32  *noise_level_exp,
-                              Int32  *nrg_tone_man,
-                              Int32  *nrg_tone_exp,
-                              Int32 *fBuf_man[64],
-                              Int32 *fBuf_exp[64],
-                              Int32 *fBufN_man[64],
-                              Int32 *fBufN_exp[64],
-                              const Int32 *frame_info,
-                              Int32  *harm_index,
-                              Int32  *phase_index,
-                              Int32  i,
-                              Int32  lowSubband,
-                              Int32  noSubbands,
-                              Int32  noNoiseFlag,
-                              Int32  band_nrg_tone_detector,
-                              Int32  maxSmoothLength,
-                              Int32  smooth_length);
-
-
-    void energy_estimation(Int32 *aBufR,
-                           Int32 *aBufI,
-                           Int32 *nrg_est_man,
-                           Int32 *nrg_est_exp,
-                           const Int32 *frame_info,
-                           Int32 i,
-                           Int32 k,
-                           Int32 c,
-                           Int32 ui2);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_envelope(SBR_FRAME_DATA *frameData,
-                       Int32 *aBufR,
-                       Int32 *aBufI,
-                       Int freqBandTable1[2][MAX_FREQ_COEFFS + 1],
-                       const Int32 *nSfb,
-                       Int32 freqBandTable2[MAX_NOISE_COEFFS + 1],
-                       Int32 nNBands,
-                       Int32 reset,
-                       Int32 *degreeAlias,
-                       Int32 *harm_index,
-                       Int32 *phase_index,
-                       Int32 hFp[64],
-                       Int32 *sUp,
-                       Int32 limSbc[][13],
-                       Int32 *gateMode,
-#ifdef HQ_SBR
-                       Int32 *fBuf_man[64],
-                       Int32 *fBuf_exp[64],
-                       Int32 *fBufN_man[64],
-                       Int32 *fBufN_exp[64],
-#endif
-                       Int32 scratch_mem[][64],
-                       struct PATCH Patch,
-                       Int32  sqrt_cache[][4],
-                       Int32  LC_flag)
-{
-
-    Int32 c;
-    Int32 li;
-    Int32 ui;
-    Int32 i;
-    Int32 j;
-    Int32 k = 0;
-    Int32 l;
-    Int m = 0;
-    Int kk = 0;
-    Int o;
-    Int next = -1;
-    Int32 ui2;
-    Int flag;
-    Int noNoiseFlag;
-    Int *ptr;
-
-
-    UInt32 nrg = 0;
-    Int32 nrg_exp = 0;
-    struct intg_div   quotient;
-    struct intg_sqrt  root_sq;
-
-    Int32 aux1;
-
-    Int32 *nL_man       = frameData->sbrNoiseFloorLevel_man;
-    Int32 *nL_exp       = frameData->sbrNoiseFloorLevel_exp;
-
-    Int32 *sfb_nrg_man  = frameData->iEnvelope_man;
-    Int32 *sfb_nrg_exp  = frameData->iEnvelope_exp;
-
-    Int32 tmp_q1;
-    Int32 tmp_q2;
-
-    Int32 g_max_man;
-    Int32 g_max_exp;
-
-    Int32 p_ref_man;
-    Int32 p_ref_exp;
-
-    Int32 p_est_man;
-    Int32 p_est_exp;
-
-    Int32 p_adj_man;
-    Int32 p_adj_exp;
-    Int32 avg_gain;
-
-    Int32 boost_gain_q;
-
-    Int32 band_nrg_tone_detector;
-
-    Int32 *nrg_est_man     = scratch_mem[0];
-    Int32 *nrg_est_exp     = scratch_mem[1];
-    Int32 *nrg_ref_man     = scratch_mem[2];
-    Int32 *nrg_ref_exp     = scratch_mem[3];
-    Int32 *nrg_gain_man    = scratch_mem[4];
-    Int32 *nrg_gain_exp    = scratch_mem[5];
-    Int32 *noise_level_man = scratch_mem[6];
-    Int32 *noise_level_exp = scratch_mem[7];
-    Int32 *nrg_tone_man    = scratch_mem[8];
-    Int32 *nrg_tone_exp    = scratch_mem[9];
-    Int32 *hF              = scratch_mem[10];
-
-
-
-    const Int32 *frame_info = frameData->frameInfo;
-    Int32 int_mode          = frameData->sbr_header.interpolFreq;
-
-
-
-
-
-    Int32 dontUseTheseGainValues[64];
-
-#ifdef HQ_SBR
-
-    Int32 n;
-    Int32 smooth_length;
-    Int32 smoothingLength   = frameData->sbr_header.smoothingLength;
-    Int32 maxSmoothLength   = smoothLengths[0];
-
-#endif
-
-    Int32 limiterBand       = frameData->sbr_header.limiterBands;
-    Int32 limiterGains      = frameData->sbr_header.limiterGains;
-    Int32 *addHarmonics     = frameData->addHarmonics;
-
-    Int32 lowSubband        = freqBandTable1[LOW_RES][0];
-    Int32 noSubbands        = freqBandTable1[LOW_RES][nSfb[LOW_RES]] - lowSubband;
-    Int32 nEnv              = frame_info[0];
-    Int32 sEnv              = frame_info[(nEnv + 1)<<1];
-
-    /* ensure that noSubbands in the range [0,64] */
-    noSubbands = (noSubbands >> 31) ^ noSubbands;
-    if (noSubbands > 64)
-    {
-        noSubbands = 64;
-    }
-
-    if (reset)
-    {
-        *sUp = 1;
-        *phase_index = 0;
-        sbr_create_limiter_bands(limSbc,
-                                 gateMode,
-                                 freqBandTable1[LOW_RES],
-                                 Patch,
-                                 nSfb[LOW_RES]);
-    }
-
-    /* Mapping. */
-    pv_memset((void*)hF, 0, (sizeof(*hF) << 6));
-
-    ptr  = freqBandTable1[HI];
-    l = *(ptr++);
-
-    for (i = nSfb[HI]; i != 0; i--)
-    {
-        k     = *(ptr++);
-        j     = ((k + l) >> 1) - lowSubband;
-        l   = k;
-        hF[j] = *(addHarmonics++);
-    }
-
-
-    /* Envelope adjustment. */
-
-    for (i = 0; i < nEnv; i++)
-    {
-
-        if (frame_info[1+i] == frame_info[(nEnv<<1)+4+kk])
-        {
-            kk++, next++;
-        }
-
-        noNoiseFlag = (i == sEnv || i == frameData->prevEnvIsShort) ? 1 : 0;
-
-#ifdef HQ_SBR
-        smooth_length = (noNoiseFlag ? 0 : smoothLengths[smoothingLength]);
-#endif
-
-
-        /* Estimate levels. */
-        c = 0;
-        o = 0;
-
-        band_nrg_tone_detector = 0;
-
-        Int kkkk = freqBandTable1[ frame_info[nEnv+2+i] ][0];
-
-        for (j = 0; j <  nSfb[frame_info[nEnv+2+i]]; j++)
-        {
-            li = freqBandTable1[ frame_info[nEnv+2+i] ][j    ];
-            ui = freqBandTable1[ frame_info[nEnv+2+i] ][j + 1];
-            flag = 0;
-
-            for (k = li; k < ui; k++)
-            {                               /* Calculate the average energy over the current envelope, */
-                ui2   = (frame_info[1+i] << 1);
-
-                if (LC_flag == ON)
-                {
-                    energy_estimation_LC((Int32 *)aBufR,
-                                         nrg_est_man,
-                                         nrg_est_exp,
-                                         frame_info,
-                                         i,
-                                         k - kkkk,
-                                         c,
-                                         ui2);
-                }
-#ifdef HQ_SBR
-                else
-                {
-
-                    energy_estimation((Int32 *)aBufR,
-                                      (Int32 *)aBufI,
-                                      nrg_est_man,
-                                      nrg_est_exp,
-                                      frame_info,
-                                      i,
-                                      k - kkkk,
-                                      c,
-                                      ui2);
-                }
-#endif
-
-                flag = (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ? 1 : flag;
-                c++;
-            }
-
-
-            ui2 = freqBandTable2[o+1];
-
-            if (!int_mode)
-            {                                /* If no interpolation is used,   */
-
-                tmp_q1 = -100;
-
-                for (k = c - (ui - li); k < c; k++)
-                {
-                    if (tmp_q1 < nrg_est_exp[k])
-                    {
-                        tmp_q1 = nrg_est_exp[k];
-                    }
-                }
-
-                nrg = 0;
-                for (k = c - (ui - li); k < c; k++)
-                {    /* average the energy in all the QMF bands, */
-                    nrg += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]); /* for the whole scalefactor band.  */
-                }
-                nrg /= (ui - li);
-                nrg_exp = tmp_q1;
-
-            }
-
-            c -= (ui - li);
-
-            for (k = 0; k < ui - li; k++)
-            {
-                o = (k + li >= ui2) ? o + 1 : o;
-                ui2 = freqBandTable2[o+1];
-                /*
-                 *  If no interpolation is used, use the averaged energy from above,
-                 *  otherwise do nothing.
-                 */
-
-
-                if (!int_mode)
-                {
-                    nrg_est_man[c] = nrg;
-                    nrg_est_exp[c] = nrg_exp;
-                }
-
-                if (LC_flag == ON)
-                {
-                    nrg_est_exp[c] += 1;
-
-                    if (flag)
-                    {
-                        dontUseTheseGainValues[k + li - lowSubband] = 1;
-                    }
-                    else
-                    {
-                        dontUseTheseGainValues[k + li - lowSubband] = 0;
-                    }
-                }
-
-                nrg_ref_man[c] = sfb_nrg_man[m];
-                nrg_ref_exp[c] = sfb_nrg_exp[m];
-
-                /*
-                 *  compute nL/(1 + nL);   where nL = nL_man*2^nL_exp
-                 */
-                aux1 = next * nNBands + o;
-
-                tmp_q1 = nL_exp[aux1];
-
-                if (tmp_q1 >= 0)
-                {
-                    pv_div(nL_man[aux1], nL_man[aux1] + (0x3FFFFFFF >> tmp_q1), &quotient);
-                }
-                else
-                {
-                    tmp_q1 = nL_man[aux1] >> (-tmp_q1);
-                    pv_div(tmp_q1, tmp_q1 + 0x3FFFFFFF, &quotient);
-                }
-
-                /*
-                 *  tmp_q1 = nL/(1 + nL)*nrg_ref[c];
-                 */
-
-                tmp_q1 = fxp_mul32_Q30(quotient.quotient >> quotient.shift_factor,  nrg_ref_man[c]);
-
-                if (flag)
-                {
-                    /*
-                     *  Calculate levels and gain, dependent on whether a synthetic, a sine is present or not.
-                     *
-                     *  nrg_gain[c]=(float)pv_sqrt( tmp/(nrg_est[c] + 1), sqrt_cache[1] );
-                     */
-
-
-                    pv_div(tmp_q1, nrg_est_man[c] + 1, &quotient);
-                    /*
-                     *  nrg_est_man[c] is an integer number, while tmp_q1 and quotient.quotient
-                     *  are fractions in Q30
-                     */
-
-                    tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30;
-
-                    pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[1]);
-                    nrg_gain_man[c] = root_sq.root;     /*  in Q28 format */
-                    nrg_gain_exp[c] = root_sq.shift_factor;
-
-
-                    /*
-                     *  nrg_tone[c]=(float)( (hF[c] && (i >= sEnv || hFp[c+lowSubband])) ?
-                     *                          pv_sqrt(nrg_ref[c]/(1+tmp_nL), sqrt_cache[2]) : 0);
-                     */
-                    if (hF[c] && (i >= sEnv || hFp[c+lowSubband]))
-                    {
-                        /*
-                         *  nrg_ref[c] and  nL, as well as quotient.quotient
-                         *  are fractions in Q30
-                         */
-
-                        /*  aux1 == next*nNBands + o */
-
-                        tmp_q2 = nL_exp[aux1];
-                        /*
-                         *  nrg_ref[c]/(1+tmp_nL)
-                         */
-
-                        if (tmp_q2 >= 0)
-                        {
-                            pv_div(nrg_ref_man[c], nL_man[aux1] + (0x3FFFFFFF >> tmp_q2), &quotient);
-                        }
-                        else
-                        {
-                            tmp_q2 = nL_man[aux1] >> (-tmp_q2);
-                            pv_div(nrg_ref_man[c], tmp_q2 + 0x3FFFFFFF, &quotient);
-                            tmp_q2 = 0;     /* exponent has been applied to the sum ((man>>exp) + 1)  */
-                        }
-
-                        tmp_q2 = nrg_ref_exp[c] - tmp_q2 - quotient.shift_factor;
-
-                        pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[2]);
-                        nrg_tone_man[c]    = root_sq.root;
-                        nrg_tone_exp[c]    = root_sq.shift_factor;
-
-                    }
-                    else
-                    {
-                        nrg_tone_man[c]    = 0;
-                        nrg_tone_exp[c]    = 0;
-                    }
-
-                }
-                else
-                {
-                    if (noNoiseFlag)
-                    {
-                        /*
-                         * nrg_gain[c] = (float) pv_sqrt(nrg_ref[c] /(nrg_est[c] + 1), sqrt_cache[3]);
-                         */
-
-                        pv_div(nrg_ref_man[c], nrg_est_man[c] + 1, &quotient);
-
-                        /*
-                         *  nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
-                         *  quotient.quotient are fractions in Q30
-                         */
-
-                        tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30;
-
-                        pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[3]);
-                        nrg_gain_man[c] = root_sq.root;
-                        nrg_gain_exp[c] = root_sq.shift_factor;
-
-                    }
-                    else
-                    {
-                        /*
-                         *  nrg_gain[c] = (float) pv_sqrt(nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL)), sqrt_cache[4]);
-                         */
-                        /*  aux1 == next*nNBands + o */
-
-                        tmp_q2 = nL_exp[aux1];
-                        /*
-                         *  nrg_ref[c]/((nrg_est[c] + 1)*(1+tmp_nL))
-                         */
-
-                        if (nrg_est_man[c] == 0)
-                        {
-                            tmp_q2 = 0;     /*  avoid division by 0 in next if-else, this could be due to
-                                                rounding noise */
-                        }
-
-
-                        if (tmp_q2 >= 0)
-                        {
-
-                            tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, nL_man[aux1] + (0x3FFFFFFF >> tmp_q2));
-                            pv_div(nrg_ref_man[c], tmp_q2, &quotient);
-                            /*
-                             *  nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
-                             *  quotient.quotient are fractions in Q30
-                             */
-                            tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1];
-                            if (nrg_est_man[c])
-                            {
-                                tmp_q2 -=  nrg_est_exp[c];
-                            }
-
-                            tmp_q2 = nrg_ref_exp[c] - nrg_est_exp[c] - quotient.shift_factor - 30 - nL_exp[aux1];
-                        }
-                        else
-                        {
-                            if (tmp_q2 > - 10)
-                            {
-                                tmp_q2 = nL_man[aux1] >> (-tmp_q2);
-
-                                tmp_q2 = fxp_mul32_Q30(nrg_est_man[c] + 1, tmp_q2 + 0x3FFFFFFF);
-                            }
-                            else
-                            {
-                                tmp_q2 = nrg_est_man[c] + 1;
-                            }
-
-
-                            pv_div(nrg_ref_man[c], tmp_q2, &quotient);
-                            /*
-                             *  nrg_est_man[c] is an integer number, while nrg_ref_man[c] and
-                             *  quotient.quotient are fractions in Q30
-                             */
-
-                            tmp_q2 = nrg_ref_exp[c] - quotient.shift_factor - 30;
-                            if (nrg_est_man[c])
-                            {
-                                tmp_q2 -=  nrg_est_exp[c];
-                            }
-
-                        }
-
-                        pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[4]);
-                        nrg_gain_man[c] = root_sq.root;
-                        nrg_gain_exp[c] = root_sq.shift_factor;
-
-                    }
-
-                    nrg_tone_man[c]    = 0;
-                    nrg_tone_exp[c]    = -100;
-
-                }
-
-                band_nrg_tone_detector |= nrg_tone_man[c];   /*  detect any tone activity  */
-
-                pv_sqrt(tmp_q1, nrg_ref_exp[c], &root_sq, sqrt_cache[5]);
-                noise_level_man[c] = root_sq.root;
-                noise_level_exp[c] = root_sq.shift_factor;
-
-                c++;
-
-            }   /* ---- end-for-loop (k) ------ */
-            m++;
-
-        }   /* -------- Estimate levels end-for-loop (j) ----- */
-
-
-
-        /*
-         *      Limiter
-         */
-
-
-        for (c = 0; c < gateMode[limiterBand]; c++)
-        {
-
-            p_ref_man = 0;
-            p_est_man = 0;
-
-            /*
-             *  get max exponent for the reference and estimated energy
-             */
-            p_ref_exp = -100;
-            p_est_exp = -100;
-
-            for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-            {
-                if (p_ref_exp < nrg_ref_exp[k])
-                {
-                    p_ref_exp = nrg_ref_exp[k];    /* max */
-                }
-                if (p_est_exp < nrg_est_exp[k])
-                {
-                    p_est_exp = nrg_est_exp[k];    /* max */
-                }
-            }
-
-            k -= limSbc[limiterBand][c];     /*  number of element used in the addition */
-
-            while (k != 0)      /*  bit guard protection depends on log2(k)  */
-            {
-                k >>= 1;
-                p_ref_exp++;       /*  add extra bit-overflow-guard, nrg_ref_exp is in Q30 format */
-            }
-
-
-            for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-            {   /*Calculate the average gain for the current limiter band.*/
-                p_ref_man += (nrg_ref_man[k] >> (p_ref_exp - nrg_ref_exp[k]));
-                p_est_man += (nrg_est_man[k] >> (p_est_exp - nrg_est_exp[k]));
-
-            }
-
-            if (p_est_man)
-            {
-                /*
-                 *  "average gain" (not equal to average of nrg_gain)
-                 */
-                pv_div(p_ref_man, p_est_man, &quotient);
-
-                tmp_q2 = p_ref_exp - 30 - p_est_exp - quotient.shift_factor;
-
-                /*
-                 *  avg_gain = sqrt(p_ref/p_est)
-                 */
-                pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[6]);
-                avg_gain  = root_sq.root;
-                g_max_exp = root_sq.shift_factor;
-
-                /*
-                 *  maximum gain allowed is calculated from table.
-                 */
-
-                /*
-                 *  g_max = avg_gain * limGains[limiterGains];
-                 */
-
-                g_max_man = fxp_mul32_Q30(avg_gain, limGains[limiterGains]);   /*  table is in Q30 */
-
-                if (limiterGains == 3)
-                {
-                    g_max_exp = limGains[4];
-                }
-
-                tmp_q1 = g_max_exp >= 16 ? g_max_exp : 16;
-
-                tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp);
-                tmp_q1 = Q28fmt(1.52587890625F) >> (tmp_q1 - 16);
-
-                if (tmp_q2 > tmp_q1)
-                {
-                    /* upper limit, +100 dB */
-                    g_max_man = Q28fmt(1.52587890625F);
-                    g_max_exp = 16;
-                }
-            }
-            else
-            {
-                /*  Qfmt(1.52587890625F)    exp = 16 */
-                g_max_man = Q28fmt(1.52587890625F);
-                g_max_exp = 16;
-            }
-
-            /*
-             *  Compute Adjusted power p_adj
-             */
-            for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-            {
-
-                tmp_q1 = g_max_exp >= nrg_gain_exp[k] ? g_max_exp : nrg_gain_exp[k];
-
-                tmp_q2 = g_max_man >> (tmp_q1 - g_max_exp);
-                tmp_q1 = nrg_gain_man[k] >> (tmp_q1 - nrg_gain_exp[k]);
-                /*
-                 *  if(g_max <= nrg_gain[k])
-                 */
-                if (tmp_q2 <= tmp_q1)
-                {
-                    tmp_q1 = fxp_mul32_Q28(noise_level_man[k], g_max_man);
-                    pv_div(tmp_q1, nrg_gain_man[k], &quotient);
-                    noise_level_man[k] = quotient.quotient >> 2;   /* in Q28 */
-                    noise_level_exp[k] = noise_level_exp[k] + g_max_exp - quotient.shift_factor - nrg_gain_exp[k];
-
-                    nrg_gain_man[k] =  g_max_man;       /* gains with noise supression */
-                    nrg_gain_exp[k] =  g_max_exp;
-                }
-            }
-
-            p_adj_exp = -100;
-
-            for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-            {
-                tmp_q1 = nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28;  /* 28 to match shift down by mult32_Q28  */
-
-                if (p_adj_exp < tmp_q1)
-                {
-                    p_adj_exp = tmp_q1;
-                }
-                if (nrg_tone_man[k])
-                {
-                    tmp_q1 = (nrg_tone_exp[k] << 1);
-                    if (p_adj_exp < tmp_q1)
-                    {
-                        p_adj_exp = tmp_q1;
-                    }
-                }
-                else if (!noNoiseFlag)
-                {
-                    tmp_q1 = (noise_level_exp[k] << 1);
-
-                    if (p_adj_exp < tmp_q1)
-                    {
-                        p_adj_exp = tmp_q1;
-                    }
-                }
-            }
-
-            p_adj_exp += 1; /* overflow bit-guard*/
-
-            p_adj_man = 0;
-
-            for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-            {
-                /*
-                 *  p_adj += nrg_gain[k]*nrg_gain[k]*nrg_est[k];
-                 */
-
-                if (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 59)
-                {
-                    tmp_q1 = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]);
-                    tmp_q1 = fxp_mul32_Q28(tmp_q1, nrg_est_man[k]);
-                    p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1) + 28)));
-                }
-
-                if (nrg_tone_man[k])
-                {
-                    /*
-                     *  p_adj += nrg_tone[k]*nrg_tone[k];
-                     */
-                    if (p_adj_exp - (nrg_tone_exp[k] << 1) < 31)
-                    {
-                        tmp_q1 = fxp_mul32_Q28(nrg_tone_man[k], nrg_tone_man[k]);
-                        p_adj_man += (tmp_q1 >> (p_adj_exp - (nrg_tone_exp[k] << 1)));
-                    }
-                }
-                else if (!noNoiseFlag)
-                {
-                    /*
-                     *  p_adj += noise_level[k]*noise_level[k];
-                     */
-
-                    if (p_adj_exp - (noise_level_exp[k] << 1) < 31)
-                    {
-                        tmp_q1 = fxp_mul32_Q28(noise_level_man[k], noise_level_man[k]);
-                        p_adj_man += (tmp_q1 >> (p_adj_exp - (noise_level_exp[k] << 1)));
-                    }
-
-                }
-            }
-
-
-            if (p_adj_man)
-            {
-                pv_div(p_ref_man, p_adj_man, &quotient);
-                tmp_q2 = p_ref_exp - p_adj_exp - 58 - quotient.shift_factor;   /*  58 <> Q30 + Q28 */
-
-                pv_sqrt(quotient.quotient, tmp_q2, &root_sq, sqrt_cache[7]);
-
-                if (root_sq.shift_factor > -28)
-                {
-                    boost_gain_q = root_sq.root << (root_sq.shift_factor + 28);
-                }
-                else
-                {
-                    boost_gain_q = root_sq.root >> (-28 - root_sq.shift_factor);
-                }
-
-                tmp_q1 = root_sq.shift_factor >= -28 ? root_sq.shift_factor : -28;
-
-                tmp_q2 = root_sq.root >> (tmp_q1 - root_sq.shift_factor);
-                tmp_q1 = Q28fmt(1.584893192f) >> (tmp_q1 + 28);
-
-
-                if (tmp_q2 > tmp_q1)
-                {
-                    boost_gain_q = Q28fmt(1.584893192f);
-                }
-            }
-            else
-            {
-                boost_gain_q = Q28fmt(1.584893192f);
-            }
-
-            if (band_nrg_tone_detector)
-            {
-                for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-                {
-                    nrg_gain_man[k]    = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q);
-                    noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q);
-                    nrg_tone_man[k]    = fxp_mul32_Q28(nrg_tone_man[k], boost_gain_q);
-                }
-            }
-            else
-            {
-
-                for (k = limSbc[limiterBand][c]; k < limSbc[limiterBand][c + 1]; k++)
-                {
-                    nrg_gain_man[k]    = fxp_mul32_Q28(nrg_gain_man[k], boost_gain_q);
-                    noise_level_man[k] = fxp_mul32_Q28(noise_level_man[k], boost_gain_q);
-                }
-
-
-            }
-
-        }   /* Limiter  End for loop (c) */
-
-
-        if (LC_flag == ON)
-        {
-
-            /*
-             *          Aliasing correction
-             */
-
-            sbr_aliasing_reduction(degreeAlias,
-                                   nrg_gain_man,
-                                   nrg_gain_exp,
-                                   nrg_est_man,
-                                   nrg_est_exp,
-                                   dontUseTheseGainValues,
-                                   noSubbands,
-                                   lowSubband,
-                                   sqrt_cache,
-                                   scratch_mem[3]);
-
-            if (*sUp)     /* Init only done once upon reset */
-            {
-                *sUp = 0;
-            }
-
-            envelope_application_LC((Int32 *)aBufR,
-                                    nrg_gain_man,
-                                    nrg_gain_exp,
-                                    noise_level_man,
-                                    noise_level_exp,
-                                    nrg_tone_man,
-                                    nrg_tone_exp,
-                                    band_nrg_tone_detector,
-                                    frame_info,
-                                    harm_index,
-                                    phase_index,
-                                    i,
-                                    lowSubband,
-                                    noSubbands,
-                                    noNoiseFlag);
-        }
-#ifdef HQ_SBR
-        else
-        {
-
-            if (*sUp)     /* Init only done once upon reset */
-            {
-                for (n = 0; n < maxSmoothLength; n++)
-                {
-                    pv_memcpy(fBuf_man[n],     nrg_gain_man, noSubbands*sizeof(*fBuf_man[n]));
-                    pv_memcpy(fBufN_man[n], noise_level_man, noSubbands*sizeof(*fBufN_man[n]));
-                    pv_memcpy(fBuf_exp[n],     nrg_gain_exp, noSubbands*sizeof(*fBuf_exp[n]));
-                    pv_memcpy(fBufN_exp[n], noise_level_exp, noSubbands*sizeof(*fBufN_exp[n]));
-                }
-                *sUp = 0;
-            }
-
-
-            envelope_application((Int32 *)aBufR,
-                                 (Int32 *)aBufI,
-                                 nrg_gain_man,
-                                 nrg_gain_exp,
-                                 noise_level_man,
-                                 noise_level_exp,
-                                 nrg_tone_man,
-                                 nrg_tone_exp,
-                                 fBuf_man,
-                                 fBuf_exp,
-                                 fBufN_man,
-                                 fBufN_exp,
-                                 frame_info,
-                                 harm_index,
-                                 phase_index,
-                                 i,
-                                 lowSubband,
-                                 noSubbands,
-                                 noNoiseFlag,
-                                 band_nrg_tone_detector,
-                                 maxSmoothLength,
-                                 smooth_length);
-
-        }
-#endif
-
-    }   /* -----  Envelope adjustment end for-loop (i) ---- */
-
-
-    pv_memcpy(&hFp[0] + lowSubband,
-              hF,
-              (64 - lowSubband)*sizeof(*hF));
-
-    if (sEnv == nEnv)
-    {
-        frameData->prevEnvIsShort = 0;
-    }
-    else
-    {
-        frameData->prevEnvIsShort = -1;
-    }
-
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void envelope_application_LC(Int32  *aBufR,
-                             Int32  *nrg_gain_man,
-                             Int32  *nrg_gain_exp,
-                             Int32  *noise_level_man,
-                             Int32  *noise_level_exp,
-                             Int32  *nrg_tone_man,
-                             Int32  *nrg_tone_exp,
-                             Int32  band_nrg_tone_detector,
-                             const Int32 *frame_info,
-                             Int32  *harm_index,
-                             Int32  *phase_index,
-                             Int32  i,
-                             Int32  lowSubband,
-                             Int32  noSubbands,
-                             Int32  noNoiseFlag)
-{
-
-    Int32 *ptrReal;
-    Int32 sb_gain_man;
-    Int32 sb_noise_man;
-    Int32 sb_noise_exp;
-    Int32 l;
-    Int32 k;
-    Int32 tmp_q1;
-    Int32 tmp_q2;
-    Int32 tone_count;
-    Int16 tmp_16;
-    Int32 indexMinus1;
-    Int32 indexPlus1;
-
-
-    /*
-     *          Application
-     */
-
-    if (band_nrg_tone_detector)     /* Add tone energy only if energy is detected  */
-    {
-
-        /*
-         *  pre-calculate tone application
-         */
-        for (k = 0; k < noSubbands; k++)
-        {
-            tmp_q2 = (-nrg_tone_exp[k]);
-            tmp_q1 = nrg_tone_man[k];
-            tmp_q2 = tmp_q1 >> tmp_q2;
-            tmp_q1 = fxp_mul32_by_16(tmp_q2, Q15fmt(0.0163f));
-            nrg_tone_man[k] = tmp_q2;
-            nrg_tone_exp[k] = tmp_q1;
-            noise_level_exp[k] += 1;
-            nrg_gain_exp[k] += 28;
-        }
-
-        for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
-        {
-            ptrReal = (aBufR + l * SBR_NUM_BANDS);
-
-            tone_count = 0;
-
-            indexPlus1  = (*harm_index + 1) & 3;
-
-            if (indexPlus1 & 1)    /*  if indexPlus1 is odd */
-            {
-                for (k = 0; k < noSubbands; k++)
-                {
-
-                    sb_gain_man = nrg_gain_man[k];
-                    tmp_q1 = *ptrReal;
-                    tmp_q2 = nrg_gain_exp[k];
-                    tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
-                    if (tmp_q2 < 0)
-                    {
-                        if (tmp_q2 > -32)
-                        {
-                            *ptrReal = tmp_q1 >> (-tmp_q2);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal = tmp_q1 << tmp_q2;
-                    }
-
-                    *phase_index = (*phase_index + 1) & 511;
-
-                    if (!nrg_tone_man[k] && !noNoiseFlag)
-
-                    {
-                        tmp_16 = rP_LCx[*phase_index];
-                        sb_noise_man = noise_level_man[k];
-                        sb_noise_exp = noise_level_exp[k];
-
-                        tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
-                        if (sb_noise_exp < 0)
-                        {
-                            if (sb_noise_exp > -32)
-                            {
-                                *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                            }
-                        }
-                        else
-                        {
-                            *ptrReal += tmp_q1 << sb_noise_exp;
-                        }
-                    }
-
-                    tmp_q1 = nrg_tone_man[k];
-
-                    if (*harm_index)
-                    {
-                        *ptrReal -= tmp_q1;
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1;
-                    }
-
-                    if (tmp_q1)
-                    {
-                        tone_count++;
-                    }
-
-                    ptrReal++;
-
-                }   /*  for-loop (k) */
-
-            }
-            else        /*  if indexPlus1 is even */
-            {
-                indexMinus1 = (*harm_index - 1) & 3;
-
-                /*  ---  k = 0  ----- */
-
-                sb_gain_man = nrg_gain_man[0];
-                tmp_q1 = *ptrReal;
-                tmp_q2 = nrg_gain_exp[0];
-                tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
-                if (tmp_q2 < 0)
-                {
-                    if (tmp_q2 > -32)
-                    {
-                        *ptrReal = tmp_q1 >> (-tmp_q2);
-                    }
-                }
-                else
-                {
-                    *ptrReal = tmp_q1 << tmp_q2;
-                }
-
-                *phase_index = (*phase_index + 1) & 511;
-
-                tmp_q1 = nrg_tone_exp[0];
-                tmp_q2 = nrg_tone_exp[1];
-
-                if ((indexPlus1 != 0) ^((lowSubband & 1) != 0))
-                {
-                    *(ptrReal - 1) -= tmp_q1;
-                    *(ptrReal)   += tmp_q2;
-                }
-                else
-                {
-                    *(ptrReal - 1) += tmp_q1;
-                    *(ptrReal)   -= tmp_q2;
-                }
-
-                if (!nrg_tone_man[0] && !noNoiseFlag)
-                {
-                    tmp_16 = rP_LCx[*phase_index];
-                    sb_noise_man = noise_level_man[0];
-                    sb_noise_exp = noise_level_exp[0];
-
-                    tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
-                    if (sb_noise_exp < 0)
-                    {
-                        if (sb_noise_exp > -32)
-                        {
-                            *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1 << sb_noise_exp;
-                    }
-                }
-                else
-                {
-                    tone_count++;
-                }
-
-                ptrReal++;
-
-                /* ----  */
-
-                for (k = 1; k < noSubbands - 1; k++)
-                {
-
-                    sb_gain_man = nrg_gain_man[k];
-                    tmp_q1 = *ptrReal;
-                    tmp_q2 = nrg_gain_exp[k];
-                    tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
-                    if (tmp_q2 < 0)
-                    {
-                        if (tmp_q2 > -32)
-                        {
-                            *ptrReal = tmp_q1 >> (-tmp_q2);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal = tmp_q1 << tmp_q2;
-                    }
-
-                    *phase_index = (*phase_index + 1) & 511;
-
-
-                    if (tone_count < 16)
-                    {
-                        tmp_q1 = nrg_tone_exp[k - 1];
-                        tmp_q2 = nrg_tone_exp[k + 1];
-
-                        tmp_q1 -= tmp_q2;
-
-
-                        if ((indexPlus1 != 0) ^(((k + lowSubband) & 1) != 0))
-                        {
-                            *(ptrReal) -= tmp_q1;
-                        }
-                        else
-                        {
-                            *(ptrReal) += tmp_q1;
-                        }
-                    }   /*   if (tone_count < 16)  */
-
-
-                    if (!nrg_tone_man[k] && !noNoiseFlag)
-                    {
-                        tmp_16 = rP_LCx[*phase_index];
-                        sb_noise_man = noise_level_man[k];
-                        sb_noise_exp = noise_level_exp[k];
-
-                        tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
-                        if (sb_noise_exp < 0)
-                        {
-                            if (sb_noise_exp > -32)
-                            {
-                                *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                            }
-                        }
-                        else
-                        {
-                            *ptrReal += tmp_q1 << sb_noise_exp;
-                        }
-                    }
-                    else
-                    {
-                        tone_count++;
-                    }
-
-                    ptrReal++;
-
-                }   /*  for-loop (k) */
-
-                sb_gain_man = nrg_gain_man[k];
-                tmp_q1 = *ptrReal;
-                tmp_q2 = nrg_gain_exp[k];
-                tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
-                if (tmp_q2 < 0)
-                {
-                    if (tmp_q2 > -31)
-                    {
-                        *ptrReal = tmp_q1 >> (-tmp_q2);
-                    }
-                }
-                else
-                {
-                    *ptrReal = tmp_q1 << tmp_q2;
-                }
-
-                *phase_index = (*phase_index + 1) & 511;
-
-
-                if ((tone_count < 16) && !(indexMinus1 &1))
-                {
-                    tmp_q1 = nrg_tone_exp[k - 1];
-                    tmp_q2 = nrg_tone_exp[k    ];
-
-                    if ((indexMinus1 != 0) ^(((k + lowSubband) & 1) != 0))
-                    {
-                        *(ptrReal)   += tmp_q1;
-
-                        if (k + lowSubband < 62)
-                        {
-                            *(ptrReal + 1) -= tmp_q2;
-                        }
-                    }
-                    else
-                    {
-                        *(ptrReal)   -= tmp_q1;
-
-                        if (k + lowSubband < 62)
-                        {
-                            *(ptrReal + 1) += tmp_q2;
-                        }
-                    }
-                }   /*   if (tone_count < 16)  */
-
-
-                if (!nrg_tone_man[k] && !noNoiseFlag)
-                {
-                    tmp_16 = rP_LCx[*phase_index];
-                    sb_noise_man = noise_level_man[k];
-                    sb_noise_exp = noise_level_exp[k];
-
-                    tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
-                    if (sb_noise_exp < 0)
-                    {
-                        if (sb_noise_exp > -31)
-                        {
-                            *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1 << sb_noise_exp;
-                    }
-                }
-
-            }   /*  if indexPlus1 is odd */
-
-            *harm_index = indexPlus1;
-
-
-        }        /*  for-loop (l) */
-
-    }
-    else        /*   if ( band_nrg_tone_detector)   */
-    {
-
-        for (k = 0; k < noSubbands; k++)
-        {
-            tmp_q1 = noise_level_exp[k];
-            tmp_q2 = nrg_gain_exp[k];
-            noise_level_exp[k] =  tmp_q1 + 1;
-            nrg_gain_exp[k] = tmp_q2 + 28;
-        }
-
-        for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
-        {
-            ptrReal = (aBufR + l * SBR_NUM_BANDS);
-
-            for (k = 0; k < noSubbands; k++)
-            {
-
-                tmp_q1 = *ptrReal;
-                sb_gain_man = nrg_gain_man[k];
-
-                tmp_q2 = nrg_gain_exp[k];
-
-                tmp_q1 = fxp_mul32_Q28(tmp_q1, sb_gain_man);
-
-                if (tmp_q2 < 0)
-                {
-                    if (tmp_q2 > -31)
-                    {
-                        *ptrReal = tmp_q1 >> (-tmp_q2);
-                    }
-                }
-                else
-                {
-                    *ptrReal = tmp_q1 << tmp_q2;
-                }
-
-                *phase_index = (*phase_index + 1) & 511;
-
-                if (! noNoiseFlag)
-                {
-                    tmp_16 = rP_LCx[*phase_index];
-                    sb_noise_man = noise_level_man[k];
-                    sb_noise_exp = noise_level_exp[k];
-
-                    tmp_q1 = fxp_mul32_by_16(sb_noise_man, tmp_16);
-
-                    if (sb_noise_exp < 0)
-                    {
-                        if (sb_noise_exp > -31)
-                        {
-                            *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1 << sb_noise_exp;
-                    }
-                }
-
-                ptrReal++;
-
-            }   /*  for-loop (k) */
-
-            *harm_index  = (*harm_index + 1) & 3;
-
-
-        }   /*  for-loop (l) */
-
-    }
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-#define Qfmt15(a)   (Int32)(a*((Int32)1<<15) + (a>=0?0.5F:-0.5F))
-
-
-const Int16 pow2[39] = { 0, 0, 1, 0, 2,
-                         0, Qfmt15(2 / 6.0f), 0, 3, 0, Qfmt15(2 / 10.0f), 0, Qfmt15(2 / 12.0f), 0, Qfmt15(2 / 14.0f), 0, 4,
-                         0, Qfmt15(2 / 18.0f),    0, Qfmt15(2 / 20.0f), 0, Qfmt15(2 / 22.0f), 0, Qfmt15(2 / 24.0f),
-                         0, Qfmt15(2 / 26.0f), 0, Qfmt15(2 / 28.0f), 0, Qfmt15(2 / 30.0f), 0, 5, 0, Qfmt15(2 / 34.0f),
-                         0, Qfmt15(2 / 36.0f), 0, Qfmt15(2 / 38.0f)
-                       };
-
-void energy_estimation_LC(Int32 *aBufR,
-                          Int32 *nrg_est_man,
-                          Int32 *nrg_est_exp,
-                          const Int32 *frame_info,
-                          Int32 i,
-                          Int32 k,
-                          Int32 c,
-                          Int32 ui2)
-{
-
-
-    Int32  aux1;
-    Int32  aux2;
-    Int32  l;
-
-
-    int64_t nrg_h = 0;
-    Int32 tmp1;
-    UInt32 tmp2;
-
-    for (l = ui2; l < (frame_info[2+i] << 1); l++)
-    {
-
-        aux1 = aBufR[l++*SBR_NUM_BANDS + k ];
-        aux2 = aBufR[l  *SBR_NUM_BANDS + k ];
-
-        nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
-        nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
-    }
-
-    /*
-     *  Check for overflow and saturate if needed
-     */
-    if (nrg_h < 0)
-    {
-        nrg_h = 0x7fffffff;
-    }
-
-
-    if (nrg_h)
-    {
-        tmp2 = (UInt32)(nrg_h >> 32);
-        if (tmp2)
-        {
-            aux2 = pv_normalize(tmp2);
-            aux2 -= 1;                  /*  ensure Q30 */
-            nrg_h = (nrg_h << aux2) >> 33;
-            tmp2 = (UInt32)(nrg_h);
-            nrg_est_exp[c] = 33 - aux2;
-        }
-        else
-        {
-            tmp2 = (UInt32)(nrg_h >> 2);
-            aux2 = pv_normalize(tmp2);
-            aux2 -= 1;                  /*  ensure Q30 */
-
-            tmp2 = (tmp2 << aux2);
-            nrg_est_exp[c] =  -aux2 + 2;
-        }
-
-        tmp1 = (l - ui2);
-
-        aux2 = pow2[tmp1];
-        if (tmp1 == (tmp1 & (-tmp1)))
-        {
-            nrg_est_man[c] = tmp2 >> aux2;
-        }
-        else
-        {
-            nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2);
-        }
-
-    }
-    else
-    {
-        nrg_est_man[c] = 0;
-        nrg_est_exp[c] = -100;
-    }
-
-
-
-
-
-}
-
-
-
-
-
-
-#if HQ_SBR
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void envelope_application(Int32  *aBufR,
-                          Int32  *aBufI,
-                          Int32  *nrg_gain_man,
-                          Int32  *nrg_gain_exp,
-                          Int32  *noise_level_man,
-                          Int32  *noise_level_exp,
-                          Int32  *nrg_tone_man,
-                          Int32  *nrg_tone_exp,
-                          Int32  *fBuf_man[64],
-                          Int32  *fBuf_exp[64],
-                          Int32  *fBufN_man[64],
-                          Int32  *fBufN_exp[64],
-                          const  Int32 *frame_info,
-                          Int32  *harm_index,
-                          Int32  *phase_index,
-                          Int32  i,
-                          Int32  lowSubband,
-                          Int32  noSubbands,
-                          Int32  noNoiseFlag,
-                          Int32  band_nrg_tone_detector,
-                          Int32  maxSmoothLength,
-                          Int32  smooth_length)
-{
-
-    Int32 *ptrReal;
-    Int32 *ptrImag;
-    Int32 sb_gain_man;
-    Int32 sb_gain_exp;
-    Int32 sb_noise_man;
-    Int32 sb_noise_exp;
-    Int32 l;
-    Int32 k;
-    Int32 n;
-    Int32 tmp_q1;
-    Int32 tmp_q2;
-    Int32  aux1;
-    Int32  aux2;
-    Int32  filter_history = 0;
-
-
-    if (band_nrg_tone_detector)     /* Add tone energy only if energy is detected  */
-    {
-
-        /*
-         *  pre-calculate tone application
-         */
-
-        ptrReal = nrg_tone_exp;
-        ptrImag = nrg_tone_man;
-        tmp_q1 = - *(ptrReal++);
-        aux1   =   *(ptrImag);
-        for (k = 0; k < noSubbands; k++)
-        {
-            *(ptrImag++) = aux1 >> tmp_q1;
-            tmp_q1 = - *(ptrReal++);
-            aux1   =   *(ptrImag);
-        }
-
-        /*
-         *          Application
-         */
-
-        for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
-        {
-            ptrReal = (aBufR + l * SBR_NUM_BANDS);
-            ptrImag = (aBufI + l * SBR_NUM_BANDS);
-
-            if (filter_history <= maxSmoothLength)     /* no more update is needed as buffer will have same info */
-            {
-                pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man));
-                pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp));
-                pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man));
-                pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp));
-            }
-
-            /*
-             *  nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation
-             */
-            for (k = 0; k < noSubbands; k++)
-            {
-                if (smooth_length == 0)     /* no filter-smooth needed */
-                {
-                    sb_gain_man = nrg_gain_man[k];
-                    sb_gain_exp = nrg_gain_exp[k];
-
-                    sb_noise_man = noise_level_man[k];
-                    sb_noise_exp = noise_level_exp[k];
-
-                }
-                else
-                {   /* else  smooth_length == 4  and fir_4 filter is being used */
-
-                    sb_gain_exp = fBuf_exp[maxSmoothLength][k];
-
-                    sb_noise_exp = fBufN_exp[maxSmoothLength][k];
-
-                    for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++)
-                    {
-                        if (sb_gain_exp  < fBuf_exp[n][k])
-                        {
-                            sb_gain_exp = fBuf_exp[n][k];
-                        }
-
-                        if (sb_noise_exp  < fBufN_exp[n][k])
-                        {
-                            sb_noise_exp = fBufN_exp[n][k];
-                        }
-                    }
-
-                    sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
-                    sb_gain_man  = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]);
-
-                    sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
-                    sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]);
-
-                    n = maxSmoothLength - smooth_length;
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]);
-
-                }
-
-
-
-                /*
-                 *    *ptrReal  = *ptrReal * sb_gain ;
-                 *    *ptrImag  = *ptrImag * sb_gain;
-                 */
-                aux1 = *ptrReal;
-                aux2 = *ptrImag;
-                sb_gain_exp += 32;
-                aux1 = fxp_mul32_Q31(aux1, sb_gain_man);
-                aux2 = fxp_mul32_Q31(aux2, sb_gain_man);
-
-
-                if (sb_gain_exp < 0)
-                {
-                    sb_gain_exp = -sb_gain_exp;
-                    if (sb_gain_exp < 32)
-                    {
-                        *ptrReal = (aux1 >> sb_gain_exp);
-                        *ptrImag = (aux2 >> sb_gain_exp);
-                    }
-                }
-                else
-                {
-                    *ptrReal = (aux1 << sb_gain_exp);
-                    *ptrImag = (aux2 << sb_gain_exp);
-                }
-
-
-
-                /*
-                 *     if ( sb_noise != 0)
-                 *     {
-                 *         *ptrReal += sb_noise * rP[*phase_index][0];
-                 *         *ptrImag += sb_noise * rP[*phase_index][1];
-                 *     }
-                 */
-                *phase_index = (*phase_index + 1) & 511;
-
-                if (nrg_tone_man[k] || noNoiseFlag)
-                {
-                    sb_noise_man = 0;
-                    sb_noise_exp = 0;
-                }
-                else
-                {
-
-                    Int32 tmp = rPxx[*phase_index];
-                    sb_noise_exp += 1;
-                    tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp);
-                    tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp);
-
-
-                    if (sb_noise_exp < 0)
-                    {
-                        if (sb_noise_exp > -32)
-                        {
-                            *ptrReal += tmp_q1 >> (-sb_noise_exp);
-                            *ptrImag += tmp_q2 >> (-sb_noise_exp);
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1 << sb_noise_exp;
-                        *ptrImag += tmp_q2 << sb_noise_exp;
-                    }
-                }
-
-                /*
-                 *      tmp_q1 = nrg_tone[k]
-                 */
-
-                tmp_q1 = nrg_tone_man[k];
-
-                if (*harm_index & 1)
-                {
-                    if ((((k + lowSubband) & 1) != 0) ^(*harm_index != 1))
-                    {
-                        *ptrImag  -=  tmp_q1;
-                    }
-                    else
-                    {
-                        *ptrImag  +=  tmp_q1;
-                    }
-                }
-                else
-                {
-                    *ptrReal += (*harm_index) ? -tmp_q1 : tmp_q1;
-                }
-
-                *ptrReal++ <<= 10;
-                *ptrImag++ <<= 10;
-
-
-            }    /*  for-loop (k) */
-
-
-            *harm_index = (*harm_index + 1) & 3;
-
-            /*
-             *  Update smoothing filter history
-             */
-
-            if (filter_history++ < maxSmoothLength)     /* no more update is needed as buffer will have same info */
-            {
-                /*
-                 *  mantissas
-                 */
-
-                ptrReal = (Int32 *)fBuf_man[0];
-                ptrImag = (Int32 *)fBufN_man[0];
-
-                for (n = 0; n < maxSmoothLength; n++)
-                {
-                    fBuf_man[n]  = fBuf_man[n+1];
-                    fBufN_man[n] = fBufN_man[n+1];
-                }
-
-                fBuf_man[maxSmoothLength]  = ptrReal;
-                fBufN_man[maxSmoothLength] = ptrImag;
-
-                /*
-                 *  exponents
-                 */
-                ptrReal = (Int32 *)fBuf_exp[0];
-                ptrImag = (Int32 *)fBufN_exp[0];
-
-                for (n = 0; n < maxSmoothLength; n++)
-                {
-                    fBuf_exp[n]  = fBuf_exp[n+1];
-                    fBufN_exp[n] = fBufN_exp[n+1];
-                }
-
-                fBuf_exp[maxSmoothLength]  = ptrReal;
-                fBufN_exp[maxSmoothLength] = ptrImag;
-            }
-
-        }   /*  for-loop (l) */
-
-
-    }
-    else        /*   ----  if ( band_nrg_tone_detector) ---- */
-    {
-
-        /*
-         *          Application
-         */
-
-        for (l = (frame_info[1+i] << 1); l < (frame_info[2+i] << 1); l++)
-        {
-            ptrReal = (aBufR + l * SBR_NUM_BANDS);
-            ptrImag = (aBufI + l * SBR_NUM_BANDS);
-
-            if (filter_history <= maxSmoothLength)     /* no more update is needed as buffer will have same info */
-            {
-                pv_memmove(fBuf_man[maxSmoothLength], nrg_gain_man, noSubbands*sizeof(*nrg_gain_man));
-                pv_memmove(fBuf_exp[maxSmoothLength], nrg_gain_exp, noSubbands*sizeof(*nrg_gain_exp));
-                pv_memmove(fBufN_man[maxSmoothLength], noise_level_man, noSubbands*sizeof(*noise_level_man));
-                pv_memmove(fBufN_exp[maxSmoothLength], noise_level_exp, noSubbands*sizeof(*noise_level_exp));
-            }
-
-            /*
-             *  nrg_gain_max bounded to 1.584893192*1e5, which requires (32-bit) Q14 notation
-             */
-            for (k = 0; k < noSubbands; k++)
-            {
-                if (smooth_length == 0)     /* no filter-smooth needed */
-                {
-                    sb_gain_man = nrg_gain_man[k];
-                    sb_gain_exp = nrg_gain_exp[k];
-
-                    sb_noise_man = noise_level_man[k];
-                    sb_noise_exp = noise_level_exp[k];
-
-                }
-                else
-                {   /* else  smooth_length == 4  and fir_4 filter is being used */
-
-                    sb_gain_exp = fBuf_exp[maxSmoothLength][k];
-
-                    sb_noise_exp = fBufN_exp[maxSmoothLength][k];
-
-                    for (n = maxSmoothLength - smooth_length; n < maxSmoothLength; n++)
-                    {
-                        if (sb_gain_exp  < fBuf_exp[n][k])
-                        {
-                            sb_gain_exp = fBuf_exp[n][k];
-                        }
-
-                        if (sb_noise_exp  < fBufN_exp[n][k])
-                        {
-                            sb_noise_exp = fBufN_exp[n][k];
-                        }
-                    }
-
-                    sb_gain_man = fxp_mul32_Q30(fBuf_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
-                    sb_gain_man  = sb_gain_man >> (sb_gain_exp - fBuf_exp[maxSmoothLength][k]);
-
-                    sb_noise_man = fxp_mul32_Q30(fBufN_man[maxSmoothLength][k], Q30fmt(0.33333333333333f));
-                    sb_noise_man = sb_noise_man >> (sb_noise_exp - fBufN_exp[maxSmoothLength][k]);
-
-                    n = maxSmoothLength - smooth_length;
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.03183050093751f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.03183050093751f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.11516383427084f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.11516383427084f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.21816949906249f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.21816949906249f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n++][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBuf_man[n][k], Q30fmt(0.30150283239582f));
-                    sb_gain_man  += tmp_q1 >> (sb_gain_exp - fBuf_exp[n][k]);
-
-                    tmp_q1 = fxp_mul32_Q30(fBufN_man[n][k], Q30fmt(0.30150283239582f));
-                    sb_noise_man += tmp_q1 >> (sb_noise_exp - fBufN_exp[n][k]);
-
-                }
-
-
-
-                /*
-                 *    *ptrReal  = *ptrReal * sb_gain ;
-                 *    *ptrImag  = *ptrImag * sb_gain;
-                 */
-                aux1 = *ptrReal;
-                aux2 = *ptrImag;
-                sb_gain_exp += 32;
-                aux1 = fxp_mul32_Q31(aux1, sb_gain_man);
-                aux2 = fxp_mul32_Q31(aux2, sb_gain_man);
-
-
-
-                /*
-                 *     if ( sb_noise != 0)
-                 *     {
-                 *         *ptrReal += sb_noise * rP[*phase_index][0];
-                 *         *ptrImag += sb_noise * rP[*phase_index][1];
-                 *     }
-                 */
-
-
-                if (sb_gain_exp < 0)
-                {
-                    if (sb_gain_exp > -32)
-                    {
-                        if (sb_gain_exp > -10)
-                        {
-                            *ptrReal = aux1 << (10 + sb_gain_exp);
-                            *ptrImag = aux2 << (10 + sb_gain_exp);
-                        }
-                        else
-                        {
-                            *ptrReal = aux1 >> (-sb_gain_exp - 10);
-                            *ptrImag = aux2 >> (-sb_gain_exp - 10);
-                        }
-                    }
-                }
-                else
-                {
-                    *ptrReal = aux1 << (sb_gain_exp + 10);
-                    *ptrImag = aux2 << (sb_gain_exp + 10);
-                }
-
-
-
-
-                /*
-                 *     if ( sb_noise != 0)
-                 *     {
-                 *         *ptrReal += sb_noise * rP[*phase_index][0];
-                 *         *ptrImag += sb_noise * rP[*phase_index][1];
-                 *     }
-                 */
-                *phase_index = (*phase_index + 1) & 511;
-
-                if (!noNoiseFlag)
-                {
-
-                    Int32 tmp = rPxx[*phase_index];
-                    sb_noise_exp += 1;
-                    tmp_q1 = fxp_mul32_by_16t(sb_noise_man, tmp);
-                    tmp_q2 = fxp_mul32_by_16b(sb_noise_man, tmp);
-
-                    if (sb_noise_exp < 0)
-                    {
-                        if (sb_noise_exp > -32)
-                        {
-                            if (sb_noise_exp > -10)
-                            {
-                                *ptrReal += tmp_q1 << (10 + sb_noise_exp);
-                                *ptrImag += tmp_q2 << (10 + sb_noise_exp);
-                            }
-                            else
-                            {
-                                *ptrReal += tmp_q1 >> (-sb_noise_exp - 10);
-                                *ptrImag += tmp_q2 >> (-sb_noise_exp - 10);
-                            }
-                        }
-                    }
-                    else
-                    {
-                        *ptrReal += tmp_q1 << (sb_noise_exp + 10);
-                        *ptrImag += tmp_q2 << (sb_noise_exp + 10);
-                    }
-                }
-
-                ptrReal++;
-                ptrImag++;
-
-
-            }    /*  for-loop (k) */
-
-
-            *harm_index = (*harm_index + 1) & 3;
-
-            /*
-             *  Update smoothing filter history
-             */
-
-            if (filter_history++ < maxSmoothLength)     /* no more update is needed as buffer will have same info */
-            {
-                /*
-                 *  mantissas
-                 */
-
-                ptrReal = (Int32 *)fBuf_man[0];
-                ptrImag = (Int32 *)fBufN_man[0];
-
-                for (n = 0; n < maxSmoothLength; n++)
-                {
-                    fBuf_man[n]  = fBuf_man[n+1];
-                    fBufN_man[n] = fBufN_man[n+1];
-                }
-
-                fBuf_man[maxSmoothLength]  = ptrReal;
-                fBufN_man[maxSmoothLength] = ptrImag;
-
-                /*
-                 *  exponents
-                 */
-                ptrReal = (Int32 *)fBuf_exp[0];
-                ptrImag = (Int32 *)fBufN_exp[0];
-
-                for (n = 0; n < maxSmoothLength; n++)
-                {
-                    fBuf_exp[n]  = fBuf_exp[n+1];
-                    fBufN_exp[n] = fBufN_exp[n+1];
-                }
-
-                fBuf_exp[maxSmoothLength]  = ptrReal;
-                fBufN_exp[maxSmoothLength] = ptrImag;
-            }
-
-        }   /*  for-loop (l) */
-
-    }       /*  if ( band_nrg_tone_detector) */
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void energy_estimation(Int32 *aBufR,
-                       Int32 *aBufI,
-                       Int32 *nrg_est_man,
-                       Int32 *nrg_est_exp,
-                       const Int32 *frame_info,
-                       Int32 i,
-                       Int32 k,
-                       Int32 c,
-                       Int32 ui2)
-{
-
-    Int32  aux1;
-    Int32  aux2;
-    Int32  l;
-
-
-
-    int64_t nrg_h = 0;
-    Int32 tmp1;
-    Int32 tmp2;
-
-    aux1 = aBufR[ui2*SBR_NUM_BANDS + k];
-    aux2 = aBufI[ui2*SBR_NUM_BANDS + k];
-    for (l = ui2 + 1; l < (frame_info[2+i] << 1);  l++)
-    {
-        nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
-        nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
-        aux1 = aBufR[l*SBR_NUM_BANDS + k];
-        aux2 = aBufI[l*SBR_NUM_BANDS + k];
-    }
-    nrg_h = fxp_mac64_Q31(nrg_h, aux1, aux1);
-    nrg_h = fxp_mac64_Q31(nrg_h, aux2, aux2);
-
-
-    /*
-     *  Check for overflow and saturate if needed
-     */
-    if (nrg_h < 0)
-    {
-        nrg_h = 0x7fffffff;
-    }
-
-    if (nrg_h)
-    {
-
-        aux1 = (UInt32)(nrg_h >> 32);
-        if (aux1)
-        {
-            aux2 = pv_normalize(aux1);
-            if (aux2)
-            {
-                aux2 -= 1;                  /*  ensure Q30 */
-                nrg_h = (nrg_h << aux2) >> 33;
-                tmp2 = (UInt32)(nrg_h);
-                nrg_est_exp[c] = 33 - aux2;
-            }
-            else
-            {
-                tmp2 = (UInt32)(aux1 >> 1);
-                nrg_est_exp[c] = 33 ;
-
-
-            }
-        }
-        else
-        {
-            aux1 = (UInt32)(nrg_h >> 1);
-            aux2 = pv_normalize(aux1);
-
-            tmp2 = (aux1 << aux2);
-            nrg_est_exp[c] =  -aux2 + 1;
-
-
-        }
-
-
-
-        tmp1 = (l - ui2);
-        aux2 = pow2[tmp1];
-        if (tmp1 == (tmp1 & (-tmp1)))
-        {
-            nrg_est_man[c] = tmp2 >> aux2;
-        }
-        else
-        {
-            nrg_est_man[c] = fxp_mul32_by_16(tmp2, aux2);
-        }
-    }
-    else
-    {
-        nrg_est_man[c] = 0;
-        nrg_est_exp[c] = -100;
-    }
-
-
-}
-
-
-
-
-
-#endif
-
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h b/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h
deleted file mode 100644
index 2a6ae57..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_envelope.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: calc_sbr_envelope.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALCULATE_SBR_ENVELOPE_H
-#define CALCULATE_SBR_ENVELOPE_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "s_sbr_frame_data.h"
-#include    "sbr_generate_high_freq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    void calc_sbr_envelope(SBR_FRAME_DATA *frameData,
-    Int32 *aBufR,
-    Int32 *aBufI,
-    Int    freqBandTable1[2][MAX_FREQ_COEFFS + 1],
-    const Int32 *nSfb,
-    Int32   freqBandTable2[MAX_NOISE_COEFFS + 1],
-    Int32   nNBands,
-    Int32   reset,
-    Int32 *degreeAlias,
-    Int32 *harm_index,
-    Int32 *phase_index,
-    Int32 hFp[64],
-    Int32 *sUp,
-    Int32 limSbc[][13],
-    Int32 *gateMode,
-#ifdef HQ_SBR
-    Int32 *fBuf_man[64],
-    Int32 *fBuf_exp[64],
-    Int32 *fBufN_man[64],
-    Int32 *fBufN_exp[64],
-#endif
-    Int32 scratch_mem[][64],
-    struct PATCH Patch,
-    Int32  sqrt_cache[][4],
-    Int32  LC_flag);
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif   /*  CALCULATE_SBR_ENVELOPE_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp b/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp
deleted file mode 100644
index e557aa1..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.cpp
+++ /dev/null
@@ -1,639 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Filename: calc_sbr_synfilterbank.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "calc_sbr_synfilterbank.h"
-#include    "qmf_filterbank_coeff.h"
-#include    "synthesis_sub_band.h"
-#include    "fxp_mul32.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#if defined (PV_ARM_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
-    Int32 x;
-    __asm
-    {
-        qdadd y, y, y
-        mov y, y, asr #16
-    }
-
-    return((Int16)y);
-}
-
-#define saturate2( a, b, c, d)      *c = sat( a);   \
-                                    *d = sat( b);   \
-                                    c += 2;         \
-                                    d -= 2;
-
-
-#elif defined (PV_ARM_V4)
-
-
-__inline Int16 sat(Int32 y)
-{
-    Int32 x;
-    Int32 z = 31; /* rvct compiler problem */
-    __asm
-    {
-        sub y, y, y, asr 2
-        mov y, y, asr N
-        mov x, y, asr #15
-        teq x, y, asr z
-        eorne  y, INT16_MAX, y, asr #31
-    }
-
-    return((Int16)y);
-}
-
-#define saturate2( a, b, c, d)      *c = sat( a);   \
-                                    *d = sat( b);   \
-                                    c += 2;         \
-                                    d -= 2;
-
-#elif defined(PV_ARM_GCC_V5)
-
-__inline Int16 sat(Int32 y)
-{
-    register Int32 x;
-    register Int32 ra = y;
-
-
-    asm volatile(
-        "qdadd %0, %1, %1\n\t"
-        "mov %0, %0, asr #16"
-    : "=&r*i"(x)
-                : "r"(ra));
-
-    return ((Int16)x);
-}
-
-
-#define saturate2( a, b, c, d)      *c = sat( a);   \
-                                    *d = sat( b);   \
-                                    c += 2;         \
-                                    d -= 2;
-
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-#include "armintr.h"
-
-#define saturate2( a, b, c, d)      *c = _DAddSatInt( a, a)>>16;   \
-                                    *d = _DAddSatInt( b, b)>>16;   \
-                                    c += 2;         \
-                                    d -= 2;
-
-#else
-
-
-#define   saturate2( a, b, c, d)    a -= (a>>2);                             \
-                                    a  = (a>>N);                     \
-                                    if((a>>15) != (a>>31))                   \
-                                    {                                        \
-                                        a = ((a >> 31) ^ INT16_MAX); \
-                                    }                                        \
-                                    *c = (Int16)a;                           \
-                                    c += 2;                                  \
-                                    b -= (b>>2);                             \
-                                    b =  (b>>N);                      \
-                                    if((b>>15) != (b>>31))                   \
-                                    {                                        \
-                                        b = ((b >> 31) ^ INT16_MAX); \
-                                    }                                        \
-                                    *d = (Int16)b;                           \
-                                    d -= 2;
-
-
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void calc_sbr_synfilterbank_LC(Int32 * Sr,
-                               Int16 * timeSig,
-                               Int16   V[1280],
-                               bool bDownSampleSBR)
-{
-    Int32 i;
-
-    Int32   realAccu1;
-    Int32   realAccu2;
-    const Int32 *pt_C2;
-
-    Int16 *pt_V1;
-    Int16 *pt_V2;
-
-
-    Int16 *pt_timeSig;
-
-    Int16 *pt_timeSig_2;
-    Int32  test1;
-    Int16  tmp1;
-    Int16  tmp2;
-
-    /* shift filterstates */
-
-    Int32 * pt_Sr = Sr;
-
-
-    if (bDownSampleSBR == false)
-    {
-
-        synthesis_sub_band_LC(pt_Sr, V);
-
-        /* content of V[] is at most 16 bits */
-
-        pt_timeSig   = &timeSig[0];
-        pt_timeSig_2 = &timeSig[64];
-
-
-        tmp1 = V[ 704];
-        tmp2 = V[ 768];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
-        tmp1 = -V[ 512];
-        tmp2 =  V[ 960];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
-        tmp1 =  V[ 448];
-        tmp2 =  V[1024];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
-        tmp1 =  -V[ 256];
-        tmp2 =   V[ 192];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
-
-        tmp1 = V[  32];
-        tmp2 = V[1248];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
-        tmp1 = V[ 224];
-        tmp2 = V[1056];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
-        tmp1 = V[ 992];
-        tmp2 = V[ 288];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
-        tmp1 = V[ 480];
-        tmp2 = V[ 800];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
-        tmp1 = V[ 736];
-        tmp2 = V[ 544];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
-
-
-
-        saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
-        pt_timeSig_2 = &timeSig[126];
-
-        pt_V1 = &V[1];
-        pt_V2 = &V[1279];
-
-        pt_C2 = &sbrDecoderFilterbankCoefficients[0];
-
-        for (i = 31; i != 0; i--)
-        {
-            test1 = *(pt_C2++);
-            tmp1 = *(pt_V1++);
-            tmp2 = *(pt_V2--);
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
-            tmp1 = pt_V1[  191];
-            tmp2 = pt_V2[ -191];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  255];
-            tmp2 = pt_V2[ -255];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  447];
-            tmp2 = pt_V2[ -447];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  511];
-            tmp2 = pt_V2[ -511];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  703];
-            tmp2 = pt_V2[ -703];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  767];
-            tmp2 = pt_V2[ -767];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  959];
-            tmp2 = pt_V2[ -959];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  1023];
-            tmp2 = pt_V2[ -1023];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  1215];
-            tmp2 = pt_V2[ -1215];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
-        }
-    }
-    else
-    {
-
-        synthesis_sub_band_LC_down_sampled(Sr, V);
-
-        /*
-         *    window signal
-         *    calculate output samples
-         */
-
-
-        pt_V1 = &V[0];
-        pt_V2 = &V[96];
-
-
-        Int32 * pt_out = Sr;
-
-        for (i = 0; i < 8; i++)
-        {
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-        }
-
-        const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
-        pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
-
-        for (int k = 0; k < 5; k++)
-        {
-            pt_out -= 32;
-            for (i = 0; i < 16; i++)
-            {
-                realAccu1   = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
-                realAccu2   = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
-                realAccu1   = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
-                realAccu2   = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
-                *(pt_out++) += realAccu1 >> 5;
-                *(pt_out++) += realAccu2 >> 5;
-
-            }
-            pt_V1 += 96;
-            pt_V2 += 96;
-            pt_C1 += 16;
-            pt_C2 += 16;
-        }
-        pt_out -= 32;
-
-        for (i = 0; i < 32; i++)
-        {
-            timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
-        }
-
-    }
-
-}
-
-
-
-#ifdef HQ_SBR
-
-void calc_sbr_synfilterbank(Int32 * Sr,
-                            Int32 * Si,
-                            Int16 * timeSig,
-                            Int16   V[1280],
-                            bool bDownSampleSBR)
-{
-    Int32 i;
-
-    const Int32 *pt_C2;
-
-    Int32   realAccu1;
-    Int32   realAccu2;
-
-    Int16 *pt_V1;
-    Int16 *pt_V2;
-
-    Int16 *pt_timeSig;
-
-    Int16 *pt_timeSig_2;
-    Int32  test1;
-    Int16  tmp1;
-    Int16  tmp2;
-
-
-    if (bDownSampleSBR == false)
-    {
-        synthesis_sub_band(Sr, Si, V);
-
-        /* content of V[] is at most 16 bits */
-        pt_timeSig   = &timeSig[0];
-        pt_timeSig_2 = &timeSig[64];
-
-        tmp1 = V[ 704];
-        tmp2 = V[ 768];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(0.853738560F), ROUND_SYNFIL);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.361158990F), realAccu1);
-        tmp1 = -V[ 512];
-        tmp2 =  V[ 960];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.361158990F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(0.070353307F), realAccu1);
-        tmp1 =  V[ 448];
-        tmp2 =  V[1024];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(0.070353307F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.013271822F), realAccu1);
-        tmp1 =  -V[ 256];
-        tmp2 =   V[ 192];
-        realAccu1 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.013271822F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(tmp2, Qfmt(0.002620176F), realAccu1);
-        realAccu1 =  fxp_mac_16_by_16(V[1216], Qfmt(0.002620176F), realAccu1);
-
-        tmp1 = V[  32];
-        tmp2 = V[1248];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.000665042F), ROUND_SYNFIL);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.000665042F), realAccu2);
-        tmp1 = V[ 224];
-        tmp2 = V[1056];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.005271576F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.005271576F), realAccu2);
-        tmp1 = V[ 992];
-        tmp2 = V[ 288];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.058591568F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.058591568F), realAccu2);
-        tmp1 = V[ 480];
-        tmp2 = V[ 800];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(-0.058370533F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(-0.058370533F), realAccu2);
-        tmp1 = V[ 736];
-        tmp2 = V[ 544];
-        realAccu2 =  fxp_mac_16_by_16(tmp1, Qfmt(0.702238872F), realAccu2);
-        realAccu2 =  fxp_mac_16_by_16(tmp2, Qfmt(0.702238872F), realAccu2);
-
-
-        saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-
-        pt_timeSig_2 = &timeSig[126];
-
-        pt_V1 = &V[1];
-        pt_V2 = &V[1279];
-
-        pt_C2 = &sbrDecoderFilterbankCoefficients[0];
-
-        for (i = 31; i != 0; i--)
-        {
-            test1 = *(pt_C2++);
-            tmp1 = *(pt_V1++);
-            tmp2 = *(pt_V2--);
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, ROUND_SYNFIL);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, ROUND_SYNFIL);
-            tmp1 = pt_V1[  191];
-            tmp2 = pt_V2[ -191];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  255];
-            tmp2 = pt_V2[ -255];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  447];
-            tmp2 = pt_V2[ -447];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  511];
-            tmp2 = pt_V2[ -511];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  703];
-            tmp2 = pt_V2[ -703];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  767];
-            tmp2 = pt_V2[ -767];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  959];
-            tmp2 = pt_V2[ -959];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            test1 = *(pt_C2++);
-            tmp1 = pt_V1[  1023];
-            tmp2 = pt_V2[ -1023];
-            realAccu1 =  fxp_mac_16_by_16_bt(tmp1 , test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bt(tmp2 , test1, realAccu2);
-            tmp1 = pt_V1[  1215];
-            tmp2 = pt_V2[ -1215];
-            realAccu1 =  fxp_mac_16_by_16_bb(tmp1, test1, realAccu1);
-            realAccu2 =  fxp_mac_16_by_16_bb(tmp2, test1, realAccu2);
-
-            saturate2(realAccu1, realAccu2, pt_timeSig, pt_timeSig_2);
-        }
-
-    }
-    else
-    {
-
-        synthesis_sub_band_down_sampled(Sr,  Si,  V);
-
-
-        Int32 * pt_out = Sr;
-
-        for (i = 0; i < 8; i++)
-        {
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-            *(pt_out++) = 0;
-        }
-
-
-        /*
-         *    window signal
-         *    calculate output samples
-         */
-
-        pt_V1 = &V[0];
-        pt_V2 = &V[96];
-
-
-        const Int32* pt_C1 = &sbrDecoderFilterbankCoefficients_down_smpl[0];
-        pt_C2 = &sbrDecoderFilterbankCoefficients_down_smpl[16];
-
-        for (Int k = 0; k < 5; k++)
-        {
-            pt_out -= 32;
-            for (i = 0; i < 16; i++)
-            {
-                realAccu1   = fxp_mul_16_by_16bt(*(pt_V1++), *(pt_C1));
-                realAccu2   = fxp_mul_16_by_16bb(*(pt_V1++), *(pt_C1++));
-                realAccu1   = fxp_mac_16_by_16_bt(*(pt_V2++), *(pt_C2), realAccu1);
-                realAccu2   = fxp_mac_16_by_16_bb(*(pt_V2++), *(pt_C2++), realAccu2);
-                *(pt_out++) += realAccu1 >> 5;
-                *(pt_out++) += realAccu2 >> 5;
-            }
-            pt_V1 += 96;
-            pt_V2 += 96;
-            pt_C1 += 16;
-            pt_C2 += 16;
-        }
-        pt_out -= 32;
-
-        for (i = 0; i < 32; i++)
-        {
-            timeSig[2*i] = (Int16)((*(pt_out++) + 512) >> 10);
-        }
-
-    }
-}
-
-
-#endif      /* --- HQ_SBR --- */
-
-
-#endif      /* --- AAC_PLUS --- */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h b/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h
deleted file mode 100644
index 28bd6de..0000000
--- a/media/libstagefright/codecs/aacdec/calc_sbr_synfilterbank.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CALC_SBR_SYNFILTERBANK_H
-#define CALC_SBR_SYNFILTERBANK_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-#define N  14
-
-#define ROUND_SYNFIL  (32768 + 4096)
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-
-    void calc_sbr_synfilterbank_LC(Int32 * Sr,
-    Int16 * timeSig,
-    Int16   V[1280],
-    bool bDownSampleSBR);
-
-#ifdef HQ_SBR
-
-
-    void calc_sbr_synfilterbank(Int32 * Sr,
-                                Int32 * Si,
-                                Int16 * timeSig,
-                                Int16   V[1280],
-                                bool bDownSampleSBR);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/chans.h b/media/libstagefright/codecs/aacdec/chans.h
deleted file mode 100644
index 325b5cd..0000000
--- a/media/libstagefright/codecs/aacdec/chans.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname:   chans.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Placed file in the correct template format.
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CHANS_H
-#define CHANS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-    /* #define is required in order to use these args in #if () directive */
-#define ICChans 0
-#define DCChans 0
-#define XCChans 0
-#define CChans  0
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    enum
-    {
-        /*
-         * channels for 5.1 main profile configuration
-         * (modify for any desired decoder configuration)
-         */
-        FChans  = 2,    /* front channels: left, center, right */
-        FCenter = 0,    /* 1 if decoder has front center channel */
-        SChans  = 0,    /* side channels: */
-        BChans  = 0,    /* back channels: left surround, right surround */
-        BCenter = 0,    /* 1 if decoder has back center channel */
-        LChans  = 0,    /* LFE channels */
-        XChans  = 0,    /* scratch space for parsing unused channels */
-
-        Chans   = FChans + SChans + BChans + LChans + XChans
-    };
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CHANS_H */
-
diff --git a/media/libstagefright/codecs/aacdec/check_crc.cpp b/media/libstagefright/codecs/aacdec/check_crc.cpp
deleted file mode 100644
index 17f3b87..0000000
--- a/media/libstagefright/codecs/aacdec/check_crc.cpp
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: check_crc.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    INPUT
-
-
-    OUTPUT
-
-    errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "check_crc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void check_crc(HANDLE_CRC hCrcBuf, UInt32 bValue, Int32 nBits)
-{
-    Int32 i;
-    UInt32 bMask = (1UL << (nBits - 1));
-
-    for (i = 0; i < nBits; i++, bMask >>= 1)
-    {
-        UInt16 flag  = (UInt16)((hCrcBuf->crcState & hCrcBuf->crcMask) ? 1 : 0);
-        UInt16 flag1 = (UInt16)((bMask & bValue) ? 1 : 0);
-
-        flag ^= flag1;
-        hCrcBuf->crcState <<= 1;
-        if (flag)
-            hCrcBuf->crcState ^= hCrcBuf->crcPoly;
-    }
-
-}
-
diff --git a/media/libstagefright/codecs/aacdec/check_crc.h b/media/libstagefright/codecs/aacdec/check_crc.h
deleted file mode 100644
index 9293d47..0000000
--- a/media/libstagefright/codecs/aacdec/check_crc.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: check_crc.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef CHECK_CRC_H
-#define CHECK_CRC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_crc_buffer.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    void check_crc(HANDLE_CRC hCrcBuf,
-    UInt32 bValue,
-    Int32 nBits);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/dct16.cpp b/media/libstagefright/codecs/aacdec/dct16.cpp
deleted file mode 100644
index 75bd4ba..0000000
--- a/media/libstagefright/codecs/aacdec/dct16.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: dct16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 16
-
-    Int32 flag           1  forward dct16, 0 modified dct-16
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement dct of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "dct16.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt_31(a)   (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-#define Qfmt15(x)   (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dct_16(Int32 vec[], Int flag)
-{
-    Int32 tmp0;
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 tmp3;
-    Int32 tmp4;
-    Int32 tmp5;
-    Int32 tmp6;
-    Int32 tmp7;
-    Int32 tmp_o0;
-    Int32 tmp_o1;
-    Int32 tmp_o2;
-    Int32 tmp_o3;
-    Int32 tmp_o4;
-    Int32 tmp_o5;
-    Int32 tmp_o6;
-    Int32 tmp_o7;
-    Int32 itmp_e0;
-    Int32 itmp_e1;
-    Int32 itmp_e2;
-
-    /*  split input vector */
-
-
-    tmp_o0 = fxp_mul32_by_16((vec[ 0] - vec[15]), Qfmt15(0.50241928618816F));
-    tmp0   =  vec[ 0] + vec[15];
-
-    tmp_o7 = fxp_mul32_Q31((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F));
-    tmp7   =  vec[ 7] + vec[ 8];
-
-    itmp_e0 = (tmp0 + tmp7);
-    tmp7    = fxp_mul32_by_16((tmp0 - tmp7), Qfmt15(0.50979557910416F));
-
-    tmp_o1 = fxp_mul32_by_16((vec[ 1] - vec[14]), Qfmt15(0.52249861493969F));
-    tmp1   =  vec[ 1] + vec[14];
-    tmp_o6 = fxp_mul32_by_16((vec[ 6] - vec[ 9]) << 1, Qfmt15(0.86122354911916F));
-    tmp6   =  vec[ 6] + vec[ 9];
-
-    itmp_e1 = (tmp1 + tmp6);
-    tmp6    = fxp_mul32_by_16((tmp1 - tmp6), Qfmt15(0.60134488693505F));
-
-    tmp_o2 = fxp_mul32_by_16((vec[ 2] - vec[13]), Qfmt15(0.56694403481636F));
-    tmp2   =  vec[ 2] + vec[13];
-    tmp_o5 = fxp_mul32_by_16((vec[ 5] - vec[10]) << 1, Qfmt15(0.53033884299517F));
-    tmp5   =  vec[ 5] + vec[10];
-
-    itmp_e2 = (tmp2 + tmp5);
-    tmp5    = fxp_mul32_by_16((tmp2 - tmp5), Qfmt15(0.89997622313642F));
-
-    tmp_o3 = fxp_mul32_by_16((vec[ 3] - vec[12]), Qfmt15(0.64682178335999F));
-    tmp3   =  vec[ 3] + vec[12];
-    tmp_o4 = fxp_mul32_by_16((vec[ 4] - vec[11]), Qfmt15(0.78815462345125F));
-    tmp4   =  vec[ 4] + vec[11];
-
-    tmp1   = (tmp3 + tmp4);
-    tmp4   =  fxp_mul32_Q31((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F));
-
-    /*  split even part of tmp_e */
-
-    tmp0 = (itmp_e0 + tmp1);
-    tmp1 = fxp_mul32_by_16((itmp_e0 - tmp1), Qfmt15(0.54119610014620F));
-
-
-    tmp3 = fxp_mul32_by_16((itmp_e1 - itmp_e2) << 1, Qfmt15(0.65328148243819F));
-    tmp2 = (itmp_e1 + itmp_e2);
-
-    vec[ 0]  = (tmp0 + tmp2) >> 1;
-    vec[ 8]  = fxp_mul32_by_16((tmp0 - tmp2), Qfmt15(0.70710678118655F));
-    vec[12]  = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
-    vec[ 4]  =  tmp1 + tmp3;
-    vec[ 4] +=  vec[12];
-
-    /*  split odd part of tmp_e */
-
-    tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
-    tmp7 += tmp4;
-    tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
-
-    tmp6 += tmp5;
-
-    vec[10]  = fxp_mul32_by_16((tmp7 - tmp6) << 1, Qfmt15(0.70710678118655F));
-    vec[ 2]  =  tmp7 + tmp6;
-    vec[14]  = fxp_mul32_by_16((tmp1 - tmp3) << 1, Qfmt15(0.70710678118655F));
-
-    tmp1    +=  tmp3 + vec[14];
-    vec[ 2] +=  tmp1;
-    vec[ 6]  =  tmp1 + vec[10];
-
-    vec[10] += vec[14];
-
-
-    // dct8;
-
-    tmp7 = tmp_o0 + tmp_o7;
-    tmp_o7 = fxp_mul32_by_16((tmp_o0 - tmp_o7) << 1, Qfmt15(0.50979557910416F));
-
-    tmp6 = tmp_o1 + tmp_o6;
-    tmp_o1 = fxp_mul32_by_16((tmp_o1 - tmp_o6) << 1, Qfmt15(0.60134488693505F));
-
-    tmp5 = tmp_o2 + tmp_o5;
-    tmp_o5 = fxp_mul32_by_16((tmp_o2 - tmp_o5) << 1, Qfmt15(0.89997622313642F));
-
-    tmp4 = tmp_o3 + tmp_o4;
-
-    tmp_o3 = fxp_mul32_Q31((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F));
-
-    if (!flag)
-    {
-        tmp7   = -tmp7;
-        tmp_o7 = -tmp_o7;
-        tmp6   = -tmp6;
-        tmp_o1 = -tmp_o1;
-        tmp5   = -tmp5;
-        tmp_o5 = -tmp_o5;
-        tmp4   = -tmp4;
-        tmp_o3 = -tmp_o3;
-    }
-
-    // even part
-
-    tmp1 = fxp_mul32_by_16((tmp7 - tmp4) << 1, Qfmt15(0.54119610014620F));
-    tmp0 =  tmp7 + tmp4;
-    tmp3 = fxp_mul32_Q31((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
-    tmp2 =  tmp6 + tmp5;
-
-    vec[ 9]  = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
-    vec[ 1]  =  tmp0 + tmp2;
-    vec[13]  = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
-
-    vec[ 5]  =  tmp1 + tmp3 + vec[13];
-
-    // odd part
-
-    tmp0 =  tmp_o7 + tmp_o3;
-    tmp1 = fxp_mul32_by_16((tmp_o7 - tmp_o3) << 1, Qfmt15(0.54119610014620F));
-    tmp2 =  tmp_o1 + tmp_o5;
-    tmp3 = fxp_mul32_Q31((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F));
-
-    vec[11]  = fxp_mul32_Q31((tmp0 - tmp2) << 1, Qfmt_31(0.70710678118655F));
-    vec[ 3]  =  tmp0 + tmp2;
-    vec[15]  = fxp_mul32_Q31((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
-    vec[ 7]  =  tmp1 + tmp3 + vec[15];
-
-
-    vec[ 3] += vec[ 7];
-    vec[ 7] += vec[11];
-    vec[11] += vec[15];
-
-    vec[ 1] += vec[ 3];
-    vec[ 3] += vec[ 5];
-    vec[ 5] += vec[ 7];
-    vec[ 7] += vec[ 9];
-    vec[ 9] += vec[11];
-    vec[11] += vec[13];
-    vec[13] += vec[15];
-
-
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/dct16.h b/media/libstagefright/codecs/aacdec/dct16.h
deleted file mode 100644
index 6f8fcb2..0000000
--- a/media/libstagefright/codecs/aacdec/dct16.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dct16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DCT16_H
-#define DCT16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void dct_16(Int32 vec[], Int flag);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* DCT16_H */
diff --git a/media/libstagefright/codecs/aacdec/dct64.cpp b/media/libstagefright/codecs/aacdec/dct64.cpp
deleted file mode 100644
index a21a814..0000000
--- a/media/libstagefright/codecs/aacdec/dct64.cpp
+++ /dev/null
@@ -1,569 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dct64.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 64
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement dct of lenght 64
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dct16.h"
-#include "dct64.h"
-
-#include "pv_audio_type_defs.h"
-#include "synthesis_sub_band.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt(a)   (Int32)(a*((Int32)1<<26) + (a>=0?0.5F:-0.5F))
-#define Qfmt31(a)   (Int32)(a*0x7FFFFFFF)
-
-const Int32 CosTable_48[48] =
-{
-    Qfmt31(0.50015063602065F) ,  Qfmt31(0.50135845244641F) ,
-    Qfmt31(0.50378872568104F) ,  Qfmt31(0.50747117207256F) ,
-    Qfmt31(0.51245147940822F) ,  Qfmt31(0.51879271310533F) ,
-    Qfmt31(0.52657731515427F) ,  Qfmt31(0.53590981690799F) ,
-    Qfmt31(0.54692043798551F) ,  Qfmt31(0.55976981294708F) ,
-    Qfmt31(0.57465518403266F) ,  Qfmt31(0.59181853585742F) ,
-    Qfmt31(0.61155734788251F) ,  Qfmt31(0.63423893668840F) ,
-    Qfmt31(0.66031980781371F) ,  Qfmt31(0.69037212820021F) ,
-    Qfmt31(0.72512052237720F) ,  Qfmt31(0.76549416497309F) ,
-    Qfmt31(0.81270209081449F) ,  Qfmt31(0.86834471522335F) ,
-    Qfmt(0.93458359703641F) ,  Qfmt(1.01440826499705F) ,
-    Qfmt(1.11207162057972F) ,  Qfmt(1.23383273797657F) ,
-    Qfmt(1.38929395863283F) ,  Qfmt(1.59397228338563F) ,
-    Qfmt(1.87467598000841F) ,  Qfmt(2.28205006800516F) ,
-    Qfmt(2.92462842815822F) ,  Qfmt(4.08461107812925F) ,
-    Qfmt(6.79675071167363F) ,  Qfmt(20.37387816723145F) , /* 32 */
-    Qfmt(0.50060299823520F) ,  Qfmt(0.50547095989754F) ,
-    Qfmt(0.51544730992262F) ,  Qfmt(0.53104259108978F) ,
-    Qfmt(0.55310389603444F) ,  Qfmt(0.58293496820613F) ,
-    Qfmt(0.62250412303566F) ,  Qfmt(0.67480834145501F) ,
-    Qfmt(0.74453627100230F) ,  Qfmt(0.83934964541553F) ,
-    Qfmt(0.97256823786196F) ,  Qfmt(1.16943993343288F) ,
-    Qfmt(1.48416461631417F) ,  Qfmt(2.05778100995341F) ,
-    Qfmt(3.40760841846872F) ,  Qfmt(10.19000812354803F)
-};
-
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; dct_64
-----------------------------------------------------------------------------*/
-
-void pv_split_LC(Int32 *vector,
-                 Int32 *temp_o)
-{
-
-    Int32 i;
-    Int32 *pt_vector     = &vector[0];
-    Int32 *pt_vector_N_1 = &vector[31];
-    const Int32 *pt_cosTerms = &CosTable_48[32];
-    Int32 *pt_temp_o = temp_o;
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 tmp3;
-
-
-    tmp1 = *(pt_vector);
-    tmp2 = *(pt_vector_N_1--);
-    for (i = 16; i != 0; i--)
-    {
-        tmp3 = *(pt_cosTerms++);
-        *(pt_vector++) =   tmp1  + tmp2;
-        *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), tmp3);
-        tmp1 = *(pt_vector);
-        tmp2 = *(pt_vector_N_1--);
-    }
-
-}
-
-
-#ifdef HQ_SBR
-
-
-void dct_64(Int32 vec[], Int32 *scratch_mem)
-{
-    Int32 *temp_e1;
-    Int32 *temp_o1;
-
-    Int32 *pt_vec;
-
-    Int   i;
-
-    Int32 aux1;
-    Int32 aux2;
-    Int32 aux3;
-    Int32 aux4;
-
-    const Int32 *cosTerms = &CosTable_48[31];
-
-    temp_o1 = &vec[32];
-    temp_e1 = temp_o1 - 1;
-
-
-    for (i = 6; i != 0; i--)
-    {
-        aux1 = *(temp_e1);
-        aux2 = *(temp_o1);
-        aux3 = *(cosTerms--);
-        *(temp_e1--) =   aux1  + aux2;
-        *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
-        aux1 = *(temp_e1);
-        aux2 = *(temp_o1);
-        aux3 = *(cosTerms--);
-        *(temp_e1--) =   aux1  + aux2;
-        *(temp_o1++) = fxp_mul32_Q26((aux1 - aux2), aux3);
-    }
-
-
-    for (i = 10; i != 0; i--)
-    {
-        aux1 = *(temp_e1);
-        aux2 = *(temp_o1);
-        aux3 = *(cosTerms--);
-        *(temp_e1--) =   aux1  + aux2;
-        *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
-        aux1 = *(temp_e1);
-        aux2 = *(temp_o1);
-        aux3 = *(cosTerms--);
-        *(temp_e1--) =   aux1  + aux2;
-        *(temp_o1++) = fxp_mul32_Q31((aux1 - aux2), aux3) << 1;
-    }
-
-
-    pv_split(&vec[16]);
-
-    dct_16(&vec[16], 0);
-    dct_16(vec,     1);      // Even terms
-
-    pv_merge_in_place_N32(vec);
-
-    pv_split_z(&vec[32]);
-
-    dct_16(&vec[32], 1);     // Even terms
-    dct_16(&vec[48], 0);
-
-    pv_merge_in_place_N32(&vec[32]);
-
-
-
-    aux1   = vec[32];
-    aux3   = vec[33];
-    aux4   = vec[ 1];  /* vec[ 1] */
-
-    /* -----------------------------------*/
-    aux1     = vec[32] + vec[33];
-    vec[ 0] +=  aux1;
-    vec[ 1] +=  aux1;
-
-    aux1        = vec[34];
-    aux2        = vec[ 2];   /* vec[ 2] */
-    aux3        += aux1;
-    vec[ 2] = aux4 + aux3;
-    aux4        = vec[ 3];  /* vec[ 3] */
-    vec[ 3] = aux2 + aux3;
-
-    aux3        = vec[35];
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[32] = vec[ 4];
-    vec[33] = vec[ 5];
-    vec[ 4] = aux2 + aux1;
-    vec[ 5] = aux4 + aux1;
-
-    aux1        = vec[36];
-    aux2        = vec[32];  /* vec[ 4] */
-    aux3        += aux1;
-    vec[34] = vec[ 6];
-    vec[35] = vec[ 7];
-    vec[ 6] = aux4 + aux3;
-    vec[ 7] = aux2 + aux3;
-
-    aux3        = vec[37];
-    aux4        = vec[33];  /* vec[ 5] */
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[32] = vec[ 8];
-    vec[33] = vec[ 9];
-    vec[ 8] = aux2 + aux1;
-    vec[ 9] = aux4 + aux1;
-
-    aux1        = vec[38];
-    aux2        = vec[34];  /* vec[ 6] */
-    aux3        += aux1;
-    vec[34] = vec[10];
-    vec[10] = aux4 + aux3;
-    aux4        = vec[35];  /* vec[ 7] */
-    vec[35] = vec[11];
-    vec[11] = aux2 + aux3;
-
-    aux3        = vec[39];
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[36] = vec[12];
-    vec[37] = vec[13];
-    vec[12] = aux2 + aux1;
-    vec[13] = aux4 + aux1;
-
-    aux1        = vec[40];
-    aux2        = vec[32];  /* vec[ 8] */
-    aux3        += aux1;
-    vec[32] = vec[14];
-    vec[14] = aux4 + aux3;
-    aux4        = vec[33];  /* vec[ 9] */
-    vec[33] = vec[15];
-    vec[15] = aux2 + aux3;
-
-    aux3        = vec[41];
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[38] = vec[16];
-    vec[39] = vec[17];
-    vec[16] = aux2 + aux1;
-    vec[17] = aux4 + aux1;
-
-    aux1        = vec[42];
-    aux2        = vec[34];  /* vec[10] */
-    aux3        += aux1;
-    vec[34] = vec[18];
-    vec[18] = aux4 + aux3;
-    aux4        = vec[35];  /* vec[11] */
-    vec[35] = vec[19];
-    vec[19] = aux2 + aux3;
-
-    aux3        = vec[43];
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[40] = vec[20];
-    vec[41] = vec[21];
-    vec[20] = aux2 + aux1;
-    vec[21] = aux4 + aux1;
-
-    aux1        = vec[44];
-    aux2        = vec[36];  /* vec[12] */
-    aux3        += aux1;
-    vec[42] = vec[22];
-    vec[43] = vec[23];
-    vec[22] = aux4 + aux3;
-    vec[23] = aux2 + aux3;
-
-    aux3        = vec[45];
-    aux4        = vec[37];  /* vec[13] */
-
-    /* -----------------------------------*/
-
-
-    scratch_mem[0] = vec[24];
-    scratch_mem[1] = vec[25];
-    aux1        += aux3;
-    vec[24] = aux2 + aux1;
-    vec[25] = aux4 + aux1;
-
-    aux1        = vec[46];
-    aux2        = vec[32];  /* vec[14] */
-    scratch_mem[2] = vec[26];
-    scratch_mem[3] = vec[27];
-    aux3        += aux1;
-    vec[26] = aux4 + aux3;
-    vec[27] = aux2 + aux3;
-
-    aux3        = vec[47];
-    aux4        = vec[33];  /* vec[15] */
-
-    /* -----------------------------------*/
-    scratch_mem[4] = vec[28];
-    scratch_mem[5] = vec[29];
-    aux1        += aux3;
-    vec[28] = aux2 + aux1;
-    vec[29] = aux4 + aux1;
-
-    aux1        = vec[48];
-    aux2        = vec[38];  /* vec[16] */
-    scratch_mem[6] = vec[30];
-    scratch_mem[7] = vec[31];
-    aux3        += aux1;
-    vec[30] = aux4 + aux3;
-    vec[31] = aux2 + aux3;
-
-    aux3        = vec[49];
-    aux4        = vec[39];  /* vec[17] */
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[32] = aux2 + aux1;
-    vec[33] = aux4 + aux1;
-
-    aux1        = vec[50];
-    aux2        = vec[34];  /* vec[18] */
-    aux3        += aux1;
-    vec[34] = aux4 + aux3;
-    aux4        = vec[35];  /* vec[19] */
-    vec[35] = aux2 + aux3;
-
-    aux3        = vec[51];
-
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[36] = aux2 + aux1;
-    vec[37] = aux4 + aux1;
-
-    aux1        = vec[52];
-    aux2        = vec[40];  /* vec[20] */
-    aux3        += aux1;
-    vec[38] = aux4 + aux3;
-    vec[39] = aux2 + aux3;
-
-    aux3        = vec[53];
-    aux4        = vec[41];  /* vec[21] */
-
-    /* -----------------------------------*/
-    aux1        += aux3;
-    vec[40] = aux2 + aux1;
-    vec[41] = aux4 + aux1;
-
-    aux1        = vec[54];
-    aux2        = vec[42];  /* vec[22] */
-    aux3        += aux1;
-    vec[42] = aux4 + aux3;
-    aux4        = vec[43];  /* vec[23] */
-    vec[43] = aux2 + aux3;
-
-    aux3        = vec[55];
-
-    /* -----------------------------------*/
-
-    pt_vec = &vec[44];
-    temp_o1 = &vec[56];
-    temp_e1 = &scratch_mem[0];
-
-    for (i = 4; i != 0; i--)
-    {
-        aux1        += aux3;
-        *(pt_vec++) = aux2 + aux1;
-        *(pt_vec++) = aux4 + aux1;
-
-        aux1        = *(temp_o1++);
-        aux3        += aux1;
-        aux2        = *(temp_e1++);
-        *(pt_vec++) = aux4 + aux3;
-        *(pt_vec++) = aux2 + aux3;
-
-        aux3        = *(temp_o1++);
-        aux4        = *(temp_e1++);
-    }
-
-    aux1       += aux3;
-    vec[60] = aux2 + aux1;
-    vec[61] = aux4 + aux1;
-    vec[62] = aux4 + aux3;
-
-}
-
-
-#endif
-
-/*----------------------------------------------------------------------------
-; pv_split
-----------------------------------------------------------------------------*/
-
-
-void pv_split(Int32 *temp_o)
-{
-
-    Int32 i;
-    const Int32 *pt_cosTerms = &CosTable_48[47];
-    Int32 *pt_temp_o = temp_o;
-    Int32 *pt_temp_e = pt_temp_o - 1;
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 cosx;
-
-    for (i = 8; i != 0; i--)
-    {
-        tmp2 = *(pt_temp_o);
-        tmp1 = *(pt_temp_e);
-        cosx = *(pt_cosTerms--);
-        *(pt_temp_e--) =   tmp1  + tmp2;
-        *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
-        tmp1 = *(pt_temp_e);
-        tmp2 = *(pt_temp_o);
-        cosx = *(pt_cosTerms--);
-        *(pt_temp_e--) =   tmp1  + tmp2;
-        *(pt_temp_o++) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
-    }
-}
-
-
-
-void pv_split_z(Int32 *vector)
-{
-    Int32 i;
-    Int32 *pt_vector     = &vector[31];
-    const Int32 *pt_cosTerms = &CosTable_48[32];
-    Int32 *pt_temp_e = vector;
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 cosx;
-
-    for (i = 8; i != 0; i--)
-    {
-        tmp1 = *(pt_vector);
-        tmp2 = *(pt_temp_e);
-        cosx = *(pt_cosTerms++);
-        *(pt_temp_e++) =   tmp1  + tmp2;
-        *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
-        tmp2 = *(pt_temp_e);
-        tmp1 = *(pt_vector);
-        cosx = *(pt_cosTerms++);
-        *(pt_temp_e++) =   tmp1  + tmp2;
-        *(pt_vector--) = fxp_mul32_Q26((tmp1 - tmp2), cosx);
-    }
-}
-
-
-void pv_merge_in_place_N32(Int32 vec[])
-{
-
-    Int32 temp[4];
-
-    temp[0] = vec[14];
-    vec[14] = vec[ 7];
-    temp[1] = vec[12];
-    vec[12] = vec[ 6];
-    temp[2] = vec[10];
-    vec[10] = vec[ 5];
-    temp[3] = vec[ 8];
-    vec[ 8] = vec[ 4];
-    vec[ 6] = vec[ 3];
-    vec[ 4] = vec[ 2];
-    vec[ 2] = vec[ 1];
-
-    vec[ 1] = vec[16] + vec[17];
-    vec[16] = temp[3];
-    vec[ 3] = vec[18] + vec[17];
-    vec[ 5] = vec[19] + vec[18];
-    vec[18] = vec[9];
-    temp[3] = vec[11];
-
-    vec[ 7] = vec[20] + vec[19];
-    vec[ 9] = vec[21] + vec[20];
-    vec[20] = temp[2];
-    temp[2] = vec[13];
-    vec[11] = vec[22] + vec[21];
-    vec[13] = vec[23] + vec[22];
-    vec[22] = temp[3];
-    temp[3] = vec[15];
-    vec[15] = vec[24] + vec[23];
-    vec[17] = vec[25] + vec[24];
-    vec[19] = vec[26] + vec[25];
-    vec[21] = vec[27] + vec[26];
-    vec[23] = vec[28] + vec[27];
-    vec[25] = vec[29] + vec[28];
-    vec[27] = vec[30] + vec[29];
-    vec[29] = vec[30] + vec[31];
-    vec[24] = temp[1];
-    vec[26] = temp[2];
-    vec[28] = temp[0];
-    vec[30] = temp[3];
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/dct64.h b/media/libstagefright/codecs/aacdec/dct64.h
deleted file mode 100644
index 3d5e82b..0000000
--- a/media/libstagefright/codecs/aacdec/dct64.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dct64.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DCT64_H
-#define DCT64_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-    extern const Int32 CosTable_48[48];
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void pv_split_LC(Int32 *vector,
-                     Int32 *temp_o);
-
-
-#ifdef HQ_SBR
-
-    void dct_64(Int32 vec[], Int32 *scratch_mem);
-
-#endif
-
-    void pv_split(Int32 *temp_o);
-
-    void pv_split_z(Int32 *vector);
-
-    void pv_merge_in_place_N32(Int32 vec[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* DCT64_H */
diff --git a/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp b/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp
deleted file mode 100644
index 0d1561b..0000000
--- a/media/libstagefright/codecs/aacdec/decode_huff_cw_binary.cpp
+++ /dev/null
@@ -1,708 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/decode_huff_cw_binary.c
- Funtions:
-    decode_huff_cw_tab1
-    decode_huff_cw_tab2
-    decode_huff_cw_tab3
-    decode_huff_cw_tab4
-    decode_huff_cw_tab5
-    decode_huff_cw_tab6
-    decode_huff_cw_tab7
-    decode_huff_cw_tab8
-    decode_huff_cw_tab9
-    decode_huff_cw_tab10
-    decode_huff_cw_tab11
-    decode_huff_cw_scl
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Updated per review comments
-              (1) make cw sgined and change "if(cw&0x80000000)" to if(cw<0)
-              (2)
-
- Description: Create specific functions for different huffman tables.
-
-
- Description: Added ( Int16) castings to eliminate several compiler warnings
-
-
- Description: Modified huffman tables to allocate int32 variables instead of
-              int16, which lead to data missaligned for some compiler.
-              Eliminated casting and unused variables
-
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    BITS          *pInputStream = pointer to input bit stream
-
- Local Stores/Buffers/Pointers Needed:
-
-
- Global Stores/Buffers/Pointers Needed:
-
-
- Outputs:
-    idx = bit field extracted from a leaf entry of packed Huffman Tables
-
- Pointers and Buffers Modified:
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-   These functions are used to decode huffman codewords from the input
-   bitstream using combined binary search and look-up table approach.
-
-   First the codewords are grouped and the input symbol is determined
-   which group it belongs. Then within that group, a look-up table is
-   used to determine which codeword the symbol is.
-   The table is created by ordering the codeword in the table according to their
-   normalized shifted binary value, i.e., all the codewords are left
-   shifted to meet the maximum codelength. Example, max codelength is
-   10, the codeword with lenth 3 will left shift by 7.
-   The binary values of after the shift are sorted.
-   Then the sorted table is divided into several partition.
-   At the VLC decoding period, input is read in at max codelenght.
-   The partition is decided using if-else logic.
-   Inside each partition, a look-up table is used to map the input value
-   to a correct symbol. Table entries can appear to be repeated according
-   to the humming distance between adjacent codewords.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) Introduction to Algorithms,
-     Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest.
-     The MIT press, 1990
-
- (3) "Selecting an Optimal Huffman Decoder for AAC",
-     Vladimir Z. Mesarovic, et al.
-     AES 111th Convention, September 21-24, 2001, New York, USA
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define    MAX_CW_LEN  (19)
-#define    MASK_IDX    (0x1FF)
-#define    MASK_RIGHT  (0xFE00)
-
-#define    UPPER16      (16)
-#define    MASK_LOW16   (0xFFFF)
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int decode_huff_cw_tab1(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              11,
-              pInputStream);
-    if ((cw >> 10) == 0)
-    {
-        pInputStream->usedBits -= (11 - 1);
-        return 40; /* idx is 40 */
-    }
-    else if ((cw >> 6) <= 23)
-    {
-        tab = (cw >> 6) - 16;
-    }
-    else if ((cw >> 4) <= 119)
-    {
-        tab = (cw >> 4) - 96 + 8;
-    }
-    else if ((cw >> 2) <= 503)
-    {
-        tab = (cw >> 2) - 480 + 32;
-    }
-    else
-    {
-        tab = cw - 2016 + 56;
-    }
-
-    tab = *(huff_tab1 + tab);
-
-    pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab2(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get9_n_lessbits(
-              9,
-              pInputStream);
-    if ((cw >> 6) == 0)
-    {
-        pInputStream->usedBits -= (9 - 3); /* used 3 bits */
-        return 40; /* idx is 40 */
-    }
-    else if ((cw >> 3) <= 49)
-    {
-        tab = (cw >> 3) - 8;
-    }
-    else if ((cw >> 2) <= 114)
-    {
-        tab = (cw >> 2) - 100 + 42;
-    }
-    else if ((cw >> 1) <= 248)
-    {
-        tab = (cw >> 1) - 230 + 57;
-    }
-    else
-    {
-        tab = cw - 498 + 76;
-    }
-
-    tab = *(huff_tab2 + tab);
-
-    pInputStream->usedBits -= (9 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab3(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              16,
-              pInputStream);
-    if ((cw >> 15) == 0)
-    {
-        pInputStream->usedBits -= (16 - 1); /* used 1 bits */
-        return 0; /* idx is 0 */
-    }
-    else if ((cw >> 10) <= 57)
-    {
-        tab = (cw >> 10) - 32;
-    }
-    else if ((cw >> 7) <= 500)
-    {
-        tab = (cw >> 7) - 464 + 26;
-    }
-    else if ((cw >> 6) <= 1016)
-    {
-        tab = (cw >> 6) - 1002 + 63;
-    }
-    else if ((cw >> 4) <= 4092)
-    {
-        tab = (cw >> 4) - 4068 + 78;
-    }
-    else
-    {
-        tab = cw - 65488 + 103;
-    }
-
-    tab = *(huff_tab3 + tab);
-
-    pInputStream->usedBits -= (16 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab4(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              12,
-              pInputStream);
-
-    if ((cw >> 7) <= 25)
-    {
-        tab = (cw >> 7);
-    }
-    else if ((cw >> 4) <= 246)
-    {
-        tab = (cw >> 4) - 208 + 26;
-    }
-    else if ((cw >> 2) <= 1017)
-    {
-        tab = (cw >> 2) - 988 + 65;
-    }
-    else
-    {
-        tab = cw - 4072 + 95;
-    }
-
-    tab = *(huff_tab4 + tab);
-
-    pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab5(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              13,
-              pInputStream);
-
-    if ((cw >> 12) == 0)
-    {
-        pInputStream->usedBits -= (13 - 1); /* used 1 bits */
-        return 40; /* idx is 40 */
-    }
-    else if ((cw >> 8) <= 27)
-    {
-        tab = (cw >> 8) - 16;
-    }
-    else if ((cw >> 5) <= 243)
-    {
-        tab = (cw >> 5) - 224 + 12;
-    }
-    else if ((cw >> 3) <= 1011)
-    {
-        tab = (cw >> 3) - 976 + 32;
-    }
-    else if ((cw >> 2) <= 2041)
-    {
-        tab = (cw >> 2) - 2024 + 68;
-    }
-    else
-    {
-        tab = cw - 8168 + 86;
-    }
-
-    tab = *(huff_tab5 + tab);
-
-    pInputStream->usedBits -= (13 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab6(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              11,
-              pInputStream);
-
-    if ((cw >> 7) <= 8)
-    {
-        tab = (cw >> 7);
-    }
-    else if ((cw >> 4) <= 116)
-    {
-        tab = (cw >> 4) - 72 + 9;
-    }
-    else if ((cw >> 2) <= 506)
-    {
-        tab = (cw >> 2) - 468 + 54;
-    }
-    else
-    {
-        tab = cw - 2028 + 93;
-    }
-
-    tab = *(huff_tab6 + tab);
-
-    pInputStream->usedBits -= (11 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab7(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              12,
-              pInputStream);
-
-    if ((cw >> 11) == 0)
-    {
-        pInputStream->usedBits -= (12 - 1); /* used 1 bits */
-        return 0; /* idx is 0 */
-    }
-    else if ((cw >> 6) <= 55)
-    {
-        tab = (cw >> 6) - 32;
-    }
-    else if ((cw >> 4) <= 243)
-    {
-        tab = (cw >> 4) - 224 + 24;
-    }
-    else if ((cw >> 2) <= 1018)
-    {
-        tab = (cw >> 2) - 976 + 44;
-    }
-    else
-    {
-        tab = cw - 4076 + 87;
-    }
-
-    tab = *(huff_tab7 + tab);
-
-    pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-
-Int decode_huff_cw_tab8(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              10,
-              pInputStream);
-
-    if ((cw >> 5) <= 20)
-    {
-        tab = (cw >> 5);
-    }
-    else if ((cw >> 3) <= 117)
-    {
-        tab = (cw >> 3) - 84 + 21;
-    }
-    else if ((cw >> 2) <= 250)
-    {
-        tab = (cw >> 2) - 236 + 55;
-    }
-    else
-    {
-        tab = cw - 1004 + 70;
-    }
-
-    tab = *(huff_tab8 + tab);
-
-    pInputStream->usedBits -= (10 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab9(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              15,
-              pInputStream);
-
-    if ((cw >> 11) <= 12)
-    {
-        tab = (cw >> 11);
-    }
-    else if ((cw >> 8) <= 114)
-    {
-        tab = (cw >> 8) - 104 + 13;
-    }
-    else if ((cw >> 6) <= 486)
-    {
-        tab = (cw >> 6) - 460 + 24;
-    }
-    else if ((cw >> 5) <= 993)
-    {
-        tab = (cw >> 5) - 974 + 51;
-    }
-    else if ((cw >> 4) <= 2018)
-    {
-        tab = (cw >> 4) - 1988 + 71;
-    }
-    else if ((cw >> 3) <= 4075)
-    {
-        tab = (cw >> 3) - 4038 + 102;
-    }
-    else if ((cw >> 2) <= 8183)
-    {
-        tab = (cw >> 2) - 8152 + 140;
-    }
-    else
-    {
-        tab = cw - 32736 + 172;
-    }
-
-    tab = *(huff_tab9 + tab);
-
-    pInputStream->usedBits -= (15 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab10(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              12,
-              pInputStream);
-
-    if ((cw >> 6) <= 41)
-    {
-        tab = (cw >> 6);
-    }
-    else if ((cw >> 5) <= 100)
-    {
-        tab = (cw >> 5) - 84 + 42;
-    }
-    else if ((cw >> 4) <= 226)
-    {
-        tab = (cw >> 4) - 202 + 59;
-    }
-    else if ((cw >> 3) <= 484)
-    {
-        tab = (cw >> 3) - 454 + 84;
-    }
-    else if ((cw >> 2) <= 1010)
-    {
-        tab = (cw >> 2) - 970 + 115;
-    }
-    else if ((cw >> 1) <= 2043)
-    {
-        tab = (cw >> 1) - 2022 + 156;
-    }
-    else
-    {
-        tab = cw - 4088 + 178;
-    }
-
-    tab = *(huff_tab10 + tab);
-
-    pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_cw_tab11(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = get17_n_lessbits(
-              12,
-              pInputStream);
-
-    if ((cw >> 6) <= 26)
-    {
-        tab = (cw >> 6);
-    }
-    else if ((cw >> 5) <= 69)
-    {
-        tab = (cw >> 5) - 54 + 27;
-    }
-    else if ((cw >> 4) <= 198)
-    {
-        tab = (cw >> 4) - 140 + 43;
-    }
-    else if ((cw >> 3) <= 452)
-    {
-        tab = (cw >> 3) - 398 + 102;
-    }
-    else if ((cw >> 2) <= 1000)
-    {
-        tab = (cw >> 2) - 906 + 157;
-    }
-    else if ((cw >> 1) <= 2044)
-    {
-        tab = (cw >> 1) - 2002 + 252;
-    }
-    else
-    {
-        tab = cw - 4090 + 295;
-    }
-
-    tab = *(huff_tab11 + tab);
-
-    pInputStream->usedBits -= (12 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
-
-Int decode_huff_scl(
-    BITS          *pInputStream)
-{
-    Int32  tab;
-    Int32  cw;
-
-    cw  = getbits(
-              19,
-              pInputStream);
-
-    if ((cw >> 18) == 0)
-    {
-        pInputStream->usedBits -= (19 - 1); /* used 1 bits */
-        return 60; /* idx is 60 */
-    }
-    else if ((cw >> 13) <= 59)
-    {
-        tab = (cw >> 13) - 32;
-    }
-    else if ((cw >> 10) <= 505)
-    {
-        tab = (cw >> 10) - 480 + 28;
-    }
-    else if ((cw >> 7) <= 4089)
-    {
-        tab = (cw >> 7) - 4048 + 54;
-    }
-    else if ((cw >> 5) <= 16377)
-    {
-        tab = (cw >> 5) - 16360 + 96;
-    }
-    else if ((cw >> 3) <= 65526)
-    {
-        tab = (cw >> 3) - 65512 + 114;
-    }
-    else if ((cw >> 1) <= 262120)
-    {
-        tab = (cw >> 1) - 262108 + 129;
-    }
-    else
-    {
-        tab = cw - 524242 + 142;
-    }
-
-    tab = *(huff_tab_scl + tab);
-
-    pInputStream->usedBits -= (19 - (tab & MASK_LOW16));
-    return ((Int)(tab >> UPPER16));
-}
-
diff --git a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp b/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp
deleted file mode 100644
index 41cd187..0000000
--- a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.cpp
+++ /dev/null
@@ -1,163 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: decode_noise_floorlevels.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "decode_noise_floorlevels.h"
-#include    "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData)
-
-{
-    Int32 env;
-    Int32 i;
-
-    Int32 * frameInfo           = hFrameData->frameInfo;
-    Int32   nNfb                = hFrameData->nNfb;
-    Int32 * domain_vec          = hFrameData->domain_vec2;
-
-    Int32 * sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
-    Int32 * prevNoiseLevel_man     = hFrameData->prevNoiseLevel_man;
-
-    Int32 nEnv = frameInfo[(frameInfo[0] << 1) + 3];
-
-    for (env = 0; env < nEnv; env++)
-    {
-        if (domain_vec[env] == 0)
-        {
-            prevNoiseLevel_man[0] = *(sbrNoiseFloorLevel_man++);
-
-            for (i = 1; i < nNfb; i++)
-            {
-                *sbrNoiseFloorLevel_man += *(sbrNoiseFloorLevel_man - 1);
-                prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
-            }
-        }
-        else
-        {
-            for (i = 0; i < nNfb; i++)
-            {
-                *sbrNoiseFloorLevel_man += prevNoiseLevel_man[i];
-                prevNoiseLevel_man[i] = *(sbrNoiseFloorLevel_man++);
-            }
-        }
-
-    }
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h b/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h
deleted file mode 100644
index a9c3551..0000000
--- a/media/libstagefright/codecs/aacdec/decode_noise_floorlevels.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: decode_noise_floorlevels.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef DECODENOISEFLOORLEVELS_H
-#define DECODENOISEFLOORLEVELS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void decode_noise_floorlevels(SBR_FRAME_DATA * hFrameData);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/deinterleave.cpp b/media/libstagefright/codecs/aacdec/deinterleave.cpp
deleted file mode 100644
index 5298b19..0000000
--- a/media/libstagefright/codecs/aacdec/deinterleave.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/deinterleave.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description: (1) Modified with new template, rename variables
-              (2) Removed for-loop to calculate win_inc, win_inc = SN2 (128)
-              (3) Replaced for-loop with memcpy
-              (4) Converted Int16 -> Int
-
- Description: Modified per review comments
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    interleaved   = input array that contains interleaved coefficients
-                    Data Type Int
-
-    deinterleaved = output array that will be updated with de-interleaved
-                    coefficients of input array. Data Type Int
-
-    pFrameInfo = pointer to structure that holds information of current
-                 frame. Data Type FrameInfo
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    deinterleaved  contents updated with de-interleaved coefficients from
-                   the input array: interleaved
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs the deinterleaving across all short windows in
- each group
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the contents of pDeinterleaved with the
- de-interleaved 1024 coefficients of one frame
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4           p78     quant_to_spec
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pInterleaved   = interleaved;
-    pDeinterleaved = deinterleaved;
-
-    pSfbPerWin  = pFrameInfo->sfb_per_win;
-    ngroups     = pFrameInfo->num_groups;
-    pGroupLen   = pFrameInfo->group_len;
-
-    pGroup = pDeinterleaved;
-
-    FOR (group = ngroups; group > 0; group--)
-
-        pSfbWidth   = pFrameInfo->sfb_width_128;
-        sfb_inc = 0;
-        pStart = pInterleaved;
-
-        FOR (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
-
-            pWin = pGroup;
-
-            FOR (win = pGroupLen[ngroups-group]; win > 0; win--)
-
-                pDeinterleaved = pWin + sfb_inc;
-
-                pv_memcpy(
-                     pDeinterleaved,
-                     pInterleaved,
-                    *pSfbWidth*sizeof(*pInterleaved));
-
-                pInterleaved += *pSfbWidth;
-
-                pWin += SN2;
-
-            ENDFOR (win)
-
-            sfb_inc += *pSfbWidth++;
-
-        ENDFOR (sfb)
-
-    pGroup += (pInterleaved - pStart);
-
-    ENDFOR (group)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void deinterleave(
-    Int16        interleaved[],
-    Int16        deinterleaved[],
-    FrameInfo   *pFrameInfo)
-{
-
-    Int      group;  /* group index */
-    Int      sfb;    /* scalefactor band index */
-    Int      win;    /* window index */
-    Int16    *pGroup;
-    Int16    *pWin;
-    Int16    *pStart;
-    Int16    *pInterleaved;
-    Int16    *pDeinterleaved;
-    Int      sfb_inc;
-
-    Int      ngroups;
-    Int     *pGroupLen;
-    Int     *pSfbPerWin;
-    Int     *pSfbWidth;
-
-    pInterleaved   = interleaved;
-    pDeinterleaved = deinterleaved;
-
-    pSfbPerWin  = pFrameInfo->sfb_per_win;
-    ngroups     = pFrameInfo->num_groups;
-    pGroupLen   = pFrameInfo->group_len;
-
-    pGroup = pDeinterleaved;
-
-    for (group = ngroups; group > 0; group--)
-    {
-        pSfbWidth   = pFrameInfo->sfb_width_128;
-        sfb_inc = 0;
-        pStart = pInterleaved;
-
-        /* Perform the deinterleaving across all windows in a group */
-
-        for (sfb = pSfbPerWin[ngroups-group]; sfb > 0; sfb--)
-        {
-            pWin = pGroup;
-
-            for (win = pGroupLen[ngroups-group]; win > 0; win--)
-            {
-                pDeinterleaved = pWin + sfb_inc;
-
-                pv_memcpy(
-                    pDeinterleaved,
-                    pInterleaved,
-                    *pSfbWidth*sizeof(*pInterleaved));
-
-                pInterleaved += *pSfbWidth;
-
-                pWin += SN2;
-
-            } /* for (win) */
-
-            sfb_inc += *pSfbWidth++;
-
-        } /* for (sfb) */
-
-        pGroup += (pInterleaved - pStart);
-
-    } /* for (group) */
-
-} /* deinterleave */
diff --git a/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp b/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp
deleted file mode 100644
index ffa980d..0000000
--- a/media/libstagefright/codecs/aacdec/digit_reversal_tables.cpp
+++ /dev/null
@@ -1,279 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/digit_reversal_tables.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-  ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
-  Tables for digit reverse operation
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
-------------------------------------------------------------------------------
- Digit Reverse tables
-------------------------------------------------------------------------------
-*/
-
-const Int16 digit_reverse_64[ 64] =
-{
-    + 0,  + 32,  + 64,  + 96,
-    + 8,  + 40,  + 72, + 104,
-    + 16,  + 48,  + 80, + 112,
-    + 24,  + 56,  + 88, + 120,
-    + 2,  + 34,  + 66,  + 98,
-    + 10,  + 42,  + 74, + 106,
-    + 18,  + 50,  + 82, + 114,
-    + 26,  + 58,  + 90, + 122,
-    + 4,  + 36,  + 68, + 100,
-    + 12,  + 44,  + 76, + 108,
-    + 20,  + 52,  + 84, + 116,
-    + 28,  + 60,  + 92, + 124,
-    + 6,  + 38,  + 70, + 102,
-    + 14,  + 46,  + 78, + 110,
-    + 22,  + 54,  + 86, + 118,
-    + 30,  + 62,  + 94, + 126
-};
-
-
-const Int16 digit_reverse_256[ 256] =
-{
-    + 0, + 128, + 256, + 384,
-    + 32, + 160, + 288, + 416,
-    + 64, + 192, + 320, + 448,
-    + 96, + 224, + 352, + 480,
-    + 8, + 136, + 264, + 392,
-    + 40, + 168, + 296, + 424,
-    + 72, + 200, + 328, + 456,
-    + 104, + 232, + 360, + 488,
-    + 16, + 144, + 272, + 400,
-    + 48, + 176, + 304, + 432,
-    + 80, + 208, + 336, + 464,
-    + 112, + 240, + 368, + 496,
-    + 24, + 152, + 280, + 408,
-    + 56, + 184, + 312, + 440,
-    + 88, + 216, + 344, + 472,
-    + 120, + 248, + 376, + 504,
-    + 2, + 130, + 258, + 386,
-    + 34, + 162, + 290, + 418,
-    + 66, + 194, + 322, + 450,
-    + 98, + 226, + 354, + 482,
-    + 10, + 138, + 266, + 394,
-    + 42, + 170, + 298, + 426,
-    + 74, + 202, + 330, + 458,
-    + 106, + 234, + 362, + 490,
-    + 18, + 146, + 274, + 402,
-    + 50, + 178, + 306, + 434,
-    + 82, + 210, + 338, + 466,
-    + 114, + 242, + 370, + 498,
-    + 26, + 154, + 282, + 410,
-    + 58, + 186, + 314, + 442,
-    + 90, + 218, + 346, + 474,
-    + 122, + 250, + 378, + 506,
-    + 4, + 132, + 260, + 388,
-    + 36, + 164, + 292, + 420,
-    + 68, + 196, + 324, + 452,
-    + 100, + 228, + 356, + 484,
-    + 12, + 140, + 268, + 396,
-    + 44, + 172, + 300, + 428,
-    + 76, + 204, + 332, + 460,
-    + 108, + 236, + 364, + 492,
-    + 20, + 148, + 276, + 404,
-    + 52, + 180, + 308, + 436,
-    + 84, + 212, + 340, + 468,
-    + 116, + 244, + 372, + 500,
-    + 28, + 156, + 284, + 412,
-    + 60, + 188, + 316, + 444,
-    + 92, + 220, + 348, + 476,
-    + 124, + 252, + 380, + 508,
-    + 6, + 134, + 262, + 390,
-    + 38, + 166, + 294, + 422,
-    + 70, + 198, + 326, + 454,
-    + 102, + 230, + 358, + 486,
-    + 14, + 142, + 270, + 398,
-    + 46, + 174, + 302, + 430,
-    + 78, + 206, + 334, + 462,
-    + 110, + 238, + 366, + 494,
-    + 22, + 150, + 278, + 406,
-    + 54, + 182, + 310, + 438,
-    + 86, + 214, + 342, + 470,
-    + 118, + 246, + 374, + 502,
-    + 30, + 158, + 286, + 414,
-    + 62, + 190, + 318, + 446,
-    + 94, + 222, + 350, + 478,
-    + 126, + 254, + 382, + 510
-};
-
-
-
-
-const Int16 digit_reverse_swap_256[ 241] =
-{
-    + 2, + 128,   + 4, + 256,
-    + 6, + 384,   + 8,  + 32,
-    + 10, + 160,  + 12, + 288,
-    + 14, + 416,  + 16,  + 64,
-    + 18, + 192,  + 20, + 320,
-    + 22, + 448,  + 24,  + 96,
-    + 26, + 224,  + 28, + 352,
-    + 30, + 480,  + 34, + 136,
-    + 36, + 264,  + 38, + 392,
-    + 42, + 168,  + 44, + 296,
-    + 46, + 424,  + 48,  + 72,
-    + 50, + 200,  + 52, + 328,
-    + 54, + 456,  + 56, + 104,
-    + 58, + 232,  + 60, + 360,
-    + 62, + 488,  + 66, + 144,
-    + 68, + 272,  + 70, + 400,
-    + 74, + 176,  + 76, + 304,
-    + 78, + 432,  + 82, + 208,
-    + 84, + 336,  + 86, + 464,
-    + 88, + 112,  + 90, + 240,
-    + 92, + 368,  + 94, + 496,
-    + 98, + 152, + 100, + 280,
-    + 102, + 408, + 106, + 184,
-    + 108, + 312, + 110, + 440,
-    + 114, + 216, + 116, + 344,
-    + 118, + 472, + 122, + 248,
-    + 124, + 376, + 126, + 504,
-    + 132, + 258, + 134, + 386,
-    + 138, + 162, + 140, + 290,
-    + 142, + 418, + 146, + 194,
-    + 148, + 322, + 150, + 450,
-    + 154, + 226, + 156, + 354,
-    + 158, + 482, + 164, + 266,
-    + 166, + 394, + 172, + 298,
-    + 174, + 426, + 178, + 202,
-    + 180, + 330, + 182, + 458,
-    + 186, + 234, + 188, + 362,
-    + 190, + 490, + 196, + 274,
-    + 198, + 402, + 204, + 306,
-    + 206, + 434, + 212, + 338,
-    + 214, + 466, + 218, + 242,
-    + 220, + 370, + 222, + 498,
-    + 228, + 282, + 230, + 410,
-    + 236, + 314, + 238, + 442,
-    + 244, + 346, + 246, + 474,
-    + 252, + 378, + 254, + 506,
-    + 262, + 388, + 268, + 292,
-    + 270, + 420, + 276, + 324,
-    + 278, + 452, + 284, + 356,
-    + 286, + 484, + 294, + 396,
-    + 302, + 428, + 308, + 332,
-    + 310, + 460, + 316, + 364,
-    + 318, + 492, + 326, + 404,
-    + 334, + 436, + 342, + 468,
-    + 348, + 372, + 350, + 500,
-    + 358, + 412, + 366, + 444,
-    + 374, + 476, + 382, + 508,
-    + 398, + 422, + 406, + 454,
-    + 414, + 486, + 438, + 462,
-    + 446, + 494, + 478, + 502
-};
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void digit_reversal_swapping(Int32 *y, Int32 *x);
-
-#ifdef __cplusplus
-}
-#endif
-
-void digit_reversal_swapping(Int32 *y, Int32 *x)
-{
-    Int16 i, j;
-    Int32 tmp[2];
-    const Int16 *pTable;
-
-    pTable = digit_reverse_swap_256;
-
-    for (Int k = 120; k != 0; k--)
-    {
-        i = *pTable++;
-        j = *pTable++;
-        tmp[0] = y[i];
-        tmp[1] = y[i+1];
-        y[i]   = y[j];
-        y[i+1] = y[j+1];
-        y[j]   = tmp[0];
-        y[j+1] = tmp[1];
-
-        tmp[0] = x[j];
-        tmp[1] = x[j+1];
-        x[j]   = x[i];
-        x[j+1] = x[i+1];
-        x[i]   = tmp[0];
-        x[i+1] = tmp[1];
-
-    }
-
-}
diff --git a/media/libstagefright/codecs/aacdec/digit_reversal_tables.h b/media/libstagefright/codecs/aacdec/digit_reversal_tables.h
deleted file mode 100644
index 7fdaaf7..0000000
--- a/media/libstagefright/codecs/aacdec/digit_reversal_tables.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/DIGIT_REVERSAL_TABLES.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions digit_reversal_tables
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef DIGIT_REVERSAL_TABLES_H
-#define DIGIT_REVERSAL_TABLES_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int16 digit_reverse_64[];
-extern const Int16 digit_reverse_256[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* DIGIT_REVERSAL_TABLES_H */
diff --git a/media/libstagefright/codecs/aacdec/dst16.cpp b/media/libstagefright/codecs/aacdec/dst16.cpp
deleted file mode 100644
index 41c9259..0000000
--- a/media/libstagefright/codecs/aacdec/dst16.cpp
+++ /dev/null
@@ -1,172 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 16
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement discrete sine transform of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "dst16.h"
-#include "dst8.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT     28
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 CosTable_8[8] =
-{
-    Qfmt(0.50241928618816F),   Qfmt(0.52249861493969F),
-    Qfmt(0.56694403481636F),   Qfmt(0.64682178335999F),
-    Qfmt(0.78815462345125F),   Qfmt(1.06067768599035F),
-    Qfmt(1.72244709823833F),   Qfmt(5.10114861868916F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dst_16(Int32 vec[], Int32 scratch_mem[])     /* scratch_mem size 8 */
-{
-    Int32 *temp_even = scratch_mem;
-
-    Int i;
-    const Int32 *pt_cos = &CosTable_8[7];
-    Int32 tmp0 = vec[15] >> 1;
-    Int32 tmp1, tmp2;
-    Int32 *pt_even = temp_even;
-    Int32 *pt_odd  = vec;
-    Int32 *pt_vec  = vec;
-    Int32 *pt_vecN_1;
-    Int32 tmp3;
-
-
-    *(pt_even++) = *(pt_vec++);
-    tmp1         = *(pt_vec++);
-    *(pt_odd++) = tmp1;
-
-    for (i = 3; i != 0; i--)
-    {
-        *(pt_even++) = *(pt_vec++);
-        tmp2         = *(pt_vec++);
-        *(pt_even++) = *(pt_vec++);
-        tmp3         = *(pt_vec++);
-        *(pt_odd++) = tmp2 + tmp1;
-        *(pt_odd++) = tmp3 + tmp2;
-        tmp1         = tmp3;
-
-    }
-
-    *(pt_even)   = *(pt_vec++);
-    *(pt_odd++) = *(pt_vec) + tmp1;
-
-
-    dst_8(temp_even);
-    dst_8(vec);
-
-    pt_vec  = &vec[7];
-
-    pt_even = &temp_even[7];
-    pt_vecN_1  = &vec[8];
-
-    tmp1 = *(pt_even--);
-
-    for (i = 4; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q28((*(pt_vec) - tmp0), *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vec--)     = tmp3 + tmp1;
-        *(pt_vecN_1++)  = tmp3 - tmp1;
-        tmp3  = fxp_mul32_Q28((*(pt_vec) + tmp0), *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp3 - tmp2;
-        *(pt_vec--)     = tmp3 + tmp2;
-    }
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst16.h b/media/libstagefright/codecs/aacdec/dst16.h
deleted file mode 100644
index bce73ba..0000000
--- a/media/libstagefright/codecs/aacdec/dst16.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST16_H
-#define DST16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void dst_16(Int32 vec[], Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* DST16_H */
diff --git a/media/libstagefright/codecs/aacdec/dst32.cpp b/media/libstagefright/codecs/aacdec/dst32.cpp
deleted file mode 100644
index 5edecf1..0000000
--- a/media/libstagefright/codecs/aacdec/dst32.cpp
+++ /dev/null
@@ -1,200 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst32.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 32
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement discrete sine transform of lenght 32
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dst32.h"
-#include "dst16.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT1     29
-#define Qfmt29(x)   (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F))
-#define Qfmt31(a)   (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-const Int32 CosTable_16[14] =
-{
-    Qfmt31(0.50060299823520F),   Qfmt31(0.50547095989754F),
-    Qfmt31(0.51544730992262F),   Qfmt31(0.53104259108978F),
-    Qfmt31(0.55310389603444F),   Qfmt31(0.58293496820613F),
-    Qfmt31(0.62250412303566F),   Qfmt31(0.67480834145501F),
-    Qfmt31(0.74453627100230F),   Qfmt31(0.83934964541553F),
-    Qfmt29(0.97256823786196F),   Qfmt29(1.16943993343288F),
-    Qfmt29(1.48416461631417F),   Qfmt29(2.05778100995341F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void dst_32(Int32 vec[], Int32 scratch_mem[])   /* scratch_mem size 32 */
-{
-    Int32 *temp_even = scratch_mem;
-
-    Int32 i;
-    const Int32 *pt_cos = &CosTable_16[13];
-    Int32 tmp0 = vec[31] >> 1;
-    Int32 tmp1, tmp2;
-    Int32 *pt_even = temp_even;
-    Int32 *pt_odd  = vec;
-    Int32 *pt_vec  = vec;
-    Int32 *pt_vecN_1  = vec;
-    Int32 tmp3;
-
-
-    tmp1 = 0;
-
-    for (i = 5; i != 0; i--)
-    {
-        *(pt_even++) = *(pt_vec++);
-        tmp2         = *(pt_vec++);
-        *(pt_even++) = *(pt_vec++);
-        tmp3         = *(pt_vec++);
-        *(pt_even++) = *(pt_vec++);
-        *(pt_odd++) = tmp2 + tmp1;
-        *(pt_odd++) = tmp3 + tmp2;
-        tmp1         = *(pt_vec++);
-        *(pt_odd++) = tmp1 + tmp3;
-    }
-
-    *(pt_even) = *(pt_vec++);
-    *(pt_odd)  = *(pt_vec) + tmp1;
-
-
-    dst_16(temp_even, &scratch_mem[16]);
-    dst_16(vec, &scratch_mem[24]);
-
-
-    pt_vecN_1  = &vec[16];
-
-    tmp1 = temp_even[15];
-
-    tmp3  = fxp_mul32_Q31((vec[15] - tmp0) << 3, Qfmt31(0.63687550772175F)) << 2;
-    tmp2  = temp_even[14];
-    *(pt_vecN_1++)  = tmp3 - tmp1;
-    vec[15]         = tmp3 + tmp1;
-    tmp1  = temp_even[13];
-    tmp3  = fxp_mul32_Q31((vec[14] + tmp0) << 3, Qfmt31(0.85190210461718F));
-    *(pt_vecN_1++)  = tmp3 - tmp2;
-    vec[14]         = tmp3 + tmp2;
-
-    pt_even = &temp_even[12];
-    pt_vec  = &vec[13];
-
-    for (i = 2; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q29((*(pt_vec) - tmp0), *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vec--)     = tmp3 + tmp1;
-        *(pt_vecN_1++)  = tmp3 - tmp1;
-        tmp3  = fxp_mul32_Q29((*(pt_vec) + tmp0), *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vec--)     = tmp3 + tmp2;
-        *(pt_vecN_1++)  = tmp3 - tmp2;
-    }
-
-    for (i = 5; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q31((*(pt_vec) - tmp0) << 1, *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vec--)     = tmp3 + tmp1;
-        *(pt_vecN_1++)  = tmp3 - tmp1;
-        tmp3  = fxp_mul32_Q31((*(pt_vec) + tmp0) << 1, *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vec--)     = tmp3 + tmp2;
-        *(pt_vecN_1++)  = tmp3 - tmp2;
-    }
-
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst32.h b/media/libstagefright/codecs/aacdec/dst32.h
deleted file mode 100644
index c2bf1d2..0000000
--- a/media/libstagefright/codecs/aacdec/dst32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST32_H
-#define DST32_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-    extern const Int32 CosTable_16[];
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void dst_32(Int32 vec[], Int32 scratch_mem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* DST32_H */
diff --git a/media/libstagefright/codecs/aacdec/dst8.cpp b/media/libstagefright/codecs/aacdec/dst8.cpp
deleted file mode 100644
index eaf8280..0000000
--- a/media/libstagefright/codecs/aacdec/dst8.cpp
+++ /dev/null
@@ -1,179 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: dst8.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 8
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement discrete sine transform of lenght 8
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "dst8.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt15(x)   (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT     29
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(x)   (Int32)(x*0x7FFFFFFF + (x>=0?0.5F:-0.5F))
-
-
-void dst_8(Int32 vec[])
-{
-
-    Int32 temp1;
-    Int32 temp2;
-    Int32 temp3;
-    Int32 temp4;
-    Int32 temp5;
-    Int32 temp6;
-    Int32 temp7;
-    Int32 tmp_a;
-    Int32 tmp_aa;
-    Int32 tmp_b;
-    Int32 tmp_bb;
-    Int32 tmp_c;
-    Int32 tmp_cc;
-    Int32 tmp_d;
-    Int32 tmp_dd;
-
-    temp1 = fxp_mul32_by_16(vec[1], Qfmt15(0.50979557910416F));         /* (1/(2*cos(  phi)));*/
-    temp2 = fxp_mul32_by_16(vec[2], Qfmt15(0.54119610014620F));         /* (1/(2*cos(2*phi)));*/
-    temp3 = fxp_mul32_by_16(vec[3], Qfmt15(0.60134488693505F));         /* (1/(2*cos(3*phi)));*/
-    temp5 = fxp_mul32_by_16(vec[5], Qfmt15(0.89997622313642F));         /* (1/(2*cos(5*phi)));*/
-    temp6 = fxp_mul32_by_16(vec[6] << 1, Qfmt15(0.65328148243819F));        /* (1/(2*cos(6*phi)));*/
-    temp7 = vec[7] + fxp_mul32_Q31(vec[7], Qfmt31(0.56291544774152F));          /* (1/(2*cos(7*phi)));*/
-
-    /*  even  */
-    tmp_a = fxp_mul32_Q31((temp2 + temp6) << 1, Qfmt31(0.70710678118655F));
-    tmp_b = (temp2 - temp6) + tmp_a;
-
-    temp4 = fxp_mul32_by_16(vec[4], Qfmt15(0.70710678118655F));
-    vec[0] =   tmp_a + temp4;
-    vec[1] =   tmp_b + temp4;
-    vec[2] =   tmp_b - temp4;
-    vec[3] =   tmp_a - temp4;
-
-
-    /* odd */
-
-    tmp_a  = fxp_mul32_by_16((temp1 + temp7) << 1, Qfmt15(0.54119610014620F));  /* (1/(2*cos(2*phi)));  */
-    tmp_aa = (temp1 - temp7);
-    tmp_bb = (temp5 - temp3);
-    temp5  = fxp_mul32_Q29((temp5 + temp3), Qfmt(1.30656296487638F));   /* (1/(2*cos(6*phi)));  */
-
-
-    tmp_c  = fxp_mul32_by_16((tmp_a + temp5) << 1, Qfmt15(0.70710678118655F));
-    tmp_cc =  tmp_a - temp5;
-
-    tmp_d  = fxp_mac32_by_16((tmp_aa - tmp_bb) << 1, Qfmt15(0.70710678118655F), tmp_c);
-    tmp_dd = (tmp_aa + tmp_bb);
-
-    tmp_dd +=  tmp_c;
-    tmp_a   =  tmp_d  + tmp_cc;
-    vec[5]  =  tmp_a  - vec[2];
-    vec[2] +=  tmp_a;
-
-    temp5   =  tmp_dd + tmp_cc;
-
-    vec[4]  =  temp5  - vec[3];
-    vec[3] +=  temp5;
-    vec[7]  =  tmp_c  - vec[0];
-    vec[0] +=  tmp_c;
-    vec[6]  =  tmp_d  - vec[1];
-    vec[1] +=  tmp_d;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/dst8.h b/media/libstagefright/codecs/aacdec/dst8.h
deleted file mode 100644
index 2738e80..0000000
--- a/media/libstagefright/codecs/aacdec/dst8.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/dst8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef DST8_H
-#define DST8_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void dst_8(Int32 vec[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* DST8_H */
diff --git a/media/libstagefright/codecs/aacdec/e_adif_const.h b/media/libstagefright/codecs/aacdec/e_adif_const.h
deleted file mode 100644
index 08b5415..0000000
--- a/media/libstagefright/codecs/aacdec/e_adif_const.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_ADIF_Const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for ADIF header related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_ADIF_CONST_H
-#define E_ADIF_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /*
-     * audio data interchange format header
-     */
-    LEN_ADIF_ID     = (32 / 8),
-    LEN_COPYRT_PRES = 1,
-    LEN_COPYRT_ID   = (72 / 8),
-    LEN_ORIG        = 1,
-    LEN_HOME        = 1,
-    LEN_BS_TYPE     = 1,
-    LEN_BIT_RATE    = 23,
-    LEN_NUM_PCE     = 4,
-    LEN_ADIF_BF     = 20
-
-} eADIF_Const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_blockswitching.h b/media/libstagefright/codecs/aacdec/e_blockswitching.h
deleted file mode 100644
index bf6ad15..0000000
--- a/media/libstagefright/codecs/aacdec/e_blockswitching.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_BlockSwitching.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for BlockSwitching related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_BLOCK_SWITCHING_H
-#define E_BLOCK_SWITCHING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /*
-     * block switching
-     */
-    LN          = 2048,
-    SN          = 256,
-    LN2         = LN / 2,
-    SN2         = SN / 2,
-    LN4         = LN / 4,
-    SN4         = SN / 4,
-    NSHORT      = LN / SN,
-    MAX_SBK     = NSHORT,
-    MAX_WIN     = MAX_SBK,
-
-    ONLY_LONG_WINDOW    = 0,
-    LONG_START_WINDOW,
-    EIGHT_SHORT_WINDOW,
-    LONG_STOP_WINDOW,
-    NUM_WIN_SEQ,
-
-    WLONG       = ONLY_LONG_WINDOW,
-    WSTART,
-    WSHORT,
-    WSTOP,
-
-    MAXBANDS        = 16 * NSHORT,  /* max number of scale factor bands */
-    MAXFAC      = 121,      /* maximum scale factor */
-    MIDFAC      = (MAXFAC - 1) / 2,
-    SF_OFFSET       = 100       /* global gain must be positive */
-} eBlockSwitching;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_coupling_mode.h b/media/libstagefright/codecs/aacdec/e_coupling_mode.h
deleted file mode 100644
index 68244bb..0000000
--- a/media/libstagefright/codecs/aacdec/e_coupling_mode.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_coupling_mode.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_COUPLING_MODE_H
-#define E_COUPLING_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    COUPLING_OFF,
-    COUPLING_LEVEL,
-    COUPLING_BAL
-}
-COUPLING_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_elementid.h b/media/libstagefright/codecs/aacdec/e_elementid.h
deleted file mode 100644
index 5f84643..0000000
--- a/media/libstagefright/codecs/aacdec/e_elementid.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./include/e_BLOCKTYPE.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for BlockType related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_ELEMENTID_H
-#define E_ELEMENTID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /* sfb 40, coef 672, pred bw of 15.75 kHz at 48 kHz
-     * this is also the highest number of bins used
-     * by predictor for any sampling rate
-     */
-    MAX_PRED_SFB    = 40,   /* 48 kHz only, now obsolete */
-    MAX_PRED_BINS   = 672,
-
-    ID_SCE      = 0,
-    ID_CPE,
-    ID_CCE,
-    ID_LFE,
-    ID_DSE,
-    ID_PCE,
-    ID_FIL,
-    ID_END
-}
-ElementId;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_huffmanconst.h b/media/libstagefright/codecs/aacdec/e_huffmanconst.h
deleted file mode 100644
index 5d0e628..0000000
--- a/media/libstagefright/codecs/aacdec/e_huffmanconst.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_HuffmanConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Huffman related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_HUFFMAN_CONST_H
-#define E_HUFFMAN_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /*
-     * specify huffman tables as signed (1) or unsigned (0)
-     */
-    HUF1SGN     = 1,
-    HUF2SGN     = 1,
-    HUF3SGN     = 0,
-    HUF4SGN     = 0,
-    HUF5SGN     = 1,
-    HUF6SGN     = 1,
-    HUF7SGN     = 0,
-    HUF8SGN     = 0,
-    HUF9SGN     = 0,
-    HUF10SGN        = 0,
-    HUF11SGN        = 0,
-
-    ZERO_HCB        = 0,
-    BY4BOOKS        = 4,
-    ESCBOOK     = 11,
-    NSPECBOOKS      = ESCBOOK + 1,
-    BOOKSCL     = NSPECBOOKS,
-    NBOOKS      = NSPECBOOKS + 1,
-    INTENSITY_HCB2  = 14,
-    INTENSITY_HCB   = 15,
-    NOISE_HCB       = 13,
-    NOISE_HCB2      = 113,
-
-    NOISE_PCM_BITS      = 9,
-    NOISE_PCM_OFFSET    = (1 << (NOISE_PCM_BITS - 1)),
-
-    NOISE_OFFSET        = 90,
-
-    LONG_SECT_BITS  = 5,
-    SHORT_SECT_BITS = 3
-} eHuffmanConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_infoinitconst.h b/media/libstagefright/codecs/aacdec/e_infoinitconst.h
deleted file mode 100644
index 788b5e9..0000000
--- a/media/libstagefright/codecs/aacdec/e_infoinitconst.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_infoinitConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Infoinit related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_INFOINIT_CONST_H
-#define E_INFOINIT_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "chans.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /* block switch windows for single channels or channel pairs */
-    Winds   = Chans,
-
-    /* average channel block length, bytes */
-    Avjframe    = 341,
-
-    TEXP    = 128,      /* size of exp cache table */
-    MAX_IQ_TBL  = 128,      /* size of inv quant table */
-    MAXFFT  = LN4
-
-} infoinitConst;
-
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_invf_mode.h b/media/libstagefright/codecs/aacdec/e_invf_mode.h
deleted file mode 100644
index 57b3281..0000000
--- a/media/libstagefright/codecs/aacdec/e_invf_mode.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_invf_mode.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_INVF_MODE_H
-#define E_INVF_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    INVF_OFF,
-    INVF_LOW_LEVEL,
-    INVF_MID_LEVEL,
-    INVF_HIGH_LEVEL,
-
-    INVF_NO_OVERRIDE
-}
-INVF_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_maskstatus.h b/media/libstagefright/codecs/aacdec/e_maskstatus.h
deleted file mode 100644
index 010b6f8..0000000
--- a/media/libstagefright/codecs/aacdec/e_maskstatus.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-   Pathname: ./include/e_MaskStatus.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file gives the enum of mask_present value used in getmask.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_MASKSTATUS_H
-#define E_MASKSTATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-enum
-{
-    MASK_NOT_PRESENT,
-    MASK_FROM_BITSTREAM,
-    MASK_ALL_FRAME,
-    MASK_ERROR
-};
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_mp4ff_const.h b/media/libstagefright/codecs/aacdec/e_mp4ff_const.h
deleted file mode 100644
index 1006406..0000000
--- a/media/libstagefright/codecs/aacdec/e_mp4ff_const.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_MP4FF_const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file enums the constants used by MP4FF header
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_MP4FF_CONST_H
-#define E_MP4FF_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    LEN_OBJ_TYPE = 5,
-    LEN_SAMP_RATE_IDX = 4,
-    LEN_SAMP_RATE   = 24,
-    LEN_CHAN_CONFIG = 4,
-    LEN_SYNC_EXTENSION_TYPE = 11,
-    LEN_FRAME_LEN_FLAG = 1,
-    LEN_DEPEND_ON_CORE = 1,
-    LEN_CORE_DELAY = 14,
-    LEN_EXT_FLAG = 1,
-    LEN_EP_CONFIG = 2,
-    LEN_LAYER_NUM = 3,
-    LEN_SUB_FRAME = 5,
-    LEN_LAYER_LEN = 11,
-    LEN_SECT_RES_FLAG = 1,
-    LEN_SCF_RES_FLAG = 1,
-    LEN_SPEC_RES_FLAG = 1,
-    LEN_EXT_FLAG3 = 1
-} eMP4FF_const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_progconfigconst.h b/media/libstagefright/codecs/aacdec/e_progconfigconst.h
deleted file mode 100644
index b5fdc08..0000000
--- a/media/libstagefright/codecs/aacdec/e_progconfigconst.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_ProgConfigConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for ProgConfig related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_PROG_CONFIG_CONST_H
-#define E_PROG_CONFIG_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    /*
-     * Program Configuration
-     */
-    Main_Profile    = 0,
-    LC_Profile      = 1,
-
-    Fs_48       = 3,
-    Fs_44       = 4,
-    Fs_32       = 5,
-
-    LEN_PROFILE     = 2,
-    LEN_SAMP_IDX    = 4,
-    LEN_NUM_ELE     = 4,
-    LEN_NUM_LFE     = 2,
-    LEN_NUM_DAT     = 3,
-    LEN_NUM_CCE     = 4,
-    LEN_MIX_PRES    = 1,
-    LEN_MMIX_IDX    = 2,
-    LEN_PSUR_ENAB   = 1,
-    LEN_ELE_IS_CPE  = 1,
-    LEN_IND_SW_CCE  = 1,
-    LEN_COMMENT_BYTES   = 8
-
-} eProgConfigConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h b/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h
deleted file mode 100644
index a460d13..0000000
--- a/media/libstagefright/codecs/aacdec/e_rawbitstreamconst.h
+++ /dev/null
@@ -1,130 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-   Pathname: e_RawBitstreamConst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for the Raw Bitstream related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_RAW_BITSTREAM_CONST_H
-#define E_RAW_BITSTREAM_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    LEN_SE_ID       = 3,
-    LEN_TAG     = 4,
-    LEN_COM_WIN     = 1,
-    LEN_ICS_RESERV  = 1,
-    LEN_WIN_SEQ     = 2,
-    LEN_WIN_SH      = 1,
-    LEN_MAX_SFBL    = 6,
-    LEN_MAX_SFBS    = 4,
-    LEN_CB          = 4,
-    LEN_SCL_PCM     = 8,
-    LEN_PRED_PRES   = 1,
-    LEN_PRED_RST    = 1,
-    LEN_PRED_RSTGRP = 5,
-    LEN_PRED_ENAB   = 1,
-    LEN_MASK_PRES   = 2,
-    LEN_MASK        = 1,
-    LEN_PULSE_PRES  = 1,
-    LEN_TNS_PRES    = 1,
-    LEN_GAIN_PRES   = 1,
-
-    LEN_PULSE_NPULSE    = 2,
-    LEN_PULSE_ST_SFB    = 6,
-    LEN_PULSE_POFF      = 5,
-    LEN_PULSE_PAMP      = 4,
-    NUM_PULSE_LINES     = 4,
-    PULSE_OFFSET_AMP    = 4,
-
-    LEN_IND_CCE_FLG = 1,
-    LEN_NCC         = 3,
-    LEN_IS_CPE      = 1,
-    LEN_CC_LR       = 1,
-    LEN_CC_DOM      = 1,
-    LEN_CC_SGN      = 1,
-    LEN_CCH_GES     = 2,
-    LEN_CCH_CGP     = 1,
-
-    LEN_D_ALIGN     = 1,
-    LEN_D_CNT       = 8,
-    LEN_D_ESC       = 8,
-    LEN_F_CNT       = 4,
-    LEN_F_ESC       = 8,
-    LEN_BYTE        = 8,
-    LEN_PAD_DATA    = 8,
-
-    LEN_PC_COMM     = 9
-
-} eRawBitstreamConst;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_element_id.h b/media/libstagefright/codecs/aacdec/e_sbr_element_id.h
deleted file mode 100644
index 1b021ff..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_element_id.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_element_id.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_ELEMENT_ID_H
-#define E_SBR_ELEMENT_ID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    SBR_ID_SCE = 0,
-    SBR_ID_CPE
-}
-SBR_ELEMENT_ID;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_error.h b/media/libstagefright/codecs/aacdec/e_sbr_error.h
deleted file mode 100644
index b6c8a90..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_error.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_error.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_ERROR_H
-#define E_SBR_ERROR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define HANDLE_ERROR_INFO Int32
-#define noError 0
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef enum
-{
-    SBRDEC_OK = 0,
-    SBRDEC_NOSYNCH,
-    SBRDEC_ILLEGAL_PROGRAM,
-    SBRDEC_ILLEGAL_TAG,
-    SBRDEC_ILLEGAL_CHN_CONFIG,
-    SBRDEC_ILLEGAL_SECTION,
-    SBRDEC_ILLEGAL_SCFACTORS,
-    SBRDEC_ILLEGAL_PULSE_DATA,
-    SBRDEC_MAIN_PROFILE_NOT_IMPLEMENTED,
-    SBRDEC_GC_NOT_IMPLEMENTED,
-    SBRDEC_ILLEGAL_PLUS_ELE_ID,
-    SBRDEC_CREATE_ERROR,
-    SBRDEC_NOT_INITIALIZED,
-    SBRDEC_TOO_MANY_SBR_ENVELOPES,
-    SBRDEC_INVALID_BITSTREAM
-}
-SBR_ERROR;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_header_status.h b/media/libstagefright/codecs/aacdec/e_sbr_header_status.h
deleted file mode 100644
index 5b2a43f..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_header_status.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_header_status.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_HEADER_STATUS_H
-#define E_SBR_HEADER_STATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    HEADER_OK,
-    HEADER_RESET,
-    HEADER_NOT_INITIALIZED
-}
-SBR_HEADER_STATUS;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_master_status.h b/media/libstagefright/codecs/aacdec/e_sbr_master_status.h
deleted file mode 100644
index 16e43a4..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_master_status.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_master_status.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_MASTER_STATUS_H
-#define E_SBR_MASTER_STATUS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    MASTER_OK,
-    MASTER_RESET
-}
-SBR_MASTER_STATUS;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h b/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h
deleted file mode 100644
index d9f8669..0000000
--- a/media/libstagefright/codecs/aacdec/e_sbr_sync_state.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sbr_sync_state.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SBR_SYNC_STATE_H
-#define E_SBR_SYNC_STATE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    SBR_NOT_INITIALIZED,
-    UPSAMPLING,
-    SBR_ACTIVE
-}
-SBR_SYNC_STATE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_sr_mode.h b/media/libstagefright/codecs/aacdec/e_sr_mode.h
deleted file mode 100644
index eff00dd..0000000
--- a/media/libstagefright/codecs/aacdec/e_sr_mode.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: e_sr_mode.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_SR_MODE_H
-#define E_SR_MODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    SINGLE_RATE = 1,
-    UP_BY_2
-}
-SR_MODE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h b/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h
deleted file mode 100644
index 83cccce..0000000
--- a/media/libstagefright/codecs/aacdec/e_tmp4audioobjecttype.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_tMP4AudioObjectType.h
-
- This file contains enumerated types for MP4 Audio Object Types, as defined
- in ISO/IEC 14496-3, AMMENDMENT 1 Dated 2000-09-15
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_TMP4AUDIOOBJECTTYPE_H
-#define E_TMP4AUDIOOBJECTTYPE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    typedef enum eMP4AudioObjectType
-    {
-        MP4AUDIO_NULL            =  0, /*                                       */
-        MP4AUDIO_AAC_MAIN        =  1, /*                                       */
-        MP4AUDIO_AAC_LC          =  2, /* LC = Low Complexity                   */
-        MP4AUDIO_AAC_SSR         =  3, /* SSR = Scalable Sampling Rate          */
-        MP4AUDIO_LTP             =  4, /* LTP = Long Term Prediction            */
-        MP4AUDIO_SBR             =  5, /* SBR = Spectral Band Replication       */
-        MP4AUDIO_AAC_SCALABLE    =  6, /* scales both bitrate and sampling rate */
-        MP4AUDIO_TWINVQ          =  7, /* low bit rate                          */
-        MP4AUDIO_CELP            =  8,
-        MP4AUDIO_HVXC            =  9,
-        /* 10 is reserved                        */
-        /* 11 is reserved                        */
-        MP4AUDIO_TTSI            = 12,
-        /* 13-16 are synthesis and MIDI types    */
-        MP4AUDIO_ER_AAC_LC       = 17, /*                                       */
-        /* 18 is reserved                        */
-        MP4AUDIO_ER_AAC_LTP      = 19, /*                                       */
-        MP4AUDIO_ER_AAC_SCALABLE = 20, /*                                       */
-        MP4AUDIO_ER_TWINVQ       = 21, /*                                       */
-        MP4AUDIO_ER_BSAC         = 22, /*                                       */
-        MP4AUDIO_ER_AAC_LD       = 23, /*                                       */
-        MP4AUDIO_ER_CELP         = 24, /*                                       */
-        MP4AUDIO_ER_HVXC         = 25, /*                                       */
-        MP4AUDIO_ER_HILN         = 26, /*                                       */
-        MP4AUDIO_PARAMETRIC      = 27, /*                                       */
-        MP4AUDIO_PS              = 29  /*  Explicit Parametric Stereo           */
-
-    } tMP4AudioObjectType;
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    /* Should not be any function declarations in this file */
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* E_TMP4AUDIOOBJECTTYPE_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/e_tns_const.h b/media/libstagefright/codecs/aacdec/e_tns_const.h
deleted file mode 100644
index 157d471..0000000
--- a/media/libstagefright/codecs/aacdec/e_tns_const.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Pathname: ./include/e_TNS_Const.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for TNS related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_TNS_CONST_H
-#define E_TNS_CONST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    TNS_MAX_BANDS = 49,
-    TNS_MAX_ORDER = 20,
-    TNS_MAX_WIN   =  8,
-    TNS_MAX_FILT  =  3,
-    Q_SPEC        = 11,
-    Q_LPC         = 19
-
-} eTNS_Const;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_window_sequence.h b/media/libstagefright/codecs/aacdec/e_window_sequence.h
deleted file mode 100644
index c4b933e..0000000
--- a/media/libstagefright/codecs/aacdec/e_window_sequence.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/e_WINDOW_SEQUENCE.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Window Sequence related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_WINDOW_SEQUENCE_H
-#define E_WINDOW_SEQUENCE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    ONLY_LONG_SEQUENCE,
-    LONG_START_SEQUENCE,
-    EIGHT_SHORT_SEQUENCE,
-    LONG_STOP_SEQUENCE,
-    NUM_WINDOW_SEQUENCE,
-    ENSURE_WINDOW_SEQUENCE_INT_SIZE = 0x7FFFFF
-}
-WINDOW_SEQUENCE;
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/e_window_shape.h b/media/libstagefright/codecs/aacdec/e_window_shape.h
deleted file mode 100644
index 3eca438..0000000
--- a/media/libstagefright/codecs/aacdec/e_window_shape.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: e_Window_shape.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- enum for Window Sequence related constants
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef E_WINDOW_SHAPE_H
-#define E_WINDOW_SHAPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-    SINE_WINDOW = 0,
-    KAISER_BESSEL_WINDOW,
-    NUM_WINDOW_SHAPES,
-    ENSURE_WINDOW_SHAPE_INT_SIZE = 0x7FFFFF
-}
-WINDOW_SHAPE;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp b/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp
deleted file mode 100644
index 778c88c..0000000
--- a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.cpp
+++ /dev/null
@@ -1,789 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/esc_iquant_scaling.c
- Funtions:  esc_iquant_scaling
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from esc_iquant_fxp.c code
-
- Description:  Eliminated unused variables to avoid warnings, changed header
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    quantSpec[] = array of quantized compressed spectral coefficients, of
-                  data type Int and length sfbWidth.
-
-    sfbWidth    = number of array elements in quantSpec and the output array
-                  coef, data type Int.
-
-    coef[]      = output array of uncompressed coefficients, stored in a
-                  variable Q format, depending on the maximum value found
-                  for the group, array of Int32, length sfbWdith to be
-                  overwritten.
-
-    QFormat     = the output Q format for the array coef[].
-
-
-    scale       = scaling factor after separating power of 2 factor out from
-                  0.25*(sfb_scale - 100), i.e., 0.25*sfb_scale.
-
-    maxInput    = maximum absolute value of quantSpec.
-
- Local Stores/Buffers/Pointers Needed: None.
-
- Global Stores/Buffers/Pointers Needed:
-    inverseQuantTable = lookup table of const integer values to the one third
-                power stored in Q27 format, in file iquant_table.c, const
-                array of UInt32, of size 1025.
-
- Outputs: None
-
- Pointers and Buffers Modified:
-    coef[] contents are overwritten with the uncompressed values from
-    quantSpec[]
-
-
-
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs the inverse quantization of the spectral coeficients
- read from huffman decoding. It takes each input array value to the four
- thirds power, then scales it according to the scaling factor input argument
- ,and stores the result in the output array in a variable Q format
- depending upon the maximum input value found.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not have static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-   of moving pictures and associated audio information - Part 7: Advanced
-   Audio Coding (AAC)", Section 10.3, "Decoding process", page 43.
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    maxInput = 0;
-
-    FOR (i = sfbWidth - 1; i >= 0; i--)
-        x = quantSpec[i];
-
-        IF ( x >= 0)
-            absX = x;
-        ELSE
-            absX = -x;
-        ENDIF
-
-        coef[i] = absX;
-
-        IF (absX > maxInput)
-            maxInput = absX;
-        ENDIF
-    ENDFOR
-
-    IF (maxInput == 0)
-        *pQFormat = QTABLE;
-    ELSE
-        temp = inverseQuantTable[(maxInput >> ORDER) + 1];
-
-        temp += ((1 << (QTABLE))-1);
-
-        temp >>= (QTABLE-1);
-
-        temp *= maxInput;
-
-        binaryDigits = 0;
-        WHILE( temp != 0)
-            temp >>= 1;
-            binaryDigits++;
-        WEND
-
-        IF (binaryDigits < (SIGNED32BITS - QTABLE))
-            binaryDigits = SIGNED32BITS - QTABLE;
-        ENDIF
-
-        *pQFormat = SIGNED32BITS - binaryDigits;
-        shift = QTABLE - *pQFormat;
-
-        IF (maxInput < TABLESIZE)
-            FOR (i = sfbWidth - 1; i >= 0; i--)
-                x = quantSpec[i];
-
-                absX = coef[i];
-
-                tmp_coef = x * (inverseQuantTable[absX] >> shift);
-
-                b_low  = (tmp_coef & 0xFFFF);
-                b_high = (tmp_coef >> 16);
-
-                mult_low  = ( (UInt32) b_low * scale );
-                mult_high = ( (Int32) b_high * scale );
-
-                mult_low >>= 16;
-
-                coef[i]  = (Int32) (mult_high + mult_low);
-
-            ENDFOR
-        ELSE
-            FOR (i = sfbWidth; i >= 0 ; i--)
-                x    = quantSpec[i];
-                absX = coef[i];
-
-                IF (absX < TABLESIZE)
-                    tmp_coef = x * (inverseQuantTable[absX] >> shift);
-                ELSE
-                    index = absX >> ORDER;
-                    w1 = inverseQuantTable[index];
-
-                    approxOneThird = (w1 * FACTOR) >> shift;
-
-
-                    x1 = index * SPACING;
-                    w2 = inverseQuantTable[index+1];
-
-                    deltaOneThird = (w2 - w1) * (absX - x1);
-
-                    deltaOneThird >>= (shift + ORDER - 1);
-
-                    tmp_coef = x * (approxOneThird + deltaOneThird);
-
-                ENDIF
-
-                b_low  = (mult_high & 0xFFFF);
-                b_high = (mult_high >> 16);
-
-                mult_low  = ( (UInt32) b_low * scale );
-                mult_high = ( (Int32) b_high * scale );
-
-                mult_low >>= 16;
-
-                coef[i]  = (Int32) (mult_high + mult_low);
-
-            ENDFOR
-        ENDIF
-    ENDIF
-
-    RETURN
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "iquant_table.h"
-#include "esc_iquant_scaling.h"
-#include "aac_mem_funcs.h"         /* For pv_memset                         */
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*
- * Read further on what order is.
- * Note: If ORDER is not a multiple of 3, FACTOR is not an integer.
- * Note: Portions of this function assume ORDER is 3, and so does the table
- *       in iquant_table.c
- */
-#define ORDER        (3)
-/*
- * For input values > TABLESIZE, multiply by FACTOR to get x ^ (1/3)
- * FACTOR = 2 ^ (ORDER/3)
- */
-#define FACTOR       (2)
-
-/*
- * This is one more than the range of expected inputs.
- */
-#define INPUTRANGE   (8192)
-
-/*
- * SPACING is 2 ^ ORDER, and is the spacing between points when in the
- * interpolation range.
- */
-#define SPACING      (1<<ORDER)
-
-/*
- * The actual table size is one more than TABLESIZE, to allow for
- * interpolation for numbers near 8191
- */
-#define TABLESIZE    (INPUTRANGE/SPACING)
-
-/*
- * Format the table is stored in.
- */
-#define QTABLE       (27)
-
-/*
- * Number of bits for data in a signed 32 bit integer.
- */
-#define SIGNED32BITS  (31)
-
-/*
- * Round up value for intermediate values obtained from the table
- */
-#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1)
-
-#define     MASK_LOW16  0xffff
-#define     UPPER16     16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
- * Processing in this function is performed in these steps:
- *
- * 1) Find the overall Q format for the entire group of inputs. This consists
- *    of:
- *    a) Finding the maximum input
- *    b) estimate the maximum output
- *    c) Using the table, get max ^ (4/3), taking into account the table is
- *       in q format.
- * 2) For each array element, see if the value is directly inside the table.
- *    a) If yes, just multiply by table value by itself, then shift as
- *       appropriate.
- *    b) If no, get an approximation (described below) for x ^ (1/3) by linearly
- *       interpolating using lower values in the table, then multiply by a
- *       correction factor, then multiply by x (see below).
- *
- * It more accurate to interpolate x ^ (1/3) then x ^ (4/3), so that is stored
- * in the lookup table. For values not in the table, interpolation is used:
- *
- *  We want y = x ^ (4/3) = x * (x ^ (1/3))
- *
- *  Let     x = w * (2 ^ m)  where m is a constant, = ORDER
- *
- *  then     x ^ (1/3) = w ^ (1/3) * (2 ^ (m/3))
- *
- *  w is most likely not an integer, so an interpolation with floor(w) and
- *  ceil(w) can be performed to approximate w ^ (1/3) by getting values out of
- *  the table. Then to get x ^ (1/3), multiply by FACTOR. If m = 0, 3, 6,
- *  then FACTOR is a simple power of 2, so a shift can do the job.
- *
- *  The actual code employs some more tricks to speed things up, and because
- *  the table is stored in Q format.
- *
- *  Rather than saving the sign of each input, the unsigned value of
- *  abs(x) ^ (1/3) is multiplied by the signed input value.
- */
-
-
-
-#if ( defined(_ARM) || defined(_ARM_V4))
-
-/*
- *  Absolute value for 16 bit-numbers
- */
-__inline Int32 abs2(Int32 x)
-{
-    Int32 z;
-    /*
-        z = x - (x<0);
-        x = z ^ sign(z)
-     */
-    __asm
-    {
-        sub  z, x, x, lsr #31
-        eor  x, z, z, asr #31
-    }
-    return (x);
-}
-
-
-#define pv_abs(x)   abs2(x)
-
-
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-
-/*
- *  Absolute value for 16 bit-numbers
- */
-__inline Int32 abs2(Int32 x)
-{
-    register Int32 z;
-    register Int32 y;
-    register Int32 ra = x;
-    asm volatile(
-        "sub  %0, %2, %2, lsr #31\n\t"
-        "eor  %1, %0, %0, asr #31"
-    : "=&r*i"(z),
-        "=&r*i"(y)
-                : "r"(ra));
-
-    return (y);
-}
-
-#define pv_abs(x)   abs2(x)
-
-
-#else
-
-#define pv_abs(x)   ((x) > 0)? (x) : (-x)
-
-#endif
-
-
-
-
-
-void esc_iquant_scaling(
-    const Int16     quantSpec[],
-    Int32         coef[],
-    const Int     sfbWidth,
-    Int const      QFormat,
-    UInt16        scale,
-    Int           maxInput)
-{
-    Int    i;
-    Int    x;
-    Int    y;
-    Int    index;
-    Int    shift;
-    UInt   absX;
-    UInt32 w1, w2;
-    UInt32 deltaOneThird;
-    UInt32 x1;
-    UInt32 approxOneThird;
-    Int32   mult_high;
-
-
-#if ( defined(_ARM) || defined(_ARM_V4))
-
-    {
-        Int32   *temp;
-        Int32   R12, R11, R10, R9;
-
-        deltaOneThird = sizeof(Int32) * sfbWidth;
-        temp = coef;
-
-        // from standard library call for __rt_memset
-        __asm
-        {
-            MOV     R12, #0x0
-            MOV     R11, #0x0
-            MOV     R10, #0x0
-            MOV     R9, #0x0
-            SUBS    deltaOneThird, deltaOneThird, #0x20
-loop:
-            STMCSIA temp!, {R12, R11, R10, R9}
-            STMCSIA temp!, {R12, R11, R10, R9}
-            SUBCSS  deltaOneThird, deltaOneThird, #0x20
-            BCS     loop
-
-            MOVS    deltaOneThird, deltaOneThird, LSL #28
-            STMCSIA temp!, {R12, R11, R10, R9}
-            STMMIIA temp!, {R12, R11}
-        }
-    }
-
-#else
-    pv_memset(coef, 0, sizeof(Int32) * sfbWidth);
-#endif
-
-    if (maxInput > 0)
-    {
-
-        shift = QTABLE - QFormat;
-
-        if (scale != 0)
-        {
-            if (maxInput < TABLESIZE)
-            {
-
-                for (i = sfbWidth - 1; i >= 0; i -= 4)
-                {
-                    x = quantSpec[i];
-                    y = quantSpec[i-1];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        mult_high = (x * (inverseQuantTable[absX] >> shift));
-                        coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
-                    }
-
-                    if (y)
-                    {
-                        absX = pv_abs(y);
-                        mult_high = y * (inverseQuantTable[absX] >> shift);
-                        coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
-                    }
-
-                    x = quantSpec[i-2];
-                    y = quantSpec[i-3];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        mult_high = x * (inverseQuantTable[absX] >> shift);
-                        coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
-                    }
-
-                    if (y)
-                    {
-                        absX = pv_abs(y);
-                        mult_high = y * (inverseQuantTable[absX] >> shift);
-                        coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
-                    }
-                } /* end for (i = sfbWidth - 1; i >= 0; i--) */
-
-            } /* end if (maxInput < TABLESIZE)*/
-
-            else /* maxInput >= TABLESIZE) */
-            {
-                for (i = sfbWidth - 1; i >= 0; i -= 4)
-                {
-                    x    = quantSpec[i];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
-
-                        }
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i] = fxp_mul32_by_16(mult_high, scale) << 1;
-
-                        }
-                    } /* if(x) */
-
-
-                    x    = quantSpec[i-1];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = (x * (inverseQuantTable[absX] >> shift));
-                            coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
-
-                        }
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-1] = fxp_mul32_by_16(mult_high, scale) << 1;
-                        }
-                    } /* if(x) */
-
-                    x    = quantSpec[i-2];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
-                        }
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-2] = fxp_mul32_by_16(mult_high, scale) << 1;
-                        }
-                    } /* if(x) */
-
-                    x    = quantSpec[i-3];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
-
-                        }
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-3] = fxp_mul32_by_16(mult_high, scale) << 1;
-
-                        }
-                    } /* if(x) */
-
-                }  /* end for (i = sfbWidth - 1; i >= 0; i--) */
-            } /* end else for if (maxInput < TABLESIZE)*/
-        }
-        else /* scale == 0 */
-        {
-            if (maxInput < TABLESIZE)
-            {
-                for (i = sfbWidth - 1; i >= 0; i -= 4)
-                {
-                    x = quantSpec[i];
-                    y = quantSpec[i-1];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        mult_high = x * (inverseQuantTable[absX] >> shift);
-                        coef[i] = mult_high >> 1;
-                    }
-
-                    if (y)
-                    {
-                        absX = pv_abs(y);
-                        mult_high = y * (inverseQuantTable[absX] >> shift);
-                        coef[i-1] = mult_high >> 1;
-                    }
-
-                    x = quantSpec[i-2];
-                    y = quantSpec[i-3];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        mult_high = x * (inverseQuantTable[absX] >> shift);
-                        coef[i-2] = mult_high >> 1;
-                    }
-
-                    if (y)
-                    {
-                        absX = pv_abs(y);
-                        mult_high = y * (inverseQuantTable[absX] >> shift);
-                        coef[i-3] = mult_high >> 1;
-                    }
-                }
-
-            } /* end if (maxInput < TABLESIZE)*/
-
-            else /* maxInput >= TABLESIZE) */
-            {
-                for (i = sfbWidth - 1; i >= 0; i -= 4)
-                {
-                    x    = quantSpec[i];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i] = (mult_high >> 1);
-                        } /* end if (absX < TABLESIZE) */
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i] = (mult_high >> 1);
-                        }
-                    } /* if(x) */
-
-                    x    = quantSpec[i-1];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i-1] = (mult_high >> 1);
-                        } /* end if (absX < TABLESIZE) */
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-1] = (mult_high >> 1);
-                        }
-                    } /* if(x) */
-
-                    x    = quantSpec[i-2];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i-2] = (mult_high >> 1);
-                        } /* end if (absX < TABLESIZE) */
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-2] = (mult_high >> 1);
-                        }
-                    } /* if(x) */
-
-                    x    = quantSpec[i-3];
-                    if (x)
-                    {
-                        absX = pv_abs(x);
-                        if (absX < TABLESIZE)
-                        {
-                            mult_high = x * (inverseQuantTable[absX] >> shift);
-                            coef[i-3] = (mult_high >> 1);
-                        } /* end if (absX < TABLESIZE) */
-                        else
-                        {
-                            index = absX >> ORDER;
-                            w1 = inverseQuantTable[index];
-                            w2 = inverseQuantTable[index+1];
-                            approxOneThird = (w1 * FACTOR) >> shift;
-                            x1 = index << ORDER;
-                            deltaOneThird = (w2 - w1) * (absX - x1);
-                            deltaOneThird >>= (shift + 2);
-                            mult_high = x * (approxOneThird + deltaOneThird);
-                            coef[i-3] = (mult_high >> 1);
-                        }
-
-                    } /* if(x) */
-
-                }  /* end for (i = sfbWidth - 1; i >= 0; i--) */
-
-            } /* end else for if (maxInput < TABLESIZE)*/
-
-        } /* end else for if(scale!=0) */
-
-    }  /* end else for if(maxInput == 0) */
-
-} /* end esc_iquant_fxp */
-
-
diff --git a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h b/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h
deleted file mode 100644
index a846b9f..0000000
--- a/media/libstagefright/codecs/aacdec/esc_iquant_scaling.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/esc_iquant_scaling.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for esc_iquant_scaling.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef ESC_IQUANT_SCALING_H
-#define ESC_IQUANT_SCALING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    void esc_iquant_scaling(
-        const Int16   quantSpec[],
-        Int32       coef[],
-        const Int   sfbWidth,
-        Int  const pQFormat,
-        UInt16      scale,
-        Int           maxInput);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* ESC_IQUANT_SCALING_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/extractframeinfo.cpp b/media/libstagefright/codecs/aacdec/extractframeinfo.cpp
deleted file mode 100644
index 571cc98..0000000
--- a/media/libstagefright/codecs/aacdec/extractframeinfo.cpp
+++ /dev/null
@@ -1,487 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Filename: extractframeInfo.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:   hBitBuf      - bitbuffer handle
-              v_frame_info - pointer to memorylocation where the frame-info will
-                             be stored.
-
- Return:     none.
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-Extracts a frame_info vector from control data read from the bitstream.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "extractframeinfo.h"
-#include    "buf_getbits.h"
-#include    "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*
- *  (int) ceil (log (bs_num_env + 1) / log (2))
- *  ceil(log([0:5]+1)/log(2))
- */
-
-const Int32 bs_pointer_bits_tbl[MAX_ENVELOPES + 1] = { 0, 1, 2, 2, 3, 3};
-
-/*
- *  (int)((float)numTimeSlots/bs_num_env + 0.5f)
- *  floor(16./[0:5] + 0.5)
- */
-
-const Int32 T_16_ov_bs_num_env_tbl[MAX_ENVELOPES + 1] = { 2147483647, 16, 8,
-        5,  4, 3
-                                                        };
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-SBR_ERROR extractFrameInfo(BIT_BUFFER     * hBitBuf,
-                           SBR_FRAME_DATA * h_frame_data)
-{
-
-    Int32 absBordLead = 0;
-    Int32 nRelLead = 0;
-    Int32 nRelTrail = 0;
-    Int32 bs_num_env = 0;
-    Int32 bs_num_rel = 0;
-    Int32 bs_var_bord = 0;
-    Int32 bs_var_bord_0 = 0;
-    Int32 bs_var_bord_1 = 0;
-    Int32 bs_pointer = 0;
-    Int32 bs_pointer_bits;
-    Int32 frameClass;
-    Int32 temp;
-    Int32 env;
-    Int32 k;
-    Int32 bs_num_rel_0 = 0;
-    Int32 bs_num_rel_1 = 0;
-    Int32 absBordTrail = 0;
-    Int32 middleBorder = 0;
-    Int32 bs_num_noise;
-    Int32 lA = 0;
-
-    Int32 tE[MAX_ENVELOPES + 1];
-    Int32 tQ[2 + 1];
-    Int32 f[MAX_ENVELOPES + 1];
-    Int32 bs_rel_bord[3];
-    Int32 bs_rel_bord_0[3];
-    Int32 bs_rel_bord_1[3];
-    Int32 relBordLead[3];
-    Int32 relBordTrail[3];
-
-
-    Int32 *v_frame_info = h_frame_data->frameInfo;
-
-    SBR_ERROR err =  SBRDEC_OK;
-
-
-    /*
-     * First read from the bitstream.
-     */
-
-    /* Read frame class */
-    h_frame_data->frameClass = frameClass = buf_getbits(hBitBuf, SBR_CLA_BITS);
-
-
-    switch (frameClass)
-    {
-
-        case FIXFIX:
-            temp = buf_getbits(hBitBuf, SBR_ENV_BITS);   /* 2 bits */
-
-            bs_num_env = 1 << temp;
-
-
-            f[0] = buf_getbits(hBitBuf, SBR_RES_BITS);   /* 1 bit */
-
-            for (env = 1; env < bs_num_env; env++)
-            {
-                f[env] = f[0];
-            }
-
-            nRelLead     = bs_num_env - 1;
-            absBordTrail  = 16;
-
-
-            break;
-
-        case FIXVAR:
-            bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS);   /* 2 bits */
-            bs_num_rel  = buf_getbits(hBitBuf, SBR_NUM_BITS);   /* 2 bits */
-            bs_num_env  = bs_num_rel + 1;
-
-            for (k = 0; k < bs_num_env - 1; k++)
-            {
-                bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
-            }
-
-            bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
-            bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
-            for (env = 0; env < bs_num_env; env++)
-            {                                                    /* 1 bit */
-                f[bs_num_env - 1 - env] = buf_getbits(hBitBuf, SBR_RES_BITS);
-            }
-
-            absBordTrail  = 16 + bs_var_bord;
-            nRelTrail     = bs_num_rel;
-
-            break;
-
-        case VARFIX:
-            bs_var_bord = buf_getbits(hBitBuf, SBR_ABS_BITS);   /* 2 bits */
-            bs_num_rel  = buf_getbits(hBitBuf, SBR_NUM_BITS);   /* 2 bits */
-            bs_num_env  = bs_num_rel + 1;
-
-            for (k = 0; k < bs_num_env - 1; k++)
-            {
-                bs_rel_bord[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
-            }
-
-            bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
-            bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
-            for (env = 0; env < bs_num_env; env++)
-            {                                  /* 1 bit */
-                f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
-            }
-
-            absBordTrail = 16;
-            absBordLead  = bs_var_bord;
-            nRelLead     = bs_num_rel;
-
-            break;
-
-        case VARVAR:
-            bs_var_bord_0 = buf_getbits(hBitBuf, SBR_ABS_BITS);   /* 2 bits */
-            bs_var_bord_1 = buf_getbits(hBitBuf, SBR_ABS_BITS);
-            bs_num_rel_0  = buf_getbits(hBitBuf, SBR_NUM_BITS);   /* 2 bits */
-            bs_num_rel_1  = buf_getbits(hBitBuf, SBR_NUM_BITS);
-
-            bs_num_env = bs_num_rel_0 + bs_num_rel_1 + 1;
-
-            for (k = 0; k < bs_num_rel_0; k++)
-            {                                                 /* 2 bits */
-                bs_rel_bord_0[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
-            }
-
-            for (k = 0; k < bs_num_rel_1; k++)
-            {                                                 /* 2 bits */
-                bs_rel_bord_1[k] = (buf_getbits(hBitBuf, SBR_REL_BITS) + 1) << 1;
-            }
-
-
-            bs_pointer_bits = bs_pointer_bits_tbl[bs_num_env];
-
-            bs_pointer = buf_getbits(hBitBuf, bs_pointer_bits);
-
-            for (env = 0; env < bs_num_env; env++)
-            {                                  /* 1 bit */
-                f[env] = buf_getbits(hBitBuf, SBR_RES_BITS);
-            }
-
-            absBordLead   = bs_var_bord_0;
-            absBordTrail  = 16 + bs_var_bord_1;
-            nRelLead      = bs_num_rel_0;
-            nRelTrail     = bs_num_rel_1;
-
-            break;
-
-    };
-
-
-    /*
-     * Calculate the framing.
-     */
-
-
-    switch (frameClass)
-    {
-        case FIXFIX:
-            for (k = 0; k < nRelLead; k++)
-            {
-                relBordLead[k] = T_16_ov_bs_num_env_tbl[bs_num_env];
-            }
-            break;
-        case VARFIX:
-            for (k = 0; k < nRelLead; k++)
-            {
-                relBordLead[k] = bs_rel_bord[k];
-            }
-            break;
-        case VARVAR:
-            for (k = 0; k < nRelLead; k++)
-            {
-                relBordLead[k] = bs_rel_bord_0[k];
-            }
-            for (k = 0; k < nRelTrail; k++)
-            {
-                relBordTrail[k] = bs_rel_bord_1[k];
-            }
-            break;
-        case FIXVAR:
-            for (k = 0; k < nRelTrail; k++)
-            {
-                relBordTrail[k] = bs_rel_bord[k];
-            }
-            break;
-    }
-
-
-    tE[0]          = absBordLead;
-    tE[bs_num_env] = absBordTrail;
-
-    for (env = 1; env <= nRelLead; env++)
-    {
-        tE[env] = absBordLead;
-        for (k = 0; k <= env - 1; k++)
-        {
-            tE[env] += relBordLead[k];
-        }
-    }
-
-    for (env = nRelLead + 1; env < bs_num_env; env++)
-    {
-        tE[env] = absBordTrail;
-        for (k = 0; k <= bs_num_env - env - 1; k++)
-        {
-            tE[env] -= relBordTrail[k];
-        }
-    }
-
-
-
-    switch (frameClass)
-    {
-        case  FIXFIX:
-            middleBorder = bs_num_env >> 1;
-            break;
-        case VARFIX:
-            switch (bs_pointer)
-            {
-                case 0:
-                    middleBorder = 1;
-                    break;
-                case 1:
-                    middleBorder = bs_num_env - 1;
-                    break;
-                default:
-                    middleBorder = bs_pointer - 1;
-                    break;
-            };
-            break;
-        case FIXVAR:
-        case VARVAR:
-            switch (bs_pointer)
-            {
-                case 0:
-                case 1:
-                    middleBorder = bs_num_env - 1;
-                    break;
-                default:
-                    middleBorder = bs_num_env + 1 - bs_pointer;
-                    break;
-            };
-            break;
-    };
-
-
-    tQ[0] = tE[0];
-    if (bs_num_env > 1)
-    {
-        tQ[1] = tE[middleBorder];
-        tQ[2] = tE[bs_num_env];
-        bs_num_noise = 2;
-    }
-    else
-    {
-        tQ[1] = tE[bs_num_env];
-        bs_num_noise = 1;
-    }
-
-    /*
-     *  Check consistency on freq bands
-     */
-
-    if ((tE[bs_num_env] < tE[0]) || (tE[0] < 0))
-    {
-        err = SBRDEC_INVALID_BITSTREAM;
-    }
-
-
-    switch (frameClass)
-    {
-        case  FIXFIX:
-            lA = -1;
-            break;
-        case VARFIX:
-            switch (bs_pointer)
-            {
-                case 0:
-                case 1:
-                    lA = -1;
-                    break;
-                default:
-                    lA = bs_pointer - 1;
-                    break;
-            };
-            break;
-        case FIXVAR:
-        case VARVAR:
-            switch (bs_pointer)
-            {
-                case 0:
-                    lA = - 1;
-                    break;
-                default:
-                    lA = bs_num_env + 1 - bs_pointer;
-                    break;
-            };
-            break;
-    };
-
-    /*
-     * Build the frameInfo vector...
-     */
-
-    v_frame_info[0] = bs_num_env;   /* Number of envelopes*/
-    pv_memcpy(v_frame_info + 1, tE, (bs_num_env + 1)*sizeof(Int32));    /* time borders*/
-    /* frequency resolution */
-    pv_memcpy(v_frame_info + 1 + bs_num_env + 1, f, bs_num_env*sizeof(Int32));
-
-    temp = (1 + bs_num_env) << 1;
-    v_frame_info[temp] = lA;                     /* transient envelope*/
-    v_frame_info[temp + 1] = bs_num_noise;       /* Number of noise envelopes */
-    /* noise borders */
-    pv_memcpy(v_frame_info + temp + 2, tQ, (bs_num_noise + 1)*sizeof(Int32));
-
-
-    return (err);
-
-}
-
-
-
-
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/extractframeinfo.h b/media/libstagefright/codecs/aacdec/extractframeinfo.h
deleted file mode 100644
index 2fcfe37..0000000
--- a/media/libstagefright/codecs/aacdec/extractframeinfo.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: extractFrameInfo.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef EXTRACTFRAMEINFO_H
-#define EXTRACTFRAMEINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-#include    "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef Int32 FRAME_INFO[LENGTH_FRAME_INFO];
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    SBR_ERROR extractFrameInfo(BIT_BUFFER     * hBitBuf,
-    SBR_FRAME_DATA * h_frame_data);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4.h b/media/libstagefright/codecs/aacdec/fft_rx4.h
deleted file mode 100644
index 8e7acb3..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/fft_rx4.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-        (1) modified definition of w_64rx4 from Int to Int16
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fft_rx4()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FFT_RX4_H
-#define FFT_RX4_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define     FFT_RX4_LONG                256
-#define     ONE_FOURTH_FFT_RX4_LONG     ((FFT_RX4_LONG)>>2)
-#define     FFT_RX4_SHORT               64
-#define     ONE_FOURTH_FFT_RX4_SHORT    ((FFT_RX4_SHORT)>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int16 w_64rx4[];
-extern const Int32 W_64rx4[];
-extern const Int32 W_256rx4[];
-extern const Int32 w_512rx2[];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void fft_rx4_long(
-        Int32      Data[],
-        Int32      *peak_value);
-
-    Int fft_rx4_short(
-        Int32      Data[],
-        Int32      *peak_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* FFT_RX4_H */
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp
deleted file mode 100644
index c517e7e..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_long.cpp
+++ /dev/null
@@ -1,428 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_long.c
- Funtions: fft_rx4_long
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-            (1) Eliminated search for max in the main loop.
-            (2) Reduced precision on w_256rx4 from Q15 to Q10
-
- Description:
-            (1) Created function fft_rx4_long_no_max to overcome LTP problem.
-
- Description:
-            (1) Modified shift so the accumulation growths faster than the
-                downshift, so now the input can be as high as 1.0 and saturation
-                will not occurre. The accumulation times the Q10 format will
-                never exceed 31 bits. This increases precision
-            (2) Eliminated unneeded data moves, used before for max search.
-            (3) Eliminated function fft_rx4_long_no_max.
-
- Description:
-            (1) Added comment to explain max search elimination and
-                Q format during multiplications
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Data       =  Input complex vector, arranged in the following order:
-                  real, imag, real, imag...
-                  This is a complex vector whose elements (real and Imag) are
-                  Int32.
-                  type Int32 *
-
-    peak_value =  Input,  peak value of the input vector
-                  Output,  peak value of the resulting vector
-                  type Int32 *
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    calculation are done in-place and returned in Data
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Fast Fourier Transform, radix 4 with Decimation in Frequency and block
-    floating point arithmetic.
-    The radix-4 FFT  simply divides the FFT into four smaller FFTs. Each of
-    the smaller FFTs is then further divided into smaller ones and so on.
-    It consists of log 4 N stages and each stage consists of N/4 dragonflies.
-
-    An FFT is nothing but a bundle of multiplications and summations which
-    may overflow during calculations.
-
-
-    This routine uses a scheme to test and scale the result output from
-    each FFT stage in order to fix the accumulation overflow.
-
-    The Input Data should be in Q13 format to get the highest precision.
-    At the end of each dragonfly calculation, a test for possible bit growth
-    is made, if bit growth is possible the Data is scale down back to Q13.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should provide a fixed point FFT for an input array
-    of size 256.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
-        C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-   MODIFY( x[] )
-   RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "fft_rx4.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void fft_rx4_long(
-    Int32      Data[],
-    Int32      *peak_value)
-
-{
-    Int     n1;
-    Int     n2;
-    Int     j;
-    Int     k;
-    Int     i;
-
-    Int32   t1;
-    Int32   t2;
-    Int32   r1;
-    Int32   r2;
-    Int32   r3;
-    Int32   r4;
-    Int32   s1;
-    Int32   s2;
-    Int32   s3;
-    Int32   *pData1;
-    Int32   *pData2;
-    Int32   *pData3;
-    Int32   *pData4;
-    Int32   temp1;
-    Int32   temp2;
-    Int32   temp3;
-    Int32   temp4;
-    Int32   max;
-
-    Int32   exp_jw1;
-    Int32   exp_jw2;
-    Int32   exp_jw3;
-
-
-
-    const Int32  *pw = W_256rx4;
-
-    n2 = FFT_RX4_LONG;
-
-    for (k = FFT_RX4_LONG; k > 4; k >>= 2)
-    {
-
-        n1 = n2;
-        n2 >>= 2;
-
-        for (i = 0; i < FFT_RX4_LONG; i += n1)
-        {
-            pData1 = &Data[ i<<1];
-            pData2 = pData1 + n1;
-
-            temp1   = *pData1;
-            temp2   = *pData2;
-
-            r1      = temp1 + temp2;
-            r2      = temp1 - temp2;
-
-            pData3 = pData1 + (n1 >> 1);
-            pData4 = pData3 + n1;
-            temp3   = *pData3++;
-            temp4   = *pData4++;
-
-            t1      = temp3 + temp4;
-
-            *(pData1++) = (r1 + t1);
-            t2      = temp3 - temp4;
-            *(pData2++) = (r1 - t1);
-
-            temp1   = *pData1;
-            temp2   = *pData2;
-
-            s1      = temp1 + temp2;
-            temp3   = *pData3;
-            s2      = temp1 - temp2;
-            temp4   = *pData4;
-            *pData3--  = (s2 - t2);
-            *pData4--  = (s2 + t2);
-
-            t1      = temp3 + temp4;
-
-            *pData1    = (s1 + t1);
-            *pData2    = (s1 - t1);
-
-            r1      = temp3 - temp4;
-
-            *pData4    = (r2 - r1);
-            *pData3    = (r2 + r1);
-
-        }  /* i */
-
-
-
-        for (j = 1; j < n2; j++)
-        {
-
-            exp_jw1 = (*pw++);
-            exp_jw2 = (*pw++);
-            exp_jw3 = (*pw++);
-
-
-            for (i = j; i < FFT_RX4_LONG; i += n1)
-            {
-                pData1 = &Data[ i<<1];
-                pData2 = pData1 + n1;
-
-                temp1   = *pData1;
-                temp2   = *pData2++;
-
-                r1      = temp1 + temp2;
-                r2      = temp1 - temp2;
-
-                pData3 = pData1 + (n1 >> 1);
-                pData4 = pData3 + n1;
-                temp3   = *pData3++;
-                temp4   = *pData4++;
-
-                r3      = temp3 + temp4;
-                r4      = temp3 - temp4;
-
-                *(pData1++) = (r1 + r3);
-                r1          = (r1 - r3) << 1;
-
-                temp2   = *pData2;
-                temp1   = *pData1;
-
-                s1      = temp1 + temp2;
-                s2      = temp1 - temp2;
-                s3      = (s2 + r4) << 1;
-                s2      = (s2 - r4) << 1;
-
-                temp3   = *pData3;
-                temp4   = *pData4;
-
-                t1      = temp3 + temp4;
-                t2      = temp3 - temp4;
-
-                *pData1  = (s1 + t1);
-                s1       = (s1 - t1) << 1;
-
-                *pData2--  = cmplx_mul32_by_16(s1, -r1, exp_jw2);
-                r3      = (r2 - t2) << 1;
-                *pData2    = cmplx_mul32_by_16(r1,  s1, exp_jw2);
-
-                r2      = (r2 + t2) << 1;
-
-                *pData3--  = cmplx_mul32_by_16(s2, -r2, exp_jw1);
-                *pData3    = cmplx_mul32_by_16(r2,  s2, exp_jw1);
-
-                *pData4--  = cmplx_mul32_by_16(s3, -r3, exp_jw3);
-                *pData4    = cmplx_mul32_by_16(r3,  s3, exp_jw3);
-
-            }  /* i */
-
-        }  /*  j */
-
-    } /* k */
-
-
-    max = 0;
-
-    pData1 = Data - 7;
-
-
-    for (i = ONE_FOURTH_FFT_RX4_LONG; i != 0 ; i--)
-    {
-        pData1 += 7;
-        pData2 = pData1 + 4;
-
-
-        temp1   = *pData1;
-        temp2   = *pData2++;
-
-        r1      = temp1 + temp2;
-        r2      = temp1 - temp2;
-
-        pData3 = pData1 + 2;
-        pData4 = pData1 + 6;
-        temp1   = *pData3++;
-        temp2   = *pData4++;
-
-        t1      = temp1 + temp2;
-        t2      = temp1 - temp2;
-
-        temp1       = (r1 + t1);
-        r1          = (r1 - t1);
-        *(pData1++) = temp1;
-        max        |= (temp1 >> 31) ^ temp1;
-
-
-
-        temp2   = *pData2;
-        temp1   = *pData1;
-
-        s1      = temp1 + temp2;
-        s2      = temp1 - temp2;
-
-
-        temp1   = *pData3;
-        temp2   = *pData4;
-
-        s3      = (s2 + t2);
-        s2      = (s2 - t2);
-
-        t1      = temp1 + temp2;
-        t2      = temp1 - temp2;
-
-        temp1      = (s1 + t1);
-        *pData1    = temp1;
-        temp2      = (s1 - t1);
-
-        max       |= (temp1 >> 31) ^ temp1;
-        *pData2--  = temp2;
-        max       |= (temp2 >> 31) ^ temp2;
-
-        *pData2    = r1;
-        max       |= (r1 >> 31) ^ r1;
-        *pData3--  = s2;
-        max       |= (s2 >> 31) ^ s2;
-        *pData4--  = s3;
-        max       |= (s3 >> 31) ^ s3;
-
-        temp1      = (r2 - t2);
-        *pData4    = temp1;
-        temp2      = (r2 + t2);
-        *pData3    = temp2;
-        max       |= (temp1 >> 31) ^ temp1;
-        max       |= (temp2 >> 31) ^ temp2;
-
-    }  /* i */
-
-    *peak_value = max;
-
-    return ;
-
-}
-
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp
deleted file mode 100644
index 4a8a0d6..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_short.cpp
+++ /dev/null
@@ -1,468 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_short.c
- Funtions: fft_rx4_short
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-            (1) Eliminated search for max in the main loop.
-            (2) Simplified the function by eliminating different conditions
-                for exp.
-            (3) Reduced precision on w_64rx4 from Q15 to Q12, so now the
-                input can be as high as 1.0 and saturation will not occurre
-                because the accumulation times the new Q12 format will never
-                exceed 31 bits.
-
- Description:
-            (1) Added comment to explain max search elimination and
-                Q format during multiplications
-            (2) Increased down shift from 1 to 2, to ensure that 32-bit
-                numbers will not overflow when 2 consecutive adds are done
-                This was found during code review.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Data       =  Input complex vector, arranged in the following order:
-                  real, imag, real, imag...
-                  This is a complex vector whose elements (real and Imag) are
-                  Int32.
-                  type Int32 *
-
-    peak_value =  Input,  peak value of the input vector
-                  Output,  peak value of the resulting vector
-                  type Int32 *
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exponent returns a shift to compensate the scaling introduced by
-    overflow protection
-
- Pointers and Buffers Modified:
-    calculation are done in-place and returned in Data
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Fast Fourier Transform, radix 4 with Decimation in Frequency and block
-    floating point arithmetic.
-    The radix-4 FFT  simply divides the FFT into four smaller FFTs. Each of
-    the smaller FFTs is then further divided into smaller ones and so on.
-    It consists of log 4 N stages and each stage consists of N/4 dragonflies.
-
-    An FFT is nothing but a bundle of multiplications and summations which
-    may overflow during calculations.
-
-
-    This routine uses a scheme to test and scale the result output from
-    each FFT stage in order to fix the accumulation overflow.
-
-    The Input Data should be in Q13 format to get the highest precision.
-    At the end of each dragonfly calculation, a test for possible bit growth
-    is made, if bit growth is possible the Data is scale down back to Q13.
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should provide a fixed point FFT for an input array
-    of size 64.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
-        C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-   MODIFY( x[] )
-   RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "fft_rx4.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int fft_rx4_short(
-    Int32      Data[],
-    Int32      *peak_value)
-
-{
-    Int     n1;
-    Int     n2;
-    Int     n3;
-    Int     j;
-    Int     k;
-    Int     i;
-    Int32   exp_jw1;
-    Int32   exp_jw2;
-    Int32   exp_jw3;
-
-
-    Int32   t1;
-    Int32   t2;
-    Int32   r1;
-    Int32   r2;
-    Int32   r3;
-    Int32   s1;
-    Int32   s2;
-    Int32   s3;
-
-    Int32   *pData1;
-    Int32   *pData2;
-    Int32   *pData3;
-    Int32   *pData4;
-    const Int32  *pw;
-    Int32   temp1;
-    Int32   temp2;
-    Int32   temp3;
-    Int32   temp4;
-    Int32   max;
-    Int     exp;
-    Int     exponent = 0;
-    Int     shift;
-
-
-    max = *peak_value;
-    exp = 0;
-
-    if (max > 0x008000)
-    {
-        exp = 8 - pv_normalize(max);   /* use 24 bits  */
-
-        exponent = exp;        /* keeps track of # of shifts */
-
-    }
-
-    n2 = FFT_RX4_SHORT;
-
-    pw = W_64rx4;
-
-
-    /* shift down to avoid possible overflow in first pass of the loop */
-    shift = 2;
-
-    for (k = FFT_RX4_SHORT; k > 4; k >>= 2)
-    {
-
-        n1 = n2;
-        n2 >>= 2;
-        n3 = n1 >> 1;
-
-        exp -= 2;
-
-        for (i = 0; i < FFT_RX4_SHORT; i += n1)
-        {
-            pData1 = &Data[ i<<1];
-            pData3 = pData1 + n3;
-            pData2 = pData1 + n1;
-            pData4 = pData3 + n1;
-
-            temp1   = *(pData1);
-            temp2   = *(pData2);
-            temp1   >>= shift;
-            temp2   >>= shift;
-
-            r1      = temp1 + temp2;
-            r2      = temp1 - temp2;
-
-            temp3   = *(pData3++);
-            temp4   = *(pData4++);
-            temp3   >>= shift;
-            temp4   >>= shift;
-
-            t1      = temp3 + temp4;
-            t2      = temp3 - temp4;
-
-            *(pData1++) = (r1 + t1) >> exp;
-            *(pData2++) = (r1 - t1) >> exp;
-
-            temp1   = *pData1;
-            temp2   = *pData2;
-            temp1   >>= shift;
-            temp2   >>= shift;
-
-            s1      = temp1 + temp2;
-            s2      = temp1 - temp2;
-
-            temp3   = *pData3;
-            temp4   = *pData4;
-            temp3   >>= shift;
-            temp4   >>= shift;
-
-            t1      = temp3 + temp4;
-            r1      = temp3 - temp4;
-
-            *pData1   = (s1 + t1) >> exp;
-            *pData2   = (s1 - t1) >> exp;
-
-            *pData4--    = (s2 + t2) >> exp;
-            *pData4      = (r2 - r1) >> exp;
-
-            *pData3--    = (s2 - t2) >> exp;
-            *pData3      = (r2 + r1) >> exp;
-
-
-        }  /* i */
-
-        for (j = 1; j < n2; j++)
-        {
-            exp_jw1 = *pw++;
-            exp_jw2 = *pw++;
-            exp_jw3 = *pw++;
-
-
-            for (i = j; i < FFT_RX4_SHORT; i += n1)
-            {
-                pData1 = &Data[ i<<1];
-                pData3 = pData1 + n3;
-                pData2 = pData1 + n1;
-                pData4 = pData3 + n1;
-
-                temp1   = *(pData1);
-                temp2   = *(pData2++);
-                temp1   >>= shift;
-                temp2   >>= shift;
-
-                r1      = temp1 + temp2;
-                r2      = temp1 - temp2;
-                temp3   = *(pData3++);
-                temp4   = *(pData4++);
-                temp3   >>= shift;
-                temp4   >>= shift;
-
-                t1      = temp3 + temp4;
-                t2      = temp3 - temp4;
-
-                *(pData1++) = (r1 + t1) >> exp;
-                r1          = (r1 - t1) >> exp;
-
-                temp1   = *pData1;
-                temp2   = *pData2;
-                temp1   >>= shift;
-                temp2   >>= shift;
-
-                s1      = temp1 + temp2;
-                s2      = temp1 - temp2;
-
-                s3      = (s2 + t2) >> exp;
-                s2      = (s2 - t2) >> exp;
-
-                temp3   = *pData3;
-                temp4   = *pData4 ;
-                temp3   >>= shift;
-                temp4   >>= shift;
-
-                t1      = temp3 + temp4;
-                t2      = temp3 - temp4;
-
-                *pData1  = (s1 + t1) >> exp;
-                s1       = (s1 - t1) >> exp;
-
-
-                *pData2--  = cmplx_mul32_by_16(s1, -r1, exp_jw2) << 1;
-                *pData2    = cmplx_mul32_by_16(r1,  s1, exp_jw2) << 1;
-
-                r3       = ((r2 - t2) >> exp);
-                r2       = ((r2 + t2) >> exp);
-
-                *pData3--  = cmplx_mul32_by_16(s2, -r2, exp_jw1) << 1;
-                *pData3    = cmplx_mul32_by_16(r2,  s2, exp_jw1) << 1;
-
-                *pData4--  = cmplx_mul32_by_16(s3, -r3, exp_jw3) << 1;
-                *pData4    = cmplx_mul32_by_16(r3,  s3, exp_jw3) << 1;
-
-            }  /* i */
-
-        }  /*  j */
-
-        /*
-         *  this will reset exp and shift to zero for the second pass of the
-         *  loop
-         */
-        exp   = 2;
-        shift = 0;
-
-    } /* k */
-
-
-    max = 0;
-
-    pData1 = Data - 7;
-
-    for (i = ONE_FOURTH_FFT_RX4_SHORT; i != 0 ; i--)
-    {
-        pData1 += 7;
-
-        pData3 = pData1 + 2;
-        pData2 = pData1 + 4;
-        pData4 = pData1 + 6;
-
-        temp1   = *pData1;
-        temp2   = *pData2++;
-
-        r1      = temp1 + temp2;
-        r2      = temp1 - temp2;
-
-        temp1   = *pData3++;
-        temp2   = *pData4++;
-
-        t1      = temp1 + temp2;
-        t2      = temp1 - temp2;
-
-        temp1       = (r1 + t1);
-        r1          = (r1 - t1);
-        *(pData1++) = temp1;
-        max        |= (temp1 >> 31) ^ temp1;
-
-
-
-        temp1   = *pData1;
-        temp2   = *pData2;
-
-        s1      = temp1 + temp2;
-        s2      = temp1 - temp2;
-
-        s3      = (s2 + t2);
-        s2      = (s2 - t2);
-
-        temp1   = *pData3;
-        temp2   = *pData4;
-
-        t1      = temp1 + temp2;
-        t2      = temp1 - temp2;
-
-        temp1      = (s1 + t1);
-        temp2      = (s1 - t1);
-        *pData1    = temp1;
-        *pData2--  = temp2;
-        max       |= (temp1 >> 31) ^ temp1;
-        max       |= (temp2 >> 31) ^ temp2;
-
-        *pData2    = r1;
-        *pData3--  = s2;
-        *pData4--  = s3;
-        max       |= (r1 >> 31) ^ r1;
-        max       |= (s2 >> 31) ^ s2;
-        max       |= (s3 >> 31) ^ s3;
-
-        temp1      = (r2 - t2);
-        temp2      = (r2 + t2);
-        *pData4    = temp1;
-        *pData3    = temp2;
-        max       |= (temp1 >> 31) ^ temp1;
-        max       |= (temp2 >> 31) ^ temp2;
-
-    }  /* i */
-
-    *peak_value = max;
-
-
-    return (exponent);
-
-}
diff --git a/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp
deleted file mode 100644
index 2476b87..0000000
--- a/media/libstagefright/codecs/aacdec/fft_rx4_tables_fxp.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fft_rx4_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Reduce the accuracy of w_256rx4 and w_512rx2 to Q10 format.
-            Try to to pack sin and cos into one 32-bit number to reduce the
-            memory access, but doesn't help in speed, so commented out for now.
-
- Description:
-        (1) Reduced precision of w_64rx4 from Q15 to Q12.
-        (2) Increased precision of w_512rx2 from Q10 to Q13, Both changes
-            increase overall decoder precision
-
- Description:
-        (1) per code review comment, added description for table generation
-        (2) modified definition of w_64rx4 from Int to Int16
-
-
- Who:                           Date:
- Description:
-
-  ----------------------------------------------------------------------------
- MODULE DESCRIPTION
-
-  Table generation
-
- n = 256  or  64;
- M = precision; 2^10, 2^12, 2^13
-
- for j=1; j<log4(n); j *= 4
-
-    for i=0; i<n/4; i +=j
-
-        phi_1 = 2*pi*i/n;
-        phi_2 = 4*pi*i/n;
-        phi_3 = 6*pi*i/n;
-        M*[cos(phi_1) sin(phi_1) cos(phi_2) sin(phi_2) cos(phi_3) sin(phi_4)];
-
-    end
-
- end
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fft_rx4.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*
-------------------------------------------------------------------------------
- Forward FFT radix-4 tables
-------------------------------------------------------------------------------
-*/
-
-
-const Int32 W_64rx4[60] =            /* 2 Q15  */
-{
-
-    0x7F610C8C,  0x7D8918F9,  0x7A7C2528,
-    0x7D8918F9,  0x764130FB,  0x6A6D471C,
-    0x7A7C2528,  0x6A6D471C,  0x513362F1,
-    0x764130FB,  0x5A825A82,  0x30FB7641,
-    0x70E23C56,  0x471C6A6D,  0x0C8C7F61,
-    0x6A6D471C,  0x30FB7641,  0xE7057D89,
-    0x62F15133,  0x18F97D89,  0xC3A870E2,
-    0x5A825A82,  0x00007FFF,  0xA57C5A82,
-    0x513362F1,  0xE7057D89,  0x8F1C3C56,
-    0x471C6A6D,  0xCF037641,  0x827518F9,
-    0x3C5670E2,  0xB8E26A6D,  0x809DF372,
-    0x30FB7641,  0xA57C5A82,  0x89BDCF03,
-    0x25287A7C,  0x9591471C,  0x9D0DAECB,
-    0x18F97D89,  0x89BD30FB,  0xB8E29591,
-    0x0C8C7F61,  0x827518F9,  0xDAD68582,
-    0x764130FB,  0x5A825A82,  0x30FB7641,
-    0x5A825A82,  0x00007FFF,  0xA57C5A82,
-    0x30FB7641,  0xA57C5A82,  0x89BDCF03,
-};
-
-
-
-const Int32 W_256rx4[495] =            /* 2 Q15  */
-{
-
-    0x7FF50324,  0x7FD80648,  0x7FA6096A,
-    0x7FD80648,  0x7F610C8C,  0x7E9C12C8,
-    0x7FA6096A,  0x7E9C12C8,  0x7CE31C0B,
-    0x7F610C8C,  0x7D8918F9,  0x7A7C2528,
-    0x7F090FAB,  0x7C291F1A,  0x776B2E11,
-    0x7E9C12C8,  0x7A7C2528,  0x73B536BA,
-    0x7E1D15E2,  0x78842B1F,  0x6F5E3F17,
-    0x7D8918F9,  0x764130FB,  0x6A6D471C,
-    0x7CE31C0B,  0x73B536BA,  0x64E84EBF,
-    0x7C291F1A,  0x70E23C56,  0x5ED755F5,
-    0x7B5C2223,  0x6DC941CE,  0x58425CB3,
-    0x7A7C2528,  0x6A6D471C,  0x513362F1,
-    0x79892826,  0x66CF4C3F,  0x49B468A6,
-    0x78842B1F,  0x62F15133,  0x41CE6DC9,
-    0x776B2E11,  0x5ED755F5,  0x398C7254,
-    0x764130FB,  0x5A825A82,  0x30FB7641,
-    0x750433DF,  0x55F55ED7,  0x28267989,
-    0x73B536BA,  0x513362F1,  0x1F1A7C29,
-    0x7254398C,  0x4C3F66CF,  0x15E27E1D,
-    0x70E23C56,  0x471C6A6D,  0x0C8C7F61,
-    0x6F5E3F17,  0x41CE6DC9,  0x03247FF5,
-    0x6DC941CE,  0x3C5670E2,  0xF9B67FD8,
-    0x6C23447A,  0x36BA73B5,  0xF0537F09,
-    0x6A6D471C,  0x30FB7641,  0xE7057D89,
-    0x68A649B4,  0x2B1F7884,  0xDDDB7B5C,
-    0x66CF4C3F,  0x25287A7C,  0xD4DF7884,
-    0x64E84EBF,  0x1F1A7C29,  0xCC1F7504,
-    0x62F15133,  0x18F97D89,  0xC3A870E2,
-    0x60EB539B,  0x12C87E9C,  0xBB846C23,
-    0x5ED755F5,  0x0C8C7F61,  0xB3BF66CF,
-    0x5CB35842,  0x06487FD8,  0xAC6360EB,
-    0x5A825A82,  0x00007FFF,  0xA57C5A82,
-    0x58425CB3,  0xF9B67FD8,  0x9F13539B,
-    0x55F55ED7,  0xF3727F61,  0x992F4C3F,
-    0x539B60EB,  0xED367E9C,  0x93DB447A,
-    0x513362F1,  0xE7057D89,  0x8F1C3C56,
-    0x4EBF64E8,  0xE0E47C29,  0x8AFA33DF,
-    0x4C3F66CF,  0xDAD67A7C,  0x877A2B1F,
-    0x49B468A6,  0xD4DF7884,  0x84A22223,
-    0x471C6A6D,  0xCF037641,  0x827518F9,
-    0x447A6C23,  0xC94473B5,  0x80F50FAB,
-    0x41CE6DC9,  0xC3A870E2,  0x80260648,
-    0x3F176F5E,  0xBE306DC9,  0x8009FCDA,
-    0x3C5670E2,  0xB8E26A6D,  0x809DF372,
-    0x398C7254,  0xB3BF66CF,  0x81E1EA1C,
-    0x36BA73B5,  0xAECB62F1,  0x83D5E0E4,
-    0x33DF7504,  0xAA095ED7,  0x8675D7D8,
-    0x30FB7641,  0xA57C5A82,  0x89BDCF03,
-    0x2E11776B,  0xA12755F5,  0x8DAAC672,
-    0x2B1F7884,  0x9D0D5133,  0x9235BE30,
-    0x28267989,  0x992F4C3F,  0x9758B64A,
-    0x25287A7C,  0x9591471C,  0x9D0DAECB,
-    0x22237B5C,  0x923541CE,  0xA34BA7BC,
-    0x1F1A7C29,  0x8F1C3C56,  0xAA09A127,
-    0x1C0B7CE3,  0x8C4936BA,  0xB13F9B16,
-    0x18F97D89,  0x89BD30FB,  0xB8E29591,
-    0x15E27E1D,  0x877A2B1F,  0xC0E790A0,
-    0x12C87E9C,  0x85822528,  0xC9448C49,
-    0x0FAB7F09,  0x83D51F1A,  0xD1ED8893,
-    0x0C8C7F61,  0x827518F9,  0xDAD68582,
-    0x096A7FA6,  0x816212C8,  0xE3F3831B,
-    0x06487FD8,  0x809D0C8C,  0xED368162,
-    0x03247FF5,  0x80260648,  0xF6948058,
-    0x7F610C8C,  0x7D8918F9,  0x7A7C2528,
-    0x7D8918F9,  0x764130FB,  0x6A6D471C,
-    0x7A7C2528,  0x6A6D471C,  0x513362F1,
-    0x764130FB,  0x5A825A82,  0x30FB7641,
-    0x70E23C56,  0x471C6A6D,  0x0C8C7F61,
-    0x6A6D471C,  0x30FB7641,  0xE7057D89,
-    0x62F15133,  0x18F97D89,  0xC3A870E2,
-    0x5A825A82,  0x00007FFF,  0xA57C5A82,
-    0x513362F1,  0xE7057D89,  0x8F1C3C56,
-    0x471C6A6D,  0xCF037641,  0x827518F9,
-    0x3C5670E2,  0xB8E26A6D,  0x809DF372,
-    0x30FB7641,  0xA57C5A82,  0x89BDCF03,
-    0x25287A7C,  0x9591471C,  0x9D0DAECB,
-    0x18F97D89,  0x89BD30FB,  0xB8E29591,
-    0x0C8C7F61,  0x827518F9,  0xDAD68582,
-    0x764130FB,  0x5A825A82,  0x30FB7641,
-    0x5A825A82,  0x00007FFF,  0xA57C5A82,
-    0x30FB7641,  0xA57C5A82,  0x89BDCF03
-};
-
-
-
-/*
-------------------------------------------------------------------------------
- Forward FFT radix-2 table
-------------------------------------------------------------------------------
-*/
-
-
-const Int32 w_512rx2[127] =
-{
-    /* Q15  */
-    0x7FFE0192, 0x7FF60324, 0x7FEA04B6,
-    0x7FD90648,  0x7FC207D9, 0x7FA7096B, 0x7F870AFB,
-    0x7F620C8C,  0x7F380E1C, 0x7F0A0FAB, 0x7ED6113A,
-    0x7E9D12C8,  0x7E601455, 0x7E1E15E2, 0x7DD6176E,
-    0x7D8A18F9,  0x7D3A1A83, 0x7CE41C0C, 0x7C891D93,
-    0x7C2A1F1A,  0x7BC6209F, 0x7B5D2224, 0x7AEF23A7,
-    0x7A7D2528,  0x7A0626A8, 0x798A2827, 0x790A29A4,
-    0x78852B1F,  0x77FB2C99, 0x776C2E11, 0x76D92F87,
-    0x764230FC,  0x75A6326E, 0x750533DF, 0x7460354E,
-    0x73B636BA,  0x73083825, 0x7255398D, 0x719E3AF3,
-    0x70E33C57,  0x70233DB8, 0x6F5F3F17, 0x6E974074,
-    0x6DCA41CE,  0x6CF94326, 0x6C24447B, 0x6B4B45CD,
-    0x6A6E471D,  0x698C486A, 0x68A749B4, 0x67BD4AFB,
-    0x66D04C40,  0x65DE4D81, 0x64E94EC0, 0x63EF4FFB,
-    0x62F25134,  0x61F15269, 0x60EC539B, 0x5FE454CA,
-    0x5ED755F6,  0x5DC8571E, 0x5CB45843, 0x5B9D5964,
-    0x5A825A82,  0x59645B9D, 0x58435CB4, 0x571E5DC8,
-    0x55F65ED7,  0x54CA5FE4, 0x539B60EC, 0x526961F1,
-    0x513462F2,  0x4FFB63EF, 0x4EC064E9, 0x4D8165DE,
-    0x4C4066D0,  0x4AFB67BD, 0x49B468A7, 0x486A698C,
-    0x471D6A6E,  0x45CD6B4B, 0x447B6C24, 0x43266CF9,
-    0x41CE6DCA,  0x40746E97, 0x3F176F5F, 0x3DB87023,
-    0x3C5770E3,  0x3AF3719E, 0x398D7255, 0x38257308,
-    0x36BA73B6,  0x354E7460, 0x33DF7505, 0x326E75A6,
-    0x30FC7642,  0x2F8776D9, 0x2E11776C, 0x2C9977FB,
-    0x2B1F7885,  0x29A4790A, 0x2827798A, 0x26A87A06,
-    0x25287A7D,  0x23A77AEF, 0x22247B5D, 0x209F7BC6,
-    0x1F1A7C2A,  0x1D937C89, 0x1C0C7CE4, 0x1A837D3A,
-    0x18F97D8A,  0x176E7DD6, 0x15E27E1E, 0x14557E60,
-    0x12C87E9D,  0x113A7ED6, 0x0FAB7F0A, 0x0E1C7F38,
-    0x0C8C7F62,  0x0AFB7F87, 0x096B7FA7, 0x07D97FC2,
-    0x06487FD9,  0x04B67FEA, 0x03247FF6, 0x01927FFE
-};
-
diff --git a/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp b/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp
deleted file mode 100644
index 535f177..0000000
--- a/media/libstagefright/codecs/aacdec/find_adts_syncword.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/find_adts_syncword.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Fixed error in logic that determines whether there are enough
- bits available to conduct a search for the syncword.  The plus sign in
- the following condition should be a minus.
-
-    if (pInputStream->usedBits <
-            (pInputStream->availableBits + syncword_length)
-
- The length of the syncword should subtract from the number of available
- bits, not add.
-
- Description:  Fixed condition when the end of file was found, unsigned
-   comparison produced a undesired search. Fixed by casting comparison
-     if ((Int)pInputStream->usedBits <
-            ((Int)pInputStream->availableBits - syncword_length) )
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pSyncword     = Pointer to variable containing the syncword that the
-                    function should be scanning for in the buffer. [ UInt32 * ]
-
-    pInputStream  = Pointer to a BITS structure, used by the function getbits
-                    to retrieve data from the bitstream.  [ BITS * ]
-
-    syncword_length = The length of the syncword. [ Int ]
-
-    syncword_mask   = A mask to be applied to the bitstream before comparison
-                      with the value pointed to by pSyncword. [ UInt32 ]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    None
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module scans the bitstream for a syncword of any length between 1 and 32.
- If certain bits in the syncword are to be ignored, that bit position should
- be set to 0 in both parameters *(pSyncword) and syncword_mask.  This allows
- for a syncword to be constructed out of non-contiguous bits.
-
- Upon finding the syncword's position in the bitstream, a value denoting the
- syncword's degree of deviance from being byte-aligned (byte_align_offset)
- is set in the structure pointed to by pInputStream.
- This is a value between 0 and 7.
-
- If no syncword is found, the function returns status == ERROR.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- "Don't care" bits must be set to '0' in both *(pSyncword) and syncword_mask.
-
- This function should not be called if there are less than
- (8 + syncword_length) bits in the buffer.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 13818-7:1997(E)
-     Part 7
-        Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
-
- (2) ISO/IEC 11172-3:1993(E)
-     Part 3
-        Subpart 2.4.3 The audio decoding process
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF (pInputStream->usedBits <
-            (pInputStream->availableBits + syncword_length) )
-
-        max_search_length = (pInputStream->availableBits - pInputStream->usedBits);
-
-        max_search_length = max_search_length - syncword_length;
-
-        search_length = 0;
-
-        adts_header =
-        CALL getbits(syncword_length, pInputStream);
-            MODIFYING pInputStream->usedBits
-            RETURNING bits from bitstream of length (syncword_length)
-
-        test_for_syncword = adts_header AND syncword_mask;
-        test_for_syncword = test_for_syncword XOR syncword;
-
-        WHILE ( (test_for_syncword != 0) && (search_length > 0) )
-
-            search_length = search_length - 1;
-
-            adts_header = adts_header << 1;
-            adts_header = adts_header OR ...
-
-            CALL getbits(syncword_length, pInputStream);
-                MODIFYING pInputStream->usedBits
-                RETURNING 1 bit from the bitstream
-
-            test_for_syncword = adts_header AND syncword_mask;
-            test_for_syncword = test_for_syncword XOR syncword;
-
-        ENDWHILE
-
-        IF (search_length == 0)
-            status = ERROR;
-        ENDIF
-
-        *(pSyncword) = adts_header;
-
-         pInputStream->byteAlignOffset =
-             (pInputStream->usedBits - syncwordlength) AND 0x7;
-
-    ELSE
-        status = ERROR;
-    ENDIF
-
-    return (status);
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "find_adts_syncword.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define FIND_ADTS_ERROR -1
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int find_adts_syncword(
-    UInt32 *pSyncword,
-    BITS   *pInputStream,
-    Int     syncword_length,
-    UInt32  syncword_mask)
-{
-
-    Int    status = SUCCESS;
-    UInt   search_length;
-    UInt32 adts_header = 0;
-    UInt32 test_for_syncword;
-    UInt32 syncword = *(pSyncword);
-
-    /*
-     * Determine the maximum number of bits available to this function for
-     * the syncword search.
-     */
-    if ((Int)pInputStream->usedBits <
-            ((Int)pInputStream->availableBits - syncword_length))
-    {
-        search_length = (pInputStream->availableBits - pInputStream->usedBits);
-
-        search_length -= syncword_length;
-
-        adts_header  = getbits(syncword_length, pInputStream);
-
-        /*
-         * Mask the result in adts_header with the syncword_mask, so only the
-         * bits relevant to syncword detection are compared to *(pSyncword).
-         */
-        test_for_syncword  = adts_header & syncword_mask;
-        test_for_syncword ^= syncword;
-
-        /*
-         * Scan bit-by-bit through the bitstream, until the function either
-         * runs out of bits, or finds the syncword.
-         */
-
-        while ((test_for_syncword != 0) && (search_length > 0))
-        {
-            search_length--;
-
-            adts_header <<= 1;
-            adts_header |= getbits(1, pInputStream);
-
-            test_for_syncword  = adts_header & syncword_mask;
-            test_for_syncword ^= syncword;
-        }
-
-        if (search_length == 0)
-        {
-            status = FIND_ADTS_ERROR;
-        }
-
-        /*
-         * Return the syncword's position in the bitstream.  Correct placement
-         * of the syncword will result in byte_align_offset == 0.
-         * If the syncword is found not to be byte-aligned, then return
-         * the degree of disalignment, so further decoding can
-         * be shifted as necessary.
-         *
-         */
-        pInputStream->byteAlignOffset =
-            (pInputStream->usedBits - syncword_length) & 0x7;
-
-    } /* END if (pInputStream->usedBits < ...) */
-
-    else
-    {
-        status = FIND_ADTS_ERROR;
-    }
-
-    *(pSyncword) = adts_header;
-
-    return (status);
-
-} /* find_adts_syncword() */
diff --git a/media/libstagefright/codecs/aacdec/find_adts_syncword.h b/media/libstagefright/codecs/aacdec/find_adts_syncword.h
deleted file mode 100644
index d147bc5..0000000
--- a/media/libstagefright/codecs/aacdec/find_adts_syncword.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/find_adts_syncword.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for find_adts_syncword()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FIND_ADTS_SYNCWORD_H
-#define FIND_ADTS_SYNCWORD_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int find_adts_syncword(
-    UInt32 *pSyncword,
-    BITS   *pInputStream,
-    Int     syncword_length,
-    UInt32  syncword_mask);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp b/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp
deleted file mode 100644
index b85c7df..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.cpp
+++ /dev/null
@@ -1,284 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/fwd_long_complex_rot.c
- Funtions: fwd_long_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
-            (1) Change the input arguments, no shifts information from
-                long_fft_rx4 is passed, only a single max is passed.
-            (2) Eliminate search for max, a fixed shift has replaced the
-                search for max with minimal loss of precision.
-            (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
-            (1) Added comments per code review
-            (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    Data_in   = Input vector (sized for long windows
-                TWICE_FWD_LONG_CX_ROT_LENGTH), with time domain samples
-                type Int32 *
-
-    Data_out  = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
-                (sized for long windows TWICE_FWD_LONG_CX_ROT_LENGTH)
-                type Int32 *
-
-    max       = Input, carries the maximum value of the input vector
-                "Data_in"
-                type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
-    Results are return in "Data_out"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    fwd_long_complex_rot() performs the pre complex rotation for the MDCT
-    for the case of long windows. It also performs digit reverse ordering of
-    the first and second halves of the input vector "Data_in", as well as
-    reordering of the two half vectors (following radix-2 decomposition)
-    Word normalization is also done to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    fwd_long_complex_rot() should execute a pre-rotation by
-    exp(-j(2pi/N)(k+1/8)), digit reverse ordering and normalization
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fwd_long_complex_rot.h"
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int fwd_long_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max)
-{
-    Int     i;
-    const   Int32 *p_rotate;
-    Int32   temp_re;
-    Int32   temp_im;
-    Int32   *pData_in_ref1;
-    Int32   *pData_in_ref2;
-    Int32   exp_jw;
-    Int32   temp_re_32;
-    Int32   temp_im_32;
-
-    Int32   *pData_out_1;
-    Int32   *pData_out_2;
-    Int32   *pData_out_3;
-    Int32   *pData_out_4;
-
-    Int32 *pData_in_1;
-    Int32 *pData_in_2;
-
-    Int     exp;
-
-    p_rotate       =  exp_rotation_N_2048;
-
-    pData_in_ref1  =  Data_in;
-    pData_in_ref2  = &Data_in[TWICE_FWD_LONG_CX_ROT_LENGTH];
-
-    pData_out_1 = Data_out;
-    pData_out_2 = &Data_out[LONG_WINDOW_LENGTH_m_1];
-    pData_out_3 = &Data_out[LONG_WINDOW_LENGTH];
-    pData_out_4 = &Data_out[TWICE_LONG_WINDOW_LENGTH_m_1];
-
-    /*
-     *  Data_out
-     *                                   >>>>                   <<<<
-     *                                pData_out_3             pData_out_4
-     *      |             |             |             |             |
-     * pData_out_1               pData_out_2
-     *      >>>>                     <<<<
-     */
-
-
-    exp = 16 - pv_normalize(max);
-
-    if (exp < 0)
-    {
-        exp = 0;
-    }
-
-    /*
-     *  Apply  A/2^(diff) + B
-     */
-
-
-    pData_in_1 = pData_in_ref1;
-    pData_in_2 = pData_in_ref2;
-
-    for (i = FWD_LONG_CX_ROT_LENGTH; i != 0; i--)
-    {
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-
-        exp_jw = *p_rotate++;
-
-        /*
-         *  Use auxiliary variables to avoid double accesses to memory.
-         *  Data in is scaled to use only lower 16 bits.
-         */
-
-        temp_re =  *(pData_in_1++) >> exp;
-        temp_im =  *(pData_in_1++) >> exp;
-
-        /*
-         *   Pre-rotation
-         */
-
-        temp_re_32  = (cmplx_mul32_by_16(temp_re,   temp_im,  exp_jw));
-        temp_im_32  = (cmplx_mul32_by_16(temp_im,  -temp_re,  exp_jw));
-
-        *(pData_out_1++) = - temp_re_32;
-        *(pData_out_2--) =   temp_im_32;
-        *(pData_out_3++) = - temp_im_32;
-        *(pData_out_4--) =   temp_re_32;
-
-        /*
-         *   Pointer increment to jump over imag (1 & 4) or real parts
-         *   (2 & 3)
-         */
-        pData_out_1++;
-        pData_out_2--;
-        pData_out_3++;
-        pData_out_4--;
-
-        /*
-         *   Repeat procedure for odd index at the output
-         */
-
-        exp_jw = *p_rotate++;
-
-        temp_re =  *(pData_in_2++) >> exp;
-        temp_im =  *(pData_in_2++) >> exp;
-
-        temp_re_32  = (cmplx_mul32_by_16(temp_re,   temp_im,  exp_jw));
-        temp_im_32  = (cmplx_mul32_by_16(temp_im,  -temp_re,  exp_jw));
-
-        *(pData_out_1++) = - temp_re_32;
-        *(pData_out_2--) =   temp_im_32;
-        *(pData_out_3++) = - temp_im_32;
-        *(pData_out_4--) =   temp_re_32;
-
-        pData_out_1++;
-        pData_out_2--;
-        pData_out_3++;
-        pData_out_4--;
-
-    }
-
-    return (exp + 1);
-}
diff --git a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h b/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h
deleted file mode 100644
index 5978906..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_long_complex_rot.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/fwd_long_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fwd_long_complex_rot
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FWD_LONG_COMPLEX_ROT_H
-#define FWD_LONG_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FWD_LONG_CX_ROT_LENGTH              256
-#define TWICE_FWD_LONG_CX_ROT_LENGTH        (FWD_LONG_CX_ROT_LENGTH<<1)
-#define LONG_WINDOW_LENGTH                  1024
-#define LONG_WINDOW_LENGTH_m_1              (LONG_WINDOW_LENGTH - 1)
-#define TWICE_LONG_WINDOW_LENGTH_m_1        ((LONG_WINDOW_LENGTH<<1) - 1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-
-Int fwd_long_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* FWD_LONG_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp b/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp
deleted file mode 100644
index 964f766..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.cpp
+++ /dev/null
@@ -1,261 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: ./src/fwd_short_complex_rot.c
- Funtions:  fwd_short_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
-            (1) Change the input argument, only a single max is passed.
-            (2) Eliminate search for max, a fixed shift has replaced the
-                search for max with minimal loss of precision.
-            (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
-            (1) Added comments per code review
-            (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    Data_in   = Input vector (sized for short windows
-                2*FWD_SHORT_CX_ROT_LENGTH elements), with freq. domain samples
-                type Int32 *
-
-    Data_out  = Output vector with a post-rotation by exp(-j(2pi/N)(k+1/8)),
-                (sized for short windows 2*FWD_SHORT_CX_ROT_LENGTH)
-                type Int32 *
-
-    max       = Input, carries the maximum value of the input vector
-                "Data_in"
-                type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
-    Results are return in "Data_out"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    fwd_short_complex_rot() performs the complex rotation for the MDCT
-    for the case of short windows. It performs digit reverse ordering as well
-    word normalization to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    fwd_short_complex_rot() should execute a pre-rotation by
-    exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fwd_short_complex_rot.h"
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "pv_normalize.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int fwd_short_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max)
-
-{
-    Int     i;
-    Int16     I;
-    const   Int16 *pTable;
-    const   Int32 *p_rotate;
-
-    Int32   *pData_in_1;
-    Int     exp;
-    Int32   temp_re;
-    Int32   temp_im;
-
-    Int32   cos_n;
-    Int32   sin_n;
-    Int32   temp_re_32;
-    Int32   temp_im_32;
-
-    Int32   *pData_in_ref;
-
-    Int32   *pData_out_1;
-    Int32   *pData_out_2;
-    Int32   *pData_out_3;
-    Int32   *pData_out_4;
-
-    pTable    =  digit_reverse_64;
-    p_rotate  =  exp_rotation_N_256;
-
-    pData_in_ref  =  Data_in;
-
-    exp = 16 - pv_normalize(max);
-
-    if (exp < 0)
-    {
-        exp = 0;
-    }
-
-    pData_out_1 = Data_out;
-    pData_out_2 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1];
-    pData_out_3 = &Data_out[TWICE_FWD_SHORT_CX_ROT_LENGTH];
-    pData_out_4 = &Data_out[FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1];
-
-    /*
-     *  Data_out
-     *                                   >>>>                   <<<<
-     *                                pData_out_3             pData_out_4
-     *      |             |             |             |             |
-     * pData_out_1               pData_out_2
-     *      >>>>                     <<<<
-     */
-
-
-    for (i = FWD_SHORT_CX_ROT_LENGTH; i != 0; i--)
-    {
-        /*
-         *   Perform digit reversal by accessing index I from table
-         */
-
-        I = *pTable++;
-        pData_in_1 = pData_in_ref + I;
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-
-        sin_n = *p_rotate++;
-        cos_n = sin_n >> 16;
-        sin_n = sin_n & 0xFFFF;
-
-        /*
-         *  Use auxiliary variables to avoid double accesses to memory.
-         *  Data in is scaled to use only lower 16 bits.
-         */
-
-        temp_re =  *(pData_in_1++) >> exp;
-        temp_im =  *(pData_in_1) >> exp;
-
-        /*
-         *   Pre-rotation
-         */
-
-        temp_re_32 = (temp_re * cos_n + temp_im * sin_n) >> 16;
-        temp_im_32 = (temp_im * cos_n - temp_re * sin_n) >> 16;
-
-        *(pData_out_1++) = - temp_re_32;
-        *(pData_out_2--) =   temp_im_32;
-        *(pData_out_3++) = - temp_im_32;
-        *(pData_out_4--) =   temp_re_32;
-
-        /*
-         *   Pointer increment to jump over imag (1 & 4) or real parts
-         *   (2 & 3)
-         */
-
-        pData_out_1++;
-        pData_out_2--;
-        pData_out_3++;
-        pData_out_4--;
-
-    } /* for(i) */
-
-    return (exp);
-}
diff --git a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h b/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h
deleted file mode 100644
index 3d1e1f1..0000000
--- a/media/libstagefright/codecs/aacdec/fwd_short_complex_rot.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fwd_short_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions fwd_short_complex_rot
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef FWD_SHORT_COMPLEX_ROT_H
-#define FWD_SHORT_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define FWD_SHORT_CX_ROT_LENGTH             64
-#define TWICE_FWD_SHORT_CX_ROT_LENGTH       (FWD_SHORT_CX_ROT_LENGTH<<1)
-#define TWICE_FWD_SHORT_CX_ROT_LENGTH_m_1   ((FWD_SHORT_CX_ROT_LENGTH<<1) - 1)
-#define FOUR_FWD_SHORT_CX_ROT_LENGTH_m_1    ((FWD_SHORT_CX_ROT_LENGTH<<2) - 1)
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int fwd_short_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* FWD_SHORT_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32.h b/media/libstagefright/codecs/aacdec/fxp_mul32.h
deleted file mode 100644
index 230cef5..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32
-#define FXP_MUL32
-
-#if   defined(PV_ARM_V5)
-
-#include "fxp_mul32_arm_v5.h"
-
-#elif defined(PV_ARM_V4)
-
-#include "fxp_mul32_arm_v4.h"
-
-#elif defined(PV_ARM_MSC_EVC_V4)
-
-#include "fxp_mul32_c_msc_evc.h"
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-#include "fxp_mul32_c_msc_evc_armv5.h"
-
-#elif defined(PV_ARM_GCC_V5)
-
-#include "fxp_mul32_arm_gcc.h"
-
-#elif defined(PV_ARM_GCC_V4)
-
-#include "fxp_mul32_arm_v4_gcc.h"
-
-#else
-
-#ifndef C_EQUIVALENT
-#define C_EQUIVALENT
-#endif
-
-#include "fxp_mul32_c_equivalent.h"
-
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h
deleted file mode 100644
index dc58976..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_gcc.h
+++ /dev/null
@@ -1,547 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_arm_gcc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_GCC
-#define FXP_MUL32_ARM_GCC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if (defined (PV_ARM_GCC_V4) || defined(PV_ARM_GCC_V5)) /* ARM GNU COMPILER  */
-
-
-
-#define preload_cache( a)
-
-
-    static inline Int32 shft_lft_1(Int32 y)
-    {
-        register Int32 x;
-        register Int32 ra = y;
-
-
-        asm volatile(
-            "qadd %0, %1, %1\n\t"
-    : "=&r*i"(x)
-                    : "r"(ra));
-
-        return (x);
-    }
-
-    static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, const Int32 L_var2)
-    {
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smulbb %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-
-    static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, const Int32 L_var2)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smultb %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-    static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, const Int32 L_var2)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smulbt %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-    static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, const Int32 L_var2)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smultt %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-    static inline Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "smlabb %0, %1, %2, %3"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp);
-    }
-
-
-
-    static inline Int32 fxp_mac_16_by_16_bb(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "smlabb %0, %1, %2, %3"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp);
-    }
-
-
-    static inline Int32 fxp_mac_16_by_16_bt(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "smlabt %0, %1, %2, %3"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp);
-    }
-
-
-
-    static inline Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
-{
-        register Int32 cx_sum;
-        register Int32 rx = (Int32)x;
-        register Int32 ry = (Int32)y;
-        register Int32 rexp = (Int32)exp_jw;
-        asm volatile(
-            "smulwt %0, %1, %3\n\t"
-            "smlawb %0, %2, %3, %0"
-    : "=&r*i"(cx_sum)
-                    : "r"(rx),
-                    "r"(ry),
-                    "r"(rexp));
-
-        return (cx_sum);
-    }
-
-
-    static inline Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smulwb %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-
-    static inline Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "smulwt %0, %1, %2"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp);
-    }
-
-
-
-    static inline Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-{
-
-        register Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "smlawb %0, %1, %2, %3"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp);
-    }
-
-
-    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-{
-        sum += (int64)L_var1 * L_var2;
-        return (sum);
-    }
-
-
-
-
-    static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add %4, %4, %0, asl #2\n\t"
-                     "add %0, %4, %1, lsr #30"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-{
-
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add %0, %0, %4"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_sub;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "sub %0, %4, %0"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile(
-            "smull %1, %0, %2, %3"
-    : "=&r*i"(result64_hi),
-            "=&r*i"(result64_lo)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #2\n\t"
-                     "orr   %0, %0, %1, lsr #30"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add   %4, %4, %0, lsl #3\n\t"
-                     "add   %0, %4, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_sub;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "sub   %4, %4, %0, lsl #3\n\t"
-                     "sub   %0, %4, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-    static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #3\n\t"
-                     "orr   %0, %0, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #4\n\t"
-                     "orr   %0, %0, %1, lsr #28"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-    static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #5\n\t"
-                     "orr   %0, %0, %1, lsr #27"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #6\n\t"
-                     "orr   %0, %0, %1, lsr #26"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #12\n\t"
-                     "orr   %0, %0, %1, lsr #20"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #17\n\t"
-                     "orr   %0, %0, %1, lsr #15"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2,  %3\n\t"
-                     "mov   %0, %0, lsl #18\n\t"
-                     "orr   %0, %0, %1, lsr #14"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h
deleted file mode 100644
index 6869c54..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4.h
+++ /dev/null
@@ -1,429 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_c_equivalent.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_V4
-#define FXP_MUL32_ARM_V4
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(PV_ARM_V4)
-
-#define preload_cache( a)
-
-
-    __inline  Int32 shft_lft_1(Int32 L_var1)
-    {
-        Int32 x;
-        Int32 z = 1; /* rvct compiler problem */
-        __asm
-        {
-            mov x, L_var1, asl 1
-            teq L_var1, x, asr z
-            eorne  x, INT32_MAX, L_var1, asr #31
-        }
-
-        return(x);
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-
-            mov L_var2, L_var2, asl #16
-            mov L_var2, L_var2, asr #16
-            mov L_var1, L_var1, asl #16
-            mov L_var1, L_var1, asr #16
-
-
-            mul L_var1, L_var2, L_var1
-        }
-
-        return L_var1;
-
-    }
-
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-
-    __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            mov L_var2, L_var2, asl #16
-            mov L_var2, L_var2, asr #16
-            mov L_var1, L_var1, asr #16
-
-            mul L_var1, L_var2, L_var1
-        }
-        return L_var1;
-    }
-
-    __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            mov L_var2, L_var2, asr #16
-            mov L_var1, L_var1, asl #16
-            mov L_var1, L_var1, asr #16
-
-            mul L_var1, L_var2, L_var1
-        }
-
-        return L_var1;
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            mov L_var2, L_var2, asr #16
-            mov L_var1, L_var1, asr #16
-
-            mul L_var1, L_var2, L_var1
-        }
-
-        return L_var1;
-
-    }
-
-    __inline  Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            mla L_add, L_var1, L_var2, L_add
-        }
-        return (L_add);
-    }
-
-
-    __inline  Int32 fxp_mac_16_by_16_bb(const Int32 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            mov L_var2, L_var2, asl #16
-            mov L_var2, L_var2, asr #16
-            mla L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            mov L_var2, L_var2, asr #16
-            mla L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-
-    __inline  Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
-    {
-
-        Int32 result64_hi;
-        Int32 rTmp0;
-        Int32 iTmp0;
-        __asm
-        {
-            mov rTmp0, exp_jw, asr #16
-            mov rTmp0, rTmp0, asl #16
-            mov iTmp0, exp_jw, asl #16
-            smull rTmp0, result64_hi, x, rTmp0
-            smlal iTmp0, result64_hi, y, iTmp0
-        }
-
-        return (result64_hi);
-    }
-
-
-    __inline  Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
-    {
-        Int32 result64_hi;
-        __asm
-        {
-            mov L_var2, L_var2, asl #16
-            smull L_var1, result64_hi, L_var2, L_var1
-        }
-        return (result64_hi);
-    }
-
-
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-
-
-    __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
-    {
-
-        Int32 result64_hi;
-        __asm
-        {
-            mov L_var2, L_var2, asr #16
-            mov L_var2, L_var2, asl #16
-            smull L_var1, result64_hi, L_var2, L_var1
-        }
-        return (result64_hi);
-
-    }
-
-    __inline  Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
-    {
-
-        __asm
-        {
-            mov L_var2, L_var2, asl #16
-            smlal L_var1, L_add, L_var2, L_var1
-        }
-
-        return (L_add);
-    }
-
-
-    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-    {
-        uint32 b = (UInt32)(sum);
-        int32 c = Int32(sum >> 32);
-        __asm
-        {
-            smlal b, c, L_var1, L_var2
-        }
-        return (((int64(c)) << 32) | b);
-    }
-
-
-    __inline  Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        __asm
-        {
-            smull L_var1, result64_hi, L_var2, L_var1
-        }
-        return (result64_hi);
-    }
-
-
-    __inline  Int32 fxp_mac32_Q31(Int32 L_add,  Int32 L_var1, const Int32 L_var2)
-    {
-        __asm
-        {
-            smlal L_var1, L_add, L_var2, L_var1
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_msu32_Q31(Int32 L_sub,  Int32 L_var1, const Int32 L_var2)
-    {
-        __asm
-        {
-            rsb   L_var1, L_var1, #0
-            smlal L_var1, L_sub, L_var2, L_var1
-        }
-        return L_sub;
-    }
-
-
-    __inline  Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #2
-            orr  result64_hi, result64_hi, result64_lo, lsr #30
-        }
-        return (result64_hi);
-    }
-
-
-    __inline  Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            add L_add, L_add, result64_hi, asl  #2
-            add L_add, L_add, result64_lo, lsr  #30
-        }
-        return (L_add);
-    }
-
-
-    __inline  Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #3
-            orr  result64_hi, result64_hi, result64_lo, lsr #29
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            add L_add, L_add, result64_hi, asl  #3
-            add L_add, L_add, result64_lo, lsr  #29
-        }
-        return (L_add);
-    }
-
-    __inline  Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            sub L_sub, L_sub, result64_hi, asl  #3
-            sub L_sub, L_sub, result64_lo, lsr  #29
-        }
-        return (L_sub);
-    }
-
-    __inline  Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #4
-            orr  result64_hi, result64_hi, result64_lo, lsr #28
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #5
-            orr  result64_hi, result64_hi, result64_lo, lsr #27
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #6
-            orr  result64_hi, result64_hi, result64_lo, lsr #26
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #12
-            orr  result64_hi, result64_hi, result64_lo, lsr #20
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #17
-            orr  result64_hi, result64_hi, result64_lo, lsr #15
-        }
-        return (result64_hi);
-    }
-
-
-
-
-    __inline  Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #18
-            orr  result64_hi, result64_hi, result64_lo, lsr #14
-        }
-        return (result64_hi);
-    }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h
deleted file mode 100755
index f4ab2f7..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v4_gcc.h
+++ /dev/null
@@ -1,630 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_arm_v4_gcc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-
-
-#ifndef FXP_MUL32_V4_ARM_GCC
-#define FXP_MUL32_V4_ARM_GCC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined (_ARM_V4_GCC) /* ARM_V4 GNU COMPILER  */
-
-
-#define preload_cache( a)
-
-
-    static inline  Int32 shft_lft_1(Int32 L_var1)
-    {
-        Int32 x;
-        register Int32 ra = L_var1;
-        Int32 z = INT32_MAX;
-
-        asm volatile(
-            "mov %0, %1, asl #1\n\t"
-            "teq %1, %0, asr #1\n\t"
-            "eorne   %0, %2, %1, asr #31"
-    : "=&r*i"(x)
-                    : "r"(ra),
-                    "r"(z));
-
-        return(x);
-    }
-
-    static inline Int32 fxp_mul_16_by_16bb(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %3, asl #16\n\t"
-            "mov %0, %0, asr #16\n\t"
-            "mov %1, %2, asl #16\n\t"
-            "mov %1, %1, asr #16\n\t"
-            "mul %0, %1, %0"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp1);
-
-    }
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-
-    static inline Int32 fxp_mul_16_by_16tb(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %3, asl #16\n\t"
-            "mov %0, %0, asr #16\n\t"
-            "mov %1, %2, asr #16\n\t"
-            "mul %0, %1, %0"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp1);
-
-    }
-
-
-    static inline Int32 fxp_mul_16_by_16bt(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %3, asr #16\n\t"
-            "mov %1, %2, asl #16\n\t"
-            "mov %1, %1, asr #16\n\t"
-            "mul %0, %1, %0"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp1);
-
-    }
-
-
-    static inline Int32 fxp_mul_16_by_16tt(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %3, asr #16\n\t"
-            "mov %1, %2, asr #16\n\t"
-            "mul %0, %1, %0"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (tmp1);
-
-    }
-
-
-
-    static inline  Int32 fxp_mac_16_by_16(Int16 L_var1,  Int16 L_var2, Int32 L_add)
-{
-
-        Int32 tmp;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "mla %0, %1, %2, %3"
-    : "=&r*i"(tmp)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp);
-    }
-
-
-
-    static inline Int32 fxp_mac_16_by_16_bb(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "mov %0, %3, asl #16\n\t"
-            "mov %0, %0, asr #16\n\t"
-            "mla %1, %0, %2, %4"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp2);
-    }
-
-
-
-    static inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-{
-
-        Int32 tmp1;
-        Int32 tmp2;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "mov %0, %3, asr #16\n\t"
-            "mla %1, %0, %2, %4"
-    : "=&r*i"(tmp1),
-            "=&r*i"(tmp2)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (tmp2);
-
-    }
-
-
-
-    static inline  Int32 cmplx_mul32_by_16(Int32 x, Int32 y, Int32 exp_jw)
-{
-
-        Int32 rTmp0;
-        Int32 iTmp0;
-        Int32 result64_hi;
-        register Int32 ra = (Int32)x;
-        register Int32 rb = (Int32)y;
-        register Int32 rc = (Int32)exp_jw;
-
-
-
-        asm volatile(
-            "mov %0, %5, asr #16\n\t"
-            "mov %1, %5, asl #16\n\t"
-            "mov %0, %0, asl #16\n\t"
-    : "=&r*i"(rTmp0),
-            "=&r*i"(iTmp0),
-            "=&r*i"(result64_hi)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-
-        asm volatile(
-            "smull %0, %2, %3, %0\n\t"
-            "smlal %1, %2, %4, %1"
-    : "=&r*i"(rTmp0),
-            "=&r*i"(iTmp0),
-            "=&r*i"(result64_hi)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (result64_hi);
-
-
-    }
-
-
-    static inline  Int32 fxp_mul32_by_16(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 rTmp0;
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %4, asl #16\n\t"
-            "smull %2, %1, %0, %3"
-    : "=&r*i"(rTmp0),
-            "=&r*i"(result64_hi),
-            "=&r*i"(result64_lo)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-
-
-    static inline  Int32 fxp_mul32_by_16t(Int32 L_var1, Int32 L_var2)
-{
-
-        Int32 rTmp0;
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-
-        asm volatile(
-            "mov %0, %4, asr #16\n\t"
-            "mov %0, %0, asl #16\n\t"
-            "smull %2, %1, %0, %3"
-    : "=&r*i"(rTmp0),
-            "=&r*i"(result64_hi),
-            "=&r*i"(result64_lo)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-
-    static inline  Int32 fxp_mac32_by_16(Int32 L_var1, Int32 L_var2, Int32 L_add)
-{
-
-        Int32 rTmp0;
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)L_var1;
-        register Int32 rb = (Int32)L_var2;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile(
-            "mov %0, %4, asl #16\n\t"
-            "mov %1, %5\n\t"
-            "smlal %2, %1, %0, %3"
-    : "=&r*i"(rTmp0),
-            "=&r*i"(result64_hi),
-            "=&r*i"(result64_lo)
-                    : "r"(ra),
-                    "r"(rb),
-                    "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-    static inline int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-{
-        sum += (int64)L_var1 * L_var2;
-        return (sum);
-    }
-
-
-    static inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add %4, %4, %0, asl #2\n\t"
-                     "add %0, %4, %1, lsr #30"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-{
-
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add %0, %0, %4"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_sub;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "sub %0, %4, %0"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile(
-            "smull %1, %0, %2, %3"
-    : "=&r*i"(result64_hi),
-            "=&r*i"(result64_lo)
-                    : "r"(ra),
-                    "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #2\n\t"
-                     "orr   %0, %0, %1, lsr #30"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_add;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "add   %4, %4, %0, lsl #3\n\t"
-                     "add   %0, %4, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        register Int32 rc = (Int32)L_sub;
-
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "sub   %4, %4, %0, lsl #3\n\t"
-                     "sub   %0, %4, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb),
-                             "r"(rc));
-
-        return (result64_hi);
-    }
-
-    static inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #3\n\t"
-                     "orr   %0, %0, %1, lsr #29"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #4\n\t"
-                     "orr   %0, %0, %1, lsr #28"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-        return (result64_hi);
-    }
-
-    static inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #5\n\t"
-                     "orr   %0, %0, %1, lsr #27"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #6\n\t"
-                     "orr   %0, %0, %1, lsr #26"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #12\n\t"
-                     "orr   %0, %0, %1, lsr #20"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-    static inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2, %3\n\t"
-                     "mov %0, %0, lsl #17\n\t"
-                     "orr   %0, %0, %1, lsr #15"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-
-
-    static inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-{
-        Int32 result64_hi;
-        Int32 result64_lo;
-        register Int32 ra = (Int32)a;
-        register Int32 rb = (Int32)b;
-        asm volatile("smull %1, %0, %2,  %3\n\t"
-                     "mov   %0, %0, lsl #18\n\t"
-                     "orr   %0, %0, %1, lsr #14"
-             : "=&r*i"(result64_hi),
-                     "=&r*i"(result64_lo)
-                             : "r"(ra),
-                             "r"(rb));
-
-        return (result64_hi);
-    }
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32_V4_ARM_GCC  */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h b/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h
deleted file mode 100644
index 8ab108f..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_arm_v5.h
+++ /dev/null
@@ -1,450 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_arm_v5.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_ARM_V5
-#define FXP_MUL32_ARM_V5
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(PV_ARM_V5)
-
-//#undef EXTENDED_ASM
-#define EXTENDED_ASM
-#define _ARM_V5_
-
-
-    __inline  Int32 shft_lft_1(Int32 L_var1)
-    {
-        __asm
-        {
-            qadd L_var1, L_var1, L_var1
-        }
-
-        return L_var1;
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            smulbb L_var1, L_var1, L_var2
-        }
-        return L_var1;
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            smulbb L_var1, L_var1, L_var2
-        }
-        return L_var1;
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            smultb L_var1, L_var1, L_var2
-        }
-        return L_var1;
-    }
-
-    __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            smultt L_var1, L_var1, L_var2
-        }
-        return L_var1;
-    }
-
-    __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
-    {
-        __asm
-        {
-            smulbt L_var1, L_var1, L_var2
-        }
-        return L_var1;
-    }
-
-
-
-    __inline  Int32 fxp_mac_16_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlabb L_add, L_var1, L_var2, L_add
-        }
-        return (L_add);
-    }
-
-    __inline  Int32 fxp_mac_16_by_16_bb(const Int32 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlabb L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_mac_16_by_16_bt(const Int32 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlabt L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-
-    __inline  Int32 fxp_mac_16_by_16_tb(const Int32 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlatb L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_mac_16_by_16_tt(const Int32 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlatt L_add, L_var1, L_var2, L_add
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_mac32_by_16(Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        __asm
-        {
-            smlawb L_add, L_var1, L_var2, L_add
-        }
-        return (L_add);
-    }
-
-
-    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-    {
-        uint32 b = (UInt32)(sum);
-        int32 c = Int32(sum >> 32);
-        __asm
-        {
-            smlal b, c, L_var1, L_var2
-        }
-        return (((int64(c)) << 32) | b);
-    }
-
-
-    __inline  Int32 fxp_mac32_Q31(Int32 L_add,  Int32 L_var1, const Int32 L_var2)
-    {
-        __asm
-        {
-            smlal L_var1, L_add, L_var2, L_var1
-        }
-        return L_add;
-    }
-
-    __inline  Int32 fxp_msu32_Q31(Int32 L_sub,  Int32 L_var1, const Int32 L_var2)
-    {
-        __asm
-        {
-            rsb   L_var1, L_var1, #0
-            smlal L_var1, L_sub, L_var2, L_var1
-        }
-        return L_sub;
-    }
-
-    __inline  Int32 fxp_mul32_Q31(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        __asm
-        {
-            smull L_var1, result64_hi, L_var2, L_var1
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q30(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #2
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #30
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #30
-#endif
-        }
-        return (result64_hi);
-    }
-
-
-    __inline  Int32 fxp_mac32_Q30(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            add L_add, L_add, result64_hi, asl  #2
-            add L_add, L_add, result64_lo, lsr  #30
-        }
-        return (L_add);
-    }
-
-
-    __inline  Int32 fxp_mul32_Q29(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #3
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #29
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #29
-#endif
-        }
-        return (result64_hi);
-    }
-
-
-
-    __inline  Int32 fxp_mac32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            add L_add, L_add, result64_hi, asl  #3
-            add L_add, L_add, result64_lo, lsr  #29
-        }
-        return (L_add);
-    }
-
-
-    __inline  Int32 fxp_msu32_Q29(const Int32 L_var1, const Int32 L_var2, Int32 L_sub)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            sub L_sub, L_sub, result64_hi, asl  #3
-            sub L_sub, L_sub, result64_lo, lsr  #29
-        }
-        return (L_sub);
-    }
-
-
-    __inline  Int32 fxp_mul32_Q28(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #4
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #28
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #28
-#endif
-
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q27(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #5
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #27
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #27
-#endif
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q26(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #6
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #26
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #26
-#endif
-
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q20(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #12
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #20
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #20
-#endif
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        __asm
-        {
-            smulwb result64_hi, L_var1, L_var2
-        }
-        return (result64_hi);
-    }
-
-#define fxp_mul32_by_16b( a, b)         fxp_mul32_by_16(a, b)
-
-    __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        __asm
-        {
-            smulwt result64_hi, L_var1, L_var2
-        }
-        return (result64_hi);
-    }
-
-    __inline  Int32 fxp_mul32_Q15(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #17
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #15
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #15
-#endif
-        }
-        return (result64_hi);
-    }
-
-
-    __inline  Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
-    {
-        Int32 result64_hi;
-
-        __asm
-        {
-            smulwt result64_hi, L_var1, cmplx
-            smlawb result64_hi, L_var2, cmplx, result64_hi
-        }
-        return (result64_hi);
-
-    }
-
-    __inline  Int32 fxp_mul32_Q14(const Int32 L_var1, const Int32 L_var2)
-    {
-        Int32 result64_hi;
-        Int32 result64_lo;
-        __asm
-        {
-            smull result64_lo, result64_hi, L_var2, L_var1
-            mov result64_hi, result64_hi, asl  #18
-#ifdef EXTENDED_ASM
-            mov result64_lo, result64_lo, lsr  #14
-            orr  result64_hi, result64_lo, result64_hi
-#else
-            orr  result64_hi, result64_hi, result64_lo, lsr #14
-#endif
-        }
-        return (result64_hi);
-    }
-
-
-#define preload_cache( a)
-
-
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h
deleted file mode 100644
index 5bcbe53..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_equivalent.h
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./c/include/fxp_mul32_c_equivalent.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_C_EQUIVALENT
-#define FXP_MUL32_C_EQUIVALENT
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-#if defined(C_EQUIVALENT)
-
-#define preload_cache( a)
-
-    __inline  Int32 shft_lft_1(Int32 L_var1)
-    {
-        if (((L_var1 << 1) >> 1) == L_var1)
-            L_var1 <<= 1;
-        else
-            L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
-
-        return (L_var1);
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-        L_var1 = (L_var1 << 16) >> 16;
-
-        L_var1 *= L_var2;
-
-        return L_var1;
-
-    }
-
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-
-    __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-        L_var1 =  L_var1 >> 16;
-
-        L_var1 *= L_var2;
-
-        return L_var1;
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = L_var2 >> 16;
-        L_var1 = (L_var1 << 16) >> 16;
-
-        L_var1 *= L_var2;
-
-        return L_var1;
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = L_var2 >> 16;
-        L_var1 = L_var1 >> 16;
-
-        L_var1 *= L_var2;
-
-        return L_var1;
-
-    }
-
-    __inline  Int32 fxp_mac_16_by_16(Int16 L_var1,  Int16 L_var2, Int32 L_add)
-    {
-
-        L_add += L_var1 * L_var2;
-
-        return L_add;
-
-    }
-
-
-
-
-
-    __inline  Int32 fxp_mac_16_by_16_bb(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-
-        L_add += L_var1 * L_var2;
-
-        return L_add;
-
-    }
-
-
-    __inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        L_var2 = L_var2 >> 16;
-
-        L_add += L_var1 * L_var2;
-
-        return L_add;
-
-    }
-
-
-
-
-
-    __inline  Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
-    {
-        Int32  rTmp0 = (Int16)(exp_jw >> 16);
-        Int32  iTmp0 = exp_jw;
-        Int32  z;
-
-        z  = (Int32)(((int64_t)x * (rTmp0 << 16)) >> 32);
-        z += (Int32)(((int64_t)y * (iTmp0 << 16)) >> 32);
-
-        return (z);
-    }
-
-
-    __inline  Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32  z;
-
-        z = (Int32)(((int64_t) L_var1 * (L_var2 << 16)) >> 32);
-        return(z);
-    }
-
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-
-    __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32  rTmp0 = (Int16)(L_var2 >> 16);
-        Int32  z;
-
-        z = (Int32)(((int64_t) L_var1 * (rTmp0 << 16)) >> 32);
-
-        return(z);
-    }
-
-
-    __inline  Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-        Int32  rTmp0 = L_var2 << 16;
-
-        L_add += (Int32)(((int64_t) L_var1 * rTmp0) >> 32);
-
-        return(L_add);
-    }
-
-    __inline  int64_t fxp_mac64_Q31(int64_t sum, const Int32 L_var1, const Int32 L_var2)
-    {
-        sum += (int64_t)L_var1 * L_var2;
-        return (sum);
-    }
-
-    __inline Int32 fxp_mul32_Q31(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 32);
-    }
-
-    __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-    {
-        return (L_add + (Int32)(((int64_t)(a) * b) >> 32));
-    }
-
-    __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-    {
-        return (L_sub - (Int32)(((int64_t)(a) * b) >> 32));
-    }
-
-
-    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 30);
-    }
-
-    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64_t)(a) * b) >> 30));
-    }
-
-
-    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 29);
-    }
-
-    __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64_t)(a) * b) >> 29));
-    }
-
-    __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-    {
-        return (L_sub - (Int32)(((int64_t)(a) * b) >> 29));
-    }
-
-
-    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 28);
-    }
-
-    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 27);
-    }
-
-    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 26);
-    }
-
-    __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 20);
-    }
-
-    __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 15);
-    }
-
-    __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64_t)(a) * b) >> 14);
-    }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h
deleted file mode 100644
index 64397cf..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc.h
+++ /dev/null
@@ -1,254 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fxp_mul32_msc_evc.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-
-#ifndef FXP_MUL32_MSC_EVC
-#define FXP_MUL32_MSC_EVC
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-#if defined(PV_ARM_MSC_EVC_V4)
-
-#include "cmnintrin.h"
-
-#define preload_cache( a)
-
-    __inline  Int32 shft_lft_1(Int32 L_var1)
-    {
-        if (((L_var1 << 1) >> 1) == L_var1)
-            L_var1 <<= 1;
-        else
-            L_var1 = ((L_var1 >> 31) ^ INT32_MAX);
-
-        return L_var1;
-
-    }
-
-    __inline  Int32 fxp_mul_16_by_16bb(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-        L_var1 = (L_var1 << 16) >> 16;
-
-        return (L_var1*L_var2);
-
-    }
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-    __inline  Int32 fxp_mul_16_by_16tb(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-        L_var1 =  L_var1 >> 16;
-
-        return (L_var1*L_var2);
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16bt(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = L_var2 >> 16;
-        L_var1 = (L_var1 << 16) >> 16;
-
-        return (L_var1*L_var2);
-
-    }
-
-
-    __inline  Int32 fxp_mul_16_by_16tt(Int32 L_var1,  Int32 L_var2)
-    {
-        L_var2 = L_var2 >> 16;
-        L_var1 = L_var1 >> 16;
-
-        return (L_var1*L_var2);
-
-    }
-
-    __inline  Int32 fxp_mac_16_by_16(Int16 L_var1,  Int16 L_var2, Int32 L_add)
-    {
-        return (L_add + (L_var1*L_var2));
-    }
-
-
-
-    __inline  Int32 fxp_mac_16_by_16_bb(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        L_var2 = (L_var2 << 16) >> 16;
-
-        return (L_add + (L_var1*L_var2));
-
-    }
-
-
-    __inline  Int32 fxp_mac_16_by_16_bt(Int16 L_var1,  Int32 L_var2, Int32 L_add)
-    {
-        L_var2 = L_var2 >> 16;
-
-        return (L_add + (L_var1*L_var2));
-
-    }
-
-
-    __inline  Int32 cmplx_mul32_by_16(Int32 x, const Int32 y, Int32 exp_jw)
-    {
-        Int32  rTmp0 = (exp_jw >> 16) << 16;
-        Int32  iTmp0 = exp_jw << 16;
-        Int32  z;
-
-
-        z  = _MulHigh(rTmp0, x);
-        z += _MulHigh(iTmp0, y);
-
-        return (z);
-    }
-
-
-    __inline  Int32 fxp_mul32_by_16(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32  rTmp0 = L_var2 << 16;
-
-        return(_MulHigh(rTmp0, L_var1));
-    }
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-
-    __inline  Int32 fxp_mul32_by_16t(Int32 L_var1, const Int32 L_var2)
-    {
-        Int32  rTmp0 = (Int16)(L_var2 >> 16);
-
-        return(_MulHigh((rTmp0 << 16), L_var1));
-    }
-
-
-    __inline  Int32 fxp_mac32_by_16(const Int32 L_var1, const Int32 L_var2, Int32 L_add)
-    {
-
-        Int32  rTmp0 = (L_var2 << 16);
-
-        return(L_add + _MulHigh(rTmp0, L_var1));
-    }
-
-    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-    {
-        sum += (int64)L_var1 * L_var2;
-        return (sum);
-    }
-
-#define fxp_mul32_Q31( a,  b)   _MulHigh( b, a)
-
-    __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-    {
-        return (L_add + _MulHigh(b, a));
-    }
-
-    __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-    {
-        return (L_sub - _MulHigh(b, a));
-    }
-
-
-    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 30);
-    }
-
-    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64)(a) * b) >> 30));
-    }
-
-
-    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 29);
-    }
-
-    __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64)(a) * b) >> 29));
-    }
-
-    __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-    {
-        return (L_sub - (Int32)(((int64)(a) * b) >> 29));
-    }
-
-
-    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 28);
-    }
-
-    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 27);
-    }
-
-    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 26);
-    }
-
-    __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 20);
-    }
-
-    __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 15);
-    }
-
-    __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 14);
-    }
-
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h b/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h
deleted file mode 100644
index 04cbf49..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_c_msc_evc_armv5.h
+++ /dev/null
@@ -1,178 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fxp_mul32_msc_evc_armv5.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_MSC_EVC_ARMV5
-#define FXP_MUL32_MSC_EVC_ARMV5
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-#if defined(PV_ARM_MSC_EVC_V5)
-
-#include "armintr.h"
-#include "cmnintrin.h"
-
-#define preload_cache( a)
-
-#define shft_lft_1( L_var1)  _AddSatInt( L_var1, L_var1)
-
-#define fxp_mul_16_by_16bb( L_var1, L_var2)  _SmulLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16(a, b)  fxp_mul_16_by_16bb(  a, b)
-
-#define fxp_mul_16_by_16tb( L_var1, L_var2)  _SmulHiLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16bt( L_var1, L_var2)  _SmulLoHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mul_16_by_16tt( L_var1, L_var2)  _SmulHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mac_16_by_16( L_var1, L_var2, L_add)  _SmulAddLo_SW_SL( L_add, L_var1, L_var2)
-
-#define fxp_mac_16_by_16_bb(a, b, c)  fxp_mac_16_by_16(  a, b, c)
-
-#define fxp_mac_16_by_16_bt( L_var1, L_var2, L_add)  _SmulAddLoHi_SW_SL( L_add, L_var1, L_var2)
-
-
-    __inline  Int32 cmplx_mul32_by_16(Int32 L_var1, const Int32 L_var2, const Int32 cmplx)
-    {
-        Int32 result64_hi;
-
-        result64_hi = _SmulWHi_SW_SL(L_var1, cmplx);
-        result64_hi = _SmulAddWLo_SW_SL(result64_hi, L_var2, cmplx);
-
-        return (result64_hi);
-    }
-
-#define fxp_mul32_by_16( L_var1, L_var2)  _SmulWLo_SW_SL( L_var1, L_var2)
-
-#define fxp_mul32_by_16b( a, b)   fxp_mul32_by_16( a, b)
-
-#define fxp_mul32_by_16t( L_var1, L_var2)  _SmulWHi_SW_SL( L_var1, L_var2)
-
-#define fxp_mac32_by_16( L_var1, L_var2, L_add)  _SmulAddWLo_SW_SL( L_add, L_var1, L_var2)
-
-
-    __inline  int64 fxp_mac64_Q31(int64 sum, const Int32 L_var1, const Int32 L_var2)
-    {
-        sum += (int64)L_var1 * L_var2;
-        return (sum);
-    }
-
-#define fxp_mul32_Q31( a,  b)   _MulHigh( b, a)
-
-
-    __inline Int32 fxp_mac32_Q31(Int32 L_add, const Int32 a, const Int32 b)
-    {
-        return (L_add + _MulHigh(b, a));
-    }
-
-
-    __inline Int32 fxp_msu32_Q31(Int32 L_sub, const Int32 a, const Int32 b)
-    {
-        return (L_sub - _MulHigh(b, a));
-    }
-
-
-    __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 30);
-    }
-
-    __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64)(a) * b) >> 30));
-    }
-
-
-    __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 29);
-    }
-
-    __inline Int32 fxp_mac32_Q29(const Int32 a, const Int32 b, Int32 L_add)
-    {
-        return (L_add + (Int32)(((int64)(a) * b) >> 29));
-    }
-
-    __inline Int32 fxp_msu32_Q29(const Int32 a, const Int32 b, Int32 L_sub)
-    {
-        return (L_sub - (Int32)(((int64)(a) * b) >> 29));
-    }
-
-
-    __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 28);
-    }
-
-    __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 27);
-    }
-
-    __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 26);
-    }
-
-    __inline Int32 fxp_mul32_Q20(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 20);
-    }
-
-    __inline Int32 fxp_mul32_Q15(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 15);
-    }
-
-    __inline Int32 fxp_mul32_Q14(const Int32 a, const Int32 b)
-    {
-        return (Int32)(((int64)(a) * b) >> 14);
-    }
-
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h b/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h
deleted file mode 100644
index 72862e7..0000000
--- a/media/libstagefright/codecs/aacdec/fxp_mul32_pentium.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .fxp_mul32_pentium.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef FXP_MUL32_PENTIUM
-#define FXP_MUL32_PENTIUM
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-#include "pv_audio_type_defs.h"
-
-
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif   /*  FXP_MUL32  */
-
diff --git a/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp b/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp
deleted file mode 100644
index 08ccc4a..0000000
--- a/media/libstagefright/codecs/aacdec/gen_rand_vector.cpp
+++ /dev/null
@@ -1,512 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to remove instances of pow() and sqrt(), and
- optimized for inclusion in fixed-point version of decoder.
-
- Description:  Modified to include comments/optimizations from code review.
- Also, declared appropriate variables as type "const"
-
- Description:  Adopted strategy of "one q-format per sfb" strategy, which
- eliminated the array q-format from this function.  The q-format the
- random vector is stored in is now returned from the function.
-
- Description:  Completely redesigned the routine to allow a simplified
-        calculation of the adjusted noise, by eliminating the dependency
-        on the band_length. Added polynomial approximation for the
-        function 1/sqrt(power). Updated comments and pseudo-code
-
- Description:  Modified function description, pseudocode, etc.
-
- Description:
-    Modified casting to ensure proper operations for different platforms
-
- Description:
-    Eliminiated access to memory for noise seed. Now a local variable is
-    used. Also unrolled loops to speed up code.
-
- Description:
-    Modified pointer decrement to a pointer increment, to ensure proper
-    compiler behavior
-
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:    random_array[] = Array for storage of the power-scaled
-                             random values of length "band_length"
-            Int32
-
-            band_length    = Length of random_array[]
-            const Int
-
-            pSeed          = seed for random number generator
-            Int32*
-
-            power_scale    = scale factor for this particular band
-            const Int
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:   Function returns the q-format the random vector is stored in.
-
- Pointers and Buffers Modified:
-            random_array[] = filled with random numbers scaled
-            to the correct power as defined by the input value power_scale.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function generates a vector of uniformly distributed random numbers for
- the PNS block.  The random numbers are each scaled by a scale_factor,
- defined in Ref(2) as
-
- 2^(scale_factor/4)
- ------------------
-  sqrt(N*MEAN_NRG)
-
- where N == band_length, and MEAN_NRG is defined as...
-
-         N-1
-         ___
-     1   \
-    ---   >    x(i)^2
-     N   /__
-         i=0
-
- And x is the unscaled vector from the random number generator.
-
- This function takes advantage of the fact that the portion of the
- scale_factor that is divisible by 4 can be simply accounted for by varying
- the q-format.
-
- The scaling of the random numbers is thus broken into the
- equivalent equation below.
-
- 2^(scale_factor%4)   2^(floor(scale_factor/4))
- ------------------ *
-  sqrt(N*MEAN_NRG)
-
-
- 2^(scale_factor%4) is stored in a simple 4-element table.
- 2^(floor(scale_factor/4) is accounted for by adjusting the q-format.
- sqrt(N*MEAN_NRG) is calculated and implemented via a polynomial approximation.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall produce uniformly distributed random 32-bit integers,
- with signed random values of average energy equal to the results of the ISO
- code's multiplying factor discussed in the FUNCTION DESCRIPTION section.
-
- Please see Ref (2) for a detailed description of the requirements.
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) Numerical Recipes in C     Second Edition
-        William H. Press        Saul A. Teukolsky
-        William T. Vetterling   Brian P. Flannery
-        Page 284
-
- (2) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.12 (Perceptual Noise Substitution)
-
- (3) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    power_adj = scale_mod_4[power_scale & 3];
-
-    power = 0;
-
-    FOR (k=band_length; k > 0; k--)
-
-        *(pSeed) = *(pSeed) * 1664525L;
-        *(pSeed) = *(pSeed) + 1013904223L;
-
-        temp = (Int)(*(pSeed) >> 16);
-
-        power = power + ((temp*temp) >> 6);
-
-        *(pArray) = (Int32)temp;
-
-        pArray = pArray + 1;
-
-    ENDFOR
-
-    k = 0;
-    q_adjust = 30;
-
-    IF (power)
-    THEN
-
-        WHILE ( power > 32767)
-
-            power = power >> 1;
-            k = k + 1;
-
-        ENDWHILE
-
-        k = k - 13;
-
-        IF (k < 0)
-        THEN
-            k = -k;
-            IF ( k & 1 )
-            THEN
-                power_adj = (power_adj*SQRT_OF_2)>>14;
-            ENDIF
-            q_adjust = q_adjust - ( k >> 1);
-
-        ELSE IF (k > 0)
-        THEN
-            IF ( k & 1  )
-            THEN
-                power_adj = (power_adj*INV_SQRT_OF_2)>>14;
-            ENDIF
-            q_adjust = q_adjust + ( k >> 1);
-        ENDIF
-
-        pInvSqrtCoeff = inv_sqrt_coeff;
-
-        inv_sqrt_power  = (*(pInvSqrtCoeff)* power) >>15;
-
-        pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
-        inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
-
-        pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
-        FOR ( k=INV_SQRT_POLY_ORDER - 1; k>0; k--)
-
-            inv_sqrt_power  =  ( inv_sqrt_power * power)>>15;
-
-            inv_sqrt_power = inv_sqrt_power + *(pInvSqrtCoeff);
-
-            pInvSqrtCoeff = pInvSqrtCoeff + 1;
-
-        ENDFOR
-
-        inv_sqrt_power = (inv_sqrt_power*power_adj)>>13;
-
-        FOR (k=band_length; k > 0; k--)
-
-            pArray = pArray - 1;
-
-            *(pArray) = *(pArray)*inv_sqrt_power;
-
-        ENDFOR
-
-    ENDIF
-
-    q_adjust = q_adjust - (power_scale >> 2);
-
-    return q_adjust;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "gen_rand_vector.h"
-#include    "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define     SQRT_OF_2       23170       /*    sqrt(2) in Q14  */
-#define     INV_SQRT_OF_2   11585       /*  1/sqrt(2) in Q14  */
-#define     INV_SQRT_POLY_ORDER     4
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-/*
- *  2^([0:3]/4) = 1.0000    1.1892    1.4142    1.6818
- */
-const UInt scale_mod_4[4] = { 16384, 19484, 23170, 27554};
-
-/*
- *  polynomial approx. in Q12 (type Int)
- */
-
-const Int  inv_sqrt_coeff[INV_SQRT_POLY_ORDER+1] =
-    { 4680, -17935, 27697, -22326, 11980};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int gen_rand_vector(
-    Int32     random_array[],
-    const Int band_length,
-    Int32*   pSeed,
-    const Int power_scale)
-{
-
-    Int      k;
-    UInt     power_adj;
-    Int      q_adjust = 30;
-
-    Int32    temp;
-    Int32    seed;
-    Int32    power;
-
-    Int32*   pArray = &random_array[0];
-
-    Int32    inv_sqrt_power;
-    const Int  *pInvSqrtCoeff;
-
-    /*
-     *  The out of the random number generator is scaled is such a way
-     *  that is independent of the band length.
-     *  The output is computed as:
-     *
-     *                  x(i)
-     *  output = ------------------ * 2^(power_scale%4) 2^(floor(power_scale/4))
-     *                   bl
-     *           sqrt(  SUM x(i)^2 )
-     *                   0
-     *
-     *  bl == band length
-     */
-
-
-    /*
-     *  get 2^(power_scale%4)
-     */
-
-
-    power = 0;
-
-    seed = *pSeed;
-
-    /*
-     *  band_length is always an even number (check tables in pg.66 IS0 14496-3)
-     */
-    if (band_length < 0 || band_length > LONG_WINDOW)
-    {
-        return  q_adjust;     /*  avoid any processing on error condition */
-    }
-
-    for (k = (band_length >> 1); k != 0; k--)
-    {
-        /*------------------------------------------------
-           Numerical Recipes in C
-                    Page 284
-        ------------------------------------------------*/
-        seed *= 1664525L;
-        seed += 1013904223L;
-
-        temp =  seed >> 16;
-
-        seed *= 1664525L;
-        seed += 1013904223L;
-
-        /* shift by 6 make room for band length accumulation  */
-        power  += ((temp * temp) >> 6);
-        *pArray++ = temp;
-
-        temp    = seed >> 16;
-        power  += ((temp * temp) >> 6);
-        *pArray++ = temp;
-
-    } /* END for (k=half_band_length; k > 0; k--) */
-
-
-    *pSeed = seed;
-
-    /*
-     *  If the distribution is uniform, the power is expected to use between
-     *  28 and 27 bits, by shifting down by 13 bits the power will be a
-     *  Q15 number.
-     *  For different band lengths, the power uses between 20 and 29 bits
-     */
-
-
-    k = 0;
-
-    if (power)
-    {
-        /*
-         *    approximation requires power  between 0.5 < power < 1 in Q15.
-         */
-
-        while (power > 32767)
-        {
-            power >>= 1;
-            k++;
-        }
-
-        /*
-         *  expected power bit usage == 27 bits
-         */
-
-        k -= 13;
-
-        power_adj = scale_mod_4[power_scale & 3];
-
-        if (k < 0)
-        {
-            k = -k;
-            if (k & 1)
-            {                               /* multiply by sqrt(2)  */
-                power_adj = (UInt)(((UInt32) power_adj * SQRT_OF_2) >> 14);
-            }
-            q_adjust -= (k >> 1);    /* adjust Q instead of shifting up */
-        }
-        else if (k > 0)
-        {
-            if (k & 1)
-            {                               /* multiply by 1/sqrt(2)  */
-                power_adj = (UInt)(((UInt32) power_adj * INV_SQRT_OF_2) >> 14);
-            }
-            q_adjust += (k >> 1);   /* adjust Q instead of shifting down */
-        }
-
-        /*
-         *    Compute 1/sqrt(power), where 0.5 < power < 1.0 is approximated
-         *    using a polynomial order INV_SQRT_POLY_ORDER
-         */
-
-        pInvSqrtCoeff = inv_sqrt_coeff;
-
-        inv_sqrt_power  = (*(pInvSqrtCoeff++) * power) >> 15;
-        inv_sqrt_power += *(pInvSqrtCoeff++);
-        inv_sqrt_power  = (inv_sqrt_power * power) >> 15;
-        inv_sqrt_power += *(pInvSqrtCoeff++);
-        inv_sqrt_power  = (inv_sqrt_power * power) >> 15;
-        inv_sqrt_power += *(pInvSqrtCoeff++);
-        inv_sqrt_power  = (inv_sqrt_power * power) >> 15;
-        inv_sqrt_power += *(pInvSqrtCoeff);
-
-        inv_sqrt_power  = (inv_sqrt_power * power_adj) >> 13;
-
-        pArray = &random_array[0];
-
-        for (k = (band_length >> 1); k != 0; k--)
-        {
-            temp        = *(pArray) * inv_sqrt_power;
-            *(pArray++) = temp;
-            temp        = *(pArray) * inv_sqrt_power;
-            *(pArray++) = temp;
-        } /* END for (k=half_band_length; k > 0; k--) */
-
-    }   /* if(power) */
-
-    /*
-     *      Adjust Q with the value corresponding to 2^(floor(power_scale/4))
-     */
-
-    q_adjust  -= (power_scale >> 2);
-
-    return (q_adjust);
-
-} /* gen_rand_vector */
diff --git a/media/libstagefright/codecs/aacdec/gen_rand_vector.h b/media/libstagefright/codecs/aacdec/gen_rand_vector.h
deleted file mode 100644
index 17b5490..0000000
--- a/media/libstagefright/codecs/aacdec/gen_rand_vector.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: gen_rand_vector.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Added include of pv_audio_type_defs.h
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for gen_rand_vector.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef gen_rand_vector_H
-#define gen_rand_vector_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int gen_rand_vector(
-    Int32  random_array[],
-    const Int    band_length,
-    Int32 *pSeed,
-    const Int    power_scale);
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_adif_header.cpp b/media/libstagefright/codecs/aacdec/get_adif_header.cpp
deleted file mode 100644
index 8a1e74b..0000000
--- a/media/libstagefright/codecs/aacdec/get_adif_header.cpp
+++ /dev/null
@@ -1,443 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adif_header.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Change to PV template, remove default config parameter,
-               move some functionality into get_prog_config().
-
- Description: Update per code review
-              1) Add parameter pScratchPCE
-              2) Change way ADIF_ID is read in.
-              3) Fix comments
-              4) ADD a test for status != SUCCESS in loop.
-
- Description: The ADIF_Header has now been delegated to the "scratch memory"
- union.  This change inside s_tDec_Int_File.h had to be reflected here also.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pVars        = pointer to the structure that contains the current state
-                   of this instance of the library, of data type pointer to
-                   tDec_Int_File
-
-    pScratchPCE  = pointer to a ProgConfig structure used as scratch in the
-                   the function get_prog_config. of data type pointer to
-                   ProgConfig
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-    The function returns 0 if no error occurred, non-zero otherwise.
-
- Pointers and Buffers Modified:
-    pVars->adif_header contents are updated with the some of the ADIF header
-           contents
-    pVars->tempProgConfig contents are overwritten with last PCE found,
-           which is most likely the first one found.
-    pVars->prog_config contents are updated with the first PCE found.
-    pVars->inputStream contents are modify in such a way that the
-           stream is moved further along in the buffer.
-    pVars->SFBWidth128 contents may be updated.
-    pVars->winSeqInfo  contents may be updated.
-    pScratchPCE        contents may be updated.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads in the ADIF Header found at the front of ADIF streams.
- If the header is not found an error is returned. An ADIF header can contain
- from zero to sixteen program configuration elements (PCE). This function, and
- the rest of the library, saves and uses the first PCE found.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- Function shall not use static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-   of moving pictures and associated audio information - Part 7: Advanced
-   Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
-   page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-     CALL getbits(
-        neededBits = 2 * LEN_BYTE,
-        pInputStream = pInputStream)
-     MODIFYING( pInputStream )
-     RETURNING( theIDFromFile )
-
-     CALL getbits(
-        neededBits = 2 * LEN_BYTE,
-        pInputStream = pInputStream)
-     MODIFYING( pInputStream )
-     RETURNING( temp )
-
-    theIDFromFile = (theIDFromFile << (2*LEN_BYTE)) | temp;
-
-    IF (theIDFromFile != ADIF_ID)
-    THEN
-
-        pInputStream->usedBits -= (4 * LEN_BYTE);
-
-        status = -1;
-    ELSE
-        CALL getbits(
-            neededBits = LEN_COPYRT_PRES,
-            pInputStream = pInputStream)
-        MODIFYING( pInputStream )
-        RETURNING( temp )
-
-        IF (temp != FALSE) THEN
-            FOR (i = LEN_COPYRT_ID; i > 0; i--)
-               CALL getbits(
-                   neededBits = LEN_BYTE,
-                   pInputStream = pInputStream)
-               MODIFYING( pInputStream )
-
-            END FOR
-        END IF
-
-        CALL getbits(
-            neededBits = LEN_ORIG + LEN_HOME,
-            pInputStream = pInputStream)
-        MODIFYING( pInputStream )
-
-        CALL getbits(
-            neededBits = LEN_BS_TYPE,
-            pInputStream = pInputStream)
-        MODIFYING( pInputStream )
-        RETURNING( bitStreamType )
-
-        CALL getbits(
-            neededBits = LEN_BIT_RATE,
-            pInputStream = pInputStream)
-        MODIFYING( pInputStream )
-        RETURNING( pHeader->bitrate )
-
-        CALL getbits(
-            neededBits = LEN_NUM_PCE,
-            pInputStream = pInputStream)
-        MODIFYING( pInputStream )
-        RETURNING( numConfigElementsMinus1 )
-
-        FOR (  i = numConfigElementsMinus1;
-              (i >= 0) && (status == SUCCESS);
-               i--)
-
-            IF (bitStreamType == CONSTANT_RATE_BITSTREAM) THEN
-               CALL getbits(
-                   neededBits = LEN_ADIF_BF,
-                   pInputStream = pInputStream)
-               MODIFYING( pInputStream )
-            END IF
-
-            CALL get_prog_config(
-                pVars = pVars)
-            MODIFYING( pVars->prog_config )
-            RETURNING( status )
-
-        END FOR
-    END IF
-
-    RETURN (status)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_adif_const.h"
-
-#include "s_progconfig.h"
-#include "s_adif_header.h"
-#include "s_bits.h"
-#include "s_mc_info.h"
-#include "s_frameinfo.h"
-#include "s_tdec_int_file.h"
-
-#include "get_prog_config.h"
-#include "ibstream.h"
-
-#include "get_adif_header.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*
- * This constant is simply the characters 'A' 'D' 'I' 'F' compressed into
- * a UInt32. Any possible endian problems that exist must be solved by
- * the function that fills the buffer and getbits(), or this constant and
- * the rest of the bit stream will not work.
- */
-#define ADIF_ID (0x41444946)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int get_adif_header(
-    tDec_Int_File *pVars,
-    ProgConfig    *pScratchPCE)
-{
-    Int          i;
-    UInt32       temp;
-    Int          numConfigElementsMinus1;
-    Int          bitStreamType;
-    UInt32       theIDFromFile;
-
-    BITS        *pInputStream = &pVars->inputStream;
-    ADIF_Header *pHeader = &pVars->scratch.adif_header;
-    Int          status  = SUCCESS;
-
-    /*
-     * The ADIF_ID field is 32 bits long, one more than what getbits() can
-     * do, so read the field in two parts. There is no point in saving the
-     * string - it either matches or it does not. If it matches, it must
-     * have been 'ADIF'
-     */
-
-    theIDFromFile = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
-
-    temp          = get17_n_lessbits((2 * LEN_BYTE), pInputStream);
-
-    theIDFromFile = (theIDFromFile << (2 * LEN_BYTE)) | temp;
-
-
-    if (theIDFromFile != ADIF_ID)
-    {
-        /*
-         * Rewind the bit stream pointer so a search for ADTS header
-         * can start at the beginning.
-         */
-
-        pInputStream->usedBits -= (4 * LEN_BYTE);
-
-        /*
-         * The constant in the next line needs to be updated when
-         * error handling method is determined.
-         */
-        status = -1;
-    }
-    else
-    {
-        /*
-         * To save space, the unused fields are read in, but not saved.
-         */
-
-        /* copyright string */
-        temp =
-            get1bits(/*                LEN_COPYRT_PRES,*/
-                pInputStream);
-
-        if (temp != FALSE)
-        {
-            /*
-             * Read in and ignore the copyright string. If restoring
-             * watch out for count down loop.
-             */
-
-            for (i = LEN_COPYRT_ID; i > 0; i--)
-            {
-                get9_n_lessbits(LEN_BYTE,
-                                pInputStream);
-            } /* end for */
-
-            /*
-             * Make sure to terminate the string with '\0' if restoring
-             * the the copyright string.
-             */
-
-        } /* end if */
-
-        /* Combine the original/copy and fields into one call */
-        get9_n_lessbits(
-            LEN_ORIG + LEN_HOME,
-            pInputStream);
-
-        bitStreamType =
-            get1bits(/*                LEN_BS_TYPE,*/
-                pInputStream);
-
-        pHeader->bitrate =
-            getbits(
-                LEN_BIT_RATE,
-                pInputStream);
-
-        /*
-         * Read in all the Program Configuration Elements.
-         * For this library, only one of the up to 16 possible PCE's will be
-         * saved. Since each PCE must be read, a temporary PCE structure is
-         * used, and if that PCE is the one to use, it is copied into the
-         * single PCE. This is done inside of get_prog_config()
-         */
-
-        numConfigElementsMinus1 =  get9_n_lessbits(LEN_NUM_PCE,
-                                   pInputStream);
-
-        for (i = numConfigElementsMinus1;
-                (i >= 0) && (status == SUCCESS);
-                i--)
-        {
-            /*
-             * For ADIF contant bit rate streams, the _encoder_ buffer
-             * fullness is transmitted. This version of an AAC decoder has
-             * no use for this variable; yet it must be read in to move
-             * the bitstream pointers.
-             */
-
-            if (bitStreamType == CONSTANT_RATE_BITSTREAM)
-            {
-                getbits(
-                    LEN_ADIF_BF,
-                    pInputStream);
-            } /* end if */
-
-            pVars->adif_test = 1;
-            /* Get one program configuration element */
-            status =
-                get_prog_config(
-                    pVars,
-                    pScratchPCE);
-
-#ifdef AAC_PLUS
-
-            /*
-             *  For implicit signalling, no hint that sbr or ps is used, so we need to
-             *  check the sampling frequency of the aac content, if lesser or equal to
-             *  24 KHz, by defualt upsample, otherwise, do nothing
-             */
-            if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
-                    pVars->mc_info.audioObjectType == MP4AUDIO_AAC_LC)
-            {
-                pVars->mc_info.upsamplingFactor = 2;
-                pVars->prog_config.sampling_rate_idx -= 3;
-                pVars->mc_info.sbrPresentFlag = 1;
-                pVars->sbrDecoderData.SbrChannel[0].syncState = UPSAMPLING;
-                pVars->sbrDecoderData.SbrChannel[1].syncState = UPSAMPLING;
-            }
-#endif
-
-
-
-        } /* end for */
-
-
-    } /* end 'else' of --> if (theIDFromFile != ADIF_ID) */
-
-    return status;
-
-} /* end get_adif_header */
diff --git a/media/libstagefright/codecs/aacdec/get_adif_header.h b/media/libstagefright/codecs/aacdec/get_adif_header.h
deleted file mode 100644
index 8bc3411..0000000
--- a/media/libstagefright/codecs/aacdec/get_adif_header.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adif_header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Add parameter to get_adif_header() function.
-
- Who:                                      Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_adif_header.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ADIF_HEADER_H
-#define GET_ADIF_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define CONSTANT_RATE_BITSTREAM  (0)
-#define VARIABLE_RATE_BITSTREAM  (1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_adif_header(
-    tDec_Int_File *pVars,
-    ProgConfig    *pScratchPCE);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_adts_header.cpp b/media/libstagefright/codecs/aacdec/get_adts_header.cpp
deleted file mode 100644
index 3ac2756..0000000
--- a/media/libstagefright/codecs/aacdec/get_adts_header.cpp
+++ /dev/null
@@ -1,672 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_adts_header.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove default_config variable
-
- Description: change enter_mc_info to set_mc_info
-
- Description: (1) add error checking for channel_config > 2
-              (2) eliminated call to check_mc_info
-              (3) use (profile + 1) when calling set_mc_info
-              (4) use winmap when calling set_mc_info
-
- Who:                                          Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pVars           =   Pointer to structure that holds file-scope variables.
-                        [ tDec_Int_File * ]
-
-    pSyncword       =   Pointer to variable that holds the 28-bit fixed
-                        header upon the exit of this function. [ UInt32 * ]
-
-    pInvoke         =   Pointer to variable that keeps track of how many
-                        "short" (14 bit) headers have been successfully
-                        parsed from the bitstream. [ Int * ]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    Status = SUCCESS or ERROR CODE
-
- Pointers and Buffers Modified:
-    pVars->prog_config   Updated with program information data as read from
-                         the ADTS header.
-
-    pSyncword            Value pointed to is updated with the contents of
-                         the 28-bit fixed header.
-
-    pInvoke              Value pointed to is updated to reflect the number
-                         of successful "short" (14 bit) headers that have
-                         been successfully parsed from the bitstream.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Acronym Definitions
- ADTS  Audio Data Transport Stream
- CRC   Cyclic Redundancy Code
-
- This function calls find_adts_syncword to find the next ADTS header.  Until
- three consistent headers have been read, the syncword used for detection
- consists of the 12-bit syncword and the 2-bit Layer.  After three consistent
- headers are read, the entire fixed header is used for a robust 28-bit
- syncword.
-
- Configuration information is then extracted from the bitstream.
-
- The bitstream information is packed as follows.
- Comments about the correct interpretation of these bits are contained within
- the code.
-
-                                      CRC_absent    sampling_rate_idx
-                                           \               / \
-                                            \             /   \
-                                             \  Profile  /     \  UNUSED
-                                              \   / \   /       \   /
-|00|01|02|03|04|05|06|07|08|09|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|
- \         _______________         / |   \  /                         \      /
-  \-------|0xFFF syncword |-------/  |   Layer == '00' for AAC         \    /
-           \-------------/           |                                  \  /
-                                     |                                   \/
-                                     ID == '1' for MPEG-2 AAC    channel_config
-       copyright_id_bit                 == '0' for MPEG-4 AAC
-          /
-    home /
-     /  /
-|26|27|28|29|30|31|32|33|34|35|36|37|38|39|40|41|42|
-  |        \  \          _____________           /
-  |         \  \--------|frame length |---------/
-  orig_copy  \           \-----------/
-              \                                  ______________________________
-        copyright_id_start                      | TOTAL HEADER LENGTH: 56 bits|
-                                                |-----------------------------|
-|43|44|45|46|47|48|49|50|51|52|53|54|55|        | FIXED    HEADER BITS 00-27  |
-  \       _______________      /  |   |         | VARIABLE HEADER BITS 28-55  |
-   \-----|buffer_fullness|----/    \ /          |_____________________________|
-          \-------------/           |
-                              headerless_frames
-
- In addition to the bits displayed above, if the value CRC_absent is '0' an
- additional 16 bits corresponding to a CRC word are read from the bitstream,
- following the header.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- After the ADTS syncword is detected, this function shall parse the
- information residing behind the syncword in the bitstream.
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 13818-7:1997(E)
-     Part 7
-        Subpart 6.2 (Audio_Data_Transport_Stream frame, ADTS)
-
- (2) ISO/IEC 11172-3:1993(E)
-     Part 3
-        Subpart 2.4.3 The audio decoding process
-
- (3) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those UIntending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF (*(pInvoke) > 3)
-
-         CALL find_adts_syncword(
-                    pSyncword,
-                   &(pVars->inputStream),
-                    LENGTH_FIXED_HEADER,
-                    MASK_28BITS);
-           RETURNING  status
-    ELSE
-
-        *(pSyncword) = SYNCWORD_15BITS;
-
-        CALL find_adts_syncword(
-                   pSyncword,
-                  &(pVars->inputStream),
-                   LENGTH_SYNCWORD,
-                   ID_BIT_FILTER);
-
-          MODIFYING  *(pSyncword) = 28-bit fixed header (long syncword)
-          RETURNING  status
-
-        CALL getbits(
-                (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
-               &(pVars->inputStream));
-
-          MODIFYING pVars->inputStream
-          RETURNING adts_header = remaining bits in the fixed header
-
-        *(pSyncword) <<= 13;
-        *(pSyncword) = *(pSyncword) OR adts_header;
-
-        pVars->prog_config.CRC_absent  = ((UInt)(adts_header >> 12)) AND 0x0001;
-
-        lower_16 = (UInt)adts_header;
-
-        pVars->prog_config.profile = (lower_16 >> 10) AND 0x3;
-
-        pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) AND 0xF;
-
-        channel_configuration = (lower_16 >> 2) AND 0x7;
-
-        channel_configuration = channel_configuration - 1;
-        pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
-
-        pVars->prog_config.front.num_ele    = 1;
-
-        pVars->prog_config.front.ele_tag[0] = 0;
-
-        pVars->prog_config.mono_mix.present = 0;
-        pVars->prog_config.stereo_mix.present = 0;
-        pVars->prog_config.matrix_mix.present = 0;
-
-        CALL set_mc_info(
-                &(pVars->mc_info),
-                &(pVars->savedMCInfo),
-                &(pVars->prog_config),
-                  pVars->pWinSeqInfo,
-                  pVars->SFBWidth128);
-          MODIFYING pVars->mc_info = multi-channel configuration information
-          RETURNING status         = SUCCESS/FAILURE
-
-        IF ( (*pInvoke) != 0)
-            CALL check_mc_info(
-                    &(pVars->mc_info),
-                    &(pVars->savedMCInfo),
-                     FALSE);
-              RETURNING status = SUCCESS/FAILURE
-        ELSE
-            CALL check_mc_info(
-                    &(pVars->mc_info),
-                    &(pVars->savedMCInfo),
-                     TRUE);
-              MODIFYING pVars->savedMCInfo = pVars->mc_info
-              RETURNING status = SUCCESS/FAILURE
-        ENDIF
-
-        IF (status == SUCCESS)
-            (*pInvoke) = (*pInvoke) + 1;
-        ELSE
-            (*pInvoke) = 0;
-        ENDIF
-
-    ENDIF
-
-    CALL getbits(
-            LENGTH_VARIABLE_HEADER,
-           &(pVars->inputStream));
-      RETURNING adts_header = 28-bits (the contents of the variable header.)
-
-    pVars->prog_config.frame_length  = ((UInt)(adts_header >> 13)) AND 0x1FFF;
-
-    lower_16 = (UInt)adts_header;
-
-    pVars->prog_config.buffer_fullness = (lower_16 >> 2) AND 0x7FF;
-
-    pVars->prog_config.headerless_frames = (lower_16 AND 0x0003);
-
-    IF (pVars->prog_config.CRC_absent == 0)
-
-        CALL getbits(
-                LENGTH_CRC,
-               &(pVars->inputStream) );
-          RETURNING pVars->prog_config.CRC_check = 16-bit CRC
-
-    ENDIF
-
-    pVars->default_config = 0;
-
-    IF (byte_align_offset > 7)
-        status = 1;
-    ENDIF
-
-    return (status);
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h"
-#include "set_mc_info.h"
-#include "find_adts_syncword.h"
-#include "get_adts_header.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LENGTH_VARIABLE_HEADER  28
-#define LENGTH_FIXED_HEADER     28
-#define LENGTH_SYNCWORD         15
-#define LENGTH_CRC              16
-
-#define ID_BIT_FILTER           0x7FFB
-#define SYNCWORD_15BITS         0x7FF8
-#define MASK_28BITS             0x0FFFFFFFL
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_adts_header(
-    tDec_Int_File *pVars,
-    UInt32        *pSyncword,
-    Int           *pInvoke,
-    Int            CorrectlyReadFramesCount)
-{
-    UInt32 adts_header;
-    UInt   lower_16;
-    Int    status = SUCCESS;
-    UInt   channel_configuration;
-
-    /*
-     * Search for the LONG ADTS syncword (comprised of the entire fixed header)
-     * if the number of CorrectlyReadFrames is > CorrectlyReadFramesCount
-     *
-     * Otherwise, search for just the short syncword.
-     */
-    if (*(pInvoke) > CorrectlyReadFramesCount)
-    {
-        /*
-         * Find the long ADTS syncword
-         * (comprised of the entire ADTS fixed header)
-         */
-
-        status = find_adts_syncword(pSyncword,
-                                    &(pVars->inputStream),
-                                    LENGTH_FIXED_HEADER,
-                                    MASK_28BITS);
-    }
-    else
-    {
-
-        *(pSyncword) = SYNCWORD_15BITS;
-
-        status = find_adts_syncword(pSyncword,
-                                    &(pVars->inputStream),
-                                    LENGTH_SYNCWORD,
-                                    ID_BIT_FILTER);
-
-        /*
-         *  Extract the data from the header following the syncword
-         */
-        adts_header = getbits((LENGTH_FIXED_HEADER - LENGTH_SYNCWORD),
-                              &(pVars->inputStream));
-
-        *(pSyncword) <<= (LENGTH_FIXED_HEADER - LENGTH_SYNCWORD);
-        *(pSyncword)  |= adts_header;
-
-        /* Denotes whether a CRC check should be performed */
-        pVars->prog_config.CRC_absent  = ((UInt)(adts_header >> 12)) & 0x0001;
-
-        /*
-         * All the unread bits in adts_header reside in the lower
-         * 16-bits at this point.  Perform a typecast for faster
-         * execution on 16-bit processors.
-         */
-        lower_16 = (UInt)adts_header;
-
-        /*
-         * Profile consists of 2 bits, which indicate
-         * the profile used.
-         *
-         * '00' AAC_MAIN profile
-         * '01' AAC_LC (Low Complexity) profile
-         * '10' AAC_SSR (Scaleable Sampling Rate) profile
-         * '11' AAC_LTP (Long Term Prediction) profile
-         */
-        pVars->prog_config.profile = (lower_16 >> 10) & 0x3;
-
-        if (pVars->prog_config.profile == MP4AUDIO_AAC_SSR)
-        {
-            status = 1;     /* Not supported */
-        }
-
-        /*
-         * Sampling_rate_idx consists of 4 bits
-         * see Ref #1 for their interpretation.
-         */
-        pVars->prog_config.sampling_rate_idx = (lower_16 >> 6) & 0xF;
-
-        /*
-         * private_bit is a bit for private use.  ISO/IEC will not make
-         * use of this bit in the future.
-         *
-         * We currently make no use of it, but parsing the information
-         * from the bitstream could be easily implemented with the
-         * following instruction...
-         *
-         * private_bit = (lower_16 & 0x0400) >> 10;
-         */
-
-        /*
-         * These 3 bits indicate the channel configuration used.
-         *
-         * If '0' then the channel configuration is unspecified here,
-         * and must be given by a program configuration element in
-         * the raw data block.
-         *
-         * If '1' then the channel configuration is MONO.
-         * If '2' then the channel configuration is STEREO
-         *
-         * 3-7 represent channel configurations which this library
-         * will not support in the forseeable future.
-         */
-        channel_configuration = (lower_16 >> 2) & 0x7;
-        /* do not support more than 2 channels */
-        if (channel_configuration > 2)
-        {
-            status = 1;
-        }
-
-        /*
-         * The following 2 bits encode copyright information.
-         * original_copy is '0' if there is no copyright in the bitstream.
-         *                  '1' if the bitstream is copyright protected.
-         *
-         * home is '0' for a copy, '1' for an original.
-         *
-         * PacketVideo currently does nothing with this information,
-         * however, parsing the data from the bitstream could be easily
-         * implemented with the following instructions...
-         *
-         * original_copy = (lower_16 >> 1) & 0x1;
-         *
-         * home = (lower_16 & 0x1);
-         *
-         */
-
-        /* Set up based on information extracted from the ADTS FIXED header */
-
-        /* This equals 1 for STEREO, 0 for MONO */
-        if (channel_configuration)
-        {
-            channel_configuration--;
-        }
-        pVars->prog_config.front.ele_is_cpe[0] = channel_configuration;
-
-        /* This value is constant for both MONO and STEREO */
-        pVars->prog_config.front.num_ele    = 1;
-
-        /* ADTS does not specify this tag value - do we even use it? */
-        pVars->prog_config.front.ele_tag[0] = 0;
-
-        /* Disable all mix related variables */
-        pVars->prog_config.mono_mix.present = 0;
-        pVars->prog_config.stereo_mix.present = 0;
-        pVars->prog_config.matrix_mix.present = 0;
-
-        /* enter configuration into MC_Info structure */
-        if (status == SUCCESS)
-        {
-            /* profile + 1 == audioObjectType */
-            status =
-                set_mc_info(
-                    &(pVars->mc_info),
-                    (tMP4AudioObjectType)(pVars->prog_config.profile + 1),
-                    pVars->prog_config.sampling_rate_idx,
-                    pVars->prog_config.front.ele_tag[0],
-                    pVars->prog_config.front.ele_is_cpe[0],
-                    pVars->winmap, /* changed from pVars->pWinSeqInfo, */
-                    pVars->SFBWidth128);
-
-        } /* if (status == SUCCESS) */
-
-
-#ifdef AAC_PLUS
-
-        /*
-         *  For implicit signalling, no hint that sbr or ps is used, so we need to
-         *  check the sampling frequency of the aac content, if lesser or equal to
-         *  24 KHz, by defualt upsample, otherwise, do nothing
-         */
-        if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == TRUE))
-        {
-            pVars->mc_info.upsamplingFactor = 2;
-            pVars->prog_config.sampling_rate_idx -= 3;
-            pVars->mc_info.sbrPresentFlag = 1;
-            pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_ACTIVE;
-            pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_ACTIVE;
-        }
-#endif
-
-
-        /*
-         * The tag and is_cpe will be checked in huffdecode,
-         * remove this check routine.
-         */
-        /*if (status == SUCCESS)
-         *{
-         *   if ( (*pInvoke) != 0)
-         *   {
-         *       status =
-         *           check_mc_info(
-         *               &(pVars->mc_info),
-         *               &(pVars->savedMCInfo),
-         *               FALSE);
-         *   }
-         *   else
-         *   {
-         *       status =
-         *           check_mc_info(
-         *               &(pVars->mc_info),
-         *               &(pVars->savedMCInfo),
-         *               TRUE);
-         *   }
-         *
-         *}*/ /* if (status == SUCCESS) */
-
-        /*
-         * This keeps track of how many headers have been read in the file.
-         * After the three successful headers with the same configuration
-         * are read in, the entire ADTS fixed header is used as the syncword
-         * for a more robust 28-bit long syncword
-         */
-
-        if (status == SUCCESS)
-        {
-            (*pInvoke)++;
-        }
-        else
-        {
-            (*pInvoke) = 0;
-        }
-
-    } /* END if (*(pInvoke) > 3) */
-
-    /* Grab the bits in the ADTS variable header */
-    adts_header = getbits(
-                      LENGTH_VARIABLE_HEADER,
-                      &(pVars->inputStream));
-    /*
-     * copyright_identification bit is a single bit of the 72-bit
-     * copyright_id field.  This consists of a 8-bit copyright identifier
-     * and a 64-bit copyright_number.  72 headers must be decoded
-     * to reconstruct the entire copyright_id field.
-     *
-     * copyright_identification_start is a single bit flagging
-     * the beginning bit of the copyright_id field.  '1' for start of
-     * copyright_id, '0' otherwise.
-     *
-     *
-     * PacketVideo currently does nothing with this information,
-     * however, parsing the data from the bitstream could be easily
-     * implemented with the following instructions...
-     *
-     * copyright_id_bit = ((UInt)(adts_header >> 27)) & 0x1;
-     *
-     * copyright_id_start = ((UInt)(adts_header >> 26)) & 0x1;
-     */
-
-    /*
-     * frame_length is a 13-bit field which indicates the length,
-     * in bytes, of the frame including error_check and headers.
-     * This information can theoretically be used to help verify syncwords.
-     */
-    pVars->prog_config.frame_length  = ((UInt)(adts_header >> 13)) & 0x1FFF;
-
-    /*
-     * All the unread bits in adts_header reside in the lower
-     * 16-bits at this point.  Perform a typecast for faster
-     * execution on 16-bit processors.
-     */
-    lower_16 = (UInt)adts_header;
-
-    /*
-     * Indicates the number of 32-bit words remaining in the
-     * encoder buffer after the encoding of the first raw
-     * data block.  This value is 0x7ff for variable bit
-     * rate encoders, since buffer fullness does not apply
-     * to Variable Bit Rate (VBR) encoders.
-     */
-    pVars->prog_config.buffer_fullness = (lower_16 >> 2) & 0x7FF;
-
-    /*
-     * headerless_frames indicates the number of
-     * frames with no headers to be processed before the reading
-     * in of the next header.
-     *
-     * In ADTS, up to 4 "no header frames" can exist between
-     * syncwords.
-     *
-     * EXAMPLES:
-     *
-     * Legend: (Sync words denoted by X, frames
-     * deonted by FRAME_#)
-     *
-     * Example(1): The ADTS sequence below packs 5
-     * frames per header.
-     * Here, headerless_frames would always be read in as "4"
-     *
-     * |X||FRAME_0||FRAME_1||FRAME_2||FRAME_3||FRAME_4||X||FRAME_0|
-     *
-     * Example(2): The ADTS sequence below packs 1 frame per header.
-     * Here, headerless_frames would always be read in as "0"
-     *
-     * |X||FRAME_0||X||FRAME_1||X||FRAME_2|
-     *
-     */
-    pVars->prog_config.headerless_frames = (lower_16 & 0x0003);
-
-    if (pVars->prog_config.CRC_absent == 0)
-    {
-        pVars->prog_config.CRC_check = (UInt)getbits(
-                                           LENGTH_CRC,
-                                           &(pVars->inputStream));
-    }
-
-    /* pVars->current_program = 0; */ /* shall be set after PCE is read */
-
-    return (status);
-
-} /* END get_adts_header */
diff --git a/media/libstagefright/codecs/aacdec/get_adts_header.h b/media/libstagefright/codecs/aacdec/get_adts_header.h
deleted file mode 100644
index 13afa05..0000000
--- a/media/libstagefright/codecs/aacdec/get_adts_header.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_adts_header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file has the function declaration for get_adts_header().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ADTS_HEADER_H
-#define GET_ADTS_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_adts_header(
-    tDec_Int_File *pVars,
-    UInt32        *pSyncword,
-    Int           *pInvoke,
-    Int            CorrectlyReadFramesCount);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp b/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp
deleted file mode 100644
index 092f397..0000000
--- a/media/libstagefright/codecs/aacdec/get_audio_specific_config.cpp
+++ /dev/null
@@ -1,691 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/get_audio_specific_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Modified per second review comments
-              (1) change audioObjectType to Int
-              (2) do not set pVars->prog_config.profile
-              (3) clean up status flag, default to SUCCESS
-              (4) fix multiple lines comments
-
- Description: Change getbits.h to ibstream.h
-
- Description: Modified per review comments
-              (1) updated revision history
-              (2) declare audioObjectType as enum type
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less.
-
- Description: Added support for backward and non-backward (explicit)
-              mode for Parametric Stereo (PS) used in enhanced AAC+
-
- Who:                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pVars = pointer to the structure that holds all information for
-            this instance of the library. pVars->prog_config is directly
-            used, and pVars->mc_info, pVars->prog_config,
-            pVars->pWinSeqInfo, pVars->SFBWidth128 are needed indirectly
-            for calling set_mc_info. Data type pointer to tDec_Int_File
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    status = 0 if successfully decoded AudioSpecificConfig
-             1 if un-supported config is used for this release
-
- Pointers and Buffers Modified:
-    pVars->prog_config contents are updated with the information read in.
-    pVars->mc_info contents are updated with channel information.
-    pVars->pWinSeqInfo contents are updated with window information.
-    pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the bitstream for the structure "AudioSpecificConfig",
- and sets the decoder configuration that is needed by the decoder to be able
- to decode the media properly.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global variables
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- Part 3
- Subpart 1  p18     1.6   Interface to MPEG-4 Systems
- Subpart 4  p13     4.4.1 GA Specific Configuration
- Amendment  p10     6.2.1 AudioSpecificInfo
- Amendment  p78     8.2   Decoder configuration (GASpecificConfig)
-
- (2) AAC DecoderSpecificInfo Information
-   PacketVideo descriptions - San Diego
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    status = SUCCESS;
-
-    pInputStream = &(pVars->inputStream);
-
-    temp = CALL getbits(
-                    neededBits = LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
-                    pInputStream = pInputStream)
-           MODIFYING (pInputStream)
-           RETURNING (temp)
-
-    audioObjectType = (temp & 0x1f0) >> 4;
-
-    pVars->prog_config.profile = audioObjectType;
-
-    pVars->prog_config.sampling_rate_idx = temp & 0xf;
-
-    IF (pVars->prog_config.sampling_rate_idx == 0xf)
-    THEN
-        sampling_rate = CALL getbits(
-                            neededBits = LEN_SAMP_RATE,
-                            pInputStream = pInputStream);
-                        MODIFYING (pInputStream)
-                        RETURNING (sampling_rate)
-    ENDIF
-
-    channel_config = CALL getbits(
-                            neededBits = LEN_CHAN_CONFIG,
-                            pInputStream = pInputStream);
-                        MODIFYING (pInputStream)
-                        RETURNING (channel_config)
-
-    IF (channel_config > 2)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (((audioObjectType == MP4AUDIO_AAC_MAIN)     OR
-        (audioObjectType == MP4AUDIO_AAC_LC)        OR
-        (audioObjectType == MP4AUDIO_AAC_SSR)       OR
-        (audioObjectType == MP4AUDIO_LTP)           OR
-        (audioObjectType == MP4AUDIO_AAC_SCALABLE)  OR
-        (audioObjectType == MP4AUDIO_TWINVQ)) AND (status == -1))
-    THEN
-        status = CALL get_GA_specific_config(
-                            pVars = pVars,
-                            channel_config = channel_config,
-                            audioObjectType = audioObjectType,
-                            pInputStream = pInputStream);
-                      MODIFYING (pVars->mc_info,channel_config,pInputStream)
-                      RETURNING (status)
-
-    ENDIF
-
-    IF (audioObjectType == MP4AUDIO_CELP)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (audioObjectType == MP4AUDIO_HVXC)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (audioObjectType == MP4AUDIO_TTSI)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF ((audioObjectType == 13) OR (audioObjectType == 14) OR
-        (audioObjectType == 15) OR (audioObjectType == 16))
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (((audioObjectType == MP4AUDIO_ER_AAC_LC)       OR
-         (audioObjectType == MP4AUDIO_ER_AAC_LTP)      OR
-         (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
-         (audioObjectType == MP4AUDIO_ER_TWINVQ)       OR
-         (audioObjectType == MP4AUDIO_ER_BSAC)         OR
-         (audioObjectType == MP4AUDIO_ER_AAC_LD)) AND (status == -1))
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (audioObjectType == MP4AUDIO_ER_CELP)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF (audioObjectType == MP4AUDIO_ER_HVXC)
-    THEN
-        status = 1;
-    ENDIF
-
-    IF ((audioObjectType == MP4AUDIO_ER_HILN) OR
-        (audioObjectType == MP4AUDIO_PARAMETRIC))
-    THEN
-        status = 1;
-    ENDIF
-
-    IF ((audioObjectType == MP4AUDIO_ER_AAC_LC)       OR
-        (audioObjectType == MP4AUDIO_ER_AAC_LTP)      OR
-        (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) OR
-        (audioObjectType == MP4AUDIO_ER_TWINVQ)       OR
-        (audioObjectType == MP4AUDIO_ER_BSAC)         OR
-        (audioObjectType == MP4AUDIO_ER_AAC_LD)       OR
-        (audioObjectType == MP4AUDIO_ER_CELP)         OR
-        (audioObjectType == MP4AUDIO_ER_HVXC)         OR
-        (audioObjectType == MP4AUDIO_ER_HILN)         OR
-        (audioObjectType == MP4AUDIO_PARAMETRIC))
-    THEN
-        epConfig = CALL getbits(
-                            neededBits = LEN_EP_CONFIG,
-                            pInputStream = pInputStream);
-                      MODIFYING (pInputStream)
-                      RETURNING (epConfig)
-
-        IF (epConfig == 2)
-        THEN
-            status = 1;
-        ENDIF
-
-    ENDIF
-
-    RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "e_mp4ff_const.h"
-#include    "e_tmp4audioobjecttype.h"
-#include    "get_audio_specific_config.h"
-#include    "get_ga_specific_config.h"
-#include    "ibstream.h"
-#include    "sfb.h"                   /* Where samp_rate_info[] is declared */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_audio_specific_config(tDec_Int_File   * const pVars)
-{
-
-    UInt    temp;
-    tMP4AudioObjectType     audioObjectType;
-    //UInt32  sampling_rate;
-    UInt    channel_config;
-    UInt    syncExtensionType;
-    UInt    extensionAudioObjectType = 0;
-    UInt    extensionSamplingFrequencyIndex = 0;
-    BITS   *pInputStream;
-    Int     status;
-
-    status = SUCCESS;
-
-    pInputStream = &(pVars->inputStream);
-
-    pVars->mc_info.upsamplingFactor = 1;   /*  default to regular AAC */
-
-    temp =  get9_n_lessbits(LEN_OBJ_TYPE + LEN_SAMP_RATE_IDX,
-                            pInputStream);
-
-    /*
-     * The following code can directly set the values of elements in
-     * MC_Info, rather than first setting the values in pVars->prog_config
-     * and then copy these values to MC_Info by calling set_mc_info.
-     * In order to keep consistent with get_prog_config (ADIF) and
-     * get_adts_header (ADTS), the code here is still copying
-     * the info, and set the pVars->current_program = 0
-     */
-
-    /* AudioObjectType */
-    audioObjectType = (tMP4AudioObjectType)((temp & 0x1f0) >> 4);
-
-    pVars->mc_info.ExtendedAudioObjectType =  audioObjectType;   /* default */
-    /* saving an audioObjectType into a profile field */
-    /* pVars->prog_config.profile = audioObjectType; */
-
-    /* sampling rate index */
-    pVars->prog_config.sampling_rate_idx = temp & 0xf;
-
-    if (pVars->prog_config.sampling_rate_idx > 0xb)
-    {
-        /*
-         *  Only support 12 sampling frequencies from array samp_rate_info ( see sfb.cpp)
-         *  7350 Hz (index 0xc) is not supported, the other indexes are reserved or escape
-         */
-        if (pVars->prog_config.sampling_rate_idx == 0xf) /* escape sequence */
-        {
-            /*
-             * sampling rate not listed in Table 1.6.2,
-             * this release does not support this
-             */
-            /*sampling_rate =  getbits( LEN_SAMP_RATE,
-                                      pInputStream);*/
-            getbits(LEN_SAMP_RATE, pInputStream); /* future use */
-        }
-
-        status = 1;
-    }
-
-    channel_config =  get9_n_lessbits(LEN_CHAN_CONFIG,
-                                      pInputStream);
-
-    if ((channel_config > 2) && (!pVars->aacConfigUtilityEnabled))
-    {
-        /*
-         * AAC lib does not support more than two channels
-         * signal error when in decoder mode
-         * do not test when in utility mode
-         */
-        status = 1;
-
-    }
-
-    if (audioObjectType == MP4AUDIO_SBR || audioObjectType == MP4AUDIO_PS)
-    {
-        /* to disable explicit backward compatiblity check */
-        pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-        pVars->mc_info.sbrPresentFlag = 1;
-
-        if (audioObjectType == MP4AUDIO_PS)
-        {
-            pVars->mc_info.psPresentFlag = 1;
-            pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
-        }
-
-        extensionSamplingFrequencyIndex = /* extensionSamplingFrequencyIndex */
-            get9_n_lessbits(LEN_SAMP_RATE_IDX,
-                            pInputStream);
-        if (extensionSamplingFrequencyIndex == 0x0f)
-        {
-            /*
-             * sampling rate not listed in Table 1.6.2,
-             * this release does not support this
-                */
-            /*sampling_rate = getbits( LEN_SAMP_RATE,
-                                     pInputStream);*/
-            getbits(LEN_SAMP_RATE, pInputStream);
-        }
-
-        audioObjectType = (tMP4AudioObjectType) get9_n_lessbits(LEN_OBJ_TYPE ,
-                          pInputStream);
-    }
-
-
-    if ((/*(audioObjectType == MP4AUDIO_AAC_MAIN)     ||*/
-                (audioObjectType == MP4AUDIO_AAC_LC)        ||
-                /*(audioObjectType == MP4AUDIO_AAC_SSR)       ||*/
-                (audioObjectType == MP4AUDIO_LTP)           /*||*/
-                /*(audioObjectType == MP4AUDIO_AAC_SCALABLE)  ||*/
-                /*(audioObjectType == MP4AUDIO_TWINVQ)*/) && (status == SUCCESS))
-    {
-        status = get_GA_specific_config(pVars,
-                                        pInputStream,
-                                        channel_config,
-                                        audioObjectType);
-
-        /*
-         *  verify that Program config returned a supported audio object type
-         */
-
-        if ((pVars->mc_info.audioObjectType != MP4AUDIO_AAC_LC) &&
-                (pVars->mc_info.audioObjectType != MP4AUDIO_LTP))
-        {
-            return 1;   /* status != SUCCESS invalid aot */
-        }
-    }
-    else
-    {
-        return 1;   /* status != SUCCESS invalid aot or invalid parameter */
-    }
-
-    /*
-     *  SBR tool explicit signaling ( backward compatible )
-     */
-    if (extensionAudioObjectType != MP4AUDIO_SBR)
-    {
-        syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
-                            pInputStream);
-
-        if (syncExtensionType == 0x2b7)
-        {
-            extensionAudioObjectType = get9_n_lessbits( /* extensionAudioObjectType */
-                                           LEN_OBJ_TYPE,
-                                           pInputStream);
-
-            if (extensionAudioObjectType == MP4AUDIO_SBR)
-            {
-                pVars->mc_info.sbrPresentFlag = get1bits(pInputStream);  /* sbrPresentFlag */
-                if (pVars->mc_info.sbrPresentFlag == 1)
-                {
-                    extensionSamplingFrequencyIndex =
-                        get9_n_lessbits( /* extensionSamplingFrequencyIndex */
-                            LEN_SAMP_RATE_IDX,
-                            pInputStream);
-                    if (pVars->aacPlusEnabled == true)
-                    {
-#ifdef AAC_PLUS
-                        pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
-                                                          samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
-
-                        if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
-                        {
-                            /*
-                             *  Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
-                             */
-                            if (pVars->prog_config.sampling_rate_idx < 6)
-                            {
-                                pVars->aacPlusEnabled = false;
-                            }
-
-                            pVars->mc_info.bDownSampledSbr = true;
-                        }
-                        pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
-
-#endif
-                    }
-
-                    if (extensionSamplingFrequencyIndex == 0x0f)
-                    {
-                        /*
-                         * sampling rate not listed in Table 1.6.2,
-                         * this release does not support this
-                         */
-                        /*sampling_rate = getbits( LEN_SAMP_RATE,
-                                                 pInputStream);*/
-                        getbits(LEN_SAMP_RATE, pInputStream);
-                    }
-                    /* syncExtensionType */
-                    syncExtensionType = (UInt)get17_n_lessbits(LEN_SYNC_EXTENSION_TYPE,
-                                        pInputStream);
-                    if (syncExtensionType == 0x548)
-                    {
-                        pVars->mc_info.psPresentFlag = get1bits(pInputStream);  /* psPresentFlag */
-                        if (pVars->mc_info.psPresentFlag)
-                        {
-                            extensionAudioObjectType = MP4AUDIO_PS;
-                        }
-                    }
-                    else
-                    {
-                        /*
-                        * Rewind bitstream pointer so that the syncExtensionType reading has no
-                        * effect when decoding raw bitstream
-                            */
-                        pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
-                    }
-
-                    pVars->mc_info.ExtendedAudioObjectType = (eMP4AudioObjectType)extensionAudioObjectType;
-                }
-            }
-        }
-        else if (!status)
-        {
-            /*
-             * Rewind bitstream pointer so that the syncExtensionType reading has no
-             * effect when decoding raw bitstream
-             */
-            pVars->inputStream.usedBits -= LEN_SYNC_EXTENSION_TYPE;
-
-#ifdef AAC_PLUS
-
-            /*
-             *  For implicit signalling, no hint that sbr or ps is used, so we need to
-             *  check the sampling frequency of the aac content, if lesser or equal to
-             *  24 KHz, by defualt upsample, otherwise, do nothing
-             */
-            if ((pVars->prog_config.sampling_rate_idx >= 6) && (pVars->aacPlusEnabled == true) &&
-                    audioObjectType == MP4AUDIO_AAC_LC)
-            {
-                pVars->mc_info.upsamplingFactor = 2;
-                pVars->prog_config.sampling_rate_idx -= 3;
-                pVars->mc_info.sbrPresentFlag = 1;
-                pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
-                pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
-
-            }
-#endif
-
-        }
-    }
-    else    /*  MP4AUDIO_SBR was detected  */
-    {
-        /*
-         *  Set the real output frequency use by the SBR tool, define tentative upsample ratio
-         */
-        if (pVars->aacPlusEnabled == true)
-        {
-#ifdef AAC_PLUS
-            pVars->mc_info.upsamplingFactor = (samp_rate_info[extensionSamplingFrequencyIndex].samp_rate >> 1) ==
-                                              samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate ? 2 : 1;
-
-            if ((Int)extensionSamplingFrequencyIndex == pVars->prog_config.sampling_rate_idx)
-            {
-                /*
-                 *  Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
-                 */
-                if (pVars->prog_config.sampling_rate_idx < 6)
-                {
-                    pVars->aacPlusEnabled = false;
-                }
-                pVars->mc_info.bDownSampledSbr = true;
-            }
-            pVars->prog_config.sampling_rate_idx = extensionSamplingFrequencyIndex;
-
-
-
-#endif
-
-
-
-
-        }
-
-    }  /*  if ( extensionAudioObjectType != MP4AUDIO_SBR ) */
-
-    /*
-     * The following object types are not supported in this release,
-     * however, keep these interfaces for future implementation
-     */
-
-    /*
-     *if (audioObjectType == MP4AUDIO_CELP)
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if (audioObjectType == MP4AUDIO_HVXC)
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if (audioObjectType == MP4AUDIO_TTSI)
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if ((audioObjectType == 13) || (audioObjectType == 14) ||
-     *   (audioObjectType == 15) || (audioObjectType == 16))
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /* The following objects are Amendment 1 objects */
-    /*
-     *if (((audioObjectType == MP4AUDIO_ER_AAC_LC)       ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_LTP)      ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
-     *    (audioObjectType == MP4AUDIO_ER_TWINVQ)       ||
-     *    (audioObjectType == MP4AUDIO_ER_BSAC)         ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_LD)) && (status == -1))
-     *{
-     */
-    /*
-     * should call get_GA_specific_config
-     * for this release, do not support Error Resilience
-     * temporary solution is set status flag and exit decoding
-     */
-    /*    status = 1;
-    *}
-    */
-
-    /*
-     *if (audioObjectType == MP4AUDIO_ER_CELP)
-     * {
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if (audioObjectType == MP4AUDIO_ER_HVXC)
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if ((audioObjectType == MP4AUDIO_ER_HILN) ||
-     *    (audioObjectType == MP4AUDIO_PARAMETRIC))
-     *{
-     *    status = 1;
-     *}
-     */
-
-    /*
-     *if ((audioObjectType == MP4AUDIO_ER_AAC_LC)       ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_LTP)      ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE) ||
-     *    (audioObjectType == MP4AUDIO_ER_TWINVQ)       ||
-     *    (audioObjectType == MP4AUDIO_ER_BSAC)         ||
-     *    (audioObjectType == MP4AUDIO_ER_AAC_LD)       ||
-     *    (audioObjectType == MP4AUDIO_ER_CELP)         ||
-     *    (audioObjectType == MP4AUDIO_ER_HVXC)         ||
-     *    (audioObjectType == MP4AUDIO_ER_HILN)         ||
-     *    (audioObjectType == MP4AUDIO_PARAMETRIC))
-     *{
-     */
-    /* error protection config */
-    /*
-     *     epConfig =
-     *       getbits(
-     *           LEN_EP_CONFIG,
-     *           pInputStream);
-     *
-     *   if (epConfig == 2)
-     *   {
-     */
-    /* should call ErrorProtectionSpecificConfig() */
-    /*
-     *       status = 1;
-     *   }
-     *
-     *}
-     */
-
-    return status;
-
-}
diff --git a/media/libstagefright/codecs/aacdec/get_audio_specific_config.h b/media/libstagefright/codecs/aacdec/get_audio_specific_config.h
deleted file mode 100644
index b7cfcf5..0000000
--- a/media/libstagefright/codecs/aacdec/get_audio_specific_config.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_audio_specific_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function declaration for get_audio_specific_config
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_AUDIO_SPECIFIC_CONFIG_H
-#define GET_AUDIO_SPECIFIC_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_audio_specific_config(
-    tDec_Int_File   * const pVars
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_dse.cpp b/media/libstagefright/codecs/aacdec/get_dse.cpp
deleted file mode 100644
index d64087f..0000000
--- a/media/libstagefright/codecs/aacdec/get_dse.cpp
+++ /dev/null
@@ -1,215 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pInputStream = pointer to a BITS structure that holds information
-                   regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    pInputStream->usedBits is rounded up to a number that represents the next
-    byte boundary.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Adquire Data Stream element (DSE) from raw bitstream
-    At this time this function just drops the information.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-  This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-void byte_align(
-    BITS  *pInputStream)
-
-    MODIFYING(pInputStream->usedBits = pInputStream->usedBits +
-                (pInputStream->usedBits + 7) % 8)
-
-    RETURN(nothing)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
- STACK USAGE:
-
-     where:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "get_dse.h"
-#include "ibstream.h"
-#include "getbits.h"
-#include "s_bits.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void get_dse(
-    Char    *DataStreamBytes,
-    BITS    *pInputStream)
-{
-    Int i;
-    Int data_byte_align_flag;
-    UInt count;
-    Int esc_count;
-    Char    *pDataStreamBytes;
-
-    pDataStreamBytes = DataStreamBytes;
-
-    /*
-     *  Get element instance tag  ( 4 bits)
-     *  ( max of 16 per raw data block)
-     */
-    get9_n_lessbits(LEN_TAG, pInputStream);
-
-    /*
-     *  get data_byte_align_flag ( 1 bit0 to see if byte alignment is
-     *  performed within the DSE
-     */
-    data_byte_align_flag = get1bits(pInputStream);
-
-    /*
-     *  get count ( 8 bits)
-     */
-    count =  get9_n_lessbits(LEN_D_CNT, pInputStream);
-
-    /*
-     *  if count == 255, its value it is incremented  by a
-     *  second 8 bit value, esc_count. This final value represents
-     *  the number of bytes in the DSE
-     */
-    if (count == (1 << LEN_D_CNT) - 1)
-    {
-        esc_count = (Int)get9_n_lessbits(LEN_D_ESC, pInputStream);  /* 8 bits */
-        count +=  esc_count;
-    }
-
-    /*
-     *  Align if flag is set
-     */
-    if (data_byte_align_flag)
-    {
-        byte_align(pInputStream);
-    }
-
-    for (i = count; i != 0; i--)
-    {
-        *(pDataStreamBytes++) = (Char) get9_n_lessbits(
-                                    LEN_BYTE,
-                                    pInputStream);
-    }
-
-    return;
-
-} /* end get_dse */
-
diff --git a/media/libstagefright/codecs/aacdec/get_dse.h b/media/libstagefright/codecs/aacdec/get_dse.h
deleted file mode 100644
index 3563f71..0000000
--- a/media/libstagefright/codecs/aacdec/get_dse.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_dse.h
- Funtions:
-    get_dse
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_DSE_H
-#define GET_DSE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void get_dse(
-    Char    *DataStreamBytes,
-    BITS    *pInputStream);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_ele_list.cpp b/media/libstagefright/codecs/aacdec/get_ele_list.cpp
deleted file mode 100644
index 0534c13..0000000
--- a/media/libstagefright/codecs/aacdec/get_ele_list.cpp
+++ /dev/null
@@ -1,243 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_ele_list.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description: Change to PacketVideo standard, rename variables.
-
- Description: Add own header file, make pInputStream second param for speed.
-
- Description: Changes per code review:
-              1) Include header file
-              2) Convert to count down
-              3) Add return (not in review)
-
- Description:
- (1) Updated copyright header
- (2) Replaced include of "interface.h" with "e_ProgConfig.h"
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Who:                                 Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pElementList = pointer to an EleList structure - only the field num_ele
-                   needs to be set. Data type pointer to EleList.
-
-   pInputStream = pointer to a BITS structure, used by the function getbits
-                   to provide data. Data type pointer to BITS
-
-    enableCPE = boolean value indicating the area to be read contains
-                a channel pair element field. Data type Bool
-
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified:
-    pElementList contents are updated with information pertaining to channel
-        configuration.
-
-    pInputBuffer contents are updated to the next location to be read from
-        the input stream.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function is called several times by get_prog_config() to read in part of
- the program configuration data related to channel setup.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not have static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-   of moving pictures and associated audio information - Part 7: Advanced
-   Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
-   page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    elementCount = pElementList->num_ele;
-
-    FOR (index = 0; index < elementCount; index++)
-        IF (enableCPE != FALSE) THEN
-            pElementList->ele_is_cpe[index] =
-                getbits(LEN_ELE_IS_CPE, pInputStream);
-        ELSE
-            pElementList->ele_is_cpe[index] = 0;
-        END IF
-
-        pElementList->ele_tag[index] = getbits(LEN_TAG, pInputStream);
-
-    END FOR
-
-    RETURNS nothing
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-#include "e_progconfigconst.h"
-#include "ibstream.h"
-#include "get_ele_list.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void get_ele_list(
-    EleList     *pElementList,
-    BITS        *pInputStream,
-    const Bool   enableCPE)
-{
-    Int index;
-    Int *pEleIsCPE;
-    Int *pEleTag;
-
-    pEleIsCPE = &pElementList->ele_is_cpe[0];
-    pEleTag   = &pElementList->ele_tag[0];
-
-    for (index = pElementList->num_ele; index > 0; index--)
-    {
-        if (enableCPE != FALSE)
-        {
-            *pEleIsCPE++ = get1bits(/*LEN_ELE_IS_CPE, */pInputStream);
-        }
-        else
-        {
-            *pEleIsCPE++ = FALSE;
-        }
-
-        *pEleTag++ = get9_n_lessbits(LEN_TAG, pInputStream);
-
-    } /* end for (index) */
-
-    return;
-
-} /* end get_ele_list */
-
diff --git a/media/libstagefright/codecs/aacdec/get_ele_list.h b/media/libstagefright/codecs/aacdec/get_ele_list.h
deleted file mode 100644
index 82f140b..0000000
--- a/media/libstagefright/codecs/aacdec/get_ele_list.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_ele_list.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_ele_list.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ELE_LIST_H
-#define GET_ELE_LIST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_elelist.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void get_ele_list(
-    EleList     *pElementList,
-    BITS        *pInputStream,
-    const Bool   enableCPE);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp b/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp
deleted file mode 100644
index 65c00ea..0000000
--- a/media/libstagefright/codecs/aacdec/get_ga_specific_config.cpp
+++ /dev/null
@@ -1,473 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_GA_specific_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Change getbits.h to ibstream.h
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Updated to use scratch memory for the temporary prog config.
-
- Description: Replace some instances of getbits to get1bits
-              when only 1 bit is read.
-
- Who:                               Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-        pVars   = pointer to the structure that holds all information for
-                  this instance of the library. pVars->prog_config
-                  pVars->mc_info, pVars->pWinSeqInfo, pVars->SFBWidth128
-                  are needed for calling set_mc_info.
-                  Data type pointer to tDec_Int_File
-
-        channel_config = variable that indicates the channel configuration
-                         information, in this decoder library, only values
-                         0, 1, and 2 are allowed.
-                         Data type UInt
-
-        audioObjectType = variable that indicates the Audio Object Type.
-                          Data type UInt.
-
-        pInputStream = pointer to a BITS structure that holds information
-                       regarding the input stream.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    status = 0 if success
-             1 otherwise
-
- Pointers and Buffers Modified:
-    pVars->mc_info contents are updated with channel information.
-    if infoinit is called within set_mc_info, then
-    pVars->pWinSeqInfo contents are updated with window information.
-    pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function takes the sampling_rate_idx, channel_config, and
- audioObjectType from AudioSpecificConfig() and set the decoder configuration
- necessary for the decoder to decode properly.
- It also reads the bitstream for frame length, scalable bitstream information
- and extension information to General Audio defined in MPEG-4 phase 1
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-  This function shall not use global variables
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
- Part 3
- Subpart 1  p18     1.6 Interface to MPEG-4 Systems
- Subpart 4  p13     4.4.1 GA Specific Configuration
- Amendment  p10     6.2.1 AudioSpecificInfo
- Amendment  p78     8.2 Decoder configuration (GASpecificConfig)
-
- (2) AAC DecoderSpecificInfo Information
-   PacketVideo descriptions - San Diego
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    frameLenFlag = CALL getbits(
-                            neededBits = LEN_FRAME_LEN_FLAG,
-                            pInputStream = pInputStream);
-                        MODIFYING (pInputStream)
-                        RETURNING (frameLenFlag)
-
-    dependsOnCoreCoder = CALL getbits(
-                               neededBits = LEN_DEPEND_ON_CORE,
-                               pInputStream = pInputStream);
-                        MODIFYING (pInputStream)
-                        RETURNING (dependsOnCoreCoder)
-
-    IF (dependsOnCoreCoder != FALSE)
-    THEN
-        coreCoderDelay = CALL getbits(
-                                neededBits = LEN_CORE_DELAY,
-                                pInputStream = pInputStream);
-                            MODIFYING (pInputStream)
-                            RETURNING (coreCoderDelay)
-    ENDIF
-
-    extFlag = CALL getbits(
-                      neededBits = LEN_EXT_FLAG,
-                      pInputStream = pInputStream);
-                   MODIFYING (pInputStream)
-                   RETURNING (extFlag)
-
-    IF (channel_config == 0)
-    THEN
-        status = CALL get_prog_config(
-                        pVars = pVars,
-                        pScratchPCE = &pVars->scratch_prog_config);
-                   MODIFYING (pVars, pScratchPCE)
-                   RETURNING (status)
-
-    ELSE
-        channel_config--;
-        pVars->prog_config.front.ele_is_cpe[0] = channel_config;
-        pVars->prog_config.front.ele_tag[0] = 0;
-
-        status = CALL set_mc_info(
-                        pMC_Info =  &(pVars->mc_info),
-                        audioObjectType = audioObjectType,
-                        sampling_rate_idx = pVars->prog_config.sampling_rate_idx,
-                        tag = pVars->prog_config.front.ele_tag[0],
-                        is_cpe = pVars->prog_config.front.ele_is_cpe[0],
-                        pWinSeqInfo = pVars->pWinSeqInfo,
-                        sfbwidth128 = pVars->SFBWidth128);
-                    MODIFYING (pMC_Info, pWinSeqInfo, sfbwidth128)
-                    RETURNING (SUCCESS)
-    ENDIF
-
-    IF ((audioObjectType == MP4AUDIO_AAC_SCALABLE) OR
-        (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
-    THEN
-        layer_num = CALL getbits(
-                            neededBits = LEN_LAYER_NUM,
-                            pInputStream = pInputStream);
-                        MODIFYING (pInputStream)
-                        RETURNING (layer_num)
-
-        status = 1;
-    ENDIF
-
-    IF (extFlag != FALSE)
-    THEN
-         IF (audioObjectType == MP4AUDIO_ER_BSAC)
-         THEN
-              numOfSubFrame = CALL getbits(
-                                     neededBits = LEN_SUB_FRAME,
-                                     pInputStream = pInputStream);
-                                MODIFYING (pInputStream)
-                                RETURNING (numOfSubFrame)
-
-              layer_len = CALL getbits(
-                                neededBits = LEN_LAYER_LEN,
-                                pInputStream = pInputStream);
-                               MODIFYING (pInputStream)
-                               RETURNING (layer_len)
-
-         ENDIF
-
-         IF (((audioObjectType > 16) AND (audioObjectType < 22)) OR
-             (audioObjectType == 23))
-         THEN
-             aacSectionDataResilienceFlag =
-                            CALL getbits(
-                                    neededBits = LEN_SECT_RES_FLAG,
-                                    pInputStream = pInputStream);
-                                MODIFYING (pInputStream)
-                                RETURNING (aacSectionDataResilienceFlag)
-
-             aacScalefactorDataResilienceFlag =
-                            CALL getbits(
-                                    neededBits = LEN_SFB_RES_FLAG,
-                                    pInputStream = pInputStream);
-                                MODIFYING (pInputStream)
-                                RETURNING (aacScalefactorDataResilienceFlag)
-
-             aacSpectralDataResilienceFlag =
-                            CALL getbits(
-                                    neededBits = LEN_SPEC_RES_FLAG,
-                                    pInputStream = pInputStream);
-                                MODIFYING (pInputStream)
-                                RETURNING (aacSpectralDataResilienceFlag)
-         ENDIF
-
-        status = 1;
-
-    ENDIF
-
-    RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "e_mp4ff_const.h"
-#include    "e_tmp4audioobjecttype.h"
-#include    "s_tdec_int_file.h"
-#include    "get_ga_specific_config.h"
-#include    "set_mc_info.h"
-#include    "get_prog_config.h"
-#include    "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_GA_specific_config(
-    tDec_Int_File * const pVars,
-    BITS    *pInputStream,
-    UInt     channel_config,
-    const tMP4AudioObjectType audioObjectType
-)
-{
-
-    Int status = SUCCESS;
-    UInt dependsOnCoreCoder;
-    /* Int coreCoderDelay; */
-    UInt extFlag;
-
-    /* These variables are left for future implementation */
-    /* UInt layer_num; */
-    /* UInt numOfSubFrame; */
-    /* UInt layer_len; */
-    /* UInt aacSectionDataResilienceFlag; */
-    /* UInt aacScalefactorDataResilienceFlag; */
-    /* UInt aacSpectralDataResilienceFlag; */
-    Int  extFlag3;
-
-    /*
-     * frame length flag == 0, 1024 samples/frame
-     * frame length flag == 1,  960 samples/frame
-     */
-    get1bits(/*            LEN_FRAME_LEN_FLAG,*/
-        pInputStream);
-
-    /*
-     * dependsOnCoreCoder == 1, core coder has different sampling rate
-     * in a scalable bitstream
-     */
-    dependsOnCoreCoder =
-        get1bits(/*            LEN_DEPEND_ON_CORE,*/
-            pInputStream);
-
-    if (dependsOnCoreCoder != FALSE)
-    {
-        /*coreCoderDelay =
-         *    getbits(
-         *        LEN_CORE_DELAY,
-         *        pInputStream);
-         */
-
-        status = 1; /* do not support scalable coding in this release */
-    }
-
-    /*
-     * extension flag indicates if Amendment 1 objects are used or not
-     * extension flag == 0 objects = 1, 2, 3, 4, 6, 7
-     * extension flag == 1 objects = 17, 19, 20, 21, 22, 23
-     */
-    extFlag = get1bits(pInputStream);       /*  LEN_EXT_FLAG,*/
-
-
-    /* Force checks for implicit channel configuration */
-    pVars->mc_info.implicit_channeling = 1;
-
-    if (status == SUCCESS)
-    {
-
-        if (channel_config == 0)
-        {
-            status = get_prog_config(pVars,
-                                     &pVars->scratch.scratch_prog_config);
-
-            if (status != SUCCESS)
-            {
-                pVars->prog_config.front.ele_is_cpe[0] = 0; /* default to mono  */
-                pVars->mc_info.nch = 1;
-                pVars->prog_config.front.ele_tag[0] = 0;
-
-                status = SUCCESS;
-            }
-        }
-        else
-        {
-            /*
-             * dummy tag = 0 and
-             * set up decoding configurations
-             */
-            channel_config--;
-            pVars->prog_config.front.ele_is_cpe[0] = channel_config;
-            pVars->prog_config.front.ele_tag[0] = 0;
-
-            status =
-                set_mc_info(
-                    &(pVars->mc_info),
-                    audioObjectType, /* previously profile */
-                    pVars->prog_config.sampling_rate_idx,
-                    pVars->prog_config.front.ele_tag[0],
-                    pVars->prog_config.front.ele_is_cpe[0],
-                    pVars->winmap, /*pVars->pWinSeqInfo,*/
-                    pVars->SFBWidth128);
-
-        } /* if (channel_config) */
-
-    } /* if(status) */
-
-    /*
-     * This layer_num is not found in ISO/IEC specs,
-     * but it is defined in San Diego spec for scalable bitstream
-     */
-    if ((audioObjectType == MP4AUDIO_AAC_SCALABLE) ||
-            (audioObjectType == MP4AUDIO_ER_AAC_SCALABLE))
-    {
-        /*layer_num =
-         *    getbits(
-         *        LEN_LAYER_NUM,
-         *        pInputStream);
-         */
-
-        status = 1; /* for this release only */
-    }
-
-    if (extFlag)
-    {
-        /*
-         * currently do not implement these functionalities
-         * defined in Amendment 1
-         * keep it here for future release
-         */
-        if (audioObjectType == MP4AUDIO_ER_BSAC)
-        {
-            status = 1;     /* NOT SUPPORTED */
-            /*
-            numOfSubFrame = getbits( LEN_SUB_FRAME, pInputStream);
-
-            layer_len = getbits( LEN_LAYER_LEN, pInputStream);
-            */
-        }
-
-        /*
-         * The following code is equivalent to
-         * if ((audioObjectType == 17) || (audioObjectType == 18) ||
-         *     (audioObjectType == 19) || (audioObjectType == 20) ||
-         *     (audioObjectType == 21) || (audioObjectType == 23))
-         */
-
-        if (((audioObjectType > 16) && (audioObjectType < 22)) ||
-                (audioObjectType == 23))
-        {
-            status = 1;     /* NOT SUPPORTED */
-            /*
-            aacSectionDataResilienceFlag = getbits( LEN_SECT_RES_FLAG,
-                                                    pInputStream);
-
-            aacScalefactorDataResilienceFlag = getbits( LEN_SCF_RES_FLAG,
-                                                        pInputStream);
-
-            aacSpectralDataResilienceFlag = getbits( LEN_SPEC_RES_FLAG,
-                                                     pInputStream);
-            */
-        }
-        /*
-         * this flag is tbd in version 3 of ISO/IEC spec
-         * if the encoder generates this bit, then it has to be read
-         * current adif2mp4ff does not write this bit. If this bit is to
-         * be read, it can be done by the following code:
-         */
-
-        extFlag3 = get1bits(pInputStream);       /*  LEN_EXT_FLAG3 */
-
-        if (extFlag3)
-        {
-            status = 1;     /* NOT SUPPORTED */
-        }
-
-    }
-
-    return status;
-}
diff --git a/media/libstagefright/codecs/aacdec/get_ga_specific_config.h b/media/libstagefright/codecs/aacdec/get_ga_specific_config.h
deleted file mode 100644
index 7c77da5..0000000
--- a/media/libstagefright/codecs/aacdec/get_ga_specific_config.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_GA_specific_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType
-              (2) update revision history
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for get_GA_specific_config.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_GA_SPECIFIC_CONFIG_H
-#define GET_GA_SPECIFIC_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_tdec_int_file.h"
-#include    "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_GA_specific_config(
-    tDec_Int_File * const pVars,
-    BITS    *pInputStream,
-    UInt     channel_config,
-    const tMP4AudioObjectType audioObjectType
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_ics_info.cpp b/media/libstagefright/codecs/aacdec/get_ics_info.cpp
deleted file mode 100644
index 17204cc..0000000
--- a/media/libstagefright/codecs/aacdec/get_ics_info.cpp
+++ /dev/null
@@ -1,608 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/get_ics_info.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Clean up code.
-
- Description:  Fix comments before review, remove lpflag[]
-
- Description:  Update per review comments, and match ISO/IEC 14496-3
-
- Description:  Update per peer review comments.
-
- Description:  Remove "rollback" of used bits, since lt_decode is to change.
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    audioObjectType = MP4 Audio Object Type for the current song. Only if
-                    this is set to LTP (MP4AUDIO_LTP) will long term
-                    prediction bits be retrieved. Data type
-                    tMP4AudioObjectType, which is an enumeration, which in
-                    turn is an Int.
-
-    pInputStream  = pointer to a BITS structure, used by the function getbits
-                    to provide data. This is the second parameter to this
-                    function to match its position in getbits().
-                    Data type pointer to BITS structure
-
-    common_window = field read in huffdecode, which tells whether information
-                    is shared between the left and right channel. Long term
-                    prediction (LTP) data is NOT shared even if its a common
-                    window, so this flag is needed to see if another set of
-                    LTP possibly needs to be read. If this flag is false,
-                    pSecondLTPStatus is not touched, it could be NULL if
-                    need be. Data type Bool, which is Int.
-
-    pWindowSequence = pointer to where the the window type of the current
-                    frame and channel should be placed, of data type
-                    WINDOW_SEQUENCE, which is Int. It can take on one
-                    of four values: ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE,
-                    EIGHT_SHORT_SEQUENCE, LONG_STOP_SEQUENCE,
-
-    pWindowShape =  pointer to where the window shape for the current frame
-                    and channel should be placed, of data type WINDOW_SHAPE,
-                    which is Int. It can take on the one of these two values:
-                    SINE_WINDOW, KAISER_BESSEL_WINDOW. It is used in the
-                    "filterbank" section of decoding.
-
-    group         = array that holds the index of the first window in each
-                    group. Data type array of Int, eight elements.
-
-    p_max_sfb     = pointer to where the maximum number of scale factor bands
-                    for the current frame and channel will be placed. Data
-                    type of pointer to Int.
-
-    p_winmap      = array of pointers to all of the possible four window
-                    configurations. This parameter did not need to be pointers,
-                    and could be changed in the future. Data type array of pointers
-                    to FrameInfo structures, length 4.
-
-    pFirstLTPStatus = pointer to a structure where the first LTP
-                    information will be stored. It would be confusing and wrong
-                    to call this left LTP status since if common_window = FALSE,
-                    this function will be called twice - once for the left, once
-                    for the right. It could be done, but extra conditional code
-                    would need to be done.
-                    Data type pointer to LT_PRED_STATUS structure.
-
-    pSecondLTPStatus = pointer to where the right channel of LTP
-                    information will be stored only if common_window is non-zero.
-                    Data type pointer to LT_PRED_STATUS structure.
-
- Local Stores/Buffers/Pointers Needed: None.
-
- Global Stores/Buffers/Pointers Needed: None.
-
- Outputs:
-    status  = 0 implies no error occurred, non-zero otherwise.
-
- Pointers and Buffers Modified:
-    pInputStream contents are modified in such a way that the number of bits
-        read increases.
-    pWindowSequence contents are updated with the current window for this
-        frame and channel
-    group[] contents will be modified to grouping information. See getgroup
-        source code for a better description of what this is.
-    p_max_sfb contents will be updated with the maximum scale factor bands
-        for this frame and channel.
-    pFirstLTPStatus contents may be updated if the stream has long term
-        prediction information.
-    pSecondLTPStatus contents may be updated if common_window != 0 and LTP data
-        is present.
-
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function retrieves the individual channel stream (ICS) information
- from the bitstream. The information read for the current
- frame and channel is:
- - window sequence
- - window shape for use in the filter bank
- - number of scale factor bands
- - long term predication (LTP) information
- - grouping information
-
- This function does NOT support MPEG2 style AAC Frequency Domain Predictor,
- not to be confused with LTP (Long Term Prediction). If such data is found
- to be on the file an error is generated.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function is not to use static or global data.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-  (1) ISO/IEC 14496-3:1999(E) Titled "Information technology - Coding
-      of audio-visual objects Part 3: Audio Subpart 4:"
-      Table 4.4.6 - Syntax of ics_info(), page 16.
-
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    status = 0;
-    first_ltp_data_present = FALSE;
-    second_ltp_data_present = FALSE;
-
-
-    CALL getbits(
-        neededBits = LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
-        pInputStream = pInputStream)
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    windowSequence = (temp >> LEN_WIN_SH) & ((0x1<<LEN_WIN_SEQ)-1);
-
-    *pWindowShape = (temp) & ((0x1<<LEN_WIN_SH)-1);
-
-    IF (windowSequence == EIGHT_SHORT_SEQUENCE)
-    THEN
-        CALL getbits(
-            neededBits = LEN_MAX_SFBS,
-            pInputStream = pInputStream)
-        MODIFYING(pInputStream)
-        RETURNING(local_max_sfb = returnValue)
-
-        CALL getgroup(
-            group = group,
-            pInputStream = pInputStream)
-        MODIFYING(group)
-        MODIFYING(pInputStream)
-        RETURNING(nothing)
-
-
-    ELSE
-
-        group[0] = 1;
-
-        CALL getbits(
-            neededBits = LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
-            pInputStream = pInputStream)
-        MODIFYING(pInputStream)
-        RETURNING(temp = returnValue)
-
-        predictor_data_present =
-            (Bool) getbits(
-                LEN_BOOLEAN,
-                pInputStream);
-
-        local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
-
-        predictor_data_present =
-            (Bool) (temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT)-1));
-
-        IF (local_max_sfb > allowed_max_sfb)
-        THEN
-            status = 1
-        ELSEIF (audioObjectType == MP4AUDIO_LTP)
-        THEN
-            IF (predictor_data_present != FALSE)
-            THEN
-                CALL getbits(
-                    neededBits = LEN_LTP_DATA_PRESENT,
-                    pInputStream = pInputStream)
-                MODIFYING(pInputStream)
-                RETURNING(first_ltp_data_present = returnValue)
-
-                IF (ltp_data_present != FALSE)
-                THEN
-
-                    CALL lt_decode(
-                        win_type = windowSequence,
-                        pInputStream  = pInputStream,
-                        max_sfb = local_max_sfb,
-                        pLt_pred = pFirstLTPStatus)
-                    MODIFYING(pInputStream)
-                    MODIFYING(pFirstLTPStatus)
-                    RETURNING(nothing)
-
-                ENDIF
-
-                IF (common_window != FALSE)
-                THEN
-                    CALL getbits(
-                        neededBits = LEN_LTP_DATA_PRESENT,
-                        pInputStream = pInputStream)
-                    MODIFYING(pInputStream)
-                    RETURNING(second_ltp_data_present = returnValue)
-
-                    IF (second_ltp_data_present != FALSE)
-                    THEN
-
-                        CALL lt_decode(
-                            win_type = windowSequence,
-                            pInputStream  = pInputStream,
-                            max_sfb = local_max_sfb,
-                            pLt_pred = pSecondLTPStatus)
-                        MODIFYING(pInputStream)
-                        MODIFYING(pSecondLTPStatus)
-                        RETURNING(nothing)
-                    ENDIF
-                ENDIF
-            ENDIF
-        ELSE
-            IF  (predictor_data_present != FALSE)
-            THEN
-                status = 1
-            ENDIF
-        END IF
-    ENDIF
-
-    pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
-
-    IF (common_window != FALSE)
-    THEN
-        pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
-    ENDIF
-
-    pFrameInfo = p_winmap[*p_wnd];
-    IF (local_max_sfb > pFrameInfo->sfb_per_frame)
-    THEN
-        status = 1;
-    ENDIF
-
-    *(p_max_sfb) = local_max_sfb;
-
-    MODIFY(*(pWindowSequence))
-    MODIFY(*(pWinShape))
-    MODIFY(*(p_max_sfb))
-    MODIFY(group[])
-    MODIFY(*pInputStream)
-    MODIFY(*pFirstLTPStatus)
-    MODIFY(*pSecondLTPStatus)
-    RETURN (status);
-
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#include "e_rawbitstreamconst.h"
-#include "e_tmp4audioobjecttype.h"
-
-#include "s_bits.h"
-#include "s_frameinfo.h"
-#include "s_lt_pred_status.h"
-
-#include "ibstream.h"
-#include "lt_decode.h"
-#include "ltp_common_internal.h" /* For LEN_LTP_DATA_PRESENT constant */
-
-#include "get_ics_info.h"
-#include "huffman.h"        /* For the declaration of getgroup */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define LEN_PREDICTOR_DATA_PRESENT (1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int get_ics_info(
-    const tMP4AudioObjectType  audioObjectType,
-    BITS                      *pInputStream,
-    const Bool                 common_window,
-    WINDOW_SEQUENCE           *pWindowSequence,
-    WINDOW_SHAPE              *pWindowShape,
-    Int                        group[],
-    Int                       *p_max_sfb,
-    FrameInfo                 *p_winmap[],
-    LT_PRED_STATUS            *pFirstLTPStatus,
-    LT_PRED_STATUS            *pSecondLTPStatus)
-{
-    WINDOW_SEQUENCE       windowSequence;
-    UInt                  temp;
-    Bool                  predictor_data_present;
-    UInt                   local_max_sfb;
-    UInt                   allowed_max_sfb;
-    Int                   status = SUCCESS;
-    Bool                  first_ltp_data_present = FALSE;
-    Bool                  second_ltp_data_present = FALSE;
-
-    /*
-     * The following three calls to getbits have been replaced with one
-     * call for speed:
-     *
-     *                  getbits(LEN_ICS_RESERV, pInputStream);
-     * windowSequence = getbits(LEN_WIN_SEQ, pInputStream);
-     * *pWindowShape  = getbits(LEN_WIN_SH, pInputStream);
-     *
-     */
-
-    temp =
-        get9_n_lessbits(
-            LEN_ICS_RESERV + LEN_WIN_SEQ + LEN_WIN_SH,
-            pInputStream);
-
-
-    windowSequence = (WINDOW_SEQUENCE)((temp >> LEN_WIN_SH) & ((0x1 << LEN_WIN_SEQ) - 1));
-
-    *pWindowShape = (WINDOW_SHAPE)((temp) & ((0x1 << LEN_WIN_SH) - 1));
-
-    /*
-     * This pointer should not be NULL as long as the initialization code
-     * has been run, so the test for NULL has been removed.
-     */
-    allowed_max_sfb = p_winmap[windowSequence]->sfb_per_win[0];
-
-    if (windowSequence == EIGHT_SHORT_SEQUENCE)
-    {
-        local_max_sfb =  get9_n_lessbits(LEN_MAX_SFBS,
-                                         pInputStream);
-
-        getgroup(
-            group,
-            pInputStream);
-
-        if (local_max_sfb > allowed_max_sfb)
-        {
-            status = 1;  /* ERROR CODE - needs to be updated */
-        }
-
-    } /* end of TRUE of if (windowSequence == EIGHT_SHORT_SEQUENCE) */
-    else
-    {
-        /* There is only one group for long windows. */
-        group[0] = 1;
-
-        /*
-         * The window is long, get the maximum scale factor bands,
-         * and get long term prediction info.
-         *
-         * Reference [1] states that the audioObjectType is first tested,
-         * then the predictor_data_present is read on either branch of the
-         * if (audioObjectType == MP4AUDIO_LTP). Instead, this code combines
-         * the two calls on both branches into one before the
-         * if, and then in turn combines with another call to getbits, all
-         * in the name of speed.
-         *
-         * This would be the individual calls, without checking the number
-         * of scale factor bands:
-         *
-         *   local_max_sfb =
-         *      (Int) getbits(
-         *          LEN_MAX_SFBL,
-         *           pInputStream);
-         *
-         *  if (audioObjectType == MP4AUDIO_LTP)
-         *  {
-         *        predictor_data_present =
-         *           (Bool) getbits(
-         *              LEN_PREDICTOR_DATA_PRESENT,
-         *              pInputStream);
-         *
-         *     .....   (read LTP data)
-         *
-         *    }
-         *    else
-         *    {
-         *
-         *        predictor_data_present =
-         *           (Bool) getbits(
-         *              LEN_PREDICTOR_DATA_PRESENT,
-         *              pInputStream);
-         *
-         *     .....   (its an error for this library)
-         *     }
-         */
-        temp =
-            get9_n_lessbits(
-                LEN_MAX_SFBL + LEN_PREDICTOR_DATA_PRESENT,
-                pInputStream);
-
-        local_max_sfb = (Int)(temp >> LEN_PREDICTOR_DATA_PRESENT);
-
-        predictor_data_present =
-            (Bool)(temp & ((0x1 << LEN_PREDICTOR_DATA_PRESENT) - 1));
-
-        if (local_max_sfb > allowed_max_sfb)
-        {
-            status = 1;  /* ERROR CODE - needs to be updated */
-        }
-        else if (audioObjectType == MP4AUDIO_LTP)
-        {
-            /*
-             * Note that the predictor data bit has already been
-             * read.
-             */
-
-            /*
-             * If the object type is LTP, the predictor data is
-             * LTP. If the object type is not LTP, the predictor data
-             * is so called "frequency predictor data", which is not
-             * supported by this implementation. Refer to (1)
-             */
-            if (predictor_data_present != FALSE)
-            {
-                first_ltp_data_present =
-                    (Bool) get1bits(/*                        LEN_LTP_DATA_PRESENT,*/
-                        pInputStream);
-
-                if (first_ltp_data_present != FALSE)
-                {
-                    lt_decode(
-                        windowSequence,
-                        pInputStream,
-                        local_max_sfb,
-                        pFirstLTPStatus);
-                }
-                if (common_window != FALSE)
-                {
-                    second_ltp_data_present =
-                        (Bool) get1bits(/*                            LEN_LTP_DATA_PRESENT,*/
-                            pInputStream);
-
-                    if (second_ltp_data_present != FALSE)
-                    {
-                        lt_decode(
-                            windowSequence,
-                            pInputStream,
-                            local_max_sfb,
-                            pSecondLTPStatus);
-                    }
-                } /* if (common_window != FALSE) */
-
-            } /* if (predictor_data_present != FALSE) */
-
-        } /* else if (audioObjectType == MP4AUDIO_LTP) */
-        else
-        {
-            /*
-             * Note that the predictor data bit has already been
-             * read.
-             */
-
-            /*
-             * The object type is not LTP. If there is data, its
-             * frequency predictor data, not supported by this
-             * implementation.
-             */
-            if (predictor_data_present != FALSE)
-            {
-                status = 1; /* ERROR CODE UPDATE LATER */
-            } /* if (predictor_data_present != FALSE) */
-
-        } /* end of "else" clause of if (audioObjectType == MP4AUDIO_LTP) */
-
-    } /*  if (windowSequence == EIGHT_SHORT_SEQUENCE) [FALSE branch] */
-
-
-    /*
-     * Save all local copies.
-     */
-    pFirstLTPStatus->ltp_data_present = first_ltp_data_present;
-    if (common_window != FALSE)
-    {
-        pSecondLTPStatus->ltp_data_present = second_ltp_data_present;
-    }
-
-    *p_max_sfb = local_max_sfb;
-
-    *pWindowSequence = windowSequence;
-
-    return (status);
-
-}  /* get_ics_info */
-
diff --git a/media/libstagefright/codecs/aacdec/get_ics_info.h b/media/libstagefright/codecs/aacdec/get_ics_info.h
deleted file mode 100644
index b94ef8e..0000000
--- a/media/libstagefright/codecs/aacdec/get_ics_info.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/get_ics_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the declaration for the function get_ics_info()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_ICS_INFO_H
-#define GET_ICS_INFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tmp4audioobjecttype.h"
-#include "s_bits.h"
-#include "e_window_sequence.h"
-#include "e_window_shape.h"
-#include "s_frameinfo.h"
-#include "s_lt_pred_status.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int get_ics_info(
-        const tMP4AudioObjectType  audioObjectType,
-        BITS                      *pInputStream,
-        const Bool                 common_window,
-        WINDOW_SEQUENCE           *p_wnd,
-        WINDOW_SHAPE              *pWindowShape,
-        Int                        group[],
-        Int                       *p_max_sfb,
-        FrameInfo                 *p_winmap[],
-        LT_PRED_STATUS            *pFirstLTPStatus,
-        LT_PRED_STATUS            *pSecondLTPStatus);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GET_ICS_INFO_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_prog_config.cpp b/media/libstagefright/codecs/aacdec/get_prog_config.cpp
deleted file mode 100644
index 6bddd57..0000000
--- a/media/libstagefright/codecs/aacdec/get_prog_config.cpp
+++ /dev/null
@@ -1,739 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_prog_config.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Move functionality from get_adif_header for when to change
-               the current program configuration, add a temporary config
-               to read into, clean up code, change function prototype.
-
- Description:  Clean up
-
- Description:  Update per review comments
-
- Description:  Fix double 'could'
-
- Description:  change enter_mc_info to set_mc_info
-
- Description:  update comments
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pVars      = pointer to the structure that holds all information for
-                 this instance of the library. pVars->prog_config is directly
-                 used, and pVars->mc_info, pVars->prog_config, pVars->winmap,
-                 pVars->SFBWidth128 are needed indirectly for calling
-                 set_mc_info. Data type  pointer to tDec_Int_File structure.
-
-    pScratchPCE = pointer to a temporary ProgConfig structure to be used
-                  to read in the program configuration element.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-    status     = zero if no error was found, non-zero otherwise.
-
- Pointers and Buffers Modified:
-    pVars->prog_config contents are updated with the PCE read in.
-    pVars->mc_info contents are updated with channel information.
-    pVars->winmap contents are updated with window information.
-    pVars->SFBWidth128 contents are updated with scale factor band width data.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads from the input stream to memory for a temporary
- program configuration element (PCE). If the PCE read is the first
- encountered it is saved. Or, if the tag of the PCE read matches the tag of
- the first PCE encounted, it is saved as well. This is a mechanism for
- changing the sampling rate.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use static or global variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-   of moving pictures and associated audio information - Part 7: Advanced
-   Audio Coding (AAC)", Table 6.21 - Syntax of program_config_element(),
-   page 16, and section 8.5 "Program Config Element (PCE)", page 30.
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    status          = SUCCESS;
-    pInputStream   = &(pVars->inputStream);
-
-
-    CALL getbits(
-        neededBits = LEN_TAG,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( tag = returnValue )
-
-    CALL getbits(
-        neededBits = LEN_PROFILE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( pScratchPCE->profile = returnValue )
-
-    CALL getbits(
-        neededBits = LEN_PROFILE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( pScratchPCE->sampling_rate_idx = returnValue )
-
-    CALL getbits(
-        neededBits = LEN_NUM_ELE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->front.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_NUM_ELE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->side.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_NUM_ELE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->back.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_NUM_LFE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->lfe.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_NUM_DAT,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->data.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_NUM_CCE,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( temp = returnValue )
-
-    pScratchPCE->coupling.num_ele = temp;
-
-    CALL getbits(
-        neededBits = LEN_MIX_PRES,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( flag = returnValue )
-
-    pScratchPCE->mono_mix.present = flag;
-
-    IF (flag != FALSE)
-    THEN
-        CALL getbits(
-            neededBits = LEN_TAG,
-            pInputStream = pInputStream )
-        MODIFYING( pInputStream )
-        RETURNING( temp = returnValue )
-
-        pScratchPCE->mono_mix.ele_tag = temp;
-
-    ENDIF
-
-    CALL getbits(
-        neededBits = LEN_MIX_PRES,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( flag = returnValue )
-
-    pScratchPCE->stereo_mix.present = flag;
-
-    IF (flag != FALSE)
-    THEN
-
-        CALL getbits(
-            neededBits = LEN_TAG,
-            pInputStream = pInputStream )
-        MODIFYING( pInputStream )
-        RETURNING( temp = returnValue )
-
-        pScratchPCE->stereo_mix.ele_tag = temp;
-
-    ENDIF
-
-    CALL getbits(
-        neededBits = LEN_MIX_PRES,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( flag = returnValue )
-
-    flag =
-        getbits(
-            LEN_MIX_PRES,
-            pInputStream);
-
-    pScratchPCE->matrix_mix.present = flag;
-
-    IF (flag != FALSE)
-    THEN
-        CALL getbits(
-            neededBits = LEN_MMIX_IDX,
-            pInputStream = pInputStream )
-        MODIFYING( pInputStream )
-        RETURNING( temp = returnValue )
-
-        pScratchPCE->matrix_mix.ele_tag = temp;
-
-        CALL getbits(
-            neededBits = LEN_PSUR_ENAB,
-            pInputStream = pInputStream )
-        MODIFYING( pInputStream )
-        RETURNING( temp = returnValue )
-
-        pScratchPCE->matrix_mix.pseudo_enab = temp;
-
-    ENDIF
-
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->front,
-        pInputStream = pInputStream,
-        enableCPE    = TRUE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->front )
-    RETURNING( nothing )
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->side,
-        pInputStream = pInputStream,
-        enableCPE    = TRUE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->side )
-    RETURNING( nothing )
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->back,
-        pInputStream = pInputStream,
-        enableCPE    = TRUE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->back )
-    RETURNING( nothing )
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->lfe,
-        pInputStream = pInputStream,
-        enableCPE    = FALSE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->lfe )
-    RETURNING( nothing )
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->data,
-        pInputStream = pInputStream,
-        enableCPE    = FALSE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->data )
-    RETURNING( nothing )
-
-    CALL get_ele_list(
-        pElementList = &pScratchPCE->coupling,
-        pInputStream = pInputStream,
-        enableCPE    = TRUE )
-    MODIFYING( pInputStream )
-    MODIFYING( pScratchPCE->coupling )
-    RETURNING( nothing )
-
-
-    CALL byte_align(
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( nothing )
-
-    CALL getbits(
-        neededBits = LEN_COMMENT_BYTES,
-        pInputStream = pInputStream )
-    MODIFYING( pInputStream )
-    RETURNING( numChars = returnValue )
-
-    FOR (i = numChars; i > 0; i--)
-
-        CALL getbits(
-            neededBits = LEN_COMMENT_BYTES,
-            pInputStream = pInputStream )
-        MODIFYING( pInputStream )
-        RETURNING( nothing )
-
-    ENDFOR
-
-    IF (pVars->current_program < 0)
-    THEN
-        pVars->current_program = tag;
-    ENDIF
-
-
-    IF (tag == pVars->current_program)
-    THEN
-
-        CALL pv_memcpy(
-            to = &pVars->prog_config,
-            from = pScratchPCE,
-            n = sizeof(ProgConfig))
-        MODIFYING( pVars->prog_config )
-        RETURNING( nothing )
-
-        CALL set_mc_info(
-            pMC_Info = &pVars->mc_info,
-            objectType = pVars->prog_config.profile + 1,
-            samplin_rate_idx = pVars->prog_config.sampling_rate_idx,
-            tag = pVars->prog_config.front.ele_tag[0],
-            is_cpe = pVars->prog_config.front.ele_is_cpe[0],
-            pWinSeqInfo = pVars->winmap,
-            pSfbwidth128 = pVars->SFBWidth128)
-        MODIFYING( pVars->mc_info )
-        MODIFYING( pVars->winmap )
-        MODIFYING( pVars->SFBWidth128 )
-        RETURN( status = return_value )
-
-    ENDIF
-
-    MODIFY( pVars->mc_info )
-    MODIFY( pVars->winmap )
-    MODIFY( pVars->SFBWidth128 )
-    RETURN (status)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "s_elelist.h"
-#include "s_tdec_int_file.h"
-#include "s_tdec_int_chan.h"
-#include "e_progconfigconst.h"
-#include "ibstream.h"
-#include "get_ele_list.h"
-#include "aac_mem_funcs.h"
-#include "set_mc_info.h"
-#include "get_prog_config.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-Int get_prog_config(
-    tDec_Int_File *pVars,
-    ProgConfig    *pScratchPCE)
-{
-    Int    i;
-    UInt    tag;
-    Int    numChars;
-    UInt    temp;
-    Bool   flag;
-    Int    status          = SUCCESS;
-    BITS  *pInputStream   = &(pVars->inputStream);
-
-
-    /*
-     * The tag is used at the very end to see if this PCE is
-     * the one to be used. Otherwise it does not need to be saved for the
-     * the simple configurations to be used in this version of an AAC
-     * decoder.
-     *
-     * All of the bits of this PCE must be read even if this PCE will not
-     * be used. They are read into a temporary PCE, then later it is decided
-     * whether to keep this PCE.
-     *
-     * To allow quick removal of the fields from the ProgConfig structure
-     * that will probably not be used at a later date,
-     * while still advancing the bitstream pointer,the return value of
-     * getbits is saved into a temporary variable, then transfered to
-     * the structure item.
-     */
-    tag =
-        get9_n_lessbits(
-            LEN_TAG,
-            pInputStream);
-
-    pScratchPCE->profile =
-        get9_n_lessbits(
-            LEN_PROFILE,
-            pInputStream);
-
-    pScratchPCE->sampling_rate_idx =
-        get9_n_lessbits(
-            LEN_SAMP_IDX,
-            pInputStream);
-
-    if (!pVars->adif_test && pScratchPCE->sampling_rate_idx != pVars->prog_config.sampling_rate_idx)
-    {
-        /* rewind the pointer as implicit channel configuration maybe the case */
-        pInputStream->usedBits -= (LEN_TAG + LEN_PROFILE + LEN_SAMP_IDX);
-
-        return (1); /*  mismatch cannot happen */
-    }
-
-
-    /*
-     * Retrieve the number of element lists for each of
-     * front, side, back, lfe, data, and coupling.
-     *
-     * For two-channel stereo or mono, only the data in the front needs
-     * to be saved. However, ALL fields need to be skipped over in some
-     * fashion. Also, the number of elements needs to be temporarily saved
-     * to call get_ele_list(). If that function was changed to pass in
-     * the number of points to be read, the memory set aside inside the
-     * ProgConfig structure could be removed.
-     */
-
-    /*
-     * The next six function calls could be combined into one, then use
-     * shifts and masks to retrieve the individual fields.
-     */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_ELE,
-            pInputStream);
-
-    pScratchPCE->front.num_ele = temp;
-
-    /* Needed only to read in the element list. */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_ELE,
-            pInputStream);
-
-    pScratchPCE->side.num_ele = temp;
-
-    /* Needed only to read in the element list. */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_ELE,
-            pInputStream);
-
-    pScratchPCE->back.num_ele = temp;
-
-    /* Needed only to read in the element list. */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_LFE,
-            pInputStream);
-
-    pScratchPCE->lfe.num_ele = temp;
-
-    /* Needed only to read in the element list. */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_DAT,
-            pInputStream);
-    pScratchPCE->data.num_ele = temp;
-
-    /* Needed only to read in the element list. */
-    temp =
-        get9_n_lessbits(
-            LEN_NUM_CCE,
-            pInputStream);
-
-    pScratchPCE->coupling.num_ele = temp;
-
-    /*
-     * Read in mix down data.
-     *
-     * Whether these fields can be removed and have proper operation
-     * will be determined at a later date.
-     */
-
-    /* Read presence of mono_mix */
-    flag =
-        get1bits(/*            LEN_MIX_PRES,*/
-            pInputStream);
-
-    pScratchPCE->mono_mix.present = flag;
-
-    if (flag != FALSE)
-    {
-        temp =
-            get9_n_lessbits(
-                LEN_TAG,
-                pInputStream);
-
-        pScratchPCE->mono_mix.ele_tag = temp;
-
-    } /* end if (flag != FALSE) */
-
-    /* Read presence of stereo mix */
-    flag =
-        get1bits(/*            LEN_MIX_PRES,*/
-            pInputStream);
-
-    pScratchPCE->stereo_mix.present = flag;
-
-    if (flag != FALSE)
-    {
-        temp =
-            get9_n_lessbits(
-                LEN_TAG,
-                pInputStream);
-
-        pScratchPCE->stereo_mix.ele_tag = temp;
-
-    } /* end if (flag != FALSE) */
-
-    /* Read presence of matrix mix */
-    flag =
-        get1bits(/*            LEN_MIX_PRES,*/
-            pInputStream);
-
-    pScratchPCE->matrix_mix.present = flag;
-
-    if (flag != FALSE)
-    {
-        temp =
-            get9_n_lessbits(
-                LEN_MMIX_IDX,
-                pInputStream);
-
-        pScratchPCE->matrix_mix.ele_tag = temp;
-
-        temp =
-            get1bits(/*                LEN_PSUR_ENAB,*/
-                pInputStream);
-
-        pScratchPCE->matrix_mix.pseudo_enab = temp;
-
-    } /* end if (flag != FALSE) */
-
-    /*
-     * Get each of the element lists. Only the front information will be
-     * used for the PV decoder, but the usedBits field of pInputStream must
-     * be advanced appropriately.
-     *
-     * This could be optimized by advancing the bit stream for the
-     * elements that do not need to be read.
-     */
-    get_ele_list(
-        &pScratchPCE->front,
-        pInputStream,
-        TRUE);
-
-    get_ele_list(
-        &pScratchPCE->side,
-        pInputStream,
-        TRUE);
-
-    get_ele_list(
-        &pScratchPCE->back,
-        pInputStream,
-        TRUE);
-
-    get_ele_list(
-        &pScratchPCE->lfe,
-        pInputStream,
-        FALSE);
-
-    get_ele_list(
-        &pScratchPCE->data,
-        pInputStream,
-        FALSE);
-
-    get_ele_list(
-        &pScratchPCE->coupling,
-        pInputStream,
-        TRUE);
-
-    /*
-     * The standard requests a byte alignment before reading in the
-     * comment. This can be done because LEN_COMMENT_BYTES == 8.
-     */
-    byte_align(pInputStream);
-
-    numChars =
-        get9_n_lessbits(
-            LEN_COMMENT_BYTES, pInputStream);
-
-    /*
-     * Ignore the comment - it requires 65 bytes to store (or worse on DSP).
-     * If this field is restored, make sure to append a trailing '\0'
-     */
-    for (i = numChars; i > 0; i--)
-    {
-        pScratchPCE->comments[i] = (Char) get9_n_lessbits(LEN_BYTE,
-                                   pInputStream);
-
-    } /* end for */
-
-    if (pVars->current_program < 0)
-    {
-        /*
-         * If this is the first PCE, it becomes the current, regardless of
-         * its tag number.
-         */
-        pVars->current_program = tag;
-
-    } /* end if (pVars->current_program < 0) */
-
-
-    if (tag == (UInt)pVars->current_program)
-    {
-        /*
-         * This branch is reached under two conditions:
-         * 1) This is the first PCE found, it was selected in the above if
-         *    block. In all encoders found thus far, the tag value has been
-         *    zero.
-         * 2) A PCE has been sent by the encoder with a tag that matches the
-         *    the first one sent. It will then be re-read. No encoder found
-         *    thus far re-sends a PCE, when looking at ADIF files.
-         *
-         * Regardless, the temporary PCE will now be copied into the
-         * the one official program configuration.
-         */
-        pv_memcpy(
-            &pVars->prog_config,
-            pScratchPCE,
-            sizeof(ProgConfig));
-
-        /* enter configuration into MC_Info structure */
-        status =
-            set_mc_info(
-                &pVars->mc_info,
-                (tMP4AudioObjectType)(pVars->prog_config.profile + 1),
-                pVars->prog_config.sampling_rate_idx,
-                pVars->prog_config.front.ele_tag[0],
-                pVars->prog_config.front.ele_is_cpe[0],
-                pVars->winmap,
-                pVars->SFBWidth128);
-
-    } /* end if (tag == pVars->current_program) */
-
-    return (status);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/get_prog_config.h b/media/libstagefright/codecs/aacdec/get_prog_config.h
deleted file mode 100644
index 646ba46..0000000
--- a/media/libstagefright/codecs/aacdec/get_prog_config.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_prog_config.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                      Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_prog_config.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_PROG_CONFIG_H
-#define GET_PROG_CONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_progconfig.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int get_prog_config(
-    tDec_Int_File *pVars,
-    ProgConfig    *pTempPCE);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_pulse_data.cpp b/media/libstagefright/codecs/aacdec/get_pulse_data.cpp
deleted file mode 100644
index f9c24f4..0000000
--- a/media/libstagefright/codecs/aacdec/get_pulse_data.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_pulse_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description: Put into PV format
-
- Description: 1) Change loop to use pointers.
-              2) Rename to from get_nec_nc to get_pulse_data
-
- Description: Changes per code review
-              1) Fix pathname
-              2) Read in two fields to save call to getbits
-              3) Change how pPulseInfo->number_pulse is stored.
-
- Description: Placed typecast to Int in places where UInt->Int
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9.
-
- Who:                                  Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-     pInputStream = pointer to a BITS structure, used by the function getbits
-                   to provide data. Data type pointer to BITS structure
-
-     pPulseInfo   = pointer to pulse data structure to be filled with data
-                    concerning pulses in the frequency domain.
-                    Data type pointer to PulseInfo
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-     status       = return value, zero signifies success, non-zero otherwise.
-                    Presently this function only returns a success, error
-                    checking may be added later.
-                    Data type Int.
-
- Pointers and Buffers Modified:
-
-    pPulseInfo contents are updated with pulse information. Specifically,
-    pPulseInfo->number_pulse with the number of pulses found, and
-    pPulseInfo->pulse_start_sfb is set to the first scale factor band.
-    Then pPulseInfo->pulse_offset and pPulseInfo->pulse_amp are filled
-    with data. For these array, only the number of pulses defined will be
-    set, those values beyond the number of pulses will retain their previous
-    value and should not be read from.
-    Note: The value in pPulseInfo->number_pulse is different by a value of
-          one from the original ISO code.
-
-    pInputBuffer contents are updated to the next location to be read from
-        the input stream.
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function fills in the pulse data structure with information to be used
- later for restoring pulses in the spectrum.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall not use global or static variables.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-  (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-      of moving pictures and associated audio information - Part 7: Advanced
-      Audio Coding (AAC)", Table 6.17 - Syntax of pulse_data(),
-      page 15, and section 9.3 "Decoding process", starting on page 41.
-
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    status = SUCCESS;
-
-    CALL getbits(neededBits = LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB,
-                 pInputStream = pInputStream)
-    MODIFYING(*pInputStream)
-    RETURNING(temp)
-
-    pPulseInfo->number_pulse = 1 + (temp >> LEN_PULSE_ST_SFB);
-    pPulseInfo->pulse_start_sfb = temp & ((1 << LEN_PULSE_ST_SFB) - 1);
-
-    pPulseOffset = &pPulseInfo->pulse_offset[0];
-    pPulseAmp    = &pPulseInfo->pulse_amp[0];
-
-    FOR (i = PulseInfo->number_pulse; i > 0; i--)
-        CALL getbits(neededBits = LEN_PULSE_POFF + LEN_PULSE_PAMP,
-                     pInputStream = pInputStream)
-        MODIFYING(*pInputStream)
-        RETURNING(temp)
-
-        *pPulseOffset++ = temp >> LEN_PULSE_PAMP;
-        *pPulseAmp++    = temp & ((1 << LEN_PULSE_PAMP) - 1);
-    END FOR
-
-    MODIFYING (*pInputStream)
-    MODIFYING (*pPulseInfo)
-
-    RETURN status
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-#include "e_rawbitstreamconst.h"
-#include "get_pulse_data.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int get_pulse_data(
-    PulseInfo   *pPulseInfo,
-    BITS        *pInputStream)
-{
-    Int   i;
-    Int  *pPulseOffset;
-    Int  *pPulseAmp;
-    Int   status = SUCCESS;
-    UInt  temp;
-
-    /*
-     * Read in both field fields at once to save cycles. These are the
-     * original lines of code:
-     * pPulseInfo->number_pulse = getbits(LEN_PULSE_NPULSE, pInputStream);
-     * pPulseInfo->pulse_start_sfb = getbits(LEN_PULSE_ST_SFB, pInputStream);
-     */
-
-    temp =
-        get9_n_lessbits(
-            LEN_PULSE_NPULSE + LEN_PULSE_ST_SFB,
-            pInputStream);
-
-    pPulseInfo->number_pulse = (Int)(1 + (temp >> LEN_PULSE_ST_SFB));
-    pPulseInfo->pulse_start_sfb = (Int)(temp & ((1 << LEN_PULSE_ST_SFB) - 1));
-
-    pPulseOffset = &pPulseInfo->pulse_offset[0];
-    pPulseAmp    = &pPulseInfo->pulse_amp[0];
-
-    /*
-     * This loop needs to count one more than the number read in from
-     * the bitstream - look at reference [1].
-     */
-
-    for (i = pPulseInfo->number_pulse; i > 0; i--)
-    {
-        /*
-         * Read in both fields. Original lines:
-         *  *pPulseOffset++ = getbits(LEN_PULSE_POFF, pInputStream);
-         *  *pPulseAmp++    = getbits(LEN_PULSE_PAMP, pInputStream);
-         */
-
-        temp =
-            get9_n_lessbits(
-                LEN_PULSE_POFF + LEN_PULSE_PAMP,
-                pInputStream);
-
-        *pPulseOffset++ = (Int)(temp >> LEN_PULSE_PAMP);
-
-        *pPulseAmp++    = (Int)(temp & ((1 << LEN_PULSE_PAMP) - 1));
-    }
-
-    return (status);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/get_pulse_data.h b/media/libstagefright/codecs/aacdec/get_pulse_data.h
deleted file mode 100644
index 267f534..0000000
--- a/media/libstagefright/codecs/aacdec/get_pulse_data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_pulse_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change structure name.
-
- Who:                                      Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for get_pulse_data.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_PULSE_DATA_H
-#define GET_PULSE_DATA_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int get_pulse_data(
-        PulseInfo   *pPulseInfo,
-        BITS        *pInputStream);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /*  GET_PULSE_DATA_H  */
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp b/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp
deleted file mode 100644
index b6ec365..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_bitstream.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    INPUT
-
-    SBRDECODER self,
-    SBRBITSTREAM * stream,
-    float *timeData,
-    int numChannels
-
-    OUTPUT
-
-    errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        sbr decoder processing, set up SBR decoder phase 2 in case of
-        different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-#include "get_sbr_bitstream.h"
-#include "pv_audio_type_defs.h"
-#include    "sbr_crc_check.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream, BITS *pInputStream)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-
-    Int32 count;
-    Int32 esc_count;
-    Int32 Extention_Type;
-    Int32 i;
-
-    count = get9_n_lessbits(LEN_F_CNT, pInputStream);
-    if (count == 15)
-    {
-        esc_count = get9_n_lessbits(LEN_F_ESC, pInputStream);
-        count = esc_count + 14;
-    }
-
-
-
-    Extention_Type = get9_n_lessbits(LEN_F_CNT, pInputStream);
-
-
-    if (((Extention_Type == SBR_EXTENSION) || (Extention_Type == SBR_EXTENSION_CRC))
-            && (count < MAXSBRBYTES) && (count) && (sbrBitStream->NrElements < MAXNRELEMENTS))
-    {
-
-        sbrBitStream->sbrElement[sbrBitStream->NrElements].ExtensionType = Extention_Type;
-        sbrBitStream->sbrElement[sbrBitStream->NrElements].Payload       = count;
-        sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[0]       = (UChar) get9_n_lessbits(LEN_F_CNT, pInputStream);
-        for (i = 1 ; i < count ; i++)
-        {
-            sbrBitStream->sbrElement[sbrBitStream->NrElements].Data[i] = (UChar) get9_n_lessbits(8, pInputStream);
-        }
-
-        sbrBitStream->NrElements += 1;
-
-    }
-    else
-    {
-        pInputStream->usedBits += (count - 1) * LEN_BYTE;
-        pInputStream->usedBits += 4;        /* compenste for LEN_F_CNT (=4) bits read for Extention_Type */
-
-    }
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h b/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h
deleted file mode 100644
index 8094b1a..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_bitstream.h
+++ /dev/null
@@ -1,126 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_bitstream.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_BITSTREAM_H
-#define GET_SBR_BITSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_rawbitstreamconst.h"
-#include "s_sbrbitstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void get_sbr_bitstream(SBRBITSTREAM *sbrBitStream,
-    BITS *pInputStream);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp b/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp
deleted file mode 100644
index 38ddc0b..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_startfreq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "get_sbr_startfreq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int v_offset[7][16] =
-{
-    { -8, -7, -6, -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7},
-    { -5, -4, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13},
-    { -5, -3, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13, 16},
-    { -6, -4, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13, 16},
-    { -4, -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13, 16, 20},
-    { -2, -1,  0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13, 16, 20, 24},
-    { 0,  1,  2,  3,  4,  5,  6,  7,  9, 11, 13, 16, 20, 24, 28, 33}
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int get_sbr_startfreq(const Int32 fs,
-                      const Int32 start_freq)
-{
-    Int k0_min = 0;
-    Int32 index;
-
-
-    switch (fs)
-    {
-        case 16000:
-            index = 0;
-            k0_min = 24;
-            break;
-        case 22050:
-            index = 1;
-            k0_min = 17;
-            break;
-        case 24000:
-            index = 2;
-            k0_min = 16;
-            break;
-        case 32000:
-            index = 3;
-            k0_min = 16;
-            break;
-        case 44100:
-            index = 4;
-            k0_min = 12;
-            break;
-        case 48000:
-            index = 4;
-            k0_min = 11;
-            break;
-        case 64000:
-            index = 4;
-            k0_min = 10;
-            break;
-        case 88200:
-        case 96000:
-            index = 5;
-            k0_min = 7;
-            break;
-
-        default:
-            index = 6;
-    }
-    return (k0_min + v_offset[index][start_freq]);
-
-}
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h b/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h
deleted file mode 100644
index 10fa160..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_startfreq.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_startfreq.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_STARTFREQ_H
-#define GET_SBR_STARTFREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_sbr_startfreq(const Int32 fs,
-                      const Int32 start_freq);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp b/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp
deleted file mode 100644
index e32c61d..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.cpp
+++ /dev/null
@@ -1,190 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_stopfreq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-     if(fs < 32000)
-     {
-         k1_min = (Int) ( ( (float) (6000 * 2 * 64) / fs ) + 0.5 );
-     }
-     else
-     {
-         if (fs < 64000)
-         {
-             k1_min = (Int) ( ( (float) (8000 * 2 * 64) / fs ) + 0.5 );
-         }
-         else
-         {
-             k1_min = (Int) ( ((float) (10000 * 2 * 64) / fs ) + 0.5);
-         }
-     }
-
-     return((Int)( k1_min * pow( 64.0 / k1_min,(stop_freq)/13.0) + 0.5));
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include    "get_sbr_stopfreq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-const UChar sbr_stopfreq_tbl[6][13] =
-{
-
-    { 21, 23, 25, 27, 29, 32, 35, 38, 41, 45, 49, 54, 59},  /* 48000  */
-    { 23, 25, 27, 29, 31, 34, 37, 40, 43, 47, 51, 55, 59},  /* 44100  */
-    { 32, 34, 36, 38, 40, 42, 44, 46, 49, 52, 55, 58, 61},  /* 32000  and 24000 */
-    { 35, 36, 38, 40, 42, 44, 46, 48, 50, 52, 55, 58, 61},  /* 22050  */
-    { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 60, 62}   /* 16000  */
-
-};
-
-Int get_sbr_stopfreq(const Int32 fs,
-                     const Int32 stop_freq)
-{
-
-    Int i;
-
-    switch (fs)
-    {
-        case 48000:
-            i = 0;
-            break;
-
-        case 32000:
-        case 24000:
-            i = 2;
-            break;
-
-        case 22050:
-            i = 3;
-            break;
-
-        case 16000:
-            i = 4;
-            break;
-
-        case 44100:
-        default:
-            i = 1;
-            break;
-    }
-
-    return((Int)sbr_stopfreq_tbl[i][stop_freq]);
-
-}
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h b/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h
deleted file mode 100644
index 341a3d4..0000000
--- a/media/libstagefright/codecs/aacdec/get_sbr_stopfreq.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: get_sbr_stopfreq.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SBR_STOPFREQ_H
-#define GET_SBR_STOPFREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int get_sbr_stopfreq(const Int32 fs,
-                     const Int32 stop_freq);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_sign_bits.h b/media/libstagefright/codecs/aacdec/get_sign_bits.h
deleted file mode 100644
index 445d2f2..0000000
--- a/media/libstagefright/codecs/aacdec/get_sign_bits.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_sign_bits.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Update comments for the structure
-
- Description: Change include file. Above description probably from another
-              header file.
-
- Description: Fix pathname above
-
- Who:                                               Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the function get_sign_bits()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_SIGN_BITS_H
-#define GET_SIGN_BITS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void get_sign_bits(
-    Int          q[],
-    BITS        *pInputStream,
-    const Int    q_len
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GET_SIGN_BITS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/get_tns.cpp b/media/libstagefright/codecs/aacdec/get_tns.cpp
deleted file mode 100644
index e0b021b..0000000
--- a/media/libstagefright/codecs/aacdec/get_tns.cpp
+++ /dev/null
@@ -1,573 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_tns.c
-
-     Date: 10/25/2000
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Brought code in-line with PV standards.  Some minor
-               optimizations (count-down for loops, etc.) were made.
-
- Description:  Made cosmetic changes as suggested during review.  Also,
- changed calculation of s_mask and n_mask from table-based to being
- calculated based on res_index.  Also, the flag coef_res was changed
- from having a range of [3,4] to having a range of [0,1], which corresponds
- exactly with the true value that is passed via the bitstream.
-
- Description:  Modified to use more efficient TNS memory structure.
-
- Description: Updated to reflect more efficient usage of memory by the TNS
- filters.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Moved pInputStream to be the 2nd parameter, for a slight
- optimization on some platforms.
-
- Description: Moved pSfbTop outside of the loops, since its value does
- not change.
-
- Description: Replace some instances of getbits to get1bits
-              when only 1 bit is read.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    FrameInfo *pFrameInfo
-        Pointer to structure that holds information about each block.
-        (long block flag,
-         number of subblocks,
-         scalefactor bands per subblock, etc.)
-
-    BITS *pInputStream
-        Pointer to a BITS structure that is
-        passed on to function getbits to pull information from the bitstream.
-
-    TNS_Frame_info *pTnsFrameInfo
-        Pointer to filter data structure - to be populated by this function.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    TNS_frame_info *pTnsFrameInfo
-
-    pTnsFrameInfo->n_filt = Number of tns filters to be applied to the data.
-
-    pTnsFrameInfo->filt[]->order = The order of each individual TNS filter.
-
-    pTnsFrameInfo->filt[]->coef_res = The resolution of the filter coefficients
-
-    pTnsFrameInfo->filt[]->start_band = start of spectral band
-
-    pTnsFrameInfo->filt[]->stop_band = end of spectral band
-
-    pTnsFrameInfo->filt[]->coef[] = Each filter's coefficients are filled with
-    data read from the input bitstream.
-
-    pTnsFrameInfo->filt[]->direction = A flag is set for each TNS filter.
-
-    If the direction flag (on the bitstream) = 0, then the filter
-    is applied to the block of spectral data in normal (upward) fashion.
-
-    If the direction flag (on the bitstream) = 1, then the filter
-    is applied in a reverse (downward) fashion.
-    (Starting with the last element in the block of data.)
-
-    The value stored in filt[]->direction maps the values [0,1] to [1,-1] for
-    a more intuitive storage of this flag's meaning.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the TNS filter information from the bitstream, and stores
- the filter order, LPC coefficients, and the number of TNS filters to
- be applied in the structure TNS_frame_info.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This code should match the ISO code in functionality, with the exception
- that coef_res has range of [0,1] (PV code) instead of [3,4] (ISO code)
-
- coef_res is only used by tns_decode_coef.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "get_tns.h"
-#include "s_mc_info.h"
-#include "s_frameinfo.h"
-#include "s_tnsfilt.h"
-#include "s_tns_frame_info.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_window_sequence.h"
-#include "e_progconfigconst.h"
-
-#include "tns_decode_coef.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#define SCALE_FACTOR_BAND_OFFSET(x) ( ((x) > 0) ? pSFB_top[(x)-1] : 0 )
-#define MINIMUM(x,y) ( ((x) < (y)) ? (x) : (y) )
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*
- * The entries in the ensuing tables provide the maximum permissable
- * number of scalefactor bands for each TNS filter.  This value is effected
- * by the sampling rate, and window type.
- */
-
-const Int tns_max_bands_tbl_long_wndw[(1<<LEN_SAMP_IDX)] =
-    {31,       /* 96000 Hz */
-     31,       /* 88200 Hz */
-     34,       /* 64000 Hz */
-     40,       /* 48000 Hz */
-     42,       /* 44100 Hz */
-     51,       /* 32000 Hz */
-     46,       /* 24000 Hz */
-     46,       /* 22050 Hz */
-     42,       /* 16000 Hz */
-     42,       /* 12000 Hz */
-     42,       /* 11025 Hz */
-     39,       /* 8000  Hz */
-     0,
-     0,
-     0,
-     0
-    };
-
-const Int tns_max_bands_tbl_short_wndw[(1<<LEN_SAMP_IDX)] =
-    {9,       /* 96000 Hz */
-     9,       /* 88200 Hz */
-     10,       /* 64000 Hz */
-     14,       /* 48000 Hz */
-     14,       /* 44100 Hz */
-     14,       /* 32000 Hz */
-     14,       /* 24000 Hz */
-     14,       /* 22050 Hz */
-     14,       /* 16000 Hz */
-     14,       /* 12000 Hz */
-     14,       /* 11025 Hz */
-     14,       /* 8000  Hz */
-     0,
-     0,
-     0,
-     0
-    };
-
-/*
- * For completeness, here are the table entries for object types that make
- * use of PQF filter bank.  We do not currently support this; these are
- * given here only to ease future implementation.
- *
- *  const Int tns_max_bands_tbl_long_wndw_PQF[(1<<LEN_SAMP_IDX)] =
- *         {28,       ; 96000
- *          28,       ; 88200
- *          27,       ; 64000
- *          26,       ; 48000
- *          26,       ; 44100
- *          26,       ; 32000
- *          29,       ; 24000
- *          29,       ; 22050
- *          23,       ; 16000
- *          23,       ; 12000
- *          23,       ; 11025
- *          19,       ; 8000
- *           0,
- *           0,
- *           0,
- *           0};
- *
- *  const Int tns_max_bands_tbl_short_wndw_PQF[(1<<LEN_SAMP_IDX)] =
- *         {7,       ; 96000
- *          7,       ; 88200
- *          7,       ; 64000
- *          6,       ; 48000
- *          6,       ; 44100
- *          6,       ; 32000
- *          7,       ; 24000
- *          7,       ; 22050
- *          8,       ; 16000
- *          8,       ; 12000
- *          8,       ; 11025
- *          7,       ; 8000
- *          0,
- *          0,
- *          0,
- *          0};
- */
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void get_tns(
-    const Int               max_bands,
-    BITS            * const pInputStream,
-    const WINDOW_SEQUENCE   wnd_seq,
-    const FrameInfo * const pFrameInfo,
-    const MC_Info   * const pMC_Info,
-    TNS_frame_info  * const pTnsFrameInfo,
-    Int32                   scratchTnsDecCoefMem[])
-{
-
-    const Int16 * const pSFB_top = pFrameInfo->win_sfb_top[0];
-
-    Int f;
-    Int t;
-    Int win;
-    UInt tempInt;
-
-    Int num_filt_bits;
-    Int num_order_bits;
-    Int num_start_band_bits;
-
-    Int top;
-    Int res;
-    Int res_index;
-    Int compress;
-
-    Int sfb_per_win;
-
-    Int32 *pLpcCoef;
-    Int32 *pStartLpcCoef;
-    Int s_mask;
-    Int n_mask;
-
-    Int tns_bands;
-    UInt max_order;
-    Int coef_res;
-
-
-    TNSfilt *pFilt;
-
-    if (wnd_seq != EIGHT_SHORT_SEQUENCE)
-    {
-        num_filt_bits  = 2;
-        num_order_bits = 5;
-        num_start_band_bits = 6;
-
-        tns_bands = tns_max_bands_tbl_long_wndw[pMC_Info->sampling_rate_idx];
-
-        /*
-         *  Definition from 14496-3:1999 doc. Our first encoder follows this rule,
-         *  later encoders don't
-         */
-
-        if (pMC_Info->sampling_rate_idx > 4)  /* if (sampling_rate <= 32000 */
-        {
-            max_order = 20;
-        }
-        else
-        {
-            max_order = 12;
-        }
-    }
-    else
-    {
-        num_filt_bits  = 1;
-        num_order_bits = 3;
-        num_start_band_bits = 4;
-
-        tns_bands = tns_max_bands_tbl_short_wndw[pMC_Info->sampling_rate_idx];
-
-        max_order = 7;
-    }
-
-    /*
-     * After this branch, tns_bands will be equal to the minimum of
-     * the passed in variable, nbands, and the result from the
-     * tns_max_bands_tbl
-     */
-
-    if (max_bands < tns_bands)
-    {
-        tns_bands = max_bands;
-    }
-
-    sfb_per_win = pFrameInfo->sfb_per_win[0];
-
-    win = 0;
-
-    pLpcCoef = pTnsFrameInfo->lpc_coef;
-
-    pFilt = pTnsFrameInfo->filt;
-
-    do
-    {
-        tempInt = get9_n_lessbits(num_filt_bits,
-                                  pInputStream);
-
-        pTnsFrameInfo->n_filt[win] = tempInt;
-
-        if (tempInt != 0)
-        {
-            /*
-             * coef_res = [0, 1]
-             * Switch between a resolution of 3 and 4 bits respectively
-             *
-             * if coef_res = 0, the coefficients have a range of
-             *
-             *                 -4  -3  -2  -1  0   1   2   3
-             *
-             * if coef_res = 1, the coefficients have a range of
-             *
-             * -8  -7  -6  -5  -4  -3  -2  -1  0   1   2   3   4   5   6   7
-             *
-             * The arrays in ./src/tns_tab.c are completely based on
-             * the value of coef_res.
-             */
-            res = get1bits(
-                      pInputStream);
-
-            /* res is post-incremented for correct calculation of res_index */
-            coef_res = res++;
-
-            top = sfb_per_win;
-
-            for (f = pTnsFrameInfo->n_filt[win]; f > 0; f--)
-            {
-                tempInt = MINIMUM(top, tns_bands);
-
-                pFilt->stop_coef = SCALE_FACTOR_BAND_OFFSET(tempInt);
-
-                pFilt->stop_band = tempInt;
-
-                top -= get9_n_lessbits(num_start_band_bits,
-                                       pInputStream);
-
-                tempInt = MINIMUM(top, tns_bands);
-
-                pFilt->start_coef = SCALE_FACTOR_BAND_OFFSET(tempInt);
-
-                pFilt->start_band = tempInt;
-
-                tempInt = get9_n_lessbits(num_order_bits,
-                                          pInputStream);
-
-                pFilt->order = tempInt;
-
-                if (tempInt != 0)
-                {
-                    if (tempInt > max_order)
-                    {
-                        pFilt->order = max_order;
-                    }
-
-                    /*
-                     * This maps the bitstream's [0,1] to
-                     * pFilt->direction = [1,-1]
-                     */
-
-                    tempInt = get1bits(pInputStream);
-
-                    pFilt->direction = (-(Int)tempInt) | 0x1;
-
-                    /*
-                     * compress = [0,1]
-                     * If compress is true, the MSB has
-                     * been omitted from transmission (Ref. 1)
-                     *
-                     * For coef_res = 0, this limits the range of
-                     * transmitted coefficients to...
-                     *
-                     *         -2  -1  0   1
-                     *
-                     * For coef_res = 1, the coefficients have
-                     * a range of...
-                     *
-                     * -4  -3  -2  -1  0   1   2   3
-                     */
-                    compress = get1bits(pInputStream);
-
-                    /*
-                     * res has a range of [1,2]
-                     * compress has a range of [0,1]
-                     * So (res - compress) has range [0,2];
-                     */
-                    res_index = res - compress;
-
-                    s_mask =  2 << res_index;
-
-                    /*
-                     * If res_index = 0, grab 2 bits of data
-                     * If res_index = 1, grab 3 bits of data
-                     * If res_index = 2, grab 4 bits of data
-                     */
-                    res_index += 2;
-
-                    pStartLpcCoef = pLpcCoef;
-
-                    for (t = pFilt->order; t > 0; t--)
-                    {
-                        /*
-                         * These are the encoded coefficients, which will
-                         * later be decoded into LPC coefficients by
-                         * the function tns_decode_coef()
-                         */
-                        tempInt = get9_n_lessbits(res_index,
-                                                  pInputStream);
-
-                        n_mask  = -((Int)tempInt & s_mask);
-
-                        /*
-                         * n_mask is used to sign_extend the
-                         * value, if it is negative.
-                         *
-                         */
-                        *(pLpcCoef++) = tempInt | n_mask;
-                    }
-
-                    /* Decode the TNS coefficients */
-
-                    tempInt = pFilt->stop_coef - pFilt->start_coef;
-
-                    if (tempInt > 0)
-                    {
-                        pFilt->q_lpc =
-                            tns_decode_coef(
-                                pFilt->order,
-                                coef_res,
-                                pStartLpcCoef,
-                                scratchTnsDecCoefMem);
-                    }
-
-                } /* if (pTnsFilt->order != 0) */
-
-                pFilt++;
-
-            } /* END for (f=pTnsInfo->n_filt; f>0; f--, pTnsFilt++) */
-
-        } /* if (pTnsInfo->n_filt != 0) */
-
-        win++;
-
-    }
-    while (win < pFrameInfo->num_win);
-
-    return;
-
-} /* get_tns */
diff --git a/media/libstagefright/codecs/aacdec/get_tns.h b/media/libstagefright/codecs/aacdec/get_tns.h
deleted file mode 100644
index 731484f..0000000
--- a/media/libstagefright/codecs/aacdec/get_tns.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: get_tns.h
-
-   Author:
-     Date: 03/08/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description: Modified to include updated function declaration, which reflects
- the combination of the get_tns and tns_setup_filter routines.  Also, moved
- pInputStream to be the 2nd parameter, for a slight optimization.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-  This file includes the function definition for get_tns.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GET_TNS_H
-#define GET_TNS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_mc_info.h"
-#include "s_tns_frame_info.h"
-#include "s_bits.h"
-#include "e_window_sequence.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    void get_tns(
-        const Int               max_bands,
-        BITS            * const pInputStream,
-        const WINDOW_SEQUENCE   wnd_seq,
-        const FrameInfo * const pFrameInfo,
-        const MC_Info   * const pMC_Info,
-        TNS_frame_info  * const pTnsFrameInfo,
-        Int32                   scratchTnsDecCoefMem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* GET_TNS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/getbits.h b/media/libstagefright/codecs/aacdec/getbits.h
deleted file mode 100644
index e854be5..0000000
--- a/media/libstagefright/codecs/aacdec/getbits.h
+++ /dev/null
@@ -1,346 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getbits.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Update comments for the structure
-
- Description: Move structur to another file
-
- Who:                                            Date: MM/DD/YYYY
- Description:
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the function getbits().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GETBITS_H
-#define GETBITS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ibstream.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#define INBUF_ARRAY_INDEX_SHIFT  (3)
-#define INBUF_BIT_WIDTH         (1<<(INBUF_ARRAY_INDEX_SHIFT))
-#define INBUF_BIT_MODULO_MASK   ((INBUF_BIT_WIDTH)-1)
-
-#define MAX_GETBITS             (25)
-
-#define  CHECK_INPUT_BUFFER_LIMITS  1
-
-    __inline UInt32 getbits(
-        const UInt  neededBits,
-        BITS       *pInputStream)
-    {
-        UInt32   returnValue = 0;
-        UInt     offset;
-        UInt     bitIndex;
-        UChar    *pElem;        /* Needs to be same type as pInput->pBuffer */
-
-        offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
-        pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
-        offset =  pInputStream->inputBufferCurrentLength - offset;
-        /*  check if access to input buffer does not go beyond boundaries */
-        if (offset > 3)
-        {
-            returnValue = (((UInt32) * (pElem)) << 24) |
-                          (((UInt32) * (pElem + 1)) << 16) |
-                          (((UInt32) * (pElem + 2)) << 8) |
-                          ((UInt32) * (pElem + 3));
-        }
-        else  /*  then access only available bytes  */
-        {
-            /*  Access to the bitstream beyond frame boundaries are not allowed,
-             *  Here, only what was available before the end of the frame will
-             *  be processed. Non-accessible bytes will be filled in with zeros.
-             *  Zero values guarantees that the data structures are filled in with values
-             *  that eventually will signal an error (like invalid parameters) or that allow
-             *  completion of the parsing routine.
-             *  Overrun is detected on file pvmp4audiodecodeframe.cpp.
-             */
-            switch (offset)
-            {
-                case 3:
-                    returnValue  = (((UInt32) * (pElem + 2)) << 8);
-                case 2:
-                    returnValue |= (((UInt32) * (pElem + 1)) << 16);
-                case 1:
-                    returnValue |= (((UInt32) * (pElem)) << 24);
-                default:
-                    break;
-            }
-        }
-
-
-#else
-
-        returnValue = (((UInt32) * (pElem)) << 24) |
-                      (((UInt32) * (pElem + 1)) << 16) |
-                      (((UInt32) * (pElem + 2)) << 8) |
-                      ((UInt32) * (pElem + 3));
-#endif
-
-        /* Remove extra high bits by shifting up */
-        bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
-        /* This line is faster way to mask off the high bits. */
-        returnValue = returnValue << (bitIndex);
-
-        /* Move the field down. */
-        returnValue = returnValue >> (32 - neededBits);
-
-        pInputStream->usedBits += neededBits;
-
-        return (returnValue);
-
-    }
-
-
-
-    __inline UInt get1bits(
-        BITS       *pInputStream)
-    {
-        UInt     returnValue;
-        UInt     offset;
-        UInt     bitIndex;
-        UChar    *pElem;        /* Needs to be same type as pInput->pBuffer */
-
-        offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
-        pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-        returnValue = (offset < pInputStream->inputBufferCurrentLength) ? ((UInt) * (pElem)) : 0;
-#else
-        returnValue = ((UInt32) * (pElem));
-#endif
-
-
-        /* Remove extra high bits by shifting up */
-        bitIndex = (UInt)((pInputStream->usedBits++) & INBUF_BIT_MODULO_MASK);
-
-        /* This line is faster way to mask off the high bits. */
-        returnValue = 0xFF & (returnValue << (bitIndex));
-
-        /* Move the field down. */
-
-        return ((UInt)(returnValue >> 7));
-
-    }
-
-
-
-    __inline UInt get9_n_lessbits(
-        const UInt  neededBits,
-        BITS       *pInputStream)
-
-    {
-        UInt     returnValue;
-        UInt     offset;
-        UInt     bitIndex;
-        UChar    *pElem;        /* Needs to be same type as pInput->pBuffer */
-
-        offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
-        pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
-
-        offset =  pInputStream->inputBufferCurrentLength - offset;
-        /*  check if access to input buffer does not go beyond boundaries */
-        if (offset > 1)
-        {
-            returnValue = (((UInt32) * (pElem)) << 8) |
-                          ((UInt32) * (pElem + 1));
-        }
-        else  /*  then access only available bytes  */
-        {
-            /*  Access to the bitstream beyond frame boundaries are not allowed,
-             *  Here, only what was available before the end of the frame will
-             *  be processed. Non-accessible bytes will be filled in with zeros.
-             *  Zero values guarantees that the data structures are filled in with values
-             *  that eventually will signal an error (like invalid parameters) or that allow
-             *  completion of the parsing routine.
-             *  Overrun is detected on file pvmp4audiodecodeframe.cpp
-             */
-            switch (offset)
-            {
-                case 1:
-                    returnValue  = (((UInt32) * (pElem)) << 8);
-                    break;
-                default:
-                    returnValue = 0;
-                    break;
-            }
-        }
-
-
-#else
-        returnValue = (((UInt32) * (pElem)) << 8) |
-                      ((UInt32) * (pElem + 1)) ;
-#endif
-
-        /* Remove extra high bits by shifting up */
-        bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
-        pInputStream->usedBits += neededBits;
-
-        /* This line is faster way to mask off the high bits. */
-        returnValue = 0xFFFF & (returnValue << (bitIndex));
-
-        /* Move the field down. */
-
-        return (UInt)(returnValue >> (16 - neededBits));
-
-    }
-
-    __inline UInt32 get17_n_lessbits(
-        const UInt  neededBits,
-        BITS       *pInputStream)
-    {
-        UInt32   returnValue;
-        UInt     offset;
-        UInt     bitIndex;
-        UChar    *pElem;        /* Needs to be same type as pInput->pBuffer */
-
-        offset = (pInputStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
-
-        pElem = pInputStream->pBuffer + offset;
-
-#if CHECK_INPUT_BUFFER_LIMITS
-
-        offset =  pInputStream->inputBufferCurrentLength - offset;
-        /*  check if access to input buffer does not go beyond boundaries */
-
-        if (offset > 2)
-        {
-            returnValue = (((UInt32) * (pElem)) << 16) |
-                          (((UInt32) * (pElem + 1)) << 8) |
-                          ((UInt32)  * (pElem + 2));
-        }
-        else   /*  then access only available bytes  */
-        {
-            /*  Access to the bitstream beyond frame boundaries are not allowed,
-             *  Here, only what was available before the end of the frame will
-             *  be processed. Non-accessible bytes will be filled in with zeros.
-             *  Zero values guarantees that the data structures are filled in with values
-             *  that eventually will signal an error (like invalid parameters) or that allow
-             *  completion of the parsing routine.
-             *  Overrun is detected on file pvmp4audiodecodeframe.cpp
-             */
-            returnValue = 0;
-            switch (offset)
-            {
-                case 2:
-                    returnValue  = (((UInt32) * (pElem + 1)) << 8);
-                case 1:
-                    returnValue |= (((UInt32) * (pElem)) << 16);
-                default:
-                    break;
-            }
-        }
-
-#else
-
-        returnValue = (((UInt32) * (pElem)) << 16) |
-                      (((UInt32) * (pElem + 1)) << 8) |
-                      ((UInt32)  * (pElem + 2));
-#endif
-
-        /* Remove extra high bits by shifting up */
-        bitIndex = (UInt)((pInputStream->usedBits) & INBUF_BIT_MODULO_MASK);
-
-        /* This line is faster way to mask off the high bits. */
-        returnValue = 0xFFFFFF & (returnValue << (bitIndex));
-
-        /* Move the field down. */
-        returnValue = returnValue >> (24 - neededBits);
-
-        pInputStream->usedBits += neededBits;
-
-        return (returnValue);
-
-    }
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* GETBITS_H*/
-
-
diff --git a/media/libstagefright/codecs/aacdec/getfill.cpp b/media/libstagefright/codecs/aacdec/getfill.cpp
deleted file mode 100644
index 3c4fc4c..0000000
--- a/media/libstagefright/codecs/aacdec/getfill.cpp
+++ /dev/null
@@ -1,247 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getfill.c
- Funtions: getfill
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  1. Used template to re-organize function and filled out
-                  Input/Output and Function definition section.
-               2. Optimized code.
-
- Description:  Made the following changes based on review comments.
-               1. Exchanging MODIFYING and RETURNING on line 87, 88.
-               2. Added MPEG reference.
-               3. Changed "fill" to "pass over", "bitstreams are" to
-                  "bitstream is" in FUNCTION DESCRIPTION section.
-               4. Fixed tabs.
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pInputStream = pointer to structure BITS containing input stream
-                   information.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    pInputStream->usedBits is updated to the newly calculated value.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function passes over fill bits in the raw data block to adjust the
- instantaneous bit rate when the bitstream is to be transmitted over a
- constant rate channel.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-     Subpart 4      p15     (Table 4.4.11)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    CALL getbits(
-            LEN_F_CNT,
-            pInputStream);
-    MODIFYING (pInputStream)
-    RETURNING (cnt)
-
-    IF ( cnt == (1<<LEN_F_CNT)-1 )
-
-        CALL getbits(
-                LEN_F_ESC,
-                pInputStream);
-        MODIFYING (pInputStream)
-        RETURNING (esc_cnt)
-
-        cnt +=  esc_cnt - 1;
-
-    ENDIF
-
-    pInputStream->usedBits += cnt * LEN_BYTE;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-        stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-        name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bits.h"
-#include "ibstream.h"
-#include "e_rawbitstreamconst.h"
-#include "getfill.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void getfill(BITS *pInputStream)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    Int cnt;
-    Int esc_cnt;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-
-    cnt = get9_n_lessbits(
-              LEN_F_CNT,
-              pInputStream);
-
-    if (cnt == (1 << LEN_F_CNT) - 1)  /* if (cnt == 15) */
-    {
-        esc_cnt = get9_n_lessbits(
-                      LEN_F_ESC,
-                      pInputStream);
-
-        cnt +=  esc_cnt - 1;
-    }
-
-    /*
-     * The following codes are replaced by directly updating usedBits
-     * in BITS structure. This will save one call for getbits().
-     *
-     * for (i=0; i<cnt; i++)
-     * { getbits(LEN_BYTE, pInputStream); }
-     */
-
-    pInputStream->usedBits += cnt * LEN_BYTE;
-
-    /*----------------------------------------------------------------------------
-    ; Return nothing or data or data pointer
-    ----------------------------------------------------------------------------*/
-
-} /* getfill */
-
diff --git a/media/libstagefright/codecs/aacdec/getfill.h b/media/libstagefright/codecs/aacdec/getfill.h
deleted file mode 100644
index 3ba976a..0000000
--- a/media/libstagefright/codecs/aacdec/getfill.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getfill.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed "definition" to "declaration" on line 28 per
-              review comments.
-
- Who:                           Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file contains prototype declaration for getfill function.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef GETFILL_H
-#define GETFILL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void getfill(BITS    *pInputStream);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/getgroup.cpp b/media/libstagefright/codecs/aacdec/getgroup.cpp
deleted file mode 100644
index 0f909cd..0000000
--- a/media/libstagefright/codecs/aacdec/getgroup.cpp
+++ /dev/null
@@ -1,255 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getgroup.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description: (1) Modified to bring code in-line with PV standards
-              (2) Eliminated if(first_short) statement, move for-loop
-                  inside if statement
-              (3) Modified UChar -> Int on data types of group
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less.
-
- Who:                       Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pInputStream = pointer to structure that holds input bitstream
-                   information. Type BITS
-
-    group[]     = array that holds the index of the first window in each
-                  group. Type Int
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    group   contains the index of first windows in each group
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the window grouping information associated with an
- Individual Channel Stream (ICS). If the window sequence is
- EIGHT_SHORT_SEQUENCE, scalefactor grouping information is transmitted. If a
- set of short windows form a group then they share scalefactors, intensity
- positions and PNS information. The first short window is always a new group
- so no grouping bit is transmitted. Subsequent short windows are in the same
- group if the associated grouping bit is 1. A new group is started if the
- associated grouping bit is 0.
- The pointer pGroup points to an array that stores the first window index
- of next group. For example, if the window grouping is:
-
- window index:    |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |
- grouping    :    |<-   0   ->|  1  |<-    2        ->|<-   3   ->|
-
- Then:
-
-    group[]  :    |     2     |  3  |        6        |     8     |
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the contents of the array pointed to by pGroup
- with the first window indexes of groups starting from the second group.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4
-                    p16 (Table 4.4.6)
-                    p55 (Recovering ics_info)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF (pFrameInfo->coef_per_win[0] > SN2)
-
-        *pGroup++ = 1;
-        *pGroup   = 1;
-
-    ELSE
-
-        FOR (win = 1; win < pFrameInfo->num_win; win++)
-
-            IF (getbits(1,pInputStream) == 0)
-
-                *pGroup++ = win;
-
-            ENDIF
-
-        ENDFOR (win)
-
-        *pGroup = win;
-
-    ENDIF(pFrameInfo)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define     SEVEN   7
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void getgroup(
-    Int         group[],
-    BITS        *pInputStream)
-{
-    Int      win;
-    Int     *pGroup;
-    UInt     mask;
-    UInt     groupBits;
-
-    pGroup      = group;
-
-    mask        = 0x40;
-
-    /* only short-window sequences are grouped!
-     * first short window is always a new group,
-     * start reading bitstream from the second
-     * window, a new group is indicated by an
-     * "0" bit in the input stream
-     */
-    groupBits =
-        get9_n_lessbits(
-            SEVEN,
-            pInputStream);
-
-    for (win = 1; win < NUM_SHORT_WINDOWS; win++)
-    {
-        if ((groupBits & mask) == 0)
-        {
-            *pGroup++ = win;
-
-        } /* if (groupBits) */
-
-        mask >>= 1;
-
-    } /* for (win) */
-
-    *pGroup = win;
-
-} /* getgroup */
diff --git a/media/libstagefright/codecs/aacdec/getics.cpp b/media/libstagefright/codecs/aacdec/getics.cpp
deleted file mode 100644
index 8d76744..0000000
--- a/media/libstagefright/codecs/aacdec/getics.cpp
+++ /dev/null
@@ -1,674 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getics.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables
-
- Description: Remove pass-in parameter global_gain, define it on stack.
-
- Description: (1) Modified to bring in-line with PV standards
-              (2) Modified pass in parameters
-              (3) Removed multiple returns, removed some if branch
-              (4) Replace for loop with pv_memset
-
- Description: Remove prstflag, fix copyright.
-
- Description: Fix pseudo-code
-
- Description: Remove lpflag from get_ics_info
-
- Description: (1) Removed widx, therefore, pChVarsWin is eliminated from
-                  pass in parameter
-
- Description: merged the above changes from Michael and Wen
-
- Description: Removed initialization of "pTnsFrameInfo->num_subblocks" since
- this element was removed from that structure, as a part of
- rearchitecting the TNS routines to use memory more efficiently.
-
- Description:
- (1) Added #include of "e_HuffmanConst.h"
-     Previously, this function was relying on another include file
-     to include "e_HuffmanConst.h"
-
- (2) Updated the copyright header.
-
- (3) Added #include of <stdlib.h> for NULL macro definition.
-
- Description:
- (1) Removed the first parameter to getics.c  This extra
-     FrameInfo was not needed, the contents of winmap can be used.
- (2) Removed the memcpy of the data from winmap to the temporary
-     FrameInfo.
-
- Description: Replace some instances of getbits to get1bits
-              when only 1 bit is read.
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pInputStream    =   pointer to structure that holds input stream,
-                        Type BITS
-
-    common_window   =   flag that indicates whether left and right channel
-                        share the same window sequence & shape, Type Int
-
-    pVars           =   pointer to structure that holds decoder information
-                        Type tDec_Int_File
-
-    pChVarsCh       =   pointer to structure that holds channel related
-                        decoding information, Type tDec_Int_Chan
-
-    group[]         =   pointer to array that contains window grouping
-                        information of current frame, Type UChar
-
-    pMax_sfb        =   pointer to variable that stores maximum active
-                        scalefactor bands of current frame, Type UChar
-
-    pCodebookMap    =   pointer to array that holds the indexes of all
-                        Huffman codebooks used for current frame, ordered
-                        from section 0 to last section. Type UChar
-
-    pTnsFrameInfo   =   pointer to structure that holds TNS information.
-                        Type TNS_frame_info
-
-    pWinMap         =   array of pointers which points to structures that
-                        hold information of long and short window sequences
-                        Type FrameInfo
-
-    pPulseInfo       =   pointer to structure that holds pulse data decoding
-                        information, Type Nec_info
-
-    sect[]          =   array of structures that hold section codebook and
-                        section length in current frame, Type SectInfo
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    status = 0  if success
-             1  otherwise
-
- Pointers and Buffers Modified:
-    pCodebookMap    contents are replaced by the indexes of all the huffman
-                    codebooks used for current frame
-
-    pWinMap         For short windows, the contents of frame_sfb_top are
-                    modified by calc_gsfb_table, with the top coefficient
-                    index of each scalefactor band.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes individual channel stream by calling other Huffman
- decoding functions.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function replaces the contents of pCodebookMap with the decoded
- codebook indexes. By calling hufffac, it decodes scale factor data. Call
- huffspec_fxp to decode spectral coefficients of current frame.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4           p24 (Table 4.4.24)
-                        p54 (4.5.2.3.2)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pGroup = group;
-
-    global_gain = CALL getbits(
-                            neededBits   = LEN_SCL_PCM,
-                            pInputStream = pInputStream)
-                        MODIFYING(pInputStream)
-                        ReTURNING(global_gain)
-
-    IF (common_window == FALSE)
-    THEN
-        status = CALL get_ics_info(
-                        pVars->mc_info.audioObjectType,
-                        pInputStream,
-                        common_window,
-                       &pChVars->wnd,
-                       &pChVars->wnd_shape_this_bk,
-                        group,
-                        pMax_sfb,
-                        pWinMap,
-                        &pChVars->lt_status,
-                        NULL)
-                    MODIFYING(pInputStream,pChVars,group,max_sfb,lt_status)
-                    RETURNING(status)
-    ENDIF
-
-    memcpy(pFrameInfo, pWinMap[pChVars->wnd], sizeof(FrameInfo))
-
-    IF (*pMax_sfb > 0)
-    THEN
-
-        i      = 0;
-        totSfb = 0;
-
-        DO
-
-            totSfb++;
-
-        WHILE( *pGroup++ < pFrameInfo->num_win);
-
-        totSfb  *=  pFrameInfo->sfb_per_win[0];
-
-        nsect = CALL huffcb(
-                        sect,
-                        pInputStream,
-                        pFrameInfo->sectbits,
-                        totSfb,
-                        pFrameInfo->sfb_per_win[0],
-                       *pMax_sfb)
-                    MODIFYING(sect,pInputStream,sectbits)
-                    RETURNING(nsect)
-
-        IF (nsect == 0)
-        THEN
-            status = 1
-
-        ENDIF
-
-        sectStart = 0;
-        FOR (i = 0; i < nsect; i++)
-
-            cb  = sect[i].sect_cb;
-            sectWidth =  sect[i].sect_end - sectStart;
-            sectStart += sectWidth;
-
-            WHILE (sectWidth > 0)
-
-                *pCodebookMap++ = cb
-                 sectWidth--
-            ENDWHILE
-
-        ENDFOR (i)
-
-    ELSE
-
-        memset(pCodebookMap,ZERO_HCB,MAXBANDS*sizeof(*pCodebookMap));
-
-    ENDIF (*pMax_sfb)
-
-    IF (pFrameInfo->islong == FALSE)
-    THEN
-        CALL calc_gsfb_table(
-                pFramInfo = pFrameInfo,
-                group[]   = group)
-              MODIFYING(pFrameInfo->frame_sfb_top)
-              RETURNING(void)
-    ENDIF
-
-    IF (status == SUCCESS)
-    THEN
-        status = CALL hufffac(
-                        pFrameInfo,
-                        pInputStream,
-                        group,
-                        nsect,
-                        sect,
-                        global_gain,
-                        pChVars->factors,
-                        pVars->huffBookUsed)
-                    MODIFYING(pInputStream,factors)
-                    RETURNING(status)
-
-    ENDIF (status)
-
-    IF (status == SUCCESS)
-    THEN
-        present = CALL getbits(
-                        neededBits   = LEN_PULSE_PRES,
-                        pInputStream = pInputStream)
-                    MODIFYING(pInputStream)
-                    RETURNING(present)
-
-        pPulseInfo->pulse_data_present = present;
-
-        IF (present != FALSE)
-        THEN
-            IF (pFrameInfo->islong == 1)
-            THEN
-                CALL get_pulse_data(
-                          pPulseInfo = pPulseInfo,
-                          pInputStream = pInputStream)
-                    MODIFYING(pInputStream,pPulseInfo)
-                    RETURNING(void)
-
-            ELSE
-
-                status = 1;
-
-            ENDIF (pFrameInfo)
-        ENDIF (present)
-
-    ENDIF (status)
-
-    IF (status == SUCCESS)
-    THEN
-        present = CALL getbits(
-                        neededBits = LEN_TNS_PRES,
-                        pInputStream = pInputStream)
-                    MODIFYING(pInputStream)
-                    RETURNING(present)
-
-        pTnsFrameInfo->tns_data_present = present;
-
-        IF (present != FALSE)
-        THEN
-            CALL get_tns(
-                    pFrameInfo = pFrameInfo,
-                    pTnsFrameInfo = pTnsFrameInfo,
-                    pInputStream = pInputStream)
-                MODIFYING(pInputStream, pTnsFrameInfo)
-                RETURNING(void)
-        ELSE
-
-            FOR (i = pTnsFrameInfo->n_subblocks - 1; i >= 0 ; i--)
-
-                pTnsFrameInfo->info[i].n_filt = 0;
-            ENDFOR
-
-        ENDIF(present)
-
-    ENDIF (status)
-
-    IF (status == SUCCESS)
-    THEN
-        present = CALL getbits(
-                        neededBits = LEN_GAIN_PRES,
-                        pInputStream = pInputStream)
-                MODIFYING(pInputStream)
-                RETURNING(present)
-
-        IF (present != FALSE)
-        THEN
-            status = 1;
-        ENDIF
-    ENDIF (status)
-
-    IF (status == SUCCESS)
-    THEN
-        status = CALL huffspec_fxp(
-                        pFrameInfo,
-                        pInputStream,
-                        nsect,
-                        sect,
-                        pChVars->factors,
-                        pChVars->fxpCoef,
-                        pVars->quantSpec,
-                        pVars->tmp_spec,
-                        pWinMap[ONLY_LONG_WINDOW],
-                        pPulseInfo,
-                        pChVars->qFormat)
-                MODIFYING(pInputStream,fxpCoef,quantSpec,tmp_spec,qFormat)
-                RETURNING(status)
-    ENDIF
-
-    RETURN status
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "e_huffmanconst.h"
-#include    "huffman.h"
-#include    "aac_mem_funcs.h"
-#include    "get_tns.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int getics(
-    BITS            *pInputStream,
-    Int             common_window,
-    tDec_Int_File   *pVars,
-    tDec_Int_Chan   *pChVars,
-    Int             group[],
-    Int             *pMax_sfb,
-    Int             *pCodebookMap,
-    TNS_frame_info  *pTnsFrameInfo,
-    FrameInfo       **pWinMap,
-    PulseInfo       *pPulseInfo,
-    SectInfo        sect[])
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    Int     status = SUCCESS;
-
-    Int     nsect = 0;
-    Int     i;
-    Int     cb;
-    Int     sectWidth;
-    Int     sectStart;
-    Int     totSfb;
-    Int     *pGroup;
-
-    FrameInfo *pFrameInfo;
-
-    Int     global_gain; /* originally passed in from huffdecode */
-    Bool    present;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-    pGroup = group;
-
-    /* read global gain from Input bitstream */
-    global_gain =
-        get9_n_lessbits(
-            LEN_SCL_PCM,
-            pInputStream);
-
-    if (common_window == FALSE)
-    {
-        status = get_ics_info(
-                     pVars->mc_info.audioObjectType,
-                     pInputStream,
-                     common_window,
-                     &pChVars->wnd,
-                     &pChVars->wnd_shape_this_bk,
-                     group,
-                     pMax_sfb,
-                     pWinMap,
-                     &pChVars->pShareWfxpCoef->lt_status,
-                     NULL);
-    }
-
-    pFrameInfo = pWinMap[pChVars->wnd];
-
-    /* First, calculate total number of scalefactor bands
-     * for this grouping. Then, decode section data
-     */
-    if (*pMax_sfb > 0)
-    {
-
-        /* calculate total number of sfb */
-        i      = 0;
-        totSfb = 0;
-
-        do
-        {
-            totSfb++;
-
-        }
-        while (*pGroup++ < pFrameInfo->num_win);
-
-        totSfb  *=  pFrameInfo->sfb_per_win[0];
-
-        /* decode section data */
-        nsect =
-            huffcb(
-                sect,
-                pInputStream,
-                pFrameInfo->sectbits,
-                totSfb,
-                pFrameInfo->sfb_per_win[0],
-                *pMax_sfb);
-
-        if (nsect == 0)
-        {
-            status = 1;     /* decode section data error */
-
-        }/* if (nsect) */
-
-        /* generate "linear" description from section info
-         * stored as codebook for each scalefactor band and group
-         * when nsect == 0, for-loop does not execute
-         */
-        sectStart = 0;
-        for (i = 0; i < nsect; i++)
-        {
-            cb  = sect[i].sect_cb;
-            sectWidth =  sect[i].sect_end - sectStart;
-            sectStart += sectWidth;
-
-            while (sectWidth > 0)
-            {
-                *pCodebookMap++ = cb;   /* cannot use memset for Int */
-                sectWidth--;
-            }
-
-        } /* for (i) */
-
-    }
-    else
-    {
-        /* set all sections with ZERO_HCB */
-        pv_memset(
-            pCodebookMap,
-            ZERO_HCB,
-            MAXBANDS*sizeof(*pCodebookMap));
-        /*
-                for (i=MAXBANDS; i>0; i--)
-                {
-                    *(pCodebookMap++) = ZERO_HCB;
-                }
-        */
-
-    } /* if (*pMax_sfb) */
-
-    /* calculate band offsets
-     * (because of grouping and interleaving this cannot be
-     * a constant: store it in pFrameInfo->frame_sfb_top)
-     */
-    if (pFrameInfo->islong == FALSE)
-    {
-        calc_gsfb_table(
-            pFrameInfo,
-            group);
-    }
-
-    /* decode scale factor data */
-    if (status == SUCCESS)
-    {
-        status =
-            hufffac(
-                pFrameInfo,
-                pInputStream,
-                group,
-                nsect,
-                sect,
-                global_gain,
-                pChVars->pShareWfxpCoef->factors,
-                pVars->scratch.huffbook_used);
-
-    } /* if (status) */
-
-    /* noiseless coding */
-    if (status == SUCCESS)
-    {
-        present =
-            get1bits(pInputStream);
-
-        pPulseInfo->pulse_data_present = present;
-
-        if (present != FALSE)
-        {
-            if (pFrameInfo->islong == 1)
-            {
-                status = get_pulse_data(
-                             pPulseInfo,
-                             pInputStream);
-            }
-            else
-            {
-                /* CommonExit(1,"Pulse data not allowed for short blocks"); */
-                status = 1;
-
-            } /* if (pFrameInfo) */
-        } /* if (present) */
-
-    } /* if (status) */
-
-
-    /* decode tns data */
-    if (status == SUCCESS)
-    {
-        present =
-            get1bits(pInputStream);
-
-        pTnsFrameInfo->tns_data_present = present;
-
-        if (present != FALSE)
-        {
-            get_tns(
-                pChVars->pShareWfxpCoef->max_sfb,
-                pInputStream,
-                pChVars->wnd,
-                pFrameInfo,
-                &pVars->mc_info,
-                pTnsFrameInfo,
-                pVars->scratch.tns_decode_coef);
-        }
-        else
-        {
-            for (i = pFrameInfo->num_win - 1; i >= 0 ; i--)
-            {
-                pTnsFrameInfo->n_filt[i] = 0;
-            }
-
-        } /* if(present) */
-
-    } /* if (status) */
-
-    /* gain control */
-    if (status == SUCCESS)
-    {
-        present =
-            get1bits(pInputStream);
-
-        if (present != FALSE)
-        {
-            /* CommonExit(1, "Gain control not implemented"); */
-            status = 1;
-        }
-    } /* if (status) */
-
-    if (status == SUCCESS)
-    {
-        status =
-            huffspec_fxp(
-                pFrameInfo,
-                pInputStream,
-                nsect,
-                sect,
-                pChVars->pShareWfxpCoef->factors,
-                pChVars->fxpCoef,
-                pVars->share.a.quantSpec,
-                pVars->scratch.tmp_spec,
-                pWinMap[ONLY_LONG_WINDOW],
-                pPulseInfo,
-                pChVars->pShareWfxpCoef->qFormat);
-    }
-
-    /*----------------------------------------------------------------------------
-    ; Return status
-    ----------------------------------------------------------------------------*/
-
-    return status;
-
-} /* getics */
diff --git a/media/libstagefright/codecs/aacdec/getmask.cpp b/media/libstagefright/codecs/aacdec/getmask.cpp
deleted file mode 100644
index 2fd34f1..0000000
--- a/media/libstagefright/codecs/aacdec/getmask.cpp
+++ /dev/null
@@ -1,384 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: getmask.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-               Replaced for-loop style memory initialization with memset()
-
- Description: (1) Modified to bring code in-line with PV standard
-              (2) Removed multiple returns, Replaced multiple 'if's with
-                  switch
-
- Description: (1) Modified per review comments
-              (2) increment pointer pMask after memset
-
- Description: Make the maximum number of bits requested from getbits
-              become a constant.
-
- Description: Typecast 1 to UInt32 for bitmask to avoid masking on a 16-bit
-              platform
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less.
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-        pFrameInfo  = pointer to structure that holds information for current
-                      frame, Type FrameInfo
-
-        pInputStream= pointer to structure that holds input stream information
-                      Type BITS
-
-        pGroup      = pointer to array that holds the stop window index for
-                      each group in current frame, Type Int
-
-        max_sfb     = number of active sfbs for each window, Type Int
-
-        mask[]      = array that holds the MS_mask information
-                      Type Int
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    mask_present = 0    (no Mid/Side mixed)
-                   2    (Mid/Side mixed present for entire frame)
-                   1    (Mid/Side mixed information read from bitstream)
-                   -1   (invalid mask_present read from bitstream)
-
- Pointers and Buffers Modified:
-    pMask   contents replaced by MS information of each scalefactor band
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function reads the Mid/Side(MS) mask information from the input
- bitstream. If the mask_present field is equal to 2, the mask bits is set to
- 1 for the entire frame. If mask_present has a value of 0, the function
- returns 0, If mask_present is set to 1, the Mid/Side(MS) information is
- read from the input stream. When mask_present is 3, an error code (-1) is
- generated.
- The Mid/Side(MS) information is later used for mixing the left and right
- channel sounds. Each scalefactor band has its own MS information.
-
- (ISO comments: read a synthesis mask,  read a synthesis mask uses
-                EXTENDED_MS_MASK and grouped mask )
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall replace the contents of pMask with the MS information
- of each scalefactor band
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4
-                    p15     (Table 4.4.5    getmask)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    CALL getbits(LEN_MASK_PRES, pInputStream)
-    MODIFYING (pInputStream)
-    RETURNING (mask present information)
-    mask_present = mask present information
-
-    SWITCH (mask_present)
-
-        CASE (0):
-            BREAK;
-
-        CASE (2):
-            nwin = pFrameInfo->num_win;
-            FOR(win = 0; win < nwin; win = *(pGroup++))
-
-                FOR(sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--)
-                    *(pMask++) = 1;
-                ENDFOR
-
-            ENDFOR
-
-            BREAK;
-
-        CASE(1):
-
-            nwin = pFrameInfo->num_win;
-
-                nToDo = max_sfb;
-
-                WHILE (nToDo > 0)
-                    nCall = nToDo;
-
-                    IF (nCall > MAX_GETBITS)
-                    THEN
-                        nCall = MAX_GETBITS;
-                    ENDIF
-
-                    tempMask =
-                        getbits(
-                            nCall,
-                            pInputStream);
-
-                    bitmask = 1 << (nCall - 1);
-                    FOR (sfb = nCall; sfb > 0; sfb--)
-                       *(pMask++) = (tempMask & bitmask) >> (sfb - 1);
-                        bitmask >>= 1;
-                    ENDFOR
-
-                    nToDo -= nCall;
-                END WHILE
-
-                pv_memset(
-                    pMask,
-                    0,
-                    (pFrameInfo->sfb_per_win[win]-max_sfb)*sizeof(*pMask));
-
-            ENDFOR (win)
-
-            BREAK
-
-        DEFAULT:
-            mask_present = -1
-
-    ENDSWITCH
-
-    RETURN  mask_present
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-#include    "aac_mem_funcs.h"
-#include    "e_maskstatus.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int getmask(
-    FrameInfo   *pFrameInfo,
-    BITS        *pInputStream,
-    Int         group[],
-    Int         max_sfb,
-    Int         mask[])
-{
-
-    Int     win; /* window index */
-    Int     sfb;
-    Int     mask_present;
-    Int    *pMask;
-    Int    *pGroup;
-    Int     nwin;
-    Int     nCall;
-    Int     nToDo;
-    UInt32  tempMask;
-    UInt32  bitmask;
-
-    pMask  = mask;
-    pGroup = group;
-
-    mask_present =
-        get9_n_lessbits(
-            LEN_MASK_PRES,
-            pInputStream);
-
-    switch (mask_present)
-    {
-        case(MASK_NOT_PRESENT):
-            /* special EXTENDED_MS_MASK cases */
-            /* no ms at all */
-            break;
-
-        case(MASK_ALL_FRAME):
-            /* MS for whole spectrum on, mask bits set to 1 */
-            nwin = pFrameInfo->num_win;
-            for (win = 0; win < nwin; win = *(pGroup++))
-            {
-                for (sfb = pFrameInfo->sfb_per_win[win]; sfb > 0; sfb--)
-                {
-                    *(pMask++) = 1; /* cannot use memset for Int type */
-                }
-
-            }
-
-            break;
-
-        case(MASK_FROM_BITSTREAM):
-            /* MS_mask_present==1, get mask information*/
-            nwin = pFrameInfo->num_win;
-            for (win = 0; win < nwin; win = *(pGroup++))
-            {
-                /*
-                 * the following code is equivalent to
-                 *
-                 * for(sfb = max_sfb; sfb > 0; sfb--)
-                 * {
-                 *   *(pMask++) =
-                 *       getbits(
-                 *           LEN_MASK,
-                 *           pInputStream);
-                 * }
-                 *
-                 * in order to save the calls to getbits, the above
-                 * for-loop is broken into two parts
-                 */
-
-                nToDo = max_sfb;
-
-                while (nToDo > 0)
-                {
-                    nCall = nToDo;
-
-                    if (nCall > MAX_GETBITS)
-                    {
-                        nCall = MAX_GETBITS;
-                    }
-
-                    tempMask =
-                        getbits(
-                            nCall,
-                            pInputStream);
-
-                    bitmask = (UInt32) 1 << (nCall - 1);
-                    for (sfb = nCall; sfb > 0; sfb--)
-                    {
-                        *(pMask++) = (Int)((tempMask & bitmask) >> (sfb - 1));
-                        bitmask >>= 1;
-                    }
-
-                    nToDo -= nCall;
-                }
-
-                /*
-                 * set remaining sfbs to zero
-                 * re-use nCall to save one variable on stack
-                 */
-
-                nCall = pFrameInfo->sfb_per_win[win] - max_sfb;
-
-
-                if (nCall >= 0)
-                {
-                    pv_memset(pMask,
-                              0,
-                              nCall*sizeof(*pMask));
-
-                    pMask += nCall;
-                }
-                else
-                {
-                    mask_present = MASK_ERROR;
-                    break;
-                }
-
-
-            } /* for (win) */
-
-            break;
-
-        default:
-            /* error */
-            break;
-
-    } /* switch (mask_present) */
-
-    return mask_present;
-
-} /* getmask */
diff --git a/media/libstagefright/codecs/aacdec/hcbtables.h b/media/libstagefright/codecs/aacdec/hcbtables.h
deleted file mode 100644
index a35fed0..0000000
--- a/media/libstagefright/codecs/aacdec/hcbtables.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: hcbtables.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) Add declaration of binary tree tables
-              (2) #if optimized Linear Search Huffman decoding
-
- Description: Modified per review comments
-              (1) delete #if optimized Linear Search Huffman decoding
-              (2) modified copyright header
-
- Description: (1) Add declaration different huffman tables
-
- Who:                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Declare the structure array for Huffman Codebooks information.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef _HCBTABLES_H
-#define _HCBTABLES_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include    "s_hcb.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /* ISO: Hcb book[NSPECBOOKS + 2]; */
-
-    extern const Hcb hcbbook_binary[13];
-    extern const Int32 huff_tab1[88];
-    extern const Int32 huff_tab2[90];
-    extern const Int32 huff_tab3[151];
-    extern const Int32 huff_tab4[119];
-    extern const Int32 huff_tab5[110];
-    extern const Int32 huff_tab6[113];
-    extern const Int32 huff_tab7[107];
-    extern const Int32 huff_tab8[90];
-    extern const Int32 huff_tab9[204];
-    extern const Int32 huff_tab10[186];
-    extern const Int32 huff_tab11[301];
-    extern const UInt32 huff_tab_scl[188];
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp b/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp
deleted file mode 100644
index d097af1..0000000
--- a/media/libstagefright/codecs/aacdec/hcbtables_binary.cpp
+++ /dev/null
@@ -1,1938 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: hcbtables.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modifiy per review comments
-    (1) delete the following comments:
-        The LAV field has been deleted, since it is never used.
-
- Description: Remove old structure of huffman table and add new table structure.
-
- Description: Modified structure to avoid assigning addresses to constant
-              tables. This solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers
-              - Eliminated references to contant vector addresses in
-                hcbbook_binary
-
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs: None
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This file defines the 12 packed Huffman Tables and a structure that reference
- to these tables.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- ISO/IEC 14496-3: 1999(E)
- Subpart 4          p78 (Table 4.6.1 and Table 4.6.2)
-                    p77 (pseudo code)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-#include    "s_hcb.h"
-#include    "hcbtables.h"
-
-/* This file store packed Huffman tables for binary tree search */
-
-/*
- * all tables are packed in the following way:
- * right pointer (7 bits) idx (9 bits)
- */
-
-
-const Hcb hcbbook_binary[13] =
-{
-
-    { 0, -1,  -1, -1, -1 },   /* ZERO_HCB */
-    { 1,  4,   3,  1,  1 },   /* codebook 1 */
-    { 2,  4,   3,  1,  1 },   /* codebook 2 */
-    { 3,  4,   3,  0,  0 },   /* codebook 3 */
-    { 4,  4,   3,  0,  0 },   /* codebook 4 */
-    { 5,  2,   9,  4,  1 },
-    { 6,  2,   9,  4,  1 },
-    { 7,  2,   8,  0,  0 },
-    { 8,  2,   8,  0,  0 },
-    { 9,  2,  13,  0,  0 },
-    {10,  2,  13,  0,  0 },
-    {11,  2,  17,  0,  0 },  /* codebook 11 ESC book */
-    {12, -1,  -1, -1, -1 }   /* scalefactor codebook */
-
-
-};
-
-
-/* New look-up table for huffman decoding
-   Created by ordering the codeword in the table according to their
-   normalized shifted binary value, i.e., all the codewords are left
-   shifted to meet the maximum codelength. Example, max codelength is
-   10, the codeword with lenth 3 will left shift by 7.
-   The binary values of after the shift are sorted.
-   Then the sorted table is divided into several partition.
-   At the VLC decoding period, input is read in at max codelenght.
-   The partition is decided using if-else logic.
-   Inside each partition, a look-up table is used to map the input value
-   to a correct symbol. Table entries can appear to be repeated according
-   to the humming distance between adjacent codewords.
-*/
-
-const Int32 huff_tab1[88] =
-{
-    0x430005,
-    0xd0005,
-    0x270005,
-    0x310005,
-    0x290005,
-    0x250005,
-    0x2b0005,
-    0x1f0005,
-    0x3a0007,
-    0x160007,
-    0x260007,
-    0x2e0007,
-    0x220007,
-    0x2a0007,
-    0x4c0007,
-    0x240007,
-    0x40007,
-    0x1c0007,
-    0x400007,
-    0x300007,
-    0x100007,
-    0x2c0007,
-    0x460007,
-    0x200007,
-    0x340007,
-    0x320007,
-    0xa0007,
-    0x440007,
-    0xc0007,
-    0x420007,
-    0xe0007,
-    0x1e0007,
-    0x490009,
-    0x130009,
-    0x3d0009,
-    0x330009,
-    0x2f0009,
-    0x230009,
-    0x210009,
-    0x370009,
-    0x410009,
-    0x2d0009,
-    0x190009,
-    0xf0009,
-    0x70009,
-    0x1d0009,
-    0x3b0009,
-    0x390009,
-    0x150009,
-    0x10009,
-    0x1b0009,
-    0x350009,
-    0x450009,
-    0x4d0009,
-    0x170009,
-    0x4f0009,
-    0x5000a,
-    0x5000a,
-    0x9000a,
-    0x9000a,
-    0x4b000a,
-    0x4b000a,
-    0x3f000a,
-    0x3f000a,
-    0xb000a,
-    0xb000a,
-    0x3000a,
-    0x3000a,
-    0x11000a,
-    0x11000a,
-    0x47000a,
-    0x47000a,
-    0x3c000b,
-    0x14000b,
-    0x18000b,
-    0x38000b,
-    0x50000b,
-    0x8000b,
-    0x48000b,
-    0x6000b,
-    0xb,
-    0x4a000b,
-    0x3e000b,
-    0x1a000b,
-    0x12000b,
-    0x2000b,
-    0x36000b,
-    0x4e000b
-};
-
-const Int32 huff_tab2[90] =
-{
-    0x430004,
-    0x430004,
-    0x430004,
-    0x430004,
-    0xd0005,
-    0xd0005,
-    0x290005,
-    0x290005,
-    0x250005,
-    0x250005,
-    0x270005,
-    0x270005,
-    0x1f0005,
-    0x1f0005,
-    0x2b0005,
-    0x2b0005,
-    0x310005,
-    0x310005,
-    0x220006,
-    0x160006,
-    0x2e0006,
-    0x2a0006,
-    0x300006,
-    0x260006,
-    0xc0006,
-    0x3a0006,
-    0x400006,
-    0x40006,
-    0x240006,
-    0x460006,
-    0x440006,
-    0x200006,
-    0x100006,
-    0x320006,
-    0x1c0006,
-    0xe0006,
-    0x1e0006,
-    0xa0006,
-    0x4c0006,
-    0x340006,
-    0x2c0006,
-    0x420006,
-    0x2f0007,
-    0x410007,
-    0x130007,
-    0x210007,
-    0x3d0007,
-    0x4b0007,
-    0x470007,
-    0x190007,
-    0x1d0007,
-    0x4f0007,
-    0xf0007,
-    0x10007,
-    0xb0007,
-    0x370007,
-    0x490007,
-    0x3b0008,
-    0x150008,
-    0x70008,
-    0x110008,
-    0x50008,
-    0x30008,
-    0x1b0008,
-    0x450008,
-    0x3f0008,
-    0x2d0008,
-    0x350008,
-    0x170008,
-    0x90008,
-    0x330008,
-    0x390008,
-    0x230008,
-    0x4d0008,
-    0x3c0008,
-    0x140008,
-    0x380009,
-    0x9,
-    0x180009,
-    0x1a0009,
-    0x500009,
-    0x60009,
-    0x3e0009,
-    0x120009,
-    0x80009,
-    0x480009,
-    0x360009,
-    0x20009,
-    0x4a0009,
-    0x4e0009
-};
-
-const Int32 huff_tab3[151] =
-{
-    0x1b0004,
-    0x1b0004,
-    0x1b0004,
-    0x1b0004,
-    0x10004,
-    0x10004,
-    0x10004,
-    0x10004,
-    0x90004,
-    0x90004,
-    0x90004,
-    0x90004,
-    0x30004,
-    0x30004,
-    0x30004,
-    0x30004,
-    0x240005,
-    0x240005,
-    0x40005,
-    0x40005,
-    0xc0006,
-    0xa0006,
-    0x1e0006,
-    0xd0006,
-    0x1c0006,
-    0x270006,
-    0x280007,
-    0x280007,
-    0x280007,
-    0x280007,
-    0x1f0007,
-    0x1f0007,
-    0x1f0007,
-    0x1f0007,
-    0x250007,
-    0x250007,
-    0x250007,
-    0x250007,
-    0x360008,
-    0x360008,
-    0x20008,
-    0x20008,
-    0x50008,
-    0x50008,
-    0x3f0008,
-    0x3f0008,
-    0x300008,
-    0x300008,
-    0x70009,
-    0x100009,
-    0x2d0009,
-    0xe0009,
-    0x420009,
-    0x60009,
-    0x150009,
-    0xf0009,
-    0x120009,
-    0xb0009,
-    0x390009,
-    0x310009,
-    0x160009,
-    0x2a0009,
-    0x2b0009,
-    0x2e000a,
-    0x21000a,
-    0x22000a,
-    0x13000a,
-    0x43000a,
-    0x29000a,
-    0x40000a,
-    0x20000a,
-    0x8000a,
-    0x11000a,
-    0x4b000a,
-    0x33000a,
-    0x1d000a,
-    0x37000a,
-    0x19000a,
-    0x48000b,
-    0x48000b,
-    0x34000b,
-    0x34000b,
-    0x26000b,
-    0x26000b,
-    0x3a000b,
-    0x3a000b,
-    0x2c000b,
-    0x2c000b,
-    0x4c000b,
-    0x4c000b,
-    0x18000b,
-    0x18000b,
-    0x17000b,
-    0x17000b,
-    0x23000c,
-    0x49000c,
-    0x45000c,
-    0x4e000c,
-    0x1a000c,
-    0x4f000c,
-    0x46000c,
-    0x32000c,
-    0x35000c,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x14000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x3c000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x2f000d,
-    0x3d000e,
-    0x3d000e,
-    0x3d000e,
-    0x3d000e,
-    0x44000e,
-    0x44000e,
-    0x44000e,
-    0x44000e,
-    0x41000e,
-    0x41000e,
-    0x41000e,
-    0x41000e,
-    0x50000f,
-    0x50000f,
-    0x4d000f,
-    0x4d000f,
-    0x47000f,
-    0x47000f,
-    0x3b000f,
-    0x3b000f,
-    0x38000f,
-    0x38000f,
-    0x4a0010,
-    0x3e0010
-};
-
-const Int32 huff_tab4[119] =
-{
-    0x280004,
-    0x280004,
-    0xd0004,
-    0xd0004,
-    0x250004,
-    0x250004,
-    0x270004,
-    0x270004,
-    0x1f0004,
-    0x1f0004,
-    0x1b0004,
-    0x1b0004,
-    0x240004,
-    0x240004,
-    0x4,
-    0x4,
-    0x40004,
-    0x40004,
-    0x1e0004,
-    0x1e0004,
-    0x1c0005,
-    0xc0005,
-    0x10005,
-    0xa0005,
-    0x30005,
-    0x90005,
-    0x430007,
-    0x430007,
-    0x2b0007,
-    0x2b0007,
-    0x310007,
-    0x310007,
-    0x290007,
-    0x290007,
-    0x420007,
-    0x420007,
-    0x400007,
-    0x400007,
-    0x300007,
-    0x300007,
-    0x3a0007,
-    0x3a0007,
-    0x100007,
-    0x100007,
-    0xe0008,
-    0x2a0008,
-    0x160008,
-    0x200008,
-    0x2e0008,
-    0x260008,
-    0x220008,
-    0x3f0008,
-    0x390008,
-    0x2d0008,
-    0x370008,
-    0xb0008,
-    0x150008,
-    0x50008,
-    0xf0008,
-    0x130008,
-    0x1d0008,
-    0x70008,
-    0x210008,
-    0x360008,
-    0x20008,
-    0x120009,
-    0x120009,
-    0x60009,
-    0x60009,
-    0x340009,
-    0x340009,
-    0x4c0009,
-    0x4c0009,
-    0x460009,
-    0x460009,
-    0x2c0009,
-    0x2c0009,
-    0x320009,
-    0x320009,
-    0x440009,
-    0x440009,
-    0x33000a,
-    0x4b000a,
-    0x45000a,
-    0x19000a,
-    0x11000a,
-    0x49000a,
-    0x17000a,
-    0x3d000a,
-    0x23000a,
-    0x4f000a,
-    0x2f000a,
-    0x3b000a,
-    0x41000a,
-    0x35000a,
-    0x47000b,
-    0x47000b,
-    0x4d000b,
-    0x4d000b,
-    0x18000b,
-    0x18000b,
-    0x48000b,
-    0x48000b,
-    0x8000b,
-    0x8000b,
-    0x3c000b,
-    0x3c000b,
-    0x14000b,
-    0x14000b,
-    0x38000b,
-    0x38000b,
-    0x50000b,
-    0x50000b,
-    0x1a000b,
-    0x1a000b,
-    0x4e000b,
-    0x4e000b,
-    0x4a000c,
-    0x3e000c
-};
-
-const Int32 huff_tab5[110] =
-{
-    0x1f0004,
-    0x1f0004,
-    0x310004,
-    0x310004,
-    0x290004,
-    0x290004,
-    0x270004,
-    0x270004,
-    0x300005,
-    0x200005,
-    0x1e0005,
-    0x320005,
-    0x160007,
-    0x160007,
-    0x2a0007,
-    0x2a0007,
-    0x3a0007,
-    0x3a0007,
-    0x260007,
-    0x260007,
-    0x150008,
-    0x3b0008,
-    0x1d0008,
-    0x330008,
-    0x170008,
-    0x390008,
-    0x210008,
-    0x2f0008,
-    0xd0008,
-    0x430008,
-    0x250008,
-    0x2b0008,
-    0xc0009,
-    0xc0009,
-    0x340009,
-    0x340009,
-    0x440009,
-    0x440009,
-    0x1c0009,
-    0x1c0009,
-    0xe0009,
-    0xe0009,
-    0x420009,
-    0x420009,
-    0x2e0009,
-    0x2e0009,
-    0x220009,
-    0x220009,
-    0x180009,
-    0x180009,
-    0x3c0009,
-    0x3c0009,
-    0x140009,
-    0x140009,
-    0x380009,
-    0x380009,
-    0xb000a,
-    0x41000a,
-    0x19000a,
-    0x37000a,
-    0x45000a,
-    0x3d000a,
-    0xf000a,
-    0x13000a,
-    0x24000a,
-    0x4000a,
-    0x4d000a,
-    0x4c000a,
-    0x3000b,
-    0x2c000b,
-    0x4b000b,
-    0x1b000b,
-    0x35000b,
-    0x23000b,
-    0x5000b,
-    0x2d000b,
-    0x40000b,
-    0xa000b,
-    0x10000b,
-    0x1a000b,
-    0x2000b,
-    0x4e000b,
-    0x36000b,
-    0x3e000b,
-    0x46000b,
-    0x6000b,
-    0x12000c,
-    0x12000c,
-    0x4a000c,
-    0x4a000c,
-    0x3f000c,
-    0x3f000c,
-    0x1000c,
-    0x1000c,
-    0x7000c,
-    0x7000c,
-    0x47000c,
-    0x47000c,
-    0x11000c,
-    0x11000c,
-    0x4f000c,
-    0x4f000c,
-    0x49000c,
-    0x49000c,
-    0x9000c,
-    0x9000c,
-    0x48000d,
-    0x8000d,
-    0x50000d,
-    0xd
-};
-const Int32 huff_tab6[113] =
-{
-    0x280004,
-    0x310004,
-    0x270004,
-    0x290004,
-    0x1f0004,
-    0x320004,
-    0x200004,
-    0x300004,
-    0x1e0004,
-    0x390006,
-    0x390006,
-    0x3b0006,
-    0x3b0006,
-    0x170006,
-    0x170006,
-    0x150006,
-    0x150006,
-    0x160006,
-    0x160006,
-    0x210006,
-    0x210006,
-    0x3a0006,
-    0x3a0006,
-    0x2f0006,
-    0x2f0006,
-    0x330006,
-    0x330006,
-    0x260006,
-    0x260006,
-    0x1d0006,
-    0x1d0006,
-    0x2a0006,
-    0x2a0006,
-    0x380006,
-    0x380006,
-    0x180006,
-    0x180006,
-    0x140006,
-    0x140006,
-    0x3c0006,
-    0x3c0006,
-    0xe0007,
-    0x440007,
-    0x420007,
-    0x220007,
-    0xc0007,
-    0x340007,
-    0x2e0007,
-    0x1c0007,
-    0x430007,
-    0xd0007,
-    0x250007,
-    0x2b0007,
-    0x450007,
-    0xb0008,
-    0xb0008,
-    0x190008,
-    0x190008,
-    0x3d0008,
-    0x3d0008,
-    0x410008,
-    0x410008,
-    0x370008,
-    0x370008,
-    0x130008,
-    0x130008,
-    0xf0008,
-    0xf0008,
-    0x460008,
-    0x460008,
-    0x400009,
-    0xa0009,
-    0x100009,
-    0x2d0009,
-    0x1b0009,
-    0x4d0009,
-    0x50009,
-    0x30009,
-    0x350009,
-    0x4b0009,
-    0x230009,
-    0x240009,
-    0x60009,
-    0x20009,
-    0x3e0009,
-    0x120009,
-    0x40009,
-    0x4e0009,
-    0x4a0009,
-    0x1a0009,
-    0x4c0009,
-    0x360009,
-    0x2c0009,
-    0x9000a,
-    0x9000a,
-    0x11000a,
-    0x11000a,
-    0x3f000a,
-    0x3f000a,
-    0x49000a,
-    0x49000a,
-    0x47000a,
-    0x47000a,
-    0x4f000a,
-    0x4f000a,
-    0x7000a,
-    0x7000a,
-    0x1000a,
-    0x1000a,
-    0x50000b,
-    0x8000b,
-    0xb,
-    0x48000b
-};
-
-const Int32 huff_tab7[107] =
-{
-    0x80003,
-    0x80003,
-    0x80003,
-    0x80003,
-    0x80003,
-    0x80003,
-    0x80003,
-    0x80003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x10003,
-    0x90004,
-    0x90004,
-    0x90004,
-    0x90004,
-    0x110006,
-    0xa0006,
-    0x100006,
-    0x20006,
-    0x190007,
-    0x190007,
-    0xb0007,
-    0xb0007,
-    0x120007,
-    0x120007,
-    0x180007,
-    0x180007,
-    0x30007,
-    0x30007,
-    0x130008,
-    0x1a0008,
-    0xc0008,
-    0x210008,
-    0xd0008,
-    0x290008,
-    0x1b0008,
-    0x140008,
-    0x40008,
-    0x200008,
-    0x220009,
-    0x220009,
-    0x150009,
-    0x150009,
-    0x2a0009,
-    0x2a0009,
-    0x50009,
-    0x50009,
-    0x310009,
-    0x310009,
-    0x280009,
-    0x280009,
-    0xe0009,
-    0xe0009,
-    0x230009,
-    0x230009,
-    0x1d0009,
-    0x1d0009,
-    0x1c0009,
-    0x1c0009,
-    0x2b0009,
-    0x2b0009,
-    0x160009,
-    0x160009,
-    0x320009,
-    0x320009,
-    0xf0009,
-    0xf0009,
-    0x1e000a,
-    0x6000a,
-    0x30000a,
-    0x24000a,
-    0x39000a,
-    0x25000a,
-    0x3a000a,
-    0x2c000a,
-    0x33000a,
-    0x17000a,
-    0x3b000a,
-    0x34000a,
-    0x2d000a,
-    0x26000a,
-    0x1f000a,
-    0x38000b,
-    0x38000b,
-    0x7000b,
-    0x7000b,
-    0x35000b,
-    0x35000b,
-    0x2e000b,
-    0x2e000b,
-    0x3c000b,
-    0x3c000b,
-    0x27000b,
-    0x27000b,
-    0x2f000b,
-    0x2f000b,
-    0x3d000b,
-    0x3d000b,
-    0x3e000c,
-    0x36000c,
-    0x37000c,
-    0x3f000c
-};
-const Int32 huff_tab8[90] =
-{
-    0x90003,
-    0x90003,
-    0x90003,
-    0x90003,
-    0x110004,
-    0x110004,
-    0x80004,
-    0x80004,
-    0xa0004,
-    0xa0004,
-    0x10004,
-    0x10004,
-    0x120004,
-    0x120004,
-    0x5,
-    0x100005,
-    0x20005,
-    0x190005,
-    0xb0005,
-    0x1a0005,
-    0x130005,
-    0x1b0006,
-    0x1b0006,
-    0x210006,
-    0x210006,
-    0xc0006,
-    0xc0006,
-    0x220006,
-    0x220006,
-    0x140006,
-    0x140006,
-    0x180006,
-    0x180006,
-    0x30006,
-    0x30006,
-    0x230006,
-    0x230006,
-    0x1c0006,
-    0x1c0006,
-    0x2a0006,
-    0x2a0006,
-    0x290007,
-    0x150007,
-    0xd0007,
-    0x2b0007,
-    0x1d0007,
-    0x240007,
-    0x2c0007,
-    0x40007,
-    0x250007,
-    0x200007,
-    0x160007,
-    0x320007,
-    0x310007,
-    0xe0007,
-    0x1e0008,
-    0x330008,
-    0x2d0008,
-    0x280008,
-    0x340008,
-    0x50008,
-    0x260008,
-    0x390008,
-    0x3a0008,
-    0x170008,
-    0x350008,
-    0x3b0008,
-    0xf0008,
-    0x2e0008,
-    0x1f0008,
-    0x360009,
-    0x360009,
-    0x3c0009,
-    0x3c0009,
-    0x300009,
-    0x300009,
-    0x270009,
-    0x270009,
-    0x60009,
-    0x60009,
-    0x3d0009,
-    0x3d0009,
-    0x3e0009,
-    0x3e0009,
-    0x370009,
-    0x370009,
-    0x2f000a,
-    0x38000a,
-    0x7000a,
-    0x3f000a
-};
-const Int32 huff_tab9[204] =
-{
-    0x1,
-    0x1,
-    0x1,
-    0x1,
-    0x1,
-    0x1,
-    0x1,
-    0x1,
-    0xd0003,
-    0xd0003,
-    0x10003,
-    0x10003,
-    0xe0004,
-    0x1b0006,
-    0x1b0006,
-    0xf0006,
-    0xf0006,
-    0x1a0006,
-    0x1a0006,
-    0x20006,
-    0x20006,
-    0x280007,
-    0x1c0007,
-    0x100007,
-    0x270008,
-    0x270008,
-    0x30008,
-    0x30008,
-    0x1d0008,
-    0x1d0008,
-    0x290008,
-    0x290008,
-    0x110008,
-    0x110008,
-    0x350008,
-    0x350008,
-    0x1e0008,
-    0x1e0008,
-    0x120008,
-    0x120008,
-    0x360009,
-    0x2a0009,
-    0x40009,
-    0x340009,
-    0x420009,
-    0x1f0009,
-    0x130009,
-    0x2b0009,
-    0x430009,
-    0x4f0009,
-    0x370009,
-    0x5000a,
-    0x20000a,
-    0x41000a,
-    0x14000a,
-    0x2c000a,
-    0x15000a,
-    0x69000a,
-    0x38000a,
-    0x44000a,
-    0x50000a,
-    0x5c000a,
-    0x6000a,
-    0x6a000a,
-    0x22000a,
-    0x2d000a,
-    0x21000a,
-    0x39000a,
-    0x76000a,
-    0x16000a,
-    0x5d000a,
-    0x4e000b,
-    0x45000b,
-    0x51000b,
-    0x6b000b,
-    0x7000b,
-    0x77000b,
-    0x2f000b,
-    0x3a000b,
-    0x2e000b,
-    0x8000b,
-    0x83000b,
-    0x52000b,
-    0x23000b,
-    0x46000b,
-    0x68000b,
-    0x5b000b,
-    0x5e000b,
-    0x84000b,
-    0x78000b,
-    0x6c000b,
-    0x17000b,
-    0x5f000b,
-    0x53000b,
-    0x47000b,
-    0x3c000b,
-    0x3b000b,
-    0x30000b,
-    0x90000b,
-    0x49000b,
-    0x75000b,
-    0x6d000b,
-    0x85000c,
-    0x24000c,
-    0x9000c,
-    0x91000c,
-    0x79000c,
-    0x54000c,
-    0x9d000c,
-    0x3d000c,
-    0x6e000c,
-    0x18000c,
-    0x7a000c,
-    0x86000c,
-    0x48000c,
-    0x60000c,
-    0x25000c,
-    0x19000c,
-    0x9e000c,
-    0x92000c,
-    0x31000c,
-    0x4a000c,
-    0x55000c,
-    0x6f000c,
-    0x93000c,
-    0xa000c,
-    0x61000c,
-    0x9f000c,
-    0x82000c,
-    0x87000c,
-    0x3e000c,
-    0x56000c,
-    0x26000c,
-    0x7b000c,
-    0x7c000c,
-    0x3f000c,
-    0x8f000c,
-    0x57000c,
-    0x32000c,
-    0x4b000c,
-    0x70000d,
-    0x63000d,
-    0xa1000d,
-    0x33000d,
-    0x94000d,
-    0x62000d,
-    0xa0000d,
-    0x95000d,
-    0x88000d,
-    0x40000d,
-    0x64000d,
-    0x4c000d,
-    0xb000d,
-    0xa2000d,
-    0x58000d,
-    0x9c000d,
-    0x89000d,
-    0x4d000d,
-    0x65000d,
-    0x7d000d,
-    0xc000d,
-    0x96000d,
-    0x71000d,
-    0x7e000d,
-    0x8a000d,
-    0x66000d,
-    0xa3000d,
-    0x59000d,
-    0x73000d,
-    0x97000d,
-    0x67000d,
-    0x5a000d,
-    0x72000e,
-    0x72000e,
-    0x8b000e,
-    0x8b000e,
-    0x74000e,
-    0x74000e,
-    0x7f000e,
-    0x7f000e,
-    0x80000e,
-    0x80000e,
-    0x81000e,
-    0x81000e,
-    0x8d000e,
-    0x8d000e,
-    0xa5000e,
-    0xa5000e,
-    0x8c000e,
-    0x8c000e,
-    0x98000e,
-    0x98000e,
-    0xa4000e,
-    0xa4000e,
-    0x99000e,
-    0x99000e,
-    0xa6000e,
-    0xa6000e,
-    0xa7000e,
-    0xa7000e,
-    0x8e000f,
-    0x9a000f,
-    0x9b000f,
-    0xa8000f
-};
-const Int32 huff_tab10[186] =
-{
-    0xe0004,
-    0xe0004,
-    0xe0004,
-    0xe0004,
-    0xf0004,
-    0xf0004,
-    0xf0004,
-    0xf0004,
-    0x1b0004,
-    0x1b0004,
-    0x1b0004,
-    0x1b0004,
-    0x1c0005,
-    0x1c0005,
-    0xd0005,
-    0xd0005,
-    0x10005,
-    0x10005,
-    0x100005,
-    0x100005,
-    0x290005,
-    0x290005,
-    0x280005,
-    0x280005,
-    0x1d0005,
-    0x1d0005,
-    0x2a0005,
-    0x2a0005,
-    0x1a0006,
-    0x20006,
-    0x1e0006,
-    0x360006,
-    0x110006,
-    0x350006,
-    0x6,
-    0x370006,
-    0x2b0006,
-    0x270006,
-    0x30006,
-    0x380006,
-    0x1f0006,
-    0x430006,
-    0x120007,
-    0x420007,
-    0x440007,
-    0x2c0007,
-    0x450007,
-    0x390007,
-    0x500007,
-    0x200007,
-    0x510007,
-    0x340007,
-    0x4f0007,
-    0x40007,
-    0x130007,
-    0x2d0007,
-    0x460007,
-    0x520007,
-    0x3a0007,
-    0x530008,
-    0x5d0008,
-    0x2e0008,
-    0x210008,
-    0x470008,
-    0x6a0008,
-    0x5e0008,
-    0x410008,
-    0x5c0008,
-    0x50008,
-    0x690008,
-    0x140008,
-    0x6b0008,
-    0x5f0008,
-    0x3b0008,
-    0x220008,
-    0x540008,
-    0x600008,
-    0x150008,
-    0x2f0008,
-    0x6c0008,
-    0x3c0008,
-    0x480008,
-    0x6d0008,
-    0x490008,
-    0x610009,
-    0x550009,
-    0x770009,
-    0x4e0009,
-    0x560009,
-    0x780009,
-    0x300009,
-    0x760009,
-    0x230009,
-    0x60009,
-    0x6e0009,
-    0x790009,
-    0x3d0009,
-    0x840009,
-    0x160009,
-    0x620009,
-    0x6f0009,
-    0x7a0009,
-    0x630009,
-    0x850009,
-    0x4a0009,
-    0x860009,
-    0x240009,
-    0x830009,
-    0x310009,
-    0x7b0009,
-    0x570009,
-    0x680009,
-    0x3e0009,
-    0x5b0009,
-    0x910009,
-    0x64000a,
-    0x92000a,
-    0x88000a,
-    0x17000a,
-    0x90000a,
-    0x7c000a,
-    0x7000a,
-    0x70000a,
-    0x87000a,
-    0x32000a,
-    0x4b000a,
-    0x71000a,
-    0x94000a,
-    0x8000a,
-    0x93000a,
-    0x25000a,
-    0x65000a,
-    0x58000a,
-    0x89000a,
-    0x3f000a,
-    0x18000a,
-    0x9e000a,
-    0x7d000a,
-    0x9f000a,
-    0x95000a,
-    0x4c000a,
-    0xa0000a,
-    0x96000a,
-    0xa1000a,
-    0x33000a,
-    0x59000a,
-    0x75000a,
-    0x8a000a,
-    0x82000a,
-    0x9d000a,
-    0x9000a,
-    0x40000a,
-    0x7e000a,
-    0xa2000a,
-    0x26000a,
-    0x72000a,
-    0x7f000b,
-    0x19000b,
-    0x97000b,
-    0xa3000b,
-    0x66000b,
-    0x4d000b,
-    0x5a000b,
-    0x8b000b,
-    0x73000b,
-    0xa4000b,
-    0xa000b,
-    0x67000b,
-    0x8f000b,
-    0x8c000b,
-    0x98000b,
-    0x99000b,
-    0xb000b,
-    0x9a000b,
-    0x80000b,
-    0x8d000b,
-    0x9c000b,
-    0x74000b,
-    0xa5000c,
-    0x8e000c,
-    0x81000c,
-    0x9b000c,
-    0xa7000c,
-    0xc000c,
-    0xa6000c,
-    0xa8000c
-};
-const Int32 huff_tab11[301] =
-{
-    0x4,
-    0x4,
-    0x4,
-    0x4,
-    0x120004,
-    0x120004,
-    0x120004,
-    0x120004,
-    0x1200005,
-    0x1200005,
-    0x110005,
-    0x110005,
-    0x10005,
-    0x10005,
-    0x230005,
-    0x230005,
-    0x130005,
-    0x130005,
-    0x240005,
-    0x240005,
-    0x140006,
-    0x340006,
-    0x350006,
-    0x220006,
-    0x250006,
-    0x20006,
-    0x360006,
-    0x450007,
-    0x150007,
-    0x460007,
-    0x260007,
-    0x470007,
-    0x370007,
-    0x330007,
-    0x30007,
-    0x560007,
-    0x570007,
-    0x270007,
-    0x480007,
-    0x160007,
-    0x580007,
-    0x380007,
-    0x590007,
-    0x490008,
-    0x680008,
-    0x280008,
-    0x670008,
-    0x690008,
-    0x390008,
-    0x170008,
-    0x540008,
-    0x430008,
-    0x1150008,
-    0x1130008,
-    0x1140008,
-    0x6a0008,
-    0x1160008,
-    0x440008,
-    0x4a0008,
-    0x40008,
-    0x320008,
-    0x5a0008,
-    0x650008,
-    0x1170008,
-    0x1120008,
-    0x1180008,
-    0x290008,
-    0x790008,
-    0x3a0008,
-    0x6b0008,
-    0x5b0008,
-    0x760008,
-    0x11a0008,
-    0x7a0008,
-    0x780008,
-    0x1190008,
-    0x870008,
-    0x210008,
-    0x180008,
-    0x4b0008,
-    0x11b0008,
-    0x7b0008,
-    0x11c0008,
-    0x980008,
-    0x1110008,
-    0x6c0008,
-    0xa90008,
-    0x2a0008,
-    0x5c0008,
-    0xba0008,
-    0x11d0008,
-    0x8b0008,
-    0x8a0008,
-    0x3b0008,
-    0x550008,
-    0x11e0008,
-    0xcb0008,
-    0x7c0008,
-    0x4c0008,
-    0x6d0008,
-    0x7d0008,
-    0x50008,
-    0x8c0009,
-    0x11f0009,
-    0xdc0009,
-    0x190009,
-    0x890009,
-    0xfe0009,
-    0x5d0009,
-    0xed0009,
-    0x3c0009,
-    0x8d0009,
-    0x7e0009,
-    0x2b0009,
-    0x8e0009,
-    0x9b0009,
-    0x9c0009,
-    0x10f0009,
-    0x4d0009,
-    0x6e0009,
-    0x660009,
-    0x9d0009,
-    0x5e0009,
-    0x8f0009,
-    0x7f0009,
-    0x1a0009,
-    0xad0009,
-    0x60009,
-    0xac0009,
-    0x9a0009,
-    0x9e0009,
-    0x4e0009,
-    0x2c0009,
-    0x9f0009,
-    0x3d0009,
-    0x6f0009,
-    0xae0009,
-    0x900009,
-    0xaf0009,
-    0xa00009,
-    0xbe0009,
-    0x1b0009,
-    0x770009,
-    0xb00009,
-    0x800009,
-    0x3e0009,
-    0x5f0009,
-    0xab0009,
-    0x4f0009,
-    0xbd0009,
-    0xdf0009,
-    0x700009,
-    0xe00009,
-    0x2d0009,
-    0x1100009,
-    0x600009,
-    0xc00009,
-    0xbf000a,
-    0xa1000a,
-    0x81000a,
-    0x91000a,
-    0x10000a,
-    0x51000a,
-    0x7000a,
-    0x40000a,
-    0xc1000a,
-    0xde000a,
-    0xe1000a,
-    0xcf000a,
-    0x2f000a,
-    0xe2000a,
-    0x92000a,
-    0x71000a,
-    0xb2000a,
-    0xb1000a,
-    0xf0000a,
-    0xd0000a,
-    0x1c000a,
-    0x50000a,
-    0xbc000a,
-    0x3f000a,
-    0x1e000a,
-    0xce000a,
-    0x82000a,
-    0x41000a,
-    0x61000a,
-    0x62000a,
-    0xf2000a,
-    0x52000a,
-    0xc2000a,
-    0xf1000a,
-    0xd1000a,
-    0xe3000a,
-    0xd2000a,
-    0x88000a,
-    0xc3000a,
-    0x2e000a,
-    0xa2000a,
-    0xf3000a,
-    0x73000a,
-    0xb4000a,
-    0x101000a,
-    0x93000a,
-    0xa3000a,
-    0xf4000a,
-    0xb3000a,
-    0x63000a,
-    0xc4000a,
-    0xef000a,
-    0x30000a,
-    0x72000a,
-    0x1d000a,
-    0xe5000a,
-    0x8000a,
-    0xe4000a,
-    0x83000a,
-    0xd3000a,
-    0x84000a,
-    0x102000a,
-    0xcd000a,
-    0x74000a,
-    0x31000a,
-    0x104000a,
-    0x103000a,
-    0x1f000a,
-    0xa4000a,
-    0x53000a,
-    0xf5000a,
-    0x95000a,
-    0xe6000a,
-    0x94000a,
-    0x64000a,
-    0x42000a,
-    0xb5000a,
-    0xc5000a,
-    0xd4000a,
-    0x105000a,
-    0x106000a,
-    0x96000a,
-    0x100000a,
-    0x85000a,
-    0x99000a,
-    0x9000a,
-    0xa6000a,
-    0xa5000a,
-    0xd5000a,
-    0xf6000a,
-    0xb7000a,
-    0xf7000a,
-    0xd6000a,
-    0x75000a,
-    0x86000a,
-    0xa7000b,
-    0x107000b,
-    0xc6000b,
-    0xc9000b,
-    0x20000b,
-    0xb6000b,
-    0xb8000b,
-    0xe8000b,
-    0xe7000b,
-    0xc8000b,
-    0xc7000b,
-    0x97000b,
-    0xf9000b,
-    0xe9000b,
-    0xd9000b,
-    0x108000b,
-    0xf8000b,
-    0xaa000b,
-    0xd7000b,
-    0xa8000b,
-    0xa000b,
-    0xd8000b,
-    0xbb000b,
-    0xda000b,
-    0xb9000b,
-    0xea000b,
-    0xd000b,
-    0xfa000b,
-    0x109000b,
-    0x10a000b,
-    0xca000b,
-    0xfb000b,
-    0xdd000b,
-    0xb000b,
-    0xeb000b,
-    0x10b000b,
-    0x10c000b,
-    0xdb000b,
-    0xee000b,
-    0xfc000b,
-    0xec000b,
-    0xcc000b,
-    0xfd000b,
-    0xe000c,
-    0xc000c,
-    0x10d000c,
-    0xff000c,
-    0xf000c,
-    0x10e000c
-};
-
-const UInt32 huff_tab_scl[188] =
-{
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3b0003,
-    0x3d0004,
-    0x3d0004,
-    0x3d0004,
-    0x3d0004,
-    0x3a0004,
-    0x3a0004,
-    0x3a0004,
-    0x3a0004,
-    0x3e0004,
-    0x3e0004,
-    0x3e0004,
-    0x3e0004,
-    0x390005,
-    0x390005,
-    0x3f0005,
-    0x3f0005,
-    0x380006,
-    0x400006,
-    0x370006,
-    0x410006,
-    0x420007,
-    0x420007,
-    0x420007,
-    0x420007,
-    0x360007,
-    0x360007,
-    0x360007,
-    0x360007,
-    0x430007,
-    0x430007,
-    0x430007,
-    0x430007,
-    0x350008,
-    0x350008,
-    0x440008,
-    0x440008,
-    0x340008,
-    0x340008,
-    0x450008,
-    0x450008,
-    0x330008,
-    0x330008,
-    0x460009,
-    0x320009,
-    0x310009,
-    0x470009,
-    0x48000a,
-    0x48000a,
-    0x48000a,
-    0x48000a,
-    0x30000a,
-    0x30000a,
-    0x30000a,
-    0x30000a,
-    0x49000a,
-    0x49000a,
-    0x49000a,
-    0x49000a,
-    0x2f000a,
-    0x2f000a,
-    0x2f000a,
-    0x2f000a,
-    0x4a000a,
-    0x4a000a,
-    0x4a000a,
-    0x4a000a,
-    0x2e000a,
-    0x2e000a,
-    0x2e000a,
-    0x2e000a,
-    0x4c000b,
-    0x4c000b,
-    0x4b000b,
-    0x4b000b,
-    0x4d000b,
-    0x4d000b,
-    0x4e000b,
-    0x4e000b,
-    0x2d000b,
-    0x2d000b,
-    0x2b000b,
-    0x2b000b,
-    0x2c000c,
-    0x4f000c,
-    0x2a000c,
-    0x29000c,
-    0x50000c,
-    0x28000c,
-    0x51000d,
-    0x51000d,
-    0x27000d,
-    0x27000d,
-    0x52000d,
-    0x52000d,
-    0x26000d,
-    0x26000d,
-    0x53000d,
-    0x53000d,
-    0x25000e,
-    0x23000e,
-    0x55000e,
-    0x21000e,
-    0x24000e,
-    0x22000e,
-    0x54000e,
-    0x20000e,
-    0x57000f,
-    0x57000f,
-    0x59000f,
-    0x59000f,
-    0x1e000f,
-    0x1e000f,
-    0x1f000f,
-    0x1f000f,
-    0x560010,
-    0x1d0010,
-    0x1a0010,
-    0x1b0010,
-    0x1c0010,
-    0x180010,
-    0x580010,
-    0x190011,
-    0x190011,
-    0x160011,
-    0x160011,
-    0x170011,
-    0x170011,
-    0x5a0012,
-    0x150012,
-    0x130012,
-    0x30012,
-    0x10012,
-    0x20012,
-    0x12,
-    0x620013,
-    0x630013,
-    0x640013,
-    0x650013,
-    0x660013,
-    0x750013,
-    0x610013,
-    0x5b0013,
-    0x5c0013,
-    0x5d0013,
-    0x5e0013,
-    0x5f0013,
-    0x600013,
-    0x680013,
-    0x6f0013,
-    0x700013,
-    0x710013,
-    0x720013,
-    0x730013,
-    0x740013,
-    0x6e0013,
-    0x690013,
-    0x6a0013,
-    0x6b0013,
-    0x6c0013,
-    0x6d0013,
-    0x760013,
-    0x60013,
-    0x80013,
-    0x90013,
-    0xa0013,
-    0x50013,
-    0x670013,
-    0x780013,
-    0x770013,
-    0x40013,
-    0x70013,
-    0xf0013,
-    0x100013,
-    0x120013,
-    0x140013,
-    0x110013,
-    0xb0013,
-    0xc0013,
-    0xe0013,
-    0xd0013
-};
diff --git a/media/libstagefright/codecs/aacdec/huffcb.cpp b/media/libstagefright/codecs/aacdec/huffcb.cpp
deleted file mode 100644
index 30f38fa..0000000
--- a/media/libstagefright/codecs/aacdec/huffcb.cpp
+++ /dev/null
@@ -1,381 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/huffcb.c
- Funtions:
-    huffcb
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Change variable names for clarity,
-               change variables 'base', 'sect_len_inc', and 'esc_val' to
-               UChar type.
-
- Description:  Add "if ((pSect[-1] % sfb_per_win) > max_sfb)" statement to
-               detect the error condition.
-               add more white space.
-
- Description: eliminated "pSect[-1]%sfb_per_win" operation
-
- Description: eliminated "pSect[-1]%sfb_per_win" operation
-
- Description: (1) Pass in SectInfo pSect
-              (2) put BITS *pInputStream as second parameter
-
- Description:  Fix a failure for thrid party AAC encoding.
-               The problem came when the total and the
-               maximun number of active scale factor bands do not coincide.
-               This is a rare situation but produces a problem when decoding
-               encoders that tolerate this.
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    UChar   *pSect  = pointer to array that contains the interleaved
-                      information of huffman codebook index and section
-                      length. Array contains:
-                      [codebook index]
-                      [section boundary]
-                      [codebook index]
-                      [section boundary]
-                      ...
-
-    Int     sectbits  =   array that defines the number of bits
-                          used for expressing the escape value of
-                          section length
-
-    Int     tot_sfb     = total number of sfb in one Frame
-
-    Int     sfb_per_win = number of sfb in each sub-block (window)
-
-    UChar   max_sfb     = 1 + number of active sfbs - see reference (2) p56
-
-    BITS    *pInputStream = pointer to input stream
-
-
- Local Stores/Buffers/Pointers Needed:
-
-    UChar    base     = number of sfb in already detected sections
-
-    UChar    sect_len_inc = section length increment in number of sfbs'
-
-    UChar    esc_val  = escape value for section length
-
-    Int     bits     = number of bits needed for expressing section length
-
-
- Global Stores/Buffers/Pointers Needed:
-
-
- Outputs:
-
-    num_sect = total number of sections in one frame
-
-
- Pointers and Buffers Modified:
-
-    UChar    *pSect = pointer to array where huffman codebook index and
-                     section length are stored
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Background knowledge: 1024(960) coef's are separated into several sections,
- each section is encoded with one single Huffman codebook, and each section
- has a length of multiples of sfb.
-
- max_sfb <= sfb_per_win <= tot_sfb
- tot_sfb = total number of scalefactor bands in one frame (1024 coefs)
-
- This function reads the codebook index and section boundaries (expressed
- in number of sfb) from the input bitstream, store these information in
- *pSect, and return the number of sections been detected. Returns 0 if there
- is an error.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should fill the array *pSect with section Huffman codebook
- indexes and section boundaries
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3 1999(E)
-   Subpart 4    p55     (Recovering section_data())
-                p24-25  (Syntax of section_data())
-
- (3) M. Bosi, K. Brandenburg, etc., "ISO/IEC MPEG-2 Advanced Audio Coding,"
-     J. Audio Eng. Soc., Vol.45, No.10, 1997 October
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- bits_needed_for_ESC  = sectbits[0];
- ESC_value            = (1<<bits_needed_for_ESC) - 1;
- num_of_section       = 0;
-
-
- FOR (base = 0; base<total_sfb AND num_of_section<total_sfb)
- {
-    *pSect++     = getbits(LEN_CB, pInputStream);   (read huffman_codebook_num)
-    sect_length_incr  = getbits(bits_needed_for_ESC, pInputStream);
-
-    WHILE (sect_length_incr == ESC_value AND base < total_sfb)
-    {
-        base              += ESC_value;
-        sect_length_incr  =  getbits(bits_needed_for_ESC, ebits);
-    }
-    ENDWHILE
-
-    base      += sect_length_incr;
-    *pSect++   =  base;
-    num_of_section++;
-
-   IF (num_of_sfb_for_this_group==max_sfb)
-   {
-        *pSect++    = 0; (use huffman codebook 0)
-        base       += sfb_per_win - max_sfb;
-        *pSect++    = base;
-        num_of_section++;
-   }
-   ENDIF
-
-   IF (num_of_sfb_for_this_group > max_sfb)
-        break;
-   ENDIF
-
- }
- ENDFOR
-
- IF (base != total_sfb OR num_of_section>total_sfb)
-      return 0;
- ENDIF
-
- return num_sect;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int huffcb(
-    SectInfo    *pSect,
-    BITS        *pInputStream,
-    Int         sectbits[],
-    Int         tot_sfb,
-    Int         sfb_per_win,
-    Int         max_sfb)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-
-    Int   base;        /* section boundary */
-    Int   sect_len_incr;
-    Int   esc_val;     /* ESC of section length = 31(long), =7 (short) */
-    Int     bits;        /* # of bits used to express esc_val */
-    Int     num_sect;
-    Int     active_sfb;
-    Int   group_base;
-
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-
-    bits       =  sectbits[0];     /* 3 for SHORT_WIN, 5 for LONG_WIN */
-    esc_val    = (1 << bits) - 1;   /* ESC_value for section length */
-    num_sect   =  0;
-    base       =  0;
-    group_base =  0;
-
-    /* read until the end of one frame */
-    while ((base < tot_sfb) && (num_sect < tot_sfb))
-    {
-
-        pSect->sect_cb  = get9_n_lessbits(
-                              LEN_CB,
-                              pInputStream); /* section codebook */
-
-        sect_len_incr   = get9_n_lessbits(
-                              bits,
-                              pInputStream); /* length_incr */
-
-
-        /* read until non-ESC value, see p55 reference 2 */
-        while ((sect_len_incr == esc_val) && (base < tot_sfb))
-        {
-            base            +=  esc_val;
-
-            sect_len_incr   = get9_n_lessbits(
-                                  bits,
-                                  pInputStream);
-        }
-
-        base      += sect_len_incr;
-        pSect->sect_end  =  base; /* total # of sfb until current section */
-        pSect++;
-        num_sect++;
-
-        /* active_sfb = base % sfb_per_win; */
-        active_sfb = base - group_base;
-
-        /*
-         *  insert a zero section for regions above max_sfb for each group
-         *  Make sure that active_sfb is also lesser than tot_sfb
-         */
-
-        if ((active_sfb == max_sfb) && (active_sfb < tot_sfb))
-        {
-            base      += (sfb_per_win - max_sfb);
-            pSect->sect_cb   =   0; /* huffman codebook 0 */
-            pSect->sect_end  =   base;
-            num_sect++;
-            pSect++;
-            group_base = base;
-        }
-        else if (active_sfb > max_sfb)
-        {
-            /* within each group, the sections must delineate the sfb
-             * from zero to max_sfb so that the 1st section within each
-             * group starts at sfb0 and the last section ends at max_sfb
-             * see p55 reference 2
-             */
-            break;
-        }
-
-    } /* while (base=0) */
-
-
-    if (base != tot_sfb || num_sect > tot_sfb)
-    {
-        num_sect = 0;   /* error */
-    }
-
-    return num_sect;
-
-} /* huffcb */
-
-
diff --git a/media/libstagefright/codecs/aacdec/huffdecode.cpp b/media/libstagefright/codecs/aacdec/huffdecode.cpp
deleted file mode 100644
index 890a6fb..0000000
--- a/media/libstagefright/codecs/aacdec/huffdecode.cpp
+++ /dev/null
@@ -1,528 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: huffdecode.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Change variable types.
-
- Description:  (1) Modified to bring in-line with PV standards.
-               (2) Eliminated global_gain on stack,
-                   getics() has to define this parameter on its stack.
-               (3) Eliminated multiple returns
-               (4) Altered return logic of getics()
-               (5) Convert Real coef -> Int32 coef
-               (6) Move BITS *pInputStream to 2nd parameter of huffdecode.c
-                   and getics.c
-               (7) Pass pFrameInfo per channel, because two channels can have
-                   different windows
-
- Description: (1) Eliminated function call to chn_config
-              (2) Eliminate widx calculation
-              (3) copy channel info from left to right when common_window
-                  is enabled
-              (4) add error checking of getmask return value
-
- Description:  Change default_position to current_program
-
- Description:  Remove prstflag
-
- Description:  Modify call to get_ics_info
-
- Description:  Modified so getmask is NOT called if the status returned
- from get_ics_info indicates an error.
-
- Description:
- (1) Added include of "e_ElementId.h"
-     Previously, this function was relying on another include file
-     to include e_ElementId.h
-
- (2) Updated the copyright header.
-
- Description:  Modified to include usage of the new "shared memory" structures
- defined in s_tDec_Int_File.h and s_tDec_Int_Chan.h
-
- Description:
- (1) Updated to reflect the fact that the temporary FrameInfo used by getics.c
- was moved into the region of memory shared with fxpCoef.
-
- Description:
- (1) Removed first parameter to getics.  The temporary FrameInfo was
-     unnecessary.
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Description: Relaxed tag verification. Some encoder do not match the tag
-              to the channel ID (as the standard request to differentiate
-              different channel), in our wireless work, with only mono
-              or stereo channel, this become restrictive to some encoders
-
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    id_syn_ele  = identification flag for channel syntactic element, Int
-
-    pInputStream= pointer to input bitstream, BITS.
-
-    pVars       = pointer to structure that holds information for decoding,
-                  tDec_Int_File
-
-    pChVars[]   = pointer to structure that holds channel information,
-                  tDec_Int_Chan
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    status = 0  if success
-             non-zero  otherwise
-
- Pointers and Buffers Modified:
-    pChVars->sect   contents updated by newly decoded section information
-                    of current frame
-
-    pChVars->factors contents updated by newly decoded scalefactors
-
-    pChVars->ch_coef contents updated by newly decoded spectral coefficients
-
-    PChVars->tns    contents updated by newly decoded TNS information
-
-    pVars->hasmask  contents updated by newly decoded Mid/Side mask
-                    information
-
-    pVars->pulseInfo contents updated by newly decoded pulse data information
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  This function offers a framework for decoding the data of the next 1024
-  samples. It maps the channel configuration according to the id_syn_ele flag,
-  configures the channel information, and calls getics to do huffman decoding
-  The function returns 1 if there was an error
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should set up the channel configuration for huffman decoding
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4       p15     (single_channel_element, channel_pair_element)
-                    p15     (Table 4.4.5    getmask)
-                    p16     (Table 4.4.6    get_ics_info)
-                    p24     (Table 4.4.24   getics)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    tag = CALL getbits(LEN_TAG,pInputStream)
-                MODIFYING(pInputStream)
-                RETURNING(tag)
-
-    common_window = 0;
-
-    IF (id_syn_ele == ID_CPE)
-    THEN
-        common_window = CALL getbits(LEN_COM_WIN,pInputStream);
-                                MODIFYING(pInputStream)
-                                RETURNING(common_window)
-    ENDIF
-
-    pMcInfo = &pVars->mc_info;
-
-    IF ( (pMcInfo->ch_info[0].cpe != id_syn_ele) OR
-         (pMcInfo->ch_info[0].tag != tag) )
-    THEN
-        status = 1;
-    ENDIF
-
-
-    IF (status == SUCCESS)
-    THEN
-        IF (id_syn_ele == ID_SCE)
-        THEN
-
-            leftCh  = 0;
-            RIGHT = 0;
-            pChVars[leftCh]->hasmask = 0;
-        ELSEIF (id_syn_ele == ID_CPE)
-
-            leftCh = 0;
-            rightCh  = 1;
-
-            IF (common_window != FALSE)
-            THEN
-
-                CALL get_ics_info(
-                        audioObjectType = pVars->mc_info.audioObjectType,
-                        pInputStream = pInputStream,
-                        common_window = common_window,
-                        pWindowSequence = &pChVars[leftCh]->wnd,
-                        &pChVars[leftCh]->wnd_shape_this_bk,
-                        pChVars[leftCh]->group,
-                        &pChVars[leftCh]->max_sfb,
-                        pVars->winmap,
-                        &pChVars[leftCh]->lt_status,
-                        &pChVars[rightCh]->lt_status);
-                     MODIFYING(pInputStream, wnd, wnd_shape_this_bk,group,
-                               max_sfb, lt_status)
-                     RETURNING(status)
-
-                IF (status == SUCCESS)
-                THEN
-
-                    pChVars[rightCh]->wnd = pChVars[leftCh]->wnd;
-                    pChVars[rightCh]->wnd_shape_this_bk =
-                        pChVars[leftCh]->wnd_shape_this_bk;
-                    pChVars[rightCh]->max_sfb = pChVars[leftCh]->max_sfb;
-                    pv_memcpy(
-                        pChVars[rightCh]->group,
-                        pChVars[leftCh]->group,
-                        NSHORT*sizeof(pChVars[leftCh]->group[0]));
-
-                    hasmask = CALL getmask(
-                                    pVars->winmap[pChVars[leftCh]->wnd],
-                                    pInputStream,
-                                    pChVars[leftCh]->group,
-                                    pChVars[leftCh]->max_sfb,
-                                    pChVars[leftCh]->mask);
-                                MODIFYING(pInputStream, mask)
-                                RETURNING(hasmask)
-
-                    IF (hasmask == MASK_ERROR)
-                    THEN
-                        status = 1;
-                    ENDIF
-                    pChVars[leftCh]->hasmask  = hasmask;
-                    pChVars[rightCh]->hasmask = hasmask;
-
-                ENDIF
-
-            ELSE
-
-                 pChVars[leftCh]->hasmask  = 0;
-                 pChVars[rightCh]->hasmask = 0;
-            ENDIF(common_window)
-
-        ENDIF(id_syn_ele)
-
-    ENDIF (status)
-
-    ch = leftCh;
-
-    WHILE((ch <= rightCh) AND (status == SUCCESS))
-
-        status = CALL getics(
-                        pInputStream,
-                        common_window,
-                        pVars,
-                        pChVars[ch],
-                        pChVars[ch]->group,
-                        &pChVars[ch]->max_sfb,
-                        pChVars[ch]->cb_map,
-                        &pChVars[ch]->tns,
-                        pVars->winmap,
-                        &pVars->pulseInfo,
-                        pChVars[ch]->sect);
-                    MODIFYING(pInputStream,pVarsp,ChVars[ch],group,
-                              max_sfb,tns,pulseInfo,sect)
-                    RETURNING(status)
-
-        ch++;
-
-    ENDWHILE
-
-    RETURN status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "aac_mem_funcs.h"
-#include    "huffman.h"
-#include    "e_maskstatus.h"
-#include    "e_elementid.h"
-#include    "get_ics_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT  (0)
-#define RIGHT (1)
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int huffdecode(
-    Int           id_syn_ele,
-    BITS          *pInputStream,
-    tDec_Int_File *pVars,
-    tDec_Int_Chan *pChVars[])
-
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    Int      ch;
-    Int      common_window;
-    Int      hasmask;
-    Int      status   = SUCCESS;
-    Int      num_channels = 0;
-    MC_Info  *pMcInfo;
-
-    per_chan_share_w_fxpCoef *pChLeftShare;  /* Helper pointer */
-    per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-
-    get9_n_lessbits(
-        LEN_TAG,
-        pInputStream);
-
-    /* suppose an un-supported id_syn_ele will never be passed */
-
-    common_window = 0;
-
-    if (id_syn_ele == ID_CPE)
-    {
-        common_window =
-            get1bits(pInputStream);
-    }
-
-    pMcInfo = &pVars->mc_info;
-
-    /*
-     *  check if provided info (num of channels) on audio config,
-     *  matches read bitstream data, if not, allow update only once.
-     *  In almost all cases it should match.
-     */
-    if ((pMcInfo->ch_info[0].cpe != id_syn_ele))
-    {
-        if (pVars->mc_info.implicit_channeling)     /* check done only once */
-        {
-            pMcInfo->ch_info[0].cpe = id_syn_ele & 1; /*  collect info from bitstream
-                                                     *  implicit_channeling flag is locked
-                                                     *  after 1st frame, to avoid toggling
-                                                     *  parameter in the middle of the clip
-                                                     */
-            pMcInfo->nch = (id_syn_ele & 1) + 1;     /* update number of channels */
-        }
-        else
-        {
-            status = 1; /* ERROR break if syntax error persist  */
-        }
-    }
-
-    if (status == SUCCESS)
-    {
-        if (id_syn_ele == ID_SCE)
-        {
-
-            num_channels = 1;
-            pVars->hasmask = 0;
-        }
-        else if (id_syn_ele == ID_CPE)
-        {
-            pChLeftShare = pChVars[LEFT]->pShareWfxpCoef;
-            pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
-            num_channels = 2;
-
-            if (common_window != FALSE)
-            {
-
-                status = get_ics_info(
-                             (tMP4AudioObjectType) pVars->mc_info.audioObjectType,
-                             pInputStream,
-                             (Bool)common_window,
-                             (WINDOW_SEQUENCE *) & pChVars[LEFT]->wnd,
-                             (WINDOW_SHAPE *) & pChVars[LEFT]->wnd_shape_this_bk,
-                             pChLeftShare->group,
-                             (Int *) & pChLeftShare->max_sfb,
-                             pVars->winmap,
-                             (LT_PRED_STATUS *) & pChLeftShare->lt_status,
-                             (LT_PRED_STATUS *) & pChRightShare->lt_status);
-
-                if (status == SUCCESS)
-                {
-                    /* copy left channel info to right channel */
-                    pChVars[RIGHT]->wnd = pChVars[LEFT]->wnd;
-                    pChVars[RIGHT]->wnd_shape_this_bk =
-                        pChVars[LEFT]->wnd_shape_this_bk;
-                    pChRightShare->max_sfb = pChLeftShare->max_sfb;
-                    pv_memcpy(
-                        pChRightShare->group,
-                        pChLeftShare->group,
-                        NSHORT*sizeof(pChLeftShare->group[0]));
-
-                    hasmask = getmask(
-                                  pVars->winmap[pChVars[LEFT]->wnd],
-                                  pInputStream,
-                                  pChLeftShare->group,
-                                  pChLeftShare->max_sfb,
-                                  pVars->mask);
-
-                    if (hasmask == MASK_ERROR)
-                    {
-                        status = 1; /* ERROR code */
-                    }
-                    pVars->hasmask  = hasmask;
-
-                } /* if (status == 0) */
-            }
-            else
-            {
-                pVars->hasmask  = 0;
-            } /* if (common_window) */
-
-        } /* if (id_syn_ele) */
-
-    } /* if (status) */
-
-    ch = 0;
-    while ((ch < num_channels) && (status == SUCCESS))
-    {
-        pChLeftShare = pChVars[ch]->pShareWfxpCoef;
-
-        status = getics(
-                     pInputStream,
-                     common_window,
-                     pVars,
-                     pChVars[ch],
-                     pChLeftShare->group,
-                     &pChLeftShare->max_sfb,
-                     pChLeftShare->cb_map,
-                     &pChLeftShare->tns,
-                     pVars->winmap,
-                     &pVars->share.a.pulseInfo,
-                     pVars->share.a.sect);
-
-        ch++;
-
-    } /* while (ch) */
-
-    /*----------------------------------------------------------------------------
-    ; Return status
-    ----------------------------------------------------------------------------*/
-
-    return status;
-
-} /* huffdecode */
-
diff --git a/media/libstagefright/codecs/aacdec/hufffac.cpp b/media/libstagefright/codecs/aacdec/hufffac.cpp
deleted file mode 100644
index e5a9c59..0000000
--- a/media/libstagefright/codecs/aacdec/hufffac.cpp
+++ /dev/null
@@ -1,550 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/hufffac.c
- Funtions:
-    hufffac
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description: (1) Modified with new templates,
-              (2) Modified variable names for clarity
-              (3) adjusted variables of "for loop"
-              (4) eliminated multiple returns, use return valid
-
- Description: (1) Change return logic: 0 if success, 1 if error
-              (2) Define SectInfo structure to store section codebook index
-                  and section boundary
-              (3) Substitute "switch" with "if- else if"
-              (4) move BITS *pInputStream to second pass-in parameter
-              (5) pass in huffBookUsed[] to save stack size
-
- Description: (1) Remove pass in parameter Hcb pBook
-
- Description: Use binary tree search in decode_huff_cw_binary
-
- Description: Use decode_huff_scl function.
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    *pFrameInfo     = pointer to structure that holds information
-                      of each Frame. type FrameInfo
-
-    *pInputStream   = pointer to input bitstream. type BITS
-
-    *pGroup         = pointer to array that contains the index of the first
-                      window in each group, type UChar
-
-    nsect           = number of sections to be decoded. type Int
-
-    *pSect          = pointer to structure array that contains the huffman
-                      codebook index and section boundary for each section,
-                      type SectInfo
-
-    global_gain     = initial value for "DPCM encoded" scalefactors and noise
-                      energy, type Int
-
-    *pFactors       = pointer to array that stores the decoded scalefactors,
-                      intensity position or noise energy, type Int
-
-    huffBookUsed    = array that will hold the huffman codebook index for
-                      each sfb, type Int
-
-    *pBook          = pointer to structure that contains the huffman codebook
-                      information, such as dimension, Largest Absolute Value
-                      (LAV) of each huffman codebook, etc. type Hcb
-
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-         0 if success
-         1 if error
-
- Pointers and Buffers Modified:
-
-        Int   *pFactors    contains the newly decoded scalefactors and/or
-                             intensity position and/or noise energy level
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function first reads the Huffman codebook index of all sections within
- one Frame. Then, depending on the huffman codebook index of each section,
- the function decodes the scalefactors, and/or intensity positions
- (INTENSITY_HCB, INTENSITY_HCB2), and/or noise energy (NOISE_HCB)
- for every scalefactor band in each section.
- The function returns 0 upon successful decoding, returns 1 if error.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should replace the content of the array pFactors with the
- decoded scalefactors and/or intensity positions and/or noise energy
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-     Subpart 4      p72-73  (scalefactors)
-                    p76     (decoding)
-                    p78     (Table 4.6.1, Table 4.6.2)
-                    p93-94  (INTENSITY_HCB)
-                    p123    (NOISE_HCB)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
- status = SUCCESS;
-
- CALL pv_memset(pHuffBookUsed, ZERO_HCB, MAXBANDS*sizeof(*pHuffBookUsed));
-
- CALL pv_memset(pFactors, ZERO_HCB, MAXBANDS*sizeof(*pFactors));
-
- sect_start       = 0;
-
- FOR(sect_idx = nsect; sect_idx > 0; sect_idx--)
- {
-     sect_cb  = pSect->sect_cb;
-     sect_end = pSect->sect_end;
-     pSect++;
-
-     CALL pv_memset(
-        &pHuffBookUsed[sect_start],
-        sect_cb,
-        (sect_end - sect_start));
-
- }
- ENDFOR
-
-    fac       = global_gain;
-    is_pos    = 0;
-    noise_nrg = global_gain - NOISE_OFFSET;
-
-    pTable    = pBook[BOOKSCL].pTable;
-    group_win  = 0;
-    group_end  = 0;
-
-    WHILE((group_end < pFrameInfo->num_win)&&(status == SUCCESS))
-    {
-        nsfb_win  = pFrameInfo->sfb_per_win[group_end];
-        group_end = *pGroup++;
-
-        FOR(sfb = 0; sfb < nsfb_win; sfb++)
-        {
-            IF ((pHuffBookUsed[sfb] > 0)&&(pHuffBookUsed[sfb] < BOOKSCL))
-            {
-                cw_index = CALL decode_huff_cw_binary(pTable, pInputStream);
-
-                fac      += cw_index - MIDFAC;
-
-                IF((fac >= 2*TEXP) || (fac < 0))
-                {
-                    status = 1;
-                }
-                ELSE
-                {
-                    pFactors[sfb] = fac;
-                }
-                ENDIF (fac)
-
-            }
-            ELSE IF (pHuffBookUsed[sfb] == ZERO_HCB)
-            {
-                do nothing;
-            }
-
-            ELSE IF ((pHuffBookUsed[sfb] == INTENSITY_HCB)||
-                     (pHuffBookUsed[sfb] == INTENSITY_HCB2))
-            {
-                cw_index = CALL decode_huff_cw_binary(pTable, pInputStream);
-
-                is_pos        += cw_index - MIDFAC;
-                pFactors[sfb] =  is_pos;
-            }
-
-            ELSE IF (pHuffBookUsed[sfb] == NOISE_HCB)
-            {
-                IF (noise_pcm_flag == TRUE)
-                {
-                    noise_pcm_flag = FALSE;
-                    dpcm_noise_nrg = CALL getbits(
-                                              NOISE_PCM_BITS,
-                                              pInputStream);
-
-                    dpcm_noise_nrg -= NOISE_PCM_OFFSET;
-                }
-                ELSE
-                {
-                    dpcm_noise_nrg = CALL decode_huff_cw_binary(
-                                              pTable,
-                                              pInputStream);
-
-                    dpcm_noise_nrg -= MIDFAC;
-                }
-                ENDIF (noise_pcm_flag)
-
-                noise_nrg       += dpcm_noise_nrg;
-                pFactors[sfb]   =  noise_nrg;
-            }
-
-            ELSE IF (pHuffBookUsed[sfb] == BOOKSCL)
-            {
-                status = 1;
-            }
-            ENDIF (pHuffBookUsed[sfb])
-
-        }
-        ENDFOR (sfb)
-
-        IF (pFrameInfo->islong == FALSE)
-        {
-
-            FOR(group_win++; group_win < group_end; group_win++)
-            {
-                FOR (sfb=0; sfb < nsfb_win; sfb++)
-                {
-                    pFactors[sfb + nsfb_win]  =  pFactors[sfb];
-                }
-                ENDFOR
-
-                pFactors  +=  nsfb_win;
-            }
-            ENDFOR
-
-        }
-        ENDIF (pFrameInfo)
-
-        pHuffBookUsed   += nsfb_win;
-        pFactors        += nsfb_win;
-
-    }
-    ENDWHILE (group_end)
-
-    return status;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "aac_mem_funcs.h"       /* pv_memset */
-#include    "s_frameinfo.h"
-#include    "s_bits.h"
-#include    "s_sectinfo.h"
-#include    "s_huffman.h"
-#include    "ibstream.h"
-
-#include    "hcbtables.h"
-#include    "e_huffmanconst.h"
-#include    "e_infoinitconst.h"
-#include    "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int hufffac(
-    FrameInfo   *pFrameInfo,
-    BITS        *pInputStream,
-    Int         *pGroup,    /* may be changed to Int */
-    Int         nsect,
-    SectInfo    *pSect,     /* may be changed to Int */
-    Int         global_gain,
-    Int         *pFactors,
-    Int         huffBookUsed[])
-{
-    Int     sect_idx;
-    Int     group_end;  /* index of 1st window in next group */
-    Int     group_win;  /* window index within group */
-    Int     cw_index;   /* huff codeword index */
-    Int     nsfb_win;   /* # of scfbands per window */
-    Int     sfb;        /* scalefactor band index */
-    Int     sect_cb;    /* huff codebook # for each section */
-    Int     fac;        /* decoded scf */
-    Int     is_pos;     /* intensity stereo position */
-    Int     noise_pcm_flag = TRUE;  /* first PNS sfb */
-    Int     dpcm_noise_nrg;     /* dpcm noise energy */
-    Int     noise_nrg;      /* noise energy */
-    Int     status = SUCCESS;  /* status of decoding */
-    Int     *pHuffBookUsed = &huffBookUsed[0];
-
-
-    pv_memset(pFactors,
-              ZERO_HCB,
-              MAXBANDS*sizeof(*pFactors));
-
-
-    if (nsect)
-    {
-        /* read section length and codebook */
-
-        if (nsect == 1) /* long window */
-        {
-            sect_cb  = pSect->sect_cb;  /* codebook for this section */
-
-            /* all sfbs in one section share the same codebook */
-
-            for (sfb = pSect->sect_end >> 2; sfb != 0; sfb--)
-            {
-                *(pHuffBookUsed++) = sect_cb;
-                *(pHuffBookUsed++) = sect_cb;
-                *(pHuffBookUsed++) = sect_cb;
-                *(pHuffBookUsed++) = sect_cb;
-            }
-            for (sfb = pSect->sect_end & 3; sfb != 0; sfb--)
-            {
-                *(pHuffBookUsed++) = sect_cb;
-            }
-
-        }
-        else            /* short */
-        {
-            Int sect_start = 0; /* start index of sfb for each section */
-            for (sect_idx = nsect; sect_idx > 0; sect_idx--)
-            {
-                sect_cb  = pSect->sect_cb;  /* codebook for this section */
-
-                /* all sfbs in one section share the same codebook */
-                for (sfb = sect_start; sfb < pSect->sect_end; sfb++)
-                {
-                    pHuffBookUsed[sfb] = sect_cb;
-                }
-
-                pSect++;
-                sect_start = sfb;
-
-            } /* for (sect_idx) */
-        }
-    }
-    else
-    {
-        /* clear array for the case of max_sfb == 0 */
-        pv_memset(pHuffBookUsed,
-                  ZERO_HCB,
-                  MAXBANDS*sizeof(*pHuffBookUsed));
-    }
-
-    pHuffBookUsed = &huffBookUsed[0];
-
-    /* scale factors and noise energy are dpcm relative to global gain
-     * intensity positions are dpcm relative to zero
-     */
-    fac       = global_gain;
-    is_pos    = 0;
-    noise_nrg = global_gain - NOISE_OFFSET;
-
-    /* get scale factors,
-     * use reserved Table entry = 12, see reference (2) p78 Table 4.6.2
-     */
-    group_win  = 0;
-    group_end  = 0;
-
-
-    /* group by group decoding scalefactors and/or noise energy
-     * and/or intensity position
-     */
-    while ((group_end < pFrameInfo->num_win) && (status == SUCCESS))
-    {
-        nsfb_win  = pFrameInfo->sfb_per_win[group_end];
-        group_end = *pGroup++;  /* index of 1st window in next group */
-
-        /* decode scf in first window of each group */
-
-        for (sfb = 0; sfb < nsfb_win; sfb++)
-        {
-
-            switch (pHuffBookUsed[sfb])
-            {
-                case ZERO_HCB:
-                    break;
-                case INTENSITY_HCB:
-                case INTENSITY_HCB2:
-                    /* intensity books */
-                    /* decode intensity position */
-                    cw_index = decode_huff_scl(pInputStream);
-
-                    is_pos        += cw_index - MIDFAC;
-                    pFactors[sfb] =  is_pos;
-                    break;
-                case NOISE_HCB:
-                    /* noise books */
-                    /* decode noise energy */
-                    if (noise_pcm_flag == TRUE)
-                    {
-                        noise_pcm_flag = FALSE;
-                        dpcm_noise_nrg = get9_n_lessbits(NOISE_PCM_BITS,
-                                                         pInputStream);
-
-                        dpcm_noise_nrg -= NOISE_PCM_OFFSET;
-                    }
-                    else
-                    {
-                        dpcm_noise_nrg = decode_huff_scl(pInputStream);
-
-                        dpcm_noise_nrg -= MIDFAC;
-                    } /* if (noise_pcm_flag) */
-
-                    noise_nrg       += dpcm_noise_nrg;
-                    pFactors[sfb]   =  noise_nrg;
-                    break;
-                case BOOKSCL:
-                    status = 1; /* invalid books */
-                    sfb = nsfb_win;  /* force out */
-                    break;
-                default:
-                    /* spectral books */
-                    /* decode scale factors */
-                    cw_index = decode_huff_scl(pInputStream);
-
-                    fac      += cw_index - MIDFAC;   /* 1.5 dB */
-                    if ((fac >= 2*TEXP) || (fac < 0))
-                    {
-                        status = 1;   /* error, MUST 0<=scf<256, Ref. p73 */
-                    }
-                    else
-                    {
-                        pFactors[sfb] = fac;  /* store scf */
-                    } /* if (fac) */
-            }
-
-        } /* for (sfb=0), first window decode ends */
-
-        /* expand scf to other windows in the same group */
-        if (pFrameInfo->islong == FALSE)
-        {
-
-            for (group_win++; group_win < group_end; group_win++)
-            {
-                for (sfb = 0; sfb < nsfb_win; sfb++)
-                {
-                    pFactors[sfb + nsfb_win]  =  pFactors[sfb];
-                }
-                pFactors  +=  nsfb_win;
-            }
-
-        } /* if (pFrameInfo->islong), one group decode ends */
-
-
-        /* points to next group */
-        pHuffBookUsed   += nsfb_win;
-        pFactors        += nsfb_win;
-
-    } /* while (group_end), all groups decode end */
-
-    return status;
-
-} /* hufffac */
-
diff --git a/media/libstagefright/codecs/aacdec/huffman.h b/media/libstagefright/codecs/aacdec/huffman.h
deleted file mode 100644
index 030ae23..0000000
--- a/media/libstagefright/codecs/aacdec/huffman.h
+++ /dev/null
@@ -1,241 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .huffman.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Put declaration of getfill in this file.
-
- Description: Remove prstflag from get_ics_info declaration.
-
- Description: Trivial change of the data type of one of the parameters to
-              get_ics_info.
-
- Description: Change where get_ics_info is declared.
-
- Description: Clean up comments
-
- Description: (1) Add declaration of binary tree search function for Huffman
-                  decoding
-              (2) #if the traditional and optimized linear seach methods.
-
- Description: Modified per review comments
-              (1) delete #if traditional and optimized linear seach methods
-
- Description: Merged Ken's change on getics: delete pFrameInfo from argument
-              list
-
- Description: Added function definition for table specific huffman decoding
-              functions.
-
- Who:                                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- include function prototype definitions for Huffman decoding module
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef HUFFMAN_H
-#define HUFFMAN_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_frameinfo.h"
-#include    "s_sectinfo.h"
-#include    "s_pulseinfo.h"
-#include    "s_tdec_int_file.h"
-#include    "s_tdec_int_chan.h"
-#include    "ibstream.h"
-
-#include    "s_hcb.h"
-#include    "hcbtables.h"
-
-#include    "get_pulse_data.h"
-#include    "get_ics_info.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-#define DIMENSION_4     4
-#define DIMENSION_2     2
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int decode_huff_cw_tab1(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab2(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab3(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab4(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab5(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab6(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab7(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab8(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab9(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab10(
-        BITS *pInputStream);
-
-    Int decode_huff_cw_tab11(
-        BITS *pInputStream);
-
-    Int decode_huff_scl(
-        BITS          *pInputStream);
-
-    Int infoinit(
-        const  Int sampling_rate_idx,
-        FrameInfo   **ppWin_seq_info,
-        Int    *pSfbwidth128);
-
-    Int huffcb(
-        SectInfo *pSect,
-        BITS     *pInputStream,
-        Int      *pSectbits,
-        Int       tot_sfb,
-        Int       sfb_per_sbk,
-        Int       max_sfb);
-
-    Int hufffac(
-        FrameInfo   *pFrameInfo,
-        BITS        *pInputStream,
-        Int         *pGroup,
-        Int          nsect,
-        SectInfo    *pSect,
-        Int          global_gain,
-        Int         *pFactors,
-        Int          huffBookUsed[]);
-
-    Int huffspec_fxp(
-        FrameInfo *pFrameInfo,
-        BITS      *pInputStream,
-        Int       nsect,
-        SectInfo  *pSectInfo,
-        Int       factors[],
-        Int32     coef[],
-        Int16     quantSpec[],
-        Int16     tmp_spec[],
-        const FrameInfo  *pLongFrameInfo,
-        PulseInfo  *pPulseInfo,
-        Int         qFormat[]);
-
-    Int huffdecode(
-        Int           id_syn_ele,
-        BITS          *pInputStream,
-        tDec_Int_File *pVars,
-        tDec_Int_Chan *pChVars[]);
-
-    void deinterleave(
-        Int16          interleaved[],
-        Int16        deinterleaved[],
-        FrameInfo   *pFrameInfo);
-
-    Int getics(
-
-        BITS            *pInputStream,
-        Int             common_window,
-        tDec_Int_File   *pVars,
-        tDec_Int_Chan   *pChVars,
-        Int             group[],
-        Int             *pMax_sfb,
-        Int             *pCodebookMap,
-        TNS_frame_info  *pTnsInfo,
-        FrameInfo       **pWinMap,
-        PulseInfo       *pPulseInfo,
-        SectInfo        sect[]);
-
-    void  calc_gsfb_table(
-        FrameInfo   *pFrameInfo,
-        Int         group[]);
-
-    Int getmask(
-        FrameInfo   *pFrameInfo,
-        BITS        *pInputStream,
-        Int         *pGroup,
-        Int         max_sfb,
-        Int         *pMask);
-
-    void getgroup(
-        Int         group[],
-        BITS        *pInputStream);
-
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp b/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp
deleted file mode 100644
index b18c12d..0000000
--- a/media/libstagefright/codecs/aacdec/huffspec_fxp.cpp
+++ /dev/null
@@ -1,671 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname:  huffspec_fxp.c
- Funtions:
-    huffspec_fxp
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description: (1) Modified to keep in-line with PV standards
-              (2) Eliminated "continue" in if(sect_cb==ZERO_HCB||...)
-
- Description: (1) Use SectInfo *pSect
-              (2) Convert 'Real' to 'Int32', float -> fixed-point
-              (3) move BITS *pInputStream to second parameter
-              (4) pass in quantSpec and tmp_spec, scratch shared with hufffac
-              (5) pass in FrameInfo *pLongFrameInfo, eliminate only_long_info
-
- Description: (1) Eliminate parameter Hcb *book, because of eliminating
-                  function 'hufftab.c', Hcb hcbbook defined as a
-                  const structure in 'hcbtables.h'.
-              (2) Replace three nested 'for' loops with a for-while loop in
-                  the rescaling part.
-              (3) Change esc_iquant-> esc_iquant_fxp, call esc_iquant_fxp()
-                  by sfb
-
- Description: Cleaned up include files.
-
- Description:  Correct definition of stack variable "scale".
-        It was defined as Int, but it receives an UInt value,
-        this present a problem when Int is 16 bits and
-        the sign bit is not interpreted correctly. This does not
-        shows for 32-bit implementations. This problem manifest itself
-        as a flipping sign on some spectral coefficients (the ones
-        multiplied by 0x8000).
-
- Description: Typecast b_low and b_high to 32-bits before multiplication, this
-              assures propoer compilation on a 16-bit platform (TI-C55x)
-
- Description: Modified to speed up decode_huff_cw
-
- Description: pass codebook index to decode_huff_cw, delete pointer to Huffman
-              structure
-
- Description: keep memset to quantSpec, remove memset to temp_spec
-
- Description: Modified per review comments
-
- Description: Use Binary tree search in decode_huff_cw_binary
-
- Description: Modified per review comments
-              (1) delete unused codes
-
- Description: (1) Change the interface to decode huffman codeword.
-              (2) Move the scaling inside the inverse quantization.
-              (3) Change scaling factor accuracy to 10 bits.
-
- Description:
-              (1) delete unused variable max_fac
-
- Description: Addresses of huffman tables are now found by means of a
-              switch statement, this solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pFrameInfo  = ptr to structure that holds Information of current Frame,
-                  type FrameInfo
-
-    pInputStream = ptr to structure of bitstream, type BITS
-
-    nsect       = number of sections in current Frame, at fs = 44.1 kHz,
-                  range [0, 49] long block, [0,112] short blocks. type Int
-
-    pSect       = ptr to structure that holds section codebook and boundary
-                  type SectInfo
-
-    factors[]   = array that contains scalefactors for each sfb, type Int16
-
-    coef[]      = array that holds inverse quantized coefs, Int32 QFormat.
-
-    quantSpec[] = array that holds quantized spectral coefs, type Int
-
-    tmp_spec[]  = temporary buffer to hold the de-interleaved coefs.
-
-    pLongFrameInfo = ptr to structure that holds long frame info
-
- Local Stores/Buffers/Pointers Needed:
-    exptable = array contains the Q15 format data for 2^0, 2^0.25, 2^0.5,
-               and 2^0.75, type const Int.
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-
-    return 0 if decoding properly.
-
- Pointers and Buffers Modified:
-
-    pInputStream    read codeword index and/or sign bits and/or ESC value
-
-    coef            contains the newly inverse quantized 1024 spec coefs,
-                    type Int32 Q-format from esc_iquant()
-
-    quantSpec       contains decoded quantized 1024 spec coefs, type Int
-
-    tmp_spec        contains the de-interleaved version of quantSpec
-
-    qFormat         contains Q-Format for each scalefactor band
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function first reads the section info (codebook and boundary), then
- decode the spectral coefficients if a spectral codebook is used.
- If necessary, get the sign bits, ESC value or the NEC_pulse data. In case of
- short window sequences, the decoded data is de-interleaved before
- multiplied by scalefactors.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function should set the content of the array 'coef' with the inverse
- quantized and rescaled value of spectral coefficients.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart (4)         p56 (spectral_data() parsing and decoding)
-                        p26 (Syntax of spectral_data())
-                        p74-78 (decoding: unpack_idx, get_sign_bits,
-                                getescape, pulse_nc, deinterleave)
-                        p72 (inverse quantization: esc_iquant)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "aac_mem_funcs.h"
-#include    "esc_iquant_scaling.h"
-#include    "huffman.h"
-#include    "unpack_idx.h"
-#include    "pulse_nc.h"
-#include    "iquant_table.h"
-#include    "e_huffmanconst.h"
-
-
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ORDER        (3)
-
-/*
- * Format the table is stored in.
- */
-#define QTABLE       (27)
-
-/*
- * Number of bits for data in a signed 32 bit integer.
- */
-#define SIGNED32BITS  (31)
-
-/*
- * Round up value for intermediate values obtained from the table
- */
-#define ROUND_UP (( ((UInt32) 1) << (QTABLE) )-1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const UInt16 exptable[4] =
-{
-    0,  /* (2^0.00)<<15 (Q10), use zero to signal no scaling required! */
-    19485,  /* (2^0.25)<<15 */
-    23171,  /* (2^0.50)<<15 */
-    27555   /* (2^0.75)<<15 */
-
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int huffspec_fxp(
-    FrameInfo *pFrameInfo,
-    BITS      *pInputStream,
-    Int       nsect,
-    SectInfo  *pSectInfo,
-    Int       factors[],
-    Int32     coef[],
-    Int16     quantSpec[],
-    Int16     tmp_spec[],
-    const FrameInfo  *pLongFrameInfo,
-    PulseInfo  *pPulseInfo,
-    Int         qFormat[])
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    const Hcb       *pHcb;
-    Int     i;
-    Int     sfb;
-    Int     idx_count;
-    Int     sect_cb;    /* section codebook */
-    Int     dim;
-    Int     idx;
-    Int     stop_idx;     /* index of 1st coef in next sfb */
-    Int     sect_start;   /* start index of sfb in one section*/
-    Int     sect_end;     /* index of 1st sfb in next section */
-    Int     *pSfbStart;
-    Int     *pSfb;
-    Int16     *pQuantSpec;        /* probably could be short */
-    Int     max = 0;
-    /* rescaling parameters */
-    Int     nsfb;
-    Int     tot_sfb;
-    Int     fac;
-
-    Int32   *pCoef; /* ptr to coef[], inverse quantized coefs */
-    UInt16     scale;
-
-    Int     power_scale_div_4;
-    Int     sfbWidth;
-
-    void (*pUnpack_idx)(
-        Int16  quant_spec[],
-        Int  codeword_indx,
-        const Hcb *pHuffCodebook,
-        BITS  *pInputStream,
-        Int *max);
-
-    Int(*pDec_huff_tab)(BITS *) = NULL;
-
-    UInt32 temp;
-    Int    binaryDigits, QFormat;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-
-    sect_start = 0;
-    stop_idx   = 0;
-
-    /* pSfb: ptr to array that holds stop index of each sfb */
-    pSfbStart = pFrameInfo->frame_sfb_top;
-
-    if (pSfbStart == NULL)
-    {
-        return (-1);   /*  error condition */
-    }
-
-    pSfb      = pSfbStart;
-
-    /* decoding spectral values section by section */
-    for (i = nsect; i > 0; i--)
-    {
-        /* read the codebook and section length */
-        sect_cb  =  pSectInfo->sect_cb;     /* codebook */
-        if ((sect_cb > 15) || (sect_cb < 0))
-        {
-            return (-1);   /*  error condition */
-        }
-        sect_end =  pSectInfo->sect_end;    /* # of sfbs */
-
-        if (sect_end < 0)
-        {
-            return (-1);   /*  error condition */
-        }
-
-        pSectInfo++;
-
-        /*  sect_cb       sect_cb - 1
-         *  ZERO_HCB        1111b
-         *    1             0000b
-         *    2             0001b
-         *    3             0010b
-         *    4             0011b
-         *    5             0100b
-         *    6             0101b
-         *    7             0110b
-         *    8             0111b
-         *    9             1000b
-         *    10            1001b
-         *    11            1010b
-         *    12            1011b
-         * NOISE_HCB        1100b
-         * INTENSITY_HCB2   1101b
-         * INTENSITY_HCB    1110b
-         * if ( ((sect_cb - 1) & 0xC) == 0xC ) is identical to
-         * if !((sect_cb == ZERO_HCB) || (sect_cb == NOISE_HCB) ||
-         *      (sec_cb == INTENSITY_HCB) || (sect_cb==INTENSITY_HCB2) )
-         * use this compare scheme to speed up the execution
-         */
-
-        if (((sect_cb - 1) & 0xC) != 0xC)
-        {
-            /* decode spec in one section */
-            if (sect_cb > BY4BOOKS)
-            {
-                dim = DIMENSION_2; /* set codebook dimension */
-            }
-            else
-            {
-                dim = DIMENSION_4;
-            }
-
-            pHcb        = &hcbbook_binary[sect_cb];
-
-            if (sect_cb == ESCBOOK)
-            {
-                pUnpack_idx = &unpack_idx_esc;
-            }
-            else if (pHcb->signed_cb == FALSE)
-            {
-                pUnpack_idx = &unpack_idx_sgn;
-            }
-            else
-            {
-                pUnpack_idx = &unpack_idx;
-            }
-
-
-            switch (sect_cb)
-            {
-                case 1:
-                    pDec_huff_tab = decode_huff_cw_tab1;
-                    break;
-                case 2:
-                    pDec_huff_tab = decode_huff_cw_tab2;
-                    break;
-                case 3:
-                    pDec_huff_tab = decode_huff_cw_tab3;
-                    break;
-                case 4:
-                    pDec_huff_tab = decode_huff_cw_tab4;
-                    break;
-                case 5:
-                    pDec_huff_tab = decode_huff_cw_tab5;
-                    break;
-                case 6:
-                    pDec_huff_tab = decode_huff_cw_tab6;
-                    break;
-                case 7:
-                    pDec_huff_tab = decode_huff_cw_tab7;
-                    break;
-                case 8:
-                    pDec_huff_tab = decode_huff_cw_tab8;
-                    break;
-                case 9:
-                    pDec_huff_tab = decode_huff_cw_tab9;
-                    break;
-                case 10:
-                    pDec_huff_tab = decode_huff_cw_tab10;
-                    break;
-                case 11:
-                    pDec_huff_tab = decode_huff_cw_tab11;
-                    break;
-                default:
-                    return (-1); /* error condition */
-            }
-
-            /* move ptr to first sfb of current section */
-            pQuantSpec  = quantSpec + stop_idx;
-
-            /* step through all sfbs in current section */
-            for (sfb = sect_start; sfb < sect_end; sfb++)
-            {
-                idx_count = *pSfb - stop_idx;
-                stop_idx  = *pSfb++;
-
-                /* decode all coefs for one sfb */
-                while ((idx_count > 0) && (idx_count < 1024))
-                {
-
-                    idx = (*pDec_huff_tab)(pInputStream);
-
-                    (*pUnpack_idx)(pQuantSpec,
-                                   idx,
-                                   pHcb,
-                                   pInputStream,
-                                   &max);      /* unpack idx -> coefs */
-
-                    pQuantSpec += dim;
-                    idx_count  -= dim;
-
-                } /* while(idx_count) */
-
-            } /* for (sfb=sect_start) */
-        }
-        else
-        {
-
-            /* current section uses ZERO_HCB, NOISE_HCB, etc */
-
-            /* move sfb pointer to the start sfb of next section */
-            pSfb        = pSfbStart + sect_end;
-            /* number of coefs in current section */
-            idx_count   = *(pSfb - 1) - stop_idx;
-
-            if ((idx_count > 1024) || (idx_count < 0))
-            {
-                return (-1);   /*  error condition */
-            }
-
-            /*
-             * This memset is necessary in terms of (1) net savings in total
-             * MIPS and (2) accurate Q-Formats for fft_rx2
-             * In case a scalefactor band uses ZERO_HCB, all coefficients of
-             * that sfb should be zeros. Without this call to memset, the
-             * coefficients for a ZERO_HCB sfb are the "leftovers" of the
-             * previous frame, which may not have all zero values. This leads
-             * to a drastical increase in the cycles consumed by esc_iquant_fxp
-             * and fft_rx2, which is the most "expensive" function of the
-             * library.
-             * This memset also guarantees the Q_Format for sfbs with all zero
-             * coefficients will be set properly.
-             * Profiling data on ARM and TMS320C55x proves that there is a net
-             * gain in total MIPS if a memset is called here.
-             */
-            pv_memset(&quantSpec[stop_idx],
-                      0,
-                      idx_count * sizeof(quantSpec[0]));
-
-            /*
-             * This memset is called because pQuantSpec points to tmp_spec
-             * after deinterleaving
-             */
-
-            pv_memset(&tmp_spec[stop_idx],
-                      0,
-                      idx_count * sizeof(tmp_spec[0]));
-
-
-            /* stop_idx is the index of the 1st coef of next section */
-            stop_idx    = *(pSfb - 1);
-
-        }/* if (sect_cb) */
-
-        sect_start = sect_end;
-
-    } /* for (i=nsect) */
-
-    /* noisless coding reconstruction */
-    if (pFrameInfo->islong != FALSE)
-    {
-        if (pPulseInfo->pulse_data_present == 1)
-        {
-            pulse_nc(quantSpec,
-                     pPulseInfo,
-                     pLongFrameInfo,
-                     &max);    /* add pulse data */
-        }
-
-        pQuantSpec = quantSpec;
-
-    }
-    else
-    {
-        deinterleave(quantSpec,
-                     tmp_spec,
-                     pFrameInfo);
-
-        pQuantSpec = tmp_spec;
-    }
-
-
-    /* inverse quantization, Q_format: Int32 */
-    /* rescaling */
-
-    /* what we can do here is assuming that we already know maxInput for each band, we have to go
-    though each one of them for re-quant and scaling, and pick the right qFormat to apply to
-    all spectral coeffs.*/
-
-    if ((max < 0) || (max > 8192))    /* (8192>>ORDER) == 1024 is the inverseQuantTable size */
-    {
-        return (-1);   /*  error condition */
-    }
-    else
-    {
-        /* Get  (max/SPACING) ^ (1/3), in Q Format  */
-        temp = inverseQuantTable[(max >> ORDER) + 1];
-    }
-
-
-    /* Round up before shifting down to Q0 */
-    temp += ROUND_UP;
-
-    /* shift down to Q0 and multiply by 2 (FACTOR) in one step */
-    temp >>= (QTABLE - 1);
-
-    /* Now get max ^ (4/3) in Q0 */
-    temp *= max;
-
-
-    binaryDigits = 31 - pv_normalize(temp);
-
-
-    /* Prevent negative shifts caused by low maximums. */
-    if (binaryDigits < (SIGNED32BITS - QTABLE))
-    {
-        binaryDigits = SIGNED32BITS - QTABLE;
-    }
-
-    QFormat = SIGNED32BITS - binaryDigits;
-
-    /********************/
-    tot_sfb = 0;
-    nsfb = pFrameInfo->sfb_per_win[0];
-    pCoef = coef;
-
-    for (i = pFrameInfo->num_win; i > 0; i--)
-    {
-        stop_idx  = 0;
-
-        for (sfb = 0; sfb < nsfb; sfb++)
-        {
-            sfbWidth   =  pFrameInfo->win_sfb_top[0][sfb] - stop_idx;
-
-            if ((sfbWidth < 0) || (sfbWidth > 1024))
-            {
-                return (-1);   /*  error condition */
-            }
-
-            stop_idx  += sfbWidth;
-
-            fac   = factors[tot_sfb] - SF_OFFSET;
-            scale = exptable[fac & 0x3];
-
-            power_scale_div_4 = fac >> 2;
-
-            power_scale_div_4++;
-
-            qFormat[tot_sfb] = QFormat;
-
-            esc_iquant_scaling(pQuantSpec,
-                               pCoef,
-                               sfbWidth,
-                               QFormat,
-                               scale,
-                               max);
-
-            pQuantSpec += sfbWidth;
-            qFormat[tot_sfb] -= power_scale_div_4;
-            pCoef += sfbWidth;
-
-            tot_sfb++;
-
-        } /* for (sfb) */
-    } /* for (i) */
-
-
-    /*----------------------------------------------------------------------------
-    ; Return status
-    ----------------------------------------------------------------------------*/
-    return SUCCESS;
-
-} /* huffspec_fxp */
diff --git a/media/libstagefright/codecs/aacdec/ibstream.h b/media/libstagefright/codecs/aacdec/ibstream.h
deleted file mode 100644
index 8b644dc..0000000
--- a/media/libstagefright/codecs/aacdec/ibstream.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ibstream.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change names of constants.
-
- Description: Change the buffer from UInt to UInt32
-
- Description: Remove declaration of getbits and include header file
-
- Description: Change input buffer to UChar
-              Add constant
-
- Who:                                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains defines, structures, and function definitions for the
- input bit stream used in the AAC Decoder.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IBSTREAM_H
-#define IBSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bits.h"
-#include    "getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define INBUF_ARRAY_INDEX_SHIFT  (3)
-#define INBUF_BIT_WIDTH         (1<<(INBUF_ARRAY_INDEX_SHIFT))
-#define INBUF_BIT_MODULO_MASK   ((INBUF_BIT_WIDTH)-1)
-
-#define MAX_GETBITS             (25)
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void byte_align(
-        BITS  *pInputStream);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif /* IBSTREAM_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/idct16.cpp b/media/libstagefright/codecs/aacdec/idct16.cpp
deleted file mode 100644
index 324fe9e..0000000
--- a/media/libstagefright/codecs/aacdec/idct16.cpp
+++ /dev/null
@@ -1,204 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: idct16.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 16
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement inverse discrete cosine transform of lenght 16
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "idct16.h"
-#include "idct8.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT     28
-#define Qfmt(x)     (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-#define Qfmt31(x)   (Int32)(x*(0x7FFFFFFF) + (x>=0?0.5F:-0.5F))
-
-const Int32 CosTable_8i[8] =
-{
-    Qfmt31(0.50241928618816F),   Qfmt31(0.52249861493969F),
-    Qfmt31(0.56694403481636F),   Qfmt31(0.64682178335999F),
-    Qfmt(0.78815462345125F),   Qfmt(1.06067768599035F),
-    Qfmt(1.72244709823833F),   Qfmt(5.10114861868916F)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void idct_16(Int32 vec[], Int32 scratch_mem[])    /* scratch_mem size 8 */
-{
-    Int32 *temp_even = scratch_mem;
-
-    Int32 i;
-    const Int32 *pt_cos = CosTable_8i;
-    Int32 tmp1, tmp2;
-    Int32 *pt_even = temp_even;
-    Int32 *pt_odd  = vec;
-    Int32 *pt_vec  = vec;
-
-    Int32 tmp3;
-    Int32 *pt_vecN_1;
-
-
-    *(pt_even++) = *(pt_vec++);
-    tmp1         = *(pt_vec++);
-    *(pt_odd++) = tmp1;
-
-    for (i = 2; i != 0; i--)
-    {
-        *(pt_even++) = *(pt_vec++);
-        tmp2         = *(pt_vec++);
-        *(pt_even++) = *(pt_vec++);
-        tmp3         = *(pt_vec++);
-        *(pt_odd++) = tmp2 + tmp1;
-        *(pt_odd++) = tmp3 + tmp2;
-        tmp1         = tmp3;
-    }
-
-    *(pt_even++) = *(pt_vec++);
-    tmp2         = *(pt_vec++);
-    *(pt_even++) = *(pt_vec++);
-    tmp3         = *(pt_vec++);
-    *(pt_odd++) = tmp2 + tmp1;
-    *(pt_odd++) = tmp3 + tmp2;
-
-
-    *(pt_even)   = *(pt_vec++);
-    *(pt_odd++) = *(pt_vec) + tmp3;
-
-
-    idct_8(temp_even);
-    idct_8(vec);
-
-
-    pt_cos = &CosTable_8i[7];
-
-    pt_vec  = &vec[7];
-
-    pt_even = &temp_even[7];
-    pt_vecN_1  = &vec[8];
-
-    tmp1 = *(pt_even--);
-
-    for (i = 2; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q28(*(pt_vec), *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp1 - tmp3;
-        *(pt_vec--)     = tmp1 + tmp3;
-        tmp3  = fxp_mul32_Q28(*(pt_vec), *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp2 - tmp3;
-        *(pt_vec--)     = tmp2 + tmp3;
-    }
-
-    tmp3  = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
-    tmp2 = *(pt_even--);
-    *(pt_vecN_1++)  = tmp1 - tmp3;
-    *(pt_vec--)     = tmp1 + tmp3;
-    tmp3  = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
-    tmp1 = *(pt_even--);
-    *(pt_vecN_1++)  = tmp2 - tmp3;
-    *(pt_vec--)     = tmp2 + tmp3;
-    tmp3  = fxp_mul32_Q31(*(pt_vec), *(pt_cos--)) << 1;
-    tmp2 = *(pt_even--);
-    *(pt_vecN_1++)  = tmp1 - tmp3;
-    *(pt_vec--)     = tmp1 + tmp3;
-    tmp3  = fxp_mul32_Q31(*(pt_vec), *(pt_cos)) << 1;
-    *(pt_vecN_1)  = tmp2 - tmp3;
-    *(pt_vec)     = tmp2 + tmp3;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/idct16.h b/media/libstagefright/codecs/aacdec/idct16.h
deleted file mode 100644
index afade07..0000000
--- a/media/libstagefright/codecs/aacdec/idct16.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Pathname: idct16.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT16_H
-#define IDCT16_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    void idct_16(Int32 vec[], Int32 scratch_mem[]);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* IDCT16_H */
diff --git a/media/libstagefright/codecs/aacdec/idct32.cpp b/media/libstagefright/codecs/aacdec/idct32.cpp
deleted file mode 100644
index ac9773b..0000000
--- a/media/libstagefright/codecs/aacdec/idct32.cpp
+++ /dev/null
@@ -1,196 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Filename: idct32.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 32
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement inverse discrete cosine transform of lenght 32
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "idct32.h"
-#include "dst32.h"
-#include "idct16.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-
-#define R_SHIFT1     29
-#define Qfmt1(x)   (Int32)(x*((Int32)1<<R_SHIFT1) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt3(a)   (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void idct_32(Int32 vec[], Int32 scratch_mem[])   /* scratch_mem size 32 */
-{
-    Int32 *temp_even = scratch_mem;
-
-    Int32 i;
-    const Int32 *pt_cos = CosTable_16;
-    Int32 tmp1, tmp2;
-    Int32 *pt_even = temp_even;
-    Int32 *pt_odd  = vec;
-    Int32 *pt_vec  = vec;
-    Int32 *pt_vecN_1;
-    Int32 tmp3;
-
-
-    *(pt_even++) = *(pt_vec++);
-    tmp1         = *(pt_vec++);
-    tmp2 = 0;
-
-    for (i = 7; i != 0; i--)
-    {
-        *(pt_odd++) = tmp2 + tmp1;
-        *(pt_even++) = *(pt_vec++);
-        tmp2         = *(pt_vec++);
-        *(pt_even++) = *(pt_vec++);
-        *(pt_odd++) = tmp2 + tmp1;
-        tmp1         = *(pt_vec++);
-    }
-
-    *(pt_odd++) = tmp2 + tmp1;
-    *(pt_even++) = *(pt_vec++);
-    tmp2         = *(pt_vec++);
-    *(pt_odd++) = tmp2 + tmp1;
-
-
-    idct_16(temp_even, &scratch_mem[16]);
-    idct_16(vec, &scratch_mem[24]);
-
-
-    pt_cos = &CosTable_16[13];
-
-    pt_vec  = &vec[15];
-
-    pt_even = &temp_even[15];
-    pt_vecN_1  = &vec[16];
-
-    tmp1 = *(pt_even--);
-
-
-    tmp3  = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.63687550772175F)) << 2;
-    tmp2 = *(pt_even--);
-    *(pt_vecN_1++)  = tmp1 - tmp3;
-    *(pt_vec--)     = tmp1 + tmp3;
-    tmp3  = fxp_mul32_Q31(*(pt_vec) << 3, Qfmt3(0.85190210461718F));
-
-    tmp1 = *(pt_even--);
-    *(pt_vecN_1++)  = tmp2 - tmp3;
-    *(pt_vec--)     = tmp2 + tmp3;
-
-    for (i = 2; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q29(*(pt_vec), *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp1 - tmp3;
-        *(pt_vec--)     = tmp1 + tmp3;
-        tmp3  = fxp_mul32_Q29(*(pt_vec), *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp2 - tmp3;
-        *(pt_vec--)     = tmp2 + tmp3;
-    }
-
-    for (i = 5; i != 0; i--)
-    {
-        tmp3  = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--));
-        tmp2 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp1 - tmp3;
-        *(pt_vec--)     = tmp1 + tmp3;
-        tmp3  = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_cos--));
-        tmp1 = *(pt_even--);
-        *(pt_vecN_1++)  = tmp2 - tmp3;
-        *(pt_vec--)     = tmp2 + tmp3;
-    }
-}
-
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/idct32.h b/media/libstagefright/codecs/aacdec/idct32.h
deleted file mode 100644
index 12c685a..0000000
--- a/media/libstagefright/codecs/aacdec/idct32.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: idct32.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT32_H
-#define IDCT32_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void idct_32(Int32 vec[], Int32 scratch_mem[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* IDCT32_H */
diff --git a/media/libstagefright/codecs/aacdec/idct8.cpp b/media/libstagefright/codecs/aacdec/idct8.cpp
deleted file mode 100644
index 8f040ce..0000000
--- a/media/libstagefright/codecs/aacdec/idct8.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: idct8.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 8
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement inverse discrete cosine transform of lenght 8
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "idct8.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-#define R_SHIFT     29
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt15(x)   (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void idct_8(Int32 vec[])
-{
-
-    Int32 tmp0;
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 tmp3;
-    Int32 tmp4;
-    Int32 tmp5;
-    Int32 tmp6;
-    Int32 tmp7;
-    Int32 tmp8;
-
-
-    tmp5 = fxp_mul32_by_16(vec[4] << 1, Qfmt15(0.70710678118655F));
-
-    tmp1 =  vec[0] + tmp5;
-    tmp5 =  vec[0] - tmp5;
-
-    tmp3 = fxp_mul32_by_16(vec[2] << 1, Qfmt15(0.54119610014620F));     /* (1/(2*cos(2*phi)));*/
-    tmp7 = fxp_mul32_Q29(vec[6], Qfmt(1.30656296487638F));      /* (1/(2*cos(6*phi)));*/
-
-    tmp0  = fxp_mul32_by_16((tmp3 - tmp7) << 1, Qfmt15(0.70710678118655F)); /* (1/(2*cos(2*phi)));  */
-    tmp7 = (tmp3 + tmp7) + tmp0;
-
-    vec[0] = tmp1 + tmp7;
-    tmp2 = fxp_mul32_by_16(vec[1] << 1, Qfmt15(0.50979557910416F));     /* (1/(2*cos(  phi)));*/
-    vec[1] = tmp5 + tmp0;
-    vec[2] = tmp5 - tmp0;
-    tmp4 = fxp_mul32_by_16(vec[3] << 1, Qfmt15(0.60134488693505F));     /* (1/(2*cos(3*phi)));*/
-    vec[3] = tmp1 - tmp7;
-
-    tmp6 = fxp_mul32_by_16(vec[5] << 1, Qfmt15(0.89997622313642F));     /* (1/(2*cos(5*phi)));*/
-    tmp8 = fxp_mul32_Q29(vec[7], Qfmt(2.56291544774151F));      /* (1/(2*cos(7*phi)));*/
-
-    tmp7  =  tmp2 + tmp8;
-    tmp5  = fxp_mul32_by_16((tmp2 - tmp8) << 1, Qfmt15(0.54119610014620F));
-    tmp8  =  tmp4 + tmp6;
-    tmp6  = fxp_mul32_Q29((tmp4 - tmp6), Qfmt(1.30656296487638F));
-
-    tmp0 =  tmp7 + tmp8;
-    tmp2 = fxp_mul32_by_16((tmp7 - tmp8) << 1, Qfmt15(0.70710678118655F));
-
-    tmp3 = fxp_mul32_by_16((tmp5 - tmp6) << 1, Qfmt15(0.70710678118655F));
-    tmp1 = (tmp5 + tmp6) + tmp3;
-
-    tmp5 = tmp0 + tmp1;
-    tmp6 = tmp1 + tmp2;
-    tmp7 = tmp2 + tmp3;
-
-    vec[7]  = vec[0] - tmp5;
-    vec[0] +=          tmp5;
-    vec[6]  = vec[1] - tmp6;
-    vec[1] +=          tmp6;
-    vec[5]  = vec[2] - tmp7;
-    vec[2] +=          tmp7;
-    vec[4]  = vec[3] - tmp3;
-    vec[3] +=          tmp3;
-
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/idct8.h b/media/libstagefright/codecs/aacdec/idct8.h
deleted file mode 100644
index ad7eaae..0000000
--- a/media/libstagefright/codecs/aacdec/idct8.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: idct8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef IDCT8_H
-#define IDCT8_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    void idct_8(Int32 vec[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* IDCT8_H */
diff --git a/media/libstagefright/codecs/aacdec/imdct_fxp.cpp b/media/libstagefright/codecs/aacdec/imdct_fxp.cpp
deleted file mode 100644
index ad67f20..0000000
--- a/media/libstagefright/codecs/aacdec/imdct_fxp.cpp
+++ /dev/null
@@ -1,476 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: imdct_fxp.c
- Funtions: imdct_fxp
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    data_quant    = Input vector, with quantized spectral lines:
-                    type Int32
-
-    freq_2_time_buffer =  Scratch memory used for in-place FFT calculation,
-                    min size required 1024,
-                    type Int32
-
-    n            =  Length of input vector "data_quant". Currently 256 or 2048
-                    type const Int
-
-    Q_format     =  Q_format of the input vector "data_quant"
-                    type Int
-
-    max          =  Maximum value inside input vector "data_quant"
-                    type Int32
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    shift = shift factor to reflect scaling introduced by IFFT and imdct_fxp,
-
- Pointers and Buffers Modified:
-    Results are return in "Data_Int_precision"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    The IMDCT is a linear orthogonal lapped transform, based on the idea of
-    time domain aliasing cancellation (TDAC).
-    IMDCT is critically sampled, which means that though it is 50% overlapped,
-    a sequence data after IMDCT has the same number of coefficients as samples
-    before the transform (after overlap-and-add). This means, that a single
-    block of IMDCT data does not correspond to the original block on which the
-    IMDCT was performed. When subsequent blocks of inverse transformed data
-    are added (still using 50% overlap), the errors introduced by the
-    transform cancels out.Thanks to the overlapping feature, the IMDCT is very
-    useful for quantization. It effectively removes the otherwise easily
-    detectable blocking artifact between transform blocks.
-
-    N = twice the length of input vector X
-    y = vector of length N, will hold fixed point IDCT
-    p = 0:1:N-1
-
-                    2   N/2-1
-            y(p) = ---   SUM   X(m)*cos(pi/(2*N)*(2*p+1+N/2)*(2*m+1))
-                    N    m=0
-
-    The window that completes the TDAC is applied before calling this function.
-    The IMDCT can be calculated using an IFFT, for this, the IMDCT need be
-    rewritten as an odd-time odd-frequency discrete Fourier transform. Thus,
-    the IMDCT can be calculated using only one n/4 point FFT and some pre and
-    post-rotation of the sample points.
-
-
-    where X(k) is the input with N frequency lines
-
-    X(k) ----------------------------
-                                     |
-                                     |
-                    Pre-rotation by exp(j(2pi/N)(k+1/8))
-                                     |
-                                     |
-                              N/4- point IFFT
-                                     |
-                                     |
-                    Post-rotation by exp(j(2pi/N)(n+1/8))
-                                     |
-                                     |
-                                      ------------- x(n)  In the time domain
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should provide a fixed point IMDCT with an average
-    quantization error less than 1 % (variance and mean).
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] Analysis/Synthesis Filter Bank design based on time domain
-        aliasing cancellation
-        Jhon Princen, et. al.
-        IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986
-        Pg 1153 - 1161
-
-    [2] Regular FFT-related transform kernels for DCT/DST based
-        polyphase filterbanks
-        Rolf Gluth
-        Proc. ICASSP 1991, pg. 2205 - 2208
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-  Cx, Cy are complex number
-
-
-    exp = log2(n)-1
-
-    FOR ( k=0; k< n/2; k +=2)
-
-        Cx = - data_quant[k] + j data_quant[n/2-1 - k]
-
-        freq_2_time_buffer = Cx * exp(j(2pi/n)(k+1/8))
-
-    ENDFOR
-
-    CALL IFFT( freq_2_time_buffer, n/4)
-
-    MODIFYING( freq_2_time_buffer )
-
-    RETURNING( shift )
-
-    FOR ( k=0; k< n/4; k +=2)
-
-        Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1]
-
-        Cy = Cx * exp(j(2pi/n)(k+1/8))
-
-        data_quant[3n/4-1 - k ] =   Real(Cy)
-        data_quant[ n/4-1 - k ] = - Imag(Cy)
-        data_quant[3n/4   + k ] =   Real(Cy)
-        data_quant[ n/4   + k ] =   Imag(Cy)
-
-    ENDFOR
-
-    FOR ( k=n/4; k< n/2; k +=2)
-
-        Cx = freq_2_time_buffer[ k] + j freq_2_time_buffer[ k+1]
-
-        Cy = Cx * exp(j(2pi/n)(k+1/8))
-
-        data_quant[3n/4-1 - k ] =   Real(Cy)
-        data_quant[ n/4   + k ] = - Real(Cy)
-        data_quant[5n/4   - k ] =   Imag(Cy)
-        data_quant[ n/4   + k ] =   Imag(Cy)
-
-    ENDFOR
-
-    MODIFIED    data_quant[]
-
-    RETURN      (exp - shift)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "imdct_fxp.h"
-
-
-#include "mix_radix_fft.h"
-#include "digit_reversal_tables.h"
-#include "fft_rx4.h"
-#include "inv_short_complex_rot.h"
-#include "inv_long_complex_rot.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ERROR_IN_FRAME_SIZE 10
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int imdct_fxp(Int32   data_quant[],
-              Int32   freq_2_time_buffer[],
-              const   Int     n,
-              Int     Q_format,
-              Int32   max)
-{
-
-    Int32     exp_jw;
-    Int     shift = 0;
-
-    const   Int32 *p_rotate;
-    const   Int32 *p_rotate_2;
-
-    Int32   *p_data_1;
-    Int32   *p_data_2;
-
-    Int32   temp_re32;
-    Int32   temp_im32;
-
-    Int     shift1 = 0;
-    Int32   temp1;
-    Int32   temp2;
-
-    Int     k;
-    Int     n_2   = n >> 1;
-    Int     n_4   = n >> 2;
-
-
-
-    if (max != 0)
-    {
-
-        switch (n)
-        {
-            case SHORT_WINDOW_TYPE:
-                p_rotate = exp_rotation_N_256;
-                shift = 21;           /* log2(n)-1 + 14 acomodates 2/N factor */
-                break;
-
-            case LONG_WINDOW_TYPE:
-                p_rotate = exp_rotation_N_2048;
-                shift = 24;           /* log2(n)-1 +14 acomodates 2/N factor */
-                break;
-
-            default:
-                /*
-                 * There is no defined behavior for a non supported frame
-                 * size. By returning a fixed scaling factor, the input will
-                 * scaled down and the will be heard as a low level noise
-                 */
-                return(ERROR_IN_FRAME_SIZE);
-
-        }
-
-        /*
-         *   p_data_1                                        p_data_2
-         *       |                                            |
-         *       RIRIRIRIRIRIRIRIRIRIRIRIRIRIRI....RIRIRIRIRIRI
-         *        |                                          |
-         *
-         */
-
-        p_data_1 =  data_quant;             /* uses first  half of buffer */
-        p_data_2 = &data_quant[n_2 - 1];    /* uses second half of buffer */
-
-        p_rotate_2 = &p_rotate[n_4-1];
-
-        shift1 = pv_normalize(max) - 1;     /* -1 to leave room for addition */
-        Q_format -= (16 - shift1);
-        max = 0;
-
-
-        if (shift1 >= 0)
-        {
-            temp_re32 =   *(p_data_1++) << shift1;
-            temp_im32 =   *(p_data_2--) << shift1;
-
-            for (k = n_4 >> 1; k != 0; k--)
-            {
-                /*
-                 *  Real and Imag parts have been swaped to use FFT as IFFT
-                 */
-                /*
-                 * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-                 */
-                exp_jw = *p_rotate++;
-
-                temp1      =  cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
-                temp2      = -cmplx_mul32_by_16(temp_re32,  temp_im32, exp_jw);
-
-                temp_im32 =   *(p_data_1--) << shift1;
-                temp_re32 =   *(p_data_2--) << shift1;
-                *(p_data_1++) = temp1;
-                *(p_data_1++) = temp2;
-                max         |= (temp1 >> 31) ^ temp1;
-                max         |= (temp2 >> 31) ^ temp2;
-
-
-                /*
-                 *  Real and Imag parts have been swaped to use FFT as IFFT
-                 */
-
-                /*
-                 * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-                 */
-
-                exp_jw = *p_rotate_2--;
-
-                temp1      =  cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
-                temp2      = -cmplx_mul32_by_16(temp_re32,  temp_im32, exp_jw);
-
-
-                temp_re32 =   *(p_data_1++) << shift1;
-                temp_im32 =   *(p_data_2--) << shift1;
-
-                *(p_data_2 + 2) = temp1;
-                *(p_data_2 + 3) = temp2;
-                max         |= (temp1 >> 31) ^ temp1;
-                max         |= (temp2 >> 31) ^ temp2;
-
-            }
-        }
-        else
-        {
-            temp_re32 =   *(p_data_1++) >> 1;
-            temp_im32 =   *(p_data_2--) >> 1;
-
-            for (k = n_4 >> 1; k != 0; k--)
-            {
-                /*
-                 *  Real and Imag parts have been swaped to use FFT as IFFT
-                 */
-                /*
-                 * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-                 */
-                exp_jw = *p_rotate++;
-
-                temp1      =  cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
-                temp2      = -cmplx_mul32_by_16(temp_re32,  temp_im32, exp_jw);
-
-                temp_im32 =   *(p_data_1--) >> 1;
-                temp_re32 =   *(p_data_2--) >> 1;
-                *(p_data_1++) = temp1;
-                *(p_data_1++) = temp2;
-
-                max         |= (temp1 >> 31) ^ temp1;
-                max         |= (temp2 >> 31) ^ temp2;
-
-
-                /*
-                 *  Real and Imag parts have been swaped to use FFT as IFFT
-                 */
-
-                /*
-                 * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-                 */
-                exp_jw = *p_rotate_2--;
-
-                temp1      =  cmplx_mul32_by_16(temp_im32, -temp_re32, exp_jw);
-                temp2      = -cmplx_mul32_by_16(temp_re32,  temp_im32, exp_jw);
-
-                temp_re32 =   *(p_data_1++) >> 1;
-                temp_im32 =   *(p_data_2--) >> 1;
-
-                *(p_data_2 + 3) = temp2;
-                *(p_data_2 + 2) = temp1;
-
-                max         |= (temp1 >> 31) ^ temp1;
-                max         |= (temp2 >> 31) ^ temp2;
-
-            }
-        }
-
-
-        if (n != SHORT_WINDOW_TYPE)
-        {
-
-            shift -= mix_radix_fft(data_quant,
-                                   &max);
-
-            shift -= inv_long_complex_rot(data_quant,
-                                          max);
-
-        }
-        else        /*  n_4 is 64 */
-        {
-
-            shift -= fft_rx4_short(data_quant,   &max);
-
-
-            shift -= inv_short_complex_rot(data_quant,
-                                           freq_2_time_buffer,
-                                           max);
-
-            pv_memcpy(data_quant,
-                      freq_2_time_buffer,
-                      SHORT_WINDOW*sizeof(*data_quant));
-        }
-
-    }
-    else
-    {
-        Q_format = ALL_ZEROS_BUFFER;
-    }
-
-    return(shift + Q_format);
-
-} /* imdct_fxp */
diff --git a/media/libstagefright/codecs/aacdec/imdct_fxp.h b/media/libstagefright/codecs/aacdec/imdct_fxp.h
deleted file mode 100644
index 5837750..0000000
--- a/media/libstagefright/codecs/aacdec/imdct_fxp.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: imdct_fxp.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: This extern had the incorrect length of the arrays.  The true
- lengths are 128 and 1024, not 64 and 512.
-
- Description:  Modified interface so a vector with extended precision is
-               returned, this is a 32 bit vector whose MSB 16 bits will be
-               extracted later.  Added copyright notice.
-
- Description:   Modified function interface to accomodate the normalization
-                that now is done in this function.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function imdct_fxp()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IMDCT_FXP_H
-#define IMDCT_FXP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-#define     LONG_WINDOW_TYPE  2048
-#define     SHORT_WINDOW_TYPE  256
-
-#define     ALL_ZEROS_BUFFER       31
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    extern const Int32 exp_rotation_N_256[64];
-    extern const Int32 exp_rotation_N_2048[512];
-    /*
-    extern const Int exp_rotation_N_256[128];
-    extern const Int exp_rotation_N_2048[1024];
-    */
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int imdct_fxp(
-        Int32   data_quant[],
-        Int32   freq_2_time_buffer[],
-        const   Int     n,
-        Int     Q_format,
-        Int32   max
-    );
-
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* IMDCT_FXP_H */
diff --git a/media/libstagefright/codecs/aacdec/infoinit.cpp b/media/libstagefright/codecs/aacdec/infoinit.cpp
deleted file mode 100644
index 7bdcdcd..0000000
--- a/media/libstagefright/codecs/aacdec/infoinit.cpp
+++ /dev/null
@@ -1,355 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: infoinit.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Pass eight_short_info and the array 'sfbwidth128'.
-               Change function arguments' names for clarity
-
- Description:  move sfb definitions to "sfb.h", and "sfb.c", eliminated
-               the function "huffbookinit.c"
-
- Description:  Remove initialization of the never used array,
-               pFrameInfo->group_offs
-
- Description:
- (1) Changed "stdinc.h" to <stdlib.h> - this avoids linking in the math
- library and stdio.h.  (All for just defining the NULL pointer macro)
-
- (2) Updated copyright header.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Addresses of constant vectors are now found by means of a
-              switch statement, this solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers
-
- Who:                               Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pSi              = pointer to sampling rate info
-    ppWin_seq_info   = pointer array to window sequence Info struct
-    pSfbwidth128     = pointer to sfb bandwidth array of short window
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
-    ppWin_seq_info[ONLY_LONG_WINDOW]{all structure members} = setup values
-    ppWin_seq_info[EIGHT_SHORT_WINDOW]{all structure members} = setup values
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function sets the values of 'Info' structure for blocks containing long
- and short window sequences, the following structures are being set:
-
- win_seq_info[ONLY_LONG_WINDOW], win_seq_info[EIGHT_SHORT_WINDOW],
- only_long_info and eight_short_info
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
- (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 4       p66     (sfb tables)
-                    p111    (4.6.10)
-                    p200    (Annex 4.B.5)
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pFrameInfo  =   pointer to only_long_info;
-    win_seq_info[ONLY_LONG_WINDOW]  =   pFrameInfo;
-    pFrameInfo{all structure members} = setup values;
-
-
-    pFrameInfo  =   pointer to eight_short_info;
-    win_seq_info[EIGHT_SHORT_WINDOW]  =   pFrameInfo;
-    pFrameInfo{all structure.members} =   setup values;
-
-
-    FOR (window_seq = 0; window_seq < NUM_WIN_SEQ; win_seq++)
-
-        win_seq_info[window_seq].members = setup values;
-
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE:
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES:
-
-------------------------------------------------------------------------------
-*/
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sr_info.h"
-#include    "s_frameinfo.h"
-#include    "e_blockswitching.h"
-#include    "e_huffmanconst.h"
-#include    "sfb.h"
-#include    "huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int infoinit(
-    const Int samp_rate_idx,
-    FrameInfo   **ppWin_seq_info,
-    Int    *pSfbwidth128)
-
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-
-    Int     i;
-    Int     sfb_idx, sfb_sbk;
-    Int     bins_sbk;
-    Int     win_seq;
-    Int     start_idx, end_idx;
-    Int     nsfb_short;
-    Int16   *sfbands;
-    FrameInfo    *pFrameInfo;
-
-    const SR_Info *pSi = &(samp_rate_info[samp_rate_idx]);
-
-    const Int16 * pt_SFbands1024 = NULL;
-    const Int16 * pt_SFbands128  = NULL;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-
-    switch (pSi->samp_rate)
-    {
-        case 96000:
-        case 88200:
-            pt_SFbands1024  = sfb_96_1024;
-            pt_SFbands128   = sfb_64_128;  /* equal to table sfb_96_128, (eliminated) */
-            break;
-        case 64000:
-            pt_SFbands1024  = sfb_64_1024;
-            pt_SFbands128   = sfb_64_128;
-            break;
-        case 48000:
-        case 44100:
-            pt_SFbands1024  = sfb_48_1024;
-            pt_SFbands128   = sfb_48_128;
-            break;
-        case 32000:
-            pt_SFbands1024  = sfb_32_1024;
-            pt_SFbands128   = sfb_48_128;
-            break;
-        case 24000:
-        case 22050:
-            pt_SFbands1024  = sfb_24_1024;
-            pt_SFbands128   = sfb_24_128;
-            break;
-        case 16000:
-        case 12000:
-        case 11025:
-            pt_SFbands1024  = sfb_16_1024;
-            pt_SFbands128   = sfb_16_128;
-            break;
-        case 8000:
-            pt_SFbands1024  = sfb_8_1024;
-            pt_SFbands128   = sfb_8_128;
-            break;
-        default:
-            // sampling rate not supported
-            return -1;
-    }
-
-    /* long block info */
-
-    pFrameInfo = ppWin_seq_info[ONLY_LONG_WINDOW];
-    pFrameInfo->islong               = 1;
-    pFrameInfo->num_win              = 1;
-    pFrameInfo->coef_per_frame       = LN2; /* = 1024 */
-
-    pFrameInfo->sfb_per_win[0]  = pSi->nsfb1024;
-    pFrameInfo->sectbits[0]     = LONG_SECT_BITS;
-    pFrameInfo->win_sfb_top[0]  = (Int16 *)pt_SFbands1024;
-
-    pFrameInfo->sfb_width_128 = NULL; /* no short block sfb */
-    pFrameInfo->num_groups    = 1; /* long block, one group */
-    pFrameInfo->group_len[0]  = 1; /* only one window */
-
-    /* short block info */
-    pFrameInfo = ppWin_seq_info[EIGHT_SHORT_WINDOW];
-    pFrameInfo->islong                  = 0;
-    pFrameInfo->num_win                 = NSHORT;
-    pFrameInfo->coef_per_frame          = LN2;
-
-    for (i = 0; i < pFrameInfo->num_win; i++)
-    {
-        pFrameInfo->sfb_per_win[i] = pSi->nsfb128;
-        pFrameInfo->sectbits[i]    = SHORT_SECT_BITS;
-        pFrameInfo->win_sfb_top[i] = (Int16 *)pt_SFbands128;
-    }
-
-    /* construct sfb width table */
-    pFrameInfo->sfb_width_128 = pSfbwidth128;
-    for (i = 0, start_idx = 0, nsfb_short = pSi->nsfb128; i < nsfb_short; i++)
-    {
-        end_idx = pt_SFbands128[i];
-        pSfbwidth128[i] = end_idx - start_idx;
-        start_idx = end_idx;
-    }
-
-
-    /* common to long and short */
-    for (win_seq = 0; win_seq < NUM_WIN_SEQ; win_seq++)
-    {
-
-        if (ppWin_seq_info[win_seq] != NULL)
-        {
-            pFrameInfo                 = ppWin_seq_info[win_seq];
-            pFrameInfo->sfb_per_frame  = 0;
-            sfb_sbk                    = 0;
-            bins_sbk                   = 0;
-
-            for (i = 0; i < pFrameInfo->num_win; i++)
-            {
-
-                /* compute coef_per_win */
-                pFrameInfo->coef_per_win[i] =
-                    pFrameInfo->coef_per_frame / pFrameInfo->num_win;
-
-                /* compute sfb_per_frame */
-                pFrameInfo->sfb_per_frame += pFrameInfo->sfb_per_win[i];
-
-                /* construct default (non-interleaved) bk_sfb_top[] */
-                sfbands = pFrameInfo->win_sfb_top[i];
-                for (sfb_idx = 0; sfb_idx < pFrameInfo->sfb_per_win[i];
-                        sfb_idx++)
-                {
-                    pFrameInfo->frame_sfb_top[sfb_idx+sfb_sbk] =
-                        sfbands[sfb_idx] + bins_sbk;
-                }
-
-                bins_sbk += pFrameInfo->coef_per_win[i];
-                sfb_sbk  += pFrameInfo->sfb_per_win[i];
-            } /* for i = sbk ends */
-        }
-
-    } /* for win_seq ends */
-
-    return SUCCESS;
-
-} /* infoinit */
diff --git a/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp b/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp
deleted file mode 100644
index fc47dd3..0000000
--- a/media/libstagefright/codecs/aacdec/init_sbr_dec.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: init_sbr_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        initializes sbr decoder structure
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "init_sbr_dec.h"
-#include    "aac_mem_funcs.h"
-#include    "extractframeinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 init_sbr_dec(Int32 codecSampleRate,
-                   Int   upsampleFac,
-                   SBR_DEC *sbrDec,
-                   SBR_FRAME_DATA *hFrameData)
-{
-    Int32 outFrameSize;
-    Int32 coreCodecFrameSize = 1024;
-#ifdef HQ_SBR
-    Int32 i;
-#endif
-
-
-    sbrDec->sbStopCodec    =  upsampleFac << 5;
-    sbrDec->prevLowSubband =  upsampleFac << 5;
-
-
-    /* set sbr sampling frequency */
-    sbrDec->outSampleRate = 2 * codecSampleRate;
-    outFrameSize = upsampleFac * coreCodecFrameSize;
-
-    hFrameData->nSfb[LO] = 0;    /* number of scale factor bands for high resp.low frequency resolution */
-    hFrameData->nSfb[HI] = 0;
-    hFrameData->offset   = 0;
-
-    hFrameData->nNfb = hFrameData->sbr_header.noNoiseBands;
-    hFrameData->prevEnvIsShort = -1;
-
-    /* Initializes pointers */
-#ifdef HQ_SBR
-    for (i = 0; i < 5; i++)
-    {
-        hFrameData->fBuf_man[i]  = hFrameData->fBuffer_man[i];
-        hFrameData->fBufN_man[i] = hFrameData->fBufferN_man[i];
-        hFrameData->fBuf_exp[i]  = hFrameData->fBuffer_exp[i];
-        hFrameData->fBufN_exp[i] = hFrameData->fBufferN_exp[i];
-    }
-#endif
-
-
-    pv_memset((void *)hFrameData->sbr_invf_mode_prev,
-              0,
-              MAX_NUM_NOISE_VALUES*sizeof(INVF_MODE));
-
-    /* Direct assignments */
-
-    sbrDec->noCols = 32;
-
-    sbrDec->bufWriteOffs = 6 + 2;
-    sbrDec->bufReadOffs  = 2;
-    sbrDec->qmfBufLen = sbrDec->noCols + sbrDec->bufWriteOffs;
-
-    sbrDec->lowBandAddSamples = 288;
-
-    sbrDec->startIndexCodecQmf = 0;
-
-    sbrDec->lowSubband =  32;
-
-
-    return outFrameSize;
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/init_sbr_dec.h b/media/libstagefright/codecs/aacdec/init_sbr_dec.h
deleted file mode 100644
index 844fa0e..0000000
--- a/media/libstagefright/codecs/aacdec/init_sbr_dec.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: init_sbr_dec.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INIT_SBR_DEC_H
-#define INIT_SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "sbr_dec.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int32 init_sbr_dec(Int32 codecSampleRate,
-                   Int  upsampleFac,
-                   SBR_DEC *sbrDec,
-                   SBR_FRAME_DATA *hFrameData);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/intensity_right.cpp b/media/libstagefright/codecs/aacdec/intensity_right.cpp
deleted file mode 100644
index 106298a..0000000
--- a/media/libstagefright/codecs/aacdec/intensity_right.cpp
+++ /dev/null
@@ -1,457 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: intensity_right.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments.
-
- Description: Noticed that the code could be more efficient by
- using some other method for storing the sign.  The code was changed to
- use a signed Int to store the table, and an adjustment of the q-format to
- reflect the difference between the data being shifted by 16 and the table
- being stored in q-15 format.
-
- Description: Updated pseudocode
-
- Description: When the multiplication of two 16-bits variables is stored in
-              an 32-bits variable, the result should be typecasted explicitly
-              to Int32 before it is stored.
-              *(pCoefRight++) = (Int32) tempInt2 * multiplier;
-
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    scalefactor  =  Multiplier used to scale the data extracted from the left
-                    channel for use on the right.
-                    [const Int]
-
-    coef_per_win =  Number of coefficients per window.
-                    (128 for short, 1024 for long)
-                    [const Int]
-
-    sfb_per_win  =  Number of scalefactor bands per window.  This should be
-                    a number divisible by four.
-                    [const Int]
-
-    wins_in_group = The number of windows in the group being decoded.
-                    This number falls within the range 1-8.
-                    [const Int]
-
-    band_length  =  The length of the scalefactor band being decoded.
-                    This value is divisible by 4.
-                    [const Int]
-
-    codebook     =  Value that denotes which Huffman codebook was used for
-                    the encoding of this grouped scalefactor band.
-                    [const Int]
-
-    ms_used      =  Flag that denotes whether M/S is active for this band.
-                    [const Bool]
-
-    q_formatLeft = The Q-format for the left channel's fixed-point spectral
-                   coefficients, on a per-scalefactor band, non-grouped basis.
-                   [const Int *, length MAXBANDS]
-
-    q_formatRight = The Q-format for the right channel's fixed-point spectral
-                    coefficients, on a per-scalefactor band, non-grouped basis.
-                    [Int *, length MAXBANDS]
-
-    coefLeft =  Array containing the fixed-point spectral coefficients
-                for the left channel.
-                [const Int32 *, length 1024]
-
-    coefRight = Array containing the fixed-point spectral coefficients
-                for the right channel.
-                [Int32 *, length 1024]
-
- Local Stores/Buffers/Pointers Needed:
-    intensity_factor =  Table which stores the values of
-                        0.5^(0), 0.5^(1/4), 0.5^(2/4) and 0.5^(3/4)
-                        [UInt, length 4]
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coefRight[]         Contains the new spectral information
-
-    q_formatRight[]     Q-format may be updated with changed fixed-point
-                        data in coefRight.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function applies Intensity Stereo, generating data on the right channel
- that is derived from data on the Left.  A scalefactor is applied using the
- following formula...
-
- RightCh = LeftCh*0.5^(scalefactor/4)
-
- This function works for one scalefactor band, which may belong to a group.
- (i.e. the same scalefactor band repeated across multiple windows belonging
-  to one group.)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- codebook must be either INTENSITY_HCB or INTENSITY_HCB2 when this function
- is called.
-
- ms_used must be 1 when TRUE, 0 when FALSE.
-
- wins_in_group falls within the range [1-8]
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo)
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-    multiplier = codebook AND 0x1;
-
-    multiplier = multiplier XOR ms_used;
-
-    multiplier = multiplier << 1;
-
-    multiplier = multiplier - 1;
-
-    multiplier = multiplier * intensity_factor[scalefactor & 0x3];
-
-    scf_div_4 = (scalefactor >> 2);
-
-    nextWinPtrUpdate = (coef_per_win - band_length);
-
-    FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
-        *(pQformatRight) = scf_div_4 + *(pQformatLeft) - 1;
-
-        FOR (tempInt = band_length; tempInt > 0; tempInt--)
-           tempInt2 = (Int)(*(pCoefLeft) >> 16);
-
-           *(pCoefRight) = tempInt2 * multiplier;
-
-           pCoefRight = pCoefRight + 1;
-           pCoefLeft  = pCoefLeft  + 1;
-
-        ENDFOR
-
-        pCoefRight = pCoefRight + nextWinPtrUpdate;
-        pCoefLeft  = pCoefLeft + nextWinPtrUpdate;
-
-        pQformatRight = pQformatRight + sfb_per_win;
-        pQformatLeft  = pQformatLeft  + sfb_per_win;
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-   resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "intensity_right.h"
-#include "e_huffmanconst.h"
-
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int16 intensity_factor[4] =
-{
-    32767,  /* (0.5^0.00)*2^15 - 1 (minus 1 for storage as type Int) */
-    27554,  /* (0.5^0.25)*2^15 */
-    23170,  /* (0.5^0.50)*2^15 */
-    19484
-}; /* (0.5^0.75)*2^15 */
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void intensity_right(
-    const Int   scalefactor,
-    const Int   coef_per_win,
-    const Int   sfb_per_win,
-    const Int   wins_in_group,
-    const Int   band_length,
-    const Int   codebook,
-    const Bool  ms_used,
-    const Int   q_formatLeft[],
-    Int   q_formatRight[],
-    const Int32 coefLeft[],
-    Int32 coefRight[])
-
-{
-    const Int32 *pCoefLeft  = coefLeft;
-    Int32 *pCoefRight = coefRight;
-
-    const Int *pQformatLeft  = q_formatLeft;
-    Int *pQformatRight = q_formatRight;
-
-    Int   multiplier;
-    Int   scf_div_4;
-    Int   nextWinPtrUpdate;
-
-    /*
-     * The sign of the intensity multiplier obeys the following table...
-     *
-     * codebook       | ms_used | multiplier
-     * --------------------------------------
-     * INTENSITY_HCB  | TRUE    |    -1
-     * INTENSITY_HCB  | FALSE   |    +1
-     * INTENSITY_HCB2 | TRUE    |    +1
-     * INTENSITY_HCB2 | FALSE   |    -1
-     *
-     * In binary, the above table is represented as...
-     *
-     * codebook       | ms_used | multiplier
-     * --------------------------------------
-     * 1111b          | 1       |    -1
-     * 1111b          | 0       |    +1
-     * 1110b          | 1       |    +1
-     * 1110b          | 0       |    -1
-     *
-     */
-
-    /*
-     * Deriving the correct value for "multiplier" is illustrated
-     * below for all 4 possible combinations of codebook and ms_used
-     */
-
-    /*
-     * 1111b AND 0x1 = 1b
-     * 1111b AND 0x1 = 1b
-     * 1110b AND 0x1 = 0b
-     * 1110b AND 0x1 = 0b
-     */
-    multiplier  = (codebook & 0x1);
-
-    /*
-     * 1b XOR 1 = 0b
-     * 1b XOR 0 = 1b
-     * 0b XOR 1 = 1b
-     * 0b XOR 0 = 0b
-     */
-    multiplier ^= ms_used;
-
-    /*
-     * 0b << 1 = 0
-     * 1b << 1 = 2
-     * 1b << 1 = 2
-     * 0b << 1 = 0
-     */
-    multiplier <<= 1;
-
-    /*
-     * 0 - 1 = -1
-     * 2 - 1 = +1
-     * 2 - 1 = +1
-     * 0 - 1 = -1
-     */
-    multiplier--;
-
-    multiplier *= intensity_factor[scalefactor & 0x3];
-
-    scf_div_4 = (scalefactor >> 2);
-
-    /*
-     * Step through all the windows in this group, replacing this
-     * band in each window's spectrum with
-     * left-channel correlated data
-     */
-
-    nextWinPtrUpdate = (coef_per_win - band_length);
-
-    for (Int win_indx = wins_in_group; win_indx > 0; win_indx--)
-    {
-
-        /*
-         * Calculate q_formatRight
-         *
-         * q_formatLeft must be included, since the values
-         * on the right-channel are derived from the values
-         * on the left-channel.
-         *
-         * scalefactor/4 is included, since the intensity
-         * formula is RightCh = LeftCh*0.5^(scalefactor/4)
-         *
-         * powers of 0.5 increase the q_format by 1.
-         * (Another way to multiply something by 0.5^(x)
-         *  is to increase its q-format by x.)
-         *
-         * Finally the q-format must be decreased by 1.
-         * The reason for this is because the table is stored
-         * in q-15 format, but we are shifting by 16 to do
-         * a 16 x 16 multiply.
-         */
-
-        *(pQformatRight) = scf_div_4 + *(pQformatLeft);
-
-        /*
-         * reconstruct right intensity values
-         *
-         * to make things faster, this for loop
-         * can be partially unrolled, since band_length is a multiple
-         * of four.
-         */
-
-
-        if (multiplier == 32767)
-        {
-            Int32 tempInt2 = *(pCoefLeft++);
-            Int32 tempInt22 = *(pCoefLeft++);
-
-            for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--)
-            {
-                *(pCoefRight++) = tempInt2;
-                *(pCoefRight++) = tempInt22;
-                tempInt2 = *(pCoefLeft++);
-                tempInt22 = *(pCoefLeft++);
-            }
-
-        }
-        else
-        {
-
-            Int32 tempInt2 = *(pCoefLeft++);
-            Int32 tempInt22 = *(pCoefLeft++);
-            for (Int tempInt = band_length >> 1; tempInt > 0; tempInt--)
-            {
-                *(pCoefRight++) = fxp_mul32_by_16(tempInt2, multiplier) << 1;
-                *(pCoefRight++) = fxp_mul32_by_16(tempInt22, multiplier) << 1;
-                tempInt2 = *(pCoefLeft++);
-                tempInt22 = *(pCoefLeft++);
-            }
-        }
-
-        /*
-         * Set pCoefRight and pCoefLeft to the beginning of
-         * this sfb in the next window in the group.
-         */
-
-        pCoefRight += nextWinPtrUpdate;
-        pCoefLeft  += (nextWinPtrUpdate - 2);
-
-        /*
-         * Update pQformatRight and pQformatLeft to this sfb in
-         * in the next window in the group.
-         */
-
-        pQformatRight += sfb_per_win;
-        pQformatLeft  += sfb_per_win;
-
-    } /* for (win_indx) */
-
-
-} /* void intensity_right */
diff --git a/media/libstagefright/codecs/aacdec/intensity_right.h b/media/libstagefright/codecs/aacdec/intensity_right.h
deleted file mode 100644
index 823da07..0000000
--- a/media/libstagefright/codecs/aacdec/intensity_right.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: intensity_right.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change ms_used from Int to Bool
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function definitions for intensity_right
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INTENSITY_RIGHT_H
-#define INTENSITY_RIGHT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void intensity_right(
-    const Int   scalefactor,
-    const Int   coef_per_win,
-    const Int   sfb_per_win,
-    const Int   wins_in_group,
-    const Int   band_length,
-    const Int   codebook,
-    const Bool  ms_used,
-    const Int   q_formatLeft[],
-    Int   q_formatRight[],
-    const Int32 coefLeft[],
-    Int32 coefRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp b/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp
deleted file mode 100644
index 84a7ec8..0000000
--- a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.cpp
+++ /dev/null
@@ -1,408 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: .inv_long_complex_rot.c
- Funtions:  inv_long_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Change the input argument, no shifts information from long fft_rx4
-               , do not have to check for shifts.
-
- Date: 10/18/2002
- Description:
-            (1) Change the input argument, only a single max is passed.
-            (2) Eliminate search for max, a fixed shift has replaced the
-                search for max with minimal loss of precision.
-            (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
-            (1) Added comments per code review
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    Data_in   = Input vector (sized for long windows
-                TWICE_INV_LONG_CX_ROT_LENGTH), with time domain samples
-                type Int32 *
-
-    Data_out  = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)),
-                (sized for long windows TWICE_INV_LONG_CX_ROT_LENGTH)
-                type Int32 *
-
-    max       = Input, carries the maximum value of the input vector
-                "Data_in"
-                type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
-    Results are return in "Data_out"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    inv_long_complex_rot() performs the complex rotation for the inverse MDCT
-    for the case of long windows. It also performs digit reverse ordering of
-    the first and second halves of the input vector "Data_in", as well as
-    reordering of the two half vectors (following radix-2 decomposition)
-    Word normalization is also done to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    inv_long_complex_rot() should execute a post-rotation by
-    exp(-j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "inv_long_complex_rot.h"
-#include "imdct_fxp.h"
-#include "inv_long_complex_rot.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-
-Int inv_long_complex_rot(
-    Int32 *Data,
-    Int32  max)
-{
-    Int     i;
-    Int16     I;
-    const   Int32 *p_rotate;
-    Int32   temp_re;
-    Int32   temp_im;
-
-    Int32    exp_jw;
-    Int32   *pData_in_1;
-    Int32   *pData_in_2;
-    Int     exp;
-    Int32   *pData_in_ref1;
-    Int32   *pData_in_ref2;
-
-
-    Int16   temp_re_0;
-    Int16   temp_im_0;
-    Int16   temp_re_1;
-    Int16   temp_im_1;
-    Int16   *p_Data_Int_precision;
-    Int     n     = 2048;
-    Int     n_2   = n >> 1;
-    Int     n_4   = n >> 2;
-    Int     n_3_4 = n_2 + n_4;
-
-    Int16   *px_1;
-    Int16   *px_2;
-    Int16   *px_3;
-    Int16   *px_4;
-
-    Int16     J;
-    const   Int32 *p_rotate2;
-
-
-
-
-    p_rotate    =  &exp_rotation_N_2048[255];
-    p_rotate2   =  &exp_rotation_N_2048[256];
-
-    pData_in_ref1  =  Data;
-    pData_in_ref2  = &Data[TWICE_INV_LONG_CX_ROT_LENGTH];
-
-
-    /*
-     *  Apply  A/2^(diff) + B
-     */
-
-    p_Data_Int_precision = (Int16 *)Data;
-
-    exp = 16 - pv_normalize(max);
-
-
-    /*
-     *        px2-->               <--px1 px4-->               <--px3
-     *
-     *                     |                           |             |
-     *       |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++|
-     *                     |             |             |             |
-     *                    n/4           n/2          3n/4
-     */
-
-    I = 255;
-    J = 256;
-
-    pData_in_1 = pData_in_ref2 + I;
-
-    px_1 = (Int16 *)pData_in_1;
-    px_1++;
-
-    pData_in_2 = pData_in_ref2 + J;
-
-    px_4 = (Int16 *)pData_in_2;
-
-
-
-    exp -= 1;
-
-
-    for (i = INV_LONG_CX_ROT_LENGTH >> 1; i != 0; i--)
-    {
-
-        pData_in_2 = pData_in_ref1 + J;
-
-        temp_im =  *(pData_in_2++);
-        temp_re =  *(pData_in_2);
-
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-        exp_jw = *p_rotate2++;
-
-        /*
-         *   Post-rotation
-         */
-
-
-
-        temp_re_0  = (Int16)(cmplx_mul32_by_16(temp_re,  -temp_im,  exp_jw) >> exp);
-        temp_im_0  = (Int16)(cmplx_mul32_by_16(temp_im,   temp_re,  exp_jw) >> exp);
-
-
-        pData_in_1 = pData_in_ref2 + I;
-
-        /*
-         *  Use auxiliary variables to avoid double accesses to memory.
-         *  Data in is scaled to use only lower 16 bits.
-         */
-
-        temp_re =  *(pData_in_1--);
-        temp_im =  *(pData_in_1);
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-        exp_jw = *p_rotate--;
-
-
-        /*
-         *   Post-rotation
-         */
-
-        temp_re_1  = (Int16)(cmplx_mul32_by_16(temp_re,  -temp_im,  exp_jw) >> exp);
-        temp_im_1  = (Int16)(cmplx_mul32_by_16(temp_im,   temp_re,  exp_jw) >> exp);
-
-
-        /*
-         *   Repeat procedure for odd index at the output
-         */
-
-        pData_in_2 = pData_in_ref2 + J;
-        J += 2;
-
-        temp_im =  *(pData_in_2++);
-        temp_re =  *(pData_in_2);
-
-
-        *(px_1--) =  temp_re_0;
-        *(px_1--) =  temp_im_1;
-        *(px_4++) =  temp_im_0;
-        *(px_4++) =  temp_re_1;
-
-
-        exp_jw = *p_rotate2++;
-
-
-        *(px_1--)  = (Int16)(cmplx_mul32_by_16(temp_re,  -temp_im,  exp_jw) >> exp);
-        *(px_4++)  = (Int16)(cmplx_mul32_by_16(temp_im,   temp_re,  exp_jw) >> exp);
-
-
-
-        /*
-         *   Repeat procedure for odd index at the output
-         */
-
-        pData_in_1 = pData_in_ref1 + I;
-        I -= 2;
-
-        temp_re =  *(pData_in_1--);
-        temp_im =  *(pData_in_1);
-
-
-        exp_jw = *p_rotate--;
-
-
-        *(px_4++)  = (Int16)(cmplx_mul32_by_16(temp_re,  -temp_im,  exp_jw) >> exp);
-        *(px_1--)  = (Int16)(cmplx_mul32_by_16(temp_im,   temp_re,  exp_jw) >> exp);
-
-    }
-
-    /*
-     *                                           <--px1 px4-->
-     *
-     *                     |                           |             |
-     *       |-------------|-------------|/////////////|\\\\\\\\\\\\\|
-     *                     |             |             |             |
-     *                    n/4           n/2          3n/4
-     */
-
-
-    px_1 = p_Data_Int_precision + n_2 - 1;
-    px_2 = p_Data_Int_precision;
-
-    px_4 = p_Data_Int_precision + n_3_4 - 1;
-
-    for (i = 0; i<INV_LONG_CX_ROT_LENGTH >> 1; i++)
-    {
-
-        Int16 temp_re_0 = *(px_4--);
-        Int16 temp_im_1 = *(px_4--);
-        Int16 temp_re_2 = *(px_4--);
-        Int16 temp_im_3 = *(px_4--);
-        *(px_1--) = temp_re_0;
-        *(px_1--) = temp_im_1;
-        *(px_1--) = temp_re_2;
-        *(px_1--) = temp_im_3;
-
-        *(px_2++) = (-temp_re_0);
-        *(px_2++) = (-temp_im_1);
-        *(px_2++) = (-temp_re_2);
-        *(px_2++) = (-temp_im_3);
-
-    }
-
-
-    px_4 = p_Data_Int_precision + n_2;
-
-
-    pv_memcpy(px_4, pData_in_ref2 + 256, TWICE_INV_LONG_CX_ROT_LENGTH*sizeof(*px_4));
-
-
-
-    /*
-     *        px2-->               <--px1 px4-->               <--px3
-     *
-     *                     |                           |             |
-     *       |+++++++++++++|+++++++++++++|+++++++++++++|+++++++++++++|
-     *                     |             |             |             |
-     *                    n/4           n/2          3n/4
-     */
-    px_3 = p_Data_Int_precision + n - 1;
-
-
-    for (i = 0; i<INV_LONG_CX_ROT_LENGTH >> 1; i++)
-    {
-
-        Int16 temp_im_0 = *(px_4++);
-        Int16 temp_re_1 = *(px_4++);
-        Int16 temp_im_2 = *(px_4++);
-        Int16 temp_re_3 = *(px_4++);
-        *(px_3--) =  temp_im_0;
-        *(px_3--) =  temp_re_1;
-        *(px_3--) =  temp_im_2;
-        *(px_3--) =  temp_re_3;
-
-    }
-
-
-    return (exp + 1);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h b/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h
deleted file mode 100644
index 8b95867..0000000
--- a/media/libstagefright/codecs/aacdec/inv_long_complex_rot.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_long_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function inv_long_complex_rot()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INV_LONG_COMPLEX_ROT_H
-#define INV_LONG_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define INV_LONG_CX_ROT_LENGTH          256
-#define TWICE_INV_LONG_CX_ROT_LENGTH (INV_LONG_CX_ROT_LENGTH<<1)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int inv_long_complex_rot(
-        Int32 *Data,
-        Int32  max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* INV_LONG_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp b/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp
deleted file mode 100644
index 5b4f1c5..0000000
--- a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.cpp
+++ /dev/null
@@ -1,305 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_short_complex_rot.c
- Funtions:  inv_short_complex_rot
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Date: 10/18/2002
- Description:
-            (1) Change the input argument, only a single max is passed.
-            (2) Eliminate search for max, a fixed shift has replaced the
-                search for max with minimal loss of precision.
-            (3) Eliminated unused variables
-
- Date: 10/28/2002
- Description:
-            (1) Added comments per code review
-            (2) Eliminated hardly used condition on if-else (exp==0)
-
- Description:
-
- ------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    Data_in   = Input vector (sized for short windows
-                2*INV_SHORT_CX_ROT_LENGTH elements), with time domain samples
-                type Int32 *
-
-    Data_out  = Output vector with a post-rotation by exp(j(2pi/N)(k+1/8)),
-                (sized for short windows 2*INV_SHORT_CX_ROT_LENGTH)
-                type Int32 *
-
-    max       = Input, carries the maximum value of the input vector
-                "Data_in"
-                type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exp = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
-    Results are return in "Data_out"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    inv_short_complex_rot() performs the complex rotation for the inverse MDCT
-    for the case of short windows. It performs digit reverse ordering as well
-    word normalization to ensure 16 by 16 bit multiplications.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    inv_short_complex_rot() should execute a post-rotation by
-    exp( j(2pi/N)(k+1/8)), digit reverse ordering and word normalization
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "digit_reversal_tables.h"
-#include "imdct_fxp.h"
-#include "inv_short_complex_rot.h"
-#include "pv_normalize.h"
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-Int inv_short_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max)
-
-{
-    Int     i;
-    Int16     I;
-    const   Int16 *pTable;
-    const   Int32 *p_rotate;
-
-    Int32   *pData_in_1;
-    Int     exp;
-    Int32   temp_re;
-    Int32   temp_im;
-
-    Int32   exp_jw;
-    Int16   *pData_re;
-    Int16   *pData_im;
-    Int32   *pData_in_ref;
-
-    Int16   temp_re_0;
-    Int16   temp_im_0;
-    Int16   temp_re_1;
-    Int16   temp_im_1;
-    Int16   *p_data_1;
-    Int16   *p_data_2;
-    Int16   *p_Data_Int_precision;
-    Int16   *p_Data_Int_precision_1;
-    Int16   *p_Data_Int_precision_2;
-
-    Int     n     = 256;
-    Int     n_2   = n >> 1;
-    Int     n_4   = n >> 2;
-    Int     n_8   = n >> 3;
-    Int     n_3_4 = n_2 + n_4;
-
-
-    p_data_1 = (Int16 *)Data_out;
-    p_data_1 += n;
-    pData_re  = p_data_1;
-    pData_im  = p_data_1 + n_4;
-
-
-    p_rotate  =  exp_rotation_N_256;
-    pTable    =  digit_reverse_64;
-
-    pData_in_ref  =  Data_in;
-
-    exp = 16 - pv_normalize(max);
-
-
-    if (exp < 0)
-    {
-        exp = 0;
-    }
-
-    exp -= 1;
-
-    for (i = INV_SHORT_CX_ROT_LENGTH; i != 0; i--)
-    {
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-
-        /*
-         *   Perform digit reversal by accessing index I from table
-         */
-
-        I = *pTable++;
-        pData_in_1 = pData_in_ref + I;
-        /*
-         *  Use auxiliary variables to avoid double accesses to memory.
-         *  Data in is scaled to use only lower 16 bits.
-         */
-
-        temp_im =  *(pData_in_1++);
-        temp_re =  *(pData_in_1);
-
-        exp_jw = *p_rotate++;
-
-        /*
-         *   Post-rotation
-         */
-
-        *(pData_re++)  = (Int16)(cmplx_mul32_by_16(temp_re, -temp_im, exp_jw) >> exp);
-        *(pData_im++)  = (Int16)(cmplx_mul32_by_16(temp_im,  temp_re, exp_jw) >> exp);
-    }
-
-
-    p_data_2 = pData_im -  1;
-
-
-    p_Data_Int_precision = (Int16 *)Data_out;
-    p_Data_Int_precision_1 = p_Data_Int_precision + n_3_4 - 1;
-    p_Data_Int_precision_2 = p_Data_Int_precision + n_3_4;
-
-    for (i = n_8 >> 1; i != 0; i--)
-    {
-        temp_re_0 = (*(p_data_1++));
-        temp_re_1 = (*(p_data_1++));
-        temp_im_0 = (*(p_data_2--));
-        temp_im_1 = (*(p_data_2--));
-
-        *(p_Data_Int_precision_1--) =  temp_re_0;
-        *(p_Data_Int_precision_1--) =  temp_im_0;
-        *(p_Data_Int_precision_1--) =  temp_re_1;
-        *(p_Data_Int_precision_1--) =  temp_im_1;
-
-        *(p_Data_Int_precision_2++) =  temp_re_0;
-        *(p_Data_Int_precision_2++) =  temp_im_0;
-        *(p_Data_Int_precision_2++) =  temp_re_1;
-        *(p_Data_Int_precision_2++) =  temp_im_1;
-
-    }
-
-
-    /*
-     *  loop is split to avoid conditional testing inside loop
-     */
-
-    p_Data_Int_precision_2 = p_Data_Int_precision;
-
-    for (i = n_8 >> 1; i != 0; i--)
-    {
-
-        temp_re_0 = (*(p_data_1++));
-        temp_re_1 = (*(p_data_1++));
-        temp_im_0 = (*(p_data_2--));
-        temp_im_1 = (*(p_data_2--));
-
-        *(p_Data_Int_precision_1--) =   temp_re_0;
-        *(p_Data_Int_precision_1--) =   temp_im_0;
-        *(p_Data_Int_precision_1--) =   temp_re_1;
-        *(p_Data_Int_precision_1--) =   temp_im_1;
-
-        *(p_Data_Int_precision_2++) = (Int16)(-temp_re_0);
-        *(p_Data_Int_precision_2++) = (Int16)(-temp_im_0);
-        *(p_Data_Int_precision_2++) = (Int16)(-temp_re_1);
-        *(p_Data_Int_precision_2++) = (Int16)(-temp_im_1);
-
-    }
-
-    return (exp + 1);
-}
diff --git a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h b/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h
deleted file mode 100644
index 97ed730..0000000
--- a/media/libstagefright/codecs/aacdec/inv_short_complex_rot.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: inv_short_complex_rot.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions inv_short_complex_rot()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef INV_SHORT_COMPLEX_ROT_H
-#define INV_SHORT_COMPLEX_ROT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define INV_SHORT_CX_ROT_LENGTH 64
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-Int inv_short_complex_rot(
-    Int32 *Data_in,
-    Int32 *Data_out,
-    Int32  max);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* INV_SHORT_COMPLEX_ROT_H */
diff --git a/media/libstagefright/codecs/aacdec/iquant_table.cpp b/media/libstagefright/codecs/aacdec/iquant_table.cpp
deleted file mode 100644
index aee47d6..0000000
--- a/media/libstagefright/codecs/aacdec/iquant_table.cpp
+++ /dev/null
@@ -1,1131 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: iquant_table.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- None, just contains tables.
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Holds a table used for esc_iquant, containing the values of x^1/3 in
- Q format.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7:1997 Titled "Information technology - Generic coding
-   of moving pictures and associated audio information - Part 7: Advanced
-   Audio Coding (AAC)", Section 10.3, "Decoding process", page 43.
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
- None.
-
-------------------------------------------------------------------------------
- RESOURCES USED
- None.
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "iquant_table.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*
-   This table contains the value of x ^ (1/3) where x is in the range of
-   [0..1024], in Q27 format.
-   Note that the length of the table is 1025, and not 1024 - this is because
-   the function esc_iquant may need to do an interpolation for numbers near
-   8191, which in that case it needs to get 8192 ^(1/3).
- */
-const UInt32 inverseQuantTable[] =
-{
-    0x00000000, /*    0 */
-    0x08000000, /*    1 */
-    0x0a14517d, /*    2 */
-    0x0b89ba25, /*    3 */
-    0x0cb2ff53, /*    4 */
-    0x0dae07de, /*    5 */
-    0x0e897685, /*    6 */
-    0x0f4daedd, /*    7 */
-    0x10000000, /*    8 */
-    0x10a402fd, /*    9 */
-    0x113c4841, /*   10 */
-    0x11cab613, /*   11 */
-    0x1250bfe2, /*   12 */
-    0x12cf8890, /*   13 */
-    0x1347f8ab, /*   14 */
-    0x13bacd65, /*   15 */
-    0x1428a2fa, /*   16 */
-    0x1491fc15, /*   17 */
-    0x14f74744, /*   18 */
-    0x1558e2f7, /*   19 */
-    0x15b72095, /*   20 */
-    0x161246d7, /*   21 */
-    0x166a9399, /*   22 */
-    0x16c03d55, /*   23 */
-    0x17137449, /*   24 */
-    0x17646369, /*   25 */
-    0x17b33124, /*   26 */
-    0x18000000, /*   27 */
-    0x184aef29, /*   28 */
-    0x18941ad8, /*   29 */
-    0x18db9cb7, /*   30 */
-    0x19218c2e, /*   31 */
-    0x1965fea5, /*   32 */
-    0x19a907c2, /*   33 */
-    0x19eab998, /*   34 */
-    0x1a2b24d0, /*   35 */
-    0x1a6a58d5, /*   36 */
-    0x1aa863ee, /*   37 */
-    0x1ae5535d, /*   38 */
-    0x1b213377, /*   39 */
-    0x1b5c0fbd, /*   40 */
-    0x1b95f2ec, /*   41 */
-    0x1bcee70f, /*   42 */
-    0x1c06f590, /*   43 */
-    0x1c3e2745, /*   44 */
-    0x1c74847a, /*   45 */
-    0x1caa1501, /*   46 */
-    0x1cdee035, /*   47 */
-    0x1d12ed0b, /*   48 */
-    0x1d464212, /*   49 */
-    0x1d78e582, /*   50 */
-    0x1daadd3a, /*   51 */
-    0x1ddc2ecf, /*   52 */
-    0x1e0cdf8c, /*   53 */
-    0x1e3cf476, /*   54 */
-    0x1e6c7257, /*   55 */
-    0x1e9b5dba, /*   56 */
-    0x1ec9baf6, /*   57 */
-    0x1ef78e2c, /*   58 */
-    0x1f24db4e, /*   59 */
-    0x1f51a620, /*   60 */
-    0x1f7df23c, /*   61 */
-    0x1fa9c314, /*   62 */
-    0x1fd51bf2, /*   63 */
-    0x20000000, /*   64 */
-    0x202a7244, /*   65 */
-    0x205475a6, /*   66 */
-    0x207e0cee, /*   67 */
-    0x20a73aca, /*   68 */
-    0x20d001cc, /*   69 */
-    0x20f8646d, /*   70 */
-    0x2120650e, /*   71 */
-    0x214805fa, /*   72 */
-    0x216f4963, /*   73 */
-    0x2196316c, /*   74 */
-    0x21bcc020, /*   75 */
-    0x21e2f77a, /*   76 */
-    0x2208d961, /*   77 */
-    0x222e67ad, /*   78 */
-    0x2253a425, /*   79 */
-    0x22789082, /*   80 */
-    0x229d2e6e, /*   81 */
-    0x22c17f82, /*   82 */
-    0x22e5854f, /*   83 */
-    0x23094155, /*   84 */
-    0x232cb509, /*   85 */
-    0x234fe1d5, /*   86 */
-    0x2372c918, /*   87 */
-    0x23956c26, /*   88 */
-    0x23b7cc47, /*   89 */
-    0x23d9eabb, /*   90 */
-    0x23fbc8b9, /*   91 */
-    0x241d676e, /*   92 */
-    0x243ec7ff, /*   93 */
-    0x245feb86, /*   94 */
-    0x2480d319, /*   95 */
-    0x24a17fc3, /*   96 */
-    0x24c1f28b, /*   97 */
-    0x24e22c6c, /*   98 */
-    0x25022e5f, /*   99 */
-    0x2521f954, /*  100 */
-    0x25418e33, /*  101 */
-    0x2560ede2, /*  102 */
-    0x2580193e, /*  103 */
-    0x259f111f, /*  104 */
-    0x25bdd657, /*  105 */
-    0x25dc69b4, /*  106 */
-    0x25facbfe, /*  107 */
-    0x2618fdf8, /*  108 */
-    0x26370060, /*  109 */
-    0x2654d3ef, /*  110 */
-    0x2672795c, /*  111 */
-    0x268ff156, /*  112 */
-    0x26ad3c8a, /*  113 */
-    0x26ca5ba2, /*  114 */
-    0x26e74f41, /*  115 */
-    0x27041808, /*  116 */
-    0x2720b695, /*  117 */
-    0x273d2b81, /*  118 */
-    0x27597762, /*  119 */
-    0x27759acb, /*  120 */
-    0x2791964b, /*  121 */
-    0x27ad6a6f, /*  122 */
-    0x27c917c0, /*  123 */
-    0x27e49ec5, /*  124 */
-    0x28000000, /*  125 */
-    0x281b3bf3, /*  126 */
-    0x2836531b, /*  127 */
-    0x285145f3, /*  128 */
-    0x286c14f5, /*  129 */
-    0x2886c096, /*  130 */
-    0x28a1494b, /*  131 */
-    0x28bbaf85, /*  132 */
-    0x28d5f3b3, /*  133 */
-    0x28f01641, /*  134 */
-    0x290a179b, /*  135 */
-    0x2923f82a, /*  136 */
-    0x293db854, /*  137 */
-    0x2957587e, /*  138 */
-    0x2970d90a, /*  139 */
-    0x298a3a59, /*  140 */
-    0x29a37cca, /*  141 */
-    0x29bca0bb, /*  142 */
-    0x29d5a687, /*  143 */
-    0x29ee8e87, /*  144 */
-    0x2a075914, /*  145 */
-    0x2a200684, /*  146 */
-    0x2a38972c, /*  147 */
-    0x2a510b5f, /*  148 */
-    0x2a696370, /*  149 */
-    0x2a819fae, /*  150 */
-    0x2a99c069, /*  151 */
-    0x2ab1c5ed, /*  152 */
-    0x2ac9b088, /*  153 */
-    0x2ae18085, /*  154 */
-    0x2af9362c, /*  155 */
-    0x2b10d1c6, /*  156 */
-    0x2b28539b, /*  157 */
-    0x2b3fbbef, /*  158 */
-    0x2b570b09, /*  159 */
-    0x2b6e412b, /*  160 */
-    0x2b855e97, /*  161 */
-    0x2b9c6390, /*  162 */
-    0x2bb35056, /*  163 */
-    0x2bca2527, /*  164 */
-    0x2be0e242, /*  165 */
-    0x2bf787e4, /*  166 */
-    0x2c0e1649, /*  167 */
-    0x2c248dad, /*  168 */
-    0x2c3aee4a, /*  169 */
-    0x2c513859, /*  170 */
-    0x2c676c13, /*  171 */
-    0x2c7d89af, /*  172 */
-    0x2c939164, /*  173 */
-    0x2ca98368, /*  174 */
-    0x2cbf5ff1, /*  175 */
-    0x2cd52731, /*  176 */
-    0x2cead95e, /*  177 */
-    0x2d0076a9, /*  178 */
-    0x2d15ff45, /*  179 */
-    0x2d2b7363, /*  180 */
-    0x2d40d332, /*  181 */
-    0x2d561ee4, /*  182 */
-    0x2d6b56a7, /*  183 */
-    0x2d807aaa, /*  184 */
-    0x2d958b19, /*  185 */
-    0x2daa8823, /*  186 */
-    0x2dbf71f4, /*  187 */
-    0x2dd448b7, /*  188 */
-    0x2de90c98, /*  189 */
-    0x2dfdbdc0, /*  190 */
-    0x2e125c5c, /*  191 */
-    0x2e26e892, /*  192 */
-    0x2e3b628d, /*  193 */
-    0x2e4fca75, /*  194 */
-    0x2e642070, /*  195 */
-    0x2e7864a8, /*  196 */
-    0x2e8c9741, /*  197 */
-    0x2ea0b862, /*  198 */
-    0x2eb4c831, /*  199 */
-    0x2ec8c6d3, /*  200 */
-    0x2edcb46c, /*  201 */
-    0x2ef09121, /*  202 */
-    0x2f045d14, /*  203 */
-    0x2f18186a, /*  204 */
-    0x2f2bc345, /*  205 */
-    0x2f3f5dc7, /*  206 */
-    0x2f52e812, /*  207 */
-    0x2f666247, /*  208 */
-    0x2f79cc88, /*  209 */
-    0x2f8d26f4, /*  210 */
-    0x2fa071ac, /*  211 */
-    0x2fb3acd0, /*  212 */
-    0x2fc6d87f, /*  213 */
-    0x2fd9f4d7, /*  214 */
-    0x2fed01f8, /*  215 */
-    0x30000000, /*  216 */
-    0x3012ef0c, /*  217 */
-    0x3025cf39, /*  218 */
-    0x3038a0a6, /*  219 */
-    0x304b636d, /*  220 */
-    0x305e17ad, /*  221 */
-    0x3070bd81, /*  222 */
-    0x30835504, /*  223 */
-    0x3095de51, /*  224 */
-    0x30a85985, /*  225 */
-    0x30bac6b9, /*  226 */
-    0x30cd2609, /*  227 */
-    0x30df778d, /*  228 */
-    0x30f1bb60, /*  229 */
-    0x3103f19c, /*  230 */
-    0x31161a59, /*  231 */
-    0x312835b0, /*  232 */
-    0x313a43ba, /*  233 */
-    0x314c4490, /*  234 */
-    0x315e3849, /*  235 */
-    0x31701efd, /*  236 */
-    0x3181f8c4, /*  237 */
-    0x3193c5b4, /*  238 */
-    0x31a585e6, /*  239 */
-    0x31b7396f, /*  240 */
-    0x31c8e066, /*  241 */
-    0x31da7ae1, /*  242 */
-    0x31ec08f6, /*  243 */
-    0x31fd8abc, /*  244 */
-    0x320f0047, /*  245 */
-    0x322069ac, /*  246 */
-    0x3231c702, /*  247 */
-    0x3243185c, /*  248 */
-    0x32545dcf, /*  249 */
-    0x32659770, /*  250 */
-    0x3276c552, /*  251 */
-    0x3287e78a, /*  252 */
-    0x3298fe2c, /*  253 */
-    0x32aa094a, /*  254 */
-    0x32bb08f9, /*  255 */
-    0x32cbfd4a, /*  256 */
-    0x32dce652, /*  257 */
-    0x32edc423, /*  258 */
-    0x32fe96d0, /*  259 */
-    0x330f5e6a, /*  260 */
-    0x33201b04, /*  261 */
-    0x3330ccb0, /*  262 */
-    0x33417380, /*  263 */
-    0x33520f85, /*  264 */
-    0x3362a0d0, /*  265 */
-    0x33732774, /*  266 */
-    0x3383a380, /*  267 */
-    0x33941506, /*  268 */
-    0x33a47c17, /*  269 */
-    0x33b4d8c4, /*  270 */
-    0x33c52b1b, /*  271 */
-    0x33d5732f, /*  272 */
-    0x33e5b10f, /*  273 */
-    0x33f5e4ca, /*  274 */
-    0x34060e71, /*  275 */
-    0x34162e14, /*  276 */
-    0x342643c1, /*  277 */
-    0x34364f88, /*  278 */
-    0x34465178, /*  279 */
-    0x345649a1, /*  280 */
-    0x34663810, /*  281 */
-    0x34761cd6, /*  282 */
-    0x3485f800, /*  283 */
-    0x3495c99d, /*  284 */
-    0x34a591bb, /*  285 */
-    0x34b55069, /*  286 */
-    0x34c505b4, /*  287 */
-    0x34d4b1ab, /*  288 */
-    0x34e4545b, /*  289 */
-    0x34f3edd2, /*  290 */
-    0x35037e1d, /*  291 */
-    0x3513054b, /*  292 */
-    0x35228367, /*  293 */
-    0x3531f881, /*  294 */
-    0x354164a3, /*  295 */
-    0x3550c7dc, /*  296 */
-    0x35602239, /*  297 */
-    0x356f73c5, /*  298 */
-    0x357ebc8e, /*  299 */
-    0x358dfca0, /*  300 */
-    0x359d3408, /*  301 */
-    0x35ac62d1, /*  302 */
-    0x35bb8908, /*  303 */
-    0x35caa6b9, /*  304 */
-    0x35d9bbf0, /*  305 */
-    0x35e8c8b9, /*  306 */
-    0x35f7cd20, /*  307 */
-    0x3606c92f, /*  308 */
-    0x3615bcf3, /*  309 */
-    0x3624a878, /*  310 */
-    0x36338bc8, /*  311 */
-    0x364266ee, /*  312 */
-    0x365139f6, /*  313 */
-    0x366004ec, /*  314 */
-    0x366ec7d9, /*  315 */
-    0x367d82c9, /*  316 */
-    0x368c35c6, /*  317 */
-    0x369ae0dc, /*  318 */
-    0x36a98414, /*  319 */
-    0x36b81f7a, /*  320 */
-    0x36c6b317, /*  321 */
-    0x36d53ef7, /*  322 */
-    0x36e3c323, /*  323 */
-    0x36f23fa5, /*  324 */
-    0x3700b488, /*  325 */
-    0x370f21d5, /*  326 */
-    0x371d8797, /*  327 */
-    0x372be5d7, /*  328 */
-    0x373a3ca0, /*  329 */
-    0x37488bf9, /*  330 */
-    0x3756d3ef, /*  331 */
-    0x37651489, /*  332 */
-    0x37734dd1, /*  333 */
-    0x37817fd1, /*  334 */
-    0x378faa92, /*  335 */
-    0x379dce1d, /*  336 */
-    0x37abea7c, /*  337 */
-    0x37b9ffb7, /*  338 */
-    0x37c80dd7, /*  339 */
-    0x37d614e6, /*  340 */
-    0x37e414ec, /*  341 */
-    0x37f20df1, /*  342 */
-    0x38000000, /*  343 */
-    0x380deb20, /*  344 */
-    0x381bcf5a, /*  345 */
-    0x3829acb6, /*  346 */
-    0x3837833d, /*  347 */
-    0x384552f8, /*  348 */
-    0x38531bee, /*  349 */
-    0x3860de28, /*  350 */
-    0x386e99af, /*  351 */
-    0x387c4e89, /*  352 */
-    0x3889fcc0, /*  353 */
-    0x3897a45b, /*  354 */
-    0x38a54563, /*  355 */
-    0x38b2dfdf, /*  356 */
-    0x38c073d7, /*  357 */
-    0x38ce0152, /*  358 */
-    0x38db885a, /*  359 */
-    0x38e908f4, /*  360 */
-    0x38f68329, /*  361 */
-    0x3903f701, /*  362 */
-    0x39116483, /*  363 */
-    0x391ecbb6, /*  364 */
-    0x392c2ca1, /*  365 */
-    0x3939874d, /*  366 */
-    0x3946dbc0, /*  367 */
-    0x39542a01, /*  368 */
-    0x39617218, /*  369 */
-    0x396eb40c, /*  370 */
-    0x397befe4, /*  371 */
-    0x398925a7, /*  372 */
-    0x3996555c, /*  373 */
-    0x39a37f09, /*  374 */
-    0x39b0a2b7, /*  375 */
-    0x39bdc06a, /*  376 */
-    0x39cad82b, /*  377 */
-    0x39d7ea01, /*  378 */
-    0x39e4f5f0, /*  379 */
-    0x39f1fc01, /*  380 */
-    0x39fefc3a, /*  381 */
-    0x3a0bf6a2, /*  382 */
-    0x3a18eb3e, /*  383 */
-    0x3a25da16, /*  384 */
-    0x3a32c32f, /*  385 */
-    0x3a3fa691, /*  386 */
-    0x3a4c8441, /*  387 */
-    0x3a595c46, /*  388 */
-    0x3a662ea6, /*  389 */
-    0x3a72fb67, /*  390 */
-    0x3a7fc28f, /*  391 */
-    0x3a8c8425, /*  392 */
-    0x3a99402e, /*  393 */
-    0x3aa5f6b1, /*  394 */
-    0x3ab2a7b3, /*  395 */
-    0x3abf533a, /*  396 */
-    0x3acbf94d, /*  397 */
-    0x3ad899f1, /*  398 */
-    0x3ae5352c, /*  399 */
-    0x3af1cb03, /*  400 */
-    0x3afe5b7d, /*  401 */
-    0x3b0ae6a0, /*  402 */
-    0x3b176c70, /*  403 */
-    0x3b23ecf3, /*  404 */
-    0x3b306830, /*  405 */
-    0x3b3cde2c, /*  406 */
-    0x3b494eeb, /*  407 */
-    0x3b55ba74, /*  408 */
-    0x3b6220cc, /*  409 */
-    0x3b6e81f9, /*  410 */
-    0x3b7ade00, /*  411 */
-    0x3b8734e5, /*  412 */
-    0x3b9386b0, /*  413 */
-    0x3b9fd364, /*  414 */
-    0x3bac1b07, /*  415 */
-    0x3bb85d9e, /*  416 */
-    0x3bc49b2f, /*  417 */
-    0x3bd0d3be, /*  418 */
-    0x3bdd0751, /*  419 */
-    0x3be935ed, /*  420 */
-    0x3bf55f97, /*  421 */
-    0x3c018453, /*  422 */
-    0x3c0da427, /*  423 */
-    0x3c19bf17, /*  424 */
-    0x3c25d52a, /*  425 */
-    0x3c31e662, /*  426 */
-    0x3c3df2c6, /*  427 */
-    0x3c49fa5b, /*  428 */
-    0x3c55fd24, /*  429 */
-    0x3c61fb27, /*  430 */
-    0x3c6df468, /*  431 */
-    0x3c79e8ed, /*  432 */
-    0x3c85d8b9, /*  433 */
-    0x3c91c3d2, /*  434 */
-    0x3c9daa3c, /*  435 */
-    0x3ca98bfc, /*  436 */
-    0x3cb56915, /*  437 */
-    0x3cc1418e, /*  438 */
-    0x3ccd156a, /*  439 */
-    0x3cd8e4ae, /*  440 */
-    0x3ce4af5e, /*  441 */
-    0x3cf0757f, /*  442 */
-    0x3cfc3714, /*  443 */
-    0x3d07f423, /*  444 */
-    0x3d13acb0, /*  445 */
-    0x3d1f60bf, /*  446 */
-    0x3d2b1055, /*  447 */
-    0x3d36bb75, /*  448 */
-    0x3d426224, /*  449 */
-    0x3d4e0466, /*  450 */
-    0x3d59a23f, /*  451 */
-    0x3d653bb4, /*  452 */
-    0x3d70d0c8, /*  453 */
-    0x3d7c6180, /*  454 */
-    0x3d87ede0, /*  455 */
-    0x3d9375ec, /*  456 */
-    0x3d9ef9a8, /*  457 */
-    0x3daa7918, /*  458 */
-    0x3db5f43f, /*  459 */
-    0x3dc16b23, /*  460 */
-    0x3dccddc7, /*  461 */
-    0x3dd84c2e, /*  462 */
-    0x3de3b65d, /*  463 */
-    0x3def1c58, /*  464 */
-    0x3dfa7e22, /*  465 */
-    0x3e05dbc0, /*  466 */
-    0x3e113535, /*  467 */
-    0x3e1c8a85, /*  468 */
-    0x3e27dbb3, /*  469 */
-    0x3e3328c4, /*  470 */
-    0x3e3e71bb, /*  471 */
-    0x3e49b69c, /*  472 */
-    0x3e54f76b, /*  473 */
-    0x3e60342b, /*  474 */
-    0x3e6b6ce0, /*  475 */
-    0x3e76a18d, /*  476 */
-    0x3e81d237, /*  477 */
-    0x3e8cfee0, /*  478 */
-    0x3e98278d, /*  479 */
-    0x3ea34c40, /*  480 */
-    0x3eae6cfe, /*  481 */
-    0x3eb989ca, /*  482 */
-    0x3ec4a2a8, /*  483 */
-    0x3ecfb79a, /*  484 */
-    0x3edac8a5, /*  485 */
-    0x3ee5d5cb, /*  486 */
-    0x3ef0df10, /*  487 */
-    0x3efbe478, /*  488 */
-    0x3f06e606, /*  489 */
-    0x3f11e3be, /*  490 */
-    0x3f1cdda2, /*  491 */
-    0x3f27d3b6, /*  492 */
-    0x3f32c5fd, /*  493 */
-    0x3f3db47b, /*  494 */
-    0x3f489f32, /*  495 */
-    0x3f538627, /*  496 */
-    0x3f5e695c, /*  497 */
-    0x3f6948d5, /*  498 */
-    0x3f742494, /*  499 */
-    0x3f7efc9d, /*  500 */
-    0x3f89d0f3, /*  501 */
-    0x3f94a19a, /*  502 */
-    0x3f9f6e94, /*  503 */
-    0x3faa37e4, /*  504 */
-    0x3fb4fd8e, /*  505 */
-    0x3fbfbf94, /*  506 */
-    0x3fca7dfb, /*  507 */
-    0x3fd538c4, /*  508 */
-    0x3fdfeff3, /*  509 */
-    0x3feaa38a, /*  510 */
-    0x3ff5538e, /*  511 */
-    0x40000000, /*  512 */
-    0x400aa8e4, /*  513 */
-    0x40154e3d, /*  514 */
-    0x401ff00d, /*  515 */
-    0x402a8e58, /*  516 */
-    0x40352921, /*  517 */
-    0x403fc06a, /*  518 */
-    0x404a5436, /*  519 */
-    0x4054e488, /*  520 */
-    0x405f7164, /*  521 */
-    0x4069facb, /*  522 */
-    0x407480c1, /*  523 */
-    0x407f0348, /*  524 */
-    0x40898264, /*  525 */
-    0x4093fe16, /*  526 */
-    0x409e7663, /*  527 */
-    0x40a8eb4c, /*  528 */
-    0x40b35cd4, /*  529 */
-    0x40bdcafe, /*  530 */
-    0x40c835cd, /*  531 */
-    0x40d29d43, /*  532 */
-    0x40dd0164, /*  533 */
-    0x40e76231, /*  534 */
-    0x40f1bfae, /*  535 */
-    0x40fc19dc, /*  536 */
-    0x410670c0, /*  537 */
-    0x4110c45a, /*  538 */
-    0x411b14af, /*  539 */
-    0x412561c0, /*  540 */
-    0x412fab90, /*  541 */
-    0x4139f222, /*  542 */
-    0x41443578, /*  543 */
-    0x414e7595, /*  544 */
-    0x4158b27a, /*  545 */
-    0x4162ec2c, /*  546 */
-    0x416d22ac, /*  547 */
-    0x417755fd, /*  548 */
-    0x41818621, /*  549 */
-    0x418bb31a, /*  550 */
-    0x4195dcec, /*  551 */
-    0x41a00399, /*  552 */
-    0x41aa2722, /*  553 */
-    0x41b4478b, /*  554 */
-    0x41be64d6, /*  555 */
-    0x41c87f05, /*  556 */
-    0x41d2961a, /*  557 */
-    0x41dcaa19, /*  558 */
-    0x41e6bb03, /*  559 */
-    0x41f0c8db, /*  560 */
-    0x41fad3a3, /*  561 */
-    0x4204db5d, /*  562 */
-    0x420ee00c, /*  563 */
-    0x4218e1b1, /*  564 */
-    0x4222e051, /*  565 */
-    0x422cdbeb, /*  566 */
-    0x4236d484, /*  567 */
-    0x4240ca1d, /*  568 */
-    0x424abcb8, /*  569 */
-    0x4254ac58, /*  570 */
-    0x425e98fe, /*  571 */
-    0x426882ae, /*  572 */
-    0x42726969, /*  573 */
-    0x427c4d31, /*  574 */
-    0x42862e09, /*  575 */
-    0x42900bf3, /*  576 */
-    0x4299e6f1, /*  577 */
-    0x42a3bf05, /*  578 */
-    0x42ad9432, /*  579 */
-    0x42b76678, /*  580 */
-    0x42c135dc, /*  581 */
-    0x42cb025e, /*  582 */
-    0x42d4cc01, /*  583 */
-    0x42de92c7, /*  584 */
-    0x42e856b2, /*  585 */
-    0x42f217c4, /*  586 */
-    0x42fbd5ff, /*  587 */
-    0x43059166, /*  588 */
-    0x430f49f9, /*  589 */
-    0x4318ffbc, /*  590 */
-    0x4322b2b1, /*  591 */
-    0x432c62d8, /*  592 */
-    0x43361036, /*  593 */
-    0x433fbaca, /*  594 */
-    0x43496298, /*  595 */
-    0x435307a2, /*  596 */
-    0x435ca9e8, /*  597 */
-    0x4366496e, /*  598 */
-    0x436fe636, /*  599 */
-    0x43798041, /*  600 */
-    0x43831790, /*  601 */
-    0x438cac28, /*  602 */
-    0x43963e08, /*  603 */
-    0x439fcd33, /*  604 */
-    0x43a959ab, /*  605 */
-    0x43b2e372, /*  606 */
-    0x43bc6a89, /*  607 */
-    0x43c5eef3, /*  608 */
-    0x43cf70b2, /*  609 */
-    0x43d8efc7, /*  610 */
-    0x43e26c34, /*  611 */
-    0x43ebe5fb, /*  612 */
-    0x43f55d1e, /*  613 */
-    0x43fed19f, /*  614 */
-    0x44084380, /*  615 */
-    0x4411b2c1, /*  616 */
-    0x441b1f66, /*  617 */
-    0x44248970, /*  618 */
-    0x442df0e1, /*  619 */
-    0x443755bb, /*  620 */
-    0x4440b7fe, /*  621 */
-    0x444a17ae, /*  622 */
-    0x445374cc, /*  623 */
-    0x445ccf5a, /*  624 */
-    0x44662758, /*  625 */
-    0x446f7ccb, /*  626 */
-    0x4478cfb2, /*  627 */
-    0x4482200f, /*  628 */
-    0x448b6de5, /*  629 */
-    0x4494b935, /*  630 */
-    0x449e0201, /*  631 */
-    0x44a7484b, /*  632 */
-    0x44b08c13, /*  633 */
-    0x44b9cd5d, /*  634 */
-    0x44c30c29, /*  635 */
-    0x44cc4879, /*  636 */
-    0x44d5824f, /*  637 */
-    0x44deb9ac, /*  638 */
-    0x44e7ee93, /*  639 */
-    0x44f12105, /*  640 */
-    0x44fa5103, /*  641 */
-    0x45037e8f, /*  642 */
-    0x450ca9ab, /*  643 */
-    0x4515d258, /*  644 */
-    0x451ef899, /*  645 */
-    0x45281c6e, /*  646 */
-    0x45313dd8, /*  647 */
-    0x453a5cdb, /*  648 */
-    0x45437977, /*  649 */
-    0x454c93ae, /*  650 */
-    0x4555ab82, /*  651 */
-    0x455ec0f3, /*  652 */
-    0x4567d404, /*  653 */
-    0x4570e4b7, /*  654 */
-    0x4579f30c, /*  655 */
-    0x4582ff05, /*  656 */
-    0x458c08a4, /*  657 */
-    0x45950fea, /*  658 */
-    0x459e14d9, /*  659 */
-    0x45a71773, /*  660 */
-    0x45b017b8, /*  661 */
-    0x45b915aa, /*  662 */
-    0x45c2114c, /*  663 */
-    0x45cb0a9e, /*  664 */
-    0x45d401a1, /*  665 */
-    0x45dcf658, /*  666 */
-    0x45e5e8c4, /*  667 */
-    0x45eed8e6, /*  668 */
-    0x45f7c6c0, /*  669 */
-    0x4600b253, /*  670 */
-    0x46099ba0, /*  671 */
-    0x461282a9, /*  672 */
-    0x461b6770, /*  673 */
-    0x462449f6, /*  674 */
-    0x462d2a3c, /*  675 */
-    0x46360844, /*  676 */
-    0x463ee40f, /*  677 */
-    0x4647bd9f, /*  678 */
-    0x465094f5, /*  679 */
-    0x46596a12, /*  680 */
-    0x46623cf8, /*  681 */
-    0x466b0da8, /*  682 */
-    0x4673dc24, /*  683 */
-    0x467ca86c, /*  684 */
-    0x46857283, /*  685 */
-    0x468e3a69, /*  686 */
-    0x46970021, /*  687 */
-    0x469fc3ab, /*  688 */
-    0x46a88509, /*  689 */
-    0x46b1443b, /*  690 */
-    0x46ba0144, /*  691 */
-    0x46c2bc25, /*  692 */
-    0x46cb74df, /*  693 */
-    0x46d42b74, /*  694 */
-    0x46dcdfe4, /*  695 */
-    0x46e59231, /*  696 */
-    0x46ee425c, /*  697 */
-    0x46f6f068, /*  698 */
-    0x46ff9c54, /*  699 */
-    0x47084622, /*  700 */
-    0x4710edd4, /*  701 */
-    0x4719936b, /*  702 */
-    0x472236e7, /*  703 */
-    0x472ad84b, /*  704 */
-    0x47337798, /*  705 */
-    0x473c14cf, /*  706 */
-    0x4744aff1, /*  707 */
-    0x474d48ff, /*  708 */
-    0x4755dffb, /*  709 */
-    0x475e74e6, /*  710 */
-    0x476707c1, /*  711 */
-    0x476f988e, /*  712 */
-    0x4778274d, /*  713 */
-    0x4780b400, /*  714 */
-    0x47893ea8, /*  715 */
-    0x4791c746, /*  716 */
-    0x479a4ddc, /*  717 */
-    0x47a2d26b, /*  718 */
-    0x47ab54f3, /*  719 */
-    0x47b3d577, /*  720 */
-    0x47bc53f7, /*  721 */
-    0x47c4d074, /*  722 */
-    0x47cd4af0, /*  723 */
-    0x47d5c36c, /*  724 */
-    0x47de39e9, /*  725 */
-    0x47e6ae69, /*  726 */
-    0x47ef20ec, /*  727 */
-    0x47f79173, /*  728 */
-    0x48000000, /*  729 */
-    0x48086c94, /*  730 */
-    0x4810d730, /*  731 */
-    0x48193fd5, /*  732 */
-    0x4821a685, /*  733 */
-    0x482a0b40, /*  734 */
-    0x48326e07, /*  735 */
-    0x483acedd, /*  736 */
-    0x48432dc1, /*  737 */
-    0x484b8ab5, /*  738 */
-    0x4853e5bb, /*  739 */
-    0x485c3ed2, /*  740 */
-    0x486495fd, /*  741 */
-    0x486ceb3c, /*  742 */
-    0x48753e91, /*  743 */
-    0x487d8ffd, /*  744 */
-    0x4885df80, /*  745 */
-    0x488e2d1d, /*  746 */
-    0x489678d3, /*  747 */
-    0x489ec2a4, /*  748 */
-    0x48a70a91, /*  749 */
-    0x48af509b, /*  750 */
-    0x48b794c4, /*  751 */
-    0x48bfd70c, /*  752 */
-    0x48c81774, /*  753 */
-    0x48d055fe, /*  754 */
-    0x48d892aa, /*  755 */
-    0x48e0cd7a, /*  756 */
-    0x48e9066e, /*  757 */
-    0x48f13d88, /*  758 */
-    0x48f972c9, /*  759 */
-    0x4901a632, /*  760 */
-    0x4909d7c3, /*  761 */
-    0x4912077e, /*  762 */
-    0x491a3564, /*  763 */
-    0x49226175, /*  764 */
-    0x492a8bb4, /*  765 */
-    0x4932b420, /*  766 */
-    0x493adabc, /*  767 */
-    0x4942ff87, /*  768 */
-    0x494b2283, /*  769 */
-    0x495343b1, /*  770 */
-    0x495b6312, /*  771 */
-    0x496380a7, /*  772 */
-    0x496b9c71, /*  773 */
-    0x4973b670, /*  774 */
-    0x497bcea7, /*  775 */
-    0x4983e515, /*  776 */
-    0x498bf9bc, /*  777 */
-    0x49940c9e, /*  778 */
-    0x499c1db9, /*  779 */
-    0x49a42d11, /*  780 */
-    0x49ac3aa5, /*  781 */
-    0x49b44677, /*  782 */
-    0x49bc5088, /*  783 */
-    0x49c458d8, /*  784 */
-    0x49cc5f69, /*  785 */
-    0x49d4643c, /*  786 */
-    0x49dc6750, /*  787 */
-    0x49e468a9, /*  788 */
-    0x49ec6845, /*  789 */
-    0x49f46627, /*  790 */
-    0x49fc624f, /*  791 */
-    0x4a045cbe, /*  792 */
-    0x4a0c5575, /*  793 */
-    0x4a144c76, /*  794 */
-    0x4a1c41c0, /*  795 */
-    0x4a243555, /*  796 */
-    0x4a2c2735, /*  797 */
-    0x4a341763, /*  798 */
-    0x4a3c05de, /*  799 */
-    0x4a43f2a7, /*  800 */
-    0x4a4bddc0, /*  801 */
-    0x4a53c729, /*  802 */
-    0x4a5baee3, /*  803 */
-    0x4a6394ef, /*  804 */
-    0x4a6b794f, /*  805 */
-    0x4a735c02, /*  806 */
-    0x4a7b3d09, /*  807 */
-    0x4a831c67, /*  808 */
-    0x4a8afa1b, /*  809 */
-    0x4a92d626, /*  810 */
-    0x4a9ab089, /*  811 */
-    0x4aa28946, /*  812 */
-    0x4aaa605d, /*  813 */
-    0x4ab235ce, /*  814 */
-    0x4aba099b, /*  815 */
-    0x4ac1dbc5, /*  816 */
-    0x4ac9ac4c, /*  817 */
-    0x4ad17b31, /*  818 */
-    0x4ad94876, /*  819 */
-    0x4ae1141a, /*  820 */
-    0x4ae8de1f, /*  821 */
-    0x4af0a686, /*  822 */
-    0x4af86d50, /*  823 */
-    0x4b00327d, /*  824 */
-    0x4b07f60d, /*  825 */
-    0x4b0fb803, /*  826 */
-    0x4b17785f, /*  827 */
-    0x4b1f3722, /*  828 */
-    0x4b26f44b, /*  829 */
-    0x4b2eafde, /*  830 */
-    0x4b3669d9, /*  831 */
-    0x4b3e223e, /*  832 */
-    0x4b45d90e, /*  833 */
-    0x4b4d8e4a, /*  834 */
-    0x4b5541f2, /*  835 */
-    0x4b5cf407, /*  836 */
-    0x4b64a48a, /*  837 */
-    0x4b6c537c, /*  838 */
-    0x4b7400dd, /*  839 */
-    0x4b7bacaf, /*  840 */
-    0x4b8356f2, /*  841 */
-    0x4b8affa7, /*  842 */
-    0x4b92a6ce, /*  843 */
-    0x4b9a4c69, /*  844 */
-    0x4ba1f079, /*  845 */
-    0x4ba992fd, /*  846 */
-    0x4bb133f8, /*  847 */
-    0x4bb8d369, /*  848 */
-    0x4bc07151, /*  849 */
-    0x4bc80db2, /*  850 */
-    0x4bcfa88c, /*  851 */
-    0x4bd741df, /*  852 */
-    0x4bded9ad, /*  853 */
-    0x4be66ff6, /*  854 */
-    0x4bee04bb, /*  855 */
-    0x4bf597fc, /*  856 */
-    0x4bfd29bc, /*  857 */
-    0x4c04b9f9, /*  858 */
-    0x4c0c48b6, /*  859 */
-    0x4c13d5f2, /*  860 */
-    0x4c1b61af, /*  861 */
-    0x4c22ebed, /*  862 */
-    0x4c2a74ad, /*  863 */
-    0x4c31fbf0, /*  864 */
-    0x4c3981b6, /*  865 */
-    0x4c410600, /*  866 */
-    0x4c4888d0, /*  867 */
-    0x4c500a25, /*  868 */
-    0x4c578a00, /*  869 */
-    0x4c5f0862, /*  870 */
-    0x4c66854c, /*  871 */
-    0x4c6e00bf, /*  872 */
-    0x4c757abb, /*  873 */
-    0x4c7cf341, /*  874 */
-    0x4c846a52, /*  875 */
-    0x4c8bdfee, /*  876 */
-    0x4c935416, /*  877 */
-    0x4c9ac6cb, /*  878 */
-    0x4ca2380e, /*  879 */
-    0x4ca9a7de, /*  880 */
-    0x4cb1163e, /*  881 */
-    0x4cb8832d, /*  882 */
-    0x4cbfeead, /*  883 */
-    0x4cc758bd, /*  884 */
-    0x4ccec15f, /*  885 */
-    0x4cd62894, /*  886 */
-    0x4cdd8e5c, /*  887 */
-    0x4ce4f2b7, /*  888 */
-    0x4cec55a7, /*  889 */
-    0x4cf3b72c, /*  890 */
-    0x4cfb1747, /*  891 */
-    0x4d0275f8, /*  892 */
-    0x4d09d340, /*  893 */
-    0x4d112f21, /*  894 */
-    0x4d188999, /*  895 */
-    0x4d1fe2ab, /*  896 */
-    0x4d273a57, /*  897 */
-    0x4d2e909d, /*  898 */
-    0x4d35e57f, /*  899 */
-    0x4d3d38fc, /*  900 */
-    0x4d448b16, /*  901 */
-    0x4d4bdbcd, /*  902 */
-    0x4d532b21, /*  903 */
-    0x4d5a7914, /*  904 */
-    0x4d61c5a7, /*  905 */
-    0x4d6910d9, /*  906 */
-    0x4d705aab, /*  907 */
-    0x4d77a31e, /*  908 */
-    0x4d7eea34, /*  909 */
-    0x4d862feb, /*  910 */
-    0x4d8d7445, /*  911 */
-    0x4d94b743, /*  912 */
-    0x4d9bf8e6, /*  913 */
-    0x4da3392d, /*  914 */
-    0x4daa7819, /*  915 */
-    0x4db1b5ac, /*  916 */
-    0x4db8f1e6, /*  917 */
-    0x4dc02cc7, /*  918 */
-    0x4dc76650, /*  919 */
-    0x4dce9e81, /*  920 */
-    0x4dd5d55c, /*  921 */
-    0x4ddd0ae1, /*  922 */
-    0x4de43f10, /*  923 */
-    0x4deb71eb, /*  924 */
-    0x4df2a371, /*  925 */
-    0x4df9d3a3, /*  926 */
-    0x4e010283, /*  927 */
-    0x4e083010, /*  928 */
-    0x4e0f5c4b, /*  929 */
-    0x4e168735, /*  930 */
-    0x4e1db0cf, /*  931 */
-    0x4e24d918, /*  932 */
-    0x4e2c0012, /*  933 */
-    0x4e3325bd, /*  934 */
-    0x4e3a4a1a, /*  935 */
-    0x4e416d2a, /*  936 */
-    0x4e488eec, /*  937 */
-    0x4e4faf62, /*  938 */
-    0x4e56ce8c, /*  939 */
-    0x4e5dec6b, /*  940 */
-    0x4e6508ff, /*  941 */
-    0x4e6c2449, /*  942 */
-    0x4e733e4a, /*  943 */
-    0x4e7a5702, /*  944 */
-    0x4e816e71, /*  945 */
-    0x4e888498, /*  946 */
-    0x4e8f9979, /*  947 */
-    0x4e96ad13, /*  948 */
-    0x4e9dbf67, /*  949 */
-    0x4ea4d075, /*  950 */
-    0x4eabe03e, /*  951 */
-    0x4eb2eec4, /*  952 */
-    0x4eb9fc05, /*  953 */
-    0x4ec10803, /*  954 */
-    0x4ec812bf, /*  955 */
-    0x4ecf1c39, /*  956 */
-    0x4ed62471, /*  957 */
-    0x4edd2b68, /*  958 */
-    0x4ee4311f, /*  959 */
-    0x4eeb3596, /*  960 */
-    0x4ef238cd, /*  961 */
-    0x4ef93ac6, /*  962 */
-    0x4f003b81, /*  963 */
-    0x4f073afe, /*  964 */
-    0x4f0e393f, /*  965 */
-    0x4f153642, /*  966 */
-    0x4f1c320a, /*  967 */
-    0x4f232c96, /*  968 */
-    0x4f2a25e8, /*  969 */
-    0x4f311dff, /*  970 */
-    0x4f3814dc, /*  971 */
-    0x4f3f0a80, /*  972 */
-    0x4f45feeb, /*  973 */
-    0x4f4cf21f, /*  974 */
-    0x4f53e41a, /*  975 */
-    0x4f5ad4de, /*  976 */
-    0x4f61c46c, /*  977 */
-    0x4f68b2c4, /*  978 */
-    0x4f6f9fe6, /*  979 */
-    0x4f768bd3, /*  980 */
-    0x4f7d768c, /*  981 */
-    0x4f846011, /*  982 */
-    0x4f8b4862, /*  983 */
-    0x4f922f81, /*  984 */
-    0x4f99156d, /*  985 */
-    0x4f9ffa27, /*  986 */
-    0x4fa6ddb0, /*  987 */
-    0x4fadc008, /*  988 */
-    0x4fb4a12f, /*  989 */
-    0x4fbb8127, /*  990 */
-    0x4fc25ff0, /*  991 */
-    0x4fc93d8a, /*  992 */
-    0x4fd019f5, /*  993 */
-    0x4fd6f533, /*  994 */
-    0x4fddcf43, /*  995 */
-    0x4fe4a827, /*  996 */
-    0x4feb7fde, /*  997 */
-    0x4ff2566a, /*  998 */
-    0x4ff92bca, /*  999 */
-    0x50000000, /* 1000 */
-    0x5006d30b, /* 1001 */
-    0x500da4ed, /* 1002 */
-    0x501475a5, /* 1003 */
-    0x501b4535, /* 1004 */
-    0x5022139c, /* 1005 */
-    0x5028e0dc, /* 1006 */
-    0x502facf4, /* 1007 */
-    0x503677e5, /* 1008 */
-    0x503d41b0, /* 1009 */
-    0x50440a55, /* 1010 */
-    0x504ad1d5, /* 1011 */
-    0x50519830, /* 1012 */
-    0x50585d67, /* 1013 */
-    0x505f217a, /* 1014 */
-    0x5065e469, /* 1015 */
-    0x506ca635, /* 1016 */
-    0x507366df, /* 1017 */
-    0x507a2667, /* 1018 */
-    0x5080e4cd, /* 1019 */
-    0x5087a212, /* 1020 */
-    0x508e5e37, /* 1021 */
-    0x5095193c, /* 1022 */
-    0x509bd320, /* 1023 */
-    0x50a28be6, /* 1024 */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
diff --git a/media/libstagefright/codecs/aacdec/iquant_table.h b/media/libstagefright/codecs/aacdec/iquant_table.h
deleted file mode 100644
index dadc3d0..0000000
--- a/media/libstagefright/codecs/aacdec/iquant_table.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: iquant_table.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for iquant_table.c, which contains a table used with
- esc_iquant.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef IQUANT_TABLE_H
-#define IQUANT_TABLE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const UInt32 inverseQuantTable[];
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_prediction.cpp b/media/libstagefright/codecs/aacdec/long_term_prediction.cpp
deleted file mode 100644
index 69e4c46..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_prediction.cpp
+++ /dev/null
@@ -1,648 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_prediction.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes based on comments and experiment results.
-
- Description: Passed in buffer sizes based on review comments and prototype
-              agreements.
-
- Description: 1. Passed in "weight_index" instead of "weight".
-              2. Added weight table.
-
- Description: 1. Removed some passed in buffer size variables since they are
-                 not used for long window.
-              2. Modified comments format.
-
- Description:
-    Modified casting to ensure proper operations for different platforms
-
- Description:
-    Implemented circular buffer techniques, which save 4096 memmoves per
-    frame.
-
- Description:
-    Implemented some optimizations found during the code review of this
-    module.  The optimizations related to the rules on the range of
-    ltp_buffer_index and num_samples, which allows for a simpler
-    code construct to be used in the processing of the predicted samples.
-
- Description:
-    Add max calculation on the filter implementation, this to eliminate
-    function buffer_adaptation() on the time to frequency transformation.
-    Function interface changed. It now return the amount of shifting needed
-    to garb only the top 16 MSB.
-
- Description:
-     Replace clearing memory with for-loop with pvmemset function
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    win_seq = type of window sequence (WINDOW_SEQUENCE).
-
-    weight_index = index (Int) of LTP coefficient table for all windows in
-                   current frame.
-
-    delay = buffer (Int) containing delays for each window.
-
-    buffer = history buffer (Int16) containing the reconstructed time domain
-             signals of previous frames.
-
-    buffer_offset = value (Int) that indicates the location of the first
-                    element in the LTP circular buffer.  (Either 0 or 1024)
-
-    time_quant    = filterbank buffer (Int32) This buffer is used by the
-                    filterbank, but it's first 1024 elements are equivalent
-                    to the last 1024 elements in the conventionally
-                    implemented LTP buffer.  Using this buffer directly avoids
-                    costly duplication of memory.
-
-    predicted_samples = buffer (Int32) with length of 2048 to hold
-                        predicted time domain signals.
-
-    buffer_index = index into buffer where the first sample of data from
-                   the frame (t-2) (two frames ago) resides.  (Int)
-
-    frame_length = length of one frame, type of Int.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    Amount of shifting needed to grab the top 16 MSB from teh predicted buffer
-
- Pointers and Buffers Modified:
-    predicted_samples contents are the newly calculated predicted time
-    domain signals
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Long term prediction (LTP) is used to reduce the redundancy of a signal
- between successive coding frames. This function performs prediction by
- applying 1-tap IIR filtering to calculate the predicted time domain
- signals of current frame from previous reconstructed frames stored in
- time domain history buffer.
-
- The equation used for IIR filter is as following.
-
-            y(n) = weight * x(n - delay)
-
-    where   y(n) ----- predicted time domain signals
-            x(n) ----- reconstructed time domain signals
-            weight ----- LTP coefficient
-            delay ----- optimal delay from 0 to 2047
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3: Audio
-        Subpart 4.6.6   Long Term Prediction (LTP)
-
- (2) MPEG-2 NBC Audio Decoder
-     "This software module was originally developed by Nokia in the course
-     of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7,
-     14496-1, 2 and 3. This software module is an implementation of a part
-     of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2
-     aac/MPEG-4 Audio standard. ISO/IEC  gives users of the MPEG-2aac/MPEG-4
-     Audio standards free license to this software module or modifications
-     thereof for use in hardware or software products claiming conformance
-     to the MPEG-2 aac/MPEG-4 Audio  standards. Those intending to use this
-     software module in hardware or software products are advised that this
-     use may infringe existing patents. The original developer of this
-     software module, the subsequent editors and their companies, and ISO/IEC
-     have no liability for use of this software module or modifications
-     thereof in an implementation. Copyright is not released for non MPEG-2
-     aac/MPEG-4 Audio conforming products. The original developer retains
-     full right to use the code for the developer's own purpose, assign or
-     donate the code to a third party and to inhibit third party from using
-     the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This
-     copyright notice must be included in all copies or derivative works.
-     Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pPredicted_samples = &predicted_samples[0];
-
-    weight = codebook[weight_index];
-
-    IF (win_seq != EIGHT_SHORT_SEQUENCE)
-    THEN
-
-        block_length = frame_length << 1;
-
-        lag = delay[0];
-
-        j = block_length - lag;
-
-        IF (lag < frame_length)
-        THEN
-
-            num_samples = frame_length + lag;
-
-        ELSE
-
-            num_samples = block_length;
-
-        ENDIF
-
-        pBuffer = &buffer[j];
-
-        FOR (i = num_samples; i>0; i--)
-
-            *pPredicted_samples = weight * (*pBuffer);
-            pPredicted_samples = pPredicted_samples + 1;
-            pBuffer = pBuffer + 1;
-
-        ENDFOR
-
-        FOR (i = block_length - num_samples; i>0; i--)
-
-            *pPredicted_samples = 0;
-            pPredicted_samples = pPredicted_samples + 1;
-
-        ENDFOR
-
-    ELSE
-
-        FOR (wnd = 0; wnd < short_window_num; wnd++)
-
-            IF (win_prediction_used[wnd] != FALSE)
-            THEN
-
-                delay[wnd] = delay[0] + ltp_short_lag[wnd];
-
-                lag = delay[wnd];
-
-                j = wnd*short_block_length - lag;
-
-                IF (lag < short_frame_length)
-                THEN
-
-                    num_samples = short_frame_length + lag;
-
-                ELSE
-
-                    num_samples = short_block_length;
-
-                ENDIF
-
-                pBuffer = &buffer[j];
-
-                FOR (i = num_samples; i>0; i--)
-
-                    *pPredicted_samples = weight * (*pBuffer);
-                    pPredicted_samples = pPredicted_samples + 1;
-                    pBuffer = pBuffer + 1;
-
-                ENDFOR
-
-                FOR (i = short_block_length - num_samples; i>0; i--)
-
-                    *pPredicted_samples = 0;
-                    pPredicted_samples = pPredicted_samples + 1;
-
-                ENDFOR
-
-            ELSE
-
-                CALL pv_memset(
-                        pPredicted_samples,
-                        0,
-                        sizeof(*pPredicted_samples)*short_block_length);
-                MODIFYING (predicted_samples[]);
-
-                pPredicted_samples = pPredicted_samples + short_block_length;
-
-            ENDIF [ IF (win_prediction_used[wnd] != FALSE) ]
-
-        ENDFOR [ FOR (wnd=0; wnd<short_window_num; wnd++) ]
-
-    ENDIF [ IF (win_seq != EIGHT_SHORT_SEQUENCE) ]
-
-    RETURN
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "ltp_common_internal.h"
-#include "long_term_prediction.h"
-#include "aac_mem_funcs.h"
-#include "pv_normalize.h"
-#include "window_block_fxp.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/* Purpose: Codebook for LTP weight coefficients. Stored in Q15 format */
-const UInt codebook[CODESIZE] =
-{
-    18705,  /* 0 */
-    22827,  /* 1 */
-    26641,  /* 2 */
-    29862,  /* 3 */
-    32273,  /* 4 */
-    34993,  /* 5 */
-    39145,  /* 6 */
-    44877   /* 7 */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int long_term_prediction(
-    WINDOW_SEQUENCE     win_seq,
-    const Int           weight_index,
-    const Int           delay[],
-    const Int16         buffer[],
-    const Int           buffer_offset,
-    const Int32         time_quant[],
-    Int32         predicted_samples[],    /* Q15 */
-    const Int           frame_length)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    /*
-     * Window index
-     *
-     * Int wnd;
-     *
-     * will be enabled when short window information is available.
-     */
-
-    /* Pointer to time domain history buffer */
-
-    const Int16 *pBuffer;
-
-    const Int32 *pTimeQuant = time_quant;
-
-    /* Pointer to array containing predicted samples */
-    Int32 *pPredicted_samples;
-
-    Int32   test;
-    Int32   datum;
-
-    /* IIR coefficient with Q15 format */
-    UInt    weight;
-
-    /* Length of one block (two frames) */
-    Int     block_length;
-
-    Int     shift;
-    Int     k;
-    Int     ltp_buffer_index;
-    Int     jump_point;
-    Int     lag;
-    Int     num_samples;
-
-    Int32   max = 0;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-    /* Initialize pointers */
-    pPredicted_samples = &predicted_samples[0];
-
-    weight = codebook[weight_index];
-
-    /****************************************/
-    /* LTP decoding process for long window */
-    /****************************************/
-
-    if (win_seq != EIGHT_SHORT_SEQUENCE)
-    {
-        /****************************************************/
-        /* Prediction based on previous time domain signals */
-        /****************************************************/
-        block_length = frame_length << 1;
-
-        /* Calculate time lag for 1-tap IIR filter */
-        lag = delay[0];
-
-        ltp_buffer_index = block_length - lag;
-
-        /* Calculate number of samples used in IIR filter */
-        if (lag < frame_length)
-        {
-            num_samples = frame_length + lag;
-        }
-        else
-        {
-            num_samples = block_length;
-        }
-
-
-        /*
-         * Calculate the predicted time domain signals from the
-         * reconstructed time domain signals of previous frames.
-         */
-
-        /* The data is stored in TWO buffers, either as...
-         *
-         *                                       [   t ==  0  ]
-         *
-         * [   t == -1   ][   t == -2   ]
-         *
-         * OR...
-         *                                       [   t ==  0  ]
-         *
-         * [   t == -2   ][   t == -1   ]
-         *
-         *
-         *
-         * In the first case, all of the buffers are non-contiguous,
-         * and each must be handled separately.  Code for this first case
-         * will function correctly for both cases.
-         *
-         * In the second case, the buffers storing t == -2, and t == -1
-         * data are contiguous, and an optimization could take advantage
-         * of this, at the cost of an increase in code size for this function.
-         */
-
-        /* Decrement block_length by num_samples.  This is important
-         * for the loop at the end of the "ACCESS DATA IN THE LTP BUFFERS"
-         * section that sets all remaining samples in the block to zero.
-         */
-
-        block_length -= num_samples;
-
-
-
-
-
-
-        /*
-         ************************************ ACCESS DATA IN THE LTP BUFFERS
-         */
-
-        /*
-         * This section of the code handles the t == -2
-         * buffer, which corresponds to 0 <= ltp_buffer_index < 1024
-         *
-         * BUFFER t == -2
-         *
-         * [0][][][][][][][][][][][...][][][][][][][][][][][][1023]
-         *
-         */
-
-        jump_point = (frame_length - ltp_buffer_index);
-
-        if (jump_point > 0)
-        {
-            pBuffer = &(buffer[ltp_buffer_index + buffer_offset]);
-
-            for (k = jump_point; k > 0; k--)
-            {
-                /* Q15 = Q15 * Q0 */
-                test = (Int32) weight * (*(pBuffer++));
-                *(pPredicted_samples++) =  test;
-                max                   |= (test >> 31) ^ test;
-            }
-
-            num_samples -= jump_point;
-
-            ltp_buffer_index += jump_point;
-        }
-
-        /*
-         * This section of the code handles the t == -1
-         * buffer, which corresponds to 1024 <= ltp_buffer_index < 2048
-         *
-         * BUFFER t == -1
-         *
-         * [1024][][][][][][][][][][][...][][][][][][][][][][][][2047]
-         *
-         */
-
-        jump_point = 2 * frame_length - ltp_buffer_index;
-
-        pBuffer = &(buffer[ltp_buffer_index - buffer_offset]);
-
-        if (num_samples < jump_point)
-        {
-            jump_point = num_samples;
-        }
-
-        for (k = jump_point; k > 0; k--)
-        {
-            /* Q15 = Q15 * Q0 */
-            test = (Int32) weight * (*(pBuffer++));
-            *(pPredicted_samples++) =  test;
-            max                   |= (test >> 31) ^ test;
-        }
-
-        num_samples -= jump_point;
-
-        ltp_buffer_index += jump_point;
-
-        /*
-         * This section of the code handles the t == 0
-         * buffer, which corresponds to 2048 <= ltp_buffer_index < 3072
-         *
-         * BUFFER t == 0
-         *
-         * [2048][][][][][][][][][][][...][][][][][][][][][][][][3071]
-         *
-         */
-        for (k = num_samples; k > 0; k--)
-        {
-
-            datum = *(pTimeQuant++) >> SCALING;
-
-            /*
-             * Limit the values in the 32-bit filterbank's buffer to
-             * 16-bit resolution.
-             *
-             * Value's greater than 32767 or less than -32768 are saturated
-             * to 32767 and -32768, respectively.
-             */
-
-            test                    = (Int32)datum * weight;
-            *(pPredicted_samples++) =  test;
-            max                    |= (test >> 31) ^ test;
-
-        }
-
-        /* Set any remaining samples in the block to 0. */
-
-        pv_memset(
-            pPredicted_samples,
-            0,
-            block_length*sizeof(*pPredicted_samples));
-
-    } /* if (win_seq != EIGHT_SHORT_SEQUENCE) */
-
-
-    /*****************************************/
-    /* LTP decoding process for short window */
-    /*****************************************/
-
-    /*
-     * For short window LTP, since there is no "ltp_short_lag"
-     * information being passed, the following code for short
-     * window LTP will be applied in the future when those
-     * information are available.
-     */
-
-    /*
-     *----------------------------------------------------------------------------
-     *  else
-     *  {
-     *      for (wnd = 0; wnd < short_window_num; wnd++)
-     *      {
-     *          if (win_prediction_used[wnd] != FALSE)
-     *          {
-     *              delay[wnd] = delay[0] + ltp_short_lag[wnd];
-     *
-     *              lag = delay[wnd];
-     *
-     *              j = wnd*short_block_length - lag;
-     *
-     *              if (lag < short_frame_length)
-     *              {
-     *                  num_samples = short_frame_length + lag;
-     *              }
-     *              else
-     *              {
-     *                  num_samples = short_block_length;
-     *              }
-     *
-     *              pBuffer = &buffer[j];
-     *
-     *              for(i = num_samples; i>0; i--)
-     *              {
-     *                  *(pPredicted_samples++) = weight * (*(pBuffer++));
-     *              }
-     *
-     *              for(i = short_block_length - num_samples; i>0; i--)
-     *              {
-     *                  *(pPredicted_samples++) = 0;
-     *              }
-     *          }
-     *          else
-     *          {
-     *              pv_memset(
-     *                  pPredicted_samples,
-     *                  0,
-     *                  sizeof(*pPredicted_samples)*short_block_length);
-     *
-     *              pPredicted_samples += short_block_length;
-     *          }
-     *      }
-     *  }
-     *----------------------------------------------------------------------------
-     */
-
-    shift = 16 - pv_normalize(max);
-
-    if (shift < 0)
-    {
-        shift = 0;
-    }
-
-    /*----------------------------------------------------------------------------
-    ; Return nothing or data or data pointer
-    ----------------------------------------------------------------------------*/
-    return (shift);
-} /* long_term_prediction */
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_prediction.h b/media/libstagefright/codecs/aacdec/long_term_prediction.h
deleted file mode 100644
index 014934b..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_prediction.h
+++ /dev/null
@@ -1,122 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_prediction.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified prototype with array size passed in per review
-              comments.
-
- Description: Changed prototype with "weight_index" instead of "weight".
-
- Description: Removed some passed in buffer size variables since they are
-              not being used for long window.
-
- Description: Temporarily define LTP_Q_FORMAT for current release.
-              Need to change function prototype and pass out Q_format
-              information later.
-
- Description: Updated function prototype to reflect the usage of a
- circular buffer by LTP.
-
- Description:  Updated function interface with new return type
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function prototype declaration for long_term_prediction().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LONG_TERM_PREDICTION_H
-#define LONG_TERM_PREDICTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define LTP_Q_FORMAT    (15)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    Int long_term_prediction(
-        WINDOW_SEQUENCE     win_seq,
-        const Int           weight_index,
-        const Int           delay[],
-        const Int16         buffer[],
-        const Int           buffer_offset,
-        const Int32         time_quant[],
-        Int32               predicted_samples[],    /* Q15 */
-        const Int           frame_length);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp b/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp
deleted file mode 100644
index c361db1..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_synthesis.cpp
+++ /dev/null
@@ -1,1158 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_synthesis.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made the following changes based on the review comments.
-              1. Separated "shift_factor>=0" on line 395 to "shift_factor>0"
-                 and "shift_factor=0" two cases.
-              2. Added comments on line 393 to explain why factor 2 is being
-                 used to calculate shift_factor.
-              3. Added comments for short window implementation.
-              4. Changed "*(pPredicted_spectral++) = *pPredicted_spectral>>2"
-                 to "*(pPredicted++)>>=2" although they are the same.
-              5. Changed pseudo code "X+=Y" to "X=X+Y".
-              6. Fixed ending comment of "for" loop.
-              7. Passed in the size of the array and deleted some of the
-                 include files.
-
- Description: Unroll the loops.
-
- Description: Changed index "wnd" in previous line 584 with "wnd_offset"
-              and made other correspondent changes to the code.
-
-
- Description: Based on Ken's suggestion, modified the function with the
-              passing-in Q format as scalefactor band basis in order to
-              simplify TNS block functions.
-
- Description: Optimization.
-
- Description: Made changes based on review comments.
-              1. Changed misspellings.
-              2. Changed win_sfb_top[] from two dimensional array to one
-              dimensional array and correspondently changed the code.
-              3. Changed function prototype to remove some redundant
-              informations.
-              4. Fixed the adjusting Q format part code.
-              5. Fixed lines 825, 826 with correct updating pointers.
-
- Description: Due to TNS and LTP Q format issue, added code to adjust
-              predicted_spectral() to maximum resolution before perform
-              long term synthesis.
-
- Description: Modified based on review comments.
-
- Description: Changed "max" data type from UInt to UInt32.
-
- Description: Changed so that nothing is done for the case of "all zero"
- data coming from the output of Trans4m_time_2_freq. Also, included more
- efficient calculation of the abs(x).  And, I updated the pseudocode.
-
- Description: Use an auxiliary variable temp, to avoid using the same
-    pointer and a post-increment pointer in the same line. This may not
-    work with all compilers.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    win_seq = type of window sequence (WINDOW_SEQUENCE).
-    sfb_per_win = number of scalefactor bands for each window, 1024 for
-                  long window, 128 for short window, type of Int.
-    win_sfb_top = buffer (Int16) containing the top coefficient per
-                  scalefactor band for each window.
-    win_prediction_used = buffer (Int) containing the prediction flag
-                          information for short windows. Each item in the
-                          buffer toggles prediction on(1)/off(0) for each
-                          window separately.
-    sfb_prediction_used = buffer (Int) containing the prediction flag
-                          information for scalefactor band(sfb). Each item
-                          toggle prediction on(1)/off(0) on each scalefactor
-                          band of every window.
-    current_frame = channel buffer (Int32) containing the dequantized
-                    spectral coefficients or errors of current frame.
-    q_format = buffer (Int) containing Q format for each scalefactor band of
-               input current_frame.
-    predicted_spectral = buffer (Int32) containing predicted spectral
-                         components of current frame.
-    pred_q_format = Q format (Int) for predicted spectral components of
-                    current frame.
-    coef_per_win = number of coefficients per window for short windows.
-                   type of Int.
-    short_window_num = number of short windows, type of Int.
-    reconstruct_sfb_num = number of scalefactor bands used for reconstruction
-                          for short windows, type of Int.
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    current_frame contents are the dequantized spectrum with a prediction
-    vector added when prediction is turned on.
-
-    q_format contents are updated with the new Q format (Int) for each
-    scalefactor band of output current_frame buffer.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function performs long term synthesis using transmitted spectral
- coeffients or errors and predicted spectral components.
-
- Long term synthesis is part of long term prediction (LTP) which is used to
- reduce the redundancy of a signal between successive coding frames. The
- functionality of long term synthesis is to reconstruct the frequency domain
- spectral by adding the predicted spectral components and the transmitted
- spectral error when prediction is turned on.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- None
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3: Audio
-        Subpart 4.6.6   Long Term Prediction (LTP)
-
- (2) MPEG-2 NBC Audio Decoder
-     "This software module was originally developed by Nokia in the course
-     of development of the MPEG-2 AAC/MPEG-4 Audio standard ISO/IEC13818-7,
-     14496-1, 2 and 3. This software module is an implementation of a part
-     of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the MPEG-2
-     aac/MPEG-4 Audio standard. ISO/IEC  gives users of the MPEG-2aac/MPEG-4
-     Audio standards free license to this software module or modifications
-     thereof for use in hardware or software products claiming conformance
-     to the MPEG-2 aac/MPEG-4 Audio  standards. Those intending to use this
-     software module in hardware or software products are advised that this
-     use may infringe existing patents. The original developer of this
-     software module, the subsequent editors and their companies, and ISO/IEC
-     have no liability for use of this software module or modifications
-     thereof in an implementation. Copyright is not released for non MPEG-2
-     aac/MPEG-4 Audio conforming products. The original developer retains
-     full right to use the code for the developer's own purpose, assign or
-     donate the code to a third party and to inhibit third party from using
-     the code for non MPEG-2 aac/MPEG-4 Audio conforming products. This
-     copyright notice must be included in all copies or derivative works.
-     Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pPredicted_spectral = &predicted_spectral[0];
-    pPredicted_spectral_start = pPredicted_spectral;
-    pSfb_prediction_used = &sfb_prediction_used[0];
-
-    IF (win_seq != EIGHT_SHORT_SEQUENCE)
-    THEN
-
-        sfb_offset = 0;
-
-        pWinSfbTop = &pWin_sfb_top[0];
-
-        pQ_format = &q_format[0];
-
-        FOR (i = sfb_per_frame; i>0; i--)
-
-            IF (*(pSfb_prediction_used++) != FALSE)
-            THEN
-
-                pPredicted_offset = pPredicted_spectral_start +
-                                                            sfb_offset;
-                pCurrent_frame = &current_frame[sfb_offset];
-
-                quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
-                max = 0;
-
-                pPredicted_spectral = pPredicted_offset;
-
-                FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--)
-
-                    tmpInt32 = *(pPredicted_spectral++);
-
-                    IF (tmpInt32 < 0)
-                    THEN
-
-                        tmpInt32 = -tmpInt32;
-
-                    ENDIF
-
-                    max |= tmpInt32;
-
-                ENDFOR
-
-                tmpInt = 0;
-
-                IF (max != 0)
-                THEN
-
-                    WHILE (max < 0x40000000L)
-
-                        max <<= 1;
-                        tmpInt++;
-
-                    ENDWHILE
-
-                    pPredicted_spectral = pPredicted_offset;
-
-                    FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                        *(pPredicted_spectral++) <<= tmpInt;
-                        *(pPredicted_spectral++) <<= tmpInt;
-                        *(pPredicted_spectral++) <<= tmpInt;
-                        *(pPredicted_spectral++) <<= tmpInt;
-
-                    ENDFOR
-
-                    adjusted_pred_q = pred_q_format + tmpInt;
-
-                    pPredicted_spectral = pPredicted_offset;
-
-                    shift_factor = *(pQ_format) - adjusted_pred_q;
-
-                    IF ((shift_factor >= 0) && (shift_factor < 31))
-                    THEN
-
-                        shift_factor = shift_factor + 1;
-
-                        FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                            *(pCurrent_frame++) =
-                                (*pCurrent_frame>>shift_factor)
-                              + (*(pPredicted_spectral++)>>1);
-                            *(pCurrent_frame++) =
-                                (*pCurrent_frame>>shift_factor)
-                              + (*(pPredicted_spectral++)>>1);
-                            *(pCurrent_frame++) =
-                                (*pCurrent_frame>>shift_factor)
-                              + (*(pPredicted_spectral++)>>1);
-                            *(pCurrent_frame++) =
-                                (*pCurrent_frame>>shift_factor)
-                              + (*(pPredicted_spectral++)>>1);
-
-                        ENDFOR
-
-                        *(pQ_format) = adjusted_pred_q - 1;
-
-                    ELSEIF (shift_factor >= 31)
-                    THEN
-
-                        FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                            *(pCurrent_frame++) = *(pPredicted_spectral++);
-                            *(pCurrent_frame++) = *(pPredicted_spectral++);
-                            *(pCurrent_frame++) = *(pPredicted_spectral++);
-                            *(pCurrent_frame++) = *(pPredicted_spectral++);
-
-                        ENDFOR
-
-                        *(pQ_format) = adjusted_pred_q;
-
-                    ELSEIF ((shift_factor < 0) && (shift_factor > -31))
-                    THEN
-
-                        shift_factor = 1 - shift_factor;
-
-                        FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                            *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                (*(pPredicted_spectral++)>>shift_factor);
-                            *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                (*(pPredicted_spectral++)>>shift_factor);
-                            *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                (*(pPredicted_spectral++)>>shift_factor);
-                            *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                (*(pPredicted_spectral++)>>shift_factor);
-
-                        ENDFOR
-
-                        *(pQ_format) = *(pQ_format) - 1;
-
-                    ENDIF
-
-                ENDIF
-
-            ENDIF [ IF (*(pSfb_prediction_used++) != FALSE) ]
-
-            sfb_offset = *pWinSfbTop;
-            pWinSfbTop = pWinSfbTop + 1;
-            pQ_format = pQ_format + 1;
-
-        ENDFOR [ FOR (i = sfb_per_frame; i>0; i--) ]
-
-    ELSE
-
-        pCurrent_frame_start = &current_frame[0];
-
-        pQ_format_start = &q_format[0];
-
-        num_sfb = sfb_per_win[0];
-
-        FOR (wnd=0; wnd<short_window_num; wnd++)
-
-            pWinSfbTop = &pWin_sfb_top[0];
-
-            pQ_format = pQ_format_start;
-
-            IF (win_prediction_used[wnd] != FALSE)
-            THEN
-
-                sfb_offset = 0;
-
-                FOR (i = reconstruct_sfb_num; i > 0; i--)
-
-                    pPredicted_offset = pPredicted_spectral_start +
-                                                                sfb_offset;
-                    pCurrent_frame = pCurrent_frame_start + sfb_offset;
-
-                    quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
-                    max = 0;
-
-                    pPredicted_spectral = pPredicted_offset;
-
-                    FOR (j = (*pWinSfbTop - sfb_offset); j>0 ; j--)
-
-                        tmpInt32 = *(pPredicted_spectral++);
-
-                        IF (tmpInt32 < 0)
-                        THEN
-
-                            tmpInt32 = -tmpInt32;
-
-                        ENDIF
-
-                        max |= tmpInt32;
-
-                    ENDFOR
-
-                    tmpInt = 0;
-
-                    IF (max != 0)
-                    THEN
-
-                        WHILE (max < 0x40000000L)
-
-                            max <<= 1;
-                            tmpInt++;
-
-                        ENDWHILE
-
-
-                        pPredicted_spectral = pPredicted_offset;
-
-                        FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                            *(pPredicted_spectral++) <<= tmpInt;
-                            *(pPredicted_spectral++) <<= tmpInt;
-                            *(pPredicted_spectral++) <<= tmpInt;
-                            *(pPredicted_spectral++) <<= tmpInt;
-
-                        ENDFOR
-
-                        adjusted_pred_q = pred_q_format + tmpInt;
-
-                        pPredicted_spectral = pPredicted_offset;
-
-                        shift_factor = *(pQ_format) - adjusted_pred_q;
-
-                        IF ((shift_factor >= 0) && (shift_factor < 31))
-                        THEN
-
-                            shift_factor = shift_factor + 1;
-
-                            FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                                *(pCurrent_frame++) =
-                                    (*pCurrent_frame>>shift_factor) +
-                                                (*(pPredicted_spectral++)>>1);
-                                *(pCurrent_frame++) =
-                                    (*pCurrent_frame>>shift_factor) +
-                                                (*(pPredicted_spectral++)>>1);
-                                *(pCurrent_frame++) =
-                                    (*pCurrent_frame>>shift_factor) +
-                                                (*(pPredicted_spectral++)>>1);
-                                *(pCurrent_frame++) =
-                                    (*pCurrent_frame>>shift_factor) +
-                                                (*(pPredicted_spectral++)>>1);
-
-                            ENDFOR
-
-                            *(pQ_format) = adjusted_pred_q - 1;
-
-                        ELSEIF (shift_factor >= 31)
-                        THEN
-
-                            FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                                *(pCurrent_frame++) = *(pPredicted_spectral++);
-                                *(pCurrent_frame++) = *(pPredicted_spectral++);
-                                *(pCurrent_frame++) = *(pPredicted_spectral++);
-                                *(pCurrent_frame++) = *(pPredicted_spectral++);
-
-                            ENDFOR
-
-                            *(pQ_format) = adjusted_pred_q;
-
-                        ELSEIF ((shift_factor < 0) && (shift_factor > -31))
-                        THEN
-
-                            shift_factor = 1 - shift_factor;
-
-                            FOR (j = quarter_sfb_width; j>0 ; j--)
-
-                                *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                    (*(pPredicted_spectral++)>>shift_factor);
-                                *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                    (*(pPredicted_spectral++)>>shift_factor);
-                                *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                    (*(pPredicted_spectral++)>>shift_factor);
-                                *(pCurrent_frame++) = (*pCurrent_frame>>1) +
-                                    (*(pPredicted_spectral++)>>shift_factor);
-
-                            ENDFOR
-
-                            *(pQ_format) = *(pQ_format) - 1;
-
-                        ENDIF
-
-                    ENDIF
-
-                    sfb_offset = *pWinSfbTop;
-                    pWinSfbTop = pWinSfbTop + 1;
-                    pQ_format = pQ_format + 1;
-
-                ENDFOR [ FOR (i = reconstruct_sfb_num; i > 0; i--) ]
-
-            ENDIF [ IF (win_prediction_used[wnd] != FALSE) ]
-
-            pPredicted_spectral_start = pPredicted_spectral_start + num_sfb;
-            pCurrent_frame_start = pCurrent_frame_start + num_sfb;
-            wnd_offset = wnd_offset + num_sfb;
-            pQ_format_start = pQ_format_start + num_sfb;
-
-        ENDFOR [ FOR (wnd=0; wnd<short_window_num; wnd++) ]
-
-    ENDIF [ IF (win_seq != EIGHT_SHORT_SEQUENCE) ]
-
-    RETURN
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "long_term_synthesis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void long_term_synthesis(
-    WINDOW_SEQUENCE     win_seq,
-    Int                 sfb_per_win,
-    Int16               win_sfb_top[],
-    Int                 win_prediction_used[],
-    Int                 sfb_prediction_used[],
-    Int32               current_frame[],
-    Int                 q_format[],         /* for each sfb */
-    Int32               predicted_spectral[],
-    Int                 pred_q_format,      /* for predicted_spectral[] */
-    Int                 coef_per_win,
-    Int                 short_window_num,
-    Int                 reconstruct_sfb_num)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    /* Scalefactor band offset */
-    Int sfb_offset;
-
-    /* Window index */
-    Int wnd;
-
-    /* Pointer to array containing predicted samples */
-    Int32 *pPredicted_spectral;
-
-    /* Pointer to the beginning of array containing predicted samples */
-    Int32 *pPredicted_spectral_start;
-
-    Int32 *pPredicted_offset;
-
-    /* Pointer to array containing current spectral components for a channel*/
-    Int32 *pCurrent_frame;
-
-    /* Another pointer to array containing current spectral components */
-    Int32 *pCurrent_frame_start;
-
-    /* Pointer to prediction flag for each scalefactor band */
-    Int *pSfb_prediction_used;
-
-    /* Pointer to top coef per scalefactor band */
-    Int16 *pWinSfbTop;
-
-    /* Pointer to q_format array */
-    Int *pQ_format;
-    Int *pQ_format_start;
-    Int32   temp;
-
-    Int i;
-    Int j;
-
-    Int quarter_sfb_width;
-    Int num_sfb;
-    Int shift_factor;
-
-    UInt32  max;
-    Int32   tmpInt32;
-
-    Int tmpInt;
-    Int adjusted_pred_q;
-    Int pred_shift;
-
-    /*----------------------------------------------------------------------------
-    ; Function body here
-    ----------------------------------------------------------------------------*/
-    /* Initialize pointers */
-    pPredicted_spectral = &predicted_spectral[0];
-    pPredicted_spectral_start = pPredicted_spectral;
-
-    /*
-     * NOTE:
-     * sfb_prediction_used[] start from 0 or 1 depending on nok_lt_decode.c;
-     * currently we agree to make it start from 0;
-     */
-    pSfb_prediction_used = &sfb_prediction_used[0];
-
-    /*********************************/
-    /* LTP synthesis for long window */
-    /*********************************/
-    if (win_seq != EIGHT_SHORT_SEQUENCE)
-    {
-
-        /*******************************************************/
-        /* Reconstruction of current frequency domain spectrum */
-        /*******************************************************/
-
-        /* Initialize scalefactor band offset */
-        sfb_offset = 0;
-
-        /*
-         * Reconstruction is processed on scalefactor band basis.
-         * 1. When prediction is turned on, all the predicted spectral
-         * components will be used for reconstruction.
-         * 2. When prediction is turned off, reconstruction is not
-         * needed. Spectral components of current frame will directly
-         * come from the transmitted data.
-         */
-        pWinSfbTop = &win_sfb_top[0];
-
-        pQ_format = &q_format[0];
-
-        for (i = sfb_per_win; i > 0; i--)
-        {
-            /* Check prediction flag for each scalefactor band. */
-            if (*(pSfb_prediction_used++) != FALSE)
-            {
-                /*
-                 * Prediction is on. Do reconstruction routine.
-                 * Reconstruct spectral component of current
-                 * frame by adding the predicted spectral
-                 * components and the quantized prediction
-                 * errors that reconstructed from transmitted
-                 * data when prediction is turned on.
-                 */
-
-                /* Set pointers to the offset of scalefactor bands */
-                pPredicted_offset = pPredicted_spectral_start +
-                                    sfb_offset;
-                pCurrent_frame = &current_frame[sfb_offset];
-
-                /*
-                 * (*pWinSfbTop - sfb_offset) is number of coefficients
-                 * of the scalefactor band.
-                 * ">>2" is used to set up for later unrolling the loop.
-                 */
-                quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
-                /*
-                 * Adjust pred_q_format and predicted_spectral() to
-                 * maximum resolution.
-                 */
-                max = 0;
-
-                pPredicted_spectral = pPredicted_offset;
-
-                /* Find the maximum absolute value */
-                for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--)
-                {
-                    tmpInt32 = *(pPredicted_spectral++);
-
-                    /*
-                     * Note: overflow is protected here even though
-                     * tmpInt32 = 0x80000000 is very rare case.
-                     *
-                     *  if (tmpInt32 == LONG_MIN)
-                     *  {
-                     *      tmpInt32 = LONG_MAX;
-                     *  }
-                     *  if (tmpInt32 < 0)
-                     *  {
-                     *      tmpInt32 = -tmpInt32;
-                     *  }
-                     */
-
-                    max |= tmpInt32 ^(tmpInt32 >> 31);
-                }
-
-                /*
-                 * IF the LTP data is all zeros
-                 * (max == 0) - do nothing for this sfb.
-                 */
-
-                if (max != 0)
-                {
-                    /* Find the number of bits to reach the max resolution */
-                    tmpInt = 0;
-
-                    while (max < 0x40000000L)
-                    {
-                        max <<= 1;
-                        tmpInt++;
-                    }
-
-                    /*
-                     * The following codes are combinded into shift factor
-                     * adjusting and reconstruction section.
-                     *
-                     * pPredicted_spectral = pPredicted_offset;
-                     * for(j = quarter_sfb_width; j>0 ; j--)
-                     * {
-                     *      *(pPredicted_spectral++) <<= tmpInt;
-                     *      *(pPredicted_spectral++) <<= tmpInt;
-                     *      *(pPredicted_spectral++) <<= tmpInt;
-                     *      *(pPredicted_spectral++) <<= tmpInt;
-                     * }
-                     *
-                     */
-
-                    /* Adjust Q format for predicted_spectral() */
-                    adjusted_pred_q = pred_q_format + tmpInt;
-
-                    /*
-                     * Adjust Q format to prevent overflow that may occur during
-                     * frequency domain reconstruction.
-                     *
-                     */
-                    pPredicted_spectral = pPredicted_offset;
-
-                    shift_factor = *(pQ_format) - adjusted_pred_q;
-
-                    if ((shift_factor >= 0) && (shift_factor < 31))
-                    {
-                        shift_factor = shift_factor + 1;
-                        pred_shift = tmpInt - 1;
-
-                        if (pred_shift >= 0)
-                        {
-                            for (j = quarter_sfb_width; j > 0 ; j--)
-                            {
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) << pred_shift);
-                            }
-                        }
-                        else
-                        {
-                            for (j = quarter_sfb_width; j > 0 ; j--)
-                            {
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) >> 1);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) >> 1);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) >> 1);
-                                temp = *pCurrent_frame >> shift_factor;
-                                *(pCurrent_frame++) = temp
-                                                      + (*(pPredicted_spectral++) >> 1);
-                            }
-                        }
-
-                        /* Updated new Q format for current scalefactor band */
-                        *(pQ_format) = adjusted_pred_q  - 1;
-                    }
-                    else if (shift_factor >= 31)
-                    {
-                        for (j = quarter_sfb_width; j > 0 ; j--)
-                        {
-                            *(pCurrent_frame++) =
-                                *(pPredicted_spectral++) << tmpInt;
-                            *(pCurrent_frame++) =
-                                *(pPredicted_spectral++) << tmpInt;
-                            *(pCurrent_frame++) =
-                                *(pPredicted_spectral++) << tmpInt;
-                            *(pCurrent_frame++) =
-                                *(pPredicted_spectral++) << tmpInt;
-                        }
-
-                        /* Updated new Q format for current scalefactor band */
-                        *(pQ_format) = adjusted_pred_q ;
-                    }
-                    else if ((shift_factor < 0) && (shift_factor > -31))
-                    {
-                        shift_factor = 1 - shift_factor;
-                        pred_shift = tmpInt - shift_factor;
-
-                        if (pred_shift >= 0)
-                        {
-                            for (j = quarter_sfb_width; j > 0 ; j--)
-                            {
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) << pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) << pred_shift);
-                            }
-                        }
-                        else
-                        {
-                            pred_shift = -pred_shift;
-
-                            for (j = quarter_sfb_width; j > 0 ; j--)
-                            {
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) >> pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) >> pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) >> pred_shift);
-                                temp = *pCurrent_frame >> 1;
-                                *(pCurrent_frame++) =  temp +
-                                                       (*(pPredicted_spectral++) >> pred_shift);
-                            }
-                        }
-
-                        /*
-                         * Updated new Q format for current scalefactor band
-                         *
-                         * This is NOT a pointer decrement
-                         */
-                        (*pQ_format)--;
-                    }
-
-                } /* if (max != 0) */
-
-                /*
-                 * For case (shift_factor <= -31), *pCurrent_frame and
-                 * *pQ_format do not need to be updated.
-                 */
-
-            } /* if (*(pSfb_prediction_used++) != FALSE) */
-
-            /* Updated to next scalefactor band. */
-            sfb_offset = *(pWinSfbTop++);
-
-            /* Updated pointer to next scalefactor band's Q-format */
-            pQ_format++;
-
-        } /* for (i = sfb_per_frame; i>0; i--) */
-
-    } /* if (win_seq!=EIGHT_SHORT_SEQUENCE) */
-
-    /**********************************/
-    /* LTP synthesis for short window */
-    /**********************************/
-    else
-    {
-        /******************************************************/
-        /*Reconstruction of current frequency domain spectrum */
-        /******************************************************/
-        pCurrent_frame_start = &current_frame[0];
-
-        pQ_format_start = &q_format[0];
-
-        num_sfb = sfb_per_win;
-
-        /* Reconstruction is processed on window basis */
-        for (wnd = 0; wnd < short_window_num; wnd++)
-        {
-            pWinSfbTop = &win_sfb_top[0];
-
-            pQ_format = pQ_format_start;
-
-            /* Check if prediction flag is on for each window */
-            if (win_prediction_used[wnd] != FALSE)
-            {
-                /* Initialize scalefactor band offset */
-                sfb_offset = 0;
-
-                /*
-                 * Reconstruction is processed on scalefactor band basis.
-                 * 1. When prediction is turned on, all the predicted
-                 * spectral components will be used for reconstruction.
-                 * 2. When prediction is turned off, reconstruction is
-                 * not needed. Spectral components of current frame
-                 * will directly come from the transmitted data.
-                 */
-
-                /*
-                 * According to ISO/IEC 14496-3 pg.91
-                 * Only the spectral components in first eight scalefactor
-                 * bands are added to the quantized prediction error.
-                 */
-                for (i = reconstruct_sfb_num; i > 0; i--)
-                {
-                    /* Set pointer to the offset of scalefactor bands */
-                    pPredicted_offset = pPredicted_spectral_start +
-                                        sfb_offset;
-                    pCurrent_frame = pCurrent_frame_start + sfb_offset;
-
-                    /*
-                     * Prediction is on. Do reconstruction routine.
-                     * Reconstruct spectral component of
-                     * current frame by adding the predicted
-                     * spectral components and the quantized
-                     * prediction errors that reconstructed
-                     * from transmitted data when prediction
-                     * is turned on.
-                     */
-
-                    /*
-                     * (*pWinSfbTop - sfb_offset) is number of coefficients
-                     * of the scalefactor band.
-                     * ">>2" is used to set up for later unrolling the loop.
-                     */
-                    quarter_sfb_width = (*pWinSfbTop - sfb_offset) >> 2;
-
-                    /*
-                     * Adjust pred_q_format and predicted_spectral() to
-                     * maximum resolution.
-                     */
-                    max = 0;
-                    pPredicted_spectral = pPredicted_offset;
-
-                    /* Find the maximum absolute value */
-                    for (j = (*pWinSfbTop - sfb_offset); j > 0 ; j--)
-                    {
-                        tmpInt32 = *(pPredicted_spectral++);
-
-
-                        /*
-                         * Note: overflow is protected here even though
-                         * tmpInt32 = 0x80000000 is very rare case.
-                         *
-                         *  if (tmpInt32 == LONG_MIN)
-                         *  {
-                         *      tmpInt32 = LONG_MAX;
-                         *  }
-                         *  if (tmpInt32 < 0)
-                         *  {
-                         *      tmpInt32 = -tmpInt32;
-                         *  }
-                         */
-
-                        max |= tmpInt32 ^(tmpInt32 >> 31);
-                    }
-
-                    if (max != 0)
-                    {
-                        /* Find the number of bits to reach
-                         * the max resolution
-                         */
-                        tmpInt = 0;
-
-                        while (max < 0x40000000L)
-                        {
-                            max <<= 1;
-                            tmpInt++;
-                        }
-                        /*
-                         * The following codes are combined into shift factor
-                         * adjusting and reconstruction section.
-                         *
-                         * pPredicted_spectral = pPredicted_offset;
-                         * for(j = quarter_sfb_width; j>0 ; j--)
-                         * {
-                         *      *(pPredicted_spectral++) <<= tmpInt;
-                         *      *(pPredicted_spectral++) <<= tmpInt;
-                         *      *(pPredicted_spectral++) <<= tmpInt;
-                         *      *(pPredicted_spectral++) <<= tmpInt;
-                         * }
-                         *
-                         */
-
-                        /* Adjust Q format for predicted_spectral() */
-                        adjusted_pred_q = pred_q_format + tmpInt;
-
-                        /*
-                         * Adjust Q format to prevent overflow that may occur
-                         * during frequency domain reconstruction.
-                         */
-                        pPredicted_spectral = pPredicted_offset;
-
-                        shift_factor = *(pQ_format) - adjusted_pred_q;
-
-                        if ((shift_factor >= 0) && (shift_factor < 31))
-                        {
-                            shift_factor = shift_factor + 1;
-
-                            pred_shift = tmpInt - 1;
-
-                            if (pred_shift >= 0)
-                            {
-                                for (j = quarter_sfb_width; j > 0 ; j--)
-                                {
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) << pred_shift);
-
-                                }
-                            }
-                            else
-                            {
-                                for (j = quarter_sfb_width; j > 0 ; j--)
-                                {
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) >> 1);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) >> 1);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) >> 1);
-                                    temp = *pCurrent_frame >> shift_factor;
-                                    *(pCurrent_frame++) = temp
-                                                          + (*(pPredicted_spectral++) >> 1);
-                                }
-                            }
-
-                            /* Updated new Q format for current scalefactor band*/
-                            *(pQ_format) = adjusted_pred_q - 1;
-                        }
-                        else if (shift_factor >= 31)
-                        {
-                            for (j = quarter_sfb_width; j > 0 ; j--)
-                            {
-                                *(pCurrent_frame++) =
-                                    *(pPredicted_spectral++) << tmpInt;
-                                *(pCurrent_frame++) =
-                                    *(pPredicted_spectral++) << tmpInt;
-                                *(pCurrent_frame++) =
-                                    *(pPredicted_spectral++) << tmpInt;
-                                *(pCurrent_frame++) =
-                                    *(pPredicted_spectral++) << tmpInt;
-                            }
-
-                            /* Updated new Q format for current scalefactor band*/
-                            *(pQ_format) = adjusted_pred_q;
-                        }
-                        else if ((shift_factor < 0) && (shift_factor > -31))
-                        {
-                            shift_factor = 1 - shift_factor;
-
-                            pred_shift = tmpInt - shift_factor;
-
-                            if (pred_shift >= 0)
-                            {
-                                for (j = quarter_sfb_width; j > 0 ; j--)
-                                {
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) << pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) << pred_shift);
-
-                                }
-                            }
-                            else
-                            {
-                                pred_shift = -pred_shift;
-
-                                for (j = quarter_sfb_width; j > 0 ; j--)
-                                {
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) >> pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) >> pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) >> pred_shift);
-                                    temp = *pCurrent_frame >> 1;
-                                    *(pCurrent_frame++) =  temp +
-                                                           (*(pPredicted_spectral++) >> pred_shift);
-                                }
-                            }
-
-                            /* Updated new Q format for current scalefactor band*/
-                            *(pQ_format) = *(pQ_format) - 1;
-                        }
-
-                        /*
-                         * For case (shift_factor <= -31), *pCurrent_frame and
-                         * *pQ_format do not need to be updated.
-                         */
-
-                    } /* if (max != 0) */
-
-                    /* Updated to next scalefactor band. */
-                    sfb_offset = *(pWinSfbTop++);
-
-                    /* Updated pointer to next scalefactor band's Q-format */
-                    pQ_format++;
-
-                } /* for (i = reconstruct_sfb_num; i > 0; i--) */
-
-            } /* if (win_prediction_used[wnd] != FALSE) */
-
-            /* Updated to next window */
-            pPredicted_spectral_start += coef_per_win;
-            pCurrent_frame_start += coef_per_win;
-            pQ_format_start += num_sfb;
-
-        } /* for (wnd=0; wnd<short_window_num; wnd++) */
-
-    } /* else */
-
-    /*----------------------------------------------------------------------------
-    ; Return nothing or data or data pointer
-    ----------------------------------------------------------------------------*/
-    return;
-} /* long_term_synthesis */
-
-
diff --git a/media/libstagefright/codecs/aacdec/long_term_synthesis.h b/media/libstagefright/codecs/aacdec/long_term_synthesis.h
deleted file mode 100644
index 1195709..0000000
--- a/media/libstagefright/codecs/aacdec/long_term_synthesis.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: long_term_synthesis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: 1. Changed protoype with array size passed in per review
-                 comments.
-              2. Moved #define NUM_RECONSTRUCTED_SFB to ltp_common_internal.h
-
- Description: Modified prototype based on review comments for new version
-          long_term_synthesis.c.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function prototype declaration for long_term_synthesis().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LONG_TERM_SYNTHESIS_H
-#define LONG_TERM_SYNTHESIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void long_term_synthesis(
-    WINDOW_SEQUENCE     win_seq,
-    Int                 sfb_per_win,
-    Int16               win_sfb_top[],
-    Int                 win_prediction_used[],
-    Int                 sfb_prediction_used[],
-    Int32               current_frame[],
-    Int                 q_format[],
-    Int32               predicted_spectral[],
-    Int                 pred_q_format,
-    Int                 coef_per_win,
-    Int                 short_window_num,
-    Int                 reconstruct_sfb_num);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/lt_decode.cpp b/media/libstagefright/codecs/aacdec/lt_decode.cpp
deleted file mode 100644
index e5f5f91..0000000
--- a/media/libstagefright/codecs/aacdec/lt_decode.cpp
+++ /dev/null
@@ -1,507 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: lt_decode.c
-
-
-------------------------------------------------------------------------------
-
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  First round of optimizations.
-
- Description:  pInputStream is now the 2nd parameter to this function.
-
- Description:  Changed to work with MT's new get_ics_info.c function, which
- only calls lt_decode if LTP is enabled.  This removes one grab from the
- bitstream and one "if" from this code.  Also, changed setting of weight.
- Now, rather than setting the actual weight, I only set the index into
- a table in this function.
-
- Description: Replace some instances of getbits to get9_n_lessbits
-              when the number of bits read is 9 or less and get1bits
-              when only 1 bit is read.
-
- Who:                                   Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    win_type        Type of window (SHORT or LONG)
-                    [WINDOW_TYPE]
-
-    max_sfb         Maximum number of active scalefactor bands
-                    [Int]
-
-    pLt_pred        Pointer to structure containing information for
-                    long-term prediction.
-                    [LT_PRED_STATUS *]
-
-    pInputStream    Pointer to structure containing bitstream
-                    information.
-                    [BITS *]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    pLt_pred->weight_index - updated with index into weight table for LTP.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes the bitstream elements for long term prediction
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by Nokia
-   in the course of development of the MPEG-2 AAC/MPEG-4 Audio standard
-   ISO/IEC13818-7, 14496-1, 2 and 3.  This software module is an implementation
-   of a part of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
-   MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the
-   MPEG-2aac/MPEG-4 Audio standards free license to this software module or
-   modifications thereof for use in hardware or software products claiming
-   conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those intending to
-   use this software module in hardware or software products are advised that
-   this use may infringe existing patents. The original developer of this
-   software module, the subsequent editors and their companies, and ISO/IEC
-   have no liability for use of this software module or modifications thereof
-   in an implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
-   Audio conforming products. The original developer retains full right to use
-   the code for the developer's own purpose, assign or donate the code to a
-   third party and to inhibit third party from using the code for non
-   MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
-   must be included in all copies or derivative works."
-   Copyright (c)1997.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pDelay[0] = (Int) getbits(
-                        LEN_LTP_LAG,
-                        pInputStream);
-
-    temp_reg  = (Int) getbits(
-                        LEN_LTP_COEF,
-                        pInputStream);
-
-    pLt_pred->weight = codebook[temp_reg];
-
-    last_band = max_sfb;
-
-    IF (win_type != EIGHT_SHORT_SEQUENCE)
-
-        IF (last_band > MAX_LT_PRED_LONG_SFB)
-
-            last_band = MAX_LT_PRED_LONG_SFB;
-
-        ENDIF
-
-        FOR (m = last_band; m > 0; m--)
-
-            *(pSfbPredictionUsed++) = (Int) getbits(
-                                               LEN_LTP_LONG_USED,
-                                               pInputStream);
-        ENDFOR
-
-        FOR (m = (max_sfb - last_band); m > 0; m--)
-
-            *(pSfbPredictionUsed++) = 0;
-
-        ENDFOR
-
-    ELSE
-
-        IF (last_band > MAX_LT_PRED_SHORT_SFB)
-
-            last_band = MAX_LT_PRED_SHORT_SFB;
-
-        ENDIF
-
-        prev_subblock = pDelay[0];
-
-        pWinPredictionUsed++;
-
-        pTempPtr = &pSfbPredictionUsed[0];
-
-        FOR (m = NUM_SHORT_WINDOWS; m > 0;)
-
-            m--;
-            temp_reg = (Int) getbits(
-                                LEN_LTP_SHORT_USED,
-                                pInputStream);
-
-            *(pWinPredictionUsed++) = temp_reg;
-
-            IF (temp_reg != FALSE)
-            {
-                *(pDelay++) = prev_subblock;
-
-                FOR (k = last_band; k > 0; k--)
-                {
-                    *(pTempPtr++) = 1;
-                }
-                break;
-            ELSE
-            {
-                pDelay++;
-                pTempPtr += last_band;
-            }
-
-        ENDFOR (m = NUM_SHORT_WINDOWS; m > 0;)
-
-        prev_subblock += LTP_LAG_OFFSET;
-
-        FOR (; m > 0; m--)
-
-            temp_reg = (Int) getbits (
-                                LEN_LTP_SHORT_USED,
-                                pInputStream);
-
-            *(pWinPredictionUsed++) = temp_reg;
-
-            IF (temp_reg != FALSE)
-
-                temp_reg = (Int) getbits(
-                                    LEN_LTP_SHORT_LAG_PRESENT,
-                                    pInputStream);
-                IF (temp_reg != 0)
-
-                    temp_reg  = (Int) getbits(
-                                         LEN_LTP_SHORT_LAG,
-                                         pInputStream);
-
-                    *(pDelay++) = prev_subblock - temp_reg;
-
-                ELSE
-
-                    *(pDelay++) = prev_subblock - LTP_LAG_OFFSET;
-
-                ENDIF
-
-                FOR (k = last_band; k > 0; k--)
-                    *(pTempPtr++) = 1;
-                ENDFOR
-
-            ELSE
-
-                pDelay++;
-                pTempPtr += last_band;
-
-            ENDIF
-
-        ENDFOR (; m > 0; m--)
-
-    ENDIF (win_type != EIGHT_SHORT_SEQUENCE)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "lt_decode.h"
-#include "ltp_common_internal.h"
-#include "window_block_fxp.h"
-#include "e_window_sequence.h"
-#include "s_lt_pred_status.h"
-#include "s_bits.h"
-#include "ibstream.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void lt_decode(
-    const WINDOW_SEQUENCE  win_type,
-    BITS            *pInputStream,
-    const Int              max_sfb,
-    LT_PRED_STATUS  *pLt_pred)
-{
-    Int wnd_num;
-    Int k;
-    Int last_band;
-    Int prev_subblock;
-    Int prev_subblock_nonzero;
-    Int temp_reg;
-
-    Bool *pWinPredictionUsed = pLt_pred->win_prediction_used;
-    Bool *pSfbPredictionUsed = pLt_pred->sfb_prediction_used;
-    Int  *pTempPtr;
-    Int  *pDelay = pLt_pred->delay;
-
-    pDelay[0] = (Int) get17_n_lessbits(
-                    LEN_LTP_LAG,  /* 11 bits */
-                    pInputStream);
-
-    pLt_pred->weight_index  = (Int) get9_n_lessbits(
-                                  LEN_LTP_COEF, /*  3 bits */
-                                  pInputStream);
-
-    last_band = max_sfb;
-
-    if (win_type != EIGHT_SHORT_SEQUENCE)
-    {
-
-        /* last_band = min(MAX_LT_PRED_LONG_SFB, max_sfb) MAX_SCFAC_BANDS */
-        if (last_band > MAX_LT_PRED_LONG_SFB)
-        {
-            last_band = MAX_LT_PRED_LONG_SFB;
-        }
-
-        for (k = last_band; k > 0; k--)
-        {
-            *(pSfbPredictionUsed++) = (Int) get1bits(pInputStream);
-        }
-
-        /*
-         * This is not a call to memset, because
-         * (max_sfb - last_band) should typically be a small value.
-         */
-        for (k = (max_sfb - last_band); k > 0; k--)
-        {
-            *(pSfbPredictionUsed++) = FALSE;
-        }
-    }
-    else /* (win_type == EIGHT_SHORT_SEQUENCE) */
-    {
-        /* last_band = min(MAX_LT_PRED_SHORT_SFB, max_sfb) */
-
-        if (last_band > MAX_LT_PRED_SHORT_SFB)
-        {
-            last_band = MAX_LT_PRED_SHORT_SFB;
-        }
-
-        /*
-         * The following two coding constructs are equivalent...
-         *
-         *  first_time == 1
-         *  for (wnd_num=NUM_SHORT_WINDOWS; wnd_num > 0; wnd_num--)
-         *  {
-         *     if (condition)
-         *     {
-         *       if (first_time == 1)
-         *       {
-         *           CODE SECTION A
-         *           first_time = 0;
-         *       }
-         *       else
-         *       {
-         *           CODE SECTION B
-         *       }
-         *     }
-         *  }
-         *
-         * -----------------------------------EQUIVALENT TO------------
-         *
-         *  wnd_num=NUM_SHORT_WINDOWS;
-         *
-         *  do
-         *  {
-         *     wnd_num--;
-         *     if (condition)
-         *     {
-         *         CODE SECTION A
-         *         break;
-         *     }
-         *  } while( wnd_num > 0)
-         *
-         *  while (wnd_num > 0)
-         *  {
-         *     if (condition)
-         *     {
-         *         CODE SECTION B
-         *     }
-         *     wnd_num--;
-         *  }
-         *
-         */
-
-        prev_subblock = pDelay[0];
-
-        pTempPtr = &pSfbPredictionUsed[0];
-
-        wnd_num = NUM_SHORT_WINDOWS;
-
-        prev_subblock_nonzero = prev_subblock;
-        prev_subblock += LTP_LAG_OFFSET;
-
-        do
-        {
-            /*
-             * Place decrement of wnd_num here, to insure
-             * that the decrement occurs before the
-             * break out of the do-while loop.
-             */
-            wnd_num--;
-
-            temp_reg = (Int) get1bits(pInputStream);
-
-            *(pWinPredictionUsed++) = temp_reg;
-
-            if (temp_reg != FALSE)
-            {
-                *(pDelay++) = prev_subblock_nonzero;
-
-                for (k = last_band; k > 0; k--)
-                {
-                    *(pTempPtr++) = TRUE;
-                }
-                for (k = (max_sfb - last_band); k > 0; k--)
-                {
-                    *(pTempPtr++) = FALSE;
-                }
-                break;
-
-            } /* if(pWinPredictionUsed) */
-            else
-            {
-                pDelay++;
-                pTempPtr += max_sfb;
-            }
-
-        }
-        while (wnd_num > 0);
-
-        /*
-         * This while loop picks up where the previous one left off.
-         * Notice that the code functions differently inside the loop
-         */
-
-        while (wnd_num > 0)
-        {
-            temp_reg = (Int) get1bits(pInputStream);
-
-            *(pWinPredictionUsed++) = temp_reg;
-
-            if (temp_reg != FALSE)
-            {
-                temp_reg = (Int) get1bits(pInputStream);
-                if (temp_reg != 0)
-                {
-                    temp_reg  = (Int) get9_n_lessbits(
-                                    LEN_LTP_SHORT_LAG,
-                                    pInputStream);
-
-                    *(pDelay++) = prev_subblock - temp_reg;
-                }
-                else
-                {
-                    *(pDelay++) = prev_subblock_nonzero;
-                }
-                for (k = last_band; k > 0; k--)
-                {
-                    *(pTempPtr++) = TRUE;
-                }
-                for (k = (max_sfb - last_band); k > 0; k--)
-                {
-                    *(pTempPtr++) = FALSE;
-                }
-
-            } /* if (temp_reg) */
-            else
-            {
-                pDelay++;
-                pTempPtr += max_sfb;
-            }
-
-            wnd_num--;
-
-        } /* while(wnd_num) */
-
-    } /* else (win_type == EIGHT_SHORT_SEQUENCE) */
-
-} /* lt_decode */
diff --git a/media/libstagefright/codecs/aacdec/lt_decode.h b/media/libstagefright/codecs/aacdec/lt_decode.h
deleted file mode 100644
index c655270..0000000
--- a/media/libstagefright/codecs/aacdec/lt_decode.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: lt_decode.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changing to move pInputStream to 2nd parameter.
-
- Description: Replaced "e_WINDOW_TYPE.h" with "e_WINDOW_SEQUENCE.h"
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the global function declaration for lt_decode
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef LT_DECODE_H
-#define LT_DECODE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_sequence.h"
-#include "s_lt_pred_status.h"
-#include "s_bits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void lt_decode(
-    const WINDOW_SEQUENCE win_type,
-    BITS           *pInputStream,
-    const Int             max_sfb,
-    LT_PRED_STATUS *pLt_pred);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/lt_prediction.h b/media/libstagefright/codecs/aacdec/lt_prediction.h
deleted file mode 100644
index e52a1e8..0000000
--- a/media/libstagefright/codecs/aacdec/lt_prediction.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**************************************************************************
-
-This software module was originally developed by
-Nokia in the course of development of the MPEG-2 AAC/MPEG-4
-Audio standard ISO/IEC13818-7, 14496-1, 2 and 3.
-This software module is an implementation of a part
-of one or more MPEG-2 AAC/MPEG-4 Audio tools as specified by the
-MPEG-2 aac/MPEG-4 Audio standard. ISO/IEC  gives users of the
-MPEG-2aac/MPEG-4 Audio standards free license to this software module
-or modifications thereof for use in hardware or software products
-claiming conformance to the MPEG-2 aac/MPEG-4 Audio  standards. Those
-intending to use this software module in hardware or software products
-are advised that this use may infringe existing patents. The original
-developer of this software module, the subsequent
-editors and their companies, and ISO/IEC have no liability for use of
-this software module or modifications thereof in an
-implementation. Copyright is not released for non MPEG-2 aac/MPEG-4
-Audio conforming products. The original developer retains full right to
-use the code for the developer's own purpose, assign or donate the code to a
-third party and to inhibit third party from using the code for non
-MPEG-2 aac/MPEG-4 Audio conforming products. This copyright notice
-must be included in all copies or derivative works.
-Copyright (c)1997.
-
-***************************************************************************/
-
-#ifndef _LT_PREDICTION_H
-#define _LT_PREDICTION_H
-
-#include "block.h"
-#include "ltp_common.h"
-#include "ibstream.h"
-#include "lt_decode.h"
-#include "s_frameinfo.h"
-#include "window_block.h"
-
-void init_lt_pred(LT_PRED_STATUS * lt_status);
-
-void lt_predict(
-    Int                  object,
-    FrameInfo           *pFrameInfo,
-    WINDOW_SEQUENCE      win_seq,
-    Wnd_Shape           *pWin_shape,
-    LT_PRED_STATUS  *pLt_status,
-    Real                *pPredicted_samples,
-    Real                *pOverlap_buffer,
-    Real                *pCurrent_frame_copy,
-    Real                 current_frame[]);
-
-short double_to_int(double sig_in);
-
-#endif /* not defined _LT_PREDICTION_H */
diff --git a/media/libstagefright/codecs/aacdec/ltp_common_internal.h b/media/libstagefright/codecs/aacdec/ltp_common_internal.h
deleted file mode 100644
index d76ac75..0000000
--- a/media/libstagefright/codecs/aacdec/ltp_common_internal.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/**************************************************************************
-
-This software module was originally developed by
-
-Mikko Suonio (Nokia)
-
-in the course of development of the MPEG-2 NBC/MPEG-4 Audio standard
-ISO/IEC 13818-7, 14496-1,2 and 3. This software module is an
-implementation of a part of one or more MPEG-2 NBC/MPEG-4 Audio tools
-as specified by the MPEG-2 NBC/MPEG-4 Audio standard. ISO/IEC gives
-users of the MPEG-2 NBC/MPEG-4 Audio standards free license to this
-software module or modifications thereof for use in hardware or
-software products claiming conformance to the MPEG-2 NBC/ MPEG-4 Audio
-standards. Those intending to use this software module in hardware or
-software products are advised that this use may infringe existing
-patents. The original developer of this software module and his/her
-company, the subsequent editors and their companies, and ISO/IEC have
-no liability for use of this software module or modifications thereof
-in an implementation. Copyright is not released for non MPEG-2
-NBC/MPEG-4 Audio conforming products. The original developer retains
-full right to use the code for his/her own purpose, assign or donate
-the code to a third party and to inhibit third party from using the
-code for non MPEG-2 NBC/MPEG-4 Audio conforming products. This
-copyright notice must be included in all copies or derivative works.
-
-Copyright (c) 1997.
-
-***************************************************************************/
-
-#ifndef _LTP_COMMON_INTERNAL_H
-#define _LTP_COMMON_INTERNAL_H
-
-
-/*
-  Purpose:      Number of LTP coefficients. */
-#define LPC 1
-
-/*
-  Purpose:      Maximum LTP lag.  */
-#define DELAY 2048
-
-/*
-  Purpose:  Length of the bitstream element ltp_data_present.  */
-#define LEN_LTP_DATA_PRESENT 1
-
-/*
-  Purpose:  Length of the bitstream element ltp_lag.  */
-#define LEN_LTP_LAG 11
-
-/*
-  Purpose:  Length of the bitstream element ltp_coef.  */
-#define LEN_LTP_COEF 3
-
-/*
-  Purpose:  Length of the bitstream element ltp_short_used.  */
-#define LEN_LTP_SHORT_USED 1
-
-/*
-  Purpose:  Length of the bitstream element ltp_short_lag_present.  */
-#define LEN_LTP_SHORT_LAG_PRESENT 1
-
-/*
-  Purpose:  Length of the bitstream element ltp_short_lag.  */
-#define LEN_LTP_SHORT_LAG 5
-
-/*
-  Purpose:  Offset of the lags written in the bitstream.  */
-#define LTP_LAG_OFFSET 16
-
-/*
-  Purpose:  Length of the bitstream element ltp_long_used.  */
-#define LEN_LTP_LONG_USED 1
-
-/*
-  Purpose:  Upper limit for the number of scalefactor bands
-        which can use lt prediction with long windows.
-  Explanation:  Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction.  */
-#define MAX_LT_PRED_LONG_SFB 40
-
-/*
-  Purpose:  Upper limit for the number of scalefactor bands
-        which can use lt prediction with short windows.
-  Explanation:  Bands 0..MAX_LT_PRED_SFB-1 can use lt prediction.  */
-#define MAX_LT_PRED_SHORT_SFB 13
-
-/*
-   Purpose:      Buffer offset to maintain block alignment.
-   Explanation:  This is only used for a short window sequence.  */
-#define SHORT_SQ_OFFSET (BLOCK_LEN_LONG-(BLOCK_LEN_SHORT*4+BLOCK_LEN_SHORT/2))
-
-/*
-  Purpose:  Number of codes for LTP weight. */
-#define CODESIZE 8
-
-/* number of scalefactor bands used for reconstruction for short windows */
-#define NUM_RECONSTRUCTED_SFB (8)
-
-#endif /* _LTP_COMMON_INTERNAL_H */
diff --git a/media/libstagefright/codecs/aacdec/mdct_fxp.cpp b/media/libstagefright/codecs/aacdec/mdct_fxp.cpp
deleted file mode 100644
index df371e8..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_fxp.cpp
+++ /dev/null
@@ -1,450 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_fxp.c
- Funtions: fft_rx2
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    data_quant  = Input vector, with quantized Q15 spectral lines:
-                  type Int32
-
-    Q_FFTarray  = Scratch memory used for in-place IFFT calculation,
-                  min size required 1024, type Int32
-
-    n           = Length of input vector "data_quant". Currently 256 or 2048.
-                  type const Int
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    shift = shift factor to reflect scaling introduced by FFT and mdct_fxp,
-
- Pointers and Buffers Modified:
-    calculation are done in-place and returned in "data_quant"
-
- Local Stores Modified:
-     None
-
- Global Stores Modified:
-     None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    The MDCT is a linear orthogonal lapped transform, based on the idea of
-    time domain aliasing cancellation (TDAC).
-    MDCT is critically sampled, which means that though it is 50% overlapped,
-    a sequence data after MDCT has the same number of coefficients as samples
-    before the transform (after overlap-and-add). This means, that a single
-    block of MDCT data does not correspond to the original block on which the
-    MDCT was performed. When subsequent blocks of data are added (still using
-    50% overlap), the errors introduced by the transform cancels out.
-    Thanks to the overlapping feature, the MDCT is very useful for
-    quantization. It effectively removes the otherwise easily detectable
-    blocking artifact between transform blocks.
-    N = length of input vector X
-    X = vector of length N/2, will hold fixed point DCT
-    k = 0:1:N-1
-
-                        N-1
-            X(m) =  2   SUM   x(k)*cos(pi/(2*N)*(2*k+1+N/2)*(2*m+1))
-                        k=0
-
-
-    The window that completes the TDAC is applied before calling this function.
-    The MDCT can be calculated using an FFT, for this, the MDCT needs to be
-    rewritten as an odd-time odd-frequency discrete Fourier transform. Thus,
-    the MDCT can be calculated using only one n/4 point FFT and some pre and
-    post-rotation of the sample points.
-
-    Computation of the MDCT implies computing
-
-        x  = ( y   - y        ) + j( y       +  y       )
-         n      2n    N/2-1-2n        N-1-2n     N/2+2n
-
-    using the Fast discrete cosine transform as described in [2]
-
-    where x(n) is an input with N points
-
-    x(n) ----------------------------
-                                     |
-                                     |
-                    Pre-rotation by exp(j(2pi/N)(n+1/8))
-                                     |
-                                     |
-                              N/4- point FFT
-                                     |
-                                     |
-                    Post-rotation by exp(j(2pi/N)(k+1/8))
-                                     |
-                                     |
-                                      ------------- DCT
-
-    By considering the N/2 overlap, a relation between successive input blocks
-    is found:
-
-        x   (2n) = x (N/2 + 2n)
-         m+1        m
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should provide a fixed point MDCT with an average
-    quantization error less than 1 %.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] Analysis/Synthesis Filter Bank design based on time domain
-        aliasing cancellation
-        Jhon Princen, et. al.
-        IEEE Transactions on ASSP, vol ASSP-34, No. 5 October 1986
-        Pg 1153 - 1161
-
-    [2] Regular FFT-related transform kernels for DCT/DST based
-        polyphase filterbanks
-        Rolf Gluth
-        Proc. ICASSP 1991, pg. 2205 - 2208
-
-------------------------------------------------------------------------------
-  PSEUDO-CODE
-
-  Cx, Cy are complex number
-
-
-    exp = log2(n)-1
-
-    FOR ( k=0; k< n/4; k +=2)
-
-        Cx =   (data_quant[3n/4 + k] + data_quant[3n/4 - 1 - k]) +
-             j (data_quant[ n/4 + k] - data_quant[ n/4 - 1 - k])
-
-        Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8))
-
-    ENDFOR
-
-    FOR ( k=n/4; k< n/2; k +=2)
-
-        Cx =   (data_quant[3n/4 - 1 - k] + data_quant[ - n/4 + k]) +
-             j (data_quant[5n/4 - 1 - k] - data_quant[   n/4 + k])
-
-        Q_FFTarray = Cx * exp(-j(2pi/n)(k+1/8))
-
-    ENDFOR
-
-    CALL FFT( Q_FFTarray, n/4)
-
-    MODIFYING( Q_FFTarray )
-
-    RETURNING( shift )
-
-    FOR ( k=0; k< n/2; k +=2)
-
-        Cx = Q_FFTarray[ k] + j Q_FFTarray[ k+1]
-
-        Cy = 2 * Cx * exp(-j(2pi/n)(k+1/8))
-
-        data_quant[           k ] = - Real(Cy)
-        data_quant[ n/2 - 1 - k ] =   Imag(Cy)
-        data_quant[ n/2     + k ] = - Imag(Cy)
-        data_quant[ n       - k ] =   Real(Cy)
-
-    ENDFOR
-
-    MODIFIED    data_quant[]
-
-    RETURN      (-shift-1)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "mdct_fxp.h"
-#include "fft_rx4.h"
-#include "mix_radix_fft.h"
-#include "fwd_long_complex_rot.h"
-#include "fwd_short_complex_rot.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define ERROR_IN_FRAME_SIZE 10
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int mdct_fxp(
-    Int32   data_quant[],
-    Int32   Q_FFTarray[],
-    Int     n)
-{
-
-    Int32   temp_re;
-    Int32   temp_im;
-
-    Int32   temp_re_32;
-    Int32   temp_im_32;
-
-    Int16     cos_n;
-    Int16     sin_n;
-    Int32     exp_jw;
-    Int     shift;
-
-
-    const Int32 *p_rotate;
-
-
-    Int32   *p_data_1;
-    Int32   *p_data_2;
-    Int32   *p_data_3;
-    Int32   *p_data_4;
-
-    Int32 *p_Q_FFTarray;
-
-    Int32   max1;
-
-    Int k;
-    Int n_2   = n >> 1;
-    Int n_4   = n >> 2;
-    Int n_8   = n >> 3;
-    Int n_3_4 = 3 * n_4;
-
-    switch (n)
-    {
-        case SHORT_WINDOW_TYPE:
-            p_rotate = (Int32 *)exp_rotation_N_256;
-            break;
-
-        case LONG_WINDOW_TYPE:
-            p_rotate = (Int32 *)exp_rotation_N_2048;
-            break;
-
-        default:
-            /*
-             *  There is no defined behavior for a non supported frame
-             *  size. By returning a fixed scaling factor, the input will
-             *  scaled down and this will be heard as a low level noise
-             */
-            return(ERROR_IN_FRAME_SIZE);
-
-    }
-
-    /*--- Reordering and Pre-rotation by exp(-j(2pi/N)(r+1/8))   */
-    p_data_1 = &data_quant[n_3_4];
-    p_data_2 = &data_quant[n_3_4 - 1];
-    p_data_3 = &data_quant[n_4];
-    p_data_4 = &data_quant[n_4 - 1];
-
-    p_Q_FFTarray = Q_FFTarray;
-
-    max1 = 0;
-
-    for (k = n_8; k > 0; k--)
-    {
-        /*
-         *  scale down to ensure numbers are Q15
-         *  temp_re and temp_im are 32-bit but
-         *  only the lower 16 bits are used
-         */
-
-        temp_re = (*(p_data_1++) + *(p_data_2--)) >> 1;
-        temp_im = (*(p_data_3++) - *(p_data_4--)) >> 1;
-
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-
-        exp_jw = *p_rotate++;
-
-        cos_n = (Int16)(exp_jw >> 16);
-        sin_n = (Int16)(exp_jw & 0xFFFF);
-
-        temp_re_32 = temp_re * cos_n + temp_im * sin_n;
-        temp_im_32 = temp_im * cos_n - temp_re * sin_n;
-        *(p_Q_FFTarray++) = temp_re_32;
-        *(p_Q_FFTarray++) = temp_im_32;
-        max1         |= (temp_re_32 >> 31) ^ temp_re_32;
-        max1         |= (temp_im_32 >> 31) ^ temp_im_32;
-
-
-        p_data_1++;
-        p_data_2--;
-        p_data_4--;
-        p_data_3++;
-    }
-
-
-    p_data_1 = &data_quant[n - 1];
-    p_data_2 = &data_quant[n_2 - 1];
-    p_data_3 = &data_quant[n_2];
-    p_data_4 =  data_quant;
-
-    for (k = n_8; k > 0; k--)
-    {
-        /*
-         *  scale down to ensure numbers are Q15
-         */
-        temp_re = (*(p_data_2--) - *(p_data_4++)) >> 1;
-        temp_im = (*(p_data_1--) + *(p_data_3++)) >> 1;
-
-        p_data_2--;
-        p_data_1--;
-        p_data_4++;
-        p_data_3++;
-
-        /*
-         * cos_n + j*sin_n == exp(j(2pi/N)(k+1/8))
-         */
-
-        exp_jw = *p_rotate++;
-
-        cos_n = (Int16)(exp_jw >> 16);
-        sin_n = (Int16)(exp_jw & 0xFFFF);
-
-        temp_re_32 = temp_re * cos_n + temp_im * sin_n;
-        temp_im_32 = temp_im * cos_n - temp_re * sin_n;
-
-        *(p_Q_FFTarray++) = temp_re_32;
-        *(p_Q_FFTarray++) = temp_im_32;
-        max1         |= (temp_re_32 >> 31) ^ temp_re_32;
-        max1         |= (temp_im_32 >> 31) ^ temp_im_32;
-
-
-    } /* for(k) */
-
-
-
-    p_Q_FFTarray = Q_FFTarray;
-
-    if (max1)
-    {
-
-        if (n != SHORT_WINDOW_TYPE)
-        {
-
-            shift = mix_radix_fft(
-                        Q_FFTarray,
-                        &max1);
-
-            shift += fwd_long_complex_rot(
-                         Q_FFTarray,
-                         data_quant,
-                         max1);
-
-        }
-        else        /*  n_4 is 64 */
-        {
-
-            shift = fft_rx4_short(
-                        Q_FFTarray,
-                        &max1);
-
-            shift += fwd_short_complex_rot(
-                         Q_FFTarray,
-                         data_quant,
-                         max1);
-        }
-
-    }
-    else
-    {
-        shift = -31;
-    }
-
-    /*
-     *  returns shift introduced by FFT and mdct_fxp, 12 accounts for
-     *  regular downshift (14) and MDCT scale factor (-2)
-     *  number are returned as 16 bits
-     */
-    return (12 - shift);
-
-} /* mdct_fxp */
-
diff --git a/media/libstagefright/codecs/aacdec/mdct_fxp.h b/media/libstagefright/codecs/aacdec/mdct_fxp.h
deleted file mode 100644
index b8d5a80..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_fxp.h
+++ /dev/null
@@ -1,107 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_fxp.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: This extern had the incorrect length of the arrays.  The true
- lengths are 128 and 1024, not 64 and 512.
-
- Description:  Modified interface so a vector with extended precision is
-               returned. Added copyright notice.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function mdct_fxp()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MDCT_FXP_H
-#define MDCT_FXP_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-#define     LONG_WINDOW_TYPE  2048
-#define     SHORT_WINDOW_TYPE  256
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    extern const Int exp_rotation_N_256[128];
-    extern const Int exp_rotation_N_2048[1024];
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int mdct_fxp(
-        Int32   data_quant[],
-        Int32   Q_FFTarray[],
-        Int     n);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* MDCT_FXP_H */
diff --git a/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp
deleted file mode 100644
index 709cbf2..0000000
--- a/media/libstagefright/codecs/aacdec/mdct_tables_fxp.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdct_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Created from fft_rx2.c
-
- Description:  Modified to include forward and inverse tables
-
- Who:                       Date:
- Description:
-
-  ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
-    MDCT rotation tables fixpoint tables
-
-    For a table with N complex points:
-
-    cos_n + j*sin_n == exp(j(2pi/N)(n+1/8))
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here. Include conditional
-    ; compile variables also.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; LOCAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; LOCAL VARIABLE DEFINITIONS
-    ; Variable declaration - defined here and used outside this module
-    ----------------------------------------------------------------------------*/
-
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL FUNCTION REFERENCES
-    ; Declare functions defined elsewhere and referenced in this module
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-
-
-
-    extern const Int32 exp_rotation_N_256[64] =
-    {
-
-        0x5A820047,  0x5A7A0280, 0x5A6304B8, 0x5A3E06EF,
-        0x5A0C0926,  0x59CB0B5B, 0x597D0D8E, 0x59210FBF,
-        0x58B711EE,  0x5840141A, 0x57BB1643, 0x57281868,
-        0x56881A8A,  0x55DB1CA8, 0x55201EC1, 0x545820D5,
-        0x538322E5,  0x52A224EF, 0x51B326F3, 0x50B828F1,
-        0x4FB12AE9,  0x4E9D2CDA, 0x4D7D2EC5, 0x4C5230A8,
-        0x4B1A3284,  0x49D73458, 0x48883624, 0x472F37E7,
-        0x45CA39A2,  0x445A3B54, 0x42E03CFD, 0x415C3E9C,
-        0x3FCE4032,  0x3E3541BE, 0x3C944340, 0x3AE844B7,
-        0x39344624,  0x37774786, 0x35B148DD, 0x33E44A29,
-        0x320E4B69,  0x30304C9E, 0x2E4B4DC6, 0x2C5F4EE3,
-        0x2A6C4FF4,  0x287250F8, 0x267251F0, 0x246D52DB,
-        0x226153BA,  0x2051548B, 0x1E3B5550, 0x1C215607,
-        0x1A0256B1,  0x17DF574E, 0x15B957DD, 0x138F585F,
-        0x116358D3,  0x0F335939, 0x0D015992, 0x0ACE59DD,
-        0x08985A1A,  0x06625A49, 0x042A5A6A, 0x01F25A7D
-    };
-
-
-
-
-
-
-    extern const Int32 exp_rotation_N_2048[512] =
-    {
-
-        0x5A820009,  0x5A820050, 0x5A820097, 0x5A8100DE,
-        0x5A810125,  0x5A80016C, 0x5A7E01B3, 0x5A7D01FA,
-        0x5A7B0242,  0x5A790289, 0x5A7702D0, 0x5A750317,
-        0x5A72035E,  0x5A7003A5, 0x5A6D03EC, 0x5A6A0433,
-        0x5A66047A,  0x5A6304C1, 0x5A5F0508, 0x5A5B054F,
-        0x5A560596,  0x5A5205DD, 0x5A4D0624, 0x5A48066A,
-        0x5A4306B1,  0x5A3E06F8, 0x5A38073F, 0x5A320786,
-        0x5A2C07CD,  0x5A260814, 0x5A20085A, 0x5A1908A1,
-        0x5A1208E8,  0x5A0B092F, 0x5A040975, 0x59FC09BC,
-        0x59F40A03,  0x59EC0A49, 0x59E40A90, 0x59DC0AD7,
-        0x59D30B1D,  0x59CA0B64, 0x59C10BAA, 0x59B80BF1,
-        0x59AE0C37,  0x59A50C7E, 0x599B0CC4, 0x59910D0A,
-        0x59860D51,  0x597C0D97, 0x59710DDD, 0x59660E23,
-        0x595B0E6A,  0x594F0EB0, 0x59440EF6, 0x59380F3C,
-        0x592C0F82,  0x59200FC8, 0x5913100E, 0x59061054,
-        0x58F9109A,  0x58EC10E0, 0x58DF1126, 0x58D1116B,
-        0x58C411B1,  0x58B611F7, 0x58A7123C, 0x58991282,
-        0x588A12C8,  0x587B130D, 0x586C1353, 0x585D1398,
-        0x584E13DD,  0x583E1423, 0x582E1468, 0x581E14AD,
-        0x580D14F2,  0x57FD1538, 0x57EC157D, 0x57DB15C2,
-        0x57CA1607,  0x57B9164C, 0x57A71690, 0x579516D5,
-        0x5783171A,  0x5771175F, 0x575E17A3, 0x574C17E8,
-        0x5739182C,  0x57261871, 0x571218B5, 0x56FF18FA,
-        0x56EB193E,  0x56D71982, 0x56C319C6, 0x56AF1A0A,
-        0x569A1A4F,  0x56851A93, 0x56701AD6, 0x565B1B1A,
-        0x56461B5E,  0x56301BA2, 0x561A1BE5, 0x56041C29,
-        0x55EE1C6D,  0x55D81CB0, 0x55C11CF3, 0x55AA1D37,
-        0x55931D7A,  0x557C1DBD, 0x55651E00, 0x554D1E43,
-        0x55351E86,  0x551D1EC9, 0x55051F0C, 0x54EC1F4F,
-        0x54D31F91,  0x54BB1FD4, 0x54A12016, 0x54882059,
-        0x546F209B,  0x545520DE, 0x543B2120, 0x54212162,
-        0x540721A4,  0x53EC21E6, 0x53D12228, 0x53B62269,
-        0x539B22AB,  0x538022ED, 0x5364232E, 0x53492370,
-        0x532D23B1,  0x531123F2, 0x52F42434, 0x52D82475,
-        0x52BB24B6,  0x529E24F7, 0x52812538, 0x52642578,
-        0x524625B9,  0x522825FA, 0x520B263A, 0x51EC267A,
-        0x51CE26BB,  0x51B026FB, 0x5191273B, 0x5172277B,
-        0x515327BB,  0x513427FB, 0x5114283A, 0x50F4287A,
-        0x50D428BA,  0x50B428F9, 0x50942938, 0x50742978,
-        0x505329B7,  0x503229F6, 0x50112A35, 0x4FF02A74,
-        0x4FCE2AB2,  0x4FAD2AF1, 0x4F8B2B2F, 0x4F692B6E,
-        0x4F472BAC,  0x4F242BEA, 0x4F022C29, 0x4EDF2C67,
-        0x4EBC2CA4,  0x4E992CE2, 0x4E752D20, 0x4E522D5D,
-        0x4E2E2D9B,  0x4E0A2DD8, 0x4DE62E15, 0x4DC22E53,
-        0x4D9D2E90,  0x4D792ECD, 0x4D542F09, 0x4D2F2F46,
-        0x4D0A2F83,  0x4CE42FBF, 0x4CBF2FFB, 0x4C993038,
-        0x4C733074,  0x4C4D30B0, 0x4C2630EC, 0x4C003127,
-        0x4BD93163,  0x4BB2319E, 0x4B8B31DA, 0x4B643215,
-        0x4B3D3250,  0x4B15328B, 0x4AED32C6, 0x4AC53301,
-        0x4A9D333C,  0x4A753376, 0x4A4C33B1, 0x4A2433EB,
-        0x49FB3425,  0x49D2345F, 0x49A83499, 0x497F34D3,
-        0x4955350C,  0x492C3546, 0x4902357F, 0x48D835B9,
-        0x48AD35F2,  0x4883362B, 0x48583664, 0x482E369C,
-        0x480336D5,  0x47D7370E, 0x47AC3746, 0x4781377E,
-        0x475537B6,  0x472937EE, 0x46FD3826, 0x46D1385E,
-        0x46A43895,  0x467838CD, 0x464B3904, 0x461E393B,
-        0x45F13972,  0x45C439A9, 0x459739E0, 0x45693A16,
-        0x453C3A4D,  0x450E3A83, 0x44E03AB9, 0x44B13AEF,
-        0x44833B25,  0x44553B5B, 0x44263B90, 0x43F73BC6,
-        0x43C83BFB,  0x43993C30, 0x43693C65, 0x433A3C9A,
-        0x430A3CCF,  0x42DA3D04, 0x42AA3D38, 0x427A3D6C,
-        0x424A3DA0,  0x42193DD4, 0x41E93E08, 0x41B83E3C,
-        0x41873E6F,  0x41563EA3, 0x41253ED6, 0x40F33F09,
-        0x40C23F3C,  0x40903F6F, 0x405E3FA1, 0x402C3FD4,
-        0x3FFA4006,  0x3FC74038, 0x3F95406A, 0x3F62409C,
-        0x3F2F40CE,  0x3EFC4100, 0x3EC94131, 0x3E964162,
-        0x3E634193,  0x3E2F41C4, 0x3DFB41F5, 0x3DC74226,
-        0x3D934256,  0x3D5F4286, 0x3D2B42B6, 0x3CF642E6,
-        0x3CC24316,  0x3C8D4346, 0x3C584375, 0x3C2343A5,
-        0x3BEE43D4,  0x3BB84403, 0x3B834432, 0x3B4D4460,
-        0x3B18448F,  0x3AE244BD, 0x3AAC44EB, 0x3A754519,
-        0x3A3F4547,  0x3A094575, 0x39D245A2, 0x399B45CF,
-        0x396445FD,  0x392D462A, 0x38F64656, 0x38BF4683,
-        0x388746B0,  0x385046DC, 0x38184708, 0x37E04734,
-        0x37A84760,  0x3770478B, 0x373847B7, 0x36FF47E2,
-        0x36C7480D,  0x368E4838, 0x36554863, 0x361D488E,
-        0x35E348B8,  0x35AA48E2, 0x3571490C, 0x35384936,
-        0x34FE4960,  0x34C44989, 0x348B49B3, 0x345149DC,
-        0x34164A05,  0x33DC4A2E, 0x33A24A56, 0x33684A7F,
-        0x332D4AA7,  0x32F24ACF, 0x32B74AF7, 0x327C4B1F,
-        0x32414B46,  0x32064B6E, 0x31CB4B95, 0x31904BBC,
-        0x31544BE3,  0x31184C0A, 0x30DD4C30, 0x30A14C56,
-        0x30654C7C,  0x30294CA2, 0x2FEC4CC8, 0x2FB04CEE,
-        0x2F734D13,  0x2F374D38, 0x2EFA4D5D, 0x2EBD4D82,
-        0x2E804DA7,  0x2E434DCB, 0x2E064DEF, 0x2DC94E13,
-        0x2D8C4E37,  0x2D4E4E5B, 0x2D104E7E, 0x2CD34EA2,
-        0x2C954EC5,  0x2C574EE8, 0x2C194F0A, 0x2BDB4F2D,
-        0x2B9D4F4F,  0x2B5E4F71, 0x2B204F93, 0x2AE14FB5,
-        0x2AA34FD7,  0x2A644FF8, 0x2A255019, 0x29E6503A,
-        0x29A7505B,  0x2968507C, 0x2929509C, 0x28E950BC,
-        0x28AA50DC,  0x286A50FC, 0x282B511C, 0x27EB513B,
-        0x27AB515B,  0x276B517A, 0x272B5199, 0x26EB51B7,
-        0x26AB51D6,  0x266A51F4, 0x262A5212, 0x25E95230,
-        0x25A9524E,  0x2568526B, 0x25275288, 0x24E652A5,
-        0x24A652C2,  0x246452DF, 0x242352FB, 0x23E25318,
-        0x23A15334,  0x235F5350, 0x231E536B, 0x22DC5387,
-        0x229B53A2,  0x225953BD, 0x221753D8, 0x21D553F3,
-        0x2193540D,  0x21515427, 0x210F5442, 0x20CD545B,
-        0x208B5475,  0x2048548F, 0x200654A8, 0x1FC354C1,
-        0x1F8154DA,  0x1F3E54F2, 0x1EFB550B, 0x1EB85523,
-        0x1E76553B,  0x1E335553, 0x1DF0556A, 0x1DAC5582,
-        0x1D695599,  0x1D2655B0, 0x1CE355C7, 0x1C9F55DD,
-        0x1C5C55F4,  0x1C18560A, 0x1BD55620, 0x1B915636,
-        0x1B4D564B,  0x1B095661, 0x1AC55676, 0x1A82568B,
-        0x1A3E569F,  0x19F956B4, 0x19B556C8, 0x197156DC,
-        0x192D56F0,  0x18E95704, 0x18A45717, 0x1860572A,
-        0x181B573E,  0x17D75750, 0x17925763, 0x174D5775,
-        0x17095788,  0x16C4579A, 0x167F57AB, 0x163A57BD,
-        0x15F557CE,  0x15B057DF, 0x156B57F0, 0x15265801,
-        0x14E15812,  0x149C5822, 0x14575832, 0x14115842,
-        0x13CC5851,  0x13875861, 0x13415870, 0x12FC587F,
-        0x12B6588E,  0x1271589D, 0x122B58AB, 0x11E558B9,
-        0x11A058C7,  0x115A58D5, 0x111458E2, 0x10CE58F0,
-        0x108858FD,  0x1042590A, 0x0FFD5916, 0x0FB75923,
-        0x0F71592F,  0x0F2A593B, 0x0EE45947, 0x0E9E5952,
-        0x0E58595E,  0x0E125969, 0x0DCC5974, 0x0D85597E,
-        0x0D3F5989,  0x0CF95993, 0x0CB2599D, 0x0C6C59A7,
-        0x0C2559B1,  0x0BDF59BA, 0x0B9959C4, 0x0B5259CD,
-        0x0B0B59D5,  0x0AC559DE, 0x0A7E59E6, 0x0A3859EE,
-        0x09F159F6,  0x09AA59FE, 0x09645A05, 0x091D5A0D,
-        0x08D65A14,  0x08905A1B, 0x08495A21, 0x08025A28,
-        0x07BB5A2E,  0x07745A34, 0x072D5A3A, 0x06E75A3F,
-        0x06A05A44,  0x06595A49, 0x06125A4E, 0x05CB5A53,
-        0x05845A57,  0x053D5A5C, 0x04F65A60, 0x04AF5A63,
-        0x04685A67,  0x04215A6A, 0x03DA5A6D, 0x03935A70,
-        0x034C5A73,  0x03055A76, 0x02BE5A78, 0x02775A7A,
-        0x02305A7C,  0x01E95A7D, 0x01A25A7F, 0x015B5A80,
-        0x01135A81,  0x00CC5A82, 0x00855A82, 0x003E5A82
-    };
-
-
-#ifdef __cplusplus
-}
-#endif
diff --git a/media/libstagefright/codecs/aacdec/mdst.cpp b/media/libstagefright/codecs/aacdec/mdst.cpp
deleted file mode 100644
index 19f82e3..0000000
--- a/media/libstagefright/codecs/aacdec/mdst.cpp
+++ /dev/null
@@ -1,294 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: mdst.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input length 64
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    mdst
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#include "pv_audio_type_defs.h"
-#include "synthesis_sub_band.h"
-#include "dct16.h"
-#include "dct64.h"
-#include "mdst.h"
-
-#ifdef HQ_SBR
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#include "fxp_mul32.h"
-#include "dst32.h"
-
-
-#define Qfmt1(a)   (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
-#define Qfmt(a)   (Int32)(a*((Int32)1<<27) + (a>=0?0.5F:-0.5F))
-
-const Int32 CosTable_32[32] =
-{
-    Qfmt1(0.50015063602065F),  Qfmt1(0.50135845244641F),
-    Qfmt1(0.50378872568104F),  Qfmt1(0.50747117207256F),
-    Qfmt1(0.51245147940822F),  Qfmt1(0.51879271310533F),
-    Qfmt1(0.52657731515427F),  Qfmt1(0.53590981690799F),
-    Qfmt1(0.54692043798551F),  Qfmt1(0.55976981294708F),
-    Qfmt1(0.57465518403266F),  Qfmt1(0.59181853585742F),
-    Qfmt1(0.61155734788251F),  Qfmt1(0.63423893668840F),
-    Qfmt1(0.66031980781371F),  Qfmt1(0.69037212820021F),
-    Qfmt1(0.72512052237720F),  Qfmt1(0.76549416497309F),
-    Qfmt1(0.81270209081449F),  Qfmt1(0.86834471522335F),
-    Qfmt(0.93458359703641F),  Qfmt(1.01440826499705F),
-    Qfmt(1.11207162057972F),  Qfmt(1.23383273797657F),
-    Qfmt(1.38929395863283F),  Qfmt(1.59397228338563F),
-    Qfmt(1.87467598000841F),  Qfmt(2.28205006800516F),
-    Qfmt(2.92462842815822F),  Qfmt(4.08461107812925F),
-    Qfmt(6.79675071167363F),  Qfmt(10.18693908361573F)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; mdst_32
-----------------------------------------------------------------------------*/
-
-void mdst_32(Int32 vec[], Int32 scratch_mem[])
-{
-
-    Int i;
-    const Int32 *pt_cos = CosTable_32;
-    Int32 *pt_vec = vec;
-    Int32 tmp1;
-    Int32 tmp2;
-
-
-
-    Int32 tmp3;
-
-    tmp3 = *(pt_vec++);
-    tmp2 = *(pt_vec);
-
-    for (i = 5; i != 0; i--)
-    {
-        *(pt_vec++)  += tmp3;
-        tmp1 = *(pt_vec);
-        *(pt_vec++)  += tmp2;
-        tmp3 = *(pt_vec);
-        *(pt_vec++)  += tmp1;
-        tmp2 = *(pt_vec);
-        *(pt_vec++)  += tmp3;
-        tmp1 = *(pt_vec);
-        *(pt_vec++)  += tmp2;
-        tmp3 = *(pt_vec);
-        *(pt_vec++)  += tmp1;
-        tmp2 = *(pt_vec);
-    }
-
-    *(pt_vec)  += tmp3;
-
-    dst_32(vec, scratch_mem);
-
-    pt_vec = vec;
-
-    for (i = 5; i != 0; i--)
-    {
-        *(pt_vec)   = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q31((*(pt_vec) << 1) + tmp2, *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q31((*(pt_vec) << 1) - tmp2, *(pt_cos++));
-        pt_vec++;
-    }
-
-    tmp2 >>= 1;
-    for (i = 3; i != 0; i--)
-    {
-        *(pt_vec)   = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q27((*(pt_vec) + tmp2), *(pt_cos++));
-        pt_vec++;
-        *(pt_vec)   = fxp_mul32_Q27((*(pt_vec) - tmp2), *(pt_cos++));
-        pt_vec++;
-    }
-
-    *(pt_vec - 1)   <<= 1;
-
-}
-
-
-
-/*----------------------------------------------------------------------------
-; mdct_32
-----------------------------------------------------------------------------*/
-
-void mdct_32(Int32 vec[])
-{
-    Int i;
-    Int32 *pt_vec  = vec;
-    Int32 tmp1, tmp2;
-
-
-    const Int32 *pt_CosTable = CosTable_32;
-
-
-    for (i = 5; i != 0; i--)
-    {
-        *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q31(*(pt_vec) << 1, *(pt_CosTable++));
-        pt_vec++;
-    }
-    for (i = 3; i != 0; i--)
-    {
-        *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
-        pt_vec++;
-        *(pt_vec) = fxp_mul32_Q27(*(pt_vec), *(pt_CosTable++));
-        pt_vec++;
-    }
-    *(pt_vec - 1)   <<= 1;
-
-
-    dct_32(vec);
-
-
-    pt_vec  = &vec[31];
-
-    tmp1 = *(pt_vec--);
-
-    for (i = 5; i != 0; i--)
-    {
-        tmp2 = *(pt_vec);
-        *(pt_vec--)  += tmp1;
-        tmp1 = *(pt_vec);
-        *(pt_vec--)  += tmp2;
-        tmp2 = *(pt_vec);
-        *(pt_vec--)  += tmp1;
-        tmp1 = *(pt_vec);
-        *(pt_vec--)  += tmp2;
-        tmp2 = *(pt_vec);
-        *(pt_vec--)  += tmp1;
-        tmp1 = *(pt_vec);
-        *(pt_vec--)  += tmp2;
-    }
-
-    *(pt_vec)  += tmp1;
-
-}
-
-#endif /*  HQ_SBR  */
-
-
-/*----------------------------------------------------------------------------
-; dct_32
-----------------------------------------------------------------------------*/
-
-
-void dct_32(Int32 vec[])
-{
-
-    pv_split(&vec[16]);
-
-    dct_16(&vec[16], 0);
-    dct_16(vec, 1);     // Even terms
-
-    pv_merge_in_place_N32(vec);
-}
-
-#endif  /* AAC_PLUS */
-
-
diff --git a/media/libstagefright/codecs/aacdec/mdst.h b/media/libstagefright/codecs/aacdec/mdst.h
deleted file mode 100644
index 5b3e1c9..0000000
--- a/media/libstagefright/codecs/aacdec/mdst.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mdst.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef MDST_H
-#define MDST_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    void mdst_32(Int32 vec[], Int32 scratch_mem[]);
-
-    void  dct_32(Int32 vec[]);
-
-    void mdct_32(Int32 vec[]);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* MDST_H */
diff --git a/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp b/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp
deleted file mode 100644
index 6081c46..0000000
--- a/media/libstagefright/codecs/aacdec/mix_radix_fft.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mix_radix_fft.c
- Funtions: mix_radix_fft
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Eliminated pointer dependency ( pData_1) on Buffer address.
-               Modified for-loop to countdown loops.
-
- Description:  No shift information going in/out from fft_rx4_long.
-
- Description:
-            (1) Increased precision on the radix 2 fft coeff. (from Q10 to Q12)
-            (2) Increased precision on the input (from 0.5 to 1.0).
-            (3) Eliminated hardly used condition (exp = 0).
-            (4) Change interface to fft_rx4_long, so now the same function is
-                used for forward and inverse calculations.
-
- Description:  per code review comments, eliminated unnecessary headers
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Data         = Input vector, with quantized spectral with a pre-rotation
-                   by exp(j(2pi/N)(k+1/8))
-                   type Int32 *
-
-    peak_value   = Input, carries the maximum value in input vector "Data"
-                   Output, maximum value computed in the first FFT, used
-                   to set precision on next stages
-                   type Int32 *
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    exponent = shift factor to reflect signal scaling
-
- Pointers and Buffers Modified:
-    Results are return in "Data"
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    mix_radix_fft() mixes radix-2 and radix-4 FFT. This is needed to be able
-    to use power of 4 length when the input length sequence is a power of 2.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    mix_radix_fft() should support only the FFT for the long window case of
-    the inverse modified cosine transform (IMDCT)
-------------------------------------------------------------------------------
- REFERENCES
-
-  ------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-   MODIFY( x[] )
-   RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "fft_rx4.h"
-#include "mix_radix_fft.h"
-#include "pv_normalize.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void digit_reversal_swapping(Int32 *y, Int32 *x);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int mix_radix_fft(
-    Int32   *Data,
-    Int32   *peak_value
-)
-
-{
-
-    const Int32     *p_w;
-    Int32   *pData_1;
-    Int32   *pData_2;
-
-    Int32   *pData_3;
-    Int32   *pData_4;
-
-    Int32   exp_jw;
-    Int32   max1;
-    Int32   max2;
-    Int32   temp1;
-    Int32   temp2;
-    Int32   temp3;
-    Int32   temp4;
-    Int32   diff1;
-    Int32   diff2;
-    Int     i;
-    Int   exp;
-
-    max1 = *peak_value;
-    p_w  = w_512rx2;
-
-    pData_1 = Data;
-    pData_3 = Data + HALF_FFT_RX4_LENGTH_FOR_LONG;
-
-
-    /*
-     * normalization to 0.9999 (0x7FFF) guarantees proper operation
-     */
-
-    exp = 8 - pv_normalize(max1);   /* use 24 bits for mix radix fft */
-
-    if (exp < 4)
-    {
-        exp = 4;
-    }
-
-
-    temp1      = (*pData_3);
-    pData_4    = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
-    temp2      = (*pData_4++);
-
-
-
-    diff1      = (temp1  - temp2) >> exp;
-    *pData_3++ = (temp1  + temp2) >> exp;
-
-    temp3      = (*pData_3);
-    temp4      = (*pData_4);
-
-    *pData_4-- = -diff1;
-    *pData_3++ = (temp3  + temp4) >> exp;
-    *pData_4   = (temp3  - temp4) >> exp;
-
-    temp1      = (*pData_1);
-    pData_2    = pData_1 + FFT_RX4_LENGTH_FOR_LONG;
-    temp2      = (*pData_2++);
-    temp4      = (*pData_2);
-
-    *pData_1++ = (temp1  + temp2) >> exp;
-
-    temp3      = (*pData_1);
-    diff1      = (temp1  - temp2) >> exp ;
-
-    *pData_1++ = (temp3  + temp4) >> exp;
-    *pData_2-- = (temp3  - temp4) >> exp;
-    *pData_2   =  diff1;
-
-    temp1      = (*pData_3);
-    pData_4    = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
-    temp2      = (*pData_4++);
-
-
-    for (i = ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG - 1; i != 0; i--)
-    {
-        /*
-         * radix 2 Butterfly
-         */
-
-        diff1      = (temp1  - temp2) >> (exp - 4);
-        *pData_3++ = (temp1  + temp2) >> exp;
-
-        temp3      = (*pData_3);
-        temp4      = (*pData_4);
-
-        exp_jw     = *p_w++;
-
-
-        diff2      = (temp3  - temp4) >> (exp - 4);
-        *pData_3++ = (temp3  + temp4) >> exp;
-
-        *pData_4-- = -cmplx_mul32_by_16(diff1,  diff2, exp_jw) >> 3;
-        *pData_4   =  cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3;
-
-
-        temp1      = (*pData_1);
-        pData_2    = pData_1 + FFT_RX4_LENGTH_FOR_LONG;
-        temp2      = (*pData_2++);
-        temp4      = (*pData_2);
-
-        *pData_1++ = (temp1  + temp2) >> exp;
-
-        temp3      = (*pData_1);
-        diff1      = (temp1  - temp2) >> (exp - 4);
-
-        diff2      = (temp3  - temp4) >> (exp - 4);
-        *pData_1++ = (temp3  + temp4) >> exp;
-
-        *pData_2-- =  cmplx_mul32_by_16(diff2, -diff1, exp_jw) >> 3;
-        *pData_2   =  cmplx_mul32_by_16(diff1,  diff2, exp_jw) >> 3;
-
-        temp1      = (*pData_3);
-        pData_4    = pData_3 + FFT_RX4_LENGTH_FOR_LONG;
-        temp2      = (*pData_4++);
-
-    }/* for i  */
-
-
-    fft_rx4_long(
-        Data,
-        &max1);
-
-
-    fft_rx4_long(
-        &Data[FFT_RX4_LENGTH_FOR_LONG],
-        &max2);
-
-    digit_reversal_swapping(Data, &Data[FFT_RX4_LENGTH_FOR_LONG]);
-
-    *peak_value = max1 | max2;
-
-    return(exp);
-}
-
diff --git a/media/libstagefright/codecs/aacdec/mix_radix_fft.h b/media/libstagefright/codecs/aacdec/mix_radix_fft.h
deleted file mode 100644
index 563c280..0000000
--- a/media/libstagefright/codecs/aacdec/mix_radix_fft.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: mix_radix_fft.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions mix_radix_fft
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MIX_RADIX_FFT_H
-#define MIX_RADIX_FFT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define     FFT_RX4_LENGTH_FOR_LONG         512
-#define     HALF_FFT_RX4_LENGTH_FOR_LONG    (FFT_RX4_LENGTH_FOR_LONG>>1)
-#define     ONE_FOURTH_FFT_RX4_LENGTH_FOR_LONG   (FFT_RX4_LENGTH_FOR_LONG>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int mix_radix_fft(
-        Int32   *Data,
-        Int32   *peak_value);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* MIX_RADIX_FFT_H */
diff --git a/media/libstagefright/codecs/aacdec/ms_map_mask.h b/media/libstagefright/codecs/aacdec/ms_map_mask.h
deleted file mode 100644
index fbbec78..0000000
--- a/media/libstagefright/codecs/aacdec/ms_map_mask.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- [Describe the contents of the include file.]
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MS_MAP_MASK_H
-#define MS_MAP_MASK_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void MS_map_mask(
-    FrameInfo  *info,
-    Int        *group,
-    Int        *mask,
-    Int        *cb_map);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/ms_synt.cpp b/media/libstagefright/codecs/aacdec/ms_synt.cpp
deleted file mode 100644
index 1f25516..0000000
--- a/media/libstagefright/codecs/aacdec/ms_synt.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ms_synt.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Cleaned up a bit, not finished.
-
- Description:
- Copied in code from pns_intensity_right.c, which has the same structure as
- this file.  Also, merged in code from ms_map_mask.c
-
- Description:
- (1) Various optimizations (eliminated extra variables by making use of a
- single temporary register throughout the code, etc.)
- (2) Wrote pseudocode, pasted in correct function template, etc.
-
- Description:  Unrolled loops to get speed up code
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    wins_in_group        = Number of windows in the current group.
-                           [const Int]
-
-    coef_per_win         = Number of coefficients per window.
-                           [const Int]
-
-    num_bands            = Number of scalefactor bands.
-                           [const Int]
-
-    band_length          = Number of coefficients per scalefactor band.
-                           [const Int]
-
-    pFirst_Window_CoefsL = Array containing the spectral coefficients for
-                           the left channel.
-                           [Int32 *, length LN]
-    pFirst_Window_CoefsR = Array containing the spectral coefficients for
-                           the right channel.
-                           [Int32 *, length LN]
-    q_formatLeft         = Array containing the q-format used to encode each
-                           scalefactor band's data on the left channel.
-                           [Int *, length MAXBANDS]
-    q_formatRight        = Array containing the q-format used to encode each
-                           scalefactor band's data on the right channel.
-                           [Int *, length MAXBANDS]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-   pFirst_Window_CoefsL  The coefficients in the group will be modified per the
-                         formula for M/S stereo on each scalefactor band where
-                         M/S stereo is active.
-
-   pFirst_Window_CoefsR  The coefficients in the group will be modified per the
-                         formula for M/S stereo on each scalefactor band where
-                         M/S stereo is active.
-
-   q_formatLeft          The q_format may be modified on scalefactor bands
-                         where M/S stereo is active.
-
-   q_formatRight         The q_format may be modified on scalefactor bands
-                         where M/S stereo is active.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module applies the formula for M/S coding to one grouped scalefactor
- band.  The ISO code has a similar function which applies M/S coding to an
- entire frame.
-
- It is the calling function's responsibility to check the map_mask array, which
- is filled by the function getmask.  If a scalefactor band is identified as
- using M/S stereo, the coefficients in that array are calculated using
- the following formula...
-
- TempLeft = LeftCoefficient;
-
- LeftCoefficient  = LeftCoefficient  + RightCoefficient;
- RightCoefficient = TempLeft         - RightCoefficient;
-
- This function should be inlined if the compiler supports C99 inlining,
- as this short function is only called by sfb_tools_ms().
- Therefore, inlining will not increase the code size.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.7.1   M/S stereo
-        Subpart 4.6.2     ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    start_indx = 0;
-
-    pCoefR = coefLeft;
-    pCoefL = coefRight;
-
-    FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
-
-        tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx];
-
-        IF (tempInt > 0)
-        THEN
-
-            shift_left_chan  = 1 + tempInt;
-            shift_right_chan = 1;
-
-            q_formatLeft[start_indx]  = (q_formatRight[start_indx] - 1);
-            q_formatRight[start_indx] = (q_formatRight[start_indx] - 1);
-
-        ELSE
-            shift_left_chan  = 1;
-            shift_right_chan = 1 - tempInt;
-
-            q_formatRight[start_indx] = (q_formatLeft[start_indx] - 1);
-            q_formatLeft[start_indx]  = (q_formatLeft[start_indx] - 1);
-
-        ENDIF
-
-        FOR (tempInt = band_length; tempInt > 0; tempInt--)
-
-            temp_left  = *(pCoefL) >> shift_left_chan;
-            temp_right = *(pCoefR) >> shift_right_chan;
-
-            *(pCoefL++) = temp_left + temp_right;
-            *(pCoefR++) = temp_left - temp_right;
-
-        ENDFOR
-
-        tempInt = (coef_per_win - band_length);
-
-        pCoefR = pCoefR + tempInt;
-        pCoefL = pCoefL + tempInt;
-
-        start_indx = start_indx + num_bands;
-
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-   resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "ms_synt.h"
-#include "fxp_mul32.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ms_synt(
-    const Int   wins_in_group,
-    const Int   coef_per_win,
-    const Int   num_bands,
-    const Int   band_length,
-    Int32 coefLeft[],
-    Int32 coefRight[],
-    Int q_formatLeft[],
-    Int q_formatRight[])
-{
-
-    Int32 *pCoefL = coefLeft;
-    Int32 *pCoefR = coefRight;
-    Int start_indx = 0;
-
-
-    if (band_length < 0 || band_length > LONG_WINDOW)
-    {
-        return;     /*  avoid any processing on error condition */
-    }
-
-
-    Int nextWinPtrUpdate = (coef_per_win - band_length);
-
-    for (Int win_indx = wins_in_group; win_indx > 0; win_indx--)
-    {
-
-        if (q_formatRight[start_indx] < 31)
-        {
-            Int tempInt = q_formatLeft[start_indx] - q_formatRight[start_indx];
-
-            /* Normalize the left and right channel to the same q-format */
-            if (tempInt > 0)
-            {
-                /*
-                 * shift_left_chan and shift_right_chan each have an offset
-                 * of 1.  Even if the left and right channel share the same
-                 * q-format, we must shift each by 1 to guard against
-                 * overflow.
-                 */
-                Int shift_left_chan  = 1 + tempInt;
-
-                /*
-                 * Following code line is equivalent to...
-                 * q_formatLeft  = q_formatRight - 1;
-                 * q_formatRight = q_formatRight - 1;
-                 */
-                q_formatLeft[start_indx] = --(q_formatRight[start_indx]);
-
-
-                /*
-                 *  band_length is always an even number (check tables in pg.66 IS0 14496-3)
-                 */
-
-                Int32 temp_left  = *(pCoefL) >> shift_left_chan;
-                Int32 temp_right = *(pCoefR) >> 1;
-
-
-
-                for (Int i = band_length; i != 0; i--)
-                {
-                    *(pCoefL++) = temp_left + temp_right;
-                    *(pCoefR++) = temp_left - temp_right;
-                    temp_left  = *(pCoefL) >> shift_left_chan;
-                    temp_right = *(pCoefR) >> 1;
-
-                }
-
-            }
-            else
-            {
-                /*
-                 * shift_left_chan and shift_right_chan each have an offset
-                 * of 1.  Even if the left and right channel share the same
-                 * q-format, we must shift each by 1 to guard against
-                 * overflow.
-                 */
-                Int shift_right_chan = 1 - tempInt;
-
-                /*
-                 * Following code line is equivalent to...
-                 * q_formatRight = q_formatLeft - 1;
-                 * q_formatLeft  = q_formatLeft - 1;
-                 */
-                q_formatRight[start_indx] = --(q_formatLeft[start_indx]);
-
-                /*
-                 *  band_length is always an even number (check tables in pg.66 IS0 14496-3)
-                 */
-
-                Int32 temp_left  = *(pCoefL) >> 1;
-                Int32 temp_right = *(pCoefR) >> shift_right_chan;
-
-                for (Int i = band_length; i != 0; i--)
-                {
-                    *(pCoefL++) = temp_left + temp_right;
-                    *(pCoefR++) = temp_left - temp_right;
-
-                    temp_left  = *(pCoefL) >> 1;
-                    temp_right = *(pCoefR) >> shift_right_chan;
-
-                }
-            }
-
-        }
-        else
-        {
-            /*
-             *  Nothing on right channel, just copy left into right
-             */
-            q_formatRight[start_indx] = (q_formatLeft[start_indx]);
-
-            pv_memcpy(pCoefR, pCoefL, band_length*sizeof(*pCoefR));
-            pCoefR += band_length;
-            pCoefL += band_length;
-        }
-
-        /*
-         * Increment the window pointers so they point
-         * to the next window in the group
-         */
-        pCoefL += nextWinPtrUpdate;
-        pCoefR += nextWinPtrUpdate;
-
-        start_indx += num_bands;
-
-    } /* for (win_indx) */
-
-    return;
-
-} /* MS_synt */
diff --git a/media/libstagefright/codecs/aacdec/ms_synt.h b/media/libstagefright/codecs/aacdec/ms_synt.h
deleted file mode 100644
index a00e6e2..0000000
--- a/media/libstagefright/codecs/aacdec/ms_synt.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ms_synt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Updated to reflect new functionality of ms_synt() routine.
- (ms_synt now only decodes one grouped scalefactor band at a time.)
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes the function declaration for ms_synt().
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef MS_SYNT_H
-#define MS_SYNT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void ms_synt(
-    const Int   wins_in_group,
-    const Int   coef_per_win,
-    const Int   num_bands,
-    const Int   band_length,
-    Int32 spectralCoefLeft[],
-    Int32 spectralCoefRight[],
-    Int   q_formatLeft[],
-    Int   q_formatRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_corr.cpp b/media/libstagefright/codecs/aacdec/pns_corr.cpp
deleted file mode 100644
index 4cfe720..0000000
--- a/media/libstagefright/codecs/aacdec/pns_corr.cpp
+++ /dev/null
@@ -1,342 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_corr.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes per review comments, the most major of which
- being the change of the scaling into a 16 x 16 multiply.
-
- Description: When the multiplication of two 16-bits variables is stored in
-              an 32-bits variable, the result should be typecasted explicitly
-              to Int32 before it is stored.
-              *(pCoefRight++) = (Int32) tempInt2 * multiplier;
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    scale        =  Multiplier used to scale the noise extracted from the left
-                    channel for use on the right.
-                    [const Int]
-
-    coef_per_win =  Number of coefficients per window.
-                    (128 for short, 1024 for long)
-                    [const Int]
-
-    sfb_per_win  =  Number of scalefactors per window.
-                    [const Int]
-
-    wins_in_group = The number of windows in the group being decoded.
-                    [const Int]
-
-    band_length  =  The length of the scalefactor band being decoded.
-                    [const Int]
-
-    sfb_prediction_used =  Flag that denotes the activation of long term
-                           prediction on a per-scalefactor band,
-                           non-grouped basis.
-                           [const Int *, length MAX_SFB]
-
-    q_formatLeft = The Q-format for the left channel's fixed-point spectral
-                   coefficients, on a per-scalefactor band, non-grouped basis.
-                   [const Int]
-
-    q_formatRight = The Q-format for the right channel's fixed-point spectral
-                    coefficients, on a per-scalefactor band, non-grouped basis.
-                    [Int *, length MAX_SFB]
-
-    coefLeft = Array containing the fixed-point spectral coefficients
-               for the left channel.
-               [const Int32 *, length 1024]
-
-    coefRight = Array containing the fixed-point spectral coefficients
-                for the right channel.
-                [Int32 *, length 1024]
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-    pcoefRight  Contains the new spectral information
-
-    q_formatRight       Q-format may be updated with changed to fixed-point
-                        data in coefRight.
-
-    sfb_prediction_used              LTP may be disabled by presence of PNS tool on the
-                        same scalefactor band.
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function derives noise from the left channel.  The PNS tool is assumed
- to have been used on the same scalefactor band on the left channel.  The
- noise on the left/right channels are not necessarily of the same amplitude,
- and therefore have separate scalefactors.  The noise is thus scaled by the
- difference between the two transmitted scalefactors.  This scaling is done
- in fixed-point using a constant 4-element table.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.7.1   M/S stereo
-        Subpart 4.6.12.3  Decoding Process (PNS)
-        Subpart 4.6.2     ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    q_format = q_formatLeft - (scale >> 2);
-    q_format = q_format - 1;
-    q_formatRight = q_format;
-
-    multiplier = hcb2_scale_mod_4[scale & 0x3];
-
-    pCoefLeft = coefLeft;
-    pCoefRight = coefRight;
-
-    start_indx = 0;
-
-    FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
-        q_formatRight[start_indx] = q_format;
-
-        sfb_prediction_used[start_indx] = FALSE;
-
-        start_indx = start_indx + sfb_per_win;
-
-        FOR (tempInt = band_length; tempInt > 0; tempInt--)
-
-            *(pCoefRight) = (*(pCoefLeft) >> 9) * multiplier;
-            pCoefRight = pCoefRight + 1;
-            pCoefLeft = pCoefLeft + 1;
-
-        ENDFOR
-
-        tempInt = (coef_per_win - band_length);
-        pCoefRight = pCoefRight + tempInt;
-        pCoefLeft = pCoefLeft + tempInt;
-
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_corr.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const UInt hcb2_scale_mod_4[4] =
-{
-    32768,  /* (2.0^0.00)*2^15 */
-    38968,  /* (2.0^0.25)*2^15 */
-    46341,  /* (2.0^0.50)*2^15 */
-    55109
-}; /* (2.0^0.75)*2^15 */
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_corr(
-    const Int scale,
-    const Int coef_per_win,
-    const Int sfb_per_win,
-    const Int wins_in_group,
-    const Int band_length,
-    const Int q_formatLeft,
-    Int q_formatRight[],
-    const Int32 coefLeft[],
-    Int32 coefRight[])
-{
-    Int tempInt;
-    Int nextWinPtrUpdate;
-
-    Int q_format;
-
-    Int start_indx;
-    Int win_indx;
-
-    const Int32   *pCoefLeft;
-    Int32   *pCoefRight;
-
-    UInt multiplier;
-
-    /*
-     * Generate noise correlated with the noise on the left channel
-     *
-     */
-
-    /*
-     * scale is interpreted as 2^(scale/4)
-     * Therefore, we can adjust the q-format by floor(scale/4)
-     * and save some complexity in the multiplier.
-     */
-    q_format = q_formatLeft - (scale >> 2);
-
-    /*
-     * Reduce the q-format by 1 to guard against overflow.
-     * This must be done because the hcb2_scale_mod_4 table
-     * must be stored in a common q-format, and we must shift
-     * by 16 to get *pCoefLeft into a 16-bit value, but we
-     * cannot store 2^0*2^16 and 2^0.75*2^16 in a table.
-     */
-    q_format--;
-
-    multiplier = hcb2_scale_mod_4[scale & 0x3];
-
-    pCoefLeft  = coefLeft;
-    pCoefRight = coefRight;
-
-    nextWinPtrUpdate = (coef_per_win - band_length);
-
-    /*
-     * Step through all the windows in this group, replacing this
-     * band in each window's spectrum with correlated random noise
-     */
-
-    start_indx = 0;
-
-    for (win_indx = wins_in_group; win_indx > 0; win_indx--)
-    {
-        /*
-         * Set the q-format for all scalefactor bands in the group.
-         * Normally, we could not assume that grouped scalefactors
-         * share the same q-format.
-         * However, here we can make this assumption.  The reason
-         * being -- if this function is called, it is assumed
-         * PNS was used on the left channel.  When PNS is used,
-         * all scalefactors in a group share the same q-format.
-         *
-         */
-        q_formatRight[start_indx] = q_format;
-
-        start_indx += sfb_per_win;
-
-        /* reconstruct right noise values */
-        for (tempInt = band_length; tempInt > 0; tempInt--)
-        {
-            *(pCoefRight++) = (Int32)(*(pCoefLeft++) >> 16) * multiplier;
-        }
-
-        pCoefRight += nextWinPtrUpdate;
-        pCoefLeft  += nextWinPtrUpdate;
-
-    } /* for (win_indx) */
-
-    return;
-
-} /* void pns_corr */
diff --git a/media/libstagefright/codecs/aacdec/pns_corr.h b/media/libstagefright/codecs/aacdec/pns_corr.h
deleted file mode 100644
index c892a8c..0000000
--- a/media/libstagefright/codecs/aacdec/pns_corr.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_corr.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Made changes per review comments.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function declaration for pns_corr.c
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_CORR_H
-#define PNS_CORR_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void pns_corr(
-    const Int scale,
-    const Int coef_per_win,
-    const Int sfb_per_win,
-    const Int wins_in_group,
-    const Int band_length,
-    const Int q_formatLeft,
-    Int q_formatRight[],
-    const Int32 coefLeft[],
-    Int32 coefRight[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp b/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp
deleted file mode 100644
index f2d50c1..0000000
--- a/media/libstagefright/codecs/aacdec/pns_intensity_right.cpp
+++ /dev/null
@@ -1,653 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_intensity_right.c
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    hasmask    = mask status for the frame. Enumerated.
-
-    pFrameInfo = Pointer to structure that holds information about each group.
-                 (long block flag, number of windows, scalefactor bands
-                  per group, etc.)
-                 [const pFrameInfo * const]
-
-    group      = Array that contains indexes of the
-                 first window in the next group.
-                 [const Int *, length num_win]
-
-    mask_map   = Array that denotes whether M/S stereo is turned on for
-                 each grouped scalefactor band.
-                 [const Int *, length MAX_SFB]
-
-    codebook_map = Array that denotes which Huffman codebook was used for
-                   the encoding of each grouped scalefactor band.
-                   [const Int *, length MAX_SFB]
-
-    factorsL     =  Array of grouped scalefactors for left chan.
-                    [const Int *, length MAX_SFB]
-
-    factorsR     =  Array of scalefactors for right chan.
-                    [const Int *, length MAX_SFB]
-
-    sfb_prediction_used =  Flag that denotes the activation of long term prediction
-                           on a per-scalefactor band, non-grouped basis.
-                           [const Int *, length MAX_SFB]
-
-    ltp_data_present = Flag that indicates whether LTP is enbaled for this frame.
-                       [const Bool]
-
-    coefLeft = Array containing the fixed-point spectral coefficients
-                       for the left channel.
-                       [Int32 *, length 1024]
-
-    coefRight = Array containing the fixed-point spectral coefficients
-                        for the right channel.
-                        [Int32 *, length 1024]
-
-    q_formatLeft = The Q-format for the left channel's fixed-point spectral
-                   coefficients, on a per-scalefactor band, non-grouped basis.
-                   [Int *, length MAX_SFB]
-
-    q_formatRight = The Q-format for the right channel's fixed-point spectral
-                    coefficients, on a per-scalefactor band, non-grouped basis.
-                    [Int *, length MAX_SFB]
-
-    pCurrentSeed  = Pointer to the current seed for the random number
-                    generator in the function gen_rand_vector().
-                    [Int32 * const]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coefLeft  = Contains the new spectral information.
-
-    coefRight = Contains the new spectral information.
-
-    q_formatLeft      = Q-format may be updated with changed to fixed-point
-                        data in coefLeft.
-
-    q_formatRight     = Q-format may be updated with changed to fixed-point
-                        data in coefRight.
-
-    pCurrentSeed      = Value pointed to by pCurrentSeed updated by calls
-                        to gen_rand_vector().
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function steps through all of the scalefactor bands, looking for
- either PNS or IS to be enabled on the right channel.
-
- If the codebook used is >= NOISE_HCB, the code then checks for the use
- of Huffman codebooks NOISE_HCB, INTENSITY_HCB, or INTENSITY_HCB2.
-
- When a SFB utilizing the codebook NOISE_HCB is detected, a check is made to
- see if M/S has also been enabled for that SFB.
-
- If M/S is not enabled, the band's spectral information is filled with
- scaled random data.   The scaled random data is generated by the function
- gen_rand_vector.  This is done across all windows in the group.
-
- If M/S is enabled, the band's spectral information is derived from the data
- residing in the same band on the left channel.  The information on the right
- channel has independent scaling, so this is a bit more involved than a
- direct copy of the information on the left channel.  This is done by calling
- the inline function pns_corr().
-
- When a SFB utilizing an intensity codebook is detected, the band's spectral
- information is generated from the information on the left channel.
- This is done across all windows in the group.  M/S being enabled has the
- effect of reversing the sign of the data on the right channel.  This code
- resides in the inline function intensity_right().
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.7.1   M/S stereo
-        Subpart 4.6.7.2.3 Decoding Process (Intensity Stereo)
-        Subpart 4.6.12.3  Decoding Process (PNS)
-        Subpart 4.6.2     ScaleFactors
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-    pCoefRight = coefRight;
-    pCoefLeft = coefLeft;
-
-    window_start = 0;
-    tot_sfb = 0;
-    start_indx = 0;
-
-    coef_per_win = pFrameInfo->coef_per_win[0];
-
-    sfb_per_win = pFrameInfo->sfb_per_win[0];
-
-    DO
-        pBand     = pFrameInfo->win_sfb_top[window_start];
-
-        partition = *pGroup;
-        pGroup = pGroup + 1;
-
-        band_start = 0;
-
-        wins_in_group = (partition - window_start);
-
-        FOR (sfb = sfb_per_win; sfb > 0; sfb--)
-
-            band_stop = *(pBand);
-            pBand = pBand + 1;
-
-            codebook = *(pCodebookMap);
-            pCodebookMap = pCodebookMap + 1;
-
-            mask_enabled = *(pMaskMap);
-            pMaskMap = pMaskMap + 1;
-
-            band_length = band_stop - band_start;
-
-            IF (codebook == NOISE_HCB)
-
-                sfb_prediction_used[tot_sfb] &= ltp_data_present;
-
-                IF (sfb_prediction_used[tot_sfb] == FALSE)
-
-                    mask_enabled = mask_enabled AND hasmask;
-
-                    IF (mask_enabled == FALSE)
-
-                        pWindow_CoefR = &(pCoefRight[band_start]);
-
-                        start_indx = tot_sfb;
-
-                        FOR (win_indx = wins_in_group;
-                             win_indx > 0;
-                             win_indx--)
-
-                            CALL
-                            q_formatRight[start_indx] =
-                                 gen_rand_vector(
-                                     pWindow_CoefR,
-                                     band_length,
-                                     pCurrentSeed,
-                                     *(pFactorsRight));
-                            MODIFYING
-                                pCoefRight[band_start]
-                            RETURNING
-                                q_formatRight[start_indx]
-
-                            pWindow_CoefR += coef_per_win;
-
-                            start_indx = start_indx + sfb_per_win;
-
-                        ENDFOR
-
-                    ELSE
-                        CALL
-                        pns_corr(
-                             (*(pFactorsRight) -
-                              *(pFactorsLeft) ),
-                             coef_per_win,
-                             sfb_per_win,
-                             wins_in_group,
-                             band_length,
-                             q_formatLeft[tot_sfb],
-                            &(q_formatRight[tot_sfb]),
-                            &(pCoefLeft[band_start]),
-                            &(pCoefRight[band_start]));
-
-                        MODIFYING
-                            pCoefRightt[band_start]
-                            q_formatRight[tot_sfb]
-                        RETURNING
-                NONE
-                    ENDIF
-
-                ENDIF
-
-            ELSE IF (codebook >= INTENSITY_HCB2)
-
-                mask_enabled = mask_enabled AND hasmask;
-
-                CALL
-                    intensity_right(
-                        *(pFactorsRight),
-                        coef_per_win,
-                        sfb_per_win,
-                        wins_in_group,
-                        band_length,
-                        codebook,
-                        mask_enabled,
-                       &(q_formatLeft[tot_sfb]),
-                       &(q_formatRight[tot_sfb]),
-                       &(pCoefLeft[band_start]),
-                       &(pCoefRight[band_start]));
-
-                MODIFYING
-                    pCoefRightt[band_start]
-                    q_formatRight[tot_sfb]
-                RETURNING
-                    NONE
-
-            ENDIF
-
-            band_start = band_stop;
-
-            tot_sfb = tot_sfb + 1;
-
-        ENDFOR
-
-        coef_per_win = coef_per_win * (wins_in_group);
-
-        wins_in_group = wins_in_group - 1;
-
-        tot_sfb = tot_sfb + sfb_per_win * wins_in_group;
-        pFactorsRight = pFactorsRight + sfb_per_win * wins_in_group;
-        pFactorsLeft  = pFactorsLeft + sfb_per_win * wins_in_group;
-
-        pCoefRight = pCoefRight + coef_per_win;
-        pCoefLeft  = pCoefLeft + coef_per_win;
-
-        window_start = partition;
-
-    WHILE (partition < pFrameInfo->num_win);
-
-    return;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_intensity_right.h"
-#include "e_huffmanconst.h"
-#include "gen_rand_vector.h"
-#include "intensity_right.h"
-#include "pns_corr.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_intensity_right(
-    const Int        hasmask,
-    const FrameInfo * const pFrameInfo,
-    const Int        group[],
-    const Bool       mask_map[],
-    const Int        codebook_map[],
-    const Int        factorsL[],
-    const Int        factorsR[],
-    Int        sfb_prediction_used[],
-    const Bool       ltp_data_present,
-    Int32      coefLeft[],
-    Int32      coefRight[],
-    Int        q_formatLeft[MAXBANDS],
-    Int        q_formatRight[MAXBANDS],
-    Int32 * const pCurrentSeed)
-{
-
-    Int32   *pCoefRight;
-    Int32   *pWindow_CoefR;
-
-    Int32   *pCoefLeft;
-
-    Int     tot_sfb;
-    Int     start_indx;
-    Int     sfb;
-
-    Int     band_length;
-    Int     band_start;
-    Int     band_stop;
-    Int     coef_per_win;
-
-    Int     codebook;
-    Int     partition;
-    Int     window_start;
-
-    Int     sfb_per_win;
-    Int     wins_in_group;
-    Int     win_indx;
-
-    const Int16 *pBand;
-    const Int   *pFactorsLeft  = factorsL;
-    const Int   *pFactorsRight = factorsR;
-    const Int   *pCodebookMap  = codebook_map;
-    const Int   *pGroup        = group;
-    const Bool  *pMaskMap      = mask_map;
-
-    Bool mask_enabled;
-
-    pCoefRight = coefRight;
-    pCoefLeft = coefLeft;
-
-    window_start = 0;
-    tot_sfb = 0;
-    start_indx = 0;
-
-    /*
-     * Each window in the frame should have the same number of coef's,
-     * so coef_per_win is constant in all the loops
-     */
-    coef_per_win = pFrameInfo->coef_per_win[0];
-
-    /*
-     * Because the number of scalefactor bands per window should be
-     * constant for each frame, sfb_per_win can be determined outside
-     * of the loop.
-     *
-     * For 44.1 kHz sampling rate   sfb_per_win = 14 for short windows
-     *                              sfb_per_win = 49 for long  windows
-     */
-
-    sfb_per_win = pFrameInfo->sfb_per_win[0];
-
-    do
-    {
-        pBand     = pFrameInfo->win_sfb_top[window_start];
-
-        /*----------------------------------------------------------
-        Partition is equal to the first window in the next group
-
-        { Group 0    }{      Group 1      }{    Group 2 }{Group 3}
-        [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
-
-        pGroup[0] = 2
-        pGroup[1] = 5
-        pGroup[2] = 7
-        pGroup[3] = 8
-        -----------------------------------------------------------*/
-        partition = *(pGroup++);
-
-        band_start = 0;
-
-        wins_in_group = (partition - window_start);
-
-        for (sfb = sfb_per_win; sfb > 0; sfb--)
-        {
-            /* band is offset table, band_stop is last coef in band */
-            band_stop = *(pBand++);
-
-            codebook = *(pCodebookMap++);
-
-            mask_enabled = *(pMaskMap++);
-
-            /*
-             * When a tool utilizing sfb is found, apply the correct tool
-             * to that sfb in each window in the group
-             *
-             * Example...  sfb[3] == NOISE_HCB
-             *
-             * [ Group 1                                      ]
-             * [win 0                 ][win 1                 ]
-             * [0][1][2][X][4][5][6][7][0][1][2][X][4][5][6][7]
-             *
-             * The for(sfb) steps through the sfb's 0-7 in win 0.
-             *
-             * Finding sfb[3]'s codebook == NOISE_HCB, the code
-             * steps through all the windows in the group (they share
-             * the same scalefactors) and replaces that sfb with noise.
-             */
-
-            /*
-             * Experimental results suggest that ms_synt is the most
-             * commonly used tool, so check for it first.
-             *
-             */
-
-            band_length = band_stop - band_start;
-
-            if (codebook == NOISE_HCB)
-            {
-                sfb_prediction_used[tot_sfb] &= ltp_data_present;
-
-                if (sfb_prediction_used[tot_sfb] == FALSE)
-                {
-                    /*
-                     * The branch and the logical AND interact in the
-                     * following manner...
-                     *
-                     * mask_enabled == 0 hasmask == X -- gen_rand_vector
-                     * mask_enabled == 1 hasmask == 1 -- pns_corr
-                     * mask_enabled == 0 hasmask == 1 -- gen_rand_vector
-                     * mask_enabled == 1 hasmask == 2 -- gen_rand_vector
-                     * mask_enabled == 0 hasmask == 2 -- gen_rand_vector
-                     */
-
-                    mask_enabled &= hasmask;
-
-                    if (mask_enabled == FALSE)
-                    {
-                        pWindow_CoefR = &(pCoefRight[band_start]);
-
-                        /*
-                         * Step through all the windows in this group,
-                         * replacing this band in each window's
-                         * spectrum with random noise
-                         */
-                        start_indx = tot_sfb;
-
-                        for (win_indx = wins_in_group;
-                                win_indx > 0;
-                                win_indx--)
-                        {
-
-                            /* generate random noise */
-                            q_formatRight[start_indx] =
-                                gen_rand_vector(
-                                    pWindow_CoefR,
-                                    band_length,
-                                    pCurrentSeed,
-                                    *(pFactorsRight));
-
-                            pWindow_CoefR += coef_per_win;
-
-                            start_indx += sfb_per_win;
-                        }
-
-                    }
-                    else
-                    {
-                        pns_corr(
-                            (*(pFactorsRight) -
-                             *(pFactorsLeft)),
-                            coef_per_win,
-                            sfb_per_win,
-                            wins_in_group,
-                            band_length,
-                            q_formatLeft[tot_sfb],
-                            &(q_formatRight[tot_sfb]),
-                            &(pCoefLeft[band_start]),
-                            &(pCoefRight[band_start]));
-
-                    } /* if (mask_map == FALSE) */
-
-                } /* if (sfb_prediction_used[tot_sfb] == FALSE) */
-
-            } /* if (codebook == 0) */
-            else if (codebook >= INTENSITY_HCB2)
-            {
-                /*
-                 * The logical AND flags the inversion of intensity
-                 * in the following manner.
-                 *
-                 * mask_enabled == X hasmask == 0 -- DO NOT INVERT
-                 * mask_enabled == 0 hasmask == X -- DO NOT INVERT
-                 * mask_enabled == 1 hasmask == 1 -- DO     INVERT
-                 * mask_enabled == 0 hasmask == 1 -- DO NOT INVERT
-                 * mask_enabled == 1 hasmask == 2 -- DO NOT INVERT
-                 * mask_enabled == 0 hasmask == 2 -- DO NOT INVERT
-                 */
-
-                mask_enabled &= hasmask;
-
-                intensity_right(
-                    *(pFactorsRight),
-                    coef_per_win,
-                    sfb_per_win,
-                    wins_in_group,
-                    band_length,
-                    codebook,
-                    mask_enabled,
-                    &(q_formatLeft[tot_sfb]),
-                    &(q_formatRight[tot_sfb]),
-                    &(pCoefLeft[band_start]),
-                    &(pCoefRight[band_start]));
-
-            } /* END else codebook must be INTENSITY_HCB or ... */
-
-            band_start = band_stop;
-
-            tot_sfb++;
-
-            pFactorsLeft++;
-            pFactorsRight++;
-
-        } /* for (sfb) */
-
-        /*
-         * Increment pCoefRight and pCoefLeft by
-         * coef_per_win * the number of windows
-         */
-
-        pCoefRight += coef_per_win * wins_in_group;
-        pCoefLeft  += coef_per_win * wins_in_group--;
-
-        /*
-         * Increase tot_sfb by sfb_per_win times the number of windows minus 1.
-         * The minus 1 comes from the fact that tot_sfb is already pointing
-         * to the first sfb in the 2nd window of the group.
-         */
-        tot_sfb += sfb_per_win * wins_in_group;
-
-        pFactorsRight += sfb_per_win * wins_in_group;
-        pFactorsLeft  += sfb_per_win * wins_in_group;
-
-        window_start = partition;
-
-    }
-    while (partition < pFrameInfo->num_win);
-
-    /* pFrameInfo->num_win = 1 for long windows, 8 for short_windows */
-
-    return;
-
-} /* pns_intensity_right() */
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_intensity_right.h b/media/libstagefright/codecs/aacdec/pns_intensity_right.h
deleted file mode 100644
index 7b6f79f..0000000
--- a/media/libstagefright/codecs/aacdec/pns_intensity_right.h
+++ /dev/null
@@ -1,106 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_intensity_right.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Add hasmask parameter
-
- Description: Changed name to from right_ch_sfb_tools_ms to intensity_right
- to more correct reflect the purpose of the function.
-
- Who:                                  Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- pns_intensity_right.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_INTENSITY_RIGHT_H
-#define PNS_INTENSITY_RIGHT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void pns_intensity_right(
-    const Int        hasmask,
-    const FrameInfo * const pFrameInfo,
-    const Int        group[],
-    const Bool       mask_map[],
-    const Int        codebook_map[],
-    const Int        factorsL[],
-    const Int        factorsR[],
-    Int        sfb_prediction_used[],
-    const Bool       ltp_data_present,
-    Int32      spectralCoefLeft[],
-    Int32      spectralCoefRight[],
-    Int        q_formatLeft[MAXBANDS],
-    Int        q_formatRight[MAXBANDS],
-    Int32     * const pCurrentSeed);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pns_left.cpp b/media/libstagefright/codecs/aacdec/pns_left.cpp
deleted file mode 100644
index 2446de2..0000000
--- a/media/libstagefright/codecs/aacdec/pns_left.cpp
+++ /dev/null
@@ -1,431 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Pathname: pns_left.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Brought code in-line with PV standards.
-               Merged PNS and Intensity blocks into one function.
-               Modified routine to interface with a fixed-point implementation.
-               Modified variable names for clarity.
-               Improved for-loop structure that was previously checking
-               the codebook used in each scale factor band multiple times.
-
- Description:  Added some comments for clarity.
-
- Description:  Changed strategy for q-format.  Q-format for SFBs should not
- be grouped.
-
- Description: Function had to be modified to obey new interpretation of the
- sfb_prediction_used flag.  LTP takes precedence, and PNS should not be
- executed when a collision occurs between these two tools.
-
- Description:
- (1) Added flag "ltp_data_present"
- (2) Where feasible, I updated the code to resemble right_ch_sfb_tools_ms.c
-     Just for conformance, readability.
-
- Description: Added include file - "e_huffmanconst.h"
-
- Description: The same "Factors" pointer indexing problem that existed in
- right_ch_sfb_tools_ms also existed here in pns_left.c
-
- Description:  Modified how groups and windows are handled, as the multigroup
- case was not correct
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    const FrameInfo *pFrameInfo         = Pointer to structure that holds
-                                          information about each group.
-                                          (long block flag,
-                                           number of windows,
-                                           scalefactor bands per group, etc.)
-
-    const Int        group[]            = Array that contains indexes of the
-                                          the first window in the next group.
-
-    const Int        codebook_map[]     = Array that denotes which Huffman
-                                          codebook was used for the encoding
-                                          of each scalefactor band.
-
-    const Int        factors[]          = Array of scalefactors
-
-    Int              sfb_prediction_used[] = Flag that denotes the activation
-                                             of long term prediction on a sfb
-                                             basis.
-
-    Bool             ltp_data_present   = Flag that denotes whether LTP
-                                          is active for the entire frame.  If
-                                          this flag is FALSE,
-                                          sfb_prediction_used is garbage.
-
-    Int32            spectral_coef[]    = Array of pointers pointing to the
-                                          spectral coef's for the LEFT channel.
-
-    Int              q_format[]           = Q-format for the information
-                                            pointed to by spectral_coef.
-                                            Indexed by scalefactor band.
-
-    Int32           *pCurrentSeed         = Pointer to the current seed for the
-                                            random number generator.
-                                            (gen_rand_vector)
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-    Int32  spectral_coef[]    =   Contains the new spectral information
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- The function steps through each scalefactor band in the group, and
- checks for the use of Huffman codebook NOISE_HCB.
-
- When a SFB utilizing NOISE_HCB is detected, the band in every window in the
- group has its spectral information filled with scaled random data.
-
- The scaled random data is generated by the function gen_rand_vector.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall replace bands that were encoded with the Huffman codebook
- NOISE_HCB with random noise as returned from gen_rand_vector().  The result
- shall be perceptually indistinguishable from the result obtained by the
- ISO decoder.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.5.5   Figures
-        Subpart 4.6.2   ScaleFactors
-        Subpart 4.6.12  Perceptual Noise Substituion (PNS)
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pFirst_Window_Coefs = spectral_coef;
-
-    window_start = 0;
-
-    tot_sfb = 0;
-
-    DO
-
-        num_bands = pFrameInfo->sfb_per_win[window_start];
-        pBand     = pFrameInfo->win_sfb_top[window_start];
-
-        partition = *(pGroup);
-        pGroup = pGroup + 1;
-
-        band_start = 0;
-
-        coef_per_win = pFrameInfo->coef_per_win[window_start];
-
-        wins_in_group = (partition - window_start);
-
-        FOR (sfb = num_bands; sfb > 0; sfb--)
-
-            band_stop = *pBand;
-            pBand = pBand + 1;
-
-            IF (*(pCodebookMap++) == NOISE_HCB )
-
-                tempInt = sfb_prediction_used[tot_sfb] AND ltp_data_present;
-
-                IF (tempInt == FALSE)
-
-                    pWindow_Coef = pFirst_Window_Coefs + band_start;
-
-                    band_length = (band_stop - band_start);
-
-                    start_indx = tot_sfb;
-
-                    tempInt = *(pFactors);
-
-                    FOR (win_indx = wins_in_group; win_indx > 0; win_indx--)
-
-                        CALL gen_rand_vector( pWindow_CoefR,
-                                              band_length,
-                                              pCurrentSeed,
-                                              tempInt);
-
-                        MODIFYING pWindow_CoefR = scaled random noise
-                                  pCurrentSeed  = current state of the random
-                                                  noise generator.
-
-                        RETURNING q_format[start_indx] = q-format for this sfb.
-
-                        pWindow_Coef = pWindow_Coef + coef_per_win;
-
-                        start_indx = start_indx +
-                                     pFrameInfo->sfb_per_win[win_indx];
-
-                    ENDFOR
-
-                ENDIF
-
-            ENDIF
-
-            band_start = band_stop;
-
-            tot_sfb = tot_sfb + 1;
-
-            pFactors = pFactors + 1;
-
-        ENDFOR
-
-        coef_per_win = coef_per_win * wins_in_group;
-        wins_in_group = wins_in_group - 1;
-
-        tot_sfb = tot_sfb + num_bands * wins_in_group;
-        pFactors = pFactors + num_bands * wins_in_group;
-
-        pFirst_Window_Coefs = pFirst_Window_Coefs + coef_per_win;
-
-        window_start = partition;
-
-    WHILE (partition < pFrameInfo->num_win);
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "pns_left.h"
-#include "e_huffmanconst.h"
-#include "gen_rand_vector.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pns_left(
-    const FrameInfo *pFrameInfo,
-    const Int        group[],
-    const Int        codebook_map[],
-    const Int        factors[],
-    const Int        sfb_prediction_used[],
-    const Bool       ltp_data_present,
-    Int32      spectral_coef[],
-    Int        q_format[],
-    Int32     *pCurrentSeed)
-{
-
-    Int     tot_sfb;
-    Int     start_indx;
-
-    Int     sfb;
-    Int     band_stop;
-
-    const Int16  *pBand;
-
-    const Int *pCodebookMap = &(codebook_map[0]);
-    const Int *pGroup   = &(group[0]);
-    const Int *pFactors = &(factors[0]);
-
-    Int     tempInt;
-    Int32  *pWindow_Coef;
-
-
-    Int32   *spec;
-
-    Int partition;
-    Int win_indx;
-
-    tot_sfb = 0;
-
-    spec = spectral_coef;
-
-    /* PNS goes by group */
-    win_indx = 0;
-    partition = 0;
-    do
-    {
-        Int num_bands = pFrameInfo->sfb_per_win[partition];
-        pBand = pFrameInfo->win_sfb_top[partition];
-
-        /*----------------------------------------------------------
-        Partition is equal to the first window in the next group
-
-        { Group 0    }{      Group 1      }{    Group 2 }{Group 3}
-        [win 0][win 1][win 2][win 3][win 4][win 5][win 6][win 7]
-
-        pGroup[0] = 2
-        pGroup[1] = 5
-        pGroup[2] = 7
-        pGroup[3] = 8
-        -----------------------------------------------------------*/
-
-        partition = *pGroup++;      /* partition = index of last sbk in group */
-
-        do
-        {
-            Int band_start = 0;
-            for (sfb = 0; sfb < num_bands; sfb++)
-            {
-                band_stop = pBand[sfb]; /* band is offset table, band_stop is last coef in band */
-
-                Int band_length =  band_stop - band_start;
-                if (pCodebookMap[sfb] == NOISE_HCB)
-                {
-
-                    tempInt = sfb_prediction_used[tot_sfb] & ltp_data_present;
-
-                    if (tempInt == FALSE)
-                    {
-                        /* generate random noise */
-                        pWindow_Coef = spec + band_start;
-
-                        tempInt = pFactors[sfb];
-
-                        start_indx = tot_sfb++;
-
-                        /* reconstruct noise substituted values */
-                        /* generate random noise */
-
-                        q_format[start_indx] = gen_rand_vector(pWindow_Coef,
-                                                               band_length,
-                                                               pCurrentSeed,
-                                                               tempInt);
-
-                    }   /* if (sfb_prediction_used[tot_sfb] == FALSE) */
-
-                }   /* if (*(pCodebookMap++) == NOISE_HCB) */
-                else
-                {
-                    tot_sfb ++;     /*  update absolute sfb counter  */
-                }
-
-                band_start = band_stop;
-
-            }   /* for (sfb) */
-
-            spec += pFrameInfo->coef_per_win[win_indx++];
-            pFactors += num_bands;
-
-        }
-        while (win_indx < partition);
-
-        pCodebookMap += pFrameInfo->sfb_per_win[win_indx-1];
-
-    }
-    while (partition < pFrameInfo->num_win);
-
-
-    return;
-
-} /* pns */
diff --git a/media/libstagefright/codecs/aacdec/pns_left.h b/media/libstagefright/codecs/aacdec/pns_left.h
deleted file mode 100644
index c44b13c..0000000
--- a/media/libstagefright/codecs/aacdec/pns_left.h
+++ /dev/null
@@ -1,113 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pns_left.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Removed #defines of LEFT and RIGHT, and the extra include
- file "e_huffmanconst.h"
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Contains the function definition for pns_left.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PNS_LEFT_H
-#define PNS_LEFT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void pns_left(
-        const FrameInfo *pFrameInfo,
-        const Int        group[],
-        const Int        codebook_map[],
-        const Int        factors[],
-        const Int        sfb_prediction_used[],
-        const Bool       ltp_data_present,
-        Int32      spectral_coef[],
-        Int        q_format[],
-        Int32     *pCurrentSeed);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
-
-
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp b/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp
deleted file mode 100644
index 48432f8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.cpp
+++ /dev/null
@@ -1,311 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_all_pass_filter_coeff.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Decorrelation is achieved by means of all-pass filtering
-
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "pv_audio_type_defs.h"
-#include    "s_ps_dec.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_all_pass_fract_delay_filter.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS] =
-{
-
-
-    { Qfmt15(0.74915491616071f),  Qfmt15(0.64942584030892f),  Qfmt15(0.56297290849050f) },
-    { Qfmt15(0.71658296328416f),  Qfmt15(0.62118993420853f),  Qfmt15(0.53849582551265f) },
-    { Qfmt15(0.68401101040761f),  Qfmt15(0.59295402810815f),  Qfmt15(0.51401874253480f) },
-    { Qfmt15(0.65143905753106f),  Qfmt15(0.56471812200776f),  Qfmt15(0.97908331911390f) },      /*  3  */
-    { Qfmt15(0.61886710465450f),  Qfmt15(0.53648221590737f),  Qfmt15(0.93012915315822f) },
-    { Qfmt15(0.58629515177795f),  Qfmt15(0.50824630980698f),  Qfmt15(0.88117498720252f) },
-    { Qfmt15(0.55372319890140f),  Qfmt15(0.48001040370660f),  Qfmt15(0.83222082124682f) },
-    { Qfmt15(0.52115124602484f),  Qfmt15(0.45177449760621f),  Qfmt15(0.78326665529112f) },
-    { Qfmt15(0.48857929314829f),  Qfmt15(0.42353859150582f),  Qfmt15(0.73431248933542f) },
-    { Qfmt15(0.45600734027174f),  Qfmt15(0.39530268540543f),  Qfmt15(0.68535832337974f) },
-    { Qfmt15(0.42343538739519f),  Qfmt15(0.36706677930504f),  Qfmt15(0.63640415742404f) },
-    { Qfmt15(0.39086343451863f),  Qfmt15(0.33883087320466f),  Qfmt15(0.58744999146834f) },
-    { Qfmt15(0.35829148164208f),  Qfmt15(0.31059496710427f),  Qfmt15(0.53849582551265f) },
-    { Qfmt15(0.32571952876553f),  Qfmt15(0.28235906100388f),  Qfmt15(0.48954165955695f) },
-    { Qfmt15(0.29314757588898f),  Qfmt15(0.25412315490349f),  Qfmt15(0.44058749360126f) },
-    { Qfmt15(0.26057562301242f),  Qfmt15(0.22588724880310f),  Qfmt15(0.39163332764556f) },
-    { Qfmt15(0.22800367013587f),  Qfmt15(0.19765134270272f),  Qfmt15(0.34267916168986f) },
-    { Qfmt15(0.19543171725932f),  Qfmt15(0.16941543660233f),  Qfmt15(0.29372499573418f) },
-    { Qfmt15(0.16285976438276f),  Qfmt15(0.14117953050194f),  Qfmt15(0.24477082977848f) },
-    { Qfmt15(0.13028781150621f),  Qfmt15(0.11294362440155f),  Qfmt15(0.19581666382278f) },
-    { Qfmt15(0.09771585862966f),  Qfmt15(0.08470771830116f),  Qfmt15(0.14686249786708f) },
-    { Qfmt15(0.06514390575311f),  Qfmt15(0.05647181220078f),  Qfmt15(0.09790833191140f) },
-    { Qfmt15(0.03257195287655f),  Qfmt15(0.02823590610039f),  Qfmt15(0.04895416595570f) }
-
-};
-
-
-
-
-
-const Char groupBorders[NO_IID_GROUPS + 1] =
-{
-    4,  5,  0,  1,  2,  3,  7,  6,   8,  9,  3,  4,
-    5,  6,  7,  8,  9,  11, 14, 18, 23, 35, 64
-};
-
-const Char bins2groupMap[NO_IID_GROUPS] =
-{
-    1, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19
-};
-
-
-
-
-/*
- *  q_phi = 0.39
- *
- *  cos(pi*([3:22]+0.5)*q_phi)
- */
-
-
-/*
- *  sin(-pi*([3:22]+0.5)*q_phi)
- */
-
-
-const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS] =
-{
-    0xCB5474A9,  0x5BEC5914, 0x72F3C7B0, 0xF1F480C6, 0x8389E21E,
-    0xB9BA6AFC,  0x4CDB665C, 0x7A57DA5D, 0x06088024, 0x89BECF04,
-    0xA9DB5EAC,  0x3BE5711F, 0x7EB9EDF7, 0x19F582A9, 0x92DDBD1F,
-    0x9C1B5008,  0x29767919, 0x7FFC0203, 0x2D3F8843, 0x9EABACDF
-};
-
-/*
- *  q(m) = { 0.43, 0.75, 0.347 }
- *
- *  cos(pi*([3:22]+0.5)*q(m))        cos(pi*([3:22]+0.5)'*q)
- *
- *  sin(-pi*([3:22]+0.5)*q(m))
- *
- */
-
-
-const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3] =
-{
-    { 0x02037FFC,  0xCF0489BE, 0x9BFB4FE0 },
-    { 0x7D5719F5,  0xCF047642, 0x18947D9E },
-    { 0x34AD8B57,  0x7642CF04, 0x7ABF244A },
-    { 0x99A4B325,  0x89BECF04, 0x58EFA3F1 },
-    { 0x9EAB5321,  0x30FC7642, 0xD77E8694 },
-    { 0x3BE5711F,  0x30FC89BE, 0x819CEBC7 },
-    { 0x7B77DE39,  0x89BE30FC, 0xB3A166B8 },
-    { 0xF9F88024,  0x764230FC, 0x37C57336 },
-    { 0x81E8E9FE,  0xCF0489BE, 0x7FF103D2 },
-    { 0xCF047642,  0xCF047642, 0x3E8B9052 },
-    { 0x68B9499A,  0x7642CF04, 0xB9E594E8 },
-    { 0x5EACA9DB,  0x89BECF04, 0x80A00CA5 },
-    { 0xC09590D1,  0x30FC7642, 0xD05276CA },
-    { 0x85A925A3,  0x30FC89BE, 0x53486134 },
-    { 0x0A0B7F9B,  0x89BE30FC, 0x7CB2E319 },
-    { 0x7EB91209,  0x764230FC, 0x20078412 },
-    { 0x2D3F8843,  0xCF0489BE, 0xA0ECAA4D },
-    { 0x9504B9BA,  0xCF047642, 0x880D2CAE },
-    { 0xA4145914,  0x7642CF04, 0xF0287F04 },
-    { 0x42E16D23,  0x89BECF04, 0x694C48C7 }
-};
-
-/*
- *  Fractional delay vector
- *
- *  phi_fract(k) = exp(-j*pi*q_phi*f_center(k))       0<= k <= SUBQMF_GROUPS
- *
- *  q_phi = 0.39
- *  f_center(k) frequency vector
- *
- *
- *  f_center(k) = {0.5/4,  1.5/4,  2.5/4,  3.5/4,
- *                -1.5/4, -0.5/4,
- *                 3.5/2,  2.5/2,  4.5/2,  5.5/2};
- */
-
-
-
-const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS] =
-{
-    0x7E80EC79,  0x72BAC73D, 0x5C45A749, 0x3D398F97, 0x72BA38C3,
-    0x7E801387,  0xBA919478, 0x05068019, 0x895DCFF2, 0x834E1CE7,
-};
-
-
-
-
-
-/*
- *  Fractional delay length matrix
- *
- *  Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k))
- *
- *  q(m) = { 0.43, 0.75, 0.347 }
- *  f_center(k) frequency vector
- *
- *
- *  f_center(k) = { 0.5/4,  1.5/4,  2.5/4,  3.5/4,
- *                 -1.5/4, -0.5/4,
- *                  3.5/2,  2.5/2,  4.5/2,  5.5/2};
- */
-
-const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3] =
-{
-
-    { 0x7E2EEA7D,  0x7A7DDAD8, 0x7ED0EE9D },
-    { 0x6FEDC1E5,  0x51349D0E, 0x7574CD1E },
-    { 0x5506A052,  0x0C8C809E, 0x636CAF62 },
-    { 0x3085898D,  0xC3A98F1D, 0x4A0D9799 },
-    { 0x6FED3E1B,  0x513462F2, 0x757432E2 },
-    { 0x7E2E1583,  0x7A7D2528, 0x7ED01163 },
-    { 0xA4C8A634,  0xB8E36A6E, 0xD5AF8732 },
-    { 0xF0F580E3,  0x8276E707, 0x1A7382C3 },
-    { 0x80ABF2F4,  0x471D6A6E, 0x9D2FAEA4 },
-    { 0x9478456F,  0x7D8AE707, 0x8152EDAB }
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h b/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h
deleted file mode 100644
index 0358acb..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_filter_coeff.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_all_pass_filter_coeff.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for all pass filter coefficients
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALL_PASS_FILTER_COEFF_H
-#define PS_ALL_PASS_FILTER_COEFF_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-extern const Char groupBorders[NO_IID_GROUPS + 1];
-extern const Int16 aRevLinkDecaySerCoeff[NO_ALLPASS_CHANNELS][NO_SERIAL_ALLPASS_LINKS];
-extern const Int32  aRevLinkDelaySer[];
-extern const Int16 aFractDelayPhaseFactorReQmf[NO_QMF_ALLPASS_CHANNELS];
-extern const Int16 aFractDelayPhaseFactorImQmf[NO_QMF_ALLPASS_CHANNELS];
-/* the old center frequencies (found in "else") were too small (factor 1/2) */
-extern const Int16 aFractDelayPhaseFactorReSubQmf[SUBQMF_GROUPS];
-extern const Int16 aFractDelayPhaseFactorImSubQmf[SUBQMF_GROUPS];
-extern const Int32 aFractDelayPhaseFactorSubQmf[SUBQMF_GROUPS];
-extern const Int32 aFractDelayPhaseFactor[NO_QMF_ALLPASS_CHANNELS];
-extern const Int32 aaFractDelayPhaseFactorSerQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerSubQmf[SUBQMF_GROUPS][3];
-extern const Char bins2groupMap[NO_IID_GROUPS];
-extern const Int32 aaFractDelayPhaseFactorSerReQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerImQmf[NO_QMF_ALLPASS_CHANNELS][3];
-extern const Int32 aaFractDelayPhaseFactorSerReSubQmf[SUBQMF_GROUPS][3];
-extern const Int32 aaFractDelayPhaseFactorSerImSubQmf[SUBQMF_GROUPS][3];
-
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_ALL_PASS_FILTER_COEFF_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp b/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp
deleted file mode 100644
index 81761a6..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.cpp
+++ /dev/null
@@ -1,391 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_all_pass_fract_delay_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Decorrelation
-  Decorrelation is achieved by means of all-pass filtering and delaying
-  Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
-  d_k(n). k index for frequency, n time index
-
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-  Delay is introduced to compensate QMF bands not passed through Hybrid
-  Analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "pv_audio_type_defs.h"
-#include    "ps_decorrelate.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_pwr_transient_detection.h"
-#include    "ps_all_pass_fract_delay_filter.h"
-#include    "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-/*
- *  For lower subbands
- *  Apply all-pass filtering
- *
- */
-
-
-void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex,
-        Int32 sb_delay,
-        const Int32 *ppFractDelayPhaseFactorSer,
-        Int32 ***pppRealDelayRBufferSer,
-        Int32 ***pppImagDelayRBufferSer,
-        Int32 *rIn,
-        Int32 *iIn)
-{
-
-    Int32 cmplx;
-    Int16 rTmp0;
-    Int32 rTmp;
-    Int32 iTmp;
-    Int32 *pt_rTmp;
-    Int32 *pt_iTmp;
-
-
-
-    /*
-     *  All pass filters
-     *                         2
-     *                        ___  Q_fract(k,m)*z^(-d(m))  -  a(m)*g_decay_slope(k)
-     *   z^(-2)*phi_fract(k)* | |  ------------------------------------------------
-     *                        m=0  1  - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m))
-     *
-     *
-     *    Fractional delay matrix:
-     *
-     *    Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k))       0<= k <= SUBQMF_GROUPS
-     *
-     *    Vectors: a(m), q(m), d(m) are constants
-     *
-     *    m                              m     0       1       2
-     *                                 -------------------------------
-     *    delay length                 d(m) == 3       4       5      (Fs > 32 KHz)
-     *    fractional delay length      q(m) == 0.43    0.75    0.347
-     *    filter coefficient           a(m) == 0.65144 0.56472 0.48954
-     *
-     *             g_decay_slope(k) is given
-     */
-
-
-    Int32 tmp_r;
-    Int32 tmp_i;
-
-    pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay];
-
-    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = Qfmt15(0.65143905753106f);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-
-
-    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
-
-    *rIn = rTmp;
-
-    pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay];
-
-
-
-    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = Qfmt15(0.56471812200776f);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-
-
-    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
-    *rIn = rTmp;
-
-    pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-
-
-    cmplx  = *(ppFractDelayPhaseFactorSer);        /* Q_fract(k,m)  */
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = Qfmt15(0.97908331911390f);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-
-
-    iTmp     =  fxp_mac32_by_16(-*iIn, rTmp0, iTmp);    /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp, rTmp0, *iIn);     /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp << 2;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp, rTmp0, *rIn);
-    *rIn = rTmp << 2;
-}
-
-
-void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex,
-        Int32 sb_delay,
-        const Int32 *ppFractDelayPhaseFactorSer,
-        Int32 ***pppRealDelayRBufferSer,
-        Int32 ***pppImagDelayRBufferSer,
-        Int32 *rIn,
-        Int32 *iIn,
-        Int32 decayScaleFactor)
-{
-
-    Int32 cmplx;
-    Int16 rTmp0;
-    Int32 rTmp;
-    Int32 iTmp;
-    Int32 *pt_rTmp;
-    Int32 *pt_iTmp;
-    const Int16 *pt_delay;
-
-
-
-    /*
-     *  All pass filters
-     *                         2
-     *                        ___  Q_fract(k,m)*z^(-d(m))  -  a(m)*g_decay_slope(k)
-     *   z^(-2)*phi_fract(k)* | |  ------------------------------------------------
-     *                        m=0  1  - a(m)*g_decay_slope(k)*Q_fract(k,m)*z^(-d(m))
-     *
-     *
-     *    Fractional delay matrix:
-     *
-     *    Q_fract(k,m) = exp(-j*pi*q(m)*f_center(k))       0<= k <= SUBQMF_GROUPS
-     *
-     *    Vectors: a(m), q(m), d(m) are constants
-     *
-     *    m                              m     0       1       2
-     *                                 -------------------------------
-     *    delay length                 d(m) == 3       4       5      (Fs > 32 KHz)
-     *    fractional delay length      q(m) == 0.43    0.75    0.347
-     *    filter coefficient           a(m) == 0.65144 0.56472 0.48954
-     *
-     *             g_decay_slope(k) is given
-     */
-
-
-    Int32 tmp_r;
-    Int32 tmp_i;
-
-    pt_rTmp = &pppRealDelayRBufferSer[0][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[0][*(delayBufIndex++)][sb_delay];
-
-    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
-    pt_delay = aRevLinkDecaySerCoeff[decayScaleFactor];
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = *(pt_delay++);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-
-
-    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
-    *rIn = rTmp;
-
-    pt_rTmp = &pppRealDelayRBufferSer[1][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[1][*(delayBufIndex++)][sb_delay];
-
-
-    cmplx  = *(ppFractDelayPhaseFactorSer++);        /* Q_fract(k,m)  */
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = *(pt_delay++);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-    iTmp     =  fxp_mac32_by_16(-*iIn << 1, rTmp0, iTmp);  /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp << 1, rTmp0, *iIn);   /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn << 1, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp << 1, rTmp0, *rIn);
-    *rIn = rTmp;
-
-    pt_rTmp = &pppRealDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-    pt_iTmp = &pppImagDelayRBufferSer[2][*(delayBufIndex)][sb_delay];
-
-
-    cmplx  = *(ppFractDelayPhaseFactorSer);        /* Q_fract(k,m)  */
-    tmp_r = *pt_rTmp << 1;
-    tmp_i = *pt_iTmp << 1;
-
-    rTmp = cmplx_mul32_by_16(tmp_r, -tmp_i,  cmplx);
-    rTmp0  = *(pt_delay);
-    iTmp = cmplx_mul32_by_16(tmp_i,  tmp_r,  cmplx);
-
-
-    iTmp     =  fxp_mac32_by_16(-*iIn, rTmp0, iTmp);    /* Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n) */
-    *pt_iTmp =  fxp_mac32_by_16(iTmp, rTmp0, *iIn);     /* y(n) = x(n) + a(m)*g_decay_slope(k)*( Q_fract(k,m)*y(n-1) - a(m)*g_decay_slope(k)*x(n)) */
-    *iIn = iTmp << 2;
-
-    rTmp     =  fxp_mac32_by_16(-*rIn, rTmp0, rTmp);
-    *pt_rTmp =  fxp_mac32_by_16(rTmp, rTmp0, *rIn);
-    *rIn = rTmp << 2;
-
-}
-
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h b/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h
deleted file mode 100644
index b4e9876..0000000
--- a/media/libstagefright/codecs/aacdec/ps_all_pass_fract_delay_filter.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_all_pass_fract_delay_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_all_pass_fract_delay_filter()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALL_PASS_FRACT_DELAY_FILTER_H
-#define PS_ALL_PASS_FRACT_DELAY_FILTER_H
-
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define R_SHIFT     29
-#define Q29_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt15(x)   (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    void ps_all_pass_fract_delay_filter_type_I(UInt32 *delayBufIndex,
-    Int32 sb_delay,
-    const Int32 *ppFractDelayPhaseFactorSer,
-    Int32 ***pppRealDelayRBufferSer,
-    Int32 ***pppImagDelayRBufferSer,
-    Int32 *rIn,
-    Int32 *iIn);
-
-
-    void ps_all_pass_fract_delay_filter_type_II(UInt32 *delayBufIndex,
-            Int32 sb_delay,
-            const Int32 *ppFractDelayPhaseFactorSer,
-            Int32 ***pppRealDelayRBufferSer,
-            Int32 ***pppImagDelayRBufferSer,
-            Int32 *rIn,
-            Int32 *iIn,
-            Int32 decayScaleFactor);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_ALL_PASS_FRACT_DELAY_FILTER_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp b/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp
deleted file mode 100644
index ab15651..0000000
--- a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.cpp
+++ /dev/null
@@ -1,341 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_allocate_decoder.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Reuses AAC+ HQ right channel, which is not used when PS is enabled
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef HQ_SBR
-
-#ifdef PARAMETRICSTEREO
-
-#include    "s_sbr_channel.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_hybrid_filter_bank_allocation.h"
-#include    "s_ps_dec.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_allocate_decoder.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     30
-#define Q30_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int32  aRevLinkDelaySer[] = {3,  4,  5};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_allocate_decoder(SBRDECODER_DATA *self,
-                          UInt32  noSubSamples)
-{
-    Int32 i, j;
-    Int32 status;
-
-    Int32 *ptr1;
-    Int32 *ptr2;
-    Int32 *ptr3;
-    Int32 *ptr4;
-    Int32 *ptr5;
-    Int32 *ptr6;
-    Int32 *ptr7;
-
-    const Int32 pHybridResolution[] = { HYBRID_8_CPLX,
-                                        HYBRID_2_REAL,
-                                        HYBRID_2_REAL
-                                      };
-
-    STRUCT_PS_DEC *h_ps_dec = self->hParametricStereoDec;
-
-    /* initialisation */
-    h_ps_dec->noSubSamples = noSubSamples;
-
-    h_ps_dec->invNoSubSamples = Q30_fmt(1.0f) / noSubSamples;
-
-    /*
-     *  Reuse AAC+ HQ right channel, which is not used when PS is enabled
-     */
-    ptr1 = (Int32 *)(self->SbrChannel[1].frameData.codecQmfBufferReal[0]);   /*  reuse un-used right channel QMF_FILTER Synthesis buffer */
-
-    ptr2 = (&ptr1[658]);  /*  reuse un-used right channel QMF_FILTER Synthesis buffer */
-    /* 1162 - 658 = 504
-     *            = NO_QMF_ALLPASS_CHANNELS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im)
-     */
-
-    ptr3 = (&ptr1[1162]);  /*  reuse un-used right channel QMF_FILTER Synthesis buffer */
-    /* 1426 - 1162 = 264
-     *            = SUBQMF_GROUPS*2 (Re&Im)*( 3 + 4 + 5) + ( 3 + 4 + 5)*2 (Re&Im)
-     */
-
-    ptr4 = (&ptr1[1426]);  /*  high freq generation buffers */
-
-    ptr5 = (&ptr1[1490]);  /*  high freq generation buffers */
-
-    ptr6 = (&ptr1[1618]);  /*  high freq generation buffers */
-
-    ptr7 = (&ptr1[1810]);  /*  high freq generation buffers */
-
-    /*  whole allocation requires 1871 words, sbrQmfBufferImag has 1920 words */
-
-
-    h_ps_dec->aPeakDecayFast =  ptr1;
-    ptr1 += NO_BINS;
-
-    h_ps_dec->aPrevNrg =  ptr1;
-    ptr1 += NO_BINS;
-
-    h_ps_dec->aPrevPeakDiff = ptr1;
-    ptr1 += NO_BINS;
-
-
-
-    status = ps_hybrid_filter_bank_allocation(&h_ps_dec->hHybrid,
-             NO_QMF_CHANNELS_IN_HYBRID,
-             pHybridResolution,
-             &ptr1);
-    h_ps_dec->mHybridRealLeft = ptr1;
-    ptr1 += SUBQMF_GROUPS;
-
-    h_ps_dec->mHybridImagLeft = ptr1;
-    ptr1 += SUBQMF_GROUPS;
-
-    h_ps_dec->mHybridRealRight = ptr1;
-    ptr1 += SUBQMF_GROUPS;
-
-    h_ps_dec->mHybridImagRight = ptr1;
-    ptr1 += SUBQMF_GROUPS;
-
-
-    h_ps_dec->delayBufIndex   = 0;
-
-
-
-    for (i = 0 ; i < NO_DELAY_CHANNELS ; i++)   /* 41  */
-    {
-        if (i < SHORT_DELAY_START)              /* 12  */
-        {
-            h_ps_dec->aNoSampleDelay[i] = LONG_DELAY;
-        }
-        else
-        {
-            h_ps_dec->aNoSampleDelay[i] = SHORT_DELAY;
-        }
-    }
-
-
-    h_ps_dec->aaRealDelayBufferQmf = (Int32 **)ptr6;
-    ptr6 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32);
-
-    h_ps_dec->aaImagDelayBufferQmf = (Int32 **)ptr7;
-    ptr7 += NO_QMF_ICC_CHANNELS * sizeof(Int32 *) / sizeof(Int32);
-
-    h_ps_dec->aaRealDelayBufferSubQmf = (Int32 **)ptr1;
-    ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32);
-
-    h_ps_dec->aaImagDelayBufferSubQmf = (Int32 **)ptr1;
-    ptr1 += SUBQMF_GROUPS * sizeof(Int32 *) / sizeof(Int32);
-
-    for (i = 0; i < NO_QMF_ICC_CHANNELS; i++)   /* 61 */
-    {
-        int delay;
-
-        if (i < NO_QMF_ALLPASS_CHANNELS)    /* 20 */
-        {
-            delay = 2;
-            h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr4;
-            ptr4 += delay;
-
-            h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr5;
-            ptr5 += delay;
-        }
-        else
-        {
-
-            if (i >= (NO_QMF_ALLPASS_CHANNELS + SHORT_DELAY_START))
-            {
-                delay = SHORT_DELAY;
-            }
-            else
-            {
-                delay = LONG_DELAY;
-            }
-
-            h_ps_dec->aaRealDelayBufferQmf[i] = (Int32 *)ptr1;
-            ptr1 += delay;
-
-            h_ps_dec->aaImagDelayBufferQmf[i] = (Int32 *)ptr1;
-            ptr1 += delay;
-        }
-    }
-
-    for (i = 0; i < SUBQMF_GROUPS; i++)
-    {
-        h_ps_dec->aaRealDelayBufferSubQmf[i] = (Int32 *)ptr1;
-        ptr1 += DELAY_ALLPASS;
-
-        h_ps_dec->aaImagDelayBufferSubQmf[i] = (Int32 *)ptr1;
-        ptr1 += DELAY_ALLPASS;
-
-    }
-
-    for (i = 0 ; i < NO_SERIAL_ALLPASS_LINKS ; i++) /*  NO_SERIAL_ALLPASS_LINKS == 3 */
-    {
-
-        h_ps_dec->aDelayRBufIndexSer[i] = 0;
-
-        h_ps_dec->aaaRealDelayRBufferSerQmf[i] = (Int32 **)ptr2;
-        ptr2 += aRevLinkDelaySer[i];
-
-        h_ps_dec->aaaImagDelayRBufferSerQmf[i] = (Int32 **)ptr2;
-        ptr2 += aRevLinkDelaySer[i];
-
-        h_ps_dec->aaaRealDelayRBufferSerSubQmf[i] = (Int32 **)ptr3;
-        ptr3 += aRevLinkDelaySer[i];
-
-        h_ps_dec->aaaImagDelayRBufferSerSubQmf[i] = (Int32 **)ptr3;
-        ptr3 += aRevLinkDelaySer[i];
-
-        for (j = 0; j < aRevLinkDelaySer[i]; j++)
-        {
-            h_ps_dec->aaaRealDelayRBufferSerQmf[i][j] = ptr2;
-            ptr2 += NO_QMF_ALLPASS_CHANNELS;    /* NO_QMF_ALLPASS_CHANNELS == 20 */
-
-            h_ps_dec->aaaImagDelayRBufferSerQmf[i][j] = ptr2;
-            ptr2 += NO_QMF_ALLPASS_CHANNELS;
-
-            h_ps_dec->aaaRealDelayRBufferSerSubQmf[i][j] = ptr3;
-            ptr3 += SUBQMF_GROUPS;
-
-            h_ps_dec->aaaImagDelayRBufferSerSubQmf[i][j] = ptr3;
-            ptr3 += SUBQMF_GROUPS;
-
-        }
-    }
-
-
-    for (i = 0; i < NO_IID_GROUPS; i++)         /*  NO_IID_GROUPS == 22   */
-    {
-        h_ps_dec->h11Prev[i] = Q30_fmt(1.0f);
-        h_ps_dec->h12Prev[i] = Q30_fmt(1.0f);
-    }
-
-
-
-    return status;
-} /*END CreatePsDec*/
-#endif
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h b/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h
deleted file mode 100644
index d5f152f..0000000
--- a/media/libstagefright/codecs/aacdec/ps_allocate_decoder.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_allocate_decoder.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_allocate_decoder()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_ALLOCATE_DECODER_H
-#define PS_ALLOCATE_DECODER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int32 ps_allocate_decoder(SBRDECODER_DATA *self,
-    UInt32  noSubSamples);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_ALLOCATE_DECODER_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_applied.cpp b/media/libstagefright/codecs/aacdec/ps_applied.cpp
deleted file mode 100644
index 77fd8a7..0000000
--- a/media/libstagefright/codecs/aacdec/ps_applied.cpp
+++ /dev/null
@@ -1,216 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_applied.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Applies Parametric Stereo Tool to a QMF-analized mono signal
-        providing a stereo image as output
-
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include    "aac_mem_funcs.h"
-#include    "ps_stereo_processing.h"
-#include    "ps_decorrelate.h"
-#include    "ps_hybrid_synthesis.h"
-#include    "ps_hybrid_analysis.h"
-#include    "ps_applied.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_applied(STRUCT_PS_DEC *h_ps_dec,
-                Int32 rIntBufferLeft[][64],
-                Int32 iIntBufferLeft[][64],
-                Int32 *rIntBufferRight,
-                Int32 *iIntBufferRight,
-                Int32 scratch_mem[],
-                Int32 band)
-
-{
-
-    /*
-     *  Get higher frequency resolution in the lower QMF subbands
-     *  creating sub-subbands
-     */
-    ps_hybrid_analysis(rIntBufferLeft,
-                       iIntBufferLeft,
-                       h_ps_dec->mHybridRealLeft,
-                       h_ps_dec->mHybridImagLeft,
-                       h_ps_dec->hHybrid,
-                       scratch_mem,
-                       band);
-
-    /*
-     *  By means of delaying and all-pass filtering, sub-subbands of
-     *  left ch. are decorrelate to creates right ch. sub-subbands
-     */
-
-    ps_decorrelate(h_ps_dec,
-                   *rIntBufferLeft,
-                   *iIntBufferLeft,
-                   rIntBufferRight,
-                   iIntBufferRight,
-                   scratch_mem);
-
-    /*
-     *  sub-subbands of left and right ch. are processed according to
-     *  stereo clues.
-     */
-
-    ps_stereo_processing(h_ps_dec,
-                         *rIntBufferLeft,
-                         *iIntBufferLeft,
-                         rIntBufferRight,
-                         iIntBufferRight);
-
-    /*
-     *  Reconstruct stereo signals
-     */
-
-    ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealLeft,
-                        (const Int32*)h_ps_dec->mHybridImagLeft,
-                        *rIntBufferLeft,
-                        *iIntBufferLeft,
-                        h_ps_dec->hHybrid);
-
-    ps_hybrid_synthesis((const Int32*)h_ps_dec->mHybridRealRight,
-                        (const Int32*)h_ps_dec->mHybridImagRight,
-                        rIntBufferRight,
-                        iIntBufferRight,
-                        h_ps_dec->hHybrid);
-
-}/* END ps_applied */
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_applied.h b/media/libstagefright/codecs/aacdec/ps_applied.h
deleted file mode 100644
index 231d9c3..0000000
--- a/media/libstagefright/codecs/aacdec/ps_applied.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_applied.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_applied()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_APPLIED_H
-#define PS_APPLIED_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_applied(STRUCT_PS_DEC *h_ps_dec,
-    Int32 rIntBufferLeft[][64],
-    Int32 iIntBufferLeft[][64],
-    Int32 *rIntBufferRight,
-    Int32 *iIntBufferRight,
-    Int32 scratch_mem[],
-    Int32 band);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_APPLIED_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp b/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp
deleted file mode 100644
index c7ed60b..0000000
--- a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.cpp
+++ /dev/null
@@ -1,304 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_bstr_decoding.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Decodes parametric stereo
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "ps_bstr_decoding.h"
-#include "ps_decode_bs_utils.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const Int32 aNoIidBins[3] = {NO_LOW_RES_IID_BINS, NO_IID_BINS, NO_HI_RES_BINS};
-const Int32 aNoIccBins[3] = {NO_LOW_RES_ICC_BINS, NO_ICC_BINS, NO_HI_RES_BINS};
-const Int32 aFixNoEnvDecode[4] = {0, 1, 2, 4};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_bstr_decoding(STRUCT_PS_DEC *ps_dec)
-{
-    UInt32 env;
-    Int32 noIidSteps;
-
-    if (!ps_dec->bPsDataAvail)
-    {
-        ps_dec->noEnv = 0;
-    }
-
-    noIidSteps = ps_dec->bFineIidQ ? NO_IID_STEPS_FINE : NO_IID_STEPS;
-
-    for (env = 0; env < ps_dec->noEnv; env++)
-    {
-        Int32 *aPrevIidIndex;
-        Int32 *aPrevIccIndex;
-        if (env == 0)
-        {
-            aPrevIidIndex = ps_dec->aIidPrevFrameIndex;
-            aPrevIccIndex = ps_dec->aIccPrevFrameIndex;
-        }
-        else
-        {
-            aPrevIidIndex = ps_dec->aaIidIndex[env-1];
-            aPrevIccIndex = ps_dec->aaIccIndex[env-1];
-        }
-
-        /*
-         * Differential Decoding of IID parameters over time/frequency
-         */
-        differential_Decoding(ps_dec->bEnableIid,
-                              ps_dec->aaIidIndex[env],
-                              aPrevIidIndex,
-                              ps_dec->abIidDtFlag[env],
-                              aNoIidBins[ps_dec->freqResIid],
-                              (ps_dec->freqResIid) ? 1 : 2,
-                              -noIidSteps,
-                              noIidSteps);
-
-        /*
-         * Differential Decoding of ICC parameters over time/frequency
-         */
-        differential_Decoding(ps_dec->bEnableIcc,
-                              ps_dec->aaIccIndex[env],
-                              aPrevIccIndex,
-                              ps_dec->abIccDtFlag[env],
-                              aNoIccBins[ps_dec->freqResIcc],
-                              (ps_dec->freqResIcc) ? 1 : 2,
-                              0,
-                              NO_ICC_STEPS - 1);
-
-
-    }   /* for (env=0; env<ps_dec->noEnv; env++) */
-
-    if (ps_dec->noEnv == 0)
-    {
-        ps_dec->noEnv = 1;
-
-        if (ps_dec->bEnableIid)
-        {   /*  NO_HI_RES_BINS == 34 */
-            pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv-1],
-                       ps_dec->aIidPrevFrameIndex,
-                       NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex));
-
-        }
-        else
-        {
-            pv_memset((void *)ps_dec->aaIidIndex[ps_dec->noEnv-1],
-                      0,
-                      NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex));
-        }
-        if (ps_dec->bEnableIcc)
-        {
-            pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv-1],
-                       ps_dec->aIccPrevFrameIndex,
-                       NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex));
-        }
-        else
-        {
-            pv_memset((void *)ps_dec->aaIccIndex[ps_dec->noEnv-1],
-                      0,
-                      NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex));
-        }
-    }
-
-    pv_memmove(ps_dec->aIidPrevFrameIndex,
-               ps_dec->aaIidIndex[ps_dec->noEnv-1],
-               NO_HI_RES_BINS*sizeof(*ps_dec->aIidPrevFrameIndex));
-
-    pv_memmove(ps_dec->aIccPrevFrameIndex,
-               ps_dec->aaIccIndex[ps_dec->noEnv-1],
-               NO_HI_RES_BINS*sizeof(*ps_dec->aIccPrevFrameIndex));
-
-    ps_dec->bPsDataAvail = 0;
-
-    if (ps_dec->bFrameClass == 0)
-    {
-        Int32 shift;
-
-        shift = ps_dec->noEnv >> 1;
-
-        ps_dec->aEnvStartStop[0] = 0;
-
-        for (env = 1; env < ps_dec->noEnv; env++)
-        {
-            ps_dec->aEnvStartStop[env] =
-                (env * ps_dec->noSubSamples) >> shift;
-        }
-
-        ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples;
-    }
-    else
-    {   /* if (ps_dec->bFrameClass != 0) */
-        ps_dec->aEnvStartStop[0] = 0;
-
-        if (ps_dec->aEnvStartStop[ps_dec->noEnv] < ps_dec->noSubSamples)
-        {
-            ps_dec->noEnv++;
-            ps_dec->aEnvStartStop[ps_dec->noEnv] = ps_dec->noSubSamples;
-
-            pv_memmove(ps_dec->aaIidIndex[ps_dec->noEnv],
-                       ps_dec->aaIidIndex[ps_dec->noEnv-1],
-                       NO_HI_RES_BINS*sizeof(**ps_dec->aaIidIndex));
-
-            pv_memmove(ps_dec->aaIccIndex[ps_dec->noEnv],
-                       ps_dec->aaIccIndex[ps_dec->noEnv-1],
-                       NO_HI_RES_BINS*sizeof(**ps_dec->aaIccIndex));
-        }
-
-        for (env = 1; env < ps_dec->noEnv; env++)
-        {
-            UInt32 thr;
-            thr = ps_dec->noSubSamples - ps_dec->noEnv + env;
-
-            if (ps_dec->aEnvStartStop[env] > thr)
-            {
-                ps_dec->aEnvStartStop[env] = thr;
-            }
-            else
-            {
-                thr = ps_dec->aEnvStartStop[env-1] + 1;
-
-                if (ps_dec->aEnvStartStop[env] < thr)
-                {
-                    ps_dec->aEnvStartStop[env] = thr;
-                }
-            }
-        }
-    }   /* if (ps_dec->bFrameClass == 0) ... else */
-
-    for (env = 0; env < ps_dec->noEnv; env++)
-    {
-        if (ps_dec->freqResIid == 2)
-        {
-            map34IndexTo20(ps_dec->aaIidIndex[env]);
-        }
-        if (ps_dec->freqResIcc == 2)
-        {
-            map34IndexTo20(ps_dec->aaIccIndex[env]);
-        }
-    }
-
-
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h b/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h
deleted file mode 100644
index 5212bf8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_bstr_decoding.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_bstr_decoding.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_bstr_decoding()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_BSTR_DECODING_H
-#define PS_BSTR_DECODING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern const Int32 aNoIidBins[3];
-extern const Int32 aNoIccBins[3];
-
-extern const Int32 aFixNoEnvDecode[4];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_bstr_decoding(STRUCT_PS_DEC *h_ps_dec);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_BSTR_DECODING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp b/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp
deleted file mode 100644
index 03a53df..0000000
--- a/media/libstagefright/codecs/aacdec/ps_channel_filtering.cpp
+++ /dev/null
@@ -1,281 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_analysis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Does Hybrid analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "s_hybrid.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_fft_rx8.h"
-#include    "ps_channel_filtering.h"
-#include    "pv_audio_type_defs.h"
-#include    "fxp_mul32.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT     29
-#define Q29_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(a)   (Int32)(-a*((Int32)1<<31)  + (a>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void two_ch_filtering(const Int32 *pQmf_r,
-                      const Int32 *pQmf_i,
-                      Int32 *mHybrid_r,
-                      Int32 *mHybrid_i)
-{
-
-    Int32 cum0;
-    Int32 cum1;
-    Int32 cum2;
-    Int32 tmp1;
-    Int32 tmp2;
-
-    tmp1 = pQmf_r[ 1] + pQmf_r[11];
-    tmp2 = pQmf_i[ 1] + pQmf_i[11];
-    cum1 =   fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp1);
-    cum2 =   fxp_mul32_Q31(Qfmt31(0.03798975052098f), tmp2);
-    tmp1 = pQmf_r[ 3] + pQmf_r[ 9];
-    tmp2 = pQmf_i[ 3] + pQmf_i[ 9];
-    cum1 =   fxp_msu32_Q31(cum1, Qfmt31(0.14586278335076f), tmp1);
-    cum2 =   fxp_msu32_Q31(cum2, Qfmt31(0.14586278335076f), tmp2);
-    tmp1 = pQmf_r[ 5] + pQmf_r[ 7];
-    tmp2 = pQmf_i[ 5] + pQmf_i[ 7];
-    cum1 =   fxp_mac32_Q31(cum1, Qfmt31(0.61193261090336f), tmp1);
-    cum2 =   fxp_mac32_Q31(cum2, Qfmt31(0.61193261090336f), tmp2);
-
-    cum0 = pQmf_r[HYBRID_FILTER_DELAY] >> 1;  /* HYBRID_FILTER_DELAY == 6 */
-
-    mHybrid_r[0] = (cum0 + cum1);
-    mHybrid_r[1] = (cum0 - cum1);
-
-    cum0 = pQmf_i[HYBRID_FILTER_DELAY] >> 1;  /* HYBRID_FILTER_DELAY == 6 */
-
-    mHybrid_i[0] = (cum0 + cum2);
-    mHybrid_i[1] = (cum0 - cum2);
-
-}
-
-
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void eight_ch_filtering(const Int32 *pQmfReal,
-                        const Int32 *pQmfImag,
-                        Int32 *mHybridReal,
-                        Int32 *mHybridImag,
-                        Int32 scratch_mem[])
-
-{
-
-    Int32 real;
-    Int32 imag;
-    Int32 tmp1;
-    Int32 tmp2;
-
-    real  = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfReal[ 4]);
-
-    real  = fxp_mac32_Q31(real, Qfmt31(0.01055120626280f), pQmfReal[12]);
-    imag  = fxp_mul32_Q29(Q29_fmt(-0.06989827306334f), pQmfImag[ 4]);
-
-    imag  = fxp_mac32_Q31(imag, Qfmt31(0.01055120626280f), pQmfImag[12]);
-
-    mHybridReal[2] = (imag - real);
-    mHybridImag[2] = -(imag + real);
-
-    real  = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfReal[ 3]);
-
-    real  = fxp_mac32_Q31(real, Qfmt31(0.04540841899650f), pQmfReal[11]);
-    imag  = fxp_mul32_Q29(Q29_fmt(-0.07266113929591f), pQmfImag[ 3]);
-
-    imag  = fxp_mac32_Q31(imag, Qfmt31(0.04540841899650f), pQmfImag[11]);
-
-    tmp1           =  fxp_mul32_Q29(Q29_fmt(-0.38268343236509f), real);
-    mHybridReal[3] =  fxp_mac32_Q29(Q29_fmt(0.92387953251129f), imag, tmp1);
-    tmp2           =  fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real);
-    mHybridImag[3] =  fxp_mac32_Q29(Q29_fmt(-0.38268343236509f), imag, tmp2);
-
-
-    mHybridImag[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfReal[ 2] - pQmfReal[10]));
-    mHybridReal[4] = fxp_mul32_Q31(Qfmt31(0.09093731860946f), (pQmfImag[10] - pQmfImag[ 2]));
-
-
-    real  = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfReal[ 1]);
-
-    real  = fxp_mac32_Q31(real, Qfmt31(0.14532227859182f), pQmfReal[ 9]);
-    imag  = fxp_mul32_Q29(Q29_fmt(-0.02270420949825f), pQmfImag[ 1]);
-
-    imag  = fxp_mac32_Q31(imag, Qfmt31(0.14532227859182f), pQmfImag[ 9]);
-
-    tmp1           =  fxp_mul32_Q29(Q29_fmt(0.92387953251129f), imag);
-
-    mHybridReal[5] =  fxp_mac32_Q31(tmp1, Qfmt31(0.76536686473018f), real);
-    tmp2           =  fxp_mul32_Q29(Q29_fmt(-0.92387953251129f), real);
-
-    mHybridImag[5] =  fxp_mac32_Q31(tmp2, Qfmt31(0.76536686473018f), imag);
-
-    real  = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfReal[ 0]);
-
-    real  = fxp_mac32_Q31(real, Qfmt31(0.13979654612668f), pQmfReal[ 8]);
-    imag  = fxp_mul32_Q29(Q29_fmt(-0.00527560313140f), pQmfImag[ 0]);
-
-    imag  = fxp_mac32_Q31(imag, Qfmt31(0.13979654612668f), pQmfImag[ 8]);
-
-    mHybridReal[6] = (imag + real);
-    mHybridImag[6] = (imag - real);
-
-
-    tmp1            =  fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfReal[ 7]);
-    mHybridReal[7]  =  fxp_mac32_Q31(tmp1, Qfmt31(0.09026515280366f), pQmfImag[ 7]);
-
-    tmp2            =  fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfReal[ 7]);
-
-    mHybridImag[7]  =  fxp_mac32_Q31(tmp2, Qfmt31(0.21791935610828f), pQmfImag[ 7]);
-
-    mHybridReal[0] = pQmfReal[HYBRID_FILTER_DELAY] >> 3;
-    mHybridImag[0] = pQmfImag[HYBRID_FILTER_DELAY] >> 3;
-
-    tmp1           =  fxp_mul32_Q29(Q29_fmt(-0.04513257640183f), pQmfImag[ 5]);
-
-    mHybridReal[1] =  fxp_mac32_Q31(tmp1, Qfmt31(0.21791935610828f), pQmfReal[ 5]);
-
-
-    tmp2            =  fxp_mul32_Q31(Qfmt31(0.21791935610828f), pQmfImag[ 5]);
-    mHybridImag[1]  =  fxp_mac32_Q31(tmp2, Qfmt31(0.09026515280366f), pQmfReal[ 5]);
-
-    /*
-     *  8*ifft
-     */
-
-    ps_fft_rx8(mHybridReal, mHybridImag, scratch_mem);
-
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_channel_filtering.h b/media/libstagefright/codecs/aacdec/ps_channel_filtering.h
deleted file mode 100644
index 19cda79..0000000
--- a/media/libstagefright/codecs/aacdec/ps_channel_filtering.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_channel_filtering.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions two_ch_filtering()
- and  eight_ch_filtering()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_CHANNEL_FILTERING_H
-#define PS_CHANNEL_FILTERING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void two_ch_filtering(const Int32 *pQmf_r,
-    const Int32 *pQmf_i,
-    Int32 *mHybrid_r,
-    Int32 *mHybrid_i);
-
-
-    void eight_ch_filtering(const Int32 *pQmfReal,
-                            const Int32 *pQmfImag,
-                            Int32 *mHybridReal,
-                            Int32 *mHybridImag,
-                            Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_CHANNEL_FILTERING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_constants.h b/media/libstagefright/codecs/aacdec/ps_constants.h
deleted file mode 100644
index d5b2ad4..0000000
--- a/media/libstagefright/codecs/aacdec/ps_constants.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/****************************************************************************
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-*******************************************************************************/
-/*
-*/
-#ifndef PS_CONSTANTS_H
-#define PS_CONSTANTS_H
-
-
-#define NO_SUB_QMF_CHANNELS         12
-#define NO_QMF_CHANNELS_IN_HYBRID   3
-#define NO_QMF_CHANNELS             64
-#define NO_ALLPASS_CHANNELS         23
-#define NO_DELAY_CHANNELS           (NO_QMF_CHANNELS-NO_ALLPASS_CHANNELS)
-#define DELAY_ALLPASS               2
-#define SHORT_DELAY_START           12
-#define SHORT_DELAY                 1
-#define LONG_DELAY                  14
-#define NO_QMF_ALLPASS_CHANNELS    (NO_ALLPASS_CHANNELS-NO_QMF_CHANNELS_IN_HYBRID)
-#define NO_QMF_ICC_CHANNELS        (NO_QMF_ALLPASS_CHANNELS+NO_DELAY_CHANNELS)
-#define HYBRIDGROUPS                8
-#define DECAY_CUTOFF                3
-#define NO_SERIAL_ALLPASS_LINKS     3
-#define MAX_NO_PS_ENV               5
-#define NEGATE_IPD_MASK                 ( 0x00001000 )
-#define NO_BINS                         ( 20 )
-#define NO_HI_RES_BINS                  ( 34 )
-#define NO_LOW_RES_BINS                 ( NO_IID_BINS / 2 )
-#define NO_IID_BINS                     ( NO_BINS )
-#define NO_ICC_BINS                     ( NO_BINS )
-#define NO_LOW_RES_IID_BINS             ( NO_LOW_RES_BINS )
-#define NO_LOW_RES_ICC_BINS             ( NO_LOW_RES_BINS )
-#define SUBQMF_GROUPS                   ( 10 )
-#define QMF_GROUPS                      ( 12 )
-#define NO_IID_GROUPS                   ( SUBQMF_GROUPS + QMF_GROUPS )
-#define NO_IID_STEPS                    ( 7 )
-#define NO_IID_STEPS_FINE               ( 15 )
-#define NO_ICC_STEPS                    ( 8 )
-#define NO_IID_LEVELS                   ( 2 * NO_IID_STEPS + 1 )
-#define NO_IID_LEVELS_FINE              ( 2 * NO_IID_STEPS_FINE + 1 )
-#define NO_ICC_LEVELS                   ( NO_ICC_STEPS )
-
-
-
-#endif      /*  PS_CONSTANTS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp b/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp
deleted file mode 100644
index 241da34..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.cpp
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_decode_bs_utils.c
-
-  Functions:
-        GetNrBitsAvailable
-        differential_Decoding
-        map34IndexTo20
-        limitMinMax
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Decode bitstream parametric stereo's utilities
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "aac_mem_funcs.h"
-#include "s_ps_dec.h"
-#include "ps_decode_bs_utils.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf)
-{
-
-    return (hBitBuf->bufferLen - hBitBuf->nrBitsRead);
-}
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-;
-;   Differential Decoding of parameters over time/frequency
-----------------------------------------------------------------------------*/
-
-void differential_Decoding(Int32 enable,
-                           Int32 *aIndex,
-                           Int32 *aPrevFrameIndex,
-                           Int32 DtDf,
-                           Int32 nrElements,
-                           Int32 stride,
-                           Int32 minIdx,
-                           Int32 maxIdx)
-{
-    Int32 i;
-    Int32 *ptr_aIndex;
-
-    if (enable == 1)
-    {
-        ptr_aIndex = aIndex;
-
-        if (DtDf == 0)
-        {
-            *(ptr_aIndex) = limitMinMax(*ptr_aIndex, minIdx, maxIdx);
-            ptr_aIndex++;
-
-            for (i = 1; i < nrElements; i++)
-            {
-                *(ptr_aIndex) = limitMinMax(aIndex[i-1] + *ptr_aIndex, minIdx, maxIdx);
-                ptr_aIndex++;
-            }
-        }
-        else
-        {
-            if (stride == 1)
-            {
-                for (i = 0; i < nrElements; i++)
-                {
-                    *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[i] + *ptr_aIndex, minIdx, maxIdx);
-                    ptr_aIndex++;
-                }
-            }
-            else
-            {
-                for (i = 0; i < nrElements; i++)
-                {
-                    *(ptr_aIndex) = limitMinMax(aPrevFrameIndex[(i<<1)] + *ptr_aIndex, minIdx, maxIdx);
-                    ptr_aIndex++;
-                }
-            }
-        }
-    }
-    else
-    {
-        pv_memset((void *)aIndex, 0, nrElements*sizeof(*aIndex));
-    }
-    if (stride == 2)
-    {
-        for (i = (nrElements << 1) - 1; i > 0; i--)
-        {
-            aIndex[i] = aIndex[(i>>1)];
-        }
-    }
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-        map34IndexTo20
-----------------------------------------------------------------------------*/
-
-void map34IndexTo20(Int32 *aIndex)
-{
-
-    aIndex[ 0] = ((aIndex[0] << 1) +  aIndex[1]) / 3;
-    aIndex[ 1] = (aIndex[1] + (aIndex[2] << 1)) / 3;
-    aIndex[ 2] = ((aIndex[3] << 1) +  aIndex[4]) / 3;
-    aIndex[ 3] = (aIndex[4] + (aIndex[5] << 1)) / 3;
-    aIndex[ 4] = (aIndex[ 6] +  aIndex[7]) >> 1;
-    aIndex[ 5] = (aIndex[ 8] +  aIndex[9]) >> 1;
-    aIndex[ 6] =   aIndex[10];
-    aIndex[ 7] =   aIndex[11];
-    aIndex[ 8] = (aIndex[12] +  aIndex[13]) >> 1;
-    aIndex[ 9] = (aIndex[14] +  aIndex[15]) >> 1;
-    aIndex[10] =   aIndex[16];
-    aIndex[11] =   aIndex[17];
-    aIndex[12] =   aIndex[18];
-    aIndex[13] =   aIndex[19];
-    aIndex[14] = (aIndex[20] +  aIndex[21]) >> 1;
-    aIndex[15] = (aIndex[22] +  aIndex[23]) >> 1;
-    aIndex[16] = (aIndex[24] +  aIndex[25]) >> 1;
-    aIndex[17] = (aIndex[26] +  aIndex[27]) >> 1;
-    aIndex[18] = (aIndex[28] +  aIndex[29] + aIndex[30] + aIndex[31]) >> 2;
-    aIndex[19] = (aIndex[32] +  aIndex[33]) >> 1;
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-        limitMinMax
-----------------------------------------------------------------------------*/
-
-
-Int32 limitMinMax(Int32 i,
-                  Int32 min,
-                  Int32 max)
-{
-    if (i < max)
-    {
-        if (i > min)
-        {
-            return i;
-        }
-        else
-        {
-            return min;
-        }
-    }
-    else
-    {
-        return max;
-    }
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h b/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h
deleted file mode 100644
index a672d94..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decode_bs_utils.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_decode_bs_utils.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions differential_Decoding(), limitMinMax(),
-                           GetNrBitsAvailable(), map34IndexTo20()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_DECODE_BS_UTILS_H
-#define PS_DECODE_BS_UTILS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-#include "s_bit_buffer.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void differential_Decoding(Int32 enable,
-    Int32 *aIndex,
-    Int32 *aPrevFrameIndex,
-    Int32 DtDf,
-    Int32 nrElements,
-    Int32 stride,
-    Int32 minIdx,
-    Int32 maxIdx);
-
-    Int32 limitMinMax(Int32 i,
-                      Int32 min,
-                      Int32 max);
-
-    Int32 GetNrBitsAvailable(HANDLE_BIT_BUFFER hBitBuf);
-
-    void map34IndexTo20(Int32 *aIndex);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_DECODE_BS_UTILS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp b/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp
deleted file mode 100644
index 6776d6e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decorrelate.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_decorrelate.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Decorrelation
-  Decorrelation is achieved by means of all-pass filtering and delaying
-  Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
-  d_k(n). k index for frequency, n time index
-
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-  Delay is introduced to compensate QMF bands not passed through Hybrid
-  Analysis
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include    "pv_audio_type_defs.h"
-#include    "ps_decorrelate.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_pwr_transient_detection.h"
-#include    "ps_all_pass_fract_delay_filter.h"
-#include    "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec,
-                    Int32 *rIntBufferLeft,
-                    Int32 *iIntBufferLeft,
-                    Int32 *rIntBufferRight,
-                    Int32 *iIntBufferRight,
-                    Int32 scratch_mem[])
-{
-    Int32 sb;
-    Int32 maxsb;
-    Int32 gr;
-    Int32 sb_delay;
-    Int32 bin;
-
-
-
-
-    Int32 *aLeftReal;
-    Int32 *aLeftImag;
-    Int32 *aRightReal;
-    Int32 *aRightImag;
-
-    Int32 *aTransRatio = scratch_mem;   /* use  NO_BINS == 20 */
-
-
-    Int32 ***pppRealDelayRBufferSer;
-    Int32 ***pppImagDelayRBufferSer;
-
-    Int32 **ppRealDelayBuffer;
-    Int32 **ppImagDelayBuffer;
-
-    const Int32(*ppFractDelayPhaseFactorSer)[3];
-    /*
-     *  Power transient estimation and detection
-     */
-
-
-    ps_pwr_transient_detection(h_ps_dec,
-                               rIntBufferLeft,
-                               iIntBufferLeft,
-                               aTransRatio);
-
-
-    aLeftReal = h_ps_dec->mHybridRealLeft;
-    aLeftImag = h_ps_dec->mHybridImagLeft;
-    aRightReal = h_ps_dec->mHybridRealRight;
-    aRightImag = h_ps_dec->mHybridImagRight;
-
-    pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerSubQmf;
-    pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerSubQmf;
-
-    ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferSubQmf;
-    ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferSubQmf;
-
-
-
-    ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerSubQmf;
-
-
-    /*
-     *   NO_IID_GROUPS (SUBQMF_GROUPS (12) + QMF_GROUPS (10)) == 22
-     */
-
-    for (gr = 0; gr < SUBQMF_GROUPS; gr++)      /*  0 to 9 */
-    {
-        Int32 rIn;
-        Int32 iIn;
-        Int32 *pt_rTmp;
-        Int32 *pt_iTmp;
-        Int32 rTmp;
-        Int32 cmplx;
-        Int32 tmp1, tmp2;
-
-        /* sb = subQMF/QMF subband */
-
-        sb = groupBorders[gr];
-
-        /*
-         *  For lower subbands
-         *  Apply all-pass filtering
-         *
-         */
-        pt_rTmp = &ppRealDelayBuffer[sb][h_ps_dec->delayBufIndex];
-        pt_iTmp = &ppImagDelayBuffer[sb][h_ps_dec->delayBufIndex];
-
-        tmp1 = aLeftReal[sb];
-        tmp2 = aLeftImag[sb];
-        rIn = *pt_rTmp >> 1;
-        iIn = *pt_iTmp >> 1;
-
-
-        *pt_rTmp = tmp1;
-        *pt_iTmp = tmp2;
-
-        /*
-         *  Fractional delay vector
-         *
-         *  phi_fract(k) = exp(-j*pi*q_phi*f_center(k))       0<= k <= SUBQMF_GROUPS
-         *
-         *  q_phi = 0.39
-         *  f_center(k) frequency vector
-         */
-
-        cmplx =  aFractDelayPhaseFactorSubQmf[sb];
-
-        aRightReal[sb]  = cmplx_mul32_by_16(rIn, -iIn, cmplx);
-        aRightImag[sb]  = cmplx_mul32_by_16(iIn,  rIn, cmplx);
-
-        ps_all_pass_fract_delay_filter_type_I(h_ps_dec->aDelayRBufIndexSer,
-                                              sb,
-                                              ppFractDelayPhaseFactorSer[sb],
-                                              pppRealDelayRBufferSer,
-                                              pppImagDelayRBufferSer,
-                                              &aRightReal[sb],
-                                              &aRightImag[sb]);
-
-        bin = bins2groupMap[gr];
-        rTmp = aTransRatio[bin];
-
-        if (rTmp != 0x7FFFFFFF)
-        {
-            aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1;
-            aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1;
-        }
-
-
-    } /* gr */
-
-    aLeftReal = rIntBufferLeft;
-    aLeftImag = iIntBufferLeft;
-    aRightReal = rIntBufferRight;
-    aRightImag = iIntBufferRight;
-
-    pppRealDelayRBufferSer = h_ps_dec->aaaRealDelayRBufferSerQmf;
-    pppImagDelayRBufferSer = h_ps_dec->aaaImagDelayRBufferSerQmf;
-
-    ppRealDelayBuffer = h_ps_dec->aaRealDelayBufferQmf;
-    ppImagDelayBuffer = h_ps_dec->aaImagDelayBufferQmf;
-
-
-
-    ppFractDelayPhaseFactorSer = aaFractDelayPhaseFactorSerQmf;
-
-
-    for (gr = SUBQMF_GROUPS; gr < NO_BINS; gr++)     /* 10 to 20 */
-    {
-
-        maxsb = min(h_ps_dec->usb, groupBorders[gr+1]);
-
-        /* sb = subQMF/QMF subband */
-
-        for (sb = groupBorders[gr]; sb < maxsb; sb++)
-        {
-
-            Int32 rIn, iIn;
-            Int32 *pt_rTmp, *pt_iTmp;
-            Int32 cmplx;
-            Int32 tmp1, tmp2;
-            Int32 rTmp;
-
-
-            sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID;  /* NO_QMF_CHANNELS_IN_HYBRID == 3 */
-
-            /*
-             *  For lower subbands
-             *  Apply all-pass filtering
-             *
-             */
-            pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->delayBufIndex];
-            pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->delayBufIndex];
-
-            rIn = *pt_rTmp >> 1;
-            iIn = *pt_iTmp >> 1;
-
-            tmp1 = aLeftReal[sb];
-            tmp2 = aLeftImag[sb];
-            *pt_rTmp = tmp1;
-            *pt_iTmp = tmp2;
-
-            /*
-             *  Fractional delay vector
-             *
-             *  phi_fract(k) = exp(-j*pi*q_phi*f_center(k))       0<= k <= SUBQMF_GROUPS
-             *
-             *  q_phi = 0.39
-             *  f_center(k) frequency vector
-             */
-
-            cmplx =  aFractDelayPhaseFactor[sb_delay];
-            aRightReal[sb] = cmplx_mul32_by_16(rIn, -iIn, cmplx);
-            aRightImag[sb] = cmplx_mul32_by_16(iIn,  rIn, cmplx);
-
-            ps_all_pass_fract_delay_filter_type_II(h_ps_dec->aDelayRBufIndexSer,
-                                                   sb_delay,
-                                                   ppFractDelayPhaseFactorSer[sb_delay],
-                                                   pppRealDelayRBufferSer,
-                                                   pppImagDelayRBufferSer,
-                                                   &aRightReal[sb],
-                                                   &aRightImag[sb],
-                                                   sb);
-
-            rTmp = aTransRatio[gr-2];
-            if (rTmp != 0x7FFFFFFF)
-            {
-                aRightReal[sb] = fxp_mul32_Q31(rTmp, aRightReal[sb]) << 1;
-                aRightImag[sb] = fxp_mul32_Q31(rTmp, aRightImag[sb]) << 1;
-            }
-
-
-        } /* sb */
-
-    }
-
-
-    maxsb = min(h_ps_dec->usb, 35);  /*  35 == groupBorders[NO_BINS + 1] */
-
-    /* sb = subQMF/QMF subband */
-    {
-        Int32 factor = aTransRatio[NO_BINS-2];
-
-        for (sb = 23; sb < maxsb; sb++)    /*  23 == groupBorders[NO_BINS] */
-        {
-
-            Int32  tmp, tmp2;
-            Int32 *pt_rTmp, *pt_iTmp;
-
-            sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID;  /*  == 3 */
-
-            /*
-             *  For the Upper Bands apply delay only
-             *                          -D(k)
-             *  Apply Delay   H_k(z) = z         , D(k) == 1 or 14
-             *
-             */
-            Int32 k = sb - NO_ALLPASS_CHANNELS;  /* == 23 */
-
-
-            pt_rTmp = &ppRealDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]];
-            pt_iTmp = &ppImagDelayBuffer[sb_delay][h_ps_dec->aDelayBufIndex[ k]];
-
-            if (++h_ps_dec->aDelayBufIndex[ k] >= LONG_DELAY)     /* == 14 */
-            {
-                h_ps_dec->aDelayBufIndex[ k] = 0;
-            }
-
-
-            tmp  = *pt_rTmp;
-            tmp2 = *pt_iTmp;
-
-            if (aTransRatio[NO_BINS-2] < 0x7FFFFFFF)
-            {
-                aRightReal[sb] = fxp_mul32_Q31(factor, tmp) << 1;
-                aRightImag[sb] = fxp_mul32_Q31(factor, tmp2) << 1;
-            }
-            else
-            {
-                aRightReal[sb] = tmp;
-                aRightImag[sb] = tmp2;
-            }
-
-
-            tmp  = aLeftReal[sb];
-            tmp2 = aLeftImag[sb];
-            *pt_rTmp = tmp;
-            *pt_iTmp = tmp2;
-
-
-        } /* sb */
-    }
-
-
-    maxsb = min(h_ps_dec->usb, 64);     /*  64 == groupBorders[NO_BINS+2] */
-
-    /* sb = subQMF/QMF subband */
-
-    {
-
-        for (sb = 35; sb < maxsb; sb++)    /*  35 == groupBorders[NO_BINS+1] */
-        {
-
-            Int32 *pt_rTmp, *pt_iTmp;
-
-            sb_delay = sb - NO_QMF_CHANNELS_IN_HYBRID;  /*  == 3 */
-
-            /*
-             *  For the Upper Bands apply delay only
-             *                          -D(k)
-             *  Apply Delay   H_k(z) = z         , D(k) == 1 or 14
-             *
-             */
-
-            pt_rTmp = &ppRealDelayBuffer[sb_delay][0];
-            pt_iTmp = &ppImagDelayBuffer[sb_delay][0];
-
-            aRightReal[sb] = *pt_rTmp;
-            aRightImag[sb] = *pt_iTmp;
-
-
-            if (aTransRatio[NO_BINS-1] < 0x7FFFFFFF)
-            {
-                aRightReal[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightReal[sb]) << 1;
-                aRightImag[sb] = fxp_mul32_Q31(aTransRatio[NO_BINS-1], aRightImag[sb]) << 1;
-            }
-
-            *pt_rTmp = aLeftReal[sb];
-            *pt_iTmp = aLeftImag[sb];
-
-
-        } /* sb */
-    }
-
-
-    if (++h_ps_dec->delayBufIndex >= DELAY_ALLPASS)
-    {
-        h_ps_dec->delayBufIndex = 0;
-    }
-
-    if (++h_ps_dec->aDelayRBufIndexSer[0] >= 3)
-    {
-        h_ps_dec->aDelayRBufIndexSer[0] = 0;
-    }
-    if (++h_ps_dec->aDelayRBufIndexSer[1] >= 4)
-    {
-        h_ps_dec->aDelayRBufIndexSer[1] = 0;
-    }
-    if (++h_ps_dec->aDelayRBufIndexSer[2] >= 5)
-    {
-        h_ps_dec->aDelayRBufIndexSer[2] = 0;
-    }
-
-
-} /* END deCorrelate */
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_decorrelate.h b/media/libstagefright/codecs/aacdec/ps_decorrelate.h
deleted file mode 100644
index c2a025a..0000000
--- a/media/libstagefright/codecs/aacdec/ps_decorrelate.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_decorrelate.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_decorrelate()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_DECORRELATE_H
-#define PS_DECORRELATE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_decorrelate(STRUCT_PS_DEC *h_ps_dec,
-    Int32 *rIntBufferLeft,
-    Int32 *iIntBufferLeft,
-    Int32 *rIntBufferRight,
-    Int32 *iIntBufferRight,
-    Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_DECORRELATE_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp b/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp
deleted file mode 100644
index 7669be3..0000000
--- a/media/libstagefright/codecs/aacdec/ps_fft_rx8.cpp
+++ /dev/null
@@ -1,318 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: fft_rx8.c
- Funtions: ps_fft_rx8
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Real     Vector of Real components size 8
-
-    Imag     Vector of Imag components size 8
-             type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-     scratch_mem size 32
-
- Outputs:
-    In-place calculation of a 8-point FFT (radix-8)
-
- Pointers and Buffers Modified:
-    calculation are done in-place and returned in Data
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    8-point DFT, radix 8 with Decimation in Frequency
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should provide a fixed point FFT for any input array
-    of size power of 8.
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] Advance Digital Signal Processing, J. Proakis, C. Rader, F. Ling,
-        C. Nikias, Macmillan Pub. Co.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-   MODIFY( x[] )
-   RETURN( exponent )
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#ifdef PARAMETRICSTEREO
-
-
-#include "pv_audio_type_defs.h"
-#include "ps_fft_rx8.h"
-
-#include    "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT     29
-#define Q29_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[])
-
-/* scratch_mem size 32 */
-{
-
-    Int     i;
-    Int32   *Q = &scratch_mem[0];
-    Int32   *Z = &scratch_mem[16];
-    Int32   temp1;
-    Int32   temp2;
-    Int32   temp3;
-    Int32   temp4;
-    Int32   aux_r[2];
-    Int32   aux_i[2];
-    Int32   *pt_r1 = &Re[0];
-    Int32   *pt_r2 = &Re[4];
-    Int32   *pt_i1 = &Im[0];
-    Int32   *pt_i2 = &Im[4];
-
-    Int32   *pt_Q = Q;
-    Int32   *pt_Z = Z;
-
-
-    temp1 = *(pt_r1++); /*  Real */
-    temp2 = *(pt_r2++); /*  Real */
-    temp3 = *(pt_i1++); /*  Imag */
-    temp4 = *(pt_i2++); /*  Imag */
-    /*
-     *  Vector Q stores data as Real, Imag, Real, Imag,....
-     */
-
-    *(pt_Q++) = temp1 + temp2;  /* Q(0) =  v(0) + v(4) */
-    *(pt_Q++) = temp3 + temp4;
-    *(pt_Q++) = temp1 - temp2;  /* Q(1) =  v(0) - v(4) */
-    *(pt_Q++) = temp3 - temp4;
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_i1++);
-    temp4 = *(pt_i2++);
-
-    *(pt_Q++) = temp1 + temp2;  /*    Q(2) =  v(1) + v(5) */
-    *(pt_Q++) = temp3 + temp4;
-    aux_r[0]  = temp1 - temp2;  /* aux[0]  =  v(1) - v(5) */
-    aux_i[0]  = temp3 - temp4;
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_i1++);
-    temp4 = *(pt_i2++);
-
-    *(pt_Q++) = temp1 + temp2;  /*  Q(3) =  v(2) + v(6) */
-    *(pt_Q++) = temp3 + temp4;
-    *(pt_Q++) = temp4 - temp3;  /*  Q(4) = (v(2) - v(6))*j */
-    *(pt_Q++) = temp1 - temp2;
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_i1++);
-    temp4 = *(pt_i2++);
-
-
-    *(pt_Q++) = temp1 + temp2;  /*  Q(5)   = v(3) + v(7) */
-    *(pt_Q++) = temp3 + temp4;
-    aux_r[1]  = temp1 - temp2;  /*  aux[1] = v(3) - v(7) */
-    aux_i[1]  = temp3 - temp4;
-    /*  Q(6) =  (aux[0] - aux[1])/sqrt(2); */
-    *(pt_Q++) = fxp_mul32_Q29((aux_r[0] - aux_r[1]), Q29_fmt(0.70710678118655f));
-    *(pt_Q++) = fxp_mul32_Q29((aux_i[0] - aux_i[1]), Q29_fmt(0.70710678118655f));
-
-    /*  Q(7) =  (aux[0] + aux[1])*j/sqrt(2); */
-    *(pt_Q++) =  fxp_mul32_Q29((aux_i[0] + aux_i[1]), Q29_fmt(-0.70710678118655f));
-    *(pt_Q) =  fxp_mul32_Q29((aux_r[0] + aux_r[1]), Q29_fmt(0.70710678118655f));
-
-    pt_r1 = &Q[0];        /* reset pointer */
-    pt_r2 = &Q[6];        /* reset pointer */
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_r1++);
-    temp4 = *(pt_r2++);
-
-    /*
-     *  Vector Z stores data as Real, Imag, Real, Imag,....
-     */
-
-    *(pt_Z++) = temp1 + temp2;  /* Q(0) + Q(3) */
-    *(pt_Z++) = temp3 + temp4;
-    aux_r[0]  = temp1 - temp2;
-    aux_i[0]  = temp3 - temp4;
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_r1++);
-    temp4 = *(pt_r2++);
-
-    *(pt_Z++) = temp1 + temp2;  /* Q(1) + Q(4) */
-    *(pt_Z++) = temp3 + temp4;
-    *(pt_Z++) = aux_r[0];       /* Q(0) - Q(3) */
-    *(pt_Z++) = aux_i[0];
-    *(pt_Z++) = temp1 - temp2;  /* Q(1) - Q(4) */
-    *(pt_Z++) = temp3 - temp4;
-
-    temp1 = *(pt_r1++);
-    temp2 = *(pt_r2++);
-    temp3 = *(pt_r1);
-    temp4 = *(pt_r2++);
-
-    *(pt_Z++) = temp1 + temp2;  /* Q(2) + Q(5) */
-    *(pt_Z++) = temp3 + temp4;
-    aux_r[0]  = temp1 - temp2;
-    aux_i[0]  = temp3 - temp4;
-
-    temp1 = *(pt_r2++);
-    temp3 = *(pt_r2++);
-    temp2 = *(pt_r2++);
-    temp4 = *(pt_r2);
-
-    *(pt_Z++) = temp1 + temp2;  /* Q(6) + Q(7) */
-    *(pt_Z++) = temp3 + temp4;
-
-    *(pt_Z++) = -aux_i[0];      /* (Q(2) - Q(5))*j */
-    *(pt_Z++) =  aux_r[0];
-
-    *(pt_Z++) =  temp2 - temp1;  /* -Q(6) + Q(7) */
-    *(pt_Z) =  temp4 - temp3;
-
-    pt_Z = &Z[0];        /* reset pointer */
-    pt_Q = &Z[8];        /* reset pointer */
-
-    pt_r1 = &Re[0];
-    pt_r2 = &Re[4];
-    pt_i1 = &Im[0];
-    pt_i2 = &Im[4];
-
-
-    for (i = 4; i != 0; i--)
-    {
-        temp1 = *(pt_Z++);
-        temp2 = *(pt_Q++);
-        temp3 = *(pt_Z++);
-        temp4 = *(pt_Q++);
-
-        *(pt_r1++) = temp1 + temp2;  /* Z(n) + Z(n+4) */
-        *(pt_i1++) = temp3 + temp4;
-        *(pt_r2++) = temp1 - temp2;  /* Z(n) - Z(n+4) */
-        *(pt_i2++) = temp3 - temp4;
-    }
-
-}
-
-#endif  /* PARAMETRICSTEREO */
-
-
-#endif  /* AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/ps_fft_rx8.h b/media/libstagefright/codecs/aacdec/ps_fft_rx8.h
deleted file mode 100644
index 6c3482e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_fft_rx8.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_fft_rx8.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_fft_rx8()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_FFT_RX8_H
-#define PS_FFT_RX8_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_fft_rx8(Int32 Re[], Int32 Im[], Int32 scratch_mem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_FFT_RX4_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp
deleted file mode 100644
index 933b07e..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_analysis.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Does Hybrid analysis:
-
-        Get higher frequency resolution in the lower QMF subbands
-        creating sub-subbands. This is done by low frequency filtering.
-        Lower QMF subbands are further split in order to obtain a higher
-        frequency resolution, enabling a proper stereo analysis and synthesis
-        for the lower frequencies.
-        Two hybrid are defined. Both filters have length 13 and a delay of 6.
-        In this implementation, the symmetry of the filters helps to simplify
-        the design.
-
-
-   Increase Freq. Resolution
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-
-          subband k             QMF channel
-             0   .................  0      -----------
-             1   .................  0
-             2   .................  0
-             3   .................  0
-             4   .................  0
-             5   .................  0        Sub-QMF  ( Increase Freq. Resolution)
-             6   .................  1
-             7   .................  1
-             8   .................  2
-             9   .................  2
-            10   .................  3      -----------
-            11   .................  4
-            12   .................  5
-            13   .................  6
-            14   .................  7
-            15   .................  8         QMF
-           16-17 .................  9-10
-           18-20 ................. 11-13
-           21-24 ................. 14-17
-           25-29 ................. 18-22
-           30-41 ................. 23-34
-           42-70 ................. 35-63   -----------
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "s_hybrid.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_channel_filtering.h"
-#include    "ps_hybrid_analysis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_hybrid_analysis(const Int32 mQmfReal[][64],
-                        const Int32 mQmfImag[][64],
-                        Int32 *mHybridReal,
-                        Int32 *mHybridImag,
-                        HYBRID *pHybrid,
-                        Int32 scratch_mem[],
-                        Int32 i)
-
-{
-
-    Int32 band;
-    HYBRID_RES hybridRes;
-    Int32  chOffset = 0;
-
-    Int32 *ptr_mHybrid_Re;
-    Int32 *ptr_mHybrid_Im;
-
-    Int32 *pt_mQmfBufferReal;
-    Int32 *pt_mQmfBufferImag;
-
-    pt_mQmfBufferReal = &scratch_mem[32 + i];
-
-    for (band = 0; band < pHybrid->nQmfBands; band++)
-    {
-        pt_mQmfBufferImag = pt_mQmfBufferReal + 44;
-
-
-        pt_mQmfBufferReal[HYBRID_FILTER_LENGTH_m_1] = mQmfReal[HYBRID_FILTER_DELAY][band];
-        pt_mQmfBufferImag[HYBRID_FILTER_LENGTH_m_1] = mQmfImag[HYBRID_FILTER_DELAY][band];
-
-
-        ptr_mHybrid_Re = &mHybridReal[ chOffset];
-        ptr_mHybrid_Im = &mHybridImag[ chOffset];
-
-        hybridRes = (HYBRID_RES)pHybrid->pResolution[band];
-        switch (hybridRes)
-        {
-                /*
-                 *  For QMF band = 1  and  2
-                 */
-
-            case HYBRID_2_REAL:
-
-                two_ch_filtering(pt_mQmfBufferReal,
-                                 pt_mQmfBufferImag,
-                                 ptr_mHybrid_Re,
-                                 ptr_mHybrid_Im);
-                chOffset += 2;
-
-                break;
-
-                /*
-                 *  For QMF band = 0
-                 */
-
-            case HYBRID_8_CPLX:
-
-                eight_ch_filtering(pt_mQmfBufferReal,
-                                   pt_mQmfBufferImag,
-                                   pHybrid->mTempReal,
-                                   pHybrid->mTempImag,
-                                   scratch_mem);
-
-                pv_memmove(ptr_mHybrid_Re, pHybrid->mTempReal, 4*sizeof(*pHybrid->mTempReal));
-
-                ptr_mHybrid_Re += 2;
-
-                *(ptr_mHybrid_Re++) +=  pHybrid->mTempReal[5];
-                *(ptr_mHybrid_Re++) +=  pHybrid->mTempReal[4];
-                *(ptr_mHybrid_Re++)  =  pHybrid->mTempReal[6];
-                *(ptr_mHybrid_Re)  =  pHybrid->mTempReal[7];
-
-                pv_memmove(ptr_mHybrid_Im, pHybrid->mTempImag, 4*sizeof(*pHybrid->mTempImag));
-                ptr_mHybrid_Im += 2;
-
-                *(ptr_mHybrid_Im++) +=  pHybrid->mTempImag[5];
-                *(ptr_mHybrid_Im++) +=  pHybrid->mTempImag[4];
-                *(ptr_mHybrid_Im++)  =  pHybrid->mTempImag[6];
-                *(ptr_mHybrid_Im)  =  pHybrid->mTempImag[7];
-
-                chOffset += 6;
-
-                break;
-
-            default:
-                ;
-        }
-
-        pt_mQmfBufferReal = pt_mQmfBufferImag + 44;
-
-    }
-
-
-}
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h b/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h
deleted file mode 100644
index 0140a1f..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_analysis.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_analysis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_hybrid_analysis()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_ANALYSIS_H
-#define PS_HYBRID_ANALYSIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_hybrid_analysis(const Int32 mQmfReal[][64],
-    const Int32 mQmfImag[][64],
-    Int32 *mHybridReal,
-    Int32 *mHybridImag,
-    HYBRID *pHybrid,
-    Int32 scratch_mem[],
-    Int32 band);
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_HYBRID_ANALYSIS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp
deleted file mode 100644
index 4ff2385..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.cpp
+++ /dev/null
@@ -1,213 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_filter_bank_allocation.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Does Hybrid filter bank memory allocation
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include    "aac_mem_funcs.h"
-#include    "ps_hybrid_filter_bank_allocation.h"
-#include    "ps_all_pass_filter_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid,
-                                       Int32 noBands,
-                                       const Int32 *pResolution,
-                                       Int32 **pPtr)
-{
-    Int32 i;
-    Int32 tmp;
-    Int32 maxNoChannels = 0;
-    HYBRID *hs;
-    Int32 *ptr = *pPtr;
-
-
-    *phHybrid = (HYBRID *)NULL;
-
-    hs = (HYBRID *)ptr;
-
-    ptr += sizeof(HYBRID) / sizeof(*ptr);
-
-    hs->pResolution = (Int32*)ptr;
-
-    ptr += noBands * sizeof(Int32) / sizeof(*ptr);
-
-    for (i = 0; i < noBands; i++)
-    {
-
-        hs->pResolution[i] = pResolution[i];
-
-        if (pResolution[i] != HYBRID_8_CPLX &&
-                pResolution[i] != HYBRID_2_REAL &&
-                pResolution[i] != HYBRID_4_CPLX)
-        {
-            return 1;
-        }
-
-        if (pResolution[i] > maxNoChannels)
-        {
-            maxNoChannels = pResolution[i];
-        }
-    }
-
-    hs->nQmfBands     = noBands;
-    hs->qmfBufferMove = HYBRID_FILTER_LENGTH - 1;
-
-    hs->mQmfBufferReal = (Int32 **)ptr;
-    ptr += noBands * sizeof(ptr) / sizeof(*ptr);
-
-    hs->mQmfBufferImag = (Int32 **)ptr;
-    ptr += noBands * sizeof(ptr) / sizeof(*ptr);
-
-    tmp = hs->qmfBufferMove;        /*  HYBRID_FILTER_LENGTH == 13 */
-
-    for (i = 0; i < noBands; i++)
-    {
-        hs->mQmfBufferReal[i] = ptr;
-        ptr += tmp;
-
-        hs->mQmfBufferImag[i] = ptr;
-        ptr += tmp;
-
-    }
-
-    hs->mTempReal = ptr;
-    ptr += maxNoChannels;
-
-
-    hs->mTempImag = ptr;
-    ptr += maxNoChannels;
-
-
-    *phHybrid = hs;
-    *pPtr = ptr;
-
-    return 0;
-}
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h b/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h
deleted file mode 100644
index fbc0d80..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_filter_bank_allocation.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_filter_bank_allocation.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for ps_hybrid_filter_bank_allocation
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_FILTER_BANK_ALLOCATION_H
-#define PS_HYBRID_FILTER_BANK_ALLOCATION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int32 ps_hybrid_filter_bank_allocation(HYBRID **phHybrid,
-    Int32 noBands,
-    const Int32 *pResolution,
-    Int32 **pPtr);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_HYBRID_FILTER_BANK_ALLOCATION_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp b/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp
deleted file mode 100644
index 4fbd016..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.cpp
+++ /dev/null
@@ -1,192 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_hybrid_synthesis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Hybrid synthesis
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "s_hybrid.h"
-#include "ps_hybrid_synthesis.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void ps_hybrid_synthesis(const Int32 *mHybridReal,
-                         const Int32 *mHybridImag,
-                         Int32 *mQmfReal,
-                         Int32 *mQmfImag,
-                         HYBRID *hHybrid)
-{
-    Int32  k;
-    Int32  band;
-    HYBRID_RES hybridRes;
-
-    Int32 real;
-    Int32 imag;
-    Int32 *ptr_mQmfReal = mQmfReal;
-    Int32 *ptr_mQmfImag = mQmfImag;
-    const Int32 *ptr_mHybrid_Re = mHybridReal;
-    const Int32 *ptr_mHybrid_Im = mHybridImag;
-
-    for (band = 0; band < hHybrid->nQmfBands; band++)
-    {
-        hybridRes = (HYBRID_RES)(min(hHybrid->pResolution[band], 6) - 2);
-
-        real  = *(ptr_mHybrid_Re++);
-        real += *(ptr_mHybrid_Re++);
-        imag  = *(ptr_mHybrid_Im++);
-        imag += *(ptr_mHybrid_Im++);
-
-        for (k = (hybridRes >> 1); k != 0; k--)    /*  hybridRes = { 2,4,6 }  */
-        {
-            real += *(ptr_mHybrid_Re++);
-            real += *(ptr_mHybrid_Re++);
-            imag += *(ptr_mHybrid_Im++);
-            imag += *(ptr_mHybrid_Im++);
-        }
-
-        *(ptr_mQmfReal++) = real;
-        *(ptr_mQmfImag++) = imag;
-    }
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h b/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h
deleted file mode 100644
index d7242dd..0000000
--- a/media/libstagefright/codecs/aacdec/ps_hybrid_synthesis.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_hybrid_synthesis.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_hybrid_synthesis()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_HYBRID_SYNTHESIS_H
-#define PS_HYBRID_SYNTHESIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hybrid.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_hybrid_synthesis(const Int32 *mHybridReal,
-    const Int32 *mHybridImag,
-    Int32 *mQmfReal,
-    Int32 *mQmfImag,
-    HYBRID *hHybrid);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_HYBRID_SYNTHESIS_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp b/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp
deleted file mode 100644
index 7027b5c..0000000
--- a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.cpp
+++ /dev/null
@@ -1,496 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_init_stereo_mixing.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-      initialize mixing procedure  type Ra, type Rb is not supported
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "pv_audio_type_defs.h"
-#include    "fxp_mul32.h"
-
-#include    "aac_mem_funcs.h"
-#include    "pv_sine.h"
-#include    "s_ps_dec.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_init_stereo_mixing.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*
-;
-;  c(b) = 10^(iid(b)/20)
-;
-;  Intensity differences
-;
-;                  sqrt(2)
-;   c_1(b) = ----------------
-;            sqrt( 1 + c^2(b))
-;
-;               sqrt(2)*c(b)
-;   c_2(b) = ----------------
-;            sqrt( 1 + c^2(b))
-;
-*/
-
-
-
-#define R_SHIFT     30
-#define Q30_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 scaleFactors[NO_IID_LEVELS] =
-{
-    Q30_fmt(1.411983f),  Q30_fmt(1.403138f),  Q30_fmt(1.386877f),
-    Q30_fmt(1.348400f),  Q30_fmt(1.291249f),  Q30_fmt(1.196037f),
-    Q30_fmt(1.107372f),  Q30_fmt(1.000000f),  Q30_fmt(0.879617f),
-    Q30_fmt(0.754649f),  Q30_fmt(0.576780f),  Q30_fmt(0.426401f),
-    Q30_fmt(0.276718f),  Q30_fmt(0.176645f),  Q30_fmt(0.079402f)
-};
-
-const Int32 scaleFactorsFine[NO_IID_LEVELS_FINE] =
-{
-    Q30_fmt(1.414207f),  Q30_fmt(1.414191f),  Q30_fmt(1.414143f),
-    Q30_fmt(1.413990f),  Q30_fmt(1.413507f),  Q30_fmt(1.411983f),
-    Q30_fmt(1.409773f),  Q30_fmt(1.405395f),  Q30_fmt(1.396780f),
-    Q30_fmt(1.380053f),  Q30_fmt(1.348400f),  Q30_fmt(1.313920f),
-    Q30_fmt(1.264310f),  Q30_fmt(1.196037f),  Q30_fmt(1.107372f),
-    Q30_fmt(1.000000f),  Q30_fmt(0.879617f),  Q30_fmt(0.754649f),
-    Q30_fmt(0.633656f),  Q30_fmt(0.523081f),  Q30_fmt(0.426401f),
-    Q30_fmt(0.308955f),  Q30_fmt(0.221375f),  Q30_fmt(0.157688f),
-    Q30_fmt(0.111982f),  Q30_fmt(0.079402f),  Q30_fmt(0.044699f),
-    Q30_fmt(0.025145f),  Q30_fmt(0.014141f),  Q30_fmt(0.007953f),
-    Q30_fmt(0.004472f)
-};
-
-
-/*
- *  alphas ranged between 0 and pi/2
- *  alpha(b) = (1/2)*arccos( gamma(b))
- *
- *    b   0    1      2        3        4      5        6     7
- *  gamma 1 0.937  0.84118  0.60092  0.36764   0    -0.589   -1
- *
- */
-
-
-
-const Int32 scaled_alphas[NO_ICC_LEVELS] =
-{
-    Q30_fmt(0.00000000000000f),  Q30_fmt(0.12616764875355f),
-    Q30_fmt(0.20199707286122f),  Q30_fmt(0.32744135137762f),
-    Q30_fmt(0.42225800677370f),  Q30_fmt(0.55536025173035f),
-    Q30_fmt(0.77803595530059f),  Q30_fmt(1.11072050346071f)
-};
-
-const Int32 cos_alphas[NO_ICC_LEVELS] =
-{
-    Q30_fmt(1.00000000000000f),  Q30_fmt(0.98412391153249f),
-    Q30_fmt(0.95947390717984f),  Q30_fmt(0.89468446298319f),
-    Q30_fmt(0.82693418207478f),  Q30_fmt(0.70710689672598f),
-    Q30_fmt(0.45332071670080f),  Q30_fmt(0.00000032679490f)
-};
-
-const Int32 sin_alphas[NO_ICC_LEVELS] =
-{
-    Q30_fmt(0.00000000000000f),  Q30_fmt(0.17748275057029f),
-    Q30_fmt(0.28179748302823f),  Q30_fmt(0.44669868110000f),
-    Q30_fmt(0.56229872711603f),  Q30_fmt(0.70710666564709f),
-    Q30_fmt(0.89134747871404f),  Q30_fmt(1.00000000000000f)
-};
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms,
-                            Int32 env,
-                            Int32 usb)
-{
-    Int32   group;
-    Int32   bin;
-    Int32   noIidSteps;
-    Int32   tmp;
-
-    Int32   invEnvLength;
-    const Int32  *pScaleFactors;
-    Int32   scaleR;
-    Int32   scaleL;
-    Int32   cos_alpha;
-    Int32   sin_alpha;
-    Int32   beta;
-    Int32   cos_beta;
-    Int32   sin_beta;
-    Int32   temp1;
-    Int32   temp2;
-    Int32   *ptr_tmp;
-    Int32   h11;
-    Int32   h12;
-    Int32   h21;
-    Int32   h22;
-
-    if (pms->bFineIidQ)
-    {
-        noIidSteps = NO_IID_STEPS_FINE;     /*  NO_IID_STEPS_FINE == 15  */
-        pScaleFactors = scaleFactorsFine;
-    }
-    else
-    {
-        noIidSteps = NO_IID_STEPS;          /*  NO_IID_STEPS == 7   */
-        pScaleFactors = scaleFactors;
-    }
-
-    if (env == 0)
-    {
-        pms->lastUsb = pms->usb;
-        pms->usb = usb;
-        if (usb != pms->lastUsb && pms->lastUsb != 0)
-        {
-            return(-1);
-
-        }
-    }
-
-    invEnvLength =  pms->aEnvStartStop[env + 1] - pms->aEnvStartStop[env];
-
-    if (invEnvLength == (Int32) pms->noSubSamples)
-    {
-        invEnvLength = pms->invNoSubSamples;
-    }
-    else
-    {
-        invEnvLength = Q30_fmt(1.0f) / invEnvLength;
-    }
-
-    if (invEnvLength == 32)     /*  more likely value  */
-    {
-        for (group = 0; group < NO_IID_GROUPS; group++)      /* == 22 */
-        {
-            bin = bins2groupMap[group];
-
-            /*
-             *  c(b) = 10^(iid(b)/20)
-             */
-
-            tmp = pms->aaIidIndex[env][bin];
-
-            /*
-             *  Intensity differences
-             *
-             *                  sqrt(2)
-             *   c_1(b) = ----------------
-             *            sqrt( 1 + c^2(b))
-             *
-             */
-            scaleR = pScaleFactors[noIidSteps + tmp];
-
-            /*
-             *               sqrt(2)*c(b)
-             *   c_2(b) = ----------------
-             *            sqrt( 1 + c^2(b))
-             *
-             */
-
-            scaleL = pScaleFactors[noIidSteps - tmp];
-
-
-            /*
-             *  alpha(b) = (1/2)*arccos( gamma(b))
-             */
-            tmp = pms->aaIccIndex[env][bin];
-
-            cos_alpha = cos_alphas[ tmp];
-            sin_alpha = sin_alphas[ tmp];
-
-            /*
-             *   beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b))
-             */
-
-            beta   = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL));
-
-            cos_beta = pv_cosine(beta);
-            sin_beta = pv_sine(beta);
-
-            temp1 = fxp_mul32_Q30(cos_beta, cos_alpha);
-            temp2 = fxp_mul32_Q30(sin_beta, sin_alpha);
-
-
-            /*
-             *  h11(b) = cos( alpha(b) +  beta(b))* c_2(b)
-             *  h12(b) = cos(  beta(b) - alpha(b))* c_1(b)
-             */
-
-            h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2));
-            h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2));
-
-            temp1 = fxp_mul32_Q30(sin_beta, cos_alpha);
-            temp2 = fxp_mul32_Q30(cos_beta, sin_alpha);
-
-            /*
-             *  h21(b) = sin( alpha(b) +  beta(b))* c_2(b)
-             *  h22(b) = sin(  beta(b) - alpha(b))* c_1(b)
-             */
-
-            h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2));
-            h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2));
-
-
-            /*
-             *   Linear interpolation
-             *
-             *                                       Hij(k, n_e+1) - Hij(k, n_e)
-             *    Hij(k,n) = Hij(k, n_e) + (n - n_e)*---------------------------
-             *                                              n_e+1 - n_e
-             */
-
-            ptr_tmp = &pms->h11Prev[group];
-            pms->H11[group]       = *ptr_tmp;
-            pms->deltaH11[group]  = (h11 - *ptr_tmp) >> 5;
-            *ptr_tmp              = h11;
-
-            ptr_tmp = &pms->h12Prev[group];
-            pms->H12[group]       = *ptr_tmp;
-            pms->deltaH12[group]  = (h12 - *ptr_tmp) >> 5;
-            *ptr_tmp              = h12;
-
-            ptr_tmp = &pms->h21Prev[group];
-            pms->H21[group]       = *ptr_tmp;
-            pms->deltaH21[group]  = (h21 - *ptr_tmp) >> 5;
-            *ptr_tmp              = h21;
-
-            ptr_tmp = &pms->h22Prev[group];
-            pms->H22[group]       = *ptr_tmp;
-            pms->deltaH22[group]  = (h22 - *ptr_tmp) >> 5;
-            *ptr_tmp              = h22;
-
-
-        } /* groups loop */
-    }
-    else
-    {
-
-        for (group = 0; group < NO_IID_GROUPS; group++)      /* == 22 */
-        {
-            bin = bins2groupMap[group];
-
-            /*
-             *  c(b) = 10^(iid(b)/20)
-             */
-
-            tmp = pms->aaIidIndex[env][bin];
-
-            /*
-             *  Intensity differences
-             *
-             *                  sqrt(2)
-             *   c_1(b) = ----------------
-             *            sqrt( 1 + c^2(b))
-             *
-             */
-            scaleR = pScaleFactors[noIidSteps + tmp];
-
-            /*
-             *               sqrt(2)*c(b)
-             *   c_2(b) = ----------------
-             *            sqrt( 1 + c^2(b))
-             *
-             */
-
-            scaleL = pScaleFactors[noIidSteps - tmp];
-
-
-            /*
-             *  alpha(b) = (1/2)*arccos( gamma(b))
-             */
-            tmp = pms->aaIccIndex[env][bin];
-
-            cos_alpha = cos_alphas[ tmp];
-            sin_alpha = sin_alphas[ tmp];
-
-            /*
-             *   beta(b) = alpha(b)/sqrt(2)*( c_1(b) - c_2(b))
-             */
-
-            beta   = fxp_mul32_Q30(scaled_alphas[ tmp], (scaleR - scaleL));
-
-            cos_beta = pv_cosine(beta);
-            sin_beta = pv_sine(beta);
-
-            temp1 = fxp_mul32_Q30(cos_beta, cos_alpha);
-            temp2 = fxp_mul32_Q30(sin_beta, sin_alpha);
-
-
-            /*
-             *  h11(b) = cos( alpha(b) +  beta(b))* c_2(b)
-             *  h12(b) = cos(  beta(b) - alpha(b))* c_1(b)
-             */
-
-            h11 = fxp_mul32_Q30(scaleL, (temp1 - temp2));
-            h12 = fxp_mul32_Q30(scaleR, (temp1 + temp2));
-
-            temp1 = fxp_mul32_Q30(sin_beta, cos_alpha);
-            temp2 = fxp_mul32_Q30(cos_beta, sin_alpha);
-
-            /*
-             *  h21(b) = sin( alpha(b) +  beta(b))* c_2(b)
-             *  h22(b) = sin(  beta(b) - alpha(b))* c_1(b)
-             */
-
-            h21 = fxp_mul32_Q30(scaleL, (temp1 + temp2));
-            h22 = fxp_mul32_Q30(scaleR, (temp1 - temp2));
-
-
-            /*
-             *   Linear interpolation
-             *
-             *                                       Hij(k, n_e+1) - Hij(k, n_e)
-             *    Hij(k,n) = Hij(k, n_e) + (n - n_e)*---------------------------
-             *                                              n_e+1 - n_e
-             */
-
-            ptr_tmp = &pms->h11Prev[group];
-            pms->deltaH11[group]  = fxp_mul32_Q30((h11 - *ptr_tmp), invEnvLength);
-            pms->H11[group]       = *ptr_tmp;
-            *ptr_tmp              = h11;
-
-            ptr_tmp = &pms->h12Prev[group];
-            pms->deltaH12[group]  = fxp_mul32_Q30((h12 - *ptr_tmp), invEnvLength);
-            pms->H12[group]       = *ptr_tmp;
-            *ptr_tmp              = h12;
-
-            ptr_tmp = &pms->h21Prev[group];
-            pms->deltaH21[group]  = fxp_mul32_Q30((h21 - *ptr_tmp), invEnvLength);
-            pms->H21[group]       = *ptr_tmp;
-            *ptr_tmp              = h21;
-
-            ptr_tmp = &pms->h22Prev[group];
-            pms->deltaH22[group]  = fxp_mul32_Q30((h22 - *ptr_tmp), invEnvLength);
-            pms->H22[group]       = *ptr_tmp;
-            *ptr_tmp              = h22;
-
-
-        } /* groups loop */
-    }
-
-
-    return (0);
-
-} /* END ps_init_stereo_mixing */
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h b/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h
deleted file mode 100644
index 6c30781..0000000
--- a/media/libstagefright/codecs/aacdec/ps_init_stereo_mixing.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_init_stereo_mixing.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_init_stereo_mixing()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_INIT_STEREO_MIXING_H
-#define PS_INIT_STEREO_MIXING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int32 ps_init_stereo_mixing(STRUCT_PS_DEC *pms,
-    Int32 env,
-    Int32 usb);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_INIT_STEREO_MIXING_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp b/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp
deleted file mode 100644
index a0e8c38..0000000
--- a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.cpp
+++ /dev/null
@@ -1,340 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_pwr_transient_detection.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Decorrelation
-  Decorrelation is achieved by means of all-pass filtering and delaying
-  Sub-band samples s_k(n) are converted into de-correlated sub-bands samples
-  d_k(n). k index for frequency, n time index
-
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-  To handle transients and other fast time-envelopes, the output of the all
-  pass filters has to be attenuated at those signals.
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "pv_audio_type_defs.h"
-#include    "s_ps_dec.h"
-#include    "aac_mem_funcs.h"
-#include    "ps_all_pass_filter_coeff.h"
-#include    "ps_pwr_transient_detection.h"
-
-#include    "fxp_mul32.h"
-#include    "pv_div.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     29
-#define Q29_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Qfmt31(a)   (Int32)(-a*((Int32)1<<31) - 1 + (a>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec,
-                                Int32 *rIntBufferLeft,
-                                Int32 *iIntBufferLeft,
-                                Int32 aTransRatio[])
-{
-
-    Int32 sb;
-    Int32 maxsb;
-    Int32 gr;
-    Int32 bin;
-
-
-
-    Int32 *aLeftReal;
-    Int32 *aLeftImag;
-    Int32   temp_r;
-    Int32   temp_i;
-    Int32   accu;
-    Int32 *aPower = aTransRatio;
-    Quotient result;
-
-    Int32 nrg;
-    Int32 *ptr_aPrevNrg;
-    Int32 peakDiff;
-    Int32 *ptr_PrevPeakDiff;
-
-
-    aLeftReal = rIntBufferLeft;
-    aLeftImag = iIntBufferLeft;
-
-    /*
-     *  Input Power Matrix
-     *                            2
-     *  Power(i,n) = SUM | s_k(n)|
-     *                i
-     */
-
-    for (gr = SUBQMF_GROUPS; gr < NO_IID_GROUPS; gr++) /* 10 to 22  */
-    {
-        maxsb = min(h_ps_dec->usb, groupBorders[ gr+1]);
-
-        accu = 0;
-
-        for (sb = groupBorders[gr]; sb < maxsb; sb++)
-        {
-
-            temp_r = aLeftReal[sb];
-            temp_i = aLeftImag[sb];
-            accu =  fxp_mac32_Q31(accu, temp_r, temp_r);
-            accu =  fxp_mac32_Q31(accu, temp_i, temp_i);
-
-        } /* sb */
-        aPower[gr - 2] = accu >> 1;
-    } /* gr */
-
-    aLeftReal = h_ps_dec->mHybridRealLeft;
-    aLeftImag = h_ps_dec->mHybridImagLeft;
-
-
-    temp_r = aLeftReal[0];
-    temp_i = aLeftImag[0];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    accu  = fxp_mac32_Q31(accu, temp_i, temp_i);
-    temp_r = aLeftReal[5];
-    temp_i = aLeftImag[5];
-    accu   = fxp_mac32_Q31(accu, temp_r, temp_r);
-    aPower[0]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[1];
-    temp_i = aLeftImag[1];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    accu  = fxp_mac32_Q31(accu, temp_i, temp_i);
-    temp_r = aLeftReal[4];
-    temp_i = aLeftImag[4];
-    accu   = fxp_mac32_Q31(accu, temp_r, temp_r);
-    aPower[1]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[2];
-    temp_i = aLeftImag[2];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[2]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[3];
-    temp_i = aLeftImag[3];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[3]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-
-
-    temp_r = aLeftReal[6];
-    temp_i = aLeftImag[6];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[5]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[7];
-    temp_i = aLeftImag[7];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[4]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[8];
-    temp_i = aLeftImag[8];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[6]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-    temp_r = aLeftReal[9];
-    temp_i = aLeftImag[9];
-    accu   = fxp_mul32_Q31(temp_r, temp_r);
-    aPower[7]  = fxp_mac32_Q31(accu, temp_i, temp_i) >> 1;
-
-
-    /*
-     *  Power transient detection
-     */
-
-    ptr_aPrevNrg = h_ps_dec->aPrevNrg;
-
-    ptr_PrevPeakDiff = h_ps_dec->aPrevPeakDiff;
-
-    for (bin = 0; bin < NO_BINS; bin++) /* NO_BINS = 20  */
-    {
-
-        peakDiff  = *ptr_PrevPeakDiff;
-
-
-        /* PEAK_DECAY_FACTOR  0.765928338364649f @ 48 KHz  for Fs > 32 Khz */
-        accu = h_ps_dec->aPeakDecayFast[bin];
-        peakDiff -= peakDiff >> 2;
-
-        accu  = fxp_mul32_Q31(accu, Qfmt31(0.765928338364649f)) << 1;
-
-        if (accu < *aPower)
-        {
-            accu = *aPower;
-        }
-        else
-        {
-            peakDiff += ((accu - *aPower) >> 2);
-        }
-
-        h_ps_dec->aPeakDecayFast[bin] = accu;
-
-        *(ptr_PrevPeakDiff++) = peakDiff;
-
-        nrg =   *ptr_aPrevNrg + ((*aPower - *ptr_aPrevNrg) >> 2);
-
-        *(ptr_aPrevNrg++) = nrg;
-
-        peakDiff += peakDiff >> 1;         /* transient impact factor == 1.5 */
-
-        if (peakDiff <= nrg)
-        {
-            *(aPower++) = 0x7FFFFFFF;    /* in Q31  */
-        }
-        else
-        {
-            pv_div(nrg, peakDiff, &result);
-            *(aPower++) = (result.quotient >> (result.shift_factor)) << 1;    /* in Q31  */
-        }
-
-    } /* bin */
-
-}
-
-
-#endif
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h b/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h
deleted file mode 100644
index 80a73a8..0000000
--- a/media/libstagefright/codecs/aacdec/ps_pwr_transient_detection.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_pwr_transient_detection.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_pwr_transient_detection()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_PWR_TRANSIENT_DETECTION_H
-#define PS_PWR_TRANSIENT_DETECTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_pwr_transient_detection(STRUCT_PS_DEC *h_ps_dec,
-    Int32 *rIntBufferLeft,
-    Int32 *iIntBufferLeft,
-    Int32 aTransRatio[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_PWR_TRANSIENT_DETECTION_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_read_data.cpp b/media/libstagefright/codecs/aacdec/ps_read_data.cpp
deleted file mode 100644
index c49eb3d..0000000
--- a/media/libstagefright/codecs/aacdec/ps_read_data.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_read_data.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Decodes parametric stereo
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include    "pv_audio_type_defs.h"
-#include    "buf_getbits.h"
-#include    "s_bit_buffer.h"
-#include    "s_huffman.h"
-#include    "aac_mem_funcs.h"
-#include    "s_ps_dec.h"
-#include    "sbr_decode_huff_cw.h"
-#include    "ps_decode_bs_utils.h"
-#include    "ps_bstr_decoding.h"
-#include    "ps_read_data.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/* IID & ICC Huffman codebooks */
-const Char aBookPsIidTimeDecode[28][2] =
-{
-    { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
-    { -62,   5 },    { -67,   6 },    { -61,   7 },    { -68,   8 },
-    { -60,   9 },    { -69,  10 },    { -59,  11 },    { -70,  12 },
-    { -58,  13 },    { -57,  14 },    { -71,  15 },    {  16,  17 },
-    { -56, -72 },    {  18,  21 },    {  19,  20 },    { -55, -78 },
-    { -77, -76 },    {  22,  25 },    {  23,  24 },    { -75, -74 },
-    { -73, -54 },    {  26,  27 },    { -53, -52 },    { -51, -50 }
-};
-
-const Char aBookPsIidFreqDecode[28][2] =
-{
-    { -64,   1 },    {   2,   3 },    { -63, -65 },    {   4,   5 },
-    { -62, -66 },    {   6,   7 },    { -61, -67 },    {   8,   9 },
-    { -68, -60 },    { -59,  10 },    { -69,  11 },    { -58,  12 },
-    { -70,  13 },    { -71,  14 },    { -57,  15 },    {  16,  17 },
-    { -56, -72 },    {  18,  19 },    { -55, -54 },    {  20,  21 },
-    { -73, -53 },    {  22,  24 },    { -74,  23 },    { -75, -78 },
-    {  25,  26 },    { -77, -76 },    { -52,  27 },    { -51, -50 }
-};
-
-const Char aBookPsIccTimeDecode[14][2] =
-{
-    { -64,   1 },    { -63,   2 },    { -65,   3 },    { -62,   4 },
-    { -66,   5 },    { -61,   6 },    { -67,   7 },    { -60,   8 },
-    { -68,   9 },    { -59,  10 },    { -69,  11 },    { -58,  12 },
-    { -70,  13 },    { -71, -57 }
-};
-
-const Char aBookPsIccFreqDecode[14][2] =
-{
-    { -64,   1 },    { -63,   2 },    { -65,   3 },    { -62,   4 },
-    { -66,   5 },    { -61,   6 },    { -67,   7 },    { -60,   8 },
-    { -59,   9 },    { -68,  10 },    { -58,  11 },    { -69,  12 },
-    { -57,  13 },    { -70, -71 }
-};
-
-const Char aBookPsIidFineTimeDecode[60][2] =
-{
-    {   1, -64 },    { -63,   2 },    {   3, -65 },    {   4,  59 },
-    {   5,   7 },    {   6, -67 },    { -68, -60 },    { -61,   8 },
-    {   9,  11 },    { -59,  10 },    { -70, -58 },    {  12,  41 },
-    {  13,  20 },    {  14, -71 },    { -55,  15 },    { -53,  16 },
-    {  17, -77 },    {  18,  19 },    { -85, -84 },    { -46, -45 },
-    { -57,  21 },    {  22,  40 },    {  23,  29 },    { -51,  24 },
-    {  25,  26 },    { -83, -82 },    {  27,  28 },    { -90, -38 },
-    { -92, -91 },    {  30,  37 },    {  31,  34 },    {  32,  33 },
-    { -35, -34 },    { -37, -36 },    {  35,  36 },    { -94, -93 },
-    { -89, -39 },    {  38, -79 },    {  39, -81 },    { -88, -40 },
-    { -74, -54 },    {  42, -69 },    {  43,  44 },    { -72, -56 },
-    {  45,  52 },    {  46,  50 },    {  47, -76 },    { -49,  48 },
-    { -47,  49 },    { -87, -41 },    { -52,  51 },    { -78, -50 },
-    {  53, -73 },    {  54, -75 },    {  55,  57 },    {  56, -80 },
-    { -86, -42 },    { -48,  58 },    { -44, -43 },    { -66, -62 }
-};
-
-const Char aBookPsIidFineFreqDecode[60][2] =
-{
-    {   1, -64 },    {   2,   4 },    {   3, -65 },    { -66, -62 },
-    { -63,   5 },    {   6,   7 },    { -67, -61 },    {   8,   9 },
-    { -68, -60 },    {  10,  11 },    { -69, -59 },    {  12,  13 },
-    { -70, -58 },    {  14,  18 },    { -57,  15 },    {  16, -72 },
-    { -54,  17 },    { -75, -53 },    {  19,  37 },    { -56,  20 },
-    {  21, -73 },    {  22,  29 },    {  23, -76 },    {  24, -78 },
-    {  25,  28 },    {  26,  27 },    { -85, -43 },    { -83, -45 },
-    { -81, -47 },    { -52,  30 },    { -50,  31 },    {  32, -79 },
-    {  33,  34 },    { -82, -46 },    {  35,  36 },    { -90, -89 },
-    { -92, -91 },    {  38, -71 },    { -55,  39 },    {  40, -74 },
-    {  41,  50 },    {  42, -77 },    { -49,  43 },    {  44,  47 },
-    {  45,  46 },    { -86, -42 },    { -88, -87 },    {  48,  49 },
-    { -39, -38 },    { -41, -40 },    { -51,  51 },    {  52,  59 },
-    {  53,  56 },    {  54,  55 },    { -35, -34 },    { -37, -36 },
-    {  57,  58 },    { -94, -93 },    { -84, -44 },    { -80, -48 }
-};
-
-
-
-
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 ps_read_data(STRUCT_PS_DEC *ps_dec,
-                   BIT_BUFFER * hBitBuf,
-                   Int32 nBitsLeft)
-
-{
-    Int     gr;
-    UInt32     env;
-    UInt32     dtFlag;
-    Int32     startbits;
-    SbrHuffman CurrentTable;
-
-    if (!ps_dec)
-    {
-        return 0;
-    }
-
-    startbits = GetNrBitsAvailable(hBitBuf);
-
-    if (buf_get_1bit(hBitBuf))  /*  Enable Header */
-    {
-        ps_dec->bEnableIid = buf_get_1bit(hBitBuf);
-
-        if (ps_dec->bEnableIid)
-        {
-            ps_dec->freqResIid = buf_getbits(hBitBuf, 3);
-
-            if (ps_dec->freqResIid > 2)
-            {
-                ps_dec->bFineIidQ = 1;
-                ps_dec->freqResIid -= 3;
-            }
-            else
-            {
-                ps_dec->bFineIidQ = 0;
-            }
-        }
-
-        ps_dec->bEnableIcc = buf_get_1bit(hBitBuf);
-        if (ps_dec->bEnableIcc)
-        {
-            ps_dec->freqResIcc = buf_getbits(hBitBuf, 3);
-
-            if (ps_dec->freqResIcc > 2)
-            {
-                ps_dec->freqResIcc -= 3;
-            }
-        }
-        ps_dec->bEnableExt = buf_get_1bit(hBitBuf);
-    }
-
-    ps_dec->bFrameClass = buf_get_1bit(hBitBuf);
-    if (ps_dec->bFrameClass == 0)
-    {
-        ps_dec->noEnv = aFixNoEnvDecode[ buf_getbits(hBitBuf, 2)];
-    }
-    else
-    {
-        ps_dec->noEnv = 1 + buf_getbits(hBitBuf, 2);
-        for (env = 1; env < ps_dec->noEnv + 1; env++)
-        {
-            ps_dec->aEnvStartStop[env] = (buf_getbits(hBitBuf, 5)) + 1;
-        }
-    }
-
-    if ((ps_dec->freqResIid > 2) || (ps_dec->freqResIcc > 2))
-    {
-
-        ps_dec->bPsDataAvail = 0;
-
-        nBitsLeft -= startbits - GetNrBitsAvailable(hBitBuf);
-        while (nBitsLeft)
-        {
-            int i = nBitsLeft;
-            if (i > 8)
-            {
-                i = 8;
-            }
-            buf_getbits(hBitBuf, i);
-            nBitsLeft -= i;
-        }
-        return (startbits - GetNrBitsAvailable(hBitBuf));
-    }
-
-    if (ps_dec->bEnableIid)
-    {
-        for (env = 0; env < ps_dec->noEnv; env++)
-        {
-            dtFlag = buf_get_1bit(hBitBuf);
-
-            if (!dtFlag)
-            {
-                if (ps_dec->bFineIidQ)
-                {
-                    CurrentTable = aBookPsIidFineFreqDecode;
-                }
-                else
-                {
-                    CurrentTable = aBookPsIidFreqDecode;
-                }
-            }
-            else
-            {
-                if (ps_dec->bFineIidQ)
-                {
-                    CurrentTable = aBookPsIidFineTimeDecode;
-                }
-                else
-                {
-                    CurrentTable = aBookPsIidTimeDecode;
-                }
-            }
-
-            for (gr = 0; gr < aNoIidBins[ps_dec->freqResIid]; gr++)
-            {
-                ps_dec->aaIidIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf);
-            }
-
-            ps_dec->abIidDtFlag[env] = dtFlag;
-        }
-    }
-
-    if (ps_dec->bEnableIcc)
-    {
-        for (env = 0; env < ps_dec->noEnv; env++)
-        {
-            dtFlag = buf_get_1bit(hBitBuf);
-            if (!dtFlag)
-            {
-                CurrentTable = aBookPsIccFreqDecode;
-            }
-            else
-            {
-                CurrentTable = aBookPsIccTimeDecode;
-            }
-            for (gr = 0; gr < aNoIccBins[ps_dec->freqResIcc]; gr++)
-            {
-                ps_dec->aaIccIndex[env][gr] = sbr_decode_huff_cw(CurrentTable, hBitBuf);
-            }
-
-            ps_dec->abIccDtFlag[env] = dtFlag;
-        }
-    }
-
-    if (ps_dec->bEnableExt)
-    {
-
-        int cnt;
-
-        cnt = (int)buf_getbits(hBitBuf, 4);
-
-        if (cnt == 15)
-        {
-            cnt += (int)buf_getbits(hBitBuf, 8);
-        }
-
-        hBitBuf->nrBitsRead += (cnt << 3);
-    }
-
-    ps_dec->bPsDataAvail = 1;
-
-    return (startbits - GetNrBitsAvailable(hBitBuf));
-}
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_read_data.h b/media/libstagefright/codecs/aacdec/ps_read_data.h
deleted file mode 100644
index e2fec53..0000000
--- a/media/libstagefright/codecs/aacdec/ps_read_data.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_read_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for functions ps_read_data()
-
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_READ_DATA_H
-#define PS_READ_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define EXTENSION_ID_PS_CODING   2
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int32 ps_read_data(STRUCT_PS_DEC *ps_dec,
-    BIT_BUFFER * hBitBuf,
-    Int32 nBitsLeft);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_READ_DATA_H */
diff --git a/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp b/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp
deleted file mode 100644
index 813b55d..0000000
--- a/media/libstagefright/codecs/aacdec/ps_stereo_processing.cpp
+++ /dev/null
@@ -1,372 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: ps_stereo_processing.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Stereo Process or reconstruction
-
-           l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
-
-           r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
-
-     _______                                              ________
-    |       |                                  _______   |        |
-  ->|Hybrid | LF ----                         |       |->| Hybrid |-->
-    | Anal. |        |                        |       |  | Synth  |   QMF -> L
-     -------         o----------------------->|       |   --------    Synth
-QMF                  |                s_k(n)  |Stereo |-------------->
-Anal.              -------------------------->|       |
-     _______       | |                        |       |   ________
-    |       | HF --o |   -----------          |Process|  |        |
-  ->| Delay |      |  ->|           |-------->|       |->| Hybrid |-->
-     -------       |    |decorrelate| d_k(n)  |       |  | Synth  |   QMF -> R
-                   ---->|           |-------->|       |   --------    Synth
-                         -----------          |_______|-------------->
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-#include    "pv_audio_type_defs.h"
-#include    "ps_stereo_processing.h"
-#include    "fxp_mul32.h"
-#include    "ps_all_pass_filter_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void ps_stereo_processing(STRUCT_PS_DEC  *pms,
-                          Int32          *qmfLeftReal,
-                          Int32          *qmfLeftImag,
-                          Int32          *qmfRightReal,
-                          Int32          *qmfRightImag)
-{
-    Int32     group;
-    Int32     subband;
-    Int32     maxSubband;
-    Int32     usb;
-    Char     index;
-
-
-    Int32  *hybrLeftReal;
-    Int32  *hybrLeftImag;
-    Int32  *hybrRightReal;
-    Int32  *hybrRightImag;
-    Int32  *ptr_hybrLeftReal;
-    Int32  *ptr_hybrLeftImag;
-    Int32  *ptr_hybrRightReal;
-    Int32  *ptr_hybrRightImag;
-
-
-    Int16   h11;
-    Int16   h12;
-    Int16   h21;
-    Int16   h22;
-
-    Int32   temp1;
-    Int32   temp2;
-    Int32   temp3;
-
-    usb = pms->usb;
-
-    /*
-     *   Complete Linear interpolation
-     */
-
-    hybrLeftReal  = pms->mHybridRealLeft;
-    hybrLeftImag  = pms->mHybridImagLeft;
-    hybrRightReal = pms->mHybridRealRight;
-    hybrRightImag = pms->mHybridImagRight;
-
-    for (group = 0; group < SUBQMF_GROUPS; group++)     /* SUBQMF_GROUPS == 10 */
-    {
-
-        temp1 = pms->deltaH11[group];
-        temp2 = pms->deltaH12[group];
-
-        pms->H11[group]  += temp1;
-        h11  = (Int16)(pms->H11[group] >> 16);
-        pms->H12[group]  += temp2;
-        h12  = (Int16)(pms->H12[group] >> 16);
-
-        temp1 = pms->deltaH21[group];
-        temp2 = pms->deltaH22[group];
-
-        pms->H21[group]  += temp1;
-        h21  = (Int16)(pms->H21[group] >> 16);
-        pms->H22[group]  += temp2;
-        h22  = (Int16)(pms->H22[group] >> 16);
-
-        index = groupBorders[group];
-
-        /*
-         *  Reconstruction of Stereo sub-band signal
-         *
-         *  l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
-         *
-         *  r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
-         */
-        ptr_hybrLeftReal  = &hybrLeftReal[  index];
-        ptr_hybrRightReal = &hybrRightReal[ index];
-
-        temp1 = *(ptr_hybrLeftReal) << 1;
-        temp2 = *(ptr_hybrRightReal) << 1;
-
-        temp3 = fxp_mul32_by_16(temp1, h11);
-        *(ptr_hybrLeftReal)  = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-        temp3 = fxp_mul32_by_16(temp1, h12);
-        *(ptr_hybrRightReal) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
-        ptr_hybrLeftImag  = &hybrLeftImag[  index];
-        ptr_hybrRightImag = &hybrRightImag[ index];
-
-        temp1 = *(ptr_hybrLeftImag) << 1;
-        temp2 = *(ptr_hybrRightImag) << 1;
-
-        temp3 = fxp_mul32_by_16(temp1, h11);
-        *(ptr_hybrLeftImag)  = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-        temp3 = fxp_mul32_by_16(temp1, h12);
-        *(ptr_hybrRightImag) = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
-    } /* groups loop */
-
-    temp1 = pms->deltaH11[SUBQMF_GROUPS];
-    temp2 = pms->deltaH12[SUBQMF_GROUPS];
-
-    pms->H11[SUBQMF_GROUPS]  += temp1;
-    h11  = (Int16)(pms->H11[SUBQMF_GROUPS] >> 16);
-    pms->H12[SUBQMF_GROUPS]  += temp2;
-    h12  = (Int16)(pms->H12[SUBQMF_GROUPS] >> 16);
-
-    temp1 = pms->deltaH21[SUBQMF_GROUPS];
-    temp2 = pms->deltaH22[SUBQMF_GROUPS];
-
-    pms->H21[SUBQMF_GROUPS]  += temp1;
-    h21  = (Int16)(pms->H21[SUBQMF_GROUPS] >> 16);
-    pms->H22[SUBQMF_GROUPS]  += temp2;
-    h22  = (Int16)(pms->H22[SUBQMF_GROUPS] >> 16);
-
-
-    ptr_hybrLeftReal  = &qmfLeftReal[  3];
-    ptr_hybrRightReal = &qmfRightReal[ 3];
-
-    /*
-     *  Reconstruction of Stereo sub-band signal
-     *
-     *  l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
-     *
-     *  r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
-     */
-    temp1 = *(ptr_hybrLeftReal) << 1;
-    temp2 = *(ptr_hybrRightReal) << 1;
-
-
-    temp3 = fxp_mul32_by_16(temp1, h11);
-    *(ptr_hybrLeftReal)  = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-    temp3 = fxp_mul32_by_16(temp1, h12);
-    *(ptr_hybrRightReal)  = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-    ptr_hybrLeftImag  = &qmfLeftImag[  3];
-    ptr_hybrRightImag = &qmfRightImag[ 3];
-
-
-    temp1 = *(ptr_hybrLeftImag) << 1;
-    temp2 = *(ptr_hybrRightImag) << 1;
-
-    temp3 = fxp_mul32_by_16(temp1, h11);
-    *(ptr_hybrLeftImag)  = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-    temp3 = fxp_mul32_by_16(temp1, h12);
-    *(ptr_hybrRightImag)  = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-
-    for (group = SUBQMF_GROUPS + 1; group < NO_IID_GROUPS; group++)   /* 11 to NO_IID_GROUPS == 22 */
-    {
-        temp1 = pms->deltaH11[group];
-        temp2 = pms->deltaH12[group];
-
-        pms->H11[group]  += temp1;
-        h11  = (Int16)(pms->H11[group] >> 16);
-        pms->H12[group]  += temp2;
-        h12  = (Int16)(pms->H12[group] >> 16);
-
-        temp1 = pms->deltaH21[group];
-        temp2 = pms->deltaH22[group];
-
-        pms->H21[group]  += temp1;
-        h21  = (Int16)(pms->H21[group] >> 16);
-        pms->H22[group]  += temp2;
-        h22  = (Int16)(pms->H22[group] >> 16);
-
-        index = groupBorders[group];
-        maxSubband = groupBorders[group + 1];
-        maxSubband = min(usb, maxSubband);
-
-        /*
-         *  Reconstruction of Stereo sub-band signal
-         *
-         *  l_k(n) = H11(k,n)*s_k(n) + H21(k,n)*d_k(n)
-         *
-         *  r_k(n) = H12(k,n)*s_k(n) + H22(k,n)*d_k(n)
-         */
-
-        ptr_hybrLeftReal  = &qmfLeftReal[  index];
-        ptr_hybrRightReal = &qmfRightReal[ index];
-
-        for (subband = index; subband < maxSubband; subband++)
-        {
-            temp1 = *(ptr_hybrLeftReal) << 1;
-            temp2 = *(ptr_hybrRightReal) << 1;
-            temp3 = fxp_mul32_by_16(temp1, h11);
-            *(ptr_hybrLeftReal++)   = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-            temp3 = fxp_mul32_by_16(temp1, h12);
-            *(ptr_hybrRightReal++)  = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-        }
-
-        ptr_hybrLeftImag  = &qmfLeftImag[  index];
-        ptr_hybrRightImag = &qmfRightImag[ index];
-
-        for (subband = index; subband < maxSubband; subband++)
-        {
-            temp1 = *(ptr_hybrLeftImag) << 1;
-            temp2 = *(ptr_hybrRightImag) << 1;
-            temp3 = fxp_mul32_by_16(temp1, h11);
-            *(ptr_hybrLeftImag++)   = fxp_mac32_by_16(temp2, h21, temp3) << 1;
-
-            temp3 = fxp_mul32_by_16(temp1, h12);
-            *(ptr_hybrRightImag++)  = fxp_mac32_by_16(temp2, h22, temp3) << 1;
-
-        } /* subband loop */
-
-    } /* groups loop */
-
-} /* END ps_stereo_processing */
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/ps_stereo_processing.h b/media/libstagefright/codecs/aacdec/ps_stereo_processing.h
deleted file mode 100644
index 58b025a..0000000
--- a/media/libstagefright/codecs/aacdec/ps_stereo_processing.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ps_stereo_processing.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for function ps_stereo_processing()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PS_STEREO_PROCESSING_H
-#define PS_STEREO_PROCESSING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_ps_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void ps_stereo_processing(STRUCT_PS_DEC  *pms,
-    Int32          *qmfLeftReal,
-    Int32          *qmfLeftImag,
-    Int32          *qmfRightReal,
-    Int32          *qmfRightImag);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif  /* PS_STEREO_PROCESSING_H */
diff --git a/media/libstagefright/codecs/aacdec/pulse_nc.cpp b/media/libstagefright/codecs/aacdec/pulse_nc.cpp
deleted file mode 100644
index 87b264d..0000000
--- a/media/libstagefright/codecs/aacdec/pulse_nc.cpp
+++ /dev/null
@@ -1,298 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pulse_nc.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Modified to pass variables by reference to eliminate use
-               of global variables.
-
- Description:  Modified to bring code in-line with PV standards.
-
- Description: Pass in max as input argument.
-
- Description: Went back to the if-statement to check for max.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    coef[]         =  Array of quantized spectral coefficents.
-                      (Int [])
-
-    pPulseInfo     =  Pointer to structure which contains noiseless
-                      encoding info, includes information about the pulse data,
-                      pulse amplitude, etc.
-                      (const PulseInfo *)
-
-    pLongFrameInfo =  Pointer to structure that holds information about
-                      each group. (long block flag, number of windows,
-                      scalefactor bands per group, etc.)
-
-                      Variable is named (pLongFrameInfo) because this function
-                      is only used for LONG windows.
-                      (FrameInfo *)
-    max             = Pointer to the maximum value of coef[]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coef[]  =  coefficient contents are modified by the encoded pulse
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function adds pulses to defined ranges of coefficients in the window,
- for the case of LONG windows.  The pulses are unsigned, so
- negative coefficients subtract the pulse, and positive coefficients add it.
- (The ampltiude of the coefficient is always increased by the pulse)
-
- A maximum of 4 coefficients may be modified by a pulse, and these
- coefficients must all occur in the same scalefactor band.
-
- The number of pulse-encoded coefficients to be processed by this function
- is communicated to this function via pPulseInfo->number_pulse
-
- This value is equal to the actual number of pulses - 1.
- (e.g if pPulseInfo->number_pulse == 0, one pulse is assumed)
- This function must not be called if no pulse encoded data exists.
- The function assumes that at least one pulse exists.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This module shall correctly add transmitted pulse(s) to the correct
- coefficients in a LONG window.
-
-------------------------------------------------------------------------------
- REFERENCES
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.3.3 Decoding Process
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb];
-
-    pPulseOffset = &(pPulseInfo->pulse_offset[0]);
-
-    pPulseAmp    = &(pPulseInfo->pulse_amp[0]);
-
-    pCoef        = &(Coef[index]);
-
-    FOR (index = pPulseInfo->number_pulse; index >= 0; index--)
-
-        pCoef   = pCoef + *(pPulseOffset);
-        pPulseOffset = pPulseOffset + 1;
-
-        IF (*pCoef > 0)
-            *(pCoef) = *(pCoef) + *(pPulseAmp);
-            pPulseAmp     = pPulseAmp + 1;
-        ELSE
-            *(pCoef) = *(pCoef) - *(pPulseAmp);
-            pPulseAmp     = pPulseAmp + 1;
-        ENDIF
-
-    ENDFOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_pulseinfo.h"
-#include "pulse_nc.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*---------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void pulse_nc(
-    Int16      coef[],
-    const PulseInfo  *pPulseInfo,
-    const FrameInfo  *pLongFrameInfo,
-    Int      *max)
-{
-    Int index;
-
-    Int16 *pCoef;
-    Int temp;
-
-    const Int *pPulseOffset;
-    const Int *pPulseAmp;
-
-    /*--- Find the scalefactor band where pulse-encoded data starts ---*/
-
-    if (pPulseInfo->pulse_start_sfb > 0)
-    {
-        index = pLongFrameInfo->win_sfb_top[0][pPulseInfo->pulse_start_sfb - 1];
-    }
-    else
-    {
-        index = 0;
-    }
-
-    /*-------------------------------------------------------------------------
-      Each pulse index is stored as an offset from the previous pulse
-
-      Example - here we have a sfb that is 20 coefficients in length:
-
-      [0][1][2][3][4][5][6][7][8][9][10][11][12][13][14][15][16][17][18][19]
-      [ ][ ][ ][ ][ ][P][P][ ][ ][ ][  ][  ][  ][  ][  ][ P][  ][  ][  ][ P]
-
-      The array pointed to by pPulseOffset == [5][1][9][4]
-
-      pPulseAmp is of the same length as pPulseOffset, and contains
-      an individual pulse amplitude for each coefficient.
-    --------------------------------------------------------------------------*/
-
-    pCoef        = &(coef[index]);
-
-    pPulseOffset = &(pPulseInfo->pulse_offset[0]);
-
-    pPulseAmp    = &(pPulseInfo->pulse_amp[0]);
-
-    for (index = pPulseInfo->number_pulse; index > 0; index--)
-    {
-        pCoef  += *pPulseOffset++;
-
-        temp = *pCoef;
-
-        if (temp > 0)
-        {
-            temp += *(pPulseAmp++);
-            *pCoef = (Int16)temp;
-            if (temp > *max)
-            {
-                *max = temp;
-            }
-        }
-        else
-        {
-            temp -= *(pPulseAmp++);
-            *pCoef = (Int16)temp;
-            if (-temp > *max)
-            {
-                *max = -temp;
-            }
-        }
-
-    } /* for() */
-
-    return;
-
-} /* pulse_nc */
diff --git a/media/libstagefright/codecs/aacdec/pulse_nc.h b/media/libstagefright/codecs/aacdec/pulse_nc.h
deleted file mode 100644
index 8181dd0..0000000
--- a/media/libstagefright/codecs/aacdec/pulse_nc.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pulse_nc.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Pass in max as input argument.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the global function declaration for pulse_nc
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PULSE_NC_H
-#define PULSE_NC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "s_pulseinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void pulse_nc(
-        Int16        coef[],
-        const PulseInfo  *pPulseInfo,
-        const FrameInfo  *pLongFrameInfo,
-        Int      *max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h b/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h
deleted file mode 100644
index dee66bc..0000000
--- a/media/libstagefright/codecs/aacdec/pv_audio_type_defs.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-------------------------------------------------------------------------------
- Pathname: ./c/include/pv_audio_type_defs.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Removed errant semicolons from #define statements
-
- Description:
-        1. Modified ifndef STD_TYPE_DEFS_H with
-           #ifndef PV_AUDIO_TYPE_DEFS_H to avoid double definition
-               if file was already included
-        2. Merged cai if-def structures and C++ definition
-            3. Updated copyright notice
-
- Description:  Added dependency on OSCL libraries
-
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file was derived from a number of standards bodies. The type
- definitions below were created from some of the best practices observed
- in the standards bodies.
-
- This file is dependent on limits.h for defining the bit widths. In an
- ANSI C environment limits.h is expected to always be present and contain
- the following definitions:
-
-     SCHAR_MIN
-     SCHAR_MAX
-     UCHAR_MAX
-
-     INT_MAX
-     INT_MIN
-     UINT_MAX
-
-     SHRT_MIN
-     SHRT_MAX
-     USHRT_MAX
-
-     LONG_MIN
-     LONG_MAX
-     ULONG_MAX
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_AUDIO_TYPE_DEFS_H
-#define PV_AUDIO_TYPE_DEFS_H
-
-#include <stdint.h>
-
-typedef int8_t        Char;
-
-typedef uint8_t       UChar;
-
-
-
-/*----------------------------------------------------------------------------
-; Define generic signed and unsigned int
-----------------------------------------------------------------------------*/
-#ifndef Int
-typedef signed int  Int;
-#endif
-
-#ifndef UInt
-typedef unsigned int    UInt;
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 16 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-#ifndef Int16
-typedef int16_t       Int16;
-#endif
-
-#ifndef INT16_MIN
-#define INT16_MIN   (-32768)
-#endif
-
-#ifndef INT16_MAX
-#define INT16_MAX   32767
-#endif
-
-#ifndef UInt16
-typedef uint16_t      UInt16;
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 32 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-#ifndef Int32
-typedef int32_t       Int32;
-#endif
-
-#ifndef INT32_MIN
-#define INT32_MIN   (-2147483647 - 1)
-#endif
-#ifndef INT32_MAX
-#define INT32_MAX   2147483647
-#endif
-
-#ifndef UInt32
-typedef uint32_t      UInt32;
-#endif
-
-#ifndef UINT32_MIN
-#define UINT32_MIN  0
-#endif
-#ifndef UINT32_MAX
-#define UINT32_MAX  0xffffffff
-#endif
-
-
-/*----------------------------------------------------------------------------
-; Define 64 bit signed and unsigned words
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; Define boolean type
-----------------------------------------------------------------------------*/
-#ifndef Bool
-typedef Int     Bool;
-#endif
-#ifndef FALSE
-#define FALSE       0
-#endif
-
-#ifndef TRUE
-#define TRUE        1
-#endif
-
-#ifndef OFF
-#define OFF     0
-#endif
-#ifndef ON
-#define ON      1
-#endif
-
-#ifndef NO
-#define NO      0
-#endif
-#ifndef YES
-#define YES     1
-#endif
-
-#ifndef SUCCESS
-#define SUCCESS     0
-#endif
-
-#ifndef  NULL
-#define  NULL       0
-#endif
-
-
-#endif  /* PV_AUDIO_TYPE_DEFS_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_div.cpp b/media/libstagefright/codecs/aacdec/pv_div.cpp
deleted file mode 100644
index 86d2487..0000000
--- a/media/libstagefright/codecs/aacdec/pv_div.cpp
+++ /dev/null
@@ -1,188 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_div.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer numerator
-    Int32 y             32-bit integer denominator
-    Quotient *result    structure that hold result and shift factor
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement division of two Int32 numbers, provides back quotient and a
-    shift factor
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "pv_div.h"
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void pv_div(Int32 x, Int32 y, Quotient *result)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    Int32 quotient;
-    Int32 i;
-    Int32 j;
-    Int32 y_ov_y_hi;
-    Int32 flag = 0;     /* carries negative sign, if any  */
-
-
-    result->shift_factor = 0;   /* default  */
-
-    if (y == 0)
-    {
-        x = 0;   /* this will return 0 for any div/0 */
-    }
-    /*
-     *  make sure x and y are both positive
-     */
-
-    if (y < 0)
-    {
-        y = -y;
-        flag ^= 1;
-    }
-
-
-    if (x < 0)
-    {
-        x = -x;
-        flag ^= 1;
-    }
-
-    if (x != 0)
-    {
-        /*----------------------------------------------------------------------------
-        ; Scale the input to get maximum precision for x
-        ----------------------------------------------------------------------------*/
-
-        i = pv_normalize(x);
-
-        x <<= i;
-
-
-        /*----------------------------------------------------------------------------
-        ; Scale the input to get maximum precision for y
-        ----------------------------------------------------------------------------*/
-
-        j = pv_normalize(y);
-
-        y <<= j;
-
-        result->shift_factor = i - j;
-
-        /*----------------------------------------------------------------------------
-        ; Function body here
-        ----------------------------------------------------------------------------*/
-        /*---------------------------------------------------------------
-         ; take the inverse of the 16 MSB of y
-         ---------------------------------------------------------------*/
-
-        quotient = (0x40000000 / (y >> 15));
-
-        y_ov_y_hi = fxp_mul32_Q15(y, quotient);            /*  y*(1/y_hi)     */
-
-        y_ov_y_hi = 0x7FFFFFFF - y_ov_y_hi;                 /*  2 - y*(1/y_hi) */
-        y_ov_y_hi = fxp_mul32_Q14(quotient,  y_ov_y_hi);
-        i  = fxp_mul32_Q31(y_ov_y_hi,  x) << 1;
-
-        result->quotient = flag ? -i : i;
-    }
-    else
-    {
-        result->quotient = 0;
-    }
-
-
-
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_div.h b/media/libstagefright/codecs/aacdec/pv_div.h
deleted file mode 100644
index 2dfa8a0..0000000
--- a/media/libstagefright/codecs/aacdec/pv_div.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_div.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_DIV_H
-#define PV_DIV_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    struct intg_div
-    {
-        Int32 quotient;
-        Int32 shift_factor;
-    };
-    typedef struct intg_div Quotient;
-
-
-    void pv_div(Int32 x, Int32 y, Quotient *quotient);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* PV_DIV_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_log2.cpp b/media/libstagefright/codecs/aacdec/pv_log2.cpp
deleted file mode 100644
index 69cbe91..0000000
--- a/media/libstagefright/codecs/aacdec/pv_log2.cpp
+++ /dev/null
@@ -1,168 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_log2.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer input
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement the logarithm base 2 of a number
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_log2.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     20
-#define Q_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 log_table[9] =
-{
-    Q_fmt(-0.00879832091331F),  Q_fmt(0.12022974263833F),
-    Q_fmt(-0.72883958314294F),  Q_fmt(2.57909824242332F),
-    Q_fmt(-5.90041216630330F),  Q_fmt(9.15023342527264F),
-    Q_fmt(-9.90616619500413F),  Q_fmt(8.11228968755409F),
-    Q_fmt(-3.41763474309898F)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-Int32 pv_log2(Int32 z)
-{
-    const Int32 *pt_table = log_table;
-    Int32 y;
-    Int32 i;
-
-    Int32 int_log2 = 0;
-
-    if (z > Q_fmt(2.0f))
-    {
-        while (z > Q_fmt(2.0f))
-        {
-            z >>= 1;
-            int_log2++;
-        }
-    }
-    else if (z < Q_fmt(1.0f))
-    {
-        {
-            while (z < Q_fmt(1.0f))
-            {
-                z <<= 1;
-                int_log2--;
-            }
-        }
-    }
-
-    /*
-     *  at this point, input limited to 1<x<2
-     */
-
-    if (z != Q_fmt(1.0f))
-    {
-        y  = fxp_mul32_Q20(*(pt_table++), z);
-
-        for (i = 7; i != 0; i--)
-        {
-            y += *(pt_table++);
-            y  = fxp_mul32_Q20(y, z);
-        }
-
-        y += *(pt_table++);
-    }
-    else
-    {
-        y = 0;
-    }
-
-
-    return (y + (int_log2 << 20));         /* Q20 */
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/pv_log2.h b/media/libstagefright/codecs/aacdec/pv_log2.h
deleted file mode 100644
index 4834e82..0000000
--- a/media/libstagefright/codecs/aacdec/pv_log2.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_log2.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_LOG2_H
-#define PV_LOG2_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    Int32 pv_log2(Int32 z);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* PV_LOG2_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_normalize.cpp b/media/libstagefright/codecs/aacdec/pv_normalize.cpp
deleted file mode 100644
index 365b5ad..0000000
--- a/media/libstagefright/codecs/aacdec/pv_normalize.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_normalize.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-Input
-    Int32 x             32-bit integer non-zero input
-Returns
-    Int32 i             number of leading zeros on x
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Returns number of leading zeros on the non-zero input
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "pv_normalize.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#if defined(_ARM)
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-/* function is inlined in header file */
-
-
-#else
-
-Int pv_normalize(Int32 x)
-{
-    /*----------------------------------------------------------------------------
-    ; Define all local variables
-    ----------------------------------------------------------------------------*/
-    Int i;
-
-
-    if (x > 0x0FFFFFFF)
-    {
-        i = 0;  /* most likely case */
-    }
-    else if (x > 0x00FFFFFF)
-    {
-        i = 3;  /* second most likely case */
-    }
-    else if (x > 0x0000FFFF)
-    {
-        i  = x > 0x000FFFFF ?  7 :  11;
-    }
-    else
-    {
-        if (x > 0x000000FF)
-        {
-            i  = x > 0x00000FFF ?  15 :  19;
-        }
-        else
-        {
-            i  = x > 0x0000000F ?  23 :  27;
-        }
-    }
-
-
-    x <<= i;
-
-    switch (x & 0x78000000)
-    {
-        case 0x08000000:
-            i += 3;
-            break;
-
-        case 0x18000000:
-        case 0x10000000:
-            i += 2;
-            break;
-        case 0x28000000:
-        case 0x20000000:
-        case 0x38000000:
-        case 0x30000000:
-            i++;
-
-        default:
-            ;
-    }
-
-    return i;
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/pv_normalize.h b/media/libstagefright/codecs/aacdec/pv_normalize.h
deleted file mode 100644
index dce080e..0000000
--- a/media/libstagefright/codecs/aacdec/pv_normalize.h
+++ /dev/null
@@ -1,105 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Pathname: pv_normalize.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_NORMALIZE_H
-#define PV_NORMALIZE_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES AND SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-#if defined(_ARM)
-
-__inline Int pv_normalize(Int32 x)
-{
-    Int32 y;
-    __asm
-    {
-        clz y, x;
-        sub y, y, #1
-    }
-    return (y);
-}
-
-
-#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
-
-__inline Int pv_normalize(Int32 x)
-{
-    register Int32 y;
-    register Int32 ra = x;
-
-
-    asm volatile(
-        "clz %0, %1\n\t"
-        "sub %0, %0, #1"
-    : "=&r*i"(y)
-                : "r"(ra));
-    return (y);
-
-}
-
-#else
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int pv_normalize(Int32 x);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
-
-
-
-#endif  /* PV_NORMALIZE_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_pow2.cpp b/media/libstagefright/codecs/aacdec/pv_pow2.cpp
deleted file mode 100644
index 8dfca23..0000000
--- a/media/libstagefright/codecs/aacdec/pv_pow2.cpp
+++ /dev/null
@@ -1,170 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_pow2.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-Input
-    Int32 x             32-bit integer input  Q27
-
-Output
-    Int32               32-bit integer in Q25
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement the power base 2 for positive numbers lesser than 5.999999
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-#ifdef AAC_PLUS
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_pow2.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#define POW_2_TABLE_LENGTH          6
-#define POW_2_TABLE_LENGTH_m_2      (POW_2_TABLE_LENGTH - 2)
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     29
-#define Q_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-#define Q27fmt(x)   (Int32)(x*((Int32)1<<27) + (x>=0?0.5F:-0.5F))
-
-const Int32 pow2_table[6] =
-{
-    Q_fmt(0.00224510927441F),   Q_fmt(0.00777943379416F),
-    Q_fmt(0.05737929218747F),   Q_fmt(0.23918017179889F),
-    Q_fmt(0.69345251849351F),   Q_fmt(0.99996347120248F)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-/*
- *      z in Q27 format
- */
-
-Int32 pv_pow2(Int32 z)
-{
-    const Int32 *pt_table = pow2_table;
-    Int32 multiplier = 0;
-    Int32 shift_factor;
-    Int32 i;
-    Int32 v_q;
-    Int32 y;
-
-
-    if (z > Q27fmt(1.0f))
-    {
-        v_q = z - (z & 0xF8000000);
-        shift_factor =   z >> 27;
-    }
-    else
-    {
-        v_q = z;
-        shift_factor = 0;
-    }
-
-    if (v_q < Q27fmt(0.5f))
-    {
-        v_q += Q27fmt(0.5f);
-        multiplier = Q_fmt(0.70710678118655F);
-    }
-
-    v_q = v_q << 2;
-
-    y  = fxp_mul32_Q29(*(pt_table++), v_q);
-
-    for (i = POW_2_TABLE_LENGTH_m_2; i != 0; i--)
-    {
-        y += *(pt_table++);
-        y  = fxp_mul32_Q29(y, v_q);
-    }
-    y += *(pt_table++);
-
-    if (multiplier)
-    {
-        y = fxp_mul32_Q29(y, multiplier);
-    }
-
-    /*
-     *  returns number on Q25
-     */
-    return (y >> (4 - shift_factor));
-
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/pv_pow2.h b/media/libstagefright/codecs/aacdec/pv_pow2.h
deleted file mode 100644
index 04bfe93..0000000
--- a/media/libstagefright/codecs/aacdec/pv_pow2.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_pow2.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_POW2_H
-#define PV_POW2_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    Int32 pv_pow2(Int32 z);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* PV_POW2_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_sine.cpp b/media/libstagefright/codecs/aacdec/pv_sine.cpp
deleted file mode 100644
index 54319b1..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sine.cpp
+++ /dev/null
@@ -1,182 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_sine.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer angle (in Q30) between 0 and pi/2
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Find the sine of a number between 0 and pi/2
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-#ifdef PARAMETRICSTEREO
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "pv_sine.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     30
-
-#define Q_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 sin_table[9] =
-{
-    Q_fmt(0.00001724684028), Q_fmt(-0.00024606242846),
-    Q_fmt(0.00007297328923), Q_fmt(0.00826706596417),
-    Q_fmt(0.00003585160465), Q_fmt(-0.16667772526248),
-    Q_fmt(0.00000174197440), Q_fmt(0.99999989138797),
-    Q_fmt(0.00000000110513)
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-Int32 pv_sine(Int32 z)
-{
-    Int32 sine;
-    Int32 i;
-    const Int32 *pt_table = sin_table;
-    Int32 sign = 0;
-
-    if (z < 0)
-    {
-        z = -z;
-        sign = 1;
-    }
-
-    if (z > Q_fmt(0.0015))
-    {
-        sine  = fxp_mul32_Q30(*(pt_table++), z);
-
-        for (i = 7; i != 0; i--)
-        {
-            sine += *(pt_table++);
-            sine  = fxp_mul32_Q30(sine, z);
-        }
-
-    }
-    else
-    {
-        sine = z;  /*  better approximation in this range */
-    }
-
-    if (sign)
-    {
-        sine = -sine;
-    }
-
-    return sine;
-}
-
-
-
-Int32 pv_cosine(Int32 z)
-{
-    Int32 cosine;
-
-    if (z < 0)
-    {
-        z = -z;     /* sign does not play a role in cosine */
-    }
-
-    if (z > Q_fmt(0.0015))
-    {
-        z = Q_fmt(1.57079632679490) - z;   /* pi/2 - z */
-
-        cosine  = pv_sine(z);
-    }
-    else
-    {   /*  better approximation in this range  */
-        cosine = Q_fmt(0.99999999906868) - (fxp_mul32_Q30(z, z) >> 1);
-    }
-
-    return cosine;
-}
-
-#endif
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_sine.h b/media/libstagefright/codecs/aacdec/pv_sine.h
deleted file mode 100644
index 145013a..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sine.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_sine.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_SINE_H
-#define PV_SINE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    Int32 pv_sine(Int32 x);
-    Int32 pv_cosine(Int32 x);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* PV_SINE_H */
diff --git a/media/libstagefright/codecs/aacdec/pv_sqrt.cpp b/media/libstagefright/codecs/aacdec/pv_sqrt.cpp
deleted file mode 100644
index 065fa38..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sqrt.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: pv_sqrt.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 x             32-bit integer
-
-    Int32 y             32-bit integer
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-
-#include "fxp_mul32.h"
-#include "pv_sqrt.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#define R_SHIFT     28
-#define Q_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-
-const Int32 sqrt_table[9] =
-{
-    Q_fmt(-0.13829740941110F),  Q_fmt(0.95383399963991F),
-    Q_fmt(-2.92784603873353F),  Q_fmt(5.27429191920042F),
-    Q_fmt(-6.20272445821478F),  Q_fmt(5.04717433019620F),
-    Q_fmt(-3.03362807640415F),  Q_fmt(1.86178814410910F),
-    Q_fmt(0.16540758699193F)
-};
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache)
-{
-
-    Int32   y;
-    Int32   xx;
-    Int32   nn;
-    Int32   i;
-    const Int32 *pt_table = sqrt_table;
-
-
-    if (sqrt_cache[0] == man && sqrt_cache[1] == exp)
-    {
-        result->root         =        sqrt_cache[2];
-        result->shift_factor = (Int16)sqrt_cache[3];
-    }
-    else
-    {
-
-        sqrt_cache[0] = man;
-        sqrt_cache[1] = exp;
-
-
-        if (man > 0)
-        {
-            xx =  man;
-            if (man >= Q_fmt(1.0f))
-            {
-                nn = exp + 1;
-                while ((xx >>= 1) > Q_fmt(1.0f))
-                {
-                    nn++;
-                }
-            }
-            else if (man < Q_fmt(0.5f))
-            {
-                nn = exp - 1;
-                while ((xx <<= 1) < Q_fmt(0.5f))
-                {
-                    nn--;
-                }
-            }
-            else
-            {
-                nn = exp;
-            }
-
-
-            y  = fxp_mul32_Q28(*(pt_table++), xx);
-
-            for (i = 3; i != 0; i--)
-            {
-                y += *(pt_table++);
-                y  = fxp_mul32_Q28(y, xx);
-                y += *(pt_table++);
-                y  = fxp_mul32_Q28(y, xx);
-            }
-            y += *(pt_table++);
-            y  = fxp_mul32_Q28(y, xx) + *(pt_table++);
-
-            if (nn >= 0)
-            {
-                if (nn&1)
-                {
-                    y = fxp_mul32_Q29(y, Q_fmt(1.41421356237310F));
-                    result->shift_factor = (nn >> 1) - 28;
-                }
-                else
-                {
-                    result->shift_factor = (nn >> 1) - 29;
-                }
-            }
-            else
-            {
-                if (nn&1)
-                {
-                    y = fxp_mul32_Q28(y, Q_fmt(0.70710678118655F));
-                }
-
-                result->shift_factor = -((-nn) >> 1) - 29;
-            }
-
-            result->root = y;
-
-        }
-        else
-        {
-            result->root = 0;
-            result->shift_factor = 0;
-        }
-
-    }
-
-    sqrt_cache[2] = result->root;
-    sqrt_cache[3] = result->shift_factor;
-
-}
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/pv_sqrt.h b/media/libstagefright/codecs/aacdec/pv_sqrt.h
deleted file mode 100644
index 45d6f52..0000000
--- a/media/libstagefright/codecs/aacdec/pv_sqrt.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pv_sqrt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef PV_SQRT_H
-#define PV_SQRT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    struct intg_sqrt
-    {
-        Int32 root;
-        Int32 shift_factor;
-    };
-    typedef struct intg_sqrt Root_sq;
-
-    void pv_sqrt(Int32 man, Int32 exp, Root_sq *result, Int32 *sqrt_cache);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* PV_SQRT_H */
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h b/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h
deleted file mode 100644
index 7806f88..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoder_api.h
+++ /dev/null
@@ -1,376 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Name: PVMP4AudioDecoder_API.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change buffer type to UChar
-
- Description: Update comments
-
- Description: Updated a comment that MT did not get around to
- before the end of his contract.
-
- Description: add a new API to decode audioSpecificConfig separately, the same
-              change has been made on 32-bits version (element \main\2)
-
- Description: add a new API to reset history buffer, the same change has been
-              made on a 32-bits version(element \nd.e0352.wjin\1)
-
- Who:                                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Main header file for the Packet Video MP4/AAC audio decoder library. The
- constants, structures, and functions defined within this file, along with
- a basic data types header file, is all that is needed to use and communicate
- with the library. The internal data structures within the library are
- purposely hidden.
-
- ---* Need description of the input buffering. *-------
-
- ---* Need an example of calling the library here *----
-
-------------------------------------------------------------------------------
- REFERENCES
-
-  (Normally header files do not have a reference section)
-
-  ISO/EIC 14496-3:(1999) Document titled
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef PVMP4AUDIODECODER_API_H
-#define PVMP4AUDIODECODER_API_H
-
-#include "pv_audio_type_defs.h"  /* Basic data types used within the lib */
-
-#include "e_tmp4audioobjecttype.h"
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*
-     * This constant is the guaranteed-to-work buffer size, specified in bytes,
-     * for the input buffer for 2 audio channels to decode one frame of data,
-     * as specified by the MPEG-2 or MPEG-4 standard.
-     * The standard, and this constant, do not take into account that lower
-     * bitrates will use less data per frame. Note that the number of bits
-     * used per frame is variable, and only that the average value will be the
-     * bit rate specified during encoding. The standard does not specify
-     * over how many frames the average must be maintained.
-     *
-     * The constant value is 6144 * 2 channels / 8 bits per byte
-     */
-
-
-#define PVMP4AUDIODECODER_INBUFSIZE  1536
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    /*
-     * This enumeration is used for the structure element outputFormat. It
-     * specifies how the output data is to be formatted. Presently only 16-bit
-     * PCM data is supported, and this enum informs how the single output
-     * buffer should be for two-channel stereo data.
-     * Grouped format stores all the left channel values, then right:
-     * "LLLL...LLRRRR...RR"
-     * Interleave format store left, then right audio samples:
-     * "LRLRLRLR...."
-     */
-    typedef enum ePVMP4AudioDecoderOutputFormat
-    {
-        OUTPUTFORMAT_16PCM_GROUPED = 0,
-        OUTPUTFORMAT_16PCM_INTERLEAVED = 1
-
-    } tPVMP4AudioDecoderOutputFormat;
-
-    /*
-     * This enumeration holds the possible return values for the main decoder
-     * function, PVMP4AudioDecodeFrame. The plan was to easily distinguish
-     * whether an error was recoverable (streaming mode) or not. Presently no
-     * errors are recoverable, which is a result of not supporting ADTS in
-     * this release.
-     */
-    typedef enum ePVMP4AudioDecoderErrorCode
-    {
-        MP4AUDEC_SUCCESS           =  0,
-        MP4AUDEC_INVALID_FRAME     = 10,
-        MP4AUDEC_INCOMPLETE_FRAME  = 20,
-        MP4AUDEC_LOST_FRAME_SYNC   = 30     /* Cannot happen since no ADTS */
-    } tPVMP4AudioDecoderErrorCode;
-
-
-    /*
-     * This enumeration holds the possible return values for stream type
-     * being decoded
-     */
-    typedef enum
-    {
-        AAC = 0,
-        AACPLUS,
-        ENH_AACPLUS
-    } STREAMTYPE;
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    /*
-     * This structure is used to communicate information in to and out of the
-     * AAC decoder.
-     */
-
-    typedef struct
-#ifdef __cplusplus
-                tPVMP4AudioDecoderExternal  // To allow forward declaration of this struct in C++
-#endif
-    {
-        /*
-         * INPUT:
-         * Pointer to the input buffer that contains the encoded bistream data.
-         * The data is filled in such that the first bit transmitted is
-         * the most-significant bit (MSB) of the first array element.
-         * The buffer is accessed in a linear fashion for speed, and the number of
-         * bytes consumed varies frame to frame.
-         * The calling environment can change what is pointed to between calls to
-         * the decode function, library, as long as the inputBufferCurrentLength,
-         * and inputBufferUsedLength are updated too. Also, any remaining bits in
-         * the old buffer must be put at the beginning of the new buffer.
-         */
-        UChar  *pInputBuffer;
-
-        /*
-         * INPUT:
-         * Number of valid bytes in the input buffer, set by the calling
-         * function. After decoding the bitstream the library checks to
-         * see if it when past this value; it would be to prohibitive to
-         * check after every read operation. This value is not modified by
-         * the AAC library.
-         */
-        Int     inputBufferCurrentLength;
-
-        /*
-         * INPUT:
-         * The actual size of the buffer.
-         * This variable is not used by the library, but is used by the
-         * console test application. This parameter could be deleted
-         * if this value was passed into these function. The helper functions are
-         * not part of the library and are not used by the Common Audio Decoder
-         * Interface.
-         */
-        Int     inputBufferMaxLength;
-
-        /*
-         * INPUT:
-         * Enumerated value the output is to be interleaved left-right-left-right.
-         * For further information look at the comments for the enumeration.
-         */
-        tPVMP4AudioDecoderOutputFormat  outputFormat;
-
-        /*
-         * INPUT: (but what is pointed to is an output)
-         * Pointer to the output buffer to hold the 16-bit PCM audio samples.
-         * If the output is stereo, both left and right channels will be stored
-         * in this one buffer. Presently it must be of length of 2048 points.
-         * The format of the buffer is set by the parameter outputFormat.
-         */
-        Int16  *pOutputBuffer;
-
-        /*
-         * INPUT: (but what is pointed to is an output)
-         * Pointer to the output buffer to hold the 16-bit PCM AAC-plus audio samples.
-         * If the output is stereo, both left and right channels will be stored
-         * in this one buffer. Presently it must be of length of 2048 points.
-         * The format of the buffer is set by the parameter outputFormat.
-         */
-        Int16  *pOutputBuffer_plus;     /* Used in AAC+ and enhanced AAC+  */
-
-        /*
-         * INPUT:
-         * AAC Plus Upsampling Factor. Normally set to 2 when Spectrum Band
-         * Replication (SBR) is used
-         */
-        Int32  aacPlusUpsamplingFactor; /* Used in AAC+ and enhanced AAC+  */
-
-        /*
-         * INPUT:
-         * AAC Plus enabler. Deafaults to be ON, unless run time conditions
-         * require the SBR and PS tools disabled
-         */
-        bool    aacPlusEnabled;
-        /*
-         * INPUT:
-         * (Currently not being used inside the AAC library.)
-         * This flag is set to TRUE when the playback position has been changed,
-         * for example, rewind or fast forward. This informs the AAC library to
-         * take an appropriate action, which has yet to be determined.
-         */
-        Bool    repositionFlag;
-
-        /*
-         * INPUT:
-         * Number of requested output audio channels. This relieves the calling
-         * environment from having to perform stereo-to-mono or mono-to-stereo
-         * conversions.
-         */
-        Int     desiredChannels;
-
-        /*
-         * INPUT/OUTPUT:
-         * Number of elements used by the library, initially set to zero by
-         * the function PVMP4AudioDecoderInitLibrary, and modified by each
-         * call to PVMP4AudioDecodeFrame.
-         */
-        Int     inputBufferUsedLength;
-
-        /*
-         * INPUT/OUTPUT:
-         * Number of bits left over in the next buffer element,
-         * This value will always be zero, unless support for ADTS is added.
-         */
-        Int32    remainderBits;
-
-        /*
-         * OUTPUT:
-         * The sampling rate decoded from the bitstream, in units of
-         * samples/second. For this release of the library this value does
-         * not change from frame to frame, but future versions will.
-         */
-        Int32   samplingRate;
-
-        /*
-         * OUTPUT:
-         * This value is the bitrate in units of bits/second. IT
-         * is calculated using the number of bits consumed for the current frame,
-         * and then multiplying by the sampling_rate, divided by points in a frame.
-         * This value can changes frame to frame.
-         */
-        Int32   bitRate;
-
-        /*
-         * OUTPUT:
-         * The number of channels decoded from the bitstream. The output data
-         * will have be the amount specified in the variable desiredChannels,
-         * this output is informative only, and can be ignored.
-         */
-        Int     encodedChannels;
-
-        /*
-         * OUTPUT:
-         * This value is the number of output PCM samples per channel.
-         * It is presently hard-coded to 1024, but may change in the future.
-         * It will not change frame to frame, and would take on
-         * one of these four values: 1024, 960, 512, or 480. If an error occurs
-         * do not rely on this value.
-         */
-        Int     frameLength;
-
-        /*
-        * This value is audio object type as defined in struct tMP4AudioObjectType
-        * in file e_tMP4AudioObjectType.h
-        */
-        Int     audioObjectType;
-
-        /*
-        * This value is extended audio object type as defined in struct tMP4AudioObjectType
-        * in file e_tMP4AudioObjectType.h. It carries the output Audio Object Type
-        */
-        Int     extendedAudioObjectType;
-
-
-    } tPVMP4AudioDecoderExternal;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    OSCL_IMPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void);
-
-    OSCL_IMPORT_REF Int PVMP4AudioDecoderInitLibrary(
-        tPVMP4AudioDecoderExternal  *pExt,
-        void                        *pMem);
-
-    OSCL_IMPORT_REF Int PVMP4AudioDecodeFrame(
-        tPVMP4AudioDecoderExternal  *pExt,
-        void                        *pMem);
-
-    OSCL_IMPORT_REF Int PVMP4AudioDecoderConfig(
-        tPVMP4AudioDecoderExternal  *pExt,
-        void                        *pMem);
-
-    OSCL_IMPORT_REF void PVMP4AudioDecoderResetBuffer(
-        void                        *pMem);
-
-    OSCL_IMPORT_REF void PVMP4AudioDecoderDisableAacPlus(
-        tPVMP4AudioDecoderExternal  *pExt,
-        void                        *pMem);
-
-    Int PVMP4SetAudioConfig(
-        tPVMP4AudioDecoderExternal  *pExt,
-        void                        *pMem,
-        Int                         upsamplingFactor,
-        Int                         samp_rate,
-        int                         num_ch,
-        tMP4AudioObjectType         audioObjectType);
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif  /* PVMP4AUDIODECODER_API_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp
deleted file mode 100644
index 9208fa8..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderconfig.cpp
+++ /dev/null
@@ -1,285 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderConfig
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) Modified to decode AudioSpecificConfig for any frame number
-                  pVars->bno
-              (2) Update the input and output descriptions
-
- Description: Eliminated search for ADIF header
-
- Description: Added support for AAC+
-
- Who:                                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pExt = pointer to the external interface structure. See the file
-           PVMP4AudioDecoder_API.h for a description of each field.
-           Data type of pointer to a tPVMP4AudioDecoderExternal
-           structure.
-
-           pExt->pInputBuffer: pointer to input buffer containing input
-                               bitstream
-
-           pExt->inputBufferCurrentLength: number of bytes in the input buffer
-
-           pExt->inputBufferUsedLength: number of bytes already consumed in
-                                        input buffer
-
-           pExt->remainderBits: number of bits consumed in addition to
-                                pExt->inputBufferUsedLength
-
-    pMem = void pointer to hide the internal implementation of the library
-           It is cast back to a tDec_Int_File structure. This structure
-           contains information that needs to persist between calls to
-           this function, or is too big to be placed on the stack, even
-           though the data is only needed during execution of this function
-           Data type void pointer, internally pointer to a tDec_Int_File
-           structure.
-
- Local Stores/Buffers/Pointers Needed: None
-           (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-     status = 0                       if no error occurred
-              MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
-              MP4AUDEC_RECOVERABLE    if a recoverable error occurred.
-              Presently a recoverable error does not exist, but this
-              was a requirement.
-
-
- Pointers and Buffers Modified:
-    pMem contents are modified.
-    pExt: (more detail in the file PVMP4AudioDecoder_API.h)
-    inputBufferUsedLength - number of array elements used up by the stream.
-    remainderBits - remaining bits in the next UInt32 buffer
-    samplingRate - sampling rate in samples per sec
-    encodedChannels - channels found on the file (informative)
-    frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
-      subclause 1.6
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h"           /* where #define INBUF_ARRAY_INDEX_SHIFT */
-#include "sfb.h"                   /* Where samp_rate_info[] is declared */
-
-#include "get_audio_specific_config.h"
-#include "pvmp4audiodecoder_api.h"   /* Where this function is declared */
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-OSCL_EXPORT_REF Int PVMP4AudioDecoderConfig(
-    tPVMP4AudioDecoderExternal  *pExt,
-    void                        *pMem)
-{
-
-    UInt           initialUsedBits;  /* Unsigned for C55x */
-    tDec_Int_File *pVars;           /* Helper pointer */
-
-    Int            status = MP4AUDEC_INCOMPLETE_FRAME;
-
-    /*
-     * Initialize "helper" pointers to existing memory.
-     */
-    pVars = (tDec_Int_File *)pMem;
-    /*
-     * Translate input buffer variables.
-     */
-    pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
-    pVars->inputStream.inputBufferCurrentLength =
-        (UInt)pExt->inputBufferCurrentLength;
-
-    pVars->inputStream.availableBits =
-        (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);
-
-    initialUsedBits =
-        (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
-               pExt->remainderBits);
-
-    pVars->inputStream.usedBits = initialUsedBits;
-
-    if (initialUsedBits <= pVars->inputStream.availableBits)
-    {
-
-        /*
-         * Buffer is not overrun, then
-         * decode the AudioSpecificConfig() structure
-         */
-
-        pVars->aacConfigUtilityEnabled = false;  /* set aac dec mode */
-
-        status = get_audio_specific_config(pVars);
-
-    }
-
-    byte_align(&pVars->inputStream);
-
-
-    if (status == SUCCESS)
-    {
-
-        pVars->bno++;
-
-        /*
-         * A possible improvement would be to set these values only
-         * when they change.
-         */
-        pExt->samplingRate =
-            samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate;
-
-        /*
-         *  we default to 2 channel, even for mono files, (where channels have same content)
-         *  this is done to ensure support for enhanced aac+ with implicit signalling
-         */
-        pExt->aacPlusEnabled = pVars->aacPlusEnabled;
-
-//        pExt->encodedChannels = pVars->mc_info.nch;
-
-        pExt->encodedChannels = 2;
-
-        pExt->frameLength = pVars->frameLength;
-#ifdef AAC_PLUS
-        pExt->aacPlusUpsamplingFactor = pVars->mc_info.upsamplingFactor;
-#endif
-
-    }
-    else
-    {
-        /*
-         *  Default to nonrecoverable error status unless there is a Buffer overrun
-         */
-        status = MP4AUDEC_INVALID_FRAME;
-
-        if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
-        {
-            /* all bits were used but were not enough to complete parsing */
-            pVars->inputStream.usedBits = pVars->inputStream.availableBits;
-
-            status = MP4AUDEC_INCOMPLETE_FRAME; /* audio config too small */
-        }
-
-    }
-
-    /*
-     * Translate from units of bits back into units of words.
-     */
-
-    pExt->inputBufferUsedLength =
-        pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
-    pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
-    pVars->status = status;
-
-    return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp
deleted file mode 100644
index 7a279dc..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderframe.cpp
+++ /dev/null
@@ -1,1458 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pvmp4audiodecodeframe
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Pulled in loop structure from console.c, so that this function
-               now decodes all frames in the file.
-
-               Original program used several global variables.  These have been
-               eliminated, except for situations in which the global variables
-               could be converted into const types.  Otherwise, they are passed
-               by reference through the functions.
-
- Description:  Begin mods for file I/O removal
-
- Description:  Merged trans4m_freq_2_time, trans4m_time_2_freq, etc.
-
- Description:  Removing commented out sections of code.  This includes the
-               removal of unneeded functions init_lt_pred, reset_mc_info,
-
- Description: Copied from aac_decode_frame.c and renamed file,
-              Made many changes.
-
- Description: Prepare for code review
-
- Description: Update per review comments:
-              1) Add comment about leaveGetLoop
-              2) Remove inverseTNSCoef array
-              3) fix wnd_shape_this_bk to wnd_shape_prev_bk in F to T
-              4) Clean up comments
-              5) Change call to long_term_synthesis
-
- Description: Remove division for calculation of bitrate.
-
- Description: Remove update of LTP buffers if not LTP audio object type.
-
- Description: Add hasmask to call to right_ch_sfb_tools_ms
-
- Description:
- Modified to call ltp related routines on the left channel
- before intensity is called on the right channel.  The previous version
- was causing a problem when IS was used on the right channel and LTP
- on the left channel for the same scalefactor band.
-
- This fix required creating a new function, apply_ms_synt, deleting another
- function (right_ch_sfb_tools_noms.c), and modifying the calling order of
- the other functions.
-
- Description: Made changes per review comments.
-
- Description: Changed name of right_ch_sfb_tools_ms to pns_intensity_right
-
- Description: Added cast, since pVars->inputStream.usedBits is UInt, and
- pExt->remainderBits is Int.
-
- pExt->remainderBits =
-    (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK);
-
- Description: Modified to pass a pointer to scratch memory into
- tns_setup_filter.c
-
- Description: Removed include of "s_TNSInfo.h"
-
- Description: Removed call to "tns_setup_filter" which has been eliminated
- by merging its functionality into "get_tns"
-
- Description:  Passing in a pointer to a q-format array, rather than
- the address of a single q-format, for the inverse filter case for
- apply_tns.
-
- Description:
- (1) Added #include of "e_ElementId.h"
-     Previously, this function was relying on another include file
-     to include "e_ElementId.h"
-
- (2) Updated the copyright header.
-
- Description:
- Per review comments, declared two temporary variables
-
-    pChLeftShare  = pChVars[LEFT]->pShareWfxpCoef;
-    pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
-
- Description:
-    long_term_synthesis should have been invoked with max_sfb
-    as the 2nd parameter, rather than pFrameInfo->sfb_per_win[0].
-
-    Old
-                long_term_synthesis(
-                    pChVars[ch]->wnd,
-                    pFrameInfo->sfb_per_win[0] ...
-
-    Correction
-                long_term_synthesis(
-                    pChVars[ch]->wnd,
-                    pChVars[ch]->pShareWfxpCoef->max_sfb ...
-
-    This problem caused long_term_synthesis to read memory which
-    was not initialized in get_ics_info.c
-
- Description:
- (1) Utilize scratch memory for the scratch Prog_Config.
-
- Description: (1) Modified to decode ID_END syntactic element after header
-
- Description:
- (1) Reconfigured LTP buffer as a circular buffer.  This saves
-     2048 Int16->Int16 copies per frame.
-
- Description: Updated so ltp buffers are not used as a wasteful
- intermediate buffer for LC streams.  Data is transferred directly
- from the filterbank to the output stream.
-
- Description: Decode ADIF header if frame count is zero.
-              The AudioSpecificConfig is decoded by a separate API.
-
- Description: Added comments explaining how the ltp_buffer_state
- variable is updated.
-
-
- Description: Modified code to take advantage of new trans4m_freq_2_time_fxp,
- which writes the output directly into a 16-bit output buffer.  This
- improvement allows faster operation by reducing the amount of memory
- transfers.  Speed can be further improved on most platforms via use of a
- DMA transfer in the function write_output.c
-
- Description: perChan[] is an array of structures in tDec_Int_File. Made
-              corresponding changes.
-
- Description: Included changes in interface for q_normalize() and
-              trans4m_freq_2_time_fxp.
-
- Description: Included changes in interface for long_term_prediction.
-
- Description: Added support for DSE (Data Streaming Channel). Added
-              function get_dse() and included file get_dse.h
-
- Description: Added support for the ill-case when a raw data block contains
-              only a terminator <ID_END>. This is illegal but is added
-              for convinience
-
- Description: Added support for empty audio frames, such the one containing
-              only DSE or FILL elements. A trap was added to stop processing
-              when no audio information was sent.
-
- Description: Added support for adts format files. Added saturation to
-              floating point version of aac+ decoding
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pExt = pointer to the external interface structure. See the file
-           PVMP4AudioDecoder_API.h for a description of each field.
-           Data type of pointer to a tPVMP4AudioDecoderExternal
-           structure.
-
-    pMem = void pointer to hide the internal implementation of the library
-           It is cast back to a tDec_Int_File structure. This structure
-           contains information that needs to persist between calls to
-           this function, or is too big to be placed on the stack, even
-           though the data is only needed during execution of this function
-           Data type void pointer, internally pointer to a tDec_Int_File
-           structure.
-
- Local Stores/Buffers/Pointers Needed: None
-           (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-     status = 0                       if no error occurred
-              MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
-              MP4AUDEC_RECOVERABLE    if a recoverable error occurred.
-              Presently a recoverable error does not exist, but this
-              was a requirement.
-
-
- Pointers and Buffers Modified:
-    pMem contents are modified.
-    pExt: (more detail in the file PVMP4AudioDecoder_API.h)
-    inputBufferUsedLength - number of array elements used up by the stream.
-    remainderBits - remaining bits in the next UInt32 buffer
-    samplingRate - sampling rate in samples per sec
-    bitRate - bit rate in bits per second, varies frame to frame.
-    encodedChannels - channels found on the file (informative)
-    frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Decodes one frame of an MPEG-2/MPEG-4 encoded audio bitstream.
-
- This function calls the various components of the decoder in the proper order.
-
-
-         Left Channel                                    Right Channel
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
- #1 ____________________                           #2 ____________________
-    |                  |                              |                  |
-    | Huffman Decoding |                              | Huffman Decoding |
-    |__________________|                              |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                                |
- #3 ____________________                                       |
-    |                  |                                       |
-    |     PNS LEFT     |                                       |
-    |__________________|                                       |
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
- #4 ______________________________________________________________________
-    |                                                                    |
-    |                          Apply MS_Synt                             |
-    |____________________________________________________________________|
-             |                                                 |
-             |                                                 |
-            \|/                                                |
- #5 ____________________                                       |
-    |                  |                                       W
-    |       LTP        |                                       A
-    |__________________|                                       I
-             |                                                 T
-             |                                                 |
-             |                                                 F
-            \|/                                                O
- #6 ____________________                                       R
-    |                  |                                       |
-    |   Time -> Freq   |                                       L
-    |__________________|                                       E
-             |                                                 F
-             |                                                 T
-             |                                                 |
-            \|/                                                C
- #7 ____________________                                       H
-    |                  |                                       A
-    |    TNS Inverse   |                                       N
-    |__________________|                                       N
-             |                                                 E
-             |                                                 L
-             |                                                 |
-            \|/                                                |
- #8 ____________________                                       |
-    |                  |                                       |
-    | Long Term Synth  |                                       |
-    |__________________|                                       |
-             |                                                 |
-             |                                                \|/
-             |                                     #9 ____________________
-             |                                        |                  |
-             |--DATA ON LEFT CHANNEL MAY BE USED----->| PNS/Intensity Rt |
-             |                                        |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                \|/
-             |                                    #10 ____________________
-             W                                        |                  |
-             A                                        |       LTP        |
-             I                                        |__________________|
-             T                                                 |
-             |                                                 |
-             F                                                 |
-             O                                                \|/
-             R                                    #11 ____________________
-             |                                        |                  |
-             R                                        |   Time -> Freq   |
-             I                                        |__________________|
-             G                                                 |
-             H                                                 |
-             T                                                 |
-             |                                                \|/
-             C                                    #12 ____________________
-             H                                        |                  |
-             A                                        |    TNS Inverse   |
-             N                                        |__________________|
-             N                                                 |
-             E                                                 |
-             L                                                 |
-             |                                                \|/
-             |                                    #13 ____________________
-             |                                        |                  |
-             |                                        | Long Term Synth  |
-             |                                        |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
-#14 ____________________                          #18 ____________________
-    |                  |                              |                  |
-    |       TNS        |                              |       TNS        |
-    |__________________|                              |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
-#15 ____________________                          #19 ____________________
-    |                  |                              |                  |
-    |   qFormatNorm    |                              |   qFormatNorm    |
-    |__________________|                              |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
-#16 ____________________                          #20 ____________________
-    |                  |                              |                  |
-    |   Freq / Time    |                              |   Freq / Time    |
-    |__________________|                              |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
-#17 ____________________                          #21 ____________________
-    |                  |                              |                  |
-    |   Limit Buffer   |                              |   Limit Buffer   |
-    |__________________|                              |__________________|
-             |                                                 |
-             |                                                 |
-             |                                                 |
-            \|/                                               \|/
-#22 ______________________________________________________________________
-    |                                                                    |
-    |                           Write Output                             |
-    |____________________________________________________________________|
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#include "s_tdec_int_chan.h"
-#include "s_tdec_int_file.h"
-#include "aac_mem_funcs.h"
-#include "sfb.h"                   /* Where samp_rate_info[] is declared */
-#include "e_tmp4audioobjecttype.h"
-#include "e_elementid.h"
-
-
-#include "get_adif_header.h"
-#include "get_adts_header.h"
-#include "get_audio_specific_config.h"
-#include "ibstream.h"           /* where getbits is declared */
-
-#include "huffman.h"            /* where huffdecode is declared */
-#include "get_prog_config.h"
-#include "getfill.h"
-#include "pns_left.h"
-
-#include "apply_ms_synt.h"
-#include "pns_intensity_right.h"
-#include "q_normalize.h"
-#include "long_term_prediction.h"
-#include "long_term_synthesis.h"
-#include "ltp_common_internal.h"
-#include "apply_tns.h"
-
-#include "window_block_fxp.h"
-
-#include "write_output.h"
-
-#include "pvmp4audiodecoder_api.h"   /* Where this function is declared */
-#include "get_dse.h"
-
-#include "sbr_applied.h"
-#include "sbr_open.h"
-#include "get_sbr_bitstream.h"
-#include "e_sbr_element_id.h"
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define LEFT (0)
-#define RIGHT (1)
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-void InitSbrSynFilterbank(bool bDownSampleSBR);
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-OSCL_EXPORT_REF Int PVMP4AudioDecodeFrame(
-    tPVMP4AudioDecoderExternal  *pExt,
-    void                        *pMem)
-{
-    Int            frameLength;      /* Helper variable */
-    Int            ch;
-    Int            id_syn_ele;
-    UInt           initialUsedBits;  /* Unsigned for C55x */
-    Int            qFormatNorm;
-    Int            qPredictedSamples;
-    Bool           leaveGetLoop;
-    MC_Info       *pMC_Info;        /* Helper pointer */
-    FrameInfo     *pFrameInfo;      /* Helper pointer */
-    tDec_Int_File *pVars;           /* Helper pointer */
-    tDec_Int_Chan *pChVars[Chans];  /* Helper pointer */
-
-    per_chan_share_w_fxpCoef *pChLeftShare;  /* Helper pointer */
-    per_chan_share_w_fxpCoef *pChRightShare; /* Helper pointer */
-
-    Int            status = MP4AUDEC_SUCCESS;
-
-
-    Bool empty_frame;
-
-#ifdef AAC_PLUS
-
-    SBRDECODER_DATA *sbrDecoderData;
-    SBR_DEC         *sbrDec;
-    SBRBITSTREAM    *sbrBitStream;
-
-#endif
-    /*
-     * Initialize "helper" pointers to existing memory.
-     */
-    pVars = (tDec_Int_File *)pMem;
-
-    pMC_Info = &pVars->mc_info;
-
-    pChVars[LEFT]  = &pVars->perChan[LEFT];
-    pChVars[RIGHT] = &pVars->perChan[RIGHT];
-
-    pChLeftShare = pChVars[LEFT]->pShareWfxpCoef;
-    pChRightShare = pChVars[RIGHT]->pShareWfxpCoef;
-
-
-#ifdef AAC_PLUS
-
-    sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData;
-    sbrDec         = (SBR_DEC *) & pVars->sbrDec;
-    sbrBitStream   = (SBRBITSTREAM *) & pVars->sbrBitStr;
-
-#ifdef PARAMETRICSTEREO
-    sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec;
-#endif
-
-#endif
-    /*
-     * Translate input buffer variables.
-     */
-    pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
-    pVars->inputStream.inputBufferCurrentLength = (UInt)pExt->inputBufferCurrentLength;
-
-    pVars->inputStream.availableBits =
-        (UInt)(pExt->inputBufferCurrentLength << INBUF_ARRAY_INDEX_SHIFT);
-
-    initialUsedBits =
-        (UInt)((pExt->inputBufferUsedLength << INBUF_ARRAY_INDEX_SHIFT) +
-               pExt->remainderBits);
-
-    pVars->inputStream.usedBits = initialUsedBits;
-
-    if (initialUsedBits > pVars->inputStream.availableBits)
-    {
-        status = MP4AUDEC_INVALID_FRAME;
-    }
-    else if (pVars->bno == 0)
-    {
-        /*
-         * Attempt to read in ADIF format first because it is easily identified.
-         * If its not an ADIF bitstream, get_adif_header rewinds the "pointer"
-         * (actually usedBits).
-         */
-        status =
-            get_adif_header(
-                pVars,
-                &(pVars->scratch.scratch_prog_config));
-
-        byte_align(&pVars->inputStream);
-
-        if (status == SUCCESS)
-        {
-            pVars->prog_config.file_is_adts = FALSE;
-        }
-        else  /* we've tried simple audio config, adif, then it should be adts */
-        {
-            pVars->prog_config.file_is_adts = TRUE;
-        }
-    }
-    else if ((pVars->bno == 1) && (pVars->prog_config.file_is_adts == FALSE))
-    {
-
-        /*
-         * There might be an ID_END element following immediately after the
-         * AudioSpecificConfig header. This syntactic element should be read
-         * and byte_aligned before proceeds to decode "real" AAC raw data.
-         */
-        id_syn_ele = (Int)getbits(LEN_SE_ID, &pVars->inputStream) ;
-
-        if (id_syn_ele == ID_END)
-        {
-
-            byte_align(&pVars->inputStream);
-
-            pExt->inputBufferUsedLength =
-                pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
-            pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
-            pVars->bno++;
-
-            return(status);
-        }
-        else
-        {
-            /*
-             * Rewind bitstream pointer so that the syntactic element can be
-             * read when decoding raw bitstream
-             */
-            pVars->inputStream.usedBits -= LEN_SE_ID;
-        }
-
-    }
-
-    if (pVars->prog_config.file_is_adts == TRUE)
-    {
-        /*
-         *  If file is adts format, let the decoder handle only on data raw
-         *  block at the time, once the last (or only) data block has been
-         *  processed, then synch on the next header
-         */
-        if (pVars->prog_config.headerless_frames)
-        {
-            pVars->prog_config.headerless_frames--;  /* raw data block counter  */
-        }
-        else
-        {
-            status =  get_adts_header(pVars,
-                                      &(pVars->syncword),
-                                      &(pVars->invoke),
-                                      3);     /*   CorrectlyReadFramesCount  */
-
-            if (status != SUCCESS)
-            {
-                status = MP4AUDEC_LOST_FRAME_SYNC;    /*  we lost track of header */
-            }
-        }
-    }
-    else
-    {
-        byte_align(&pVars->inputStream);
-    }
-
-#ifdef AAC_PLUS
-    sbrBitStream->NrElements = 0;
-    sbrBitStream->NrElementsCore = 0;
-
-#endif
-
-    /*
-     * The variable leaveGetLoop is used to signal that the following
-     * loop can be left, which retrieves audio syntatic elements until
-     * an ID_END is found, or an error occurs.
-     */
-    leaveGetLoop = FALSE;
-    empty_frame  = TRUE;
-
-    while ((leaveGetLoop == FALSE) && (status == SUCCESS))
-    {
-        /* get audio syntactic element */
-        id_syn_ele = (Int)get9_n_lessbits(LEN_SE_ID, &pVars->inputStream);
-
-        /*
-         *  As fractional frames are a possible input, check that parsing does not
-         *  go beyond the available bits before parsing the syntax.
-         */
-        if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
-        {
-            status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */
-            id_syn_ele = ID_END;           /* quit while-loop */
-        }
-
-        switch (id_syn_ele)
-        {
-            case ID_END:        /* terminator field */
-                leaveGetLoop = TRUE;
-                break;
-
-            case ID_SCE:        /* single channel */
-            case ID_CPE:        /* channel pair */
-                empty_frame = FALSE;
-                status =
-                    huffdecode(
-                        id_syn_ele,
-                        &(pVars->inputStream),
-                        pVars,
-                        pChVars);
-
-#ifdef AAC_PLUS
-                if (id_syn_ele == ID_SCE)
-                {
-                    sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_SCE;
-                }
-                else if (id_syn_ele == ID_CPE)
-                {
-                    sbrBitStream->sbrElement[sbrBitStream->NrElements].ElementID = SBR_ID_CPE;
-                }
-                sbrBitStream->NrElementsCore++;
-
-
-#endif
-
-                break;
-
-            case ID_PCE:        /* program config element */
-                /*
-                 * PCE are not accepted in the middle of a
-                 * raw_data_block. If found, a possible error may happen
-                 * If a PCE is encountered during the first 2 frames,
-                 * it will be read and accepted
-                 * if its tag matches the first, with no error checking
-                 * (inside of get_prog_config)
-                 */
-
-                if (pVars->bno <= 1)
-                {
-                    status = get_prog_config(pVars,
-                                             &(pVars->scratch.scratch_prog_config));
-                }
-                else
-                {
-                    status = MP4AUDEC_INVALID_FRAME;
-                }
-                break;
-
-            case ID_FIL:        /* fill element */
-#ifdef AAC_PLUS
-                get_sbr_bitstream(sbrBitStream, &pVars->inputStream);
-
-#else
-                getfill(&pVars->inputStream);
-#endif
-
-                break;
-
-            case ID_DSE:       /* Data Streaming element */
-                get_dse(pVars->share.data_stream_bytes,
-                        &pVars->inputStream);
-                break;
-
-            default: /* Unsupported element, including ID_LFE */
-                status = -1;  /* ERROR CODE needs to be updated */
-                break;
-
-        } /* end switch() */
-
-    } /* end while() */
-
-    byte_align(&pVars->inputStream);
-
-    /*
-     *   After parsing the first frame ( bno=0 (adif), bno=1 (raw))
-     *   verify if implicit signalling is forcing to upsample AAC with
-     *   no AAC+/eAAC+ content. If so, disable upsampling
-     */
-
-#ifdef AAC_PLUS
-    if (pVars->bno <= 1)
-    {
-        if ((pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC) &&
-                (!sbrBitStream->NrElements))
-        {
-            PVMP4AudioDecoderDisableAacPlus(pExt, pMem);
-        }
-    }
-#endif
-
-    /*
-     *   There might be an empty raw data block with only a
-     *   ID_END element or non audio ID_DSE, ID_FIL
-     *   This is an "illegal" condition but this trap
-     *   avoids any further processing
-     */
-
-    if (empty_frame == TRUE)
-    {
-        pExt->inputBufferUsedLength =
-            pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
-        pExt->remainderBits = pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK;
-
-        pVars->bno++;
-
-        return(status);
-
-    }
-
-#ifdef AAC_PLUS
-
-    if (sbrBitStream->NrElements)
-    {
-        /* for every core SCE or CPE there must be an SBR element, otherwise sths. wrong */
-        if (sbrBitStream->NrElements != sbrBitStream->NrElementsCore)
-        {
-            status = MP4AUDEC_INVALID_FRAME;
-        }
-
-        if (pExt->aacPlusEnabled == false)
-        {
-            sbrBitStream->NrElements = 0;   /* disable aac processing  */
-        }
-    }
-    else
-    {
-        /*
-         *  This is AAC, but if aac+/eaac+ was declared in the stream, and there is not sbr content
-         *  something is wrong
-         */
-        if (pMC_Info->sbrPresentFlag || pMC_Info->psPresentFlag)
-        {
-            status = MP4AUDEC_INVALID_FRAME;
-        }
-    }
-#endif
-
-
-
-
-    /*
-     * Signal processing section.
-     */
-    frameLength = pVars->frameLength;
-
-    if (status == SUCCESS)
-    {
-        /*
-         *   PNS and INTENSITY STEREO and MS
-         */
-
-        pFrameInfo = pVars->winmap[pChVars[LEFT]->wnd];
-
-        pns_left(
-            pFrameInfo,
-            pChLeftShare->group,
-            pChLeftShare->cb_map,
-            pChLeftShare->factors,
-            pChLeftShare->lt_status.sfb_prediction_used,
-            pChLeftShare->lt_status.ltp_data_present,
-            pChVars[LEFT]->fxpCoef,
-            pChLeftShare->qFormat,
-            &(pVars->pns_cur_noise_state));
-
-        /*
-         * apply_ms_synt can only be ran for common windows.
-         * (where both the left and right channel share the
-         * same grouping, window length, etc.
-         *
-         * pVars->hasmask will be > 0 only if
-         * common windows are enabled for this frame.
-         */
-
-        if (pVars->hasmask > 0)
-        {
-            apply_ms_synt(
-                pFrameInfo,
-                pChLeftShare->group,
-                pVars->mask,
-                pChLeftShare->cb_map,
-                pChVars[LEFT]->fxpCoef,
-                pChVars[RIGHT]->fxpCoef,
-                pChLeftShare->qFormat,
-                pChRightShare->qFormat);
-        }
-
-        for (ch = 0; (ch < pMC_Info->nch); ch++)
-        {
-            pFrameInfo = pVars->winmap[pChVars[ch]->wnd];
-
-            /*
-             * Note: This MP4 library assumes that if there are two channels,
-             * then the second channel is right AND it was a coupled channel,
-             * therefore there is no need to check the "is_cpe" flag.
-             */
-
-            if (ch > 0)
-            {
-                pns_intensity_right(
-                    pVars->hasmask,
-                    pFrameInfo,
-                    pChRightShare->group,
-                    pVars->mask,
-                    pChRightShare->cb_map,
-                    pChLeftShare->factors,
-                    pChRightShare->factors,
-                    pChRightShare->lt_status.sfb_prediction_used,
-                    pChRightShare->lt_status.ltp_data_present,
-                    pChVars[LEFT]->fxpCoef,
-                    pChVars[RIGHT]->fxpCoef,
-                    pChLeftShare->qFormat,
-                    pChRightShare->qFormat,
-                    &(pVars->pns_cur_noise_state));
-            }
-
-            if (pChVars[ch]->pShareWfxpCoef->lt_status.ltp_data_present != FALSE)
-            {
-                /*
-                 * LTP - Long Term Prediction
-                 */
-
-                qPredictedSamples = long_term_prediction(
-                                        pChVars[ch]->wnd,
-                                        pChVars[ch]->pShareWfxpCoef->lt_status.
-                                        weight_index,
-                                        pChVars[ch]->pShareWfxpCoef->lt_status.
-                                        delay,
-                                        pChVars[ch]->ltp_buffer,
-                                        pVars->ltp_buffer_state,
-                                        pChVars[ch]->time_quant,
-                                        pVars->share.predictedSamples,      /* Scratch */
-                                        frameLength);
-
-                trans4m_time_2_freq_fxp(
-                    pVars->share.predictedSamples,
-                    pChVars[ch]->wnd,
-                    pChVars[ch]->wnd_shape_prev_bk,
-                    pChVars[ch]->wnd_shape_this_bk,
-                    &qPredictedSamples,
-                    pVars->scratch.fft);   /* scratch memory for FFT */
-
-
-                /*
-                 * To solve a potential problem where a pointer tied to
-                 * the qFormat was being incremented, a pointer to
-                 * pChVars[ch]->qFormat is passed in here rather than
-                 * the address of qPredictedSamples.
-                 *
-                 * Neither values are actually needed in the case of
-                 * inverse filtering, but the pointer was being
-                 * passed (and incremented) regardless.
-                 *
-                 * So, the solution is to pass a space of memory
-                 * that a pointer can happily point to.
-                 */
-
-                /* This is the inverse filter */
-                apply_tns(
-                    pVars->share.predictedSamples,  /* scratch re-used for each ch */
-                    pChVars[ch]->pShareWfxpCoef->qFormat,     /* Not used by the inv_filter */
-                    pFrameInfo,
-                    &(pChVars[ch]->pShareWfxpCoef->tns),
-                    TRUE,                       /* TRUE is FIR */
-                    pVars->scratch.tns_inv_filter);
-
-                /*
-                 * For the next function long_term_synthesis,
-                 * the third param win_sfb_top[], and
-                 * the tenth param coef_per_win,
-                 * are used differently that in the rest of the project. This
-                 * is because originally the ISO code was going to have
-                 * these parameters change as the "short window" changed.
-                 * These are all now the same value for each of the eight
-                 * windows.  This is why there is a [0] at the
-                 * end of each of theses parameters.
-                 * Note in particular that win_sfb_top was originally an
-                 * array of pointers to arrays, but inside long_term_synthesis
-                 * it is now a simple array.
-                 * When the rest of the project functions are changed, the
-                 * structure FrameInfo changes, and the [0]'s are removed,
-                 * this comment could go away.
-                 */
-                long_term_synthesis(
-                    pChVars[ch]->wnd,
-                    pChVars[ch]->pShareWfxpCoef->max_sfb,
-                    pFrameInfo->win_sfb_top[0], /* Look above */
-                    pChVars[ch]->pShareWfxpCoef->lt_status.win_prediction_used,
-                    pChVars[ch]->pShareWfxpCoef->lt_status.sfb_prediction_used,
-                    pChVars[ch]->fxpCoef,   /* input and output */
-                    pChVars[ch]->pShareWfxpCoef->qFormat,   /* input and output */
-                    pVars->share.predictedSamples,
-                    qPredictedSamples,       /* q format for previous aray */
-                    pFrameInfo->coef_per_win[0], /* Look above */
-                    NUM_SHORT_WINDOWS,
-                    NUM_RECONSTRUCTED_SFB);
-
-            } /* end if (pChVars[ch]->lt_status.ltp_data_present != FALSE) */
-
-        } /* for(ch) */
-
-        for (ch = 0; (ch < pMC_Info->nch); ch++)
-        {
-
-            pFrameInfo = pVars->winmap[pChVars[ch]->wnd];
-
-            /*
-             * TNS - Temporal Noise Shaping
-             */
-
-            /* This is the forward filter
-             *
-             * A special note:  Scratch memory is not used by
-             * the forward filter, but is passed in to maintain
-             * common interface for inverse and forward filter
-             */
-            apply_tns(
-                pChVars[ch]->fxpCoef,
-                pChVars[ch]->pShareWfxpCoef->qFormat,
-                pFrameInfo,
-                &(pChVars[ch]->pShareWfxpCoef->tns),
-                FALSE,                   /* FALSE is IIR */
-                pVars->scratch.tns_inv_filter);
-
-            /*
-             * Normalize the q format across all scale factor bands
-             * to one value.
-             */
-            qFormatNorm =
-                q_normalize(
-                    pChVars[ch]->pShareWfxpCoef->qFormat,
-                    pFrameInfo,
-                    pChVars[ch]->abs_max_per_window,
-                    pChVars[ch]->fxpCoef);
-
-            /*
-             *  filterbank - converts frequency coeficients to time domain.
-             */
-
-#ifdef AAC_PLUS
-            if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1)
-            {
-                trans4m_freq_2_time_fxp_2(
-                    pChVars[ch]->fxpCoef,
-                    pChVars[ch]->time_quant,
-                    pChVars[ch]->wnd,   /* window sequence */
-                    pChVars[ch]->wnd_shape_prev_bk,
-                    pChVars[ch]->wnd_shape_this_bk,
-                    qFormatNorm,
-                    pChVars[ch]->abs_max_per_window,
-                    pVars->scratch.fft,
-                    &pExt->pOutputBuffer[ch]);
-                /*
-                 *  Update LTP buffers if needed
-                 */
-
-                if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP)
-                {
-                    Int16 * pt = &pExt->pOutputBuffer[ch];
-                    Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]);
-                    Int16  x, y;
-                    for (Int32 i = HALF_LONG_WINDOW; i != 0; i--)
-                    {
-                        x = *pt;
-                        pt += 2;
-                        y = *pt;
-                        pt += 2;
-                        *(ptr++) =  x;
-                        *(ptr++) =  y;
-                    }
-                }
-            }
-            else
-            {
-                trans4m_freq_2_time_fxp_1(
-                    pChVars[ch]->fxpCoef,
-                    pChVars[ch]->time_quant,
-                    &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state + 288]),
-                    pChVars[ch]->wnd,   /* window sequence */
-                    pChVars[ch]->wnd_shape_prev_bk,
-                    pChVars[ch]->wnd_shape_this_bk,
-                    qFormatNorm,
-                    pChVars[ch]->abs_max_per_window,
-                    pVars->scratch.fft);
-
-            }
-#else
-
-            trans4m_freq_2_time_fxp_2(
-                pChVars[ch]->fxpCoef,
-                pChVars[ch]->time_quant,
-                pChVars[ch]->wnd,   /* window sequence */
-                pChVars[ch]->wnd_shape_prev_bk,
-                pChVars[ch]->wnd_shape_this_bk,
-                qFormatNorm,
-                pChVars[ch]->abs_max_per_window,
-                pVars->scratch.fft,
-                &pExt->pOutputBuffer[ch]);
-            /*
-             *  Update LTP buffers only if needed
-             */
-
-            if (pVars->mc_info.audioObjectType == MP4AUDIO_LTP)
-            {
-                Int16 * pt = &pExt->pOutputBuffer[ch];
-                Int16 * ptr = &(pChVars[ch]->ltp_buffer[pVars->ltp_buffer_state]);
-                Int16  x, y;
-                for (Int32 i = HALF_LONG_WINDOW; i != 0; i--)
-                {
-                    x = *pt;
-                    pt += 2;
-                    y = *pt;
-                    pt += 2;
-                    *(ptr++) =  x;
-                    *(ptr++) =  y;
-                }
-
-            }
-
-
-#endif
-
-
-            /* Update the window shape */
-            pChVars[ch]->wnd_shape_prev_bk = pChVars[ch]->wnd_shape_this_bk;
-
-        } /* end for() */
-
-
-        /*
-         * Copy to the final output buffer, taking into account the desired
-         * channels from the calling environment, the actual channels, and
-         * whether the data should be interleaved or not.
-         *
-         * If the stream had only one channel, write_output will not use
-         * the right channel data.
-         *
-         */
-
-
-        /* CONSIDER USE OF DMA OPTIMIZATIONS WITHIN THE write_output FUNCTION.
-         *
-         * It is presumed that the ltp_buffer will reside in internal (fast)
-         * memory, while the pExt->pOutputBuffer will reside in external
-         * (slow) memory.
-         *
-         */
-
-
-#ifdef AAC_PLUS
-
-        if (sbrBitStream->NrElements || pMC_Info->upsamplingFactor == 2)
-        {
-
-            if (pVars->bno <= 1)   /* allows console to operate with ADIF and audio config */
-            {
-                if (sbrDec->outSampleRate == 0) /* do it only once (disregarding of signaling type) */
-                {
-                    sbr_open(samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate,
-                             sbrDec,
-                             sbrDecoderData,
-                             pVars->mc_info.bDownSampledSbr);
-                }
-
-            }
-            pMC_Info->upsamplingFactor =
-                sbrDecoderData->SbrChannel[0].frameData.sbr_header.sampleRateMode;
-
-
-            /* reuse right aac spectrum channel  */
-            {
-                Int16 *pt_left  =  &(pChVars[LEFT ]->ltp_buffer[pVars->ltp_buffer_state]);
-                Int16 *pt_right =  &(pChVars[RIGHT]->ltp_buffer[pVars->ltp_buffer_state]);
-
-                if (sbr_applied(sbrDecoderData,
-                                sbrBitStream,
-                                pt_left,
-                                pt_right,
-                                pExt->pOutputBuffer,
-                                sbrDec,
-                                pVars,
-                                pMC_Info->nch) != SBRDEC_OK)
-                {
-                    status = MP4AUDEC_INVALID_FRAME;
-                }
-            }
-
-
-        }  /*  if( pExt->aacPlusEnabled == FALSE) */
-#endif
-
-        /*
-         * Copied mono data in both channels or just leave it as mono,
-         * according with desiredChannels (default is 2)
-         */
-
-        if (pExt->desiredChannels == 2)
-        {
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
-            if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1)
-#else
-            if (pMC_Info->nch != 2)
-#endif
-#else
-            if (pMC_Info->nch != 2)
-#endif
-            {
-                /* mono */
-
-
-                Int16 * pt  = &pExt->pOutputBuffer[0];
-                Int16 * pt2 = &pExt->pOutputBuffer[1];
-                Int i;
-                if (pMC_Info->upsamplingFactor == 2)
-                {
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2 = *pt;
-                        pt += 2;
-                        pt2 += 2;
-                    }
-                    pt  = &pExt->pOutputBuffer_plus[0];
-                    pt2 = &pExt->pOutputBuffer_plus[1];
-
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2 = *pt;
-                        pt += 2;
-                        pt2 += 2;
-                    }
-                }
-                else
-                {
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2 = *pt;
-                        pt += 2;
-                        pt2 += 2;
-                    }
-                }
-
-            }
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
-
-            else if (pMC_Info->psPresentFlag == 1)
-            {
-                Int32 frameSize = 0;
-                if (pExt->aacPlusEnabled == false)
-                {
-                    /*
-                     *  Decoding eaac+ when only aac is enabled, copy L into R
-                     */
-                    frameSize = 1024;
-                }
-                else if (sbrDecoderData->SbrChannel[0].syncState != SBR_ACTIVE)
-                {
-                    /*
-                     *  Decoding eaac+ when no PS data was found, copy upsampled L into R
-                     */
-                    frameSize = 2048;
-                }
-
-                Int16 * pt  = &pExt->pOutputBuffer[0];
-                Int16 * pt2 = &pExt->pOutputBuffer[1];
-                Int i;
-                for (i = 0; i < frameSize; i++)
-                {
-                    *pt2 = *pt;
-                    pt += 2;
-                    pt2 += 2;
-                }
-            }
-#endif
-#endif
-
-        }
-        else
-        {
-
-#if defined(AAC_PLUS)
-#if defined(PARAMETRICSTEREO)&&defined(HQ_SBR)
-            if (pMC_Info->nch != 2 && pMC_Info->psPresentFlag != 1)
-#else
-            if (pMC_Info->nch != 2)
-#endif
-#else
-            if (pMC_Info->nch != 2)
-#endif
-            {
-                /* mono */
-                Int16 * pt  = &pExt->pOutputBuffer[0];
-                Int16 * pt2 = &pExt->pOutputBuffer[0];
-                Int i;
-
-                if (pMC_Info->upsamplingFactor == 2)
-                {
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2++ = *pt;
-                        pt += 2;
-                    }
-
-                    pt  = &pExt->pOutputBuffer_plus[0];
-                    pt2 = &pExt->pOutputBuffer_plus[0];
-
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2++ = *pt;
-                        pt += 2;
-                    }
-                }
-                else
-                {
-                    for (i = 0; i < 1024; i++)
-                    {
-                        *pt2++ = *pt;
-                        pt += 2;
-                    }
-                }
-
-            }
-
-        }
-
-
-
-
-        /* pVars->ltp_buffer_state cycles between 0 and 1024.  The value
-         * indicates the location of the data corresponding to t == -2.
-         *
-         * | t == -2 | t == -1 |  pVars->ltp_buffer_state == 0
-         *
-         * | t == -1 | t == -2 |  pVars->ltp_buffer_state == 1024
-         *
-         */
-
-#ifdef AAC_PLUS
-        if (sbrBitStream->NrElements == 0 && pMC_Info->upsamplingFactor == 1)
-        {
-            pVars->ltp_buffer_state ^= frameLength;
-        }
-        else
-        {
-            pVars->ltp_buffer_state ^= (frameLength + 288);
-        }
-#else
-        pVars->ltp_buffer_state ^= frameLength;
-#endif
-
-
-        if (pVars->bno <= 1)
-        {
-            /*
-             * to set these values only during the second call
-             * when they change.
-             */
-            pExt->samplingRate =
-                samp_rate_info[pVars->mc_info.sampling_rate_idx].samp_rate;
-
-            pVars->mc_info.implicit_channeling = 0; /* disable flag, as this is allowed
-                                                      * only the first time
-                                                      */
-
-
-#ifdef AAC_PLUS
-
-            if (pMC_Info->upsamplingFactor == 2)
-            {
-                pExt->samplingRate *= pMC_Info->upsamplingFactor;
-                pExt->aacPlusUpsamplingFactor = pMC_Info->upsamplingFactor;
-            }
-
-#endif
-
-            pExt->extendedAudioObjectType = pMC_Info->ExtendedAudioObjectType;
-            pExt->audioObjectType = pMC_Info->audioObjectType;
-
-            pExt->encodedChannels = pMC_Info->nch;
-            pExt->frameLength = pVars->frameLength;
-        }
-
-        pVars->bno++;
-
-
-        /*
-         * Using unit analysis, the bitrate is a function of the sampling rate, bits,
-         * points in a frame
-         *
-         *     bits        samples                frame
-         *     ----  =    --------- *  bits  *   -------
-         *     sec           sec                  sample
-         *
-         * To save a divide, a shift is used. Presently only the value of
-         * 1024 is used by this library, so make it the most accurate for that
-         * value. This may need to be updated later.
-         */
-
-        pExt->bitRate = (pExt->samplingRate *
-                         (pVars->inputStream.usedBits - initialUsedBits)) >> 10;  /*  LONG_WINDOW  1024 */
-
-        pExt->bitRate >>= (pMC_Info->upsamplingFactor - 1);
-
-
-    } /* end if (status == SUCCESS) */
-
-
-    if (status != MP4AUDEC_SUCCESS)
-    {
-        /*
-         *  A non-SUCCESS decoding could be due to an error on the bitstream or
-         *  an incomplete frame. As access to the bitstream beyond frame boundaries
-         *  are not allowed, in those cases the bitstream reading routine return a 0
-         *  Zero values guarantees that the data structures are filled in with values
-         *  that eventually will signal an error (like invalid parameters) or that allow
-         *  completion of the parsing routine. Either way, the partial frame condition
-         *  is verified at this time.
-         */
-        if (pVars->prog_config.file_is_adts == TRUE)
-        {
-            status = MP4AUDEC_LOST_FRAME_SYNC;
-            pVars->prog_config.headerless_frames = 0; /* synchronization forced */
-        }
-        else
-        {
-            /*
-             *  Check if the decoding error was due to buffer overrun, if it was,
-             *  update status
-             */
-            if (pVars->inputStream.usedBits > pVars->inputStream.availableBits)
-            {
-                /* all bits were used but were not enough to complete decoding */
-                pVars->inputStream.usedBits = pVars->inputStream.availableBits;
-
-                status = MP4AUDEC_INCOMPLETE_FRAME; /* possible EOF or fractional frame */
-            }
-        }
-    }
-
-    /*
-     * Translate from units of bits back into units of words.
-     */
-
-    pExt->inputBufferUsedLength =
-        pVars->inputStream.usedBits >> INBUF_ARRAY_INDEX_SHIFT;
-
-    pExt->remainderBits = (Int)(pVars->inputStream.usedBits & INBUF_BIT_MODULO_MASK);
-
-
-
-    return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp
deleted file mode 100644
index 7cdecd0..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecodergetmemrequirements.cpp
+++ /dev/null
@@ -1,157 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderGetMemRequirements.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Copied from aac_decode_frame
-
- Description: Cleaned up.
-
- Description: (1) use UInt32 to replace size_t type
-              (2) memory of tDec_Int_File is splitted into 3 pieces,
-                  sizeof(tDec_Int_File) is only part of the total memory
-                  required. The additional memory required to decode per
-                  channel information is allocated by a DPI call outside this
-                  API
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs: None
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-    size = amount of memory needed to be allocated by the calling
-        environment.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function returns the amount of internal memory needed by the library.
- Presently this is a constant value, but could later be more sophisticated
- by taking into account mono or stereo, and whether LTP is to be used.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    size = sizeof(tDec_Int_File);
-
- RETURN (size)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-OSCL_EXPORT_REF UInt32 PVMP4AudioDecoderGetMemRequirements(void)
-{
-    UInt32 size;
-
-    size = (UInt32) sizeof(tDec_Int_File);
-
-    return (size);
-
-} /* PVMP4AudioDecoderGetMemRequirements() */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp
deleted file mode 100644
index 146ba0f..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderinitlibrary.cpp
+++ /dev/null
@@ -1,418 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderInitLibrary.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Copied from aac_decode_frame
-
- Description:  Clean up.
-
- Description:  Update per review comments
-
- Description:  Add frame_length, fix mistake in pseudo-code.
-               Change frame_length to frameLength, to matcht the API,
-               look more professional, etc.
-
- Description:
- (1) Added #include of "e_ProgConfigConst.h"
-     Previously, this function was relying on another include file
-     to include "e_ProgConfigConst.h"
-
- (2) Updated the copyright header.
-
- Description:
- (1) Modified to initialize pointers for shared memory techniques.
-
- Description: Since memory will be allocated continuously, it is initialized
-              in one spot
-
- Description: Added field aacPlusUpsamplingFactor (default == 1) to have a
-              common interface for all AAC variations
-
- Description: Added PVMP4AudioDecoderDisableAacPlus to disable sbr decoding
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pExt = pointer to the external application-program interface (API)
-           structure that a client program uses to communicate information
-           with this library. Among the items in this structure is a pointer
-           to the input and output buffers, data for handling the input buffer
-           and output information. Look in PVMP4AudioDecoder_API.h for all the
-           fields to this structure. Data type pointer to a
-           tPVMP4AudioDecoderExternal structure.
-
-   pMem =  pointer to allocated memory, of the size returned by the function
-           PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
-           two reasons:
-           1) So the external program does not need all of the header files
-              for all of the fields in the structure tDec_Int_File
-           2) To hide data and the implementation of the program. Even knowing
-              how data is stored can help in reverse engineering software.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-    status = 0 (SUCCESS). Presently there is no error checking in this
-    function.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Initializes the internal memory for the MP4 Audio Decoder library.
- Also sets relevant values for the external interface structure, clears
- the bit rate, channel count, sampling rate, and number of used buffer
- elements.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pVars = pMem;
-
-    CALL pv_memset(
-           to = pVars,
-           c  = 0,
-           n  = sizeof(tDec_Int_File))
-    MODIFYING(*pVars = 0)
-    RETURNING(nothing)
-
-    pVars->current_program = -1
-    pVars->mc_info.sampling_rate_idx = Fs_44
-    pVars->frameLength = LONG_WINDOW
-
-
-    pVars->winmap[ONLY_LONG_SEQUENCE]   = &pVars->longFrameInfo;
-    pVars->winmap[LONG_START_SEQUENCE]  = &pVars->longFrameInfo;
-    pVars->winmap[EIGHT_SHORT_SEQUENCE] = &pVars->shortFrameInfo;
-    pVars->winmap[LONG_STOP_SEQUENCE]   = &pVars->longFrameInfo;
-
-    CALL infoinit(
-        samp_rate_indx = pVars->mc_info.sampling_rate_idx,
-        ppWin_seq_info = pVars->winmap,
-        pSfbwidth128   = pVars->SFBWidth128)
-    MODIFYING(ppWinSeq_info)
-    MODIFYING(pSfbwidth128)
-    RETURNING(nothing)
-
-    pExt->bitRate = 0;
-    pExt->encodedChannels = 0;
-    pExt->samplingRate = 0;
-    pExt->inputBufferUsedLength = 0;
-
-    MODIFY(pExt)
-    MODIFY(pMem)
-    RETURN(SUCCESS)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "e_progconfigconst.h"
-
-#include "huffman.h"               /* For the definition of infoinit        */
-#include "aac_mem_funcs.h"         /* For pv_memset                         */
-#include "pvmp4audiodecoder_api.h" /* Where this function is declared       */
-#include "s_tdec_int_chan.h"
-#include "sfb.h"                   /* samp_rate_info[] is declared here     */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-OSCL_EXPORT_REF Int PVMP4AudioDecoderInitLibrary(
-    tPVMP4AudioDecoderExternal  *pExt,
-    void                        *pMem)
-{
-    tDec_Int_File *pVars;
-
-    pVars = (tDec_Int_File *)pMem;
-
-    /*
-     * Initialize all memory. The pointers to channel memory will be
-     * set to zero also.
-     */
-    pv_memset(
-        pVars,
-        0,
-        sizeof(tDec_Int_File));
-
-    /*
-     * Pick default values for the library.
-     */
-    pVars->perChan[0].fxpCoef = pVars->fxpCoef[0];
-    pVars->perChan[1].fxpCoef = pVars->fxpCoef[1];
-
-    /* Here, the "shared memory" pointer is set to point
-     * at the 1024th element of fxpCoef, because those spaces
-     * in memory are not used until the filterbank is called.
-     *
-     * Therefore, any variables that are only used before
-     * the filterbank can occupy this same space in memory.
-     */
-
-    pVars->perChan[0].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
-                                       & (pVars->perChan[0].fxpCoef[1024]);
-
-    pVars->perChan[1].pShareWfxpCoef = (per_chan_share_w_fxpCoef *)
-                                       & (pVars->perChan[1].fxpCoef[1024]);
-
-    /*
-     * This next line informs the function get_prog_config that no
-     * configuration has been found thus far, so it is a default
-     * configuration.
-     */
-
-    pVars->current_program = -1;
-    pVars->mc_info.sampling_rate_idx = Fs_44; /* Fs_44 = 4, 44.1kHz */
-
-    /*
-     * In the future, the frame length will change with MP4 file format.
-     * Presently this variable is used to simply the unit test for
-     * the function PVMP4AudioDecodeFrame() .. otherwise the test would
-     * have to pass around 1024 length arrays.
-     */
-    pVars->frameLength = LONG_WINDOW; /* 1024*/
-
-    /*
-     * The window types ONLY_LONG_SEQUENCE, LONG_START_SEQUENCE, and
-     * LONG_STOP_SEQUENCE share the same information. The only difference
-     * between the windows is accounted for in the "filterbank", in
-     * the function trans4m_freq_2_time_fxp()
-     */
-
-    pVars->winmap[ONLY_LONG_SEQUENCE]   /* 0 */ = &pVars->longFrameInfo;
-    pVars->winmap[LONG_START_SEQUENCE]  /* 1 */ = &pVars->longFrameInfo;
-    pVars->winmap[EIGHT_SHORT_SEQUENCE] /* 2 */ = &pVars->shortFrameInfo;
-    pVars->winmap[LONG_STOP_SEQUENCE]   /* 3 */ = &pVars->longFrameInfo;
-
-    infoinit(
-        pVars->mc_info.sampling_rate_idx,
-        (FrameInfo   **)pVars->winmap,
-        pVars->SFBWidth128);
-
-
-    /*
-     * Clear out external output values. These values are set later at the end
-     * of PVMP4AudioDecodeFrames()
-     */
-    pExt->bitRate = 0;
-    pExt->encodedChannels = 0;
-    pExt->samplingRate = 0;
-    pExt->aacPlusUpsamplingFactor = 1;  /*  Default for regular AAC */
-    pVars->aacPlusEnabled = pExt->aacPlusEnabled;
-
-
-#if defined(AAC_PLUS)
-    pVars->sbrDecoderData.setStreamType = 1;        /* Enable Lock for AAC stream type setting  */
-#endif
-
-    /*
-     * Initialize input buffer variable.
-     */
-
-    pExt->inputBufferUsedLength = 0;
-
-    return (MP4AUDEC_SUCCESS);
-
-}  /* PVMP4AudioDecoderInitLibrary */
-
-
-/*
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pExt = pointer to the external application-program interface (API)
-           structure that a client program uses to communicate information
-           with this library. Among the items in this structure is a pointer
-           to the input and output buffers, data for handling the input buffer
-           and output information. Look in PVMP4AudioDecoder_API.h for all the
-           fields to this structure. Data type pointer to a
-           tPVMP4AudioDecoderExternal structure.
-
-   pMem =  pointer to allocated memory, of the size returned by the function
-           PVMP4AudioDecoderGetMemRequirements. This is a void pointer for
-           two reasons:
-           1) So the external program does not need all of the header files
-              for all of the fields in the structure tDec_Int_File
-           2) To hide data and the implementation of the program. Even knowing
-              how data is stored can help in reverse engineering software.
-
- Local Stores/Buffers/Pointers Needed: None
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-    status = 0 (SUCCESS). Presently there is no error checking in this
-    function.
-
- Pointers and Buffers Modified: None
-
- Local Stores Modified: None
-
- Global Stores Modified: None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- Disable SBR decoding functionality and set parameters accordingly
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-OSCL_EXPORT_REF void PVMP4AudioDecoderDisableAacPlus(
-    tPVMP4AudioDecoderExternal  *pExt,
-    void                        *pMem)
-{
-    tDec_Int_File *pVars;
-
-    pVars = (tDec_Int_File *)pMem;
-
-    if ((pVars->aacPlusEnabled == true) && (pExt->aacPlusEnabled == true))
-    {
-        // disable only when makes sense
-        pVars->aacPlusEnabled = false;
-        pExt->aacPlusEnabled = false;
-
-#if defined(AAC_PLUS)
-        pVars->mc_info.upsamplingFactor = 1;
-        pVars->mc_info.psPresentFlag  = 0;
-        pVars->mc_info.sbrPresentFlag = 0;
-        pVars->prog_config.sampling_rate_idx += 3;
-        pVars->sbrDecoderData.SbrChannel[0].syncState = SBR_NOT_INITIALIZED;
-        pVars->sbrDecoderData.SbrChannel[1].syncState = SBR_NOT_INITIALIZED;
-
-
-        pExt->samplingRate = samp_rate_info[pVars->prog_config.sampling_rate_idx].samp_rate;
-        pExt->aacPlusUpsamplingFactor = 1;
-#endif
-    }
-}  /* PVMP4AudioDecoderDisableAacPlus */
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp b/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp
deleted file mode 100644
index c10423b..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4audiodecoderresetbuffer.cpp
+++ /dev/null
@@ -1,354 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: PVMP4AudioDecoderResetBuffer.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) add more comments (2) set pVars->bno = 1
-
- Description: perChan[] is an array of structures in tDec_Int_File. Made
-              corresponding changes.
-
- Who:                                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    pMem = void pointer to hide the internal implementation of the library
-           It is cast back to a tDec_Int_File structure. This structure
-           contains information that needs to persist between calls to
-           PVMP4AudioDecodeFrame
-           Data type void pointer, internally pointer to a tDec_Int_File
-           structure.
-
- Local Stores/Buffers/Pointers Needed: None
-           (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs: None
-
- Pointers and Buffers Modified:
-    pMem contents are modified.
-    pMem->perChan[0].time_quant[0-1023]: contents are set to zero
-    pMem->perChan[1].time_quant[0-1023]: contents are set to zero
-    pMem->bno = 1
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  This function is called when the same audio clip will be played again from
-  the begining. This situation happens when the "stop" button is pressed or
-  the "loop-mode" is selected on PVPlayer. Since it is the same audio clip to
-  be played again, the decoder does not need to reset the audioSpecificInfo.
-  However, the overlap-and-add buffer of the filterbank output needs to be
-  cleared, so that the decoder can re-start properly from the begining of
-  the audio. The frame number counter, pVars->bno, is set to 1 because the
-  audioSpecificInfo is decoded on pVars->bno==0
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
-      subclause 1.6
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "pvmp4audiodecoder_api.h"   /* Where this function is declared */
-#include "aac_mem_funcs.h"
-
-#ifdef AAC_PLUS
-#include    "s_sbr_frame_data.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT  (0)
-#define RIGHT (1)
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-OSCL_EXPORT_REF void PVMP4AudioDecoderResetBuffer(void  *pMem)
-{
-
-    tDec_Int_File *pVars;           /* Helper pointer */
-
-#ifdef AAC_PLUS
-    SBR_FRAME_DATA * hFrameData_1;
-    SBR_FRAME_DATA * hFrameData_2;
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-    SBRDECODER_DATA *sbrDecoderData;
-#endif
-#endif
-
-#endif
-    /*
-     * Initialize "helper" pointers to existing memory.
-     */
-    pVars = (tDec_Int_File *)pMem;
-
-    /*
-     * Clear the overlap-and-add buffer of filterbank output. The audio
-     * clip will be played again from the beginning.
-     */
-    pv_memset(pVars->perChan[LEFT].time_quant,
-              0,
-              LONG_WINDOW*sizeof(pVars->perChan[LEFT].time_quant[0]));
-
-    pv_memset(pVars->perChan[RIGHT].time_quant,
-              0,
-              LONG_WINDOW*sizeof(pVars->perChan[RIGHT].time_quant[0]));
-
-
-#ifdef AAC_PLUS
-
-    if (!pVars->sbrDecoderData.setStreamType)  /* reset only when stream type is defined */
-    {
-        if (pVars->aacPlusEnabled == true)  /* clear buffer only if they were used */
-        {
-
-            hFrameData_1   = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[LEFT].frameData;
-            hFrameData_2   = (SBR_FRAME_DATA *) & pVars->sbrDecoderData.SbrChannel[RIGHT].frameData;
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-            sbrDecoderData = (SBRDECODER_DATA *) & pVars->sbrDecoderData;
-            sbrDecoderData->hParametricStereoDec = (HANDLE_PS_DEC) & pVars->sbrDecoderData.ParametricStereoDec;
-#endif
-#endif
-
-
-            pv_memset(&pVars->perChan[LEFT].ltp_buffer[0],
-                      0,
-                      288*sizeof(pVars->perChan[LEFT].ltp_buffer[0]));
-            pv_memset(&pVars->perChan[LEFT].ltp_buffer[1024 + 288],
-                      0,
-                      288*sizeof(pVars->perChan[LEFT].ltp_buffer[0]));
-            pv_memset(hFrameData_1->V,
-                      0,
-                      1152*sizeof(hFrameData_1->V[0]));
-            pv_memset(hFrameData_1->prevNoiseLevel_man,
-                      0,
-                      MAX_NUM_NOISE_VALUES*sizeof(hFrameData_1->prevNoiseLevel_man[0]));
-
-
-            pv_memset(&pVars->perChan[RIGHT].ltp_buffer[0],
-                      0,
-                      288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0]));
-            pv_memset(&pVars->perChan[RIGHT].ltp_buffer[1024 + 288],
-                      0,
-                      288*sizeof(pVars->perChan[RIGHT].ltp_buffer[0]));
-            pv_memset(hFrameData_2->V,
-                      0,
-                      1152*sizeof(hFrameData_2->V[0]));
-
-            pv_memset(hFrameData_2->prevNoiseLevel_man,
-                      0,
-                      MAX_NUM_NOISE_VALUES*sizeof(hFrameData_2->prevNoiseLevel_man[0]));
-
-
-            int i;
-            for (i = 0; i < 8; i++)
-            {
-                pv_memset((void *)&hFrameData_1->codecQmfBufferReal[i],
-                          0,
-                          sizeof(**hFrameData_1->codecQmfBufferReal) << 5);
-            }
-
-
-            /* ---- */
-            pv_memset((void *)hFrameData_1->BwVectorOld,
-                      0,
-                      sizeof(*hFrameData_1->BwVectorOld)*MAX_NUM_PATCHES);
-
-#ifdef HQ_SBR
-
-            for (i = 0; i < 5; i++)
-            {
-                pv_memset((void *)&hFrameData_1->fBuffer_man[i],
-                          0,
-                          sizeof(**hFrameData_1->fBuffer_man)*64);
-                pv_memset((void *)&hFrameData_1->fBufferN_man[i],
-                          0,
-                          sizeof(**hFrameData_1->fBufferN_man)*64);
-            }
-#endif
-
-
-            /* ---- */
-
-
-
-            pv_memset((void *)hFrameData_1->HistsbrQmfBufferReal,
-                      0,
-                      sizeof(*hFrameData_1->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS);
-
-#ifdef HQ_SBR
-            pv_memset((void *)hFrameData_1->HistsbrQmfBufferImag,
-                      0,
-                      sizeof(*hFrameData_1->HistsbrQmfBufferImag)*6*SBR_NUM_BANDS);
-#endif
-
-            if (pVars->sbrDec.LC_aacP_DecoderFlag == 1)  /* clear buffer only for LC decoding */
-            {
-
-                for (i = 0; i < 8; i++)
-                {
-                    pv_memset((void *)&hFrameData_2->codecQmfBufferReal[i],
-                              0,
-                              sizeof(**hFrameData_1->codecQmfBufferReal) << 5);
-                }
-
-                pv_memset((void *)hFrameData_2->HistsbrQmfBufferReal,
-                          0,
-                          sizeof(*hFrameData_2->HistsbrQmfBufferReal)*6*SBR_NUM_BANDS);
-
-
-                pv_memset((void *)hFrameData_2->BwVectorOld,
-                          0,
-                          sizeof(*hFrameData_2->BwVectorOld)*MAX_NUM_PATCHES);
-
-#ifdef HQ_SBR
-
-                for (i = 0; i < 5; i++)
-                {
-                    pv_memset((void *)&hFrameData_2->fBuffer_man[i],
-                              0,
-                              sizeof(**hFrameData_2->fBuffer_man)*64);
-                    pv_memset((void *)&hFrameData_2->fBufferN_man[i],
-                              0,
-                              sizeof(**hFrameData_2->fBufferN_man)*64);
-                }
-#endif
-
-            }
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-            else if (pVars->mc_info.psPresentFlag == 1)
-            {
-                for (i = 0; i < 3; i++)
-                {
-                    pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal[i],
-                              0,
-                              HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferReal));
-                    pv_memset(sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag[i],
-                              0,
-                              HYBRID_FILTER_LENGTH_m_1*sizeof(*sbrDecoderData->hParametricStereoDec->hHybrid->mQmfBufferImag));
-                }
-            }
-#endif
-#endif
-
-            /*
-             *  default to UPSAMPLING, as if the file is SBR_ACTIVE, this will be fine and will be
-             *  fixed onced the new sbr header is found
-             *  SBR headers contain SBT freq. range as well as control signals that do not require
-             *  frequent changes.
-             *  For streaming, the SBR header is sent twice per second. Also, an SBR header can be
-             *  inserted at any time, if a change of parameters is needed.
-             */
-
-            pVars->sbrDecoderData.SbrChannel[LEFT].syncState = UPSAMPLING;
-            pVars->sbrDecoderData.SbrChannel[RIGHT].syncState = UPSAMPLING;
-
-        }
-    }
-#endif      /*  #ifdef AAC_PLUS */
-
-    /* reset frame count to 1 */
-    pVars->bno = 1;
-
-    return ;
-
-} /* PVMP4AudioDecoderDecodeFrame */
-
diff --git a/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp b/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp
deleted file mode 100644
index d183d84..0000000
--- a/media/libstagefright/codecs/aacdec/pvmp4setaudioconfig.cpp
+++ /dev/null
@@ -1,368 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: pvmp4setaudioconfigg
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pExt = pointer to the external interface structure. See the file
-           PVMP4AudioDecoder_API.h for a description of each field.
-           Data type of pointer to a tPVMP4AudioDecoderExternal
-           structure.
-
-           pExt->pInputBuffer: pointer to input buffer containing input
-                               bitstream
-
-           pExt->inputBufferCurrentLength: number of bytes in the input buffer
-
-           pExt->inputBufferUsedLength: number of bytes already consumed in
-                                        input buffer
-
-           pExt->remainderBits: number of bits consumed in addition to
-                                pExt->inputBufferUsedLength
-
-    pMem = void pointer to hide the internal implementation of the library
-           It is cast back to a tDec_Int_File structure. This structure
-           contains information that needs to persist between calls to
-           this function, or is too big to be placed on the stack, even
-           though the data is only needed during execution of this function
-           Data type void pointer, internally pointer to a tDec_Int_File
-           structure.
-
- Local Stores/Buffers/Pointers Needed: None
-           (The memory set aside in pMem performs this task)
-
- Global Stores/Buffers/Pointers Needed: None
-
- Outputs:
-     status = 0                       if no error occurred
-              MP4AUDEC_NONRECOVERABLE if a non-recoverable error occurred
-              MP4AUDEC_RECOVERABLE    if a recoverable error occurred.
-              Presently a recoverable error does not exist, but this
-              was a requirement.
-
-
- Pointers and Buffers Modified:
-    pMem contents are modified.
-    pExt: (more detail in the file PVMP4AudioDecoder_API.h)
-    inputBufferUsedLength - number of array elements used up by the stream.
-    remainderBits - remaining bits in the next UInt32 buffer
-    samplingRate - sampling rate in samples per sec
-    encodedChannels - channels found on the file (informative)
-    frameLength - length of the frame
-
- Local Stores Modified: None.
-
- Global Stores Modified: None.
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- PacketVideo Document # CCC-AUD-AAC-ERS-0003
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-#include "ibstream.h"           /* where #define INBUF_ARRAY_INDEX_SHIFT */
-#include "sfb.h"                   /* Where samp_rate_info[] is declared */
-
-#include "get_audio_specific_config.h"
-#include "pvmp4audiodecoder_api.h"   /* Where this function is declared */
-#include "set_mc_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int PVMP4SetAudioConfig(
-    tPVMP4AudioDecoderExternal  *pExt,
-    void                        *pMem,
-    Int                         upsamplingFactor,
-    Int                         samp_rate,
-    Int                         num_ch,
-    tMP4AudioObjectType         audioObjectType)
-
-{
-
-    tDec_Int_File *pVars;           /* Helper pointer */
-
-    Int            status = MP4AUDEC_INCOMPLETE_FRAME;
-
-    /*
-     * Initialize "helper" pointers to existing memory.
-     */
-    pVars = (tDec_Int_File *)pMem;
-    /*
-     * Translate input buffer variables.
-     */
-    pVars->inputStream.pBuffer = pExt->pInputBuffer;
-
-    pVars->inputStream.availableBits = 0;
-
-    pVars->inputStream.usedBits = 0;
-
-
-
-    /*
-     *  get sampling rate index
-     */
-
-    switch (samp_rate)
-    {
-        case 96000:
-            pVars->prog_config.sampling_rate_idx = 0;
-            break;
-        case 88200:
-            pVars->prog_config.sampling_rate_idx = 1;
-            break;
-        case 64000:
-            pVars->prog_config.sampling_rate_idx = 2;
-            break;
-        case 48000:
-            pVars->prog_config.sampling_rate_idx = 3;
-            break;
-        case 44100:
-            pVars->prog_config.sampling_rate_idx = 4;
-            break;
-        case 32000:
-            pVars->prog_config.sampling_rate_idx = 5;
-            break;
-        case 24000:
-            pVars->prog_config.sampling_rate_idx = 6;
-            break;
-        case 22050:
-            pVars->prog_config.sampling_rate_idx = 7;
-            break;
-        case 16000:
-            pVars->prog_config.sampling_rate_idx = 8;
-            break;
-        case 12000:
-            pVars->prog_config.sampling_rate_idx = 9;
-            break;
-        case 11025:
-            pVars->prog_config.sampling_rate_idx = 10;
-            break;
-        case 8000:
-            pVars->prog_config.sampling_rate_idx = 11;
-            break;
-        case 7350:
-            pVars->prog_config.sampling_rate_idx = 12;
-            break;
-        default:
-            status = -1;
-
-            break;
-    }
-
-    pVars->mc_info.sbrPresentFlag = 0;
-    pVars->mc_info.psPresentFlag = 0;
-#ifdef AAC_PLUS
-    pVars->mc_info.bDownSampledSbr = 0;
-#endif
-    pVars->mc_info.implicit_channeling = 0;
-    pVars->mc_info.nch = num_ch;
-    pVars->mc_info.upsamplingFactor = upsamplingFactor;
-
-
-    /*
-     *  Set number of channels
-     */
-
-    if (num_ch == 2)
-    {
-        pVars->prog_config.front.ele_is_cpe[0] = 1;
-    }
-    else if (num_ch == 1)
-    {
-        pVars->prog_config.front.ele_is_cpe[0] = 0;
-    }
-    else
-    {
-        status = -1; /* do not support more than two channels */
-        pVars->status = status;
-        return (status);
-    }
-
-
-    /*
-     *  Set AAC bitstream
-     */
-
-    if ((audioObjectType == MP4AUDIO_AAC_LC)        ||
-            (audioObjectType == MP4AUDIO_LTP))
-    {
-        pVars->aacPlusEnabled = false;
-
-        status = set_mc_info(&(pVars->mc_info),
-                             audioObjectType, /* previously profile */
-                             pVars->prog_config.sampling_rate_idx,
-                             pVars->prog_config.front.ele_tag[0],
-                             pVars->prog_config.front.ele_is_cpe[0],
-                             pVars->winmap, /*pVars->pWinSeqInfo,*/
-                             pVars->SFBWidth128);
-    }
-    else if ((audioObjectType == MP4AUDIO_SBR)        ||
-             (audioObjectType == MP4AUDIO_PS))
-    {
-        pVars->aacPlusEnabled = true;
-
-
-        status = set_mc_info(&(pVars->mc_info),
-                             MP4AUDIO_AAC_LC,
-                             pVars->prog_config.sampling_rate_idx,
-                             pVars->prog_config.front.ele_tag[0],
-                             pVars->prog_config.front.ele_is_cpe[0],
-                             pVars->winmap, /*pVars->pWinSeqInfo,*/
-                             pVars->SFBWidth128);
-
-        pVars->mc_info.sbrPresentFlag = 1;
-        if (audioObjectType == MP4AUDIO_PS)
-        {
-            pVars->mc_info.psPresentFlag = 1;
-        }
-
-        if (upsamplingFactor == 1)
-        {
-#ifdef AAC_PLUS
-            pVars->mc_info.bDownSampledSbr = 1;
-#endif
-
-            /*
-             *  Disable SBR decoding for any sbr-downsampled file whose SF is >= 24 KHz
-             */
-            if (pVars->prog_config.sampling_rate_idx < 6)
-            {
-                pVars->aacPlusEnabled = false;
-            }
-        }
-
-    }
-    else
-    {
-        status = -1;
-    }
-
-
-    /*
-     * Translate from units of bits back into units of words.
-     */
-    pExt->inputBufferUsedLength = 0;
-
-    pExt->remainderBits = 0;
-
-    pVars->bno++;
-
-    pExt->samplingRate = samp_rate * upsamplingFactor;
-
-    pExt->aacPlusEnabled = pVars->aacPlusEnabled;
-
-    /*
-     *  we default to 2 channel, even for mono files, (where channels have same content)
-     *  this is done to ensure support for enhanced aac+ with implicit signalling
-     */
-
-    pExt->encodedChannels = 2;
-
-    pExt->frameLength = 1024;
-#ifdef AAC_PLUS
-    pExt->aacPlusUpsamplingFactor = upsamplingFactor;
-#endif
-
-    pVars->status = status;
-
-    return (status);
-
-} /* PVMP4AudioDecoderDecodeFrame */
diff --git a/media/libstagefright/codecs/aacdec/q_normalize.cpp b/media/libstagefright/codecs/aacdec/q_normalize.cpp
deleted file mode 100644
index 5266966..0000000
--- a/media/libstagefright/codecs/aacdec/q_normalize.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: q_normalize.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modify to include search over the scalefactor bands to insure
-     that the data is using all 31 data-bits.
-
- Description:
- (1) Modify to remove search over the scalefactor bands to insure
-     that the data is using all 31 data-bits.
-     (Pushed out into separate function)
- (2) Change variable "k" to more descriptive "shift_amt"
- (3) Update pseudocode to reflect removed code.
- (4) Add PV Copyright notice.
-
- Description:
- (1) Modified to protect q-normalize from shifting by amounts >= 32.
-
- Description:
- (1) Delete local variable idx_count.
-
- Description:
- (1) Included search for max in each frame, modified interface.
-
- Description:
- (1) unrolled loop based on the fact that the size of each scale band
-     is always an even number.
-
- Description:Check shift, if zero, do not shift.
-
- Description: Eliminated warning: non use variable "i" and memset function
-    definition
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    qFormat[] = Array of qFormats, one per scalefactor band. [ Int ]
-
-    pFrameInfo = Pointer to structure that holds information about each group.
-                 (long block flag, number of windows, scalefactor bands, etc.)
-                 [const FrameInfo]
-
-    coef[]    = Array of the spectral coefficients for one channel. [ Int32 ]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    min_q = The common q-format for the entire frame. [Int]
-
- Pointers and Buffers Modified:
-    coef[]    = Array of spectral data, now normalized to one q-format.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This module first scans every scalefactor band for the frame, insuring that
- at least one element in that scalefactor band is using all available bits.
- If not, the elements in the scalefactor band are shifted up to use all 31
- data bits.  The q-format is adjusted accordingly.
-
- This module then scans the q-formats for each scalefactor band.
- Upon finding the minimum q-format in the frame, the coefficients in each
- scalefactor band are normalized to the minimum q-format.
- The minimum q-format is then returned to the calling function, which is now
- the q-format for the entire frame.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    nwin = pFrameInfo->num_win;
-
-    pQformat   = &(qFormat[0]);
-    pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
-    pCoef      = &(coef[0]);
-
-    FOR (win = nwin; win > 0; win--)
-
-        nsfb = *(pSfbPerWin++);
-
-        FOR (sfb = nsfb; sfb > 0; sfb--)
-
-            IF ( *(pQformat) < min_q)
-                min_q = *(pQformat);
-            ENDIF
-
-            pQformat++;
-
-        ENDFOR
-
-    ENDFOR
-
-    pQformat   = &(qFormat[0]);
-    pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
-    pCoef      = &(coef[0]);
-
-    FOR (win = 0; win < nwin; win++)
-
-        stop_idx = 0;
-
-        nsfb   = *(pSfbPerWin++);
-
-        pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]);
-
-        FOR (sfb = nsfb; sfb > 0; sfb--)
-
-            sfbWidth  = *(pWinSfbTop++) - stop_idx;
-
-            stop_idx += sfbWidth;
-
-            k = *(pQformat++) - min_q;
-
-            IF (k < 32)
-            THEN
-                FOR (; sfbWidth > 0; sfbWidth--)
-                    *(pCoef++) >>= k;
-                ENDFOR
-            ELSE
-                FOR (; sfbWidth > 0; sfbWidth--)
-                    *(pCoef++) = 0;
-                ENDFOR
-            ENDIF
-
-        ENDFOR
-
-    ENDFOR
-
-    return min_q;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-#include "q_normalize.h"
-#include "aac_mem_funcs.h"         /* For pv_memset                         */
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int q_normalize(
-    Int        qFormat[],
-    const FrameInfo *pFrameInfo,
-    Int32      abs_max_per_window[],
-    Int32      coef[])
-{
-    Int    sfb;
-    Int    nsfb;
-    Int    win;
-    Int    nwin;
-    Int    sfbWidth;
-
-    Int    shift_amt;
-
-    /* Initialize min_q to a very large value */
-    Int    min_q = 1000;
-
-    Int stop_idx  = 0;
-
-    const Int   *pSfbPerWin;
-    const Int16 *pWinSfbTop;
-
-    Int   *pQformat;
-    Int32 *pCoef;
-
-    nwin = pFrameInfo->num_win;
-
-    /* Find the minimum q format */
-    pQformat   = &(qFormat[0]);
-    pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
-
-    for (win = nwin; win != 0; win--)
-    {
-
-        nsfb = *(pSfbPerWin++);
-
-        if (nsfb < 0 || nsfb > MAXBANDS)
-        {
-            break;  /* avoid any processing on error condition */
-        }
-
-        for (sfb = nsfb; sfb != 0; sfb--)
-        {
-            Int qformat = *(pQformat++);
-            if (qformat < min_q)
-            {
-                min_q = qformat;
-            }
-        }
-
-    } /* for(win) */
-
-    /* Normalize the coefs in each scalefactor band to one q-format */
-    pQformat   = &(qFormat[0]);
-    pSfbPerWin = &(pFrameInfo->sfb_per_win[0]);
-    pCoef      = &(coef[0]);
-
-    for (win = 0; win < nwin; win++)
-    {
-
-        Int32 max = 0;
-        stop_idx = 0;
-
-        nsfb   = *(pSfbPerWin++);
-
-        if (nsfb < 0 || nsfb > MAXBANDS)
-        {
-            break;  /* avoid any processing on error condition */
-        }
-
-        pWinSfbTop = &(pFrameInfo->win_sfb_top[win][0]);
-
-        for (sfb = nsfb; sfb != 0; sfb--)
-        {
-            Int tmp1, tmp2;
-            tmp1 = *(pWinSfbTop++);
-            tmp2 = *(pQformat++);
-            sfbWidth  = tmp1 - stop_idx;
-
-            if (sfbWidth < 2)
-            {
-                break;  /* will lead to error condition */
-            }
-
-            stop_idx += sfbWidth;
-
-            shift_amt = tmp2 - min_q;
-
-            if (shift_amt == 0)
-            {
-                Int32 tmp1, tmp2;
-                tmp1 = *(pCoef++);
-                tmp2 = *(pCoef++);
-                /*
-                 *  sfbWidth is always an even number
-                 *  (check tables in pg.66 IS0 14496-3)
-                 */
-                for (Int i = (sfbWidth >> 1) - 1; i != 0; i--)
-                {
-                    max  |= (tmp1 >> 31) ^ tmp1;
-                    max  |= (tmp2 >> 31) ^ tmp2;
-                    tmp1 = *(pCoef++);
-                    tmp2 = *(pCoef++);
-                }
-                max  |= (tmp1 >> 31) ^ tmp1;
-                max  |= (tmp2 >> 31) ^ tmp2;
-
-            }
-            else
-            {
-                if (shift_amt < 31)
-                {
-                    Int32 tmp1, tmp2;
-                    tmp1 = *(pCoef++) >> shift_amt;
-                    tmp2 = *(pCoef--) >> shift_amt;
-                    /*
-                     *  sfbWidth is always an even number
-                     *  (check tables in pg.66 IS0 14496-3)
-                     */
-                    for (Int i = (sfbWidth >> 1) - 1; i != 0; i--)
-                    {
-                        *(pCoef++)   = tmp1;
-                        *(pCoef++)   = tmp2;
-
-                        max  |= (tmp1 >> 31) ^ tmp1;
-                        max  |= (tmp2 >> 31) ^ tmp2;
-                        tmp1 = *(pCoef++) >> shift_amt;
-                        tmp2 = *(pCoef--) >> shift_amt;
-
-                    }
-                    *(pCoef++)   = tmp1;
-                    *(pCoef++)   = tmp2;
-                    max  |= (tmp1 >> 31) ^ tmp1;
-                    max  |= (tmp2 >> 31) ^ tmp2;
-
-                }
-                else
-                {
-                    pv_memset(pCoef, 0, sizeof(Int32)*sfbWidth);
-                    pCoef += sfbWidth;
-                }
-            }
-
-            abs_max_per_window[win] = max;
-
-        }
-
-    } /* for (win) */
-
-    return min_q;
-
-} /* normalize() */
diff --git a/media/libstagefright/codecs/aacdec/q_normalize.h b/media/libstagefright/codecs/aacdec/q_normalize.h
deleted file mode 100644
index 63a9d53..0000000
--- a/media/libstagefright/codecs/aacdec/q_normalize.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: q_normalize.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Added PV Copyright notice.
- (2) Removed embedded TABS
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-  This file includes the function definition for q_normalize.h
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef Q_NORMALIZE_H
-#define Q_NORMALIZE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int q_normalize(
-        Int        qFormat[],
-        const FrameInfo *pFrameInfo,
-        Int32     abs_max_per_window[],
-        Int32      coef[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp b/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp
deleted file mode 100644
index 1164129..0000000
--- a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.cpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: qmf_filterbank_coeff.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function defines the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "qmf_filterbank_coeff.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-
-const Int32 sbrDecoderFilterbankCoefficients[155] =
-{
-    /*  10/9*table */
-
-    0xFFEA0066,  0x020C09CF,  0x34F67965,  0xCE380A2F,  0xFE43005A,
-    0xFFEA006C,  0x02360998,  0x36907954,  0xCFCD0A57,  0xFE690054,
-    0xFFEC0072,  0x0262095B,  0x382B7937,  0xD1600A7A,  0xFE8E004F,
-    0xFFED0078,  0x028E0919,  0x39C6790F,  0xD2F00A98,  0xFEB20049,
-    0xFFED007E,  0x02BB08D0,  0x3B6378DB,  0xD47D0AB1,  0xFED50043,
-    0xFFEC0084,  0x02E90882,  0x3D00789B,  0xD6080AC6,  0xFEF6003E,
-    0xFFEB0089,  0x0318082F,  0x3E9D7851,  0xD78F0AD6,  0xFF160039,
-    0xFFEB008F,  0x034807D5,  0x403A77FB,  0xD9130AE2,  0xFF350033,
-    0xFFEA0095,  0x03790775,  0x41D7779A,  0xDA930AEA,  0xFF53002E,
-    0xFFE9009A,  0x03AB070E,  0x4373772D,  0xDC100AED,  0xFF6F0029,
-    0xFFE800A0,  0x03DE06A2,  0x450D76B6,  0xDD890AED,  0xFF8A0024,
-    0xFFE800A5,  0x0412062F,  0x46A77633,  0xDEFD0AE9,  0xFFA40020,
-    0xFFE700AA,  0x044705B6,  0x483F75A6,  0xE06D0AE2,  0xFFBD001C,
-    0xFFE600AF,  0x047B0537,  0x49D5750E,  0xE1D90AD7,  0xFFD40017,
-    0xFFE500B3,  0x04B104B0,  0x4B69746B,  0xE3400AC8,  0xFFEB0013,
-    0xFFE400B8,  0x04E70423,  0x4CFA73BE,  0xE4A20AB7,  0x0002000F,
-    0xFFE400BC,  0x051E0390,  0x4E897306,  0xE5FF0AA2,  0x0016000B,
-    0xFFE300BF,  0x055502F6,  0x50157244,  0xE7560A8A,  0x00280008,
-    0xFFE300C3,  0x058D0254,  0x519D7178,  0xE8A80A6F,  0x003A0004,
-    0xFFE300C6,  0x05C401AD,  0x532270A2,  0xE9F50A53,  0x004A0001,
-    0xFFE200C8,  0x05FC00FE,  0x54A36FC3,  0xEB3C0A33,  0x005AFFFC,
-    0xFFE200CA,  0x06340048,  0x56206EDA,  0xEC7D0A11,  0x0068FFF9,
-    0xFFE200CC,  0x066CFF8A,  0x57986DE8,  0xEDB809EC,  0x0075FFF7,
-    0xFFE200CD,  0x06A4FEC6,  0x590C6CEC,  0xEEED09C6,  0x0081FFF4,
-    0xFFE200CE,  0x06DCFDFC,  0x5A7B6BE7,  0xF01C099E,  0x008DFFF2,
-    0xFFE200CE,  0x0713FD2B,  0x5BE56ADA,  0xF1450973,  0x0097FFF0,
-    0xFFE300CD,  0x074BFC52,  0x5D4869C4,  0xF2680947,  0x00A0FFEE,
-    0xFFE300CC,  0x0781FB73,  0x5EA668A6,  0xF384091A,  0x00A8FFEC,
-    0xFFE400CA,  0x07B7FA8D,  0x5FFF6780,  0xF49908EB,  0x00B0FFEA,
-    0xFFE400C8,  0x07EDF9A0,  0x61506652,  0xF5A808BA,  0x00B6FFE9,
-    0xFFE500C5,  0x0822F8AC,  0x629B651C,  0xF6B00888,  0x00BCFFE7
-};
-
-
-const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160] =
-{
-    0x0000FFEE,  0xFFF0FFEF, 0xFFEEFFED, 0xFFEBFFEA,
-    0xFFE9FFE8,  0xFFE7FFE6, 0xFFE6FFE7, 0xFFE7FFE8,
-    0xFFEAFFED,  0xFFEFFFF3, 0xFFF7FFFB, 0x00000007,
-    0x000D0014,  0x001C0025, 0x002E0037, 0x0041004B,
-    0x00560061,  0x006B0076, 0x0080008A, 0x0094009D,
-    0x00A500AC,  0x00B200B6, 0x00B800B9, 0x00B700B3,
-    0x00AD00A3,  0x00970087, 0x0074005D, 0x00420024,
-    0x0001FFDA,  0xFFAFFF7F, 0xFF4BFF12, 0xFED5FE93,
-    0x01B301FD,  0x024C029E, 0x02F4034D, 0x03A90408,
-    0x046904CC,  0x05300595, 0x05FA065E, 0x06C10722,
-    0x078007DA,  0x08300881, 0x08CB090F, 0x094A097C,
-    0x09A409C1,  0x09D209D5, 0x09CB09B2, 0x0988094D,
-    0x090108A2,  0x082F07A8, 0x070C0659, 0x059104B1,
-    0x03B902AA,  0x01810041, 0xFEE7FD74, 0xFBE9FA45,
-    0xF887F6B2,  0xF4C4F2BF, 0xF0A4EE72, 0xEC2AE9CF,
-    0xE760E4DE,  0xE24CDFA9, 0xDCF9DA3B, 0xD772D4A0,
-    0x2E3A311B,  0x33FF36E7, 0x39CE3CB4, 0x3F964273,
-    0x45484813,  0x4AD24D84, 0x502552B4, 0x55305795,
-    0x59E35C17,  0x5E2F602B, 0x620863C4, 0x655F66D7,
-    0x682B6959,  0x6A626B43, 0x6BFC6C8C, 0x6CF46D32,
-    0x6D476D32,  0x6CF46C8C, 0x6BFC6B43, 0x6A626959,
-    0x682B66D7,  0x655F63C4, 0x6208602B, 0x5E2F5C17,
-    0x59E35795,  0x553052B4, 0x50254D84, 0x4AD24813,
-    0x45484273,  0x3F963CB4, 0x39CE36E7, 0x33FF311B,
-    0xD1C6D4A0,  0xD772DA3B, 0xDCF9DFA9, 0xE24CE4DE,
-    0xE760E9CF,  0xEC2AEE72, 0xF0A4F2BF, 0xF4C4F6B2,
-    0xF887FA45,  0xFBE9FD74, 0xFEE70041, 0x018102AA,
-    0x03B904B1,  0x05910659, 0x070C07A8, 0x082F08A2,
-    0x0901094D,  0x098809B2, 0x09CB09D5, 0x09D209C1,
-    0x09A4097C,  0x094A090F, 0x08CB0881, 0x083007DA,
-    0x07800722,  0x06C1065E, 0x05FA0595, 0x053004CC,
-    0x04690408,  0x03A9034D, 0x02F4029E, 0x024C01FD,
-    0xFE4DFE93,  0xFED5FF12, 0xFF4BFF7F, 0xFFAFFFDA,
-    0x00010024,  0x0042005D, 0x00740087, 0x009700A3,
-    0x00AD00B3,  0x00B700B9, 0x00B800B6, 0x00B200AC,
-    0x00A5009D,  0x0094008A, 0x00800076, 0x006B0061,
-    0x0056004B,  0x00410037, 0x002E0025, 0x001C0014,
-    0x000D0007,  0x0000FFFB, 0xFFF7FFF3, 0xFFEFFFED,
-    0xFFEAFFE8,  0xFFE7FFE7, 0xFFE6FFE6, 0xFFE7FFE8,
-    0xFFE9FFEA,  0xFFEBFFED, 0xFFEEFFEF, 0xFFF0FFEE
-};
-
-const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155] =
-{
-
-    Qfmt27(-0.00079446133872F), Qfmt27(0.02197766364781F), Qfmt27(0.54254182141522F), Qfmt27(-0.47923775873194F),
-    Qfmt27(-0.01574239605130F), Qfmt27(-0.00068946163857F), Qfmt27(0.02537571195384F), Qfmt27(0.57449847577240F),
-    Qfmt27(-0.44806230039026F), Qfmt27(-0.01291535202742F), Qfmt27(-0.00071286404460F), Qfmt27(0.02892516313544F),
-    Qfmt27(0.60657315615086F), Qfmt27(-0.41729436041451F), Qfmt27(-0.01026942774868F), Qfmt27(-0.00077308974337F),
-    Qfmt27(0.03262310249845F), Qfmt27(0.63865835544980F), Qfmt27(-0.38701849746199F), Qfmt27(-0.00782586328859F),
-    Qfmt27(-0.00083027488297F), Qfmt27(0.03646915244785F), Qfmt27(0.67068416485018F), Qfmt27(-0.35729827194706F),
-    Qfmt27(-0.00557215982767F), Qfmt27(-0.00089272089703F), Qfmt27(0.04045671426315F), Qfmt27(0.70254003810627F),
-    Qfmt27(-0.32819525024294F), Qfmt27(-0.00351102841332F), Qfmt27(-0.00095851011196F), Qfmt27(0.04455021764484F),
-    Qfmt27(0.73415149000395F), Qfmt27(-0.29977591877185F), Qfmt27(-0.00163598204794F), Qfmt27(-0.00101225729839F),
-    Qfmt27(0.04873676213679F), Qfmt27(0.76545064960593F), Qfmt27(-0.27208998714049F), Qfmt27(0.00003903936539F),
-    Qfmt27(-0.00105230782648F), Qfmt27(0.05300654158217F), Qfmt27(0.79631383686511F), Qfmt27(-0.24519750285673F),
-    Qfmt27(0.00154182229475F), Qfmt27(-0.00108630976316F), Qfmt27(0.05732502937107F), Qfmt27(0.82666485395476F),
-    Qfmt27(-0.21914753347432F), Qfmt27(0.00286720203220F), Qfmt27(-0.00110794157381F), Qfmt27(0.06167350555855F),
-    Qfmt27(0.85641712130638F), Qfmt27(-0.19396671004887F), Qfmt27(0.00402297937976F), Qfmt27(-0.00110360418081F),
-    Qfmt27(0.06602157445253F), Qfmt27(0.88547343436495F), Qfmt27(-0.16971665552213F), Qfmt27(0.00500649278750F),
-    Qfmt27(-0.00109714405326F), Qfmt27(0.07034096875232F), Qfmt27(0.91376152398903F), Qfmt27(-0.14641770628514F),
-    Qfmt27(0.00583386287581F), Qfmt27(-0.00106490281247F), Qfmt27(0.07461825625751F), Qfmt27(0.94117890777861F),
-    Qfmt27(-0.12410396326951F), Qfmt27(0.00651097277313F), Qfmt27(-0.00102041023958F), Qfmt27(0.07879625324269F),
-    Qfmt27(0.96765488212662F), Qfmt27(-0.10280530739363F), Qfmt27(0.00704839655425F), Qfmt27(-0.00094051141595F),
-    Qfmt27(0.08286099010631F), Qfmt27(0.99311573680798F), Qfmt27(-0.08254839941155F), Qfmt27(0.00745513427428F),
-    Qfmt27(-0.00084090835475F), Qfmt27(0.08675566213219F), Qfmt27(1.01745066253324F), Qfmt27(-0.06332944781672F),
-    Qfmt27(0.00774335382672F), Qfmt27(-0.00072769348801F), Qfmt27(0.09046949018457F), Qfmt27(1.04060828658052F),
-    Qfmt27(-0.04518854556363F), Qfmt27(0.00790787636150F), Qfmt27(-0.00057913742435F), Qfmt27(0.09395575430420F),
-    Qfmt27(1.06251808919053F), Qfmt27(-0.02811939233087F), Qfmt27(0.00797463714114F), Qfmt27(-0.00040969484059F),
-    Qfmt27(0.09716267023308F), Qfmt27(1.08310018709600F), Qfmt27(-0.01212147193047F), Qfmt27(0.00795079915733F),
-    Qfmt27(-0.00020454902123F), Qfmt27(0.10007381188066F), Qfmt27(1.10227871198194F), Qfmt27(0.00279527795884F),
-    Qfmt27(0.00784545014643F), Qfmt27(0.00001908481202F), Qfmt27(0.10262701466139F), Qfmt27(1.12001978353403F),
-    Qfmt27(0.01663452156443F), Qfmt27(0.00766458213130F), Qfmt27(0.00028892665922F), Qfmt27(0.10479373974558F),
-    Qfmt27(1.13624787143434F), Qfmt27(0.02941522773279F), Qfmt27(0.00741912981120F), Qfmt27(0.00056943874774F),
-    Qfmt27(0.10650970405576F), Qfmt27(1.15091404672203F), Qfmt27(0.04112872592057F), Qfmt27(0.00712664923329F),
-    Qfmt27(0.00088238158168F), Qfmt27(0.10776200996423F), Qfmt27(1.16395714324633F), Qfmt27(0.05181934748033F),
-    Qfmt27(0.00677868764313F), Qfmt27(0.00121741725989F), Qfmt27(0.10848340171661F), Qfmt27(1.17535833075364F),
-    Qfmt27(0.06148559051724F), Qfmt27(0.00639363830229F), Qfmt27(0.00159101288509F), Qfmt27(0.10864412991640F),
-    Qfmt27(1.18507099110810F), Qfmt27(0.07014197759039F), Qfmt27(0.00597707038378F), Qfmt27(0.00196610899088F),
-    Qfmt27(0.10819451041273F), Qfmt27(1.19306425909871F), Qfmt27(0.07784680399703F), Qfmt27(0.00554476792518F),
-    Qfmt27(0.00238550675072F), Qfmt27(0.10709920766553F), Qfmt27(1.19929775892826F), Qfmt27(0.08459352758522F),
-    Qfmt27(0.00509233837916F), Qfmt27(0.00280596092809F), Qfmt27(0.10531144797543F), Qfmt27(1.20377455661175F),
-    Qfmt27(0.09043115226911F), Qfmt27(0.00463008004888F), Qfmt27(0.00325513071185F), Qfmt27(0.10278145526768F),
-    Qfmt27(1.20646855283790F), Qfmt27(0.09539224314440F), Qfmt27(0.00416760958657F)
-};
-
-
-
-#ifdef HQ_SBR
-
-
-const Int32 sbrDecoderFilterbankCoefficients_an_filt[155] =
-{
-    Qfmt27(-0.000561769F),   Qfmt27(+ 0.015540555F),   Qfmt27(+ 0.383635001F),   Qfmt27(-0.338872269F),   Qfmt27(-0.011131555F),
-    Qfmt27(-0.000487523F),   Qfmt27(+ 0.017943338F),   Qfmt27(+ 0.406231768F),   Qfmt27(-0.316827891F),   Qfmt27(-0.009132533F),
-    Qfmt27(-0.000504071F),   Qfmt27(+ 0.020453179F),   Qfmt27(+ 0.428911992F),   Qfmt27(-0.295071672F),   Qfmt27(-0.007261582F),
-    Qfmt27(-0.000546657F),   Qfmt27(+ 0.023068017F),   Qfmt27(+ 0.451599654F),   Qfmt27(-0.273663404F),   Qfmt27(-0.005533721F),
-    Qfmt27(-0.000587093F),   Qfmt27(+ 0.025787585F),   Qfmt27(+ 0.474245321F),   Qfmt27(-0.252648031F),   Qfmt27(-0.003940112F),
-    Qfmt27(-0.000631249F),   Qfmt27(+ 0.028607217F),   Qfmt27(+ 0.496770825F),   Qfmt27(-0.232069087F),   Qfmt27(-0.002482672F),
-    Qfmt27(-0.000677769F),   Qfmt27(+ 0.031501761F),   Qfmt27(+ 0.519123497F),   Qfmt27(-0.211973585F),   Qfmt27(-0.001156814F),
-    Qfmt27(-0.000715774F),   Qfmt27(+ 0.034462095F),   Qfmt27(+ 0.541255345F),   Qfmt27(-0.192396675F),   Qfmt27(+ 0.000027605F),
-    Qfmt27(-0.000744094F),   Qfmt27(+ 0.037481285F),   Qfmt27(+ 0.563078914F),   Qfmt27(-0.173380817F),   Qfmt27(+ 0.001090233F),
-    Qfmt27(-0.000768137F),   Qfmt27(+ 0.040534917F),   Qfmt27(+ 0.584540324F),   Qfmt27(-0.154960707F),   Qfmt27(+ 0.002027418F),
-    Qfmt27(-0.000783433F),   Qfmt27(+ 0.043609754F),   Qfmt27(+ 0.605578354F),   Qfmt27(-0.137155176F),   Qfmt27(+ 0.002844676F),
-    Qfmt27(-0.000780366F),   Qfmt27(+ 0.046684303F),   Qfmt27(+ 0.626124270F),   Qfmt27(-0.120007798F),   Qfmt27(+ 0.003540125F),
-    Qfmt27(-0.000775798F),   Qfmt27(+ 0.049738576F),   Qfmt27(+ 0.646126970F),   Qfmt27(-0.103532953F),   Qfmt27(+ 0.004125164F),
-    Qfmt27(-0.000753000F),   Qfmt27(+ 0.052763075F),   Qfmt27(+ 0.665513988F),   Qfmt27(-0.087754754F),   Qfmt27(+ 0.004603953F),
-    Qfmt27(-0.000721539F),   Qfmt27(+ 0.055717365F),   Qfmt27(+ 0.684235329F),   Qfmt27(-0.072694330F),   Qfmt27(+ 0.004983969F),
-    Qfmt27(-0.000665042F),   Qfmt27(+ 0.058591568F),   Qfmt27(+ 0.702238872F),   Qfmt27(-0.058370533F),   Qfmt27(+ 0.005271576F),
-    Qfmt27(-0.000594612F),   Qfmt27(+ 0.061345517F),   Qfmt27(+ 0.719446263F),   Qfmt27(-0.044780682F),   Qfmt27(+ 0.005475378F),
-    Qfmt27(-0.000514557F),   Qfmt27(+ 0.063971590F),   Qfmt27(+ 0.735821176F),   Qfmt27(-0.031953127F),   Qfmt27(+ 0.005591713F),
-    Qfmt27(-0.000409512F),   Qfmt27(+ 0.066436751F),   Qfmt27(+ 0.751313746F),   Qfmt27(-0.019883413F),   Qfmt27(+ 0.005638920F),
-    Qfmt27(-0.000289698F),   Qfmt27(+ 0.068704383F),   Qfmt27(+ 0.765867487F),   Qfmt27(-0.008571175F),   Qfmt27(+ 0.005622064F),
-    Qfmt27(-0.000144638F),   Qfmt27(+ 0.070762871F),   Qfmt27(+ 0.779428752F),   Qfmt27(+ 0.001976560F),   Qfmt27(+ 0.005547571F),
-    Qfmt27(+ 0.000013495F),   Qfmt27(+ 0.072568258F),   Qfmt27(+ 0.791973584F),   Qfmt27(+ 0.011762383F),   Qfmt27(+ 0.005419678F),
-    Qfmt27(+ 0.000204302F),   Qfmt27(+ 0.074100364F),   Qfmt27(+ 0.803448575F),   Qfmt27(+ 0.020799707F),   Qfmt27(+ 0.005246117F),
-    Qfmt27(+ 0.000402654F),   Qfmt27(+ 0.075313734F),   Qfmt27(+ 0.813819127F),   Qfmt27(+ 0.029082401F),   Qfmt27(+ 0.005039302F),
-    Qfmt27(+ 0.000623938F),   Qfmt27(+ 0.076199248F),   Qfmt27(+ 0.823041989F),   Qfmt27(+ 0.036641812F),   Qfmt27(+ 0.004793256F),
-    Qfmt27(+ 0.000860844F),   Qfmt27(+ 0.076709349F),   Qfmt27(+ 0.831103846F),   Qfmt27(+ 0.043476878F),   Qfmt27(+ 0.004520985F),
-    Qfmt27(+ 0.001125016F),   Qfmt27(+ 0.076823001F),   Qfmt27(+ 0.837971734F),   Qfmt27(+ 0.049597868F),   Qfmt27(+ 0.004226427F),
-    Qfmt27(+ 0.001390249F),   Qfmt27(+ 0.076505072F),   Qfmt27(+ 0.843623828F),   Qfmt27(+ 0.055046003F),   Qfmt27(+ 0.003920743F),
-    Qfmt27(+ 0.001686808F),   Qfmt27(+ 0.075730576F),   Qfmt27(+ 0.848031578F),   Qfmt27(+ 0.059816657F),   Qfmt27(+ 0.003600827F),
-    Qfmt27(+ 0.001984114F),   Qfmt27(+ 0.074466439F),   Qfmt27(+ 0.851197152F),   Qfmt27(+ 0.063944481F),   Qfmt27(+ 0.003273961F),
-    Qfmt27(+ 0.002301725F),   Qfmt27(+ 0.072677464F),   Qfmt27(+ 0.853102095F),   Qfmt27(+ 0.067452502F),   Qfmt27(+ 0.002946945F)
-};
-
-
-
-#endif  /* HQ_SBR */
-
-
-#endif  /* AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h b/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h
deleted file mode 100644
index c8968cb..0000000
--- a/media/libstagefright/codecs/aacdec/qmf_filterbank_coeff.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: qmf_filterbank_coeff.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef QMF_FILTERBANK_COEFF_H
-#define QMF_FILTERBANK_COEFF_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-#define Qfmt(x)   (Int16)(x*(((Int32)1<<15)*1.11111111111111111F) + (x>=0?0.5F:-0.5F))
-
-
-#define Qfmt30(x)   (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Qfmt27(x)   (Int32)(x*(((Int32)1<<27)) + (x>=0?0.5F:-0.5F))
-
-extern const Int32 sbrDecoderFilterbankCoefficients[155];
-
-
-extern const Int32 sbrDecoderFilterbankCoefficients_down_smpl[160];
-extern const Int32 sbrDecoderFilterbankCoefficients_an_filt_LC[155];
-
-#ifdef HQ_SBR
-extern const Int32 sbrDecoderFilterbankCoefficients_an_filt[155];
-#endif
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_adif_header.h b/media/libstagefright/codecs/aacdec/s_adif_header.h
deleted file mode 100644
index 7fd49d3..0000000
--- a/media/libstagefright/codecs/aacdec/s_adif_header.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_ADIF_Header.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, ADIF_Header
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_ADIF_HEADER_H
-#define S_ADIF_HEADER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_adif_const.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-    Char    adif_id[LEN_ADIF_ID+1];
-    Int     copy_id_present;
-    Char    copy_id[LEN_COPYRT_ID+1];
-    Int     original_copy;
-    Int     home;
-    Int     bitstream_type;
-    Int32   bitrate;
-    Int     num_pce;
-    Int     prog_tags[(1<<LEN_TAG)];
-} ADIF_Header;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_bit_buffer.h b/media/libstagefright/codecs/aacdec/s_bit_buffer.h
deleted file mode 100644
index 9f0dbda..0000000
--- a/media/libstagefright/codecs/aacdec/s_bit_buffer.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_bit_buffer.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_BIT_BUFFER_H
-#define S_BIT_BUFFER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    UChar *char_ptr;
-    UInt32 buffered_bits;
-    UInt32 buffer_word;
-    UInt32 nrBitsRead;
-    UInt32 bufferLen;
-}
-BIT_BUFFER;
-
-typedef BIT_BUFFER *HANDLE_BIT_BUFFER;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_bits.h b/media/libstagefright/codecs/aacdec/s_bits.h
deleted file mode 100644
index cae69ad..0000000
--- a/media/libstagefright/codecs/aacdec/s_bits.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_BITS.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove unused field.
-
- Description: Change buffer type from UInt to UInt32, makes API much easier
-              to understand and describe, and getbits is faster on TI C55X
-              if the buffer is 32 bits instead of 16.
-
- Description: Change buffer type from UInt32 to UChar.
-
- Who:                                   Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, BITS
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef  S_BITS_H
-#define  S_BITS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-/*
- * Name: BITS
- * Description: Holds information for processing the input data buffer
- *    as a "stream". The data is in packed format.
- * Fields:
- *    pBuffer - pointer to the beginning of the buffer. If the data type of
- *        this changes, make sure to update the constants in ibstream.h
- *    usedBits - number of bits read thus far from the buffer. Bit 0 is
- *        the LSB of pBuffer[0].
- *    availableBits - number of bits available in the buffer.
- *    byteAlignOffset - used with ADTS in case sync word is not aligned
-                        on a boundary.
- */
-typedef struct
-{
-    UChar    *pBuffer;
-    UInt      usedBits;      /* Keep this unsigned so can go to 65536 */
-    UInt      availableBits; /* Ditto */
-    UInt      inputBufferCurrentLength; /* Ditto */
-    Int      byteAlignOffset; /* Used in ADTS.  See find_adts_syncword() */
-} BITS;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_ch_info.h b/media/libstagefright/codecs/aacdec/s_ch_info.h
deleted file mode 100644
index 9fd259c..0000000
--- a/media/libstagefright/codecs/aacdec/s_ch_info.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Ch_Info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Ch_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_CH_INFO_H
-#define S_CH_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-//    Int present;    /* channel present */
-    Int tag;        /* element tag */
-    Int cpe;        /* 0 if single channel, 1 if channel pair */
-//    Int common_window;  /* 1 if common window for cpe */
-//    Int ch_is_left; /* 1 if left channel of cpe */
-//    Int paired_ch;  /* index of paired channel in cpe */
-//    Int widx;       /* window element index for this channel */
-    Int is_present; /* intensity stereo is used */
-    Int ncch;       /* number of coupling channels for this ch */
-    /* #if (CChans > 0) */
-    /*    int cch[CChans];*/    /* coupling channel idx */
-    /*    int cc_dom[CChans];*/ /* coupling channel domain */
-    /*    int cc_ind[CChans];*/ /* independently switched coupling channel flag */
-    /* #endif */
-    Char *fext;     /* filename extension */
-
-} Ch_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_crc_buffer.h b/media/libstagefright/codecs/aacdec/s_crc_buffer.h
deleted file mode 100644
index 69250e7..0000000
--- a/media/libstagefright/codecs/aacdec/s_crc_buffer.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_crc_buffer.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_CRC_BUFFER_H
-#define S_CRC_BUFFER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    unsigned short crcState;
-    unsigned short crcMask;
-    unsigned short crcPoly;
-}
-CRC_BUFFER;
-
-typedef CRC_BUFFER *HANDLE_CRC;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_elelist.h b/media/libstagefright/codecs/aacdec/s_elelist.h
deleted file mode 100644
index 40b2f13..0000000
--- a/media/libstagefright/codecs/aacdec/s_elelist.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_EleList.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, EleList
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_ELELIST_H
-#define S_ELELIST_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-    Int num_ele;
-    Int ele_is_cpe[(1<<LEN_TAG)];
-    Int ele_tag[(1<<LEN_TAG)];
-} EleList;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_frameinfo.h b/media/libstagefright/codecs/aacdec/s_frameinfo.h
deleted file mode 100644
index 871ae83..0000000
--- a/media/libstagefright/codecs/aacdec/s_frameinfo.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_frameinfo.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changed name of bk_sfb_top to frame_sfb_top.
- Included "interface.h" for defintion of MAX_WIN.  This
- will hopefully be simplified when interface.h is broken up into smaller
- include files.
-
- Description: Eliminated the never used array, group_offs[8]
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, FrameInfo
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_FRAMEINFO_H
-#define S_FRAMEINFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_blockswitching.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    typedef struct
-    {
-        Int     islong;                 /* true if long block */
-        Int     num_win;                /* sub-blocks (SB) per block */
-        Int     coef_per_frame;         /* coef's per block */
-        Int     sfb_per_frame;          /* sfb per block */
-        Int     coef_per_win[MAX_WIN];  /* coef's per SB */
-        Int     sfb_per_win[MAX_WIN];   /* sfb per SB */
-        Int     sectbits[MAX_WIN];
-        Int16   *win_sfb_top[MAX_WIN];  /* top coef per sfb per SB */
-        Int     *sfb_width_128;         /* sfb width for short blocks */
-
-        Int     frame_sfb_top[MAXBANDS];    /* Only used in calc_gsfb_table() -
-                                      it is simply a cum version of
-                                      the above information */
-        Int     num_groups;
-        Int     group_len[8];
-
-    } FrameInfo;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_FRAMEINFO_H */
diff --git a/media/libstagefright/codecs/aacdec/s_hcb.h b/media/libstagefright/codecs/aacdec/s_hcb.h
deleted file mode 100644
index 6a64c27..0000000
--- a/media/libstagefright/codecs/aacdec/s_hcb.h
+++ /dev/null
@@ -1,123 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Hcb.h
-
-     Date: 05/07/2001
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) LAV removed from structure definition, since it was never used.
-
- Description: Huffman tables are stored as UInt16
-
- Description: Modified the declaration of the structure so no pointers are
-              used in the structure.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define the structure Hcb to store Huffman codebook information,
- this structure was originally defined in all.h
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HCB_H
-#define S_HCB_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_huffman.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    typedef struct
-    {
-        Int     n;
-        Int     dim;
-        Int     mod;
-        Int     off;
-        Int     signed_cb;
-    } Hcb;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_HCB_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_huffman.h b/media/libstagefright/codecs/aacdec/s_huffman.h
deleted file mode 100644
index 2db3dd9..0000000
--- a/media/libstagefright/codecs/aacdec/s_huffman.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Huffman.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:   Changed "ulong" to "UInt32"
-
- Description: add helper structure to speed up decode_huff_cw
-
- Description: Remove the structure definition of Huffman
-
- Description: Added definition for SBR Huffman, used for AAC plus
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Huffman
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HUFFMAN_H
-#define S_HUFFMAN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef const Char(*SbrHuffman)[2];
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_hybrid.h b/media/libstagefright/codecs/aacdec/s_hybrid.h
deleted file mode 100644
index 3880d30..0000000
--- a/media/libstagefright/codecs/aacdec/s_hybrid.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_hybrid.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_HYBRID_H
-#define S_HYBRID_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "ps_constants.h"
-#include    "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define HYBRID_FILTER_LENGTH        13
-#define HYBRID_FILTER_LENGTH_m_1    12
-#define HYBRID_FILTER_DELAY         6
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef enum
-{
-
-    HYBRID_2_REAL = 2,
-    HYBRID_4_CPLX = 4,
-    HYBRID_8_CPLX = 8
-
-} HYBRID_RES;
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int32   nQmfBands;
-    Int32   *pResolution;
-    Int32   qmfBufferMove;
-
-    Int32 **mQmfBufferReal;
-    Int32 **mQmfBufferImag;
-    Int32 *mTempReal;
-    Int32 *mTempImag;
-
-
-} HYBRID;
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-
-#endif      /*  S_HYBRID_H */
diff --git a/media/libstagefright/codecs/aacdec/s_lt_pred_status.h b/media/libstagefright/codecs/aacdec/s_lt_pred_status.h
deleted file mode 100644
index 4b5b56e..0000000
--- a/media/libstagefright/codecs/aacdec/s_lt_pred_status.h
+++ /dev/null
@@ -1,174 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: LT_PRED_STATUS.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
- (1) Merged in #defines from ltp_common.h, thereby eliminating that file.
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description: Moved large ltp_buffer up to s_tDec_Int_Chan.h, since this
- move allowed for other elements in this structure to be shared with
- the fxpCoef array.
-
- Description: Decreased size of LTP buffers from 4096 to 3072.  The upper 1024
- elements in the LTP buffers were never touched in the code.  This saves
- 4 kilobytes in memory.
-
- Description: Decreased size of LTP buffers again from 3072 to 2048.  This
- time, I realized that 1024 elements were duplicated in the 32-bit array
- pVars->pChVars[]->time_quant.  Rather than copy this data EVERY frame
- from a 32-bit to a 16-bit LTP buffer, the data is accessed only
- when it is needed.  This saves both MIPS and memory.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define LT_PRED_STATUS structure for pulse data decoding.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_LT_PRED_STATUS_H
-#define S_LT_PRED_STATUS_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_blockswitching.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-    /*
-      Macro:    MAX_SHORT_WINDOWS
-      Purpose:  Number of short windows in one long window.
-      Explanation:  -  */
-#ifndef MAX_SHORT_WINDOWS
-#define MAX_SHORT_WINDOWS NSHORT
-#endif
-
-    /*
-      Macro:    MAX_SCFAC_BANDS
-      Purpose:  Maximum number of scalefactor bands in one frame.
-      Explanation:  -  */
-#ifndef MAX_SCFAC_BANDS
-#define MAX_SCFAC_BANDS MAXBANDS
-#endif
-
-    /*
-      Macro:    BLOCK_LEN_LONG
-      Purpose:  Length of one long window
-      Explanation:  -  */
-#ifndef BLOCK_LEN_LONG
-#define BLOCK_LEN_LONG LN2
-#endif
-
-
-    /*
-      Macro:    LTP_MAX_BLOCK_LEN_LONG
-      Purpose:  Informs the routine of the maximum block size used.
-      Explanation:  This is needed since the TwinVQ long window
-            is different from the AAC long window.  */
-#define LTP_MAX_BLOCK_LEN_LONG BLOCK_LEN_LONG //(2 * BLOCK_LEN_LONG) 
-
-    /*
-      Macro:    LT_BLEN
-      Purpose:  Length of the history buffer.
-      Explanation:  Has to hold 2 long windows of time domain data.  */
-#ifndef LT_BLEN
-#define LT_BLEN (2 * LTP_MAX_BLOCK_LEN_LONG)
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    /*
-      Type:     LT_PRED_STATUS
-      Purpose:  Type of the struct holding the LTP encoding parameters.
-      Explanation:  -  */
-    typedef struct
-    {
-        Int weight_index;
-        Int win_prediction_used[MAX_SHORT_WINDOWS];
-        Int sfb_prediction_used[MAX_SCFAC_BANDS];
-        Bool ltp_data_present;
-
-        Int delay[MAX_SHORT_WINDOWS];
-    }
-    LT_PRED_STATUS;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_LT_PRED_STATUS_H */
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_mc_info.h b/media/libstagefright/codecs/aacdec/s_mc_info.h
deleted file mode 100644
index 9006119..0000000
--- a/media/libstagefright/codecs/aacdec/s_mc_info.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_MC_Info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, MC_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_MC_INFO_H
-#define S_MC_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-#include "s_ch_info.h"
-#include "chans.h"
-#include "e_tmp4audioobjecttype.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-    Int nch;        /* total number of audio channels */
-    Int nfsce;      /* number of front SCE's pror to first front CPE */
-    Int nfch;       /* number of front channels */
-    Int nsch;       /* number of side channels */
-    Int nbch;       /* number of back channels */
-    Int nlch;       /* number of lfe channels */
-    Int ncch;       /* number of valid coupling channels */
-    tMP4AudioObjectType audioObjectType;    /* Should eventually be called object */
-    Int sampling_rate_idx;
-
-    Int implicit_channeling;
-    Int  upsamplingFactor;
-#ifdef AAC_PLUS
-    bool bDownSampledSbr;
-    Int HE_AAC_level;
-#endif
-    /* All AAC content should be aware of these flag */
-    /*  AAC+ content Flag */
-    Int sbrPresentFlag;
-    /*  Enhanced AAC+ content Flag */
-    Int psPresentFlag;
-    tMP4AudioObjectType ExtendedAudioObjectType;    /* Should eventually be called object */
-
-    Ch_Info ch_info[Chans];
-} MC_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/s_mixdown.h b/media/libstagefright/codecs/aacdec/s_mixdown.h
deleted file mode 100644
index 7f456d5..0000000
--- a/media/libstagefright/codecs/aacdec/s_mixdown.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_MIXdown.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, MIXdown
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_MIXDOWN_H
-#define S_MIXDOWN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int present;
-    Int ele_tag;
-    Int pseudo_enab;
-} MIXdown;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_patch.h b/media/libstagefright/codecs/aacdec/s_patch.h
deleted file mode 100644
index 554fc2d..0000000
--- a/media/libstagefright/codecs/aacdec/s_patch.h
+++ /dev/null
@@ -1,121 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_patch.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PATCH_H
-#define S_PATCH_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_NUM_PATCHES   6
-
-#define     SBR_NUM_COLUMNS      38
-#define     SBR_NUM_BANDS        48
-#define     SBR_NUM_BANDS_OVR_4 (SBR_NUM_BANDS>>2)
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-struct PATCH
-{
-    Int32 noOfPatches;
-    Int32 targetStartBand[MAX_NUM_PATCHES];
-};
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_progconfig.h b/media/libstagefright/codecs/aacdec/s_progconfig.h
deleted file mode 100644
index e58e5fc..0000000
--- a/media/libstagefright/codecs/aacdec/s_progconfig.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_ProgConfig.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, ProgConfig
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PROGCONFIG_H
-#define S_PROGCONFIG_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_mixdown.h"
-#include "s_elelist.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int     profile;
-    Int     sampling_rate_idx;
-    EleList front;
-    EleList side;
-    EleList back;
-    EleList lfe;
-    EleList data;
-    EleList coupling;
-    MIXdown mono_mix;
-    MIXdown stereo_mix;
-    MIXdown matrix_mix;
-
-    Char    comments[(1<<LEN_PC_COMM)+1]; /* TO BE DELETED */
-
-    Int32   buffer_fullness;    /* put this transport level info here */
-    Bool    file_is_adts;       /* For ADTS use only */
-    Int32   headerless_frames;  /* For ADTS use only */
-    Int32   frame_length;       /* For use by ADTS only */
-    Int32   CRC_absent;         /* For use by ADTS only */
-    UInt32  CRC_check;          /* For use by ADTS only */
-
-} ProgConfig;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_ps_dec.h b/media/libstagefright/codecs/aacdec/s_ps_dec.h
deleted file mode 100644
index 8b4391c..0000000
--- a/media/libstagefright/codecs/aacdec/s_ps_dec.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/****************************************************************************
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2003.
-
-*******************************************************************************/
-
-#ifndef S_PS_DEC_H
-#define S_PS_DEC_H
-
-
-#include "s_hybrid.h"
-#include "s_patch.h"
-
-/****************************************************************
-  Type definitions
- ****************************************************************/
-struct PS_DEC
-{
-
-    Int psDetected;
-    Int32 *R_ch_qmf_filter_history;
-    Int32 invNoSubSamples;
-
-    Int32 bForceMono;
-    UInt32 noSubSamples;
-    Int32 usb;
-    Int32 lastUsb;
-
-    Int32 bPsDataAvail;
-
-    UInt32 bEnableIid;
-    UInt32 bEnableIcc;
-
-    UInt32 bEnableExt;
-    Int32 bFineIidQ;
-
-    Int32 aIidPrevFrameIndex[NO_HI_RES_BINS];
-    Int32 aIccPrevFrameIndex[NO_HI_RES_BINS];
-
-    UInt32 freqResIid;
-    UInt32 freqResIcc;
-
-    UInt32 bFrameClass;
-    UInt32 noEnv;
-    UInt32 aEnvStartStop[MAX_NO_PS_ENV+1];
-
-    UInt32 abIidDtFlag[MAX_NO_PS_ENV];
-    UInt32 abIccDtFlag[MAX_NO_PS_ENV];
-
-    Int32   delayBufIndex;
-
-    UInt32 aDelayRBufIndexSer[NO_SERIAL_ALLPASS_LINKS];
-
-    Int32 **aaaRealDelayRBufferSerQmf[NO_SERIAL_ALLPASS_LINKS];
-    Int32 **aaaImagDelayRBufferSerQmf[NO_SERIAL_ALLPASS_LINKS];
-
-    Int32 **aaaRealDelayRBufferSerSubQmf[NO_SERIAL_ALLPASS_LINKS];
-    Int32 **aaaImagDelayRBufferSerSubQmf[NO_SERIAL_ALLPASS_LINKS];
-
-    Int32 **aaRealDelayBufferQmf;
-    Int32 **aaImagDelayBufferQmf;
-    Int32 **aaRealDelayBufferSubQmf;
-    Int32 **aaImagDelayBufferSubQmf;
-
-    Int32 *aPeakDecayFast;
-    Int32 *aPrevNrg;
-    Int32 *aPrevPeakDiff;
-
-    Int32 *mHybridRealLeft;
-    Int32 *mHybridImagLeft;
-    Int32 *mHybridRealRight;
-    Int32 *mHybridImagRight;
-
-
-    HYBRID *hHybrid;
-
-
-
-    Int32 h11Prev[NO_IID_GROUPS];
-    Int32 h12Prev[NO_IID_GROUPS];
-    Int32 h21Prev[NO_IID_GROUPS];
-    Int32 h22Prev[NO_IID_GROUPS];
-
-    Int32 H11[NO_IID_GROUPS];
-    Int32 H12[NO_IID_GROUPS];
-    Int32 H21[NO_IID_GROUPS];
-    Int32 H22[NO_IID_GROUPS];
-
-    Int32 deltaH11[NO_IID_GROUPS];
-    Int32 deltaH12[NO_IID_GROUPS];
-    Int32 deltaH21[NO_IID_GROUPS];
-    Int32 deltaH22[NO_IID_GROUPS];
-
-    Int32(*qmfBufferReal)[64];
-    Int32(*qmfBufferImag)[64];
-
-    Int32 aDelayBufIndex[NO_DELAY_CHANNELS];
-    Int32 aNoSampleDelay[NO_DELAY_CHANNELS];  /////
-    Int32 aaIidIndex[MAX_NO_PS_ENV+1][NO_HI_RES_BINS];
-    Int32 aaIccIndex[MAX_NO_PS_ENV+1][NO_HI_RES_BINS];
-
-};
-
-typedef struct PS_DEC STRUCT_PS_DEC;
-typedef struct PS_DEC * HANDLE_PS_DEC;
-
-
-
-#endif      /*  E_PS_DEC_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_pulseinfo.h b/media/libstagefright/codecs/aacdec/s_pulseinfo.h
deleted file mode 100644
index a7ced04..0000000
--- a/media/libstagefright/codecs/aacdec/s_pulseinfo.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_PulseInfo.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Comment out unused field.
-
- Description:  Fix ARM warnings, update copyright.
-
- Who:                                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- define PulseInfo structure for pulse data decoding.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_PULSEINFO_H
-#define S_PULSEINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int pulse_data_present;
-    Int number_pulse;
-    Int pulse_start_sfb;
-    Int pulse_offset[NUM_PULSE_LINES];
-    Int pulse_amp[NUM_PULSE_LINES];
-} PulseInfo;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_channel.h b/media/libstagefright/codecs/aacdec/s_sbr_channel.h
deleted file mode 100644
index 99e28dd..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_channel.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_channel.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_CHANNEL_H
-#define S_SBR_CHANNEL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "s_sbr_frame_data.h"
-#include    "e_sbr_sync_state.h"
-
-#ifdef PARAMETRICSTEREO
-#include "s_ps_dec.h"
-
-#endif
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAXNRELEMENTS 1
-#define MAXNRSBRCHANNELS (MAXNRELEMENTS*2)
-
-#ifdef PARAMETRICSTEREO
-#define MAXNRQMFCHANNELS MAXNRSBRCHANNELS
-#else
-#define MAXNRQMFCHANNELS MAXNRSBRCHANNELS
-#endif
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int32 outFrameSize;
-    SBR_SYNC_STATE syncState;
-    SBR_FRAME_DATA frameData;
-
-} SBR_CHANNEL;
-
-typedef struct
-{
-    SBR_CHANNEL SbrChannel[MAXNRSBRCHANNELS];
-    Int32 setStreamType;
-#ifdef PARAMETRICSTEREO
-    HANDLE_PS_DEC hParametricStereoDec;
-    STRUCT_PS_DEC ParametricStereoDec;
-#endif
-
-} SBRDECODER_DATA;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_dec.h b/media/libstagefright/codecs/aacdec/s_sbr_dec.h
deleted file mode 100644
index 810479c..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_dec.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_dec.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_DEC_H
-#define S_SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "s_sbr_frame_data.h"
-#include    "pv_audio_type_defs.h"
-#include    "s_patch.h"
-#include    "e_blockswitching.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int32 outSampleRate;
-    Int32 LC_aacP_DecoderFlag;  /* Low Complexity decoder flag  */
-
-    Int32 startIndexCodecQmf;
-    Int32 lowBandAddSamples;
-    Int32 noCols;
-    Int32 qmfBufLen;
-    Int32 bufWriteOffs;
-    Int32 bufReadOffs;
-
-    Int32 sbStopCodec;
-    Int   lowSubband;
-    Int   prevLowSubband;
-    Int32 highSubband;
-    Int32 noSubbands;
-
-    Int   FreqBandTable[2][MAX_FREQ_COEFFS + 1];
-    Int32 FreqBandTableNoise[MAX_NOISE_COEFFS + 1];
-    Int32 V_k_master[MAX_FREQ_COEFFS + 1];         /* Master BandTable which freqBandTable is derived from*/
-    Int32 NSfb[2];
-    Int32 NoNoiseBands;                            /* Number of noisebands */
-    Int32 Num_Master;                              /* Number of bands in V_k_master*/
-
-    struct PATCH Patch;                         /* Used by sbr_generate_high_freq */
-    /* Used by calc_sbr_envelope */
-    Int32 gateMode[4];
-    Int32 limSbc[4][12 + 1];                            /* Limiting bands */
-
-    Int32 sqrt_cache[8][4];                     /* cache memory for repeated sqrt() calculations */
-
-} SBR_DEC;
-
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h b/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h
deleted file mode 100644
index e9b6780..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_element_stream.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_element_stream.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_ELEMENT_STREAM_H
-#define S_SBR_ELEMENT_STREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define MAXSBRBYTES 1024
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-    Int32 ElementID;
-    Int32 ExtensionType;
-    Int32 Payload;
-    UChar Data[MAXSBRBYTES];
-}
-SBR_ELEMENT_STREAM;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h b/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h
deleted file mode 100644
index 89d1bb1..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_frame_data.h
+++ /dev/null
@@ -1,181 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_frame_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_FRAME_DATA_H
-#define S_SBR_FRAME_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sbr_header_data.h"
-#include    "e_invf_mode.h"
-#include    "e_coupling_mode.h"
-#include    "sbr_constants.h"
-#include    "s_patch.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int32 nScaleFactors;            /* total number of scalefactors in frame */
-    Int32 nNoiseFactors;
-    Int32 crcCheckSum;
-    Int32 frameClass;
-    Int32 frameInfo[LENGTH_FRAME_INFO];
-    Int32 nSfb[2];
-    Int32 nNfb;
-    Int32 offset;
-    Int32 ampRes;
-    Int32 nNoiseFloorEnvelopes;
-    Int32 p;
-    Int32 prevEnvIsShort;
-
-    Int32 reset_flag;
-
-
-    SBR_HEADER_DATA sbr_header;
-
-
-    /* dynamic control signals */
-    Int32 domain_vec1[MAX_ENVELOPES];
-    Int32 domain_vec2[MAX_ENVELOPES];
-
-
-    INVF_MODE sbr_invf_mode[MAX_NUM_NOISE_VALUES];
-    INVF_MODE sbr_invf_mode_prev[MAX_NUM_NOISE_VALUES];
-
-    COUPLING_MODE coupling;               /*  3 possibilities: off, level, pan */
-
-
-    Int32 addHarmonics[MAX_NUM_ENVELOPE_VALUES];
-
-    /* Used by calc_sbr_envelope */
-    Int32 hFp[64];
-    Int32 harm_index;
-    Int32 phase_index;
-    Int32 sUp;
-
-    /*
-     *    envelope data
-     */
-
-    Int32 iEnvelope_man[MAX_NUM_ENVELOPE_VALUES]; /* mantissa */
-    Int32 iEnvelope_exp[MAX_NUM_ENVELOPE_VALUES]; /* exponent */
-    Int32 sfb_nrg_prev_man[MAX_FREQ_COEFFS];      /* mantissa */
-
-
-    /*
-     *    noise data
-     */
-
-    Int32 sbrNoiseFloorLevel_man[MAX_NUM_NOISE_VALUES]; /* mantissa */
-    Int32 sbrNoiseFloorLevel_exp[MAX_NUM_NOISE_VALUES]; /* exponent */
-    Int32 prevNoiseLevel_man[MAX_NUM_NOISE_VALUES]; /* mantissa */
-
-    Int32  BwVector[MAX_NUM_PATCHES];
-    Int32  BwVectorOld[MAX_NUM_PATCHES];
-    /* Both implement a pseudo circular buffer  */
-
-    /*
-     * 40 ==  Biggest of  autoCorrLength(38) + sbrDec->bufReadOffs (2)  and
-     *    sbrDec->noCols (32) + sbrDec->bufWriteOffs  (6)
-     */
-    Int32 codecQmfBufferReal[40][32];
-    Int32 *sbrQmfBufferReal;
-    Int32 HistsbrQmfBufferReal[6*SBR_NUM_BANDS];
-#ifdef HQ_SBR
-    Int32 codecQmfBufferImag[40][32];
-    Int32 *sbrQmfBufferImag;
-    Int32 HistsbrQmfBufferImag[6*SBR_NUM_BANDS];
-#endif
-    Int16  V[1152];     /* Used by calc_sbr_synfilterbank as freq. history buffer */
-
-
-    Int32 degreeAlias[64];
-
-
-#ifdef HQ_SBR
-
-    Int32 fBuffer_man[5][64];        /* smoothing history buffers */
-    Int32 fBufferN_man[5][64];
-    Int32 fBuffer_exp[5][64];        /* smoothing history buffers */
-    Int32 fBufferN_exp[5][64];
-
-    Int32 *fBuf_man[64];        /* pointer to smoothing history buffers */
-    Int32 *fBuf_exp[64];        /* pointer to smoothing history buffers */
-    Int32 *fBufN_man[64];
-    Int32 *fBufN_exp[64];
-
-
-#endif
-
-}
-SBR_FRAME_DATA;
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbr_header_data.h b/media/libstagefright/codecs/aacdec/s_sbr_header_data.h
deleted file mode 100644
index 7d7d746..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbr_header_data.h
+++ /dev/null
@@ -1,112 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbr_header_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBR_HEADER_DATA_H
-#define S_SBR_HEADER_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "e_sbr_header_status.h"
-#include    "e_sbr_master_status.h"
-#include    "e_sr_mode.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    SBR_HEADER_STATUS status;      /* the current status of the header     */
-    SBR_MASTER_STATUS masterStatus;/* status of v_k_master freq table      */
-
-    /* Changes in these variables indicates an error */
-    Int32 crcEnable;
-    SR_MODE sampleRateMode;
-    Int32 ampResolution;
-
-    /* Changes in these variables causes a reset of the decoder */
-    Int32 startFreq;
-    Int32 stopFreq;
-    Int32 xover_band;
-    Int32 freqScale;
-    Int32 alterScale;
-    Int32 noise_bands;               /* noise bands per octave, read from bitstream */
-
-    /* Helper variable*/
-    Int32 noNoiseBands;              /* actual number of noise bands to read from the bitstream */
-
-    Int32 limiterBands;
-    Int32 limiterGains;
-    Int32 interpolFreq;
-    Int32 smoothingLength;
-}
-SBR_HEADER_DATA;
-
-typedef SBR_HEADER_DATA *HANDLE_SBR_HEADER_DATA;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sbrbitstream.h b/media/libstagefright/codecs/aacdec/s_sbrbitstream.h
deleted file mode 100644
index 609463a..0000000
--- a/media/libstagefright/codecs/aacdec/s_sbrbitstream.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: s_sbrbitstream.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SBRBITSTREAM_H
-#define S_SBRBITSTREAM_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "s_sbr_element_stream.h"
-#include    "s_sbr_channel.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-typedef struct
-{
-    Int32 NrElements;
-    Int32 NrElementsCore;
-    SBR_ELEMENT_STREAM sbrElement[MAXNRELEMENTS];
-}
-SBRBITSTREAM;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sectinfo.h b/media/libstagefright/codecs/aacdec/s_sectinfo.h
deleted file mode 100644
index 83dcc31..0000000
--- a/media/libstagefright/codecs/aacdec/s_sectinfo.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/s_SectInfo.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- defines a structre that holds the Huffman codebook index and section
- boundary information for each Frame.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SECTINFO_H
-#define S_SECTINFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int   sect_cb;
-    Int   sect_end;
-} SectInfo;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/s_sr_info.h b/media/libstagefright/codecs/aacdec/s_sr_info.h
deleted file mode 100644
index 9b71003..0000000
--- a/media/libstagefright/codecs/aacdec/s_sr_info.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_SR_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified the declaration of the structure so no pointers are
-              used in the structure.
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, SR_Info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_SR_INFO_H
-#define S_SR_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int32   samp_rate;
-    Int     nsfb1024;
-    Int     nsfb128;
-} SR_Info;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h b/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h
deleted file mode 100644
index f7a3602..0000000
--- a/media/libstagefright/codecs/aacdec/s_tdec_int_chan.h
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_tDec_Int_Chan.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change data types of win
-
- Description: Remove wnd_shape structure.
-
- Description: Remove dependency on window_block.h, Fix header too.
-
- Description:
- Modified to utilize memory in the last 1024 elements in fxpCoef.
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) Move temporary FrameInfo structure into the shared region with fxpCoef.
- (2) Add more comments detailing the size of the shared structure.
-
- Description:
- (1) Changed time_quant from 2048 Int32 buffer to 1024 Int32 buffer.
-
- Who:                                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, tDec_Int_Chan
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TDEC_INT_CHAN_H
-#define S_TDEC_INT_CHAN_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_rawbitstreamconst.h"
-#include "s_tns_frame_info.h"
-#include "s_wnd_shape.h"
-#include "s_lt_pred_status.h"
-#include "s_sectinfo.h"
-#include "s_frameinfo.h"
-#include "e_window_shape.h"
-#include "e_window_sequence.h"
-#include "window_block_fxp.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /* This structure was created with the specific goal in mind of sharing memory
-     * with the last 1024 data elements in fxpCoef.
-     *
-     * The size of this structure must NOT exceed 4 kilobytes
-     * Also, the size of the fxpCoef array cannot be less than 8 kilobytes
-     *
-     * The fxpCoef array is declared as an Int32, so its size should not vary
-     * from platform to platform.
-     *
-     * The shared structure is 3,640 bytes (3.55 KB), on a 32-bit platform,
-     * which represents the worst case.
-     */
-    typedef struct
-    {
-        TNS_frame_info       tns;
-
-        FrameInfo            frameInfo;
-
-        Int                  factors[MAXBANDS];
-        Int                  cb_map[MAXBANDS];
-        Int                  group[NSHORT];
-        Int                  qFormat[MAXBANDS];
-
-        Int                  max_sfb;
-        LT_PRED_STATUS       lt_status;
-
-    } per_chan_share_w_fxpCoef;
-
-    /*
-     * This structure contains one per channel.
-     */
-    typedef struct
-    {
-#ifdef AAC_PLUS
-        Int16                ltp_buffer[LT_BLEN + 2*288]; /* LT_BLEN  = 2048 + 2*288 */
-#else
-        Int16                ltp_buffer[LT_BLEN]; /* LT_BLEN  = 2048 */
-#endif
-
-
-        Int32                time_quant[LONG_WINDOW]; /*  1024 holds overlap&add */
-
-        Int32                *fxpCoef;         /* Spectrum coeff.*/
-
-        per_chan_share_w_fxpCoef * pShareWfxpCoef;
-
-        Int32                abs_max_per_window[NUM_SHORT_WINDOWS];
-
-        WINDOW_SEQUENCE      wnd;
-
-
-        WINDOW_SHAPE         wnd_shape_prev_bk;
-        WINDOW_SHAPE         wnd_shape_this_bk;
-
-    } tDec_Int_Chan;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TDEC_INT_CHAN_H */
-
diff --git a/media/libstagefright/codecs/aacdec/s_tdec_int_file.h b/media/libstagefright/codecs/aacdec/s_tdec_int_file.h
deleted file mode 100644
index d0ffb0b..0000000
--- a/media/libstagefright/codecs/aacdec/s_tdec_int_file.h
+++ /dev/null
@@ -1,277 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_tDec_Int_File.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Remove unneeded structure elements, clean up.
-
- Description: Remove block.h, not needed, chains in other not needed files.
-
- Description: Added declaration of scratch memory, scratchTnsDecCoefMem,
- which will be utilized by tns_decode_coef().
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description: Per review comments...
- (1) Removed declaration of unused variable, savedMCInfo
- (2) Commented out ADTS related variables.
- (3) Slight re-wording of comment for clarity.
-
- Description:
- (1) Moved scratch_prog_config into the scratch union.
-
- Description:
- (1) Added ltp state variable.
-
- Description: Make tDec_Int_perChan an array of structures.
-              In the user applications, the malloc command will allocate a
-              continuous chunk of memory.
-
- Description:
-           (1) Added the array data_stream_bytes[] to structure tDec_Int_File.
-               This to support Data Streaming Elements (DSE).
-           (2) Updated the copyright header.
-
-
- Who:                                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, tDec_Int_Chan
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TDEC_INT_FILE_H
-#define S_TDEC_INT_FILE_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_progconfig.h"
-#include "s_frameinfo.h"
-#include "s_mc_info.h"
-#include "s_adif_header.h"
-#include "s_tdec_int_chan.h"
-#include "s_pulseinfo.h"
-#include "s_bits.h"
-#include "s_hcb.h"
-#include "e_infoinitconst.h"
-
-#include "s_sbr_channel.h"
-#include "s_sbr_dec.h"
-#include "s_sbrbitstream.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-
-
-
-    /*
-     * Note: most of the names of the variables put into this structure were kept
-     * the same because the name is also used in called functions.
-     *
-     * bno - block number
-     *
-     */
-    typedef struct
-    {
-        UInt32         bno;
-        Int            status;  /* save the status */
-
-        bool           aacPlusEnabled;
-        bool           aacConfigUtilityEnabled;
-
-        Int            current_program;
-        Int            frameLength;
-        Int            adif_test;
-
-        BITS           inputStream;
-
-        ProgConfig     prog_config;
-
-        Int            SFBWidth128[(1<<LEN_MAX_SFBS)];
-
-        /*
-         * One of the two arrays should be deleted in the final version.
-         */
-        FrameInfo      longFrameInfo;
-        FrameInfo      shortFrameInfo;
-        FrameInfo     *winmap[NUM_WIN_SEQ];
-
-        /*
-         * Pns variables.
-         */
-        Int32          pns_cur_noise_state;
-
-        /*
-         *
-         */
-        MC_Info        mc_info;
-
-        Int            ltp_buffer_state;
-
-        /*
-         *  For eaac+, a scratch matrix is created with the rigth element ( perChan[1] is not used)
-         *  and the fxpCoef matrix. These  2 matrices are [2][38][64] == 4864 Int32
-         *    2349 coming from the perChan[1] plus 4096 coming from fxpCoef
-         */
-        tDec_Int_Chan  perChan[Chans];
-
-        Int32          fxpCoef[2][LN];         /* LN  = 2048     */
-
-
-
-#ifdef AAC_PLUS
-
-        SBRDECODER_DATA sbrDecoderData;/* allocates 2 SBR_CHANNEL, each has a SBR_FRAME_DATA */
-        SBR_DEC         sbrDec;
-        SBRBITSTREAM    sbrBitStr;
-
-#endif
-
-
-        /*
-         * If ADTS support is needed, the following variables will
-         * be required.
-         */
-        UInt32         syncword;
-        Int            invoke;
-
-        Int         mask[MAXBANDS];
-        Int         hasmask;
-
-
-        /*  SBR usage
-         *  These two unions are used for the SBR tool and used
-         *  as a single 2560 int32 continuous memory for circular
-         *  buffering the synthesis QMF's bank history
-         */
-
-        /* This union specifies memory for arrays which are used
-         * by only one function.  This is the simplest type of scratch
-         * memory to implement, since there are no worries about
-         * function interaction.
-         */
-        union scratch_memory
-        {
-            Int32  fft[LONG_WINDOW];    /* 1024, as needed by the FFT */
-            Int32  tns_inv_filter[TNS_MAX_ORDER];
-            Int32  tns_decode_coef[2*TNS_MAX_ORDER];
-            Int    huffbook_used[248];
-            Int16  tmp_spec[LN2];  /* Used in conjunction with quant_spec */
-
-            ADIF_Header    adif_header;
-
-            ProgConfig     scratch_prog_config;
-
-
-            Int32  scratch_mem[16][64];
-        } scratch;
-
-        /* This union tries to take advantage of the fact that
-         * some variables are only used before LTP, and
-         * the long array, predictedSamples, is only used after LTP.
-         */
-
-        /*
-         *  also used by the circular buffer scheme on aac+ (needs 4096 + 1152)
-         *  from scratch_mem[2] + 5248  (uses most of shared_memory).
-         *  For eaac+, shared memory is used by sbrQmfBufferReal which needs
-         *  1824 bytes
-         */
-        union shared_memory
-        {
-            Int32       predictedSamples[LONG_BLOCK1];  /* 2048 Int32 */
-
-            Char        data_stream_bytes[(1<<LEN_D_CNT)+1];
-
-            struct
-            {
-                Int16         quantSpec[LN2];
-                SectInfo    sect[MAXBANDS + 1];
-                PulseInfo   pulseInfo;
-            } a;
-
-        } share;
-
-
-    } tDec_Int_File;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TDEC_INT_FILE_H */
diff --git a/media/libstagefright/codecs/aacdec/s_tns_frame_info.h b/media/libstagefright/codecs/aacdec/s_tns_frame_info.h
deleted file mode 100644
index 61af0ac..0000000
--- a/media/libstagefright/codecs/aacdec/s_tns_frame_info.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_TNS_frame_info.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified to eliminate triple-nested structure, which wasted
- 2 KB of memory.
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Description:
- (1) Changed hard coded size of arrays from "8" to "TNS_MAX_WIN"
- (2) Moved elements from s_TNSinfo.h up to the level of TNS_frame_info
- (3) Added Bool "tns_data_present" for future use.
- (4) Moved lpc_coef up from s_TNSfilt.h (allowed for use of smaller array.)
-
- Description:
- (1) Removed the array "coef_res", which is now a local variable on the
- stack inside get_tns.c
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, s_TNS_frame_info
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TNS_FRAME_INFO_H
-#define S_TNS_FRAME_INFO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "s_tnsfilt.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-    typedef struct
-    {
-        Bool tns_data_present;
-
-        /* Information about the number of filters for each window. */
-        Int n_filt[TNS_MAX_WIN];
-
-        /*
-         * Filter Information
-         *
-         * For short windows, there is a maximum of
-         * 1 filter per window (8 total)
-         *
-         * For long windows, there is a maximum of 3 filters
-         *
-         */
-        TNSfilt filt[TNS_MAX_WIN];
-
-        /*
-         * For short windows, there is a maximum of 8 filters,
-         * each of order 7 (requring 56 Ints)
-         *
-         * For long windows, there is a maximum of 3 filters,
-         * each of order 20 (requiring 60 Ints)
-         *
-         * So, 3*TNS_MAX_ORDER declares an array of sufficient
-         * size (60) for both cases.
-         */
-        Int32 lpc_coef[3*TNS_MAX_ORDER];
-
-    } TNS_frame_info;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TNS_FRAME_INFO_H */
diff --git a/media/libstagefright/codecs/aacdec/s_tnsfilt.h b/media/libstagefright/codecs/aacdec/s_tnsfilt.h
deleted file mode 100644
index c1d78af..0000000
--- a/media/libstagefright/codecs/aacdec/s_tnsfilt.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_TNSfilt.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Added lpc, start, & size, so the data from
- tns_inv_subblock can be shared with tns_decode_subblock.
-
- Description: Removed lpc to save 2KB of memory (on 32-bit machines.)
- This change requires tns_decode_coef.c to perform calculations in place.
-
- Description: Removed start & size.  start_band and stop_band can simply
- take on a new meaning after this function.  (coef index, rather than
- scalefactor band index.)
-
- Description: Had to add "start_coef" and "stop_coef" in order to preserve
- values "start_band" and "stop_band."  This required a change to
- tns_setup_filter.c also.
-
- Description: Had to add element "q_lpc" to store the q-format of the lpc
- coefficients passed via "coef."
-
- Description: Moved lpc_coef array up to the s_TNS_frame_info.h structure.
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, s_TNSfilt
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_TNSFILT_H
-#define S_TNSFILT_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    typedef struct
-    {
-        Int start_band;
-        Int stop_band;
-        Int start_coef;
-        Int stop_coef;
-        UInt order;
-        Int direction;
-        Int q_lpc;
-
-    } TNSfilt;
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* S_TNSFILT_H */
diff --git a/media/libstagefright/codecs/aacdec/s_wnd_shape.h b/media/libstagefright/codecs/aacdec/s_wnd_shape.h
deleted file mode 100644
index c8a05c8..0000000
--- a/media/libstagefright/codecs/aacdec/s_wnd_shape.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: s_Wnd_Shape.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Change data type to Int
-
- Who:                                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file defines the structure, Wnd_Shape
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef S_WND_SHAPE_H
-#define S_WND_SHAPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-typedef struct
-{
-    Int    this_bk;
-    Int    prev_bk;
-} Wnd_Shape;
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp b/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp
deleted file mode 100644
index efbab7d..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.cpp
+++ /dev/null
@@ -1,366 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_aliasing_reduction.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-
-#include    "sbr_aliasing_reduction.h"
-#include    "pv_sqrt.h"
-
-#include    "aac_mem_funcs.h"
-
-#include    "pv_div.h"
-#include    "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Q30fmt(x)   (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#include "pv_normalize.h"
-#include  "sbr_constants.h"
-
-/*******************************************************************************
- Functionname:  sbr_aliasing_reduction
- *******************************************************************************
- Description:
- Arguments:
-
- Return:        none
-*******************************************************************************/
-void sbr_aliasing_reduction(Int32 *degreeAlias,
-                            Int32  * nrg_gain_man,
-                            Int32  * nrg_gain_exp,
-                            Int32  * nrg_est_man,
-                            Int32  * nrg_est_exp,
-                            Int32  * dontUseTheseGainValues,
-                            Int32    noSubbands,
-                            Int32    lowSubband,
-                            Int32  sqrt_cache[][4],
-                            Int32 * groupVector)
-{
-
-    Int32 temp1;
-    Int32 est_total;
-    Int32 ref_total_man;
-    Int32 ref_total_exp;
-    Int32 tmp_q1;
-    Int32 tmp_q2;
-    Int32 tmp_q3;
-    Int32 tmp_q4;
-    Int32 bst_man;
-    Int32 bst_exp;
-    struct intg_div   quotient;
-    struct intg_sqrt  root_sq;
-    Int32 group;
-    Int32 grouping = 0;
-    Int32 index = 0;
-    Int32 noGroups;
-    Int32 k;
-
-
-    /* Calculate grouping*/
-    for (k = 0; k < noSubbands - 1; k++)
-    {
-        if (degreeAlias[k + lowSubband + 1] && dontUseTheseGainValues[k] == 0)
-        {
-            if (grouping == 0)
-            {
-                groupVector[index] = k + lowSubband;
-                grouping = 1;
-                index++;
-            }
-        }
-        else
-        {
-            if (grouping)
-            {
-                groupVector[index] = k + lowSubband;
-
-                if (! dontUseTheseGainValues[k])
-                {
-                    (groupVector[index])++;
-                }
-                grouping = 0;
-                index++;
-            }
-        }
-    }
-
-    if (grouping)
-    {
-        groupVector[index] = noSubbands + lowSubband;
-        index++;
-    }
-    noGroups = (index >> 1);
-
-
-
-    /*Calculate new gain*/
-    for (group = 0; group < noGroups; group ++)
-    {
-
-        int startGroup = groupVector[(group<<1)] - lowSubband;
-        int stopGroup  = groupVector[(group<<1)+1] - lowSubband;
-
-
-        est_total = 0;
-        ref_total_man = 0;
-
-        tmp_q1 = -100;
-        tmp_q2 = -100;
-
-        for (k = startGroup; k < stopGroup; k++)
-        {
-            if (tmp_q1 < nrg_est_exp[k])
-            {
-                tmp_q1 = nrg_est_exp[k];    /* max */
-            }
-            if (tmp_q2 < (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)))
-            {
-                tmp_q2 = (nrg_est_exp[k] + (nrg_gain_exp[k] << 1));  /* max */
-            }
-        }
-
-
-        k -= startGroup;        /*  number of element used in the addition */
-        /* adjust Q format */
-        tmp_q2 += 59 - pv_normalize(k);
-
-        for (k = startGroup; k < stopGroup; k++)
-        {
-            /*
-             *  est_total += nrg_est[k]
-             *  ref_total += nrg_est[k]*nrg_gain[k]*nrg_gain[k
-             */
-            est_total += nrg_est_man[k] >> (tmp_q1 - nrg_est_exp[k]);
-
-            if (tmp_q2 - (nrg_est_exp[k] + (nrg_gain_exp[k] << 1)) < 60)
-            {
-                nrg_gain_man[k] = fxp_mul32_Q28(nrg_gain_man[k], nrg_gain_man[k]);
-                nrg_gain_exp[k] = (nrg_gain_exp[k] << 1) + 28;
-                tmp_q3          = fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]);
-                ref_total_man    += tmp_q3 >> (tmp_q2 - (nrg_est_exp[k] + nrg_gain_exp[k]));
-            }
-        }
-
-        ref_total_exp = tmp_q2 + 28;
-
-        pv_div(ref_total_man, est_total, &quotient);
-
-        tmp_q2 += - tmp_q1 - quotient.shift_factor - 2;
-
-
-
-        for (k = startGroup; k < stopGroup; k++)
-        {
-            Int32 alpha;
-            temp1 = k + lowSubband;
-            if (k < noSubbands - 1)
-            {
-                alpha = degreeAlias[temp1 + 1] > degreeAlias[temp1 ] ?
-                        degreeAlias[temp1 + 1] : degreeAlias[temp1 ];
-            }
-            else
-            {
-                alpha = degreeAlias[temp1];
-            }
-
-            /*
-             *  nrg_gain[k] = alpha*newGain + (1.0f-alpha)*nrg_gain[k]*nrg_gain[k];
-             */
-
-            tmp_q1 = tmp_q2 > nrg_gain_exp[k] ? tmp_q2 : nrg_gain_exp[k];
-            tmp_q1++;
-
-            tmp_q3 = fxp_mul32_Q30(alpha, quotient.quotient);
-            tmp_q4 = fxp_mul32_Q30(Q30fmt(1.0f) - alpha, nrg_gain_man[k]);
-
-            nrg_gain_man[k] = (tmp_q3 >> (tmp_q1 - tmp_q2)) +
-                              (tmp_q4 >> (tmp_q1 - nrg_gain_exp[k]));
-
-            nrg_gain_exp[k] = tmp_q1;
-        }
-
-
-        bst_exp = -100;
-
-        for (k = startGroup; k < stopGroup; k++)
-        {
-            if (bst_exp < nrg_gain_exp[k] + nrg_est_exp[k])
-            {
-                bst_exp = nrg_gain_exp[k] + nrg_est_exp[k];    /* max */
-            }
-        }
-
-        k -= startGroup;        /*  number of element used in the addition */
-
-        while (k != 0)          /*  bit guard protection depends on log2(k)  */
-        {
-            k >>= 1;
-            bst_exp++;           /*  add extra bit-overflow-guard */
-        }
-
-        bst_man = 0;
-
-        for (k = startGroup; k < stopGroup; k++)
-        {
-            tmp_q2 =  fxp_mul32_Q28(nrg_gain_man[k], nrg_est_man[k]);
-            bst_man +=  tmp_q2 >> (bst_exp - nrg_gain_exp[k] - nrg_est_exp[k]);
-        }
-
-        bst_exp += 28;  /* compensate for shift down */
-
-        if (bst_man)
-        {
-            /*
-             *  bst = ref_total / bst
-             */
-
-            pv_div(ref_total_man, bst_man, &quotient);
-            bst_exp = ref_total_exp - bst_exp - quotient.shift_factor - 30;
-            bst_man = quotient.quotient;      /*  Q30 */
-
-            for (k = startGroup; k < stopGroup; k++)
-            {
-                tmp_q1 = fxp_mul32_Q30(bst_man, nrg_gain_man[k]);
-                pv_sqrt(tmp_q1, (bst_exp + nrg_gain_exp[k] + 60), &root_sq, sqrt_cache[0]);
-                nrg_gain_man[k] = root_sq.root;
-                nrg_gain_exp[k] = root_sq.shift_factor;
-            }
-        }
-        else
-        {
-            pv_memset((void *)&nrg_gain_man[startGroup],
-                      0,
-                      (stopGroup - startGroup)*sizeof(nrg_gain_man[0]));
-
-            pv_memset((void *)&nrg_gain_exp[startGroup],
-                      0,
-                      (stopGroup - startGroup)*sizeof(nrg_gain_exp[0]));
-
-        }
-
-    }
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h b/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h
deleted file mode 100644
index 2ce99ec..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_aliasing_reduction.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_aliasing_reduction.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ALIASING_REDUCTION_H
-#define SBR_ALIASING_REDUCTION_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_aliasing_reduction(Int32 *degreeAlias,
-                            Int32  * nrg_gain_man,
-                            Int32  * nrg_gain_exp,
-                            Int32  * nrg_est_man,
-                            Int32  * nrg_est_exp,
-                            Int32  * dontUseTheseGainValues,
-                            Int32    noSubbands,
-                            Int32    lowSubband,
-                            Int32  sqrt_cache[][4],
-                            Int32 * groupVector);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_applied.cpp b/media/libstagefright/codecs/aacdec/sbr_applied.cpp
deleted file mode 100644
index c8b81b2..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_applied.cpp
+++ /dev/null
@@ -1,435 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Filename: sbr_applied.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    INPUT
-
-    SBRDECODER self,
-    SBRBITSTREAM * stream,
-    float *timeData,
-    int numChannels
-
-    OUTPUT
-
-    errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        sbr decoder processing, set up SBR decoder phase 2 in case of
-        different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include    "sbr_applied.h"
-#include    "sbr_read_data.h"
-
-#include    "sbr_decode_envelope.h"
-#include    "decode_noise_floorlevels.h"
-#include    "sbr_requantize_envelope_data.h"
-#include    "sbr_envelope_unmapping.h"
-#include    "sbr_dec.h"
-#include    "e_sbr_element_id.h"
-#include    "aac_mem_funcs.h"
-
-#ifdef PARAMETRICSTEREO
-#include    "ps_bstr_decoding.h"
-#include    "ps_allocate_decoder.h"
-
-#endif
-
-#include    "init_sbr_dec.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define LEFT  (0)
-#define RIGHT (1)
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR  sbr_applied(SBRDECODER_DATA * self,
-                       SBRBITSTREAM * stream,
-                       Int16 *ch_left,
-                       Int16 *ch_right,
-                       Int16 *timeData,
-                       SBR_DEC *sbrDec,
-                       tDec_Int_File  *pVars,
-                       Int32 numChannels)
-{
-    SBR_ERROR err = SBRDEC_OK ;
-
-    Int32 eleChannels = 0;
-
-    SBR_CHANNEL *SbrChannel = self->SbrChannel;
-
-    /* Get SBR or PS Data only when available */
-    if (stream->NrElements)
-    {
-        /* read frame data from bitstream */
-
-        err = sbr_read_data(self,
-                            sbrDec,
-                            stream);
-
-        if (err != SBRDEC_OK)
-        {
-            /*
-             * This error condition disables any further SBR processing
-             */
-            self->SbrChannel[LEFT].syncState = UPSAMPLING;
-            if (eleChannels == 2)
-            {
-                self->SbrChannel[RIGHT].syncState = UPSAMPLING;
-            }
-        }
-
-        /*
-         *  Setting bistream and decoding type is only done once,
-         */
-        if (SbrChannel[LEFT].syncState == SBR_ACTIVE && self->setStreamType)
-        {
-            self->setStreamType = 0;  /* Disable Lock for AAC stream type setting  */
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
-            Int sbrEnablePS = self->hParametricStereoDec->psDetected;
-
-            pVars->mc_info.psPresentFlag  = sbrEnablePS;
-
-            if (sbrEnablePS)   /* Initialize PS arrays */
-            {
-                pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_PS;
-                ps_allocate_decoder(self, 32);
-
-                /* Disable LC (or Enable HQ)  if PS is detected */
-                sbrDec->LC_aacP_DecoderFlag = OFF;
-            }
-            else
-            {
-                /*
-                 *  Do not downgrade stream type from eaac+, if it has been explicitly declared
-                 */
-                if (pVars->mc_info.ExtendedAudioObjectType != MP4AUDIO_PS)
-                {
-                    pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
-                    if (pVars->mc_info.nch > 1)
-                    {
-                        sbrDec->LC_aacP_DecoderFlag = ON;    /* Enable LC for stereo */
-                    }
-                    else
-                    {
-                        sbrDec->LC_aacP_DecoderFlag = OFF;    /* Disable LC, Enable HQ for mono */
-                    }
-                }
-                else
-                {
-                    sbrEnablePS = 1;  /* Force this condition as it was explicititly declared */
-                    pVars->mc_info.psPresentFlag  = sbrEnablePS;
-
-                }
-            }
-#else
-
-            pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
-            if (pVars->mc_info.nch > 1)
-            {
-                sbrDec->LC_aacP_DecoderFlag = ON;    /* Enable LC for stereo */
-            }
-            else
-            {
-                sbrDec->LC_aacP_DecoderFlag = OFF;    /* Disable LC, Enable HQ for mono */
-            }
-#endif
-
-#else
-            pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-
-            sbrDec->LC_aacP_DecoderFlag = ON;       /* Enable LC for all sbr decoding */
-
-#endif
-
-        }   /*   (SbrChannel[LEFT].syncState == SBR_ACTIVE && lock)  */
-        else
-        {
-            /*
-             *  Default setting for upsampler
-             */
-            if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_AAC_LC)
-            {
-                /*
-                 *  Change only in implicit signalling, otherwise keep original declaration
-                 */
-                pVars->mc_info.ExtendedAudioObjectType = MP4AUDIO_SBR;
-            }
-
-#ifdef HQ_SBR
-            if (pVars->mc_info.nch > 1)
-            {
-                sbrDec->LC_aacP_DecoderFlag = ON;    /* Enable LC for stereo */
-            }
-            else
-            {
-                sbrDec->LC_aacP_DecoderFlag = OFF;    /* Disable LC, Enable HQ for mono */
-            }
-#else
-            sbrDec->LC_aacP_DecoderFlag = ON;       /* Enable LC for all sbr decoding */
-
-#endif
-            /* mask error and let upsampler run */
-            err = SBRDEC_OK;
-
-        }
-
-        /* decoding */
-        eleChannels = (stream->sbrElement [LEFT].ElementID == SBR_ID_CPE) ? 2 : 1;
-
-        if (SbrChannel[LEFT].syncState == SBR_ACTIVE)
-        {
-
-            sbr_decode_envelope(&(SbrChannel[LEFT].frameData));
-
-            decode_noise_floorlevels(&(SbrChannel[LEFT].frameData));
-
-            if (! SbrChannel[LEFT].frameData.coupling)
-            {
-                sbr_requantize_envelope_data(&(SbrChannel[LEFT].frameData));
-            }
-
-            if (eleChannels == 2)
-            {
-
-                sbr_decode_envelope(&(SbrChannel[RIGHT].frameData));
-
-                decode_noise_floorlevels(&(SbrChannel[RIGHT].frameData));
-
-                if (SbrChannel[RIGHT].frameData.coupling)
-                {
-                    sbr_envelope_unmapping(&(SbrChannel[ LEFT].frameData),
-                                           &(SbrChannel[RIGHT].frameData));
-                }
-                else
-                {
-                    sbr_requantize_envelope_data(&(SbrChannel[RIGHT].frameData));
-                }
-            }
-        }
-        else            /* enable upsampling until valid SBR is obtained */
-        {
-            /*
-             *  Incomplete sbr frame, or disabled SBR section
-             *  Set the decoder to act as a regular upsampler
-             */
-
-            init_sbr_dec((sbrDec->outSampleRate >> 1),
-                         pVars->mc_info.upsamplingFactor,
-                         sbrDec,
-                         &(self->SbrChannel[LEFT].frameData));
-
-            if ((eleChannels == 2) && (SbrChannel[RIGHT].syncState != SBR_ACTIVE))
-            {
-                init_sbr_dec((sbrDec->outSampleRate >> 1),
-                             pVars->mc_info.upsamplingFactor,
-                             sbrDec,
-                             &(self->SbrChannel[RIGHT].frameData));
-
-            }
-
-        }
-
-    }
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-    if (pVars->mc_info.ExtendedAudioObjectType == MP4AUDIO_PS)
-    {
-        ps_bstr_decoding(self->hParametricStereoDec);
-        /* allocate pointer for rigth channel qmf filter history  */
-        Int16 *tempInt16Ptr = (Int16 *)SbrChannel[RIGHT].frameData.V;
-        self->hParametricStereoDec->R_ch_qmf_filter_history = (Int32 *)tempInt16Ptr;
-
-
-        /*
-         * 1824 (48*38) Int32 needed by each matrix sbrQmfBufferReal, sbrQmfBufferImag
-         * pVars->share.predictedSamples  has 2048 available
-         * pVars->fxpCoef[1]  has 2048 available
-         */
-        SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->share.predictedSamples;
-        SbrChannel[LEFT].frameData.sbrQmfBufferImag = &pVars->fxpCoef[0][920];
-
-        sbr_dec(ch_left,
-                timeData,
-                &(SbrChannel[LEFT].frameData),
-                (SbrChannel[LEFT].syncState == SBR_ACTIVE),
-                sbrDec,
-                &timeData[RIGHT],
-                self->hParametricStereoDec,
-                pVars);
-    }
-    else
-    {
-#endif
-#endif
-
-        SbrChannel[LEFT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT];
-#ifdef HQ_SBR
-        SbrChannel[LEFT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT];
-#endif
-
-        sbr_dec(ch_left,
-                timeData,
-                &(SbrChannel[LEFT].frameData),
-                (SbrChannel[LEFT].syncState == SBR_ACTIVE),
-                sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-                NULL,
-                NULL,
-#endif
-#endif
-                pVars);
-
-        if (numChannels == 2)
-        {
-            SbrChannel[RIGHT].frameData.sbrQmfBufferReal = pVars->fxpCoef[LEFT];
-#ifdef HQ_SBR
-            SbrChannel[RIGHT].frameData.sbrQmfBufferImag = pVars->fxpCoef[RIGHT];
-#endif
-
-            sbr_dec(ch_right,
-                    &timeData[RIGHT],
-                    &(SbrChannel[RIGHT].frameData),
-                    (SbrChannel[RIGHT].syncState == SBR_ACTIVE),
-                    sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-                    NULL,
-                    NULL,
-#endif
-#endif
-                    pVars);
-
-        }
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-    }
-#endif
-#endif
-
-    return err;
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_applied.h b/media/libstagefright/codecs/aacdec/sbr_applied.h
deleted file mode 100644
index 6878537..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_applied.h
+++ /dev/null
@@ -1,136 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_applied.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_APPLIED_H
-#define SBR_APPLIED_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_sbr_error.h"
-#include "s_sbr_channel.h"
-#include "s_sbrbitstream.h"
-#include "sbr_dec.h"
-#include "pv_audio_type_defs.h"
-#include "s_tdec_int_file.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_FRAME_SIZE  1024
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    SBR_ERROR  sbr_applied(SBRDECODER_DATA * self,
-    SBRBITSTREAM * stream,
-    Int16 *ch_left,
-    Int16 *ch_right,
-    Int16 *timeData,
-    SBR_DEC *sbrDec,
-    tDec_Int_File  *pVars,
-    Int32 numChannels);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp b/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp
deleted file mode 100644
index 9db3221..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.cpp
+++ /dev/null
@@ -1,403 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_code_book_envlevel.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include   "pv_audio_type_defs.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here. Include conditional
-    ; compile variables also.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; LOCAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-    ; Variable declaration - defined here and used outside this module
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL FUNCTION REFERENCES
-    ; Declare functions defined elsewhere and referenced in this module
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-    /*******************************************************************************/
-    /* table       : envelope level, 1.5 dB                                        */
-    /* theor range : [-58,58], CODE_BOOK_SCF_LAV   = 58                            */
-    /* implem range: [-60,60], CODE_BOOK_SCF_LAV10 = 60                            */
-    /* raw stats   : envelopeLevel_00 (yes, wrong suffix in name)  KK 01-03-09     */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode3C2FIX.m/envelopeLevel_00T_cF.mat/m_hALC_cF
-       built by : FH 01-07-05 */
-
-    extern const Char bookSbrEnvLevel10T[120][2] =
-    {
-        {   1,   2 },    { -64, -65 },    {   3,   4 },    { -63, -66 },
-        {   5,   6 },    { -62, -67 },    {   7,   8 },    { -61, -68 },
-        {   9,  10 },    { -60, -69 },    {  11,  12 },    { -59, -70 },
-        {  13,  14 },    { -58, -71 },    {  15,  16 },    { -57, -72 },
-        {  17,  18 },    { -73, -56 },    {  19,  21 },    { -74,  20 },
-        { -55, -75 },    {  22,  26 },    {  23,  24 },    { -54, -76 },
-        { -77,  25 },    { -53, -78 },    {  27,  34 },    {  28,  29 },
-        { -52, -79 },    {  30,  31 },    { -80, -51 },    {  32,  33 },
-        { -83, -82 },    { -81, -50 },    {  35,  57 },    {  36,  40 },
-        {  37,  38 },    { -88, -84 },    { -48,  39 },    { -90, -85 },
-        {  41,  46 },    {  42,  43 },    { -49, -87 },    {  44,  45 },
-        { -89, -86 },    { -124, -123 },    {  47,  50 },    {  48,  49 },
-        { -122, -121 },    { -120, -119 },    {  51,  54 },    {  52,  53 },
-        { -118, -117 },    { -116, -115 },    {  55,  56 },    { -114, -113 },
-        { -112, -111 },    {  58,  89 },    {  59,  74 },    {  60,  67 },
-        {  61,  64 },    {  62,  63 },    { -110, -109 },    { -108, -107 },
-        {  65,  66 },    { -106, -105 },    { -104, -103 },    {  68,  71 },
-        {  69,  70 },    { -102, -101 },    { -100, -99 },    {  72,  73 },
-        { -98, -97 },    { -96, -95 },    {  75,  82 },    {  76,  79 },
-        {  77,  78 },    { -94, -93 },    { -92, -91 },    {  80,  81 },
-        { -47, -46 },    { -45, -44 },    {  83,  86 },    {  84,  85 },
-        { -43, -42 },    { -41, -40 },    {  87,  88 },    { -39, -38 },
-        { -37, -36 },    {  90, 105 },    {  91,  98 },    {  92,  95 },
-        {  93,  94 },    { -35, -34 },    { -33, -32 },    {  96,  97 },
-        { -31, -30 },    { -29, -28 },    {  99, 102 },    { 100, 101 },
-        { -27, -26 },    { -25, -24 },    { 103, 104 },    { -23, -22 },
-        { -21, -20 },    { 106, 113 },    { 107, 110 },    { 108, 109 },
-        { -19, -18 },    { -17, -16 },    { 111, 112 },    { -15, -14 },
-        { -13, -12 },    { 114, 117 },    { 115, 116 },    { -11, -10 },
-        {  -9,  -8 },    { 118, 119 },    {  -7,  -6 },    {  -5,  -4 }
-    };
-
-    /* direction: freq
-       raw table: HuffCode3C2FIX.m/envelopeLevel_00F_cF.mat/m_hALC_cF
-       built by : FH 01-07-05 */
-
-    extern const Char bookSbrEnvLevel10F[120][2] =
-    {
-        {   1,   2 },    { -64, -65 },    {   3,   4 },    { -63, -66 },
-        {   5,   6 },    { -67, -62 },    {   7,   8 },    { -68, -61 },
-        {   9,  10 },    { -69, -60 },    {  11,  13 },    { -70,  12 },
-        { -59, -71 },    {  14,  16 },    { -58,  15 },    { -72, -57 },
-        {  17,  19 },    { -73,  18 },    { -56, -74 },    {  20,  23 },
-        {  21,  22 },    { -55, -75 },    { -54, -53 },    {  24,  27 },
-        {  25,  26 },    { -76, -52 },    { -77, -51 },    {  28,  31 },
-        {  29,  30 },    { -50, -78 },    { -79, -49 },    {  32,  36 },
-        {  33,  34 },    { -48, -47 },    { -80,  35 },    { -81, -82 },
-        {  37,  47 },    {  38,  41 },    {  39,  40 },    { -83, -46 },
-        { -45, -84 },    {  42,  44 },    { -85,  43 },    { -44, -43 },
-        {  45,  46 },    { -88, -87 },    { -86, -90 },    {  48,  66 },
-        {  49,  56 },    {  50,  53 },    {  51,  52 },    { -92, -42 },
-        { -41, -39 },    {  54,  55 },    { -105, -89 },    { -38, -37 },
-        {  57,  60 },    {  58,  59 },    { -94, -91 },    { -40, -36 },
-        {  61,  63 },    { -20,  62 },    { -115, -110 },    {  64,  65 },
-        { -108, -107 },    { -101, -97 },    {  67,  89 },    {  68,  75 },
-        {  69,  72 },    {  70,  71 },    { -95, -93 },    { -34, -27 },
-        {  73,  74 },    { -22, -17 },    { -16, -124 },    {  76,  82 },
-        {  77,  79 },    { -123,  78 },    { -122, -121 },    {  80,  81 },
-        { -120, -119 },    { -118, -117 },    {  83,  86 },    {  84,  85 },
-        { -116, -114 },    { -113, -112 },    {  87,  88 },    { -111, -109 },
-        { -106, -104 },    {  90, 105 },    {  91,  98 },    {  92,  95 },
-        {  93,  94 },    { -103, -102 },    { -100, -99 },    {  96,  97 },
-        { -98, -96 },    { -35, -33 },    {  99, 102 },    { 100, 101 },
-        { -32, -31 },    { -30, -29 },    { 103, 104 },    { -28, -26 },
-        { -25, -24 },    { 106, 113 },    { 107, 110 },    { 108, 109 },
-        { -23, -21 },    { -19, -18 },    { 111, 112 },    { -15, -14 },
-        { -13, -12 },    { 114, 117 },    { 115, 116 },    { -11, -10 },
-        {  -9,  -8 },    { 118, 119 },    {  -7,  -6 },    {  -5,  -4 }
-    };
-
-    /*******************************************************************************/
-    /* table       : envelope balance, 1.5 dB                                      */
-    /* theor range : [-48,48], CODE_BOOK_SCF_LAV = 48                              */
-    /* implem range: same but mapped to [-24,24], CODE_BOOK_SCF_LAV_BALANCE10 = 24 */
-    /* raw stats   : envelopePan_00 (yes, wrong suffix in name)  KK 01-03-09       */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
-       built by : FH 01-05-15 */
-
-    extern const Char bookSbrEnvBalance10T[48][2] =
-    {
-        { -64,   1 },    { -63,   2 },    { -65,   3 },    { -62,   4 },
-        { -66,   5 },    { -61,   6 },    { -67,   7 },    { -60,   8 },
-        { -68,   9 },    {  10,  11 },    { -69, -59 },    {  12,  13 },
-        { -70, -58 },    {  14,  28 },    {  15,  21 },    {  16,  18 },
-        { -57,  17 },    { -71, -56 },    {  19,  20 },    { -88, -87 },
-        { -86, -85 },    {  22,  25 },    {  23,  24 },    { -84, -83 },
-        { -82, -81 },    {  26,  27 },    { -80, -79 },    { -78, -77 },
-        {  29,  36 },    {  30,  33 },    {  31,  32 },    { -76, -75 },
-        { -74, -73 },    {  34,  35 },    { -72, -55 },    { -54, -53 },
-        {  37,  41 },    {  38,  39 },    { -52, -51 },    { -50,  40 },
-        { -49, -48 },    {  42,  45 },    {  43,  44 },    { -47, -46 },
-        { -45, -44 },    {  46,  47 },    { -43, -42 },    { -41, -40 }
-    };
-
-    /* direction: freq
-       raw table: HuffCode3C.m/envelopePan_00T.mat/v_hALB
-       built by : FH 01-05-15 */
-
-    extern const Char bookSbrEnvBalance10F[48][2] =
-    {
-        { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
-        { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
-        { -60,   9 },    {  10,  11 },    { -69, -59 },    { -70,  12 },
-        { -58,  13 },    {  14,  17 },    { -71,  15 },    { -57,  16 },
-        { -56, -73 },    {  18,  32 },    {  19,  25 },    {  20,  22 },
-        { -72,  21 },    { -88, -87 },    {  23,  24 },    { -86, -85 },
-        { -84, -83 },    {  26,  29 },    {  27,  28 },    { -82, -81 },
-        { -80, -79 },    {  30,  31 },    { -78, -77 },    { -76, -75 },
-        {  33,  40 },    {  34,  37 },    {  35,  36 },    { -74, -55 },
-        { -54, -53 },    {  38,  39 },    { -52, -51 },    { -50, -49 },
-        {  41,  44 },    {  42,  43 },    { -48, -47 },    { -46, -45 },
-        {  45,  46 },    { -44, -43 },    { -42,  47 },    { -41, -40 }
-    };
-
-    /*******************************************************************************/
-    /* table       : envelope level, 3.0 dB                                        */
-    /* theor range : [-29,29], CODE_BOOK_SCF_LAV   = 29                            */
-    /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31                            */
-    /* raw stats   : envelopeLevel_11  KK 00-02-03                                 */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode2.m
-       built by : FH 00-02-04 */
-
-    extern const Char bookSbrEnvLevel11T[62][2] =
-    {
-        { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
-        { -62,   5 },    { -67,   6 },    { -61,   7 },    { -68,   8 },
-        { -60,   9 },    {  10,  11 },    { -69, -59 },    {  12,  14 },
-        { -70,  13 },    { -71, -58 },    {  15,  18 },    {  16,  17 },
-        { -72, -57 },    { -73, -74 },    {  19,  22 },    { -56,  20 },
-        { -55,  21 },    { -54, -77 },    {  23,  31 },    {  24,  25 },
-        { -75, -76 },    {  26,  27 },    { -78, -53 },    {  28,  29 },
-        { -52, -95 },    { -94,  30 },    { -93, -92 },    {  32,  47 },
-        {  33,  40 },    {  34,  37 },    {  35,  36 },    { -91, -90 },
-        { -89, -88 },    {  38,  39 },    { -87, -86 },    { -85, -84 },
-        {  41,  44 },    {  42,  43 },    { -83, -82 },    { -81, -80 },
-        {  45,  46 },    { -79, -51 },    { -50, -49 },    {  48,  55 },
-        {  49,  52 },    {  50,  51 },    { -48, -47 },    { -46, -45 },
-        {  53,  54 },    { -44, -43 },    { -42, -41 },    {  56,  59 },
-        {  57,  58 },    { -40, -39 },    { -38, -37 },    {  60,  61 },
-        { -36, -35 },    { -34, -33 }
-    };
-
-    /* direction: freq
-       raw table: HuffCode2.m
-       built by : FH 00-02-04 */
-
-    extern const Char bookSbrEnvLevel11F[62][2] =
-    {
-        { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
-        { -62,   5 },    { -67,   6 },    {   7,   8 },    { -61, -68 },
-        {   9,  10 },    { -60, -69 },    {  11,  12 },    { -59, -70 },
-        {  13,  14 },    { -58, -71 },    {  15,  16 },    { -57, -72 },
-        {  17,  19 },    { -56,  18 },    { -55, -73 },    {  20,  24 },
-        {  21,  22 },    { -74, -54 },    { -53,  23 },    { -75, -76 },
-        {  25,  30 },    {  26,  27 },    { -52, -51 },    {  28,  29 },
-        { -77, -79 },    { -50, -49 },    {  31,  39 },    {  32,  35 },
-        {  33,  34 },    { -78, -46 },    { -82, -88 },    {  36,  37 },
-        { -83, -48 },    { -47,  38 },    { -86, -85 },    {  40,  47 },
-        {  41,  44 },    {  42,  43 },    { -80, -44 },    { -43, -42 },
-        {  45,  46 },    { -39, -87 },    { -84, -40 },    {  48,  55 },
-        {  49,  52 },    {  50,  51 },    { -95, -94 },    { -93, -92 },
-        {  53,  54 },    { -91, -90 },    { -89, -81 },    {  56,  59 },
-        {  57,  58 },    { -45, -41 },    { -38, -37 },    {  60,  61 },
-        { -36, -35 },    { -34, -33 }
-    };
-
-    /*******************************************************************************/
-    /* table       : envelope balance, 3.0 dB                                      */
-    /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24                              */
-    /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
-    /* raw stats   : envelopeBalance_11  KK 00-02-03                               */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
-       built by : FH 01-05-15 */
-
-    extern const Char bookSbrEnvBalance11T[24][2] =
-    {
-        { -64,   1 },    { -63,   2 },    { -65,   3 },    { -66,   4 },
-        { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
-        { -60,   9 },    {  10,  16 },    {  11,  13 },    { -69,  12 },
-        { -76, -75 },    {  14,  15 },    { -74, -73 },    { -72, -71 },
-        {  17,  20 },    {  18,  19 },    { -70, -59 },    { -58, -57 },
-        {  21,  22 },    { -56, -55 },    { -54,  23 },    { -53, -52 }
-    };
-
-    /* direction: time (?)
-       raw table: HuffCode3C.m/envelopeBalance_11T.mat/v_hALB
-       built by : FH 01-05-15 */
-
-    extern const Char bookSbrEnvBalance11F[24][2] =
-    {
-        { -64,   1 },    { -65,   2 },    { -63,   3 },    { -66,   4 },
-        { -62,   5 },    { -61,   6 },    { -67,   7 },    { -68,   8 },
-        { -60,   9 },    {  10,  13 },    { -69,  11 },    { -59,  12 },
-        { -58, -76 },    {  14,  17 },    {  15,  16 },    { -75, -74 },
-        { -73, -72 },    {  18,  21 },    {  19,  20 },    { -71, -70 },
-        { -57, -56 },    {  22,  23 },    { -55, -54 },    { -53, -52 }
-    };
-
-    /*******************************************************************************/
-    /* table       : noise level, 3.0 dB                                           */
-    /* theor range : [-29,29], CODE_BOOK_SCF_LAV   = 29                            */
-    /* implem range: [-31,31], CODE_BOOK_SCF_LAV11 = 31                            */
-    /* raw stats   : noiseLevel_11  KK 00-02-03                                    */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode2.m
-       built by : FH 00-02-04 */
-
-    extern const Char bookSbrNoiseLevel11T[62][2] =
-    {
-        { -64,   1 },    { -63,   2 },    { -65,   3 },    { -66,   4 },
-        { -62,   5 },    { -67,   6 },    {   7,   8 },    { -61, -68 },
-        {   9,  30 },    {  10,  15 },    { -60,  11 },    { -69,  12 },
-        {  13,  14 },    { -59, -53 },    { -95, -94 },    {  16,  23 },
-        {  17,  20 },    {  18,  19 },    { -93, -92 },    { -91, -90 },
-        {  21,  22 },    { -89, -88 },    { -87, -86 },    {  24,  27 },
-        {  25,  26 },    { -85, -84 },    { -83, -82 },    {  28,  29 },
-        { -81, -80 },    { -79, -78 },    {  31,  46 },    {  32,  39 },
-        {  33,  36 },    {  34,  35 },    { -77, -76 },    { -75, -74 },
-        {  37,  38 },    { -73, -72 },    { -71, -70 },    {  40,  43 },
-        {  41,  42 },    { -58, -57 },    { -56, -55 },    {  44,  45 },
-        { -54, -52 },    { -51, -50 },    {  47,  54 },    {  48,  51 },
-        {  49,  50 },    { -49, -48 },    { -47, -46 },    {  52,  53 },
-        { -45, -44 },    { -43, -42 },    {  55,  58 },    {  56,  57 },
-        { -41, -40 },    { -39, -38 },    {  59,  60 },    { -37, -36 },
-        { -35,  61 },    { -34, -33 }
-    };
-
-    /*******************************************************************************/
-    /* table       : noise balance, 3.0 dB                                         */
-    /* theor range : [-24,24], CODE_BOOK_SCF_LAV = 24                              */
-    /* implem range: same but mapped to [-12,12], CODE_BOOK_SCF_LAV_BALANCE11 = 12 */
-    /* raw stats   : noiseBalance_11  KK 00-02-03                                  */
-    /*******************************************************************************/
-
-    /* direction: time
-       raw table: HuffCode3C.m/noiseBalance_11.mat/v_hALB
-       built by : FH 01-05-15 */
-
-    extern const Char bookSbrNoiseBalance11T[24][2] =
-    {
-        { -64,   1 },    { -65,   2 },    { -63,   3 },    {   4,   9 },
-        { -66,   5 },    { -62,   6 },    {   7,   8 },    { -76, -75 },
-        { -74, -73 },    {  10,  17 },    {  11,  14 },    {  12,  13 },
-        { -72, -71 },    { -70, -69 },    {  15,  16 },    { -68, -67 },
-        { -61, -60 },    {  18,  21 },    {  19,  20 },    { -59, -58 },
-        { -57, -56 },    {  22,  23 },    { -55, -54 },    { -53, -52 }
-    };
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h b/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h
deleted file mode 100644
index 3df0531..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_code_book_envlevel.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: sbr_code_book_envlevel.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CODE_BOOK_ENVLEVEL_H
-#define SBR_CODE_BOOK_ENVLEVEL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-    extern const Char bookSbrEnvLevel10T[120][2];
-    extern const Char bookSbrEnvLevel10F[120][2];
-    extern const Char bookSbrEnvBalance10T[48][2];
-    extern const Char bookSbrEnvBalance10F[48][2];
-    extern const Char bookSbrEnvLevel11T[62][2];
-    extern const Char bookSbrEnvLevel11F[62][2];
-    extern const Char bookSbrEnvBalance11T[24][2];
-    extern const Char bookSbrEnvBalance11F[24][2];
-    extern const Char bookSbrNoiseLevel11T[62][2];
-    extern const Char bookSbrNoiseBalance11T[24][2];
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-}
-#endif
-
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_constants.h b/media/libstagefright/codecs/aacdec/sbr_constants.h
deleted file mode 100644
index d54a699..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_constants.h
+++ /dev/null
@@ -1,210 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_constants.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CONSTANTS_H
-#define SBR_CONSTANTS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-
-#define SBR_AMP_RES_1_5         0
-#define SBR_AMP_RES_3_0         1
-
-#define MAX_NOISE_ENVELOPES     2
-#define MAX_NOISE_COEFFS        5
-#define MAX_NUM_NOISE_VALUES     (MAX_NOISE_ENVELOPES * MAX_NOISE_COEFFS)
-
-#define MAX_ENVELOPES           5
-#define MAX_FREQ_COEFFS         58
-#define MAX_NUM_ENVELOPE_VALUES (MAX_ENVELOPES * MAX_FREQ_COEFFS)
-
-#define MAX_NUM_CHANNELS            2
-#define NOISE_FLOOR_OFFSET          6
-#define NOISE_FLOOR_OFFSET_PLUS_1   7
-
-#define LOW_RES                     0
-#define HIGH_RES                    1
-
-#define LO                          0
-#define HI                          1
-
-#define TIME                        1
-#define FREQ                        0
-
-#define LENGTH_FRAME_INFO           35
-
-#define SI_SBR_CRC_BITS             10
-
-#define SBR_FREQ_SCALE_DEFAULT      2
-#define SBR_ALTER_SCALE_DEFAULT     1
-#define SBR_NOISE_BANDS_DEFAULT     2
-
-#define SBR_LIMITER_BANDS_DEFAULT      2
-#define SBR_LIMITER_GAINS_DEFAULT      2
-#define SBR_INTERPOL_FREQ_DEFAULT      1
-#define SBR_SMOOTHING_LENGTH_DEFAULT   1
-
-/* header */
-#define SI_SBR_AMP_RES_BITS            1
-#define SI_SBR_START_FREQ_BITS         4
-#define SI_SBR_STOP_FREQ_BITS          4
-#define SI_SBR_XOVER_BAND_BITS         3
-#define SI_SBR_RESERVED_BITS_HDR       2
-#define SI_SBR_DATA_EXTRA_BITS         1
-#define SI_SBR_HEADER_EXTRA_1_BITS     1
-#define SI_SBR_HEADER_EXTRA_2_BITS     1
-
-#define SI_SBR_FREQ_SCALE_BITS         2
-#define SI_SBR_ALTER_SCALE_BITS        1
-#define SI_SBR_NOISE_BANDS_BITS        2
-
-#define SI_SBR_LIMITER_BANDS_BITS      2
-#define SI_SBR_LIMITER_GAINS_BITS      2
-#define SI_SBR_INTERPOL_FREQ_BITS      1
-#define SI_SBR_SMOOTHING_LENGTH_BITS   1
-
-
-/* data */
-#define SI_SBR_RESERVED_PRESENT        1
-#define SI_SBR_RESERVED_BITS_DATA      4
-
-#define SI_SBR_COUPLING_BITS           1
-
-#define SI_SBR_INVF_MODE_BITS          2
-
-#define SI_SBR_EXTENDED_DATA_BITS      1
-#define SI_SBR_EXTENSION_SIZE_BITS     4
-#define SI_SBR_EXTENSION_ESC_COUNT_BITS   8
-#define SI_SBR_EXTENSION_ID_BITS          2
-
-#define SI_SBR_NOISE_MODE_BITS         1
-#define SI_SBR_DOMAIN_BITS             1
-
-#define SI_SBR_START_ENV_BITS_AMP_RES_3_0           6
-#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0   5
-#define SI_SBR_START_NOISE_BITS_AMP_RES_3_0         5
-#define SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0 5
-
-#define SI_SBR_START_ENV_BITS_AMP_RES_1_5           7
-#define SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5   6
-
-
-#define SBR_CLA_BITS  2
-#define SBR_ABS_BITS  2
-#define SBR_RES_BITS  1
-#define SBR_REL_BITS  2
-#define SBR_ENV_BITS  2
-#define SBR_NUM_BITS  2
-
-
-#define FIXFIX  0
-#define FIXVAR  1
-#define VARFIX  2
-#define VARVAR  3
-
-
-#define    LEN_EX_TYPE  (4)
-#define    LEN_NIBBLE   (4)
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp b/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp
deleted file mode 100644
index 3bb4398..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_crc_check.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_crc_check.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "sbr_crc_check.h"
-#include "s_crc_buffer.h"
-#include "buf_getbits.h"
-#include "sbr_constants.h"
-#include "check_crc.h"
-
-
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const unsigned short MAXCRCSTEP = 16;
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 sbr_crc_check(BIT_BUFFER * hBitBuf, UInt32 NrBits)
-{
-    Int32 crcResult = 1;
-    BIT_BUFFER BitBufferCRC;
-    UInt32 NrCrcBits;
-
-    UInt32 crcCheckSum;
-
-    Int32 i;
-    CRC_BUFFER CrcBuf;
-    UInt32 bValue;
-    Int32 CrcStep;
-    Int32 CrcNrBitsRest;
-
-    crcCheckSum = buf_getbits(hBitBuf, SI_SBR_CRC_BITS);
-
-
-    /*
-     *    Copy Bit buffer State
-     */
-
-    BitBufferCRC.char_ptr       = hBitBuf->char_ptr;
-    BitBufferCRC.buffer_word    = hBitBuf->buffer_word;
-    BitBufferCRC.buffered_bits  = hBitBuf->buffered_bits;
-    BitBufferCRC.nrBitsRead     = hBitBuf->nrBitsRead;
-    BitBufferCRC.bufferLen      = hBitBuf->bufferLen;
-
-
-    NrCrcBits = min(NrBits, BitBufferCRC.bufferLen - BitBufferCRC.nrBitsRead);
-
-
-    CrcStep = NrCrcBits / MAXCRCSTEP;
-    CrcNrBitsRest = (NrCrcBits - CrcStep * MAXCRCSTEP);
-
-    CrcBuf.crcState = CRCSTART;
-    CrcBuf.crcMask  = CRCMASK;
-    CrcBuf.crcPoly  = CRCPOLY;
-
-    for (i = 0; i < CrcStep; i++)
-    {
-        bValue = buf_getbits(&BitBufferCRC, MAXCRCSTEP);
-        check_crc(&CrcBuf, bValue, MAXCRCSTEP);
-    }
-
-    bValue = buf_getbits(&BitBufferCRC, CrcNrBitsRest);
-    check_crc(&CrcBuf, bValue, CrcNrBitsRest);
-
-    if ((UInt32)(CrcBuf.crcState & CRCRANGE) != crcCheckSum)
-    {
-        crcResult = 0;
-    }
-
-    return (crcResult);
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_crc_check.h b/media/libstagefright/codecs/aacdec/sbr_crc_check.h
deleted file mode 100644
index 9e6b1be..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_crc_check.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_crc_check.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CRC_CHECK_H
-#define SBR_CRC_CHECK_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_bit_buffer.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define CRCPOLY  0x0233
-#define CRCMASK  0x0200
-#define CRCSTART 0x0000
-#define CRCRANGE 0x03FF
-
-#define SBR_EXTENSION      13 /* 1101 */
-#define SBR_EXTENSION_CRC  14 /* 1110 */
-
-
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int32 sbr_crc_check(BIT_BUFFER * hBitBuf,
-                    UInt32 NrBits);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp b/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp
deleted file mode 100644
index 9472ffc..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.cpp
+++ /dev/null
@@ -1,253 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_create_limiter_bands.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_create_limiter_bands.h"
-#include    "shellsort.h"
-#include    "s_patch.h"
-#include    "pv_log2.h"
-
-#include "fxp_mul32.h"
-
-#define R_SHIFT     29
-#define Q_fmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_create_limiter_bands(Int32 limSbc[][13],
-                              Int32 *gateMode,
-                              Int   *freqTable,
-                              struct PATCH Patch,
-                              const Int32 noBands)
-{
-    Int32 i;
-    Int32 j;
-    Int32 k;
-    Int isPatchBorder[2];
-    Int32 patchBorders[MAX_NUM_PATCHES + 1];
-    Int32 workLimiterBandTable[32 + MAX_NUM_PATCHES + 1];
-
-    Int32 nOctaves;
-    const Int32 limiterBandsPerOctave[4] =
-        {Q_fmt(0.0F), Q_fmt(1.2F),
-         Q_fmt(2.0F), Q_fmt(3.0F)
-        };
-
-    Int32 tmp_q1;
-
-    Int32 noPatches = Patch.noOfPatches;
-    Int32 lowSubband = freqTable[0];
-    Int32 highSubband = freqTable[noBands];
-
-
-    for (i = 0; i < noPatches; i++)
-    {
-        patchBorders[i] = Patch.targetStartBand[i] - lowSubband;
-    }
-    patchBorders[i] = highSubband - lowSubband;
-
-    /* First band: 1 limiter band. */
-    limSbc[0][0] = freqTable[0] - lowSubband;
-    limSbc[0][1] = freqTable[noBands] - lowSubband;
-    gateMode[0] = 1;
-
-    /* Next three bands: 1.2, 2, 3 limiter bands/octave plus bandborders at patchborders. */
-    for (i = 1; i < 4; i++)
-    {
-
-        for (k = 0; k <= noBands; k++)
-        {
-            workLimiterBandTable[k] = freqTable[k] - lowSubband;
-        }
-
-        for (k = 1; k < noPatches; k++)
-        {
-            workLimiterBandTable[noBands+k] = patchBorders[k];
-        }
-
-        gateMode[i] = noBands + noPatches - 1;
-        shellsort(workLimiterBandTable, gateMode[i] + 1);
-
-        for (j = 1; j <= gateMode[i]; j++)
-        {
-            tmp_q1 = ((workLimiterBandTable[j] + lowSubband) << 20) / (workLimiterBandTable[j-1] + lowSubband);
-
-            nOctaves = pv_log2(tmp_q1);
-
-            tmp_q1 = fxp_mul32_Q20(nOctaves, limiterBandsPerOctave[i]);
-            if (tmp_q1 < Q_fmt(0.49))
-            {
-                if (workLimiterBandTable[j] == workLimiterBandTable[j-1])
-                {
-                    workLimiterBandTable[j] = highSubband;
-                    shellsort(workLimiterBandTable, gateMode[i] + 1);
-                    gateMode[i]--;
-                    j--;
-                    continue;
-                }
-
-                isPatchBorder[0] = isPatchBorder[1] = 0;
-
-                for (k = 0; k <= noPatches; k++)
-                {
-                    if (workLimiterBandTable[j-1] == patchBorders[k])
-                    {
-                        isPatchBorder[0] = 1;
-                        break;
-                    }
-                }
-
-                for (k = 0; k <= noPatches; k++)
-                {
-                    if (workLimiterBandTable[j] == patchBorders[k])
-                    {
-                        isPatchBorder[1] = 1;
-                        break;
-                    }
-                }
-
-                if (!isPatchBorder[1])
-                {
-                    workLimiterBandTable[j] = highSubband;
-                    shellsort(workLimiterBandTable, gateMode[i] + 1);
-                    gateMode[i]--;
-                    j--;
-                }
-                else if (!isPatchBorder[0])
-                {
-                    workLimiterBandTable[j-1] = highSubband;
-                    shellsort(workLimiterBandTable, gateMode[i] + 1);
-                    gateMode[i]--;
-                    j--;
-                }
-            }
-        }
-        for (k = 0; k <= gateMode[i]; k++)
-        {
-            limSbc[i][k] = workLimiterBandTable[k];
-        }
-    }
-}
-
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h b/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h
deleted file mode 100644
index 7a53944..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_create_limiter_bands.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_create_limiter_bands.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_CREATE_LIMITER_BANDS_H
-#define SBR_CREATE_LIMITER_BANDS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "sbr_generate_high_freq.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void sbr_create_limiter_bands(Int32 limSbc[4][12 + 1],
-    Int32 gateMode[4],
-    Int   *freqTable,
-    struct PATCH Patch,
-    const Int32 noBands);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_dec.cpp b/media/libstagefright/codecs/aacdec/sbr_dec.cpp
deleted file mode 100644
index 8519b17..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_dec.cpp
+++ /dev/null
@@ -1,960 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2010 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    sbr decoder core function
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-#include    "s_sbr_frame_data.h"
-#include    "calc_sbr_synfilterbank.h"
-#include    "calc_sbr_anafilterbank.h"
-#include    "calc_sbr_envelope.h"
-#include    "sbr_generate_high_freq.h"
-#include    "sbr_dec.h"
-#include    "decode_noise_floorlevels.h"
-#include    "aac_mem_funcs.h"
-#include    "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-#ifdef PARAMETRICSTEREO
-
-#include   "ps_applied.h"
-#include   "ps_init_stereo_mixing.h"
-
-#endif
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_dec(Int16 *inPcmData,
-             Int16 *ftimeOutPtr,
-             SBR_FRAME_DATA * hFrameData,
-             int32_t applyProcessing,
-             SBR_DEC *sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-             Int16 * ftimeOutPtrPS,
-             HANDLE_PS_DEC hParametricStereoDec,
-#endif
-#endif
-             tDec_Int_File  *pVars)
-{
-    int32_t   i;
-    int32_t   j;
-    int32_t   m;
-
-    int32_t  *frameInfo = hFrameData->frameInfo;
-    Int  num_qmf_bands;
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
-    int32_t env;
-
-    int32_t *qmf_PS_generated_Real;
-    int32_t *qmf_PS_generated_Imag;
-
-    int32_t *Sr_x;
-    int32_t *Si_x;
-
-
-#endif
-#endif
-
-    int32_t(*scratch_mem)[64];
-    Int16 *circular_buffer_s;
-
-    int32_t   k;
-    int32_t *Sr;
-    int32_t *Si;
-    int32_t *ptr_tmp1;
-    int32_t *ptr_tmp2;
-    scratch_mem = pVars->scratch.scratch_mem;
-
-
-    if (applyProcessing)
-    {
-        num_qmf_bands = sbrDec->lowSubband;
-    }
-    else
-    {
-        num_qmf_bands = 32;     /* becomes a resampler by 2  */
-    }
-
-    /* -------------------------------------------------- */
-    /*
-     *    Re-Load Buffers
-     */
-    pv_memmove(&hFrameData->sbrQmfBufferReal[0],
-               &hFrameData->HistsbrQmfBufferReal[0],
-               6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-#ifdef HQ_SBR
-
-
-    if (sbrDec->LC_aacP_DecoderFlag == OFF)
-    {
-        pv_memmove(&hFrameData->sbrQmfBufferImag[0],
-                   &hFrameData->HistsbrQmfBufferImag[0],
-                   6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-    }
-#endif
-    /* -------------------------------------------------- */
-
-
-    /*
-     *    low band codec signal subband filtering
-     */
-
-    for (i = 0; i < 32; i++)
-    {
-
-        if (sbrDec->LC_aacP_DecoderFlag == ON)
-        {
-
-            calc_sbr_anafilterbank_LC(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i],
-                                      &inPcmData[319] + (i << 5),
-                                      scratch_mem,
-                                      num_qmf_bands);
-
-        }
-#ifdef HQ_SBR
-        else
-        {
-
-            calc_sbr_anafilterbank(hFrameData->codecQmfBufferReal[sbrDec->bufWriteOffs + i],
-                                   hFrameData->codecQmfBufferImag[sbrDec->bufWriteOffs + i],
-                                   &inPcmData[319] + (i << 5),
-                                   scratch_mem,
-                                   num_qmf_bands);
-        }
-#endif
-
-    }
-
-    if (pVars->ltp_buffer_state)
-    {
-        pv_memcpy(&inPcmData[-1024-288], &inPcmData[1024], 288*sizeof(*inPcmData));
-    }
-    else
-    {
-        pv_memcpy(&inPcmData[1024 + 288], &inPcmData[1024], 288*sizeof(*inPcmData));
-    }
-
-
-    if (applyProcessing)
-    {
-
-        /*
-         *  Inverse filtering of lowband + HF generation
-         */
-
-        if (sbrDec->LC_aacP_DecoderFlag == ON)
-        {
-
-            sbr_generate_high_freq((int32_t(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs),
-                                   NULL,
-                                   (int32_t *)(hFrameData->sbrQmfBufferReal),
-                                   NULL,
-                                   hFrameData->sbr_invf_mode,
-                                   hFrameData->sbr_invf_mode_prev,
-                                   &(sbrDec->FreqBandTableNoise[1]),
-                                   sbrDec->NoNoiseBands,
-                                   sbrDec->lowSubband,
-                                   sbrDec->V_k_master,
-                                   sbrDec->Num_Master,
-                                   sbrDec->outSampleRate,
-                                   frameInfo,
-                                   hFrameData->degreeAlias,
-                                   scratch_mem,
-                                   hFrameData->BwVector,/* */
-                                   hFrameData->BwVectorOld,
-                                   &(sbrDec->Patch),
-                                   sbrDec->LC_aacP_DecoderFlag,
-                                   &(sbrDec->highSubband));
-
-
-            /*
-             *      Adjust envelope of current frame.
-             */
-
-            calc_sbr_envelope(hFrameData,
-                              (int32_t *)(hFrameData->sbrQmfBufferReal),
-                              NULL,
-                              sbrDec->FreqBandTable,
-                              sbrDec->NSfb,
-                              sbrDec->FreqBandTableNoise,
-                              sbrDec->NoNoiseBands,
-                              hFrameData->reset_flag,
-                              hFrameData->degreeAlias,
-                              &(hFrameData->harm_index),
-                              &(hFrameData->phase_index),
-                              hFrameData->hFp,
-                              &(hFrameData->sUp),
-                              sbrDec->limSbc,
-                              sbrDec->gateMode,
-#ifdef HQ_SBR
-                              NULL,
-                              NULL,
-                              NULL,
-                              NULL,
-#endif
-                              scratch_mem,
-                              sbrDec->Patch,
-                              sbrDec->sqrt_cache,
-                              sbrDec->LC_aacP_DecoderFlag);
-        }
-#ifdef HQ_SBR
-        else
-        {
-
-            sbr_generate_high_freq((int32_t(*)[32])(hFrameData->codecQmfBufferReal + sbrDec->bufReadOffs),
-                                   (int32_t(*)[32])(hFrameData->codecQmfBufferImag + sbrDec->bufReadOffs),
-                                   (int32_t *)(hFrameData->sbrQmfBufferReal),
-                                   (int32_t *)(hFrameData->sbrQmfBufferImag),
-                                   hFrameData->sbr_invf_mode,
-                                   hFrameData->sbr_invf_mode_prev,
-                                   &(sbrDec->FreqBandTableNoise[1]),
-                                   sbrDec->NoNoiseBands,
-                                   sbrDec->lowSubband,
-                                   sbrDec->V_k_master,
-                                   sbrDec->Num_Master,
-                                   sbrDec->outSampleRate,
-                                   frameInfo,
-                                   NULL,
-                                   scratch_mem,
-                                   hFrameData->BwVector,
-                                   hFrameData->BwVectorOld,
-                                   &(sbrDec->Patch),
-                                   sbrDec->LC_aacP_DecoderFlag,
-                                   &(sbrDec->highSubband));
-
-            /*
-             *      Adjust envelope of current frame.
-             */
-
-            calc_sbr_envelope(hFrameData,
-                              (int32_t *)(hFrameData->sbrQmfBufferReal),
-                              (int32_t *)(hFrameData->sbrQmfBufferImag),
-                              sbrDec->FreqBandTable,
-                              sbrDec->NSfb,
-                              sbrDec->FreqBandTableNoise,
-                              sbrDec->NoNoiseBands,
-                              hFrameData->reset_flag,
-                              NULL,
-                              &(hFrameData->harm_index),
-                              &(hFrameData->phase_index),
-                              hFrameData->hFp,
-                              &(hFrameData->sUp),
-                              sbrDec->limSbc,
-                              sbrDec->gateMode,
-                              hFrameData->fBuf_man,
-                              hFrameData->fBuf_exp,
-                              hFrameData->fBufN_man,
-                              hFrameData->fBufN_exp,
-                              scratch_mem,
-                              sbrDec->Patch,
-                              sbrDec->sqrt_cache,
-                              sbrDec->LC_aacP_DecoderFlag);
-
-        }
-#endif
-
-
-    }
-    else   /*  else for applyProcessing */
-    {
-        /* no sbr, set high band buffers to zero */
-
-        for (i = 0; i < SBR_NUM_COLUMNS; i++)
-        {
-            pv_memset((void *)&hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS],
-                      0,
-                      SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
-#ifdef HQ_SBR
-            pv_memset((void *)&hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS],
-                      0,
-                      SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-
-#endif
-        }
-
-    }
-
-
-    /*
-     *  Synthesis subband filtering.
-     */
-
-#ifdef HQ_SBR
-
-#ifdef PARAMETRICSTEREO
-
-
-    /*
-     * psPresentFlag set implies hParametricStereoDec !=NULL, second condition is
-     * is just here to prevent CodeSonar warnings.
-     */
-    if ((pVars->mc_info.psPresentFlag) && (applyProcessing) &&
-            (hParametricStereoDec != NULL))
-    {
-
-        /*
-         *  qmfBufferReal uses the rigth aac channel ( perChan[1] is not used)
-         *  followed by the buffer fxpCoef[2][2048]  which makes a total of
-         *  2349 + 2048*2 = 6445
-         *  These  2 matrices (qmfBufferReal & qmfBufferImag) are
-         *  [2][38][64] == 4864 int32_t
-         */
-
-
-        tDec_Int_Chan *tmpx = &pVars->perChan[1];
-        /*
-         *  dereferencing type-punned pointer avoid
-         *  breaking strict-aliasing rules
-         */
-        int32_t *tmp = (int32_t *)tmpx;
-        hParametricStereoDec->qmfBufferReal = (int32_t(*)[64]) tmp;
-
-        tmp = (int32_t *) & hParametricStereoDec->qmfBufferReal[38][0];
-        hParametricStereoDec->qmfBufferImag = (int32_t(*)[64]) tmp;
-
-        for (i = 0; i < 32; i++)
-        {
-            Int   xoverBand;
-
-            if (i < ((hFrameData->frameInfo[1]) << 1))
-            {
-                xoverBand = sbrDec->prevLowSubband;
-            }
-            else
-            {
-                xoverBand = sbrDec->lowSubband;
-            }
-
-            if (xoverBand > sbrDec->highSubband)
-            {
-                /*
-                 * error condition, default to upsampling mode
-                 * and make sure that the number of bands for xover does
-                 * not exceed the number of high freq bands.
-                 */
-                xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband;
-            }
-
-            m = sbrDec->bufReadOffs + i;    /*  2 + i */
-
-            Sr_x = hParametricStereoDec->qmfBufferReal[i];
-            Si_x = hParametricStereoDec->qmfBufferImag[i];
-
-
-
-            for (int32_t j = 0; j < xoverBand; j++)
-            {
-                Sr_x[j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]);
-                Si_x[j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]);
-            }
-
-
-
-
-            pv_memcpy(&Sr_x[xoverBand],
-                      &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS],
-                      (sbrDec->highSubband - xoverBand)*sizeof(*Sr_x));
-
-            pv_memcpy(&Si_x[xoverBand],
-                      &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS],
-                      (sbrDec->highSubband - xoverBand)*sizeof(*Si_x));
-
-            pv_memset((void *)&Sr_x[sbrDec->highSubband],
-                      0,
-                      (64 - sbrDec->highSubband)*sizeof(*Sr_x));
-
-            pv_memset((void *)&Si_x[sbrDec->highSubband],
-                      0,
-                      (64 - sbrDec->highSubband)*sizeof(*Si_x));
-
-
-        }
-
-        for (i = 32; i < 32 + 6; i++)
-        {
-            m = sbrDec->bufReadOffs + i;     /*  2 + i */
-
-            for (int32_t j = 0; j < 5; j++)
-            {
-                hParametricStereoDec->qmfBufferReal[i][j] = shft_lft_1(hFrameData->codecQmfBufferReal[m][j]);
-                hParametricStereoDec->qmfBufferImag[i][j] = shft_lft_1(hFrameData->codecQmfBufferImag[m][j]);
-            }
-
-        }
-
-
-        /*
-         *    Update Buffers
-         */
-        for (i = 0; i < sbrDec->bufWriteOffs; i++)     /* sbrDec->bufWriteOffs set to 8 and unchanged */
-        {
-            j = sbrDec->noCols + i;                    /* sbrDec->noCols set to 32 and unchanged */
-
-            pv_memmove(hFrameData->codecQmfBufferReal[i],         /* to    */
-                       hFrameData->codecQmfBufferReal[j],        /* from  */
-                       sizeof(*hFrameData->codecQmfBufferReal[i]) << 5);
-
-            pv_memmove(hFrameData->codecQmfBufferImag[i],
-                       hFrameData->codecQmfBufferImag[j],
-                       sizeof(*hFrameData->codecQmfBufferImag[i]) << 5);
-        }
-
-
-        pv_memmove(&hFrameData->HistsbrQmfBufferReal[0],
-                   &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS],
-                   6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
-        pv_memmove(&hFrameData->HistsbrQmfBufferImag[0],
-                   &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS],
-                   6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-
-
-        /*
-         *   Needs whole QMF matrix formed before applying
-         *   Parametric stereo processing.
-         */
-
-        qmf_PS_generated_Real = scratch_mem[0];
-        qmf_PS_generated_Imag = scratch_mem[1];
-        env = 0;
-
-        /*
-         *  Set circular buffer for Left channel
-         */
-
-        circular_buffer_s = (Int16 *)scratch_mem[7];
-
-
-        if (pVars->mc_info.bDownSampledSbr)
-        {
-            pv_memmove(&circular_buffer_s[2048],
-                       hFrameData->V,
-                       640*sizeof(*circular_buffer_s));
-        }
-        else
-        {
-            pv_memmove(&circular_buffer_s[4096],
-                       hFrameData->V,
-                       1152*sizeof(*circular_buffer_s));
-
-        }
-
-
-        /*
-         *  Set Circular buffer for PS hybrid analysis
-         */
-
-        int32_t *pt_temp = &scratch_mem[2][32];
-
-        for (i = 0, j = 0; i < 3; i++)
-        {
-
-            pv_memmove(&pt_temp[ j],
-                       hParametricStereoDec->hHybrid->mQmfBufferReal[i],
-                       HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal));
-            pv_memmove(&pt_temp[ j + 44],
-                       hParametricStereoDec->hHybrid->mQmfBufferImag[i],
-                       HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag));
-            j += 88;
-        }
-
-
-        pv_memset((void *)&qmf_PS_generated_Real[hParametricStereoDec->usb],
-                  0,
-                  (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Real));
-
-        pv_memset((void *)&qmf_PS_generated_Imag[hParametricStereoDec->usb],
-                  0,
-                  (64 - hParametricStereoDec->usb)*sizeof(*qmf_PS_generated_Imag));
-
-
-        for (i = 0; i < 32; i++)
-        {
-            if (i == (Int)hParametricStereoDec-> aEnvStartStop[env])
-            {
-                ps_init_stereo_mixing(hParametricStereoDec, env, sbrDec->highSubband);
-                env++;
-            }
-
-
-            ps_applied(hParametricStereoDec,
-                       &hParametricStereoDec->qmfBufferReal[i],
-                       &hParametricStereoDec->qmfBufferImag[i],
-                       qmf_PS_generated_Real,
-                       qmf_PS_generated_Imag,
-                       scratch_mem[2],
-                       i);
-
-            /* Create time samples for regular mono channel */
-
-            if (pVars->mc_info.bDownSampledSbr)
-            {
-                calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i],  /* realSamples  */
-                                       hParametricStereoDec->qmfBufferImag[i], /* imagSamples  */
-                                       ftimeOutPtr + (i << 6),
-                                       &circular_buffer_s[1984 - (i<<6)],
-                                       pVars->mc_info.bDownSampledSbr);
-            }
-            else
-            {
-                calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i],  /* realSamples  */
-                                       hParametricStereoDec->qmfBufferImag[i], /* imagSamples  */
-                                       ftimeOutPtr + (i << 7),
-                                       &circular_buffer_s[3968 - (i<<7)],
-                                       pVars->mc_info.bDownSampledSbr);
-
-            }
-
-            pv_memmove(hParametricStereoDec->qmfBufferReal[i], qmf_PS_generated_Real, 64*sizeof(*qmf_PS_generated_Real));
-            pv_memmove(hParametricStereoDec->qmfBufferImag[i], qmf_PS_generated_Imag, 64*sizeof(*qmf_PS_generated_Real));
-
-        }
-
-
-        /*
-         *  Save Circular buffer history used on PS hybrid analysis
-         */
-
-
-        pt_temp = &scratch_mem[2][64];
-
-        for (i = 0, j = 0; i < 3; i++)
-        {
-            pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferReal[i],
-                       &pt_temp[ j],
-                       HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferReal));
-
-            pv_memmove(hParametricStereoDec->hHybrid->mQmfBufferImag[i],
-                       &pt_temp[ j + 44],
-                       HYBRID_FILTER_LENGTH_m_1*sizeof(*hParametricStereoDec->hHybrid->mQmfBufferImag));
-
-            j += 88;
-        }
-
-
-        pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
-
-        /*
-         *  Set circular buffer for Right channel
-         */
-
-        circular_buffer_s = (Int16 *)scratch_mem[5];
-
-        if (pVars->mc_info.bDownSampledSbr)
-        {
-            pv_memmove(&circular_buffer_s[2048],
-                       (int32_t *)hParametricStereoDec->R_ch_qmf_filter_history,
-                       640*sizeof(*circular_buffer_s));
-        }
-        else
-        {
-            pv_memmove(&circular_buffer_s[4096],
-                       (int32_t *)hParametricStereoDec->R_ch_qmf_filter_history,
-                       1152*sizeof(*circular_buffer_s));
-
-        }
-
-
-        for (i = 0; i < 32; i++)
-        {
-            if (pVars->mc_info.bDownSampledSbr)
-            {
-
-                calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i],  /* realSamples  */
-                                       hParametricStereoDec->qmfBufferImag[i], /* imagSamples  */
-                                       ftimeOutPtrPS + (i << 6),
-                                       &circular_buffer_s[1984 - (i<<6)],
-                                       pVars->mc_info.bDownSampledSbr);
-            }
-            else
-            {
-                calc_sbr_synfilterbank(hParametricStereoDec->qmfBufferReal[i],  /* realSamples  */
-                                       hParametricStereoDec->qmfBufferImag[i], /* imagSamples  */
-                                       ftimeOutPtrPS + (i << 7),
-                                       &circular_buffer_s[3968 - (i<<7)],
-                                       pVars->mc_info.bDownSampledSbr);
-            }
-
-        }
-
-        if (pVars->mc_info.bDownSampledSbr)
-        {
-            pv_memmove((int32_t *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s));
-        }
-        else
-        {
-            pv_memmove((int32_t *)hParametricStereoDec->R_ch_qmf_filter_history, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
-        }
-
-
-
-
-
-    }
-    else    /*  else -- sbrEnablePS  */
-    {
-
-#endif      /*   PARAMETRICSTEREO */
-#endif      /*   HQ_SBR */
-
-        /*
-         *  Use shared aac memory as continuous buffer
-         */
-
-
-        Sr  = scratch_mem[0];
-        Si  = scratch_mem[1];
-
-        circular_buffer_s = (Int16*)scratch_mem[2];
-
-        if (pVars->mc_info.bDownSampledSbr)
-        {
-
-            pv_memmove(&circular_buffer_s[2048],
-                       hFrameData->V,
-                       640*sizeof(*circular_buffer_s));
-        }
-        else
-        {
-            pv_memmove(&circular_buffer_s[4096],
-                       hFrameData->V,
-                       1152*sizeof(*circular_buffer_s));
-        }
-
-        for (i = 0; i < 32; i++)
-        {
-            Int   xoverBand;
-
-            if (applyProcessing)
-            {
-                if (i < ((hFrameData->frameInfo[1]) << 1))
-                {
-                    xoverBand = sbrDec->prevLowSubband;
-
-                }
-                else
-                {
-                    xoverBand = sbrDec->lowSubband;
-                }
-
-                if (xoverBand > sbrDec->highSubband)
-                {
-                    /*
-                     * error condition, default to upsampling mode
-                     * and make sure that the number of bands for xover does
-                     * not exceed the number of high freq bands.
-                     */
-                    xoverBand = (sbrDec->highSubband > 32)? 32: sbrDec->highSubband;
-                }
-            }
-            else
-            {
-                xoverBand = 32;
-                sbrDec->highSubband = 32;
-            }
-
-
-            m = sbrDec->bufReadOffs + i;    /* sbrDec->bufReadOffs == 2 */
-
-
-            ptr_tmp1 = (hFrameData->codecQmfBufferReal[m]);
-            ptr_tmp2 = Sr;
-
-            if (sbrDec->LC_aacP_DecoderFlag == ON)
-            {
-
-                for (k = (xoverBand >> 1); k != 0; k--)
-                {
-                    *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9;
-                    *(ptr_tmp2++) = (*(ptr_tmp1++)) >> 9;
-                }
-                if (xoverBand & 1)
-                {
-                    *(ptr_tmp2++) = (*(ptr_tmp1)) >> 9;
-                }
-
-                ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS];
-
-
-                for (k = xoverBand; k < sbrDec->highSubband; k++)
-                {
-                    *(ptr_tmp2++) = (*(ptr_tmp1++)) << 1;
-                }
-
-                pv_memset((void *)ptr_tmp2,
-                          0,
-                          (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
-                if (pVars->mc_info.bDownSampledSbr)
-                {
-                    calc_sbr_synfilterbank_LC(Sr,               /* realSamples  */
-                                              ftimeOutPtr + (i << 6),
-                                              &circular_buffer_s[1984 - (i<<6)],
-                                              pVars->mc_info.bDownSampledSbr);
-                }
-                else
-                {
-                    calc_sbr_synfilterbank_LC(Sr,               /* realSamples  */
-                                              ftimeOutPtr + (i << 7),
-                                              &circular_buffer_s[3968 - (i<<7)],
-                                              pVars->mc_info.bDownSampledSbr);
-                }
-            }
-#ifdef HQ_SBR
-            else
-            {
-
-                for (k = xoverBand; k != 0; k--)
-                {
-                    *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
-                }
-
-                ptr_tmp1 = &hFrameData->sbrQmfBufferReal[i*SBR_NUM_BANDS];
-                ptr_tmp2 = &Sr[xoverBand];
-
-
-                for (k = xoverBand; k < sbrDec->highSubband; k++)
-                {
-                    *(ptr_tmp2++) = (*(ptr_tmp1++));
-                }
-
-                pv_memset((void *)ptr_tmp2,
-                          0,
-                          (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
-                ptr_tmp1 = (hFrameData->codecQmfBufferImag[m]);
-                ptr_tmp2 = Si;
-
-                for (k = (xoverBand >> 1); k != 0; k--)
-                {
-                    *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
-                    *(ptr_tmp2++) = shft_lft_1(*(ptr_tmp1++));
-                }
-                if (xoverBand & 1)
-                {
-                    *(ptr_tmp2) = shft_lft_1(*(ptr_tmp1));
-                }
-
-                ptr_tmp1 = &hFrameData->sbrQmfBufferImag[i*SBR_NUM_BANDS];
-                ptr_tmp2 = &Si[xoverBand];
-
-                for (k = xoverBand; k < sbrDec->highSubband; k++)
-                {
-                    *(ptr_tmp2++) = (*(ptr_tmp1++));
-                }
-
-                pv_memset((void *)ptr_tmp2,
-                          0,
-                          (64 - sbrDec->highSubband)*sizeof(*ptr_tmp2));
-
-
-                if (pVars->mc_info.bDownSampledSbr)
-                {
-                    calc_sbr_synfilterbank(Sr,              /* realSamples  */
-                                           Si,             /* imagSamples  */
-                                           ftimeOutPtr + (i << 6),
-                                           &circular_buffer_s[1984 - (i<<6)],
-                                           pVars->mc_info.bDownSampledSbr);
-                }
-                else
-                {
-                    calc_sbr_synfilterbank(Sr,              /* realSamples  */
-                                           Si,             /* imagSamples  */
-                                           ftimeOutPtr + (i << 7),
-                                           &circular_buffer_s[3968 - (i<<7)],
-                                           pVars->mc_info.bDownSampledSbr);
-                }
-            }
-#endif
-
-        }
-
-        if (pVars->mc_info.bDownSampledSbr)
-        {
-            pv_memmove(hFrameData->V, &circular_buffer_s[0], 640*sizeof(*circular_buffer_s));
-        }
-        else
-        {
-            pv_memmove(hFrameData->V, &circular_buffer_s[0], 1152*sizeof(*circular_buffer_s));
-        }
-
-
-
-
-        /*
-         *    Update Buffers
-         */
-        for (i = 0; i < sbrDec->bufWriteOffs; i++)     /* sbrDec->bufWriteOffs set to 8 and unchanged */
-        {
-            j = sbrDec->noCols + i;                    /* sbrDec->noCols set to 32 and unchanged */
-
-            pv_memmove(hFrameData->codecQmfBufferReal[i],         /* to    */
-                       hFrameData->codecQmfBufferReal[j],        /* from  */
-                       sizeof(*hFrameData->codecQmfBufferReal[i]) << 5);
-        }
-
-
-        pv_memmove(&hFrameData->HistsbrQmfBufferReal[0],
-                   &hFrameData->sbrQmfBufferReal[32*SBR_NUM_BANDS],
-                   6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferReal));
-
-#ifdef HQ_SBR
-        if (sbrDec->LC_aacP_DecoderFlag == OFF)
-        {
-            for (i = 0; i < sbrDec->bufWriteOffs; i++)     /* sbrDec->bufWriteOffs set to 6 and unchanged */
-            {
-                j = sbrDec->noCols + i;                    /* sbrDec->noCols set to 32 and unchanged */
-
-
-                pv_memmove(hFrameData->codecQmfBufferImag[i],
-                           hFrameData->codecQmfBufferImag[j],
-                           sizeof(*hFrameData->codecQmfBufferImag[i]) << 5);
-
-            }
-
-            pv_memmove(&hFrameData->HistsbrQmfBufferImag[0],
-                       &hFrameData->sbrQmfBufferImag[32*SBR_NUM_BANDS],
-                       6*SBR_NUM_BANDS*sizeof(*hFrameData->sbrQmfBufferImag));
-        }
-#endif
-
-
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-    }
-#endif
-#endif
-
-
-    hFrameData->reset_flag = 0;
-    if (applyProcessing)
-    {
-        sbrDec->prevLowSubband = sbrDec->lowSubband;
-    }
-
-}
-
-
-#endif      /*  AAC_PLUS */
diff --git a/media/libstagefright/codecs/aacdec/sbr_dec.h b/media/libstagefright/codecs/aacdec/sbr_dec.h
deleted file mode 100644
index ba7c1f3..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_dec.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_dec.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DEC_H
-#define SBR_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "s_sbr_frame_data.h"
-#include    "pv_audio_type_defs.h"
-#include    "s_patch.h"
-#include    "e_blockswitching.h"
-#include    "s_sbr_dec.h"
-#include    "s_tdec_int_file.h"
-#ifdef PARAMETRICSTEREO
-#include    "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-
-    void sbr_dec(Int16 *inPcmData,
-    Int16 *ftimeOutPtr,
-    SBR_FRAME_DATA * hFrameData,
-    Int32 applyProcessing,
-    SBR_DEC *sbrDec,
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-    Int16 * ftimeOutPtrPS,
-    HANDLE_PS_DEC hParametricStereoDec,
-#endif
-#endif
-    tDec_Int_File  *pVars);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp b/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp
deleted file mode 100644
index 771bb32..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.cpp
+++ /dev/null
@@ -1,286 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_decode_envelope.h"
-#include    "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void mapLowResEnergyVal(
-    Int32  currVal,
-    Int32 *prevData,
-    Int32 offset,
-    Int32 index,
-    Int32 res);
-
-Int32 indexLow2High(Int32 offset,
-                    Int32 index,
-                    Int32 res);
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData)
-
-{
-    Int32 i;
-    Int32 no_of_bands;
-    Int32 band;
-    Int32 freqRes;
-    Int32 *iEnvelope    = hFrameData->iEnvelope_man;
-    Int32 *sfb_nrg_prev = hFrameData->sfb_nrg_prev_man;
-
-    Int32  offset       = hFrameData->offset;
-    Int32 *nSfb         = hFrameData->nSfb;
-    Int32 *domain_vec   = hFrameData->domain_vec1;
-    Int32 *frameInfo    = hFrameData->frameInfo;
-
-
-
-    for (i = 0; i < frameInfo[0]; i++)
-    {
-        freqRes = frameInfo[frameInfo[0] + i + 2];
-        no_of_bands = nSfb[freqRes];
-
-        if (domain_vec[i] == 0)
-        {
-            mapLowResEnergyVal(*iEnvelope,
-                               sfb_nrg_prev,
-                               offset,
-                               0,
-                               freqRes);
-            iEnvelope++;
-
-            for (band = 1; band < no_of_bands; band++)
-            {
-                *iEnvelope +=  *(iEnvelope - 1);
-
-                mapLowResEnergyVal(*iEnvelope,
-                                   sfb_nrg_prev,
-                                   offset,
-                                   band,
-                                   freqRes);
-                iEnvelope++;
-            }
-        }
-        else
-        {
-            for (band = 0; band < no_of_bands; band++)
-            {
-                *iEnvelope +=  sfb_nrg_prev[ indexLow2High(offset, band, freqRes)];
-
-                mapLowResEnergyVal(*iEnvelope,
-                                   sfb_nrg_prev,
-                                   offset,
-                                   band,
-                                   freqRes);
-                iEnvelope++;
-            }
-        }
-    }
-}
-
-
-
-void mapLowResEnergyVal(
-    Int32  currVal,
-    Int32 *prevData,
-    Int32  offset,
-    Int32  index,
-    Int32  res)
-{
-    Int32 tmp;
-
-    if (res == LO)
-    {
-        if (offset >= 0)
-        {
-            if (index < offset)
-            {
-                prevData[index] = currVal;
-            }
-            else
-            {
-                tmp = (index << 1) - offset;
-                prevData[tmp    ] = currVal;
-                prevData[tmp +1 ] = currVal;
-            }
-        }
-        else
-        {
-            offset = -offset;
-            if (index < offset)
-            {
-                tmp = (index << 1) + index;
-                prevData[tmp    ] = currVal;
-                prevData[tmp + 1] = currVal;
-                prevData[tmp + 2] = currVal;
-            }
-            else
-            {
-                tmp = (index << 1) + offset;
-                prevData[tmp    ] = currVal;
-                prevData[tmp + 1] = currVal;
-            }
-        }
-    }
-    else
-    {
-        prevData[index] = currVal;
-    }
-}
-
-
-Int32 indexLow2High(Int32 offset,
-                    Int32 index,
-                    Int32 res)
-{
-    if (res == LO)
-    {
-        if (offset >= 0)
-        {
-            if (index < offset)
-            {
-                return(index);
-            }
-            else
-            {
-                return((index << 1) - offset);
-            }
-        }
-        else
-        {
-            offset = -offset;
-            if (index < offset)
-            {
-                return((index << 1) + index);
-            }
-            else
-            {
-                return((index << 1) + offset);
-            }
-        }
-    }
-    else
-    {
-        return(index);
-    }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h b/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h
deleted file mode 100644
index 19c04a9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_envelope.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_envelope.h
- Funtions:
-    decodeEnvelope
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DECODE_ENVELOPE_H
-#define SBR_DECODE_ENVELOPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void sbr_decode_envelope(SBR_FRAME_DATA * hFrameData);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp b/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp
deleted file mode 100644
index 290fd18..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_huff_cw.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-        SbrHuffman          h,     pointer to huffman codebook table
-        BIT_BUFFER    * hBitBuf    pointer  to Bitbuffer
-
-    return    decoded value
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Decodes one huffman code word
-
-  Reads bits from the bitstream until a valid codeword is found.
-  The table entries are interpreted either as index to the next entry
-  or - if negative - as the codeword.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_decode_huff_cw.h"
-#include    "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int32 sbr_decode_huff_cw(SbrHuffman h,
-                         BIT_BUFFER * hBitBuf)
-{
-    Int32 bits;
-    Char index = 0;
-
-    while (index >= 0)
-    {
-        bits = buf_get_1bit(hBitBuf);
-        index = h[index][bits];
-    }
-
-    return((Int32)index + 64); /* Add offset */
-}
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h b/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h
deleted file mode 100644
index bfbdb67..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_decode_huff_cw.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_decode_huff_cw.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DECODE_HUFF_CW_H
-#define SBR_DECODE_HUFF_CW_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_huffman.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int32 sbr_decode_huff_cw(SbrHuffman h,
-    BIT_BUFFER * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp b/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp
deleted file mode 100644
index c2b007a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_downsample_lo_res.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_downsample_lo_res.h"
-#include    "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void  sbr_downsample_lo_res(Int32 v_result[],
-                            Int32 num_result,
-                            Int   freqBandTableRef[],
-                            Int32 num_Ref)
-{
-    Int32 step;
-    Int32 i, j;
-    Int32 org_length;
-    Int32 result_length;
-    Int32 v_index[MAX_FREQ_COEFFS/2];
-
-    /* init */
-    org_length = num_Ref;
-    result_length = num_result;
-
-    v_index[0] = 0; /* Always use left border */
-    i = 0;
-    while (org_length > 0)  /* Create downsample vector */
-    {
-        i++;
-        step = org_length / result_length; /* floor; */
-        org_length = org_length - step;
-        result_length--;
-        v_index[i] = v_index[i-1] + step;
-    }
-
-    for (j = 0; j <= i; j++)   /* Use downsample vector to index LoResolution vector. */
-    {
-        v_result[j] = freqBandTableRef[ v_index[j]];
-    }
-
-}  /* End downSampleLoRes */
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h b/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h
deleted file mode 100644
index 2f49aea..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_downsample_lo_res.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_downsample_lo_res.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_DOWNSAMPLE_LO_RES_H
-#define SBR_DOWNSAMPLE_LO_RES_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void  sbr_downsample_lo_res(Int32 v_result[],
-    Int32 num_result,
-    Int   freqBandTableRef[],
-    Int32 num_Ref);
-
-#ifdef __cplusplus
-}
-#endif
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp b/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp
deleted file mode 100644
index 2ed76dd..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.cpp
+++ /dev/null
@@ -1,424 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_calc_tbl.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_envelope_calc_tbl.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-#define Q30_fmt(x)   (Int32)(x*((Int32)1<<30) + (x>=0?0.5F:-0.5F))
-#define Qfmt15(x)    (Int16)(x*((Int32)1<<15) + (x>=0?0.5F:-0.5F))
-
-
-const Int32 limGains[5] = { Q30_fmt(0.70795f), Q30_fmt(1.0f),
-                            Q30_fmt(1.41254f), Q30_fmt(1.16415321826935f), 33
-                          };
-
-const Int32 smoothLengths[2] = { 4, 0 };
-
-const Int16 rP_LCx[512] =
-{
-    Qfmt15(-0.99948153278296f), Qfmt15(0.97113454393991f), Qfmt15(0.14130051758487f), Qfmt15(-0.47005496701697f),
-    Qfmt15(0.80705063769351f), Qfmt15(-0.38981478896926f), Qfmt15(-0.01053049862020f), Qfmt15(-0.91266367957293f),
-    Qfmt15(0.54840422910309f), Qfmt15(0.40009252867955f), Qfmt15(-0.99867974711855f), Qfmt15(-0.95531076805040f),
-    Qfmt15(-0.45725933317144f), Qfmt15(-0.72929675029275f), Qfmt15(0.75622801399036f), Qfmt15(0.07069442601050f),
-    Qfmt15(0.74496252926055f), Qfmt15(-0.96440182703856f), Qfmt15(0.30424629369539f), Qfmt15(0.66565033746925f),
-    Qfmt15(0.91697008020594f), Qfmt15(-0.70774918760427f), Qfmt15(-0.70051415345560f), Qfmt15(-0.99496513054797f),
-    Qfmt15(0.98164490790123f), Qfmt15(-0.54671580548181f), Qfmt15(-0.01689629065389f), Qfmt15(-0.86110349531986f),
-    Qfmt15(-0.98892980586032f), Qfmt15(0.51756627678691f), Qfmt15(-0.99635026409640f), Qfmt15(-0.99969370862163f),
-    Qfmt15(0.55266258627194f), Qfmt15(0.34581177741673f), Qfmt15(0.62664209577999f), Qfmt15(-0.77149701404973f),
-    Qfmt15(-0.91592244254432f), Qfmt15(-0.76285492357887f), Qfmt15(0.79788337195331f), Qfmt15(0.54473080610200f),
-    Qfmt15(-0.85639281671058f), Qfmt15(-0.92882402971423f), Qfmt15(-0.11708371046774f), Qfmt15(0.21356749817493f),
-    Qfmt15(-0.76191692573909f), Qfmt15(0.98111043100884f), Qfmt15(-0.85913269895572f), Qfmt15(-0.93307242253692f),
-    Qfmt15(0.30485754879632f), Qfmt15(0.85289650925190f), Qfmt15(0.91328082618125f), Qfmt15(-0.05890199924154f),
-    Qfmt15(0.28398686150148f), Qfmt15(0.95258164539612f), Qfmt15(-0.78566324168507f), Qfmt15(-0.95789495447877f),
-    Qfmt15(0.82411158711197f), Qfmt15(-0.65185446735885f), Qfmt15(-0.93643603134666f), Qfmt15(0.91427159529618f),
-    Qfmt15(-0.70395684036886f), Qfmt15(0.00563771969365f), Qfmt15(0.89065051931895f), Qfmt15(-0.68683707712762f),
-    Qfmt15(0.72165342518718f), Qfmt15(-0.62928247730667f), Qfmt15(0.29938434065514f), Qfmt15(-0.91781958879280f),
-    Qfmt15(0.99298717043688f), Qfmt15(0.82368298622748f), Qfmt15(-0.98512833386833f), Qfmt15(-0.95915368242257f),
-    Qfmt15(-0.21411126572790f), Qfmt15(-0.68821476106884f), Qfmt15(0.91851997982317f), Qfmt15(-0.96062769559127f),
-    Qfmt15(0.51646184922287f), Qfmt15(0.61130721139669f), Qfmt15(0.47336129371299f), Qfmt15(0.90998308703519f),
-    Qfmt15(0.44844799194357f), Qfmt15(0.66614891079092f), Qfmt15(0.74922239129237f), Qfmt15(-0.99571588506485f),
-    Qfmt15(0.97401082477563f), Qfmt15(0.72683747733879f), Qfmt15(0.95432193457128f), Qfmt15(-0.72962208425191f),
-    Qfmt15(-0.85359479233537f), Qfmt15(-0.81412430338535f), Qfmt15(-0.87930772356786f), Qfmt15(-0.71573331064977f),
-    Qfmt15(0.83524300028228f), Qfmt15(-0.48086065601423f), Qfmt15(0.97139128574778f), Qfmt15(0.51992825347895f),
-    Qfmt15(-0.00848591195325f), Qfmt15(-0.70294374303036f), Qfmt15(-0.95894428168140f), Qfmt15(0.97079252950321f),
-    Qfmt15(-0.92404293670797f), Qfmt15(-0.69506469500450f), Qfmt15(0.26559203620024f), Qfmt15(0.28038443336943f),
-    Qfmt15(-0.74138124825523f), Qfmt15(-0.01752795995444f), Qfmt15(-0.55126773094930f), Qfmt15(0.97960898850996f),
-    Qfmt15(-0.99196309146936f), Qfmt15(-0.67684928085260f), Qfmt15(0.09140039465500f), Qfmt15(-0.71658965751996f),
-    Qfmt15(0.81014640078925f), Qfmt15(0.40616991671205f), Qfmt15(-0.67680188682972f), Qfmt15(0.86849774348749f),
-    Qfmt15(-0.99500381284851f), Qfmt15(0.84329189340667f), Qfmt15(-0.09215968531446f), Qfmt15(0.99956173327206f),
-    Qfmt15(-0.79732779473535f), Qfmt15(0.96349973642406f), Qfmt15(-0.79942778496547f), Qfmt15(-0.11566039853896f),
-    Qfmt15(-0.39922954514662f), Qfmt15(0.99089197565987f), Qfmt15(0.28631285179909f), Qfmt15(-0.83302725605608f),
-    Qfmt15(0.95404443402072f), Qfmt15(-0.06449863579434f), Qfmt15(-0.99575054486311f), Qfmt15(-0.65501142790847f),
-    Qfmt15(-0.81254441908887f), Qfmt15(-0.99646369485481f), Qfmt15(0.00287840603348f), Qfmt15(0.70176989408455f),
-    Qfmt15(0.96361882270190f), Qfmt15(-0.68883758192426f), Qfmt15(-0.34875585502238f), Qfmt15(0.91980081243087f),
-    Qfmt15(-0.99009048343881f), Qfmt15(0.68865791458395f), Qfmt15(-0.99484402129368f), Qfmt15(0.94214511408023f),
-    Qfmt15(-0.67414626793544f), Qfmt15(-0.47339353684664f), Qfmt15(0.14323651387360f), Qfmt15(-0.29268293575672f),
-    Qfmt15(0.43793861458754f), Qfmt15(-0.36345126374441f), Qfmt15(-0.08750604656825f), Qfmt15(-0.96495267812511f),
-    Qfmt15(0.55526940659947f), Qfmt15(0.73538215752630f), Qfmt15(-0.30889773919437f), Qfmt15(0.03574995626194f),
-    Qfmt15(0.98720684660488f), Qfmt15(-0.81689296271203f), Qfmt15(0.67866860118215f), Qfmt15(-0.15808569732583f),
-    Qfmt15(0.80723395114371f), Qfmt15(0.47788757329038f), Qfmt15(0.96367554763201f), Qfmt15(-0.99143875716818f),
-    Qfmt15(0.83081876925833f), Qfmt15(-0.58753191905341f), Qfmt15(0.95538108220960f), Qfmt15(-0.96490920476211f),
-    Qfmt15(-0.97327101028521f), Qfmt15(0.91400366022124f), Qfmt15(-0.99925837363824f), Qfmt15(-0.86875903507313f),
-    Qfmt15(-0.26240034795124f), Qfmt15(-0.24664412953388f), Qfmt15(0.02416275806869f), Qfmt15(0.82068619590515f),
-    Qfmt15(0.88547373760759f), Qfmt15(-0.18173078152226f), Qfmt15(0.09355476558534f), Qfmt15(-0.54668414224090f),
-    Qfmt15(0.37050990604091f), Qfmt15(-0.70373594262891f), Qfmt15(-0.34600785879594f), Qfmt15(-0.68774481731008f),
-    Qfmt15(-0.26843291251234f), Qfmt15(0.49072334613242f), Qfmt15(0.38975993093975f), Qfmt15(-0.97757125224150f),
-    Qfmt15(-0.17325552859616f), Qfmt15(0.99948035025744f), Qfmt15(-0.64946246527458f), Qfmt15(-0.12016920576437f),
-    Qfmt15(-0.58947456517751f), Qfmt15(-0.41815140454465f), Qfmt15(0.99885650204884f), Qfmt15(-0.56649614128386f),
-    Qfmt15(0.94138021032330f), Qfmt15(-0.75725076534641f), Qfmt15(0.20541973692630f), Qfmt15(0.99980371023351f),
-    Qfmt15(0.29078277605775f), Qfmt15(-0.62858772103030f), Qfmt15(0.43440904467688f), Qfmt15(-0.98298583762390f),
-    Qfmt15(0.19513029146934f), Qfmt15(-0.95476662400101f), Qfmt15(0.93379635304810f), Qfmt15(-0.85235410573336f),
-    Qfmt15(-0.86425093011245f), Qfmt15(0.38879779059045f), Qfmt15(0.92045124735495f), Qfmt15(0.89162532251878f),
-    Qfmt15(-0.36834336949252f), Qfmt15(0.93891760988045f), Qfmt15(0.99267657565094f), Qfmt15(-0.94063471614176f),
-    Qfmt15(0.99740224117019f), Qfmt15(-0.35899413170555f), Qfmt15(0.05237237274947f), Qfmt15(0.36703583957424f),
-    Qfmt15(0.91653180367913f), Qfmt15(0.69000803499316f), Qfmt15(-0.38658751133527f), Qfmt15(-0.29250814029851f),
-    Qfmt15(-0.60182204677608f), Qfmt15(-0.97418588163217f), Qfmt15(0.88461574003963f), Qfmt15(0.05198933055162f),
-    Qfmt15(-0.53499621979720f), Qfmt15(-0.49429560226497f), Qfmt15(-0.98935142339139f), Qfmt15(-0.98081380091130f),
-    Qfmt15(-0.27338148835532f), Qfmt15(0.06310802338302f), Qfmt15(-0.20461677199539f), Qfmt15(0.66223843141647f),
-    Qfmt15(-0.84764345483665f), Qfmt15(-0.89039863483811f), Qfmt15(0.95903308477986f), Qfmt15(0.73504123909879f),
-    Qfmt15(-0.31744434966056f), Qfmt15(-0.34110827591623f), Qfmt15(0.47803883714199f), Qfmt15(0.98299195879514f),
-    Qfmt15(-0.30963073129751f), Qfmt15(0.99992588229018f), Qfmt15(-0.93149731080767f), Qfmt15(0.99923472302773f),
-    Qfmt15(-0.26024169633417f), Qfmt15(-0.35712514743563f), Qfmt15(-0.99899084509530f), Qfmt15(0.86557171579452f),
-    Qfmt15(0.33408042438752f), Qfmt15(0.99010736374716f), Qfmt15(-0.66694269691195f), Qfmt15(0.64016792079480f),
-    Qfmt15(0.99570534804836f), Qfmt15(-0.63431466947340f), Qfmt15(-0.07706847005931f), Qfmt15(0.98590090577724f),
-    Qfmt15(0.80099335254678f), Qfmt15(0.78368131392666f), Qfmt15(0.08707806671691f), Qfmt15(-0.86811883080712f),
-    Qfmt15(-0.39466529740375f), Qfmt15(0.97875325649683f), Qfmt15(-0.95038560288864f), Qfmt15(0.17005239424212f),
-    Qfmt15(-0.76910792026848f), Qfmt15(0.99743281016846f), Qfmt15(0.95437383549973f), Qfmt15(0.99578905365569f),
-    Qfmt15(0.28058259829990f), Qfmt15(0.85256524470573f), Qfmt15(-0.50608540105128f), Qfmt15(-0.97210735183243f),
-    Qfmt15(0.95424048234441f), Qfmt15(-0.96926570524023f), Qfmt15(0.30872163214726f), Qfmt15(-0.24523839572639f),
-    Qfmt15(-0.33813265086024f), Qfmt15(-0.05826828420146f), Qfmt15(-0.22898461455054f), Qfmt15(-0.18509915019881f),
-    Qfmt15(-0.10488238045009f), Qfmt15(-0.71886586182037f), Qfmt15(0.99793873738654f), Qfmt15(0.57563307626120f),
-    Qfmt15(0.28909646383717f), Qfmt15(0.42188998312520f), Qfmt15(0.93335049681047f), Qfmt15(-0.97087374418267f),
-    Qfmt15(0.36722871286923f), Qfmt15(-0.81093025665696f), Qfmt15(-0.26240603062237f), Qfmt15(0.83996497984604f),
-    Qfmt15(-0.99909615720225f), Qfmt15(0.74649464155061f), Qfmt15(-0.74774595569805f), Qfmt15(0.95781667469567f),
-    Qfmt15(0.95472308713099f), Qfmt15(0.48708332746299f), Qfmt15(0.46332038247497f), Qfmt15(-0.76497004940162f),
-    Qfmt15(0.57397389364339f), Qfmt15(0.75374316974495f), Qfmt15(-0.59174397685714f), Qfmt15(0.75087906691890f),
-    Qfmt15(-0.98607857336230f), Qfmt15(-0.40761056640505f), Qfmt15(0.66929266740477f), Qfmt15(-0.97463695257310f),
-    Qfmt15(0.90145509409859f), Qfmt15(-0.87259289048043f), Qfmt15(-0.91529461447692f), Qfmt15(-0.03305738840705f),
-    Qfmt15(0.07223051368337f), Qfmt15(0.99498012188353f), Qfmt15(-0.74904939500519f), Qfmt15(0.04585228574211f),
-    Qfmt15(-0.89054954257993f), Qfmt15(-0.83782144651251f), Qfmt15(0.33454804933804f), Qfmt15(-0.99707579362824f),
-    Qfmt15(-0.22827527843994f), Qfmt15(0.67248046289143f), Qfmt15(-0.05146538187944f), Qfmt15(0.99947295749905f),
-    Qfmt15(0.66951124390363f), Qfmt15(-0.99602956559179f), Qfmt15(0.82104905483590f), Qfmt15(0.99186510988782f),
-    Qfmt15(-0.65284592392918f), Qfmt15(0.93885443798188f), Qfmt15(0.96735248738388f), Qfmt15(-0.22225968841114f),
-    Qfmt15(-0.44132783753414f), Qfmt15(-0.85694974219574f), Qfmt15(0.91783042091762f), Qfmt15(0.72556974415690f),
-    Qfmt15(-0.99711581834508f), Qfmt15(0.77638976371966f), Qfmt15(0.07717324253925f), Qfmt15(-0.56049829194163f),
-    Qfmt15(0.98398893639988f), Qfmt15(0.47546946844938f), Qfmt15(0.65675089314631f), Qfmt15(0.03273375457980f),
-    Qfmt15(-0.38684144784738f), Qfmt15(-0.97346267944545f), Qfmt15(-0.53282156061942f), Qfmt15(0.99817310731176f),
-    Qfmt15(-0.50254500772635f), Qfmt15(0.01995873238855f), Qfmt15(0.99930381973804f), Qfmt15(0.82907767600783f),
-    Qfmt15(-0.58660709669728f), Qfmt15(-0.17573736667267f), Qfmt15(0.83434292401346f), Qfmt15(0.05946491307025f),
-    Qfmt15(0.81505484574602f), Qfmt15(-0.44976380954860f), Qfmt15(-0.89746474625671f), Qfmt15(0.39677256130792f),
-    Qfmt15(-0.07588948563079f), Qfmt15(0.76343198951445f), Qfmt15(-0.74490104699626f), Qfmt15(0.64880119792759f),
-    Qfmt15(0.62319537462542f), Qfmt15(0.42215817594807f), Qfmt15(0.02704554141885f), Qfmt15(0.80001773566818f),
-    Qfmt15(-0.79351832348816f), Qfmt15(0.63872359151636f), Qfmt15(0.52890520960295f), Qfmt15(0.74238552914587f),
-    Qfmt15(0.99096131449250f), Qfmt15(-0.80412329643109f), Qfmt15(-0.64612616129736f), Qfmt15(0.11657770663191f),
-    Qfmt15(-0.95053182488101f), Qfmt15(-0.62228872928622f), Qfmt15(0.03004475787316f), Qfmt15(-0.97987214341034f),
-    Qfmt15(-0.99986980746200f), Qfmt15(0.89110648599879f), Qfmt15(0.10407960510582f), Qfmt15(0.95964737821728f),
-    Qfmt15(0.50843233159162f), Qfmt15(0.17006334670615f), Qfmt15(0.25872675063360f), Qfmt15(-0.01115998681937f),
-    Qfmt15(-0.79598702973261f), Qfmt15(-0.99264708948101f), Qfmt15(-0.99829663752818f), Qfmt15(-0.70801016548184f),
-    Qfmt15(-0.70467057786826f), Qfmt15(0.99846021905254f), Qfmt15(-0.63364968534650f), Qfmt15(-0.16258217500792f),
-    Qfmt15(-0.43645594360633f), Qfmt15(-0.99848471702976f), Qfmt15(-0.16796458968998f), Qfmt15(-0.87979225745213f),
-    Qfmt15(0.44183099021786f), Qfmt15(0.93310180125532f), Qfmt15(-0.93941931782002f), Qfmt15(-0.88590003188677f),
-    Qfmt15(0.99971463703691f), Qfmt15(-0.75376385639978f), Qfmt15(0.93887685615875f), Qfmt15(0.85126435782309f),
-    Qfmt15(0.39701421446381f), Qfmt15(-0.37024464187437f), Qfmt15(-0.36024828242896f), Qfmt15(-0.93388812549209f),
-    Qfmt15(-0.65298804552119f), Qfmt15(0.11960319006843f), Qfmt15(0.94292565553160f), Qfmt15(0.75081145286948f),
-    Qfmt15(0.56721979748394f), Qfmt15(0.46857766746029f), Qfmt15(0.97312313923635f), Qfmt15(-0.38299976567017f),
-    Qfmt15(0.41025800019463f), Qfmt15(0.09638062008048f), Qfmt15(-0.85283249275397f), Qfmt15(0.88866808958124f),
-    Qfmt15(-0.48202429536989f), Qfmt15(0.27572582416567f), Qfmt15(-0.65889129659168f), Qfmt15(0.98838086953732f),
-    Qfmt15(-0.20651349620689f), Qfmt15(-0.62126416356920f), Qfmt15(0.20320105410437f), Qfmt15(-0.97790548600584f),
-    Qfmt15(0.11112534735126f), Qfmt15(-0.41368337314182f), Qfmt15(0.24133038992960f), Qfmt15(-0.66393410674885f),
-    Qfmt15(-0.53697829178752f), Qfmt15(-0.97224737889348f), Qfmt15(0.87392477144549f), Qfmt15(0.19050361015753f),
-    Qfmt15(-0.46353441212724f), Qfmt15(-0.07064096339021f), Qfmt15(-0.92444085484466f), Qfmt15(-0.83822593578728f),
-    Qfmt15(0.75214681811150f), Qfmt15(-0.42102998829339f), Qfmt15(-0.72094786237696f), Qfmt15(0.78843311019251f),
-    Qfmt15(0.97394027897442f), Qfmt15(0.99206463477946f), Qfmt15(0.76789609461795f), Qfmt15(-0.82002421836409f),
-    Qfmt15(0.81924990025724f), Qfmt15(-0.26719850873357f), Qfmt15(-0.43311260380975f), Qfmt15(0.99194979673836f),
-    Qfmt15(-0.80692001248487f), Qfmt15(0.43080003649976f), Qfmt15(0.67709491937357f), Qfmt15(0.56151770568316f),
-    Qfmt15(0.10831862810749f), Qfmt15(0.91229417540436f), Qfmt15(-0.48972893932274f), Qfmt15(-0.89033658689697f),
-    Qfmt15(0.65269447475094f), Qfmt15(0.67439478141121f), Qfmt15(-0.47770832416973f), Qfmt15(-0.99715979260878f),
-    Qfmt15(-0.90889593602546f), Qfmt15(-0.06618622548177f), Qfmt15(0.99430266919728f), Qfmt15(0.97686402381843f),
-    Qfmt15(0.94813650221268f), Qfmt15(-0.95434497492853f), Qfmt15(-0.49104783137150f), Qfmt15(0.99881175120751f),
-    Qfmt15(0.50449166760303f), Qfmt15(0.47162891065108f), Qfmt15(-0.62081581361840f), Qfmt15(-0.43867015250812f),
-    Qfmt15(0.98630563232075f), Qfmt15(-0.61510362277374f), Qfmt15(-0.03841517601843f), Qfmt15(-0.30102157304644f),
-    Qfmt15(0.41881284182683f), Qfmt15(-0.86135454941237f), Qfmt15(0.67226861393788f), Qfmt15(-0.70737398842068f),
-    Qfmt15(0.94044946687963f), Qfmt15(-0.82386352534327f), Qfmt15(-0.32070666698656f), Qfmt15(0.57593163224487f),
-    Qfmt15(-0.36326018419965f), Qfmt15(0.99979044674350f), Qfmt15(-0.92366023326932f), Qfmt15(-0.44607178518598f),
-    Qfmt15(0.44226800932956f), Qfmt15(0.03671907158312f), Qfmt15(0.52175424682195f), Qfmt15(-0.94701139690956f),
-    Qfmt15(-0.98759606946049f), Qfmt15(0.87434794743625f), Qfmt15(-0.93412041758744f), Qfmt15(0.96063943315511f),
-    Qfmt15(0.97534253457837f), Qfmt15(0.99642466504163f), Qfmt15(-0.94705089665984f), Qfmt15(0.91599807087376f)
-};
-
-
-#ifdef HQ_SBR
-
-
-const Int32 fir_table[5][5] =
-{
-    { Q30_fmt(1.0f)},
-    { Q30_fmt(0.33333333333333f), Q30_fmt(0.66666666666666f)},
-    { Q30_fmt(0.12500000000000f), Q30_fmt(0.37500000000000f),
-      Q30_fmt(0.50000000000000f)},
-    { Q30_fmt(0.05857864376269f), Q30_fmt(0.20000000000000f),
-      Q30_fmt(0.34142135623731f), Q30_fmt(0.40000000000000f)},
-    { Q30_fmt(0.03183050093751f), Q30_fmt(0.11516383427084f),
-      Q30_fmt(0.21816949906249f), Q30_fmt(0.30150283239582f),
-      Q30_fmt(0.33333333333333f)}
-};
-
-
-
-const Int32 rPxx[512] =
-{
-
-    0x8010B3DB,  0x7C4DA98F, 0x12168648, 0xC3D4D033,
-    0x674D25F5,  0xCE1972A6, 0xFEA5AA4A, 0x8B2DF13E,
-    0x46326048,  0x3336815E, 0x802A8F2B, 0x85B7745C,
-    0xC577B766,  0xA2A5828C, 0x60CB1AD1, 0x090C9BD7,
-    0x5F5A8B4D,  0x848D86BB, 0x26F1C0B7, 0x553352C1,
-    0x755E166B,  0xA5674343, 0xA654C5F5, 0x80A48CB4,
-    0x7DA69CD8,  0xBA04FCB4, 0xFDD4005E, 0x91C63676,
-    0x816A8F82,  0x423F55AA, 0x8077B59E, 0x80097DE9,
-    0x46BD4C18,  0x2C437971, 0x5035A0C2, 0x9D3ED49F,
-    0x8AC204B8,  0x9E5A8B0A, 0x662088B9, 0x45B9F0BC,
-    0x9261364F,  0x891B23AD, 0xF1028040, 0x1B568BE1,
-    0x9E787FB3,  0x7D94854D, 0x92077A94, 0x88903F45,
-    0x2705A5B4,  0x6D2B3BDC, 0x74E58034, 0xF8745A8C,
-    0x24592C54,  0x79EDB9BB, 0x9B6E9F44, 0x8563E5DA,
-    0x697C7BB7,  0xAC8F8E6A, 0x88227FD5, 0x7506822F,
-    0xA5E34B42,  0x00B94F10, 0x72004390, 0xA814676E,
-    0x5C5EA758,  0xAF721171, 0x2652C50C, 0x8A84A142,
-    0x7F19343E,  0x696EA13B, 0x81E68008, 0x853980F9,
-    0xE4968869,  0xA7E7DD92, 0x75910BFA, 0x85092E35,
-    0x421BA4A3,  0x4E3F3C18, 0x3C97DD02, 0x74797BCB,
-    0x39667EFD,  0x55447BA2, 0x5FE68CF3, 0x808B4390,
-    0x7CABEA6B,  0x5D08C27A, 0x7A265820, 0xA29A9DF0,
-    0x92BC7195,  0x97CA8338, 0x8F725FAD, 0xA46281D3,
-    0x6AE86B23,  0xC2728178, 0x7C566684, 0x428C66B7,
-    0xFEE89DDB,  0xA60546DC, 0x8540C89D, 0x7C420BF0,
-    0x89B86D72,  0xA7077E3F, 0x21FF5DD7, 0x23E3129C,
-    0xA1197F1D,  0xFDC0963F, 0xB96F8168, 0x7D6387A6,
-    0x810655C8,  0xA95C102B, 0x0BB3E5B4, 0xA44682D4,
-    0x67B244C3,  0x33FDDE1D, 0xA95D78F5, 0x6F2AE887,
-    0x80A3FC9F,  0x6BF00D52, 0xF4325902, 0x7FF1F02C,
-    0x99F08AC5,  0x7B537BB2, 0x99AB5255, 0xF1302497,
-    0xCCE4787B,  0x7ED58A28, 0x24A68B79, 0x955EA9D0,
-    0x7A1D3EED,  0xF7BD0429, 0x808A3642, 0xAC2769A8,
-    0x97FDBDE9,  0x80736C25, 0x005E52E7, 0x59D3E5D0,
-    0x7B57341A,  0xA7D374E9, 0xD35A5B7B, 0x75BB5520,
-    0x81446DE8,  0x5825473E, 0x80A8E653, 0x78978062,
-    0xA9B43F6B,  0xC366920A, 0x1255877D, 0xDA88075F,
-    0x380E9AFF,  0xD1795309, 0xF4CB7D09, 0x847BBAED,
-    0x471364FA,  0x5E207B74, 0xD87498BF, 0x0493836B,
-    0x7E5C3DF6,  0x976F8BBC, 0x56DE680A, 0xEBC26D28,
-    0x6753E05B,  0x3D2BC4B0, 0x7B593143, 0x8118E010,
-    0x6A5786AD,  0xB4CA01A7, 0x7A49927C, 0x847DAE0C,
-    0x836B0FD8,  0x74FD4A34, 0x80175AFC, 0x90CBE605,
-    0xDE68A89E,  0xE06C8FD0, 0x031822CE, 0x690B9315,
-    0x71568D43,  0xE8BBDE85, 0x0BFA4633, 0xBA057ADA,
-    0x2F6CB34F,  0xA5EB74C5, 0xD3B480B6, 0xA7F7D94A,
-    0xDDA26A63,  0x3ED0C5EF, 0x31E37A42, 0x82DE06CB,
-    0xE9D18940,  0x7FEE4A9A, 0xACDD57DD, 0xF09CB6D9,
-    0xB48BD364,  0xCA7814D5, 0x7FDA0E41, 0xB77C8C2A,
-    0x787E2D29,  0x9F1144AC, 0x1A4B871E, 0x7FF96630,
-    0x25382D4D,  0xAF89319E, 0x379A81DB, 0x822D1AE8,
-    0x18FA875E,  0x85C97DE7, 0x7786A544, 0x92E5F550,
-    0x915FC560,  0x31C47C82, 0x75D0B014, 0x72204656,
-    0xD0D87B76,  0x782E8CD6, 0x7F0FFB2F, 0x879834E7,
-    0x7FAAEA73,  0xD20BC44E, 0x06B4DF2C, 0x2EFBCE84,
-    0x7550D8D7,  0x5851746A, 0xCE837F5C, 0xDA8D2FEE,
-    0xB2F66F13,  0x834D7B7A, 0x713A499C, 0x06A81B39,
-    0xBB847C77,  0xC0B97DAC, 0x815CCC7A, 0x8274A2BD,
-    0xDD007FEF,  0x0814BA2F, 0xE5CDEDCE, 0x54C45CD5,
-    0x937F0309,  0x8E0671BF, 0x7AC1623B, 0x5E15FB32,
-    0xD75CD0D9,  0xD4553378, 0x3D30CD88, 0x7DD2028C,
-    0xD85CE8DB,  0x7FFDDE5A, 0x88C48228, 0x7FE6996A,
-    0xDEAF9EB7,  0xD24818B4, 0x80205F8B, 0x6ECA4728,
-    0x2AC36E51,  0x7EBB05E4, 0xAAA08AB1, 0x51F01408,
-    0x7F723AAE,  0xAECD1AFB, 0xF6218D55, 0x7E3170F2,
-    0x6686D0D3,  0x644F3A3F, 0x0B256799, 0x90E0325D,
-    0xCD7AAA7B,  0x7D47A33C, 0x865972A3, 0x15C445FE,
-    0x9D8D84D3,  0x7FAB36A7, 0x7A287C29, 0x7F75BABD,
-    0x23EA92BC,  0x6D20AD59, 0xBF37ABB6, 0x8391E26E,
-    0x7A2480F8,  0x83EE5E6E, 0x27843523, 0xE09A50E7,
-    0xD4B6CE82,  0xF889F71C, 0xE2AF7C3A, 0xE84D3CE2,
-    0xF2918FA6,  0xA3FB63E0, 0x7FBB7340, 0x49AE8B79,
-    0x25017B45,  0x36003DA1, 0x7777C844, 0x83B96EE4,
-    0x2F015392,  0x98320B3C, 0xDE68893F, 0x6B834779,
-    0x801D8516,  0x5F8C0F8C, 0xA049DD90, 0x7A999AD0,
-    0x7A33F500,  0x3E587FFF, 0x3B4E0E09, 0x9E147230,
-    0x49772D2B,  0x607A7BC7, 0xB4408D8F, 0x601CDA17,
-    0x81C7200B,  0xCBD28CBD, 0x55AB7E3E, 0x833EFFC0,
-    0x73627FB7,  0x904E7F04, 0x8AD7EBE6, 0xFBC3D05F,
-    0x093F8E53,  0x7F5B7C47, 0xA01E7FFA, 0x05DE7FC2,
-    0x8E01D74D,  0x94C17CF9, 0x2AD2919F, 0x805F7757,
-    0xE2C61829,  0x5613FB53, 0xF9688978, 0x7FEE77D6,
-    0x55B27E98,  0x8081C6D6, 0x69177F69, 0x7EF45C30,
-    0xAC6E42CC,  0x782BA021, 0x7BD17457, 0xE38B491E,
-    0xC781895B,  0x924E71B8, 0x757BC4A8, 0x5CDF8020,
-    0x805E4A82,  0x636078BA, 0x09E14B0E, 0xB84069A0,
-    0x7DF23284,  0x3CDC57D2, 0x54101777, 0x0431A015,
-    0xCE7A41B6,  0x8365846A, 0xBBCB8AF9, 0x7FC34E40,
-    0xBFAB8E4B,  0x028E6D15, 0x7FE8790F, 0x6A1EF7E6,
-    0xB4E97BF4,  0xE980C257, 0x6ACBEF53, 0x079C1A41,
-    0x685386CC,  0xC66D3458, 0x8D1F7FCD, 0x32C9A02E,
-    0xF6475ED7,  0x61B7356F, 0xA0A6793F, 0x530B34E9,
-    0x4FC488D4,  0x3609F61F, 0x0376F90F, 0x6666752C,
-    0x9A6DD1A5,  0x51C10A67, 0x43B34CDC, 0x5F0605C0,
-    0x7ED7E718,  0x99118EB3, 0xAD4A5C69, 0x0EEC94E8,
-    0x865483EA,  0xB05769F0, 0x03D88055, 0x82932EC1,
-    0x8003D1E3,  0x720F82B1, 0x0D526304, 0x7AD5D2A3,
-    0x41147B04,  0x15C49D9F, 0x211E7FDC, 0xFE907E12,
-    0x9A1C7C55,  0x80F08095, 0x80370267, 0xA55F2B1C,
-    0xA5CC7763,  0x7FCD81A1, 0xAEE3EAE8, 0xEB2F8532,
-    0xC82186A5,  0x80317B31, 0xEA7E814B, 0x8F62A430,
-    0x388D883A,  0x776F801B, 0x87C0B7CA, 0x8E9A3CF5,
-    0x7FF6949E,  0x9F83010B, 0x782CF18C, 0x6CF54301,
-    0x32D168AD,  0xD09A908B, 0xD1E22C5C, 0x887593DE,
-    0xAC6AE864,  0x0F4F7FDE, 0x78B16A72, 0x601AD283,
-    0x489AE12D,  0x3BFAD96A, 0x7C8E8093, 0xCEF87E19,
-    0x348302B6,  0x0C5605A6, 0x92D57516, 0x71BF8056,
-    0xC24C8416,  0x234B4B0D, 0xABA84B4F, 0x7E827FFD,
-    0xE58F45E1,  0xB079B355, 0x1A0290CA, 0x82D37B40,
-    0x0E391B80,  0xCB0B241E, 0x1EE441A8, 0xAB03F56F,
-    0xBB438301,  0x838C1C43, 0x6FDCEF9D, 0x1862020D,
-    0xC4A98614,  0xF6F38710, 0x89ABF29B, 0x94B4FDD3,
-    0x6046800E,  0xCA1A7FA4, 0xA3B7D32F, 0x64EB43A6,
-    0x7CA9DDD3,  0x7EFBB705, 0x624A9E0D, 0x9708A1E0,
-    0x68DC7F9C,  0xDDCB5832, 0xC88E6D35, 0x7EF77599,
-    0x98B6D63B,  0x3724E3F0, 0x56AA85C9, 0x47DFA582,
-    0x0DDDF4F3,  0x74C5AB88, 0xC14F480C, 0x8E08A446,
-    0x538B545F,  0x56529770, 0xC2D9EA81, 0x805C883B,
-    0x8BA84F67,  0xF785E183, 0x7F441814, 0x7D09DB4D,
-    0x795C8330,  0x85D79A19, 0xC1242A1B, 0x7FD871E9,
-    0x409391EC,  0x3C5EE815, 0xB0885FFF, 0xC7D87FFE,
-    0x7E3EBB6A,  0xB1438D6B, 0xFB13A68A, 0xD976F62D,
-    0x359B02CD,  0x91BE7EA6, 0x560CEEB8, 0xA5739E04,
-    0x78600B8E,  0x968A0B6C, 0xD6F1402E, 0x49B88152,
-    0xD17F0986,  0x7FF8EDE8, 0x89C48295, 0xC6E6BA93,
-    0x389C5B4C,  0x04B3516A, 0x42C892B0, 0x86C7FDA8,
-    0x81956954,  0x6FEA726E, 0x886E34F5, 0x7AF57730,
-    0x7CD76E45,  0x7F8A59D7, 0x86C6DA22, 0x753F825E
-};
-
-
-#endif
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h b/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h
deleted file mode 100644
index 60e806d..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_calc_tbl.h
+++ /dev/null
@@ -1,96 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_calc_tbl.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ENVELOPE_CALC_TBL_H
-#define SBR_ENVELOPE_CALC_TBL_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-extern const Int32 limGains[5];
-
-extern const Int32 smoothLengths[2];
-
-extern const Int16 rP_LCx[512];
-
-#ifdef HQ_SBR
-
-
-extern const Int32 fir_table[5][5];
-
-extern const Int32 rPxx[512];
-
-#endif
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp b/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp
deleted file mode 100644
index 7fce46b..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.cpp
+++ /dev/null
@@ -1,427 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_unmapping.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_envelope_unmapping.h"
-#include    "sbr_constants.h"
-
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-#define R_SHIFT     30
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-/*
- *  1./(1+2.^-[0:10])
- */
-const Int32 one_over_one_plus_two_to_n[11] =
-{
-    Qfmt(0.50000000000000F), Qfmt(0.66666666666667F), Qfmt(0.80000000000000F),
-    Qfmt(0.88888888888889F), Qfmt(0.94117647058824F), Qfmt(0.96969696969697F),
-    Qfmt(0.98461538461538F), Qfmt(0.99224806201550F), Qfmt(0.99610894941634F),
-    Qfmt(0.99805068226121F), Qfmt(0.99902439024390F)
-};
-
-/*
- *  1./(1+2.^[0.5:-1:-10.5])
- */
-const Int32 one_over_one_plus_sq_2_by_two_to_n[12] =
-{
-    Qfmt(0.41421356237310F), Qfmt(0.58578643762690F), Qfmt(0.73879612503626F),
-    Qfmt(0.84977889517767F), Qfmt(0.91878969685839F), Qfmt(0.95767628767521F),
-    Qfmt(0.97838063800882F), Qfmt(0.98907219289563F), Qfmt(0.99450607818892F),
-    Qfmt(0.99724547251514F), Qfmt(0.99862083678608F), Qfmt(0.99930994254211F)
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1,
-                            SBR_FRAME_DATA * hFrameData2)
-
-{
-    Int32 i;
-    Int32 tempLeft;
-    Int32 tempRight;
-
-    Int32 tmp;
-    Int32 *iEnvelopeLeft_man    = hFrameData1->iEnvelope_man;
-    Int32 *iEnvelopeLeft_exp    = hFrameData1->iEnvelope_exp;
-    Int32 *noiseFloorLeft_man   = hFrameData1->sbrNoiseFloorLevel_man;
-    Int32 *noiseFloorLeft_exp   = hFrameData1->sbrNoiseFloorLevel_exp;
-
-    Int32 *iEnvelopeRight_man   = hFrameData2->iEnvelope_man;
-    Int32 *iEnvelopeRight_exp   = hFrameData2->iEnvelope_exp;
-    Int32 *noiseFloorRight_man  = hFrameData2->sbrNoiseFloorLevel_man;
-    Int32 *noiseFloorRight_exp  = hFrameData2->sbrNoiseFloorLevel_exp;
-
-
-    if (hFrameData2->ampRes)
-    {
-        for (i = 0; i < hFrameData1->nScaleFactors; i++)
-        {
-            tempRight = iEnvelopeRight_man[i];
-            tempLeft  = iEnvelopeLeft_man[i];
-            /*  iEnvelope[i] always positive  6 bits max */
-
-            iEnvelopeLeft_exp[i] = tempLeft + 7;
-
-            iEnvelopeRight_exp[i] = tempRight - 12;
-            iEnvelopeRight_man[i] = Qfmt(1.000F);
-
-            /*
-             *  iEnvelopeRight[i] = tempLeft / (1 + tempRight);
-             *  iEnvelopeLeft[i]  = tempRight * iEnvelopeRight[i];
-             *
-             *
-             *   iEnvelopeRight[i] = k*2^n/(1+2^m) =  k*2^(n-m)/(1 + 2^-m);
-             *   where k = 1 or sqrt(2)
-             */
-            if (iEnvelopeRight_exp[i] >= 0)
-            {
-                if (iEnvelopeRight_exp[i] < 11)
-                {
-                    iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]];
-                }
-                else        /*  1/(1+2^-m) == 1 - 2^-m ;  for m >= 10  */
-                {
-                    iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
-                }
-                iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-            }
-            else
-            {
-                if (iEnvelopeRight_exp[i] > -11)
-                {
-                    iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]];
-                    iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
-                }
-                else        /*  1/(1+2^m) == 2^-m ;  for m >= 10  */
-                {
-                    iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i];
-                    iEnvelopeLeft_exp[i] = 0;
-                }
-            }
-
-            iEnvelopeLeft_man[i]  = iEnvelopeRight_man[i];
-        }
-    }
-    else
-    {
-        for (i = 0; i < hFrameData1->nScaleFactors; i++)
-        {
-            /*  iEnvelope[i] always positive  7 bits max */
-            tempRight = iEnvelopeRight_man[i];
-            tempLeft  = iEnvelopeLeft_man[i];
-
-            iEnvelopeLeft_exp[i] = (tempLeft >> 1) + 7;
-            if (tempLeft & 0x1)   /*  odd */
-            {
-                iEnvelopeLeft_man[i] = Qfmt(1.41421356237310F);
-            }
-            else
-            {
-                iEnvelopeLeft_man[i] = Qfmt(1.000F);
-            }
-
-            iEnvelopeRight_exp[i] = (tempRight >> 1) - 12;
-            if (tempRight & 0x1)   /*  odd */
-            {
-                if (iEnvelopeRight_exp[i] > 0)
-                {
-                    iEnvelopeRight_man[i] = Qfmt(1.41421356237310F);
-                }
-                else
-                {
-                    iEnvelopeRight_man[i] = Qfmt(0.7071067811865F);
-                }
-            }
-            else
-            {
-                iEnvelopeRight_man[i] = Qfmt(1.000F);
-            }
-
-            if (iEnvelopeRight_man[i] == Qfmt(1.000F))
-            {
-
-                /*
-                 *  iEnvelopeRight[i] = tempLeft / (1 + tempRight);
-                 *  iEnvelopeLeft[i]  = tempRight * iEnvelopeRight[i];
-                 *
-                 *
-                 *   iEnvelopeRight[i] = k*2^n/(1+2^m) =  k*2^(n-m)/(1 + 2^-m);
-                 *   where k = 1 or sqrt(2)
-                 */
-                if (iEnvelopeRight_exp[i] >= 0)
-                {
-                    if (iEnvelopeRight_exp[i] < 11)
-                    {
-                        iEnvelopeRight_man[i] = one_over_one_plus_two_to_n[ iEnvelopeRight_exp[i]];
-                    }
-                    else        /*  1/(1+2^-m) == 1 - 2^-m ;  for m >= 10  */
-                    {
-                        iEnvelopeRight_man[i] -= (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
-                    }
-                    iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
-                }
-                else
-                {
-                    if (iEnvelopeRight_exp[i] > -11)
-                    {
-                        iEnvelopeRight_man[i] -= one_over_one_plus_two_to_n[ -iEnvelopeRight_exp[i]];
-                        iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-                    }
-                    else        /*  1/(1+2^m) == 2^-m ;  for m >= 10  */
-                    {
-                        iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i];
-                        iEnvelopeLeft_exp[i]  = 0;
-                    }
-                }
-
-                /*
-                 *  apply "k" factor 1 or sqrt(2)
-                 *
-                 *   (2^m)*2*k*2^n/(1+2^m) =  k*2^(n+1)/(1 + 2^-m);
-                 *
-                 */
-                if (iEnvelopeLeft_man[i] != Qfmt(1.000F))
-                {
-                    iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]);
-                }
-
-                iEnvelopeLeft_man[i]  = iEnvelopeRight_man[i];
-
-            }
-            else
-            {
-
-                /*
-                *  iEnvelopeRight[i] = tempLeft / (1 + tempRight);
-                *  iEnvelopeLeft[i]  = tempRight * iEnvelopeRight[i];
-                *
-                *
-                *   iEnvelopeRight[i] = k*2^n/(1+q2^m) =  k*2^(n-m)/(1 + q2^-m);
-                *   where k = 1 or sqrt(2)
-                *   and q = sqrt(2)
-                    */
-                if (iEnvelopeRight_exp[i] >= 0)
-                {
-                    if (iEnvelopeRight_exp[i] < 12)
-                    {
-                        iEnvelopeRight_man[i] = one_over_one_plus_sq_2_by_two_to_n[ iEnvelopeRight_exp[i]];
-                    }
-                    else        /*  1/(1+2^-m) == 1 - 2^-m ;  for m >= 11  */
-                    {
-                        iEnvelopeRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> iEnvelopeRight_exp[i]);
-                    }
-                }
-                else
-                {
-                    if (iEnvelopeRight_exp[i] > -12)
-                    {
-                        iEnvelopeRight_man[i] = Qfmt(1.000F) - one_over_one_plus_sq_2_by_two_to_n[ -iEnvelopeRight_exp[i]];
-                    }
-                    else        /*  1/(1+2^m) == 2^-m ;  for m >= 11  */
-                    {
-                        iEnvelopeRight_man[i] = Qfmt(1.000F);
-                        iEnvelopeRight_exp[i] = 0;
-                    }
-                }
-
-                iEnvelopeRight_exp[i] = iEnvelopeLeft_exp[i] - iEnvelopeRight_exp[i];
-
-                /*
-                *  apply "k" factor 1 or sqrt(2)
-                *
-                *   Right ==    k*2^(n-m)/(1 + q2^-m)
-                *   Left  == (q2^m)*k*2^n/(1 + q2^m) =  qk*2^n/(1 + q2^-m);
-                */
-                if (iEnvelopeLeft_man[i] != Qfmt(1.000F))
-                {
-                    /*
-                    *   k/(1 + q2^-m);
-                        */
-                    tmp = iEnvelopeRight_man[i];
-                    iEnvelopeRight_man[i] = fxp_mul32_Q30(iEnvelopeLeft_man[i], iEnvelopeRight_man[i]);
-                    iEnvelopeLeft_man[i] = tmp;
-                    iEnvelopeLeft_exp[i] += 1;      /* extra one due to sqrt(2)^2 */
-                }
-                else
-                {
-                    iEnvelopeLeft_man[i]  = fxp_mul32_Q30(iEnvelopeRight_man[i], Qfmt(1.41421356237310F));
-                }
-
-            }       /*  end of     if (iEnvelopeRight_man[i] == Qfmt( 1.000F) )  */
-        }      /* end of for loop */
-    }     /*  end  if (hFrameData2->ampRes) */
-
-
-    for (i = 0; i < hFrameData1->nNoiseFactors; i++)
-    {
-
-        noiseFloorLeft_exp[i]  = NOISE_FLOOR_OFFSET_PLUS_1 - noiseFloorLeft_man[i];
-        noiseFloorRight_exp[i] = noiseFloorRight_man[i] - SBR_ENERGY_PAN_OFFSET_INT;
-
-
-        /*
-         *  noiseFloorRight[i] = tempLeft / (1.0f + tempRight);
-         *  noiseFloorLeft[i]  = tempRight*noiseFloorRight[i];
-         *
-         *
-         *   noiseFloorRight[i] = 2^n/(1+2^m) =  2^(n-m)/(1 + 2^-m);
-         */
-        if (noiseFloorRight_exp[i] >= 0)
-        {
-            if (noiseFloorRight_exp[i] < 11)
-            {
-                noiseFloorRight_man[i] = one_over_one_plus_two_to_n[ noiseFloorRight_exp[i]];
-            }
-            else        /*  1/(1+2^-m) == 1 - 2^-m ;  for m >= 10  */
-            {
-                noiseFloorRight_man[i] = Qfmt(1.000F) - (Qfmt(1.000F) >> noiseFloorRight_exp[i]);
-            }
-        }
-        else
-        {
-            if (noiseFloorRight_exp[i] > -11)
-            {
-                noiseFloorRight_man[i] = Qfmt(1.000F) - one_over_one_plus_two_to_n[ -noiseFloorRight_exp[i]];
-            }
-            else        /*  1/(1+2^m) == 2^-m ;  for m >= 10  */
-            {
-                noiseFloorRight_man[i] = Qfmt(1.000F);
-                noiseFloorRight_exp[i] = 0;
-            }
-        }
-
-        noiseFloorRight_exp[i] = noiseFloorLeft_exp[i] - noiseFloorRight_exp[i];
-
-        /*
-         *   (2^m)*2^n/(1+2^m) =  2^n/(1 + 2^-m);
-         */
-
-        noiseFloorLeft_man[i] = noiseFloorRight_man[i];
-        noiseFloorLeft_exp[i] = noiseFloorLeft_exp[i];
-
-    }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h b/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h
deleted file mode 100644
index b949830..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_envelope_unmapping.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_envelope_unmapping.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_ENVELOPE_UNMAPPING_H
-#define SBR_ENVELOPE_UNMAPPING_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-#define UNMAPPING_SCALE_INT         (-18)           /*  factor's 2-exponent */
-#define SBR_ENERGY_PAN_OFFSET_INT   12
-
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_envelope_unmapping(SBR_FRAME_DATA * hFrameData1,
-                            SBR_FRAME_DATA * hFrameData2);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp b/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp
deleted file mode 100644
index 92b22f7..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.cpp
+++ /dev/null
@@ -1,223 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_extract_extended_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    SBR_FRAME_DATA *hFrameData,     Destination for extracted data of left channel
-    SBR_FRAME_DATA *hFrameDataRight Destination for extracted data of right channel
-    BIT_BUFFER hBitBuf              pointer to bit buffer
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Reads extension data from the bitstream
-
-  The bitstream format allows up to 4 kinds of extended data element.
-  Extended data may contain several elements, each identified by a 2-bit-ID.
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_extract_extended_data.h"
-#include    "buf_getbits.h"
-
-#ifdef PARAMETRICSTEREO
-#include    "ps_read_data.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_extract_extended_data(BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO         /* Parametric Stereo Decoder */
-                               , HANDLE_PS_DEC hParametricStereoDec
-#endif
-                              )
-{
-    Int32 extended_data;
-    Int32 i;
-    Int32 nBitsLeft;
-    Int32 extension_id;
-
-    extended_data = buf_get_1bit(hBitBuf);    /*  SI_SBR_EXTENDED_DATA_BITS  */
-
-    if (extended_data)
-    {
-        Int32 cnt;
-
-        cnt = buf_getbits(hBitBuf, SI_SBR_EXTENSION_SIZE_BITS);
-        if (cnt == (1 << SI_SBR_EXTENSION_SIZE_BITS) - 1)
-        {
-            cnt += buf_getbits(hBitBuf, SI_SBR_EXTENSION_ESC_COUNT_BITS);
-        }
-
-        nBitsLeft = (cnt << 3);
-        while (nBitsLeft > 7)
-        {
-            extension_id = buf_getbits(hBitBuf, SI_SBR_EXTENSION_ID_BITS);
-            nBitsLeft -= SI_SBR_EXTENSION_ID_BITS;
-
-            switch (extension_id)
-            {
-#ifdef HQ_SBR
-#ifdef PARAMETRICSTEREO
-
-                    /*
-                     *  Parametric Coding supports the Transient, Sinusoidal, Noise, and
-                     *  Parametric Stereo tools (MPEG4).
-                     *  3GPP use aac+ hq along with ps for enhanced aac+
-                     *  The PS tool uses complex-value QMF data, therefore can not be used
-                     *  with low power version of aac+
-                     */
-                case EXTENSION_ID_PS_CODING:
-
-                    if (hParametricStereoDec != NULL)
-                    {
-                        if (!hParametricStereoDec->psDetected)
-                        {
-                            /* parametric stereo detected */
-                            hParametricStereoDec->psDetected = 1;
-                        }
-
-                        nBitsLeft -= ps_read_data(hParametricStereoDec,
-                                                  hBitBuf,
-                                                  nBitsLeft);
-
-                    }
-
-                    break;
-#endif
-#endif
-                case 0:
-
-                default:
-                    /*   An unknown extension id causes the remaining extension data
-                     *   to be skipped
-                     */
-                    cnt = nBitsLeft >> 3; /* number of remaining bytes */
-
-                    for (i = 0; i < cnt; i++)
-                    {
-                        buf_getbits(hBitBuf, 8);
-                    }
-
-                    nBitsLeft -= (cnt << 3);
-            }
-        }
-        /* read fill bits for byte alignment */
-        buf_getbits(hBitBuf, nBitsLeft);
-    }
-}
-
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h b/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h
deleted file mode 100644
index bbca3b9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_extract_extended_data.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_extract_extended_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_EXTRACT_EXTENDED_DATA_H
-#define SBR_EXTRACT_EXTENDED_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-
-#ifdef PARAMETRICSTEREO
-#include    "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_extract_extended_data(BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO         /* Parametric Stereo Decoder */
-                               , HANDLE_PS_DEC hParametricStereoDec
-#endif
-                              );
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp b/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp
deleted file mode 100644
index fc3d38f..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.cpp
+++ /dev/null
@@ -1,198 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_find_start_andstop_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_find_start_andstop_band.h"
-#include    "get_sbr_startfreq.h"
-#include    "get_sbr_stopfreq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq,
-                                      const Int32 startFreq,
-                                      const Int32 stopFreq,
-                                      Int   *lsbM,
-                                      Int   *usb)
-{
-    /* Update startFreq struct */
-    *lsbM = get_sbr_startfreq(samplingFreq, startFreq);
-
-    if (*lsbM == 0)
-    {
-        return(SBRDEC_ILLEGAL_SCFACTORS);
-    }
-
-    /*Update stopFreq struct */
-    if (stopFreq < 13)
-    {
-        *usb = get_sbr_stopfreq(samplingFreq, stopFreq);
-    }
-    else if (stopFreq == 13)
-    {
-        *usb = 64;
-    }
-    else if (stopFreq == 14)
-    {
-        *usb = (*lsbM) << 1;
-    }
-    else
-    {
-        *usb = 3 * *lsbM;
-    }
-
-    /* limit to Nyqvist */
-    if (*usb > 64)
-    {
-        *usb = 64;
-    }
-
-    /* test for invalid lsb, usb combinations */
-    if ((*usb - *lsbM) > 48)
-    {
-        /*
-         *  invalid SBR bitstream ?
-         */
-        return(SBRDEC_INVALID_BITSTREAM);
-    }
-
-    if ((samplingFreq == 44100) && ((*usb - *lsbM) > 35))
-    {
-        /*
-         *  invalid SBR bitstream ?
-         */
-        return(SBRDEC_INVALID_BITSTREAM);
-    }
-
-    if ((samplingFreq >= 48000) && ((*usb - *lsbM) > 32))
-    {
-        /*
-         *  invalid SBR bitstream ?
-         */
-        return(SBRDEC_INVALID_BITSTREAM);
-    }
-
-    return(SBRDEC_OK);
-
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h b/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h
deleted file mode 100644
index 88283c6..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_find_start_andstop_band.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
- Filename: sbr_find_start_andstop_band.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_FIND_START_ANDSTOP_BAND_H
-#define SBR_FIND_START_ANDSTOP_BAND_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_find_start_andstop_band(const Int32 samplingFreq,
-                                      const Int32 startFreq,
-                                      const Int32 stopFreq,
-                                      Int *lsbM,
-                                      Int *usb);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp b/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp
deleted file mode 100644
index 2126e47..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.cpp
+++ /dev/null
@@ -1,1040 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_generate_high_freq.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    HF generator with built-in QMF bank inverse filtering function
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-
-
-#include    "sbr_generate_high_freq.h"
-#include    "calc_auto_corr.h"
-#include    "sbr_inv_filt_levelemphasis.h"
-#include    "pv_div.h"
-#include    "fxp_mul32.h"
-#include    "aac_mem_funcs.h"
-#include    "sbr_constants.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void high_freq_coeff_LC(Int32 sourceBufferReal[][32],
-    Int32 *alphar[2],
-    Int32 *degreeAlias,
-    Int32 *v_k_master,
-    Int32 *scratch_mem);
-
-
-    void high_freq_generation_LC(Int32 sourceBufferReal[][32],
-                                 Int32 *targetBufferReal,
-                                 Int32 *alphar[2],
-                                 Int32 *degreeAlias,
-                                 Int32 *invFiltBandTable,
-                                 Int32 targetStopBand,
-                                 Int32 patchDistance,
-                                 Int32 numBandsInPatch,
-                                 Int32 startSample,
-                                 Int32 slopeLength,
-                                 Int32 stopSample,
-                                 Int32 *BwVector,
-                                 Int32 sbrStartFreqOffset);
-
-
-#ifdef HQ_SBR
-
-    void high_freq_coeff(Int32 sourceBufferReal[][32],
-                         Int32 sourceBufferImag[][32],
-                         Int32 *alphar[2],
-                         Int32 *alphai[2],
-                         Int32 *v_k_master);
-
-    void high_freq_generation(Int32 sourceBufferReal[][32],
-                              Int32 sourceBufferImag[][32],
-                              Int32 *targetBufferReal,
-                              Int32 *targetBufferImag,
-                              Int32 *alphar[2],
-                              Int32 *alphai[2],
-                              Int32 *invFiltBandTable,
-                              Int32 targetStopBand,
-                              Int32 patchDistance,
-                              Int32 numBandsInPatch,
-                              Int32 startSample,
-                              Int32 slopeLength,
-                              Int32 stopSample,
-                              Int32 *BwVector,
-                              Int32 sbrStartFreqOffset);
-
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_generate_high_freq(Int32 sourceBufferReal[][32],
-                            Int32 sourceBufferImag[][32],
-                            Int32 *targetBufferReal,
-                            Int32 *targetBufferImag,
-                            INVF_MODE *invFiltMode,
-                            INVF_MODE *prevInvFiltMode,
-                            Int32 *invFiltBandTable,
-                            Int32 noInvFiltBands,
-                            Int32 highBandStartSb,
-                            Int32  *v_k_master,
-                            Int32 numMaster,
-                            Int32 fs,
-                            Int32   *frameInfo,
-                            Int32 *degreeAlias,
-                            Int32  scratch_mem[][64],
-                            Int32  BwVector[MAX_NUM_PATCHES],
-                            Int32  BwVectorOld[MAX_NUM_PATCHES],
-                            struct PATCH *Patch,
-                            Int32 LC_flag,
-                            Int32 *highBandStopSb)
-{
-    Int32    i;
-    Int32    patch;
-    Int32    startSample;
-    Int32    stopSample;
-    Int32    goalSb;
-    Int32    targetStopBand;
-    Int32    sourceStartBand;
-    Int32    patchDistance;
-    Int32    numBandsInPatch;
-    Int32    sbrStartFreqOffset;
-
-    Int32  *alphar[2];
-    Int32  *alphai[2];
-
-    Int32    lsb = v_k_master[0];                           /* Lowest subband related to the synthesis filterbank */
-    Int32    usb = v_k_master[numMaster];                   /* Stop subband related to the synthesis filterbank */
-    Int32  xoverOffset = highBandStartSb - v_k_master[0]; /* Calculate distance in subbands between k0 and kx */
-
-
-
-    Int    slopeLength = 0;
-
-    Int32 firstSlotOffs = frameInfo[1];
-    Int32 lastSlotOffs  = frameInfo[frameInfo[0] + 1] - 16;
-
-
-    alphar[0] = scratch_mem[0];
-    alphar[1] = scratch_mem[1];
-    alphai[0] = scratch_mem[2];
-    alphai[1] = scratch_mem[3];
-
-
-    startSample = (firstSlotOffs << 1);
-    stopSample  = (lastSlotOffs << 1) + 32;
-
-
-    sbr_inv_filt_levelemphasis(invFiltMode,
-                               prevInvFiltMode,
-                               noInvFiltBands,
-                               BwVector,
-                               BwVectorOld);
-
-
-    if (LC_flag == ON)
-    {
-        /* Set subbands to zero  */
-
-        pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS],
-                  0,
-                  (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0]));
-
-        high_freq_coeff_LC(sourceBufferReal,
-                           alphar,
-                           degreeAlias,
-                           v_k_master,
-                           scratch_mem[4]);
-    }
-#ifdef HQ_SBR
-    else
-    {
-        /* Set subbands to zero  */
-
-        pv_memset((void *)&targetBufferReal[startSample*SBR_NUM_BANDS],
-                  0,
-                  (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferReal[0]));
-        pv_memset((void *)&targetBufferImag[startSample*SBR_NUM_BANDS],
-                  0,
-                  (stopSample - startSample)*SBR_NUM_BANDS*sizeof(targetBufferImag[0]));
-
-        high_freq_coeff(sourceBufferReal,
-                        sourceBufferImag,
-                        alphar,
-                        alphai,
-                        v_k_master);
-
-    }
-#endif     /*  #ifdef HQ_SBR */
-
-
-
-
-    /*
-     * Initialize the patching parameter
-     */
-    switch (fs)
-
-    {
-            /*
-             *  goalSb = (int)( 2.048e6f / fs + 0.5f );
-             */
-        case 48000:
-            goalSb = 43;  /* 16 kHz band */
-            break;
-        case 32000:
-            goalSb = 64;  /* 16 kHz band */
-            break;
-        case 24000:
-            goalSb = 85;  /* 16 kHz band */
-            break;
-        case 22050:
-            goalSb = 93;  /* 16 kHz band */
-            break;
-        case 16000:
-            goalSb = 128;  /* 16 kHz band */
-            break;
-        case 44100:
-        default:
-            goalSb = 46;  /* 16 kHz band */
-            break;
-    }
-
-    i = 0;
-
-    if (goalSb > v_k_master[0])
-    {
-        if (goalSb < v_k_master[numMaster])
-        {
-            while (v_k_master[i] < goalSb)
-            {
-                i++;
-            }
-        }
-        else
-        {
-            i = numMaster;
-        }
-    }
-
-    goalSb =  v_k_master[i];
-
-    /* First patch */
-    sourceStartBand = xoverOffset + 1;
-    targetStopBand = lsb + xoverOffset;
-
-    /* even (odd) numbered channel must be patched to even (odd) numbered channel */
-    patch = 0;
-
-
-    sbrStartFreqOffset = targetStopBand;
-
-    while (targetStopBand < usb)
-    {
-        Patch->targetStartBand[patch] = targetStopBand;
-
-        numBandsInPatch = goalSb - targetStopBand;                   /* get the desired range of the patch */
-
-        if (numBandsInPatch >= lsb - sourceStartBand)
-        {
-            /* desired number bands are not available -> patch whole source range */
-            patchDistance   = targetStopBand - sourceStartBand;        /* get the targetOffset */
-            patchDistance   = patchDistance & ~1;                      /* rounding off odd numbers and make all even */
-            numBandsInPatch = lsb - (targetStopBand - patchDistance);
-
-            if (targetStopBand + numBandsInPatch > v_k_master[0])
-            {
-                i = numMaster;
-                if (targetStopBand + numBandsInPatch < v_k_master[numMaster])
-                {
-                    while (v_k_master[i] > targetStopBand + numBandsInPatch)
-                    {
-                        i--;
-                    }
-                }
-            }
-            else
-            {
-                i = 0;
-            }
-            numBandsInPatch =  v_k_master[i] - targetStopBand;
-        }
-
-        /* desired number bands are available -> get the minimal even patching distance */
-        patchDistance   = numBandsInPatch + targetStopBand - lsb;  /* get minimal distance */
-        patchDistance   = (patchDistance + 1) & ~1;                /* rounding up odd numbers and make all even */
-
-        /* All patches but first */
-        sourceStartBand = 1;
-
-        /* Check if we are close to goalSb */
-        if (goalSb - (targetStopBand + numBandsInPatch) < 3)
-        { /* MPEG doc */
-            goalSb = usb;
-        }
-
-
-        if ((numBandsInPatch < 3) && (patch > 0))
-        {
-            if (LC_flag == ON)
-            {
-
-                pv_memset((void *) &degreeAlias[targetStopBand], 0, numBandsInPatch*sizeof(*degreeAlias));
-            }
-            break;
-        }
-
-        if (numBandsInPatch <= 0)
-        {
-            continue;
-        }
-
-
-        /*
-         *  High Frequency generation
-         */
-
-        if (LC_flag == ON)
-        {
-
-            high_freq_generation_LC(sourceBufferReal,
-                                    (Int32 *)targetBufferReal,
-                                    alphar,
-                                    degreeAlias,
-                                    invFiltBandTable,
-                                    targetStopBand,
-                                    patchDistance,
-                                    numBandsInPatch,
-                                    startSample,
-                                    slopeLength,
-                                    stopSample,
-                                    BwVector,
-                                    sbrStartFreqOffset);
-
-        }
-#ifdef HQ_SBR
-        else
-        {
-
-            high_freq_generation(sourceBufferReal,
-                                 sourceBufferImag,
-                                 (Int32 *)targetBufferReal,
-                                 (Int32 *)targetBufferImag,
-                                 alphar,
-                                 alphai,
-                                 invFiltBandTable,
-                                 targetStopBand,
-                                 patchDistance,
-                                 numBandsInPatch,
-                                 startSample,
-                                 slopeLength,
-                                 stopSample,
-                                 BwVector,
-                                 sbrStartFreqOffset);
-
-        }
-#endif
-
-        targetStopBand += numBandsInPatch;
-
-        patch++;
-
-    }  /* targetStopBand */
-
-    Patch->noOfPatches = patch;
-
-    pv_memmove(BwVectorOld, BwVector, noInvFiltBands*sizeof(BwVector[0]));
-
-    *highBandStopSb = goalSb;
-
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void high_freq_coeff_LC(Int32 sourceBufferReal[][32],
-                        Int32 *alphar[2],
-                        Int32 *degreeAlias,
-                        Int32 *v_k_master,
-                        Int32 *scratch_mem)
-{
-
-    Int32  fac;
-    Int32 *k1;
-    struct ACORR_COEFS ac;
-    struct intg_div  quotient;
-
-    Int32 temp1;
-    Int32 temp2;
-    Int32 temp3;
-    Int32 autoCorrLength;
-    Int32 loBand;
-
-    k1 = scratch_mem;
-
-
-    autoCorrLength = 38;
-
-    for (loBand = 1; loBand < v_k_master[0]; loBand++)
-    {
-
-        calc_auto_corr_LC(&ac,
-                          sourceBufferReal,
-                          loBand,
-                          autoCorrLength);
-
-        if (ac.r11r && ac.det)
-        {
-
-            pv_div(ac.r01r, ac.r11r, &quotient);
-
-            fac = -(quotient.quotient >> 2);   /*  Q28 */
-
-            if (quotient.shift_factor > 0)
-            {
-                fac >>= quotient.shift_factor;    /* Q28 */
-            }
-            else if (quotient.shift_factor < 0)
-            {
-                if (quotient.shift_factor > -4)     /* |fac| < 8 */
-                {
-                    fac <<= (-quotient.shift_factor); /* Q28 */
-                }
-                else
-                {
-                    fac = 0x80000000;     /* overshoot possible fac = -8 */
-                }
-            }
-
-            /*
-             *  prevent for overflow of reflection coefficients
-             */
-            if (quotient.shift_factor > 0)
-            {
-                k1[loBand] = - quotient.quotient >> quotient.shift_factor;
-            }
-            else if (quotient.shift_factor == 0)
-            {
-                if (quotient.quotient >= 0x40000000)
-                {
-                    k1[loBand] = (Int32)0xC0000000;   /* -1.0 in Q30  */
-                }
-                else if (quotient.quotient <= (Int32)0xC0000000)
-                {
-                    k1[loBand] = 0x40000000;   /*  1.0 in Q30  */
-                }
-                else
-                {
-                    k1[loBand] = -quotient.quotient;
-                }
-            }
-            else
-            {
-                if (quotient.quotient > 0)
-                {
-                    k1[loBand] = (Int32)0xC0000000;   /* -1.0 in Q30  */
-                }
-                else
-                {
-                    k1[loBand] = 0x40000000;   /*  1.0 in Q30  */
-                }
-            }
-            /*
-             *   alphar[1][loBand] = ( ac.r01r * ac.r12r - ac.r02r * ac.r11r ) / ac.det;
-             */
-
-            temp1  = -fxp_mul32_Q30(ac.r02r, ac.r11r);
-            temp1  =  fxp_mac32_Q30(ac.r01r, ac.r12r, temp1);
-
-            temp2 = ac.det;
-            temp3 = temp1 > 0 ? temp1 : -temp1;
-            temp2 = temp2 > 0 ? temp2 : -temp2;
-
-            /* prevent for shootovers */
-            if ((temp3 >> 2) >= temp2 || fac == (Int32)0x80000000)
-            {
-                alphar[0][loBand] = 0;
-                alphar[1][loBand] = 0;
-            }
-            else
-            {
-                pv_div(temp1, ac.det, &quotient);
-                /*
-                 *  alphar[1][loBand] is lesser than 4.0
-                 */
-                alphar[1][loBand] = quotient.quotient;
-                quotient.shift_factor += 2;             /* Q28 */
-
-                if (quotient.shift_factor > 0)
-                {
-                    alphar[1][loBand] >>= quotient.shift_factor;    /* Q28 */
-                }
-                else if (quotient.shift_factor < 0)     /* at this point can only be -1 */
-                {
-                    alphar[1][loBand] <<= (-quotient.shift_factor); /* Q28 */
-                }
-
-                /*
-                 *  alphar[0][loBand] = - ( ac.r01r + alphar[1][loBand] * ac.r12r ) / ac.r11r;
-                 */
-
-                pv_div(ac.r12r, ac.r11r, &quotient);
-
-                temp3 = (quotient.quotient >> 2);       /*  Q28 */
-
-                if (quotient.shift_factor > 0)
-                {
-                    temp3 >>= quotient.shift_factor;    /* Q28 */
-                }
-                else if (quotient.shift_factor < 0)
-                {
-                    temp3 <<= (-quotient.shift_factor); /* Q28 */
-                }
-
-                alphar[0][loBand] = fac - fxp_mul32_Q28(alphar[1][loBand], temp3) ;    /* Q28 */
-
-                if ((alphar[0][loBand] >= 0x40000000) || (alphar[0][loBand] <= (Int32)0xC0000000))
-                {
-                    alphar[0][loBand] = 0;
-                    alphar[1][loBand] = 0;
-                }
-
-            }
-
-        }
-        else
-        {
-            alphar[0][loBand] = 0;
-            alphar[1][loBand] = 0;
-
-            k1[loBand] = 0;
-        }
-
-    }
-
-    k1[0] = 0;
-    degreeAlias[1] = 0;
-    for (loBand = 2; loBand < v_k_master[0]; loBand++)
-    {
-        degreeAlias[loBand] = 0;
-        if ((!(loBand & 1)) && (k1[loBand] < 0))
-        {
-            if (k1[loBand-1] < 0)
-            { // 2-CH Aliasing Detection
-                degreeAlias[loBand]   = 0x40000000;
-                if (k1[loBand-2] > 0)
-                { // 3-CH Aliasing Detection
-                    degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
-
-                }
-            }
-            else if (k1[loBand-2] > 0)
-            { // 3-CH Aliasing Detection
-                degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
-            }
-        }
-        if ((loBand & 1) && (k1[loBand] > 0))
-        {
-            if (k1[loBand-1] > 0)
-            { // 2-CH Aliasing Detection
-                degreeAlias[loBand]   = 0x40000000;
-                if (k1[loBand-2] < 0)
-                { // 3-CH Aliasing Detection
-                    degreeAlias[loBand-1] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
-                }
-            }
-            else if (k1[loBand-2] < 0)
-            { // 3-CH Aliasing Detection
-                degreeAlias[loBand] = 0x40000000 - fxp_mul32_Q30(k1[loBand-1], k1[loBand-1]);
-            }
-        }
-    }
-
-}
-
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void high_freq_generation_LC(Int32 sourceBufferReal[][32],
-                             Int32 *targetBufferReal,
-                             Int32 *alphar[2],
-                             Int32 *degreeAlias,
-                             Int32 *invFiltBandTable,
-                             Int32 targetStopBand,
-                             Int32 patchDistance,
-                             Int32 numBandsInPatch,
-                             Int32 startSample,
-                             Int32 slopeLength,
-                             Int32 stopSample,
-                             Int32 *BwVector,
-                             Int32 sbrStartFreqOffset)
-{
-
-    Int32  temp1;
-    Int32  temp2;
-    Int32  temp3;
-
-
-    Int32  a0r;
-    Int32  a1r;
-    Int32  i;
-    Int32  bw;
-    Int32  hiBand;
-    Int32  bwIndex;
-    Int32  loBand;
-    Int32  j;
-
-    bwIndex = 0;
-
-    for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++)
-    {
-        loBand = hiBand - patchDistance;
-
-        if (hiBand != targetStopBand)
-        {
-            degreeAlias[hiBand] = degreeAlias[loBand];
-        }
-        else
-        {
-            degreeAlias[hiBand] = 0;
-        }
-
-        while (hiBand >= invFiltBandTable[bwIndex])
-        {
-            bwIndex++;
-        }
-
-        bw = BwVector[bwIndex];
-
-        /*
-         *  Inverse Filtering
-         */
-
-
-        j = hiBand - sbrStartFreqOffset;
-
-        if (bw > 0 && (alphar[0][loBand] | alphar[1][loBand]))
-        {
-            /* Apply current bandwidth expansion factor */
-            a0r = fxp_mul32_Q29(bw, alphar[0][loBand]);
-
-            bw  = fxp_mul32_Q31(bw, bw) << 2;
-
-            a1r = fxp_mul32_Q28(bw, alphar[1][loBand]);
-
-            i = startSample + slopeLength;
-
-            temp1 = sourceBufferReal[i    ][loBand];
-            temp2 = sourceBufferReal[i - 1][loBand];
-            temp3 = sourceBufferReal[i - 2][loBand];
-
-            for (; i < stopSample + slopeLength - 1; i++)
-            {
-
-
-                targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2)  +
-                                                        fxp_mul32_Q28(a1r, temp3);
-
-
-                temp3 = temp2;
-                temp2 = temp1;
-                temp1 = sourceBufferReal[i + 1][loBand];
-            }
-            targetBufferReal[i*SBR_NUM_BANDS + j] = temp1 + fxp_mul32_Q28(a0r, temp2)  +
-                                                    fxp_mul32_Q28(a1r, temp3);
-
-        }
-        else
-        {
-
-            for (i = startSample + slopeLength; i < stopSample + slopeLength; i++)
-            {
-                targetBufferReal[i*SBR_NUM_BANDS + j] = sourceBufferReal[i][loBand];
-            }
-        }
-
-
-    }  /* hiBand */
-
-}
-
-
-#ifdef HQ_SBR
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void high_freq_coeff(Int32 sourceBufferReal[][32],
-                     Int32 sourceBufferImag[][32],
-                     Int32 *alphar[2],
-                     Int32 *alphai[2],
-                     Int32 *v_k_master)
-{
-
-    Int32  overflow_flag;
-
-    Int32  temp1r;
-    Int32  temp1i;
-    Int32  temp0r;
-    Int32  temp0i;
-    Int32  loBand;
-
-    struct ACORR_COEFS ac;
-    struct intg_div  quotient;
-
-    Int32 autoCorrLength;
-
-    autoCorrLength = 38;
-
-    for (loBand = 1; loBand < v_k_master[0]; loBand++)
-    {
-
-        calc_auto_corr(&ac,
-                       sourceBufferReal,
-                       sourceBufferImag,
-                       loBand,
-                       autoCorrLength);
-
-
-        overflow_flag = 0;
-
-        if (ac.det < 1)
-        {
-            /* ---  */
-            temp1r = 0;
-            temp1i = 0;
-            alphar[1][loBand] = 0;
-            alphai[1][loBand] = 0;
-
-        }
-        else
-        {
-
-            temp1r =  fxp_mul32_Q29(ac.r01r, ac.r12r);
-            temp1r =  fxp_msu32_Q29(ac.r01i, ac.r12i, temp1r);
-            temp1r =  fxp_msu32_Q29(ac.r02r, ac.r11r, temp1r);
-
-            temp1i =  fxp_mul32_Q29(ac.r01r, ac.r12i);
-            temp1i =  fxp_msu32_Q29(ac.r02i, ac.r11r, temp1i);
-            temp1i =  fxp_mac32_Q29(ac.r01i, ac.r12r, temp1i);
-
-            pv_div(temp1r, ac.det, &quotient);
-            overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
-            temp1r = quotient.quotient >> (2 + quotient.shift_factor);   /*  Q28 */
-            pv_div(temp1i, ac.det, &quotient);
-            overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
-            temp1i = quotient.quotient >> (2 + quotient.shift_factor);   /*  Q28 */
-
-            alphar[1][loBand] = temp1r;
-            alphai[1][loBand] = temp1i;
-
-        }
-
-        if (ac.r11r == 0)
-        {
-            temp0r = 0;
-            temp0i = 0;
-            alphar[0][loBand] = 0;
-            alphai[0][loBand] = 0;
-
-        }
-        else
-        {
-            temp0r = - (ac.r01r + fxp_mul32_Q28(temp1r, ac.r12r) + fxp_mul32_Q28(temp1i, ac.r12i));
-            temp0i = - (ac.r01i + fxp_mul32_Q28(temp1i, ac.r12r) - fxp_mul32_Q28(temp1r, ac.r12i));
-
-            pv_div(temp0r, ac.r11r, &quotient);
-            overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
-            temp0r = quotient.quotient >> (2 + quotient.shift_factor);   /*  Q28 */
-            pv_div(temp0i, ac.r11r, &quotient);
-            overflow_flag = (quotient.shift_factor < -2) ? 1 : 0;
-            temp0i = quotient.quotient >> (2 + quotient.shift_factor);   /*  Q28 */
-
-            alphar[0][loBand] = temp0r;
-            alphai[0][loBand] = temp0i;
-
-        }
-
-        /* prevent for shootovers */
-
-        if (fxp_mul32_Q28((temp0r >> 2), (temp0r >> 2)) + fxp_mul32_Q28((temp0i >> 2), (temp0i >> 2)) >= 0x10000000 ||
-                fxp_mul32_Q28((temp1r >> 2), (temp1r >> 2)) + fxp_mul32_Q28((temp1i >> 2), (temp1i >> 2)) >= 0x10000000 ||
-                overflow_flag)     /*  0x10000000 == 1 in Q28 */
-
-        {
-            alphar[0][loBand] = 0;
-            alphar[1][loBand] = 0;
-            alphai[0][loBand] = 0;
-            alphai[1][loBand] = 0;
-
-        }
-    }
-}
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void high_freq_generation(Int32 sourceBufferReal[][32],
-                          Int32 sourceBufferImag[][32],
-                          Int32 *targetBufferReal,
-                          Int32 *targetBufferImag,
-                          Int32 *alphar[2],
-                          Int32 *alphai[2],
-                          Int32 *invFiltBandTable,
-                          Int32 targetStopBand,
-                          Int32 patchDistance,
-                          Int32 numBandsInPatch,
-                          Int32 startSample,
-                          Int32 slopeLength,
-                          Int32 stopSample,
-                          Int32 *BwVector,
-                          Int32 sbrStartFreqOffset)
-{
-    Int32  temp1_r;
-    Int32  temp2_r;
-    Int32  temp3_r;
-    Int32  temp1_i;
-    Int32  temp2_i;
-    Int32  temp3_i;
-
-
-    Int32  a0i;
-    Int32  a1i;
-    Int32  a0r;
-    Int32  a1r;
-    Int32  i;
-    Int32  bw;
-    Int32  hiBand;
-    Int32  bwIndex;
-    Int32  loBand;
-    Int32  j;
-
-
-
-    int64_t tmp;
-
-    bwIndex = 0;
-
-    for (hiBand = targetStopBand; hiBand < targetStopBand + numBandsInPatch; hiBand++)
-    {
-
-        loBand = hiBand - patchDistance;
-
-        while (hiBand >= invFiltBandTable[bwIndex])
-        {
-            bwIndex++;
-        }
-
-        bw = BwVector[bwIndex];
-
-        /*
-         *  Inverse Filtering
-         */
-
-
-        j = hiBand - sbrStartFreqOffset;
-
-        if (bw >= 0 && (alphar[0][loBand] | alphar[1][loBand] |
-                        alphai[0][loBand] | alphai[1][loBand]))
-        {
-            /* Apply current bandwidth expansion factor */
-            a0r = fxp_mul32_Q29(bw, alphar[0][loBand]);
-            a0i = fxp_mul32_Q29(bw, alphai[0][loBand]);
-
-
-            bw  = fxp_mul32_Q30(bw, bw);
-
-
-            a1r = fxp_mul32_Q28(bw, alphar[1][loBand]);
-            a1i = fxp_mul32_Q28(bw, alphai[1][loBand]);
-
-
-            i  = startSample + slopeLength;
-            j += i * SBR_NUM_BANDS;
-
-            temp1_r = sourceBufferReal[i    ][loBand];
-            temp2_r = sourceBufferReal[i - 1][loBand];
-            temp3_r = sourceBufferReal[i - 2][loBand];
-
-            temp1_i = sourceBufferImag[i    ][loBand];
-            temp2_i = sourceBufferImag[i - 1][loBand];
-            temp3_i = sourceBufferImag[i - 2][loBand];
-
-            while (i < stopSample + slopeLength)
-            {
-                tmp =  fxp_mac64_Q31(((int64_t)temp1_r << 28),  a0r, temp2_r);
-                tmp =  fxp_mac64_Q31(tmp, -a0i, temp2_i);
-                tmp =  fxp_mac64_Q31(tmp,  a1r, temp3_r);
-                targetBufferReal[j] = (Int32)(fxp_mac64_Q31(tmp, -a1i, temp3_i) >> 28);
-
-                tmp =  fxp_mac64_Q31(((int64_t)temp1_i << 28),  a0i, temp2_r);
-                tmp =  fxp_mac64_Q31(tmp,  a0r, temp2_i);
-                tmp =  fxp_mac64_Q31(tmp,  a1i, temp3_r);
-                targetBufferImag[j] = (Int32)(fxp_mac64_Q31(tmp,  a1r, temp3_i) >> 28);
-
-                i++;
-                j += SBR_NUM_BANDS;
-
-                temp3_r  = temp2_r;
-                temp2_r  = temp1_r;
-                temp1_r  = sourceBufferReal[i ][loBand];
-
-                temp3_i  = temp2_i;
-                temp2_i  = temp1_i;
-                temp1_i  = sourceBufferImag[i ][loBand];
-
-            }
-
-        }
-
-
-
-        else
-        {
-            i = startSample + slopeLength;
-            j += i * SBR_NUM_BANDS;
-
-            for (; i < stopSample + slopeLength; i++)
-            {
-                targetBufferReal[j] = sourceBufferReal[i][loBand];
-                targetBufferImag[j] = sourceBufferImag[i][loBand];
-                j += SBR_NUM_BANDS;
-            }
-        }
-    }
-}
-
-#endif
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h b/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h
deleted file mode 100644
index 0e9c928..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_generate_high_freq.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_generate_high_freq.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GENERATE_HIGH_FREQ_H
-#define SBR_GENERATE_HIGH_FREQ_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "e_invf_mode.h"
-#include    "s_patch.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-
-
-
-    void sbr_generate_high_freq(
-        Int32 sourceBufferReal[][32],
-        Int32 sourceBufferImag[][32],
-        Int32 *targetBufferReal,
-        Int32 *targetBufferImag,
-        INVF_MODE *invFiltMode,
-        INVF_MODE *prevInvFiltMode,
-        Int32 *invFiltBandTable,
-        Int32 noInvFiltBands,
-        Int32 highBandStartSb,
-        Int32 *v_k_master,
-        Int32 numMaster,
-        Int32 fs,
-        Int32 *frameInfo,
-        Int32 *degreeAlias,
-        Int32 scratch_mem[][64],
-        Int32 BwVector[MAX_NUM_PATCHES],
-        Int32 BwVectorOld[MAX_NUM_PATCHES],
-        struct PATCH * Patch,
-        Int32 LC_flag,
-        Int32 *highBandStopSb);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp
deleted file mode 100644
index 60072dd..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.cpp
+++ /dev/null
@@ -1,145 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_additional_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_additional_data.h"
-#include    "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData,
-                             BIT_BUFFER     * hBitBuf)
-{
-    Int32 i;
-
-    Int32 flag = buf_getbits(hBitBuf, 1);
-
-    if (flag)
-    {
-        for (i = 0; i < hFrameData->nSfb[HI]; i++)
-        {
-            hFrameData->addHarmonics[i] = buf_getbits(hBitBuf, 1);
-        }
-    }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h b/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h
deleted file mode 100644
index 51285c5..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_additional_data.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_additional_data.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_ADDITIONAL_DATA_H
-#define SBR_GET_ADDITIONAL_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_header_data.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_get_additional_data(SBR_FRAME_DATA * hFrameData,
-                             BIT_BUFFER     * hBitBuf);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp b/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp
deleted file mode 100644
index 657d032..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_cpe.cpp
+++ /dev/null
@@ -1,266 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_cpe.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     hFrameDataLeft  - handle to struct SBR_FRAME_DATA for first channel
-                hFrameDataRight - handle to struct SBR_FRAME_DATA for first channel
-                hBitBuf         - handle to struct BIT_BUF
-
- Return:        SbrFrameOK
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_cpe.h"
-#include    "buf_getbits.h"
-#include    "extractframeinfo.h"
-#include    "sbr_get_dir_control_data.h"
-#include    "sbr_get_envelope.h"
-#include    "sbr_get_noise_floor_data.h"
-#include    "sbr_get_additional_data.h"
-#include    "sbr_extract_extended_data.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft,
-                      SBR_FRAME_DATA * hFrameDataRight,
-                      BIT_BUFFER  * hBitBuf)
-{
-    Int32 i;
-    Int32 bits;
-    SBR_ERROR err =  SBRDEC_OK;
-
-    /* reserved bits */
-    bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT);
-
-    if (bits)
-    {
-        buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
-        buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
-    }
-
-    /* Read coupling flag */
-    bits = buf_getbits(hBitBuf, SI_SBR_COUPLING_BITS);
-
-    if (bits)
-    {
-        hFrameDataLeft->coupling = COUPLING_LEVEL;
-        hFrameDataRight->coupling = COUPLING_BAL;
-    }
-    else
-    {
-        hFrameDataLeft->coupling = COUPLING_OFF;
-        hFrameDataRight->coupling = COUPLING_OFF;
-    }
-
-
-    err = extractFrameInfo(hBitBuf, hFrameDataLeft);
-
-    if (err != SBRDEC_OK)
-    {
-        return err;
-    }
-
-    if (hFrameDataLeft->coupling)
-    {
-
-        pv_memcpy(hFrameDataRight->frameInfo,
-                  hFrameDataLeft->frameInfo,
-                  LENGTH_FRAME_INFO * sizeof(Int32));
-
-        hFrameDataRight->nNoiseFloorEnvelopes = hFrameDataLeft->nNoiseFloorEnvelopes;
-        hFrameDataRight->frameClass = hFrameDataLeft->frameClass;
-
-
-        sbr_get_dir_control_data(hFrameDataLeft, hBitBuf);
-        sbr_get_dir_control_data(hFrameDataRight, hBitBuf);
-
-        for (i = 0; i < hFrameDataLeft->nNfb; i++)
-        {
-            hFrameDataLeft->sbr_invf_mode_prev[i]  = hFrameDataLeft->sbr_invf_mode[i];
-            hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i];
-
-            hFrameDataLeft->sbr_invf_mode[i]  = (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
-            hFrameDataRight->sbr_invf_mode[i] = hFrameDataLeft->sbr_invf_mode[i];
-        }
-
-        sbr_get_envelope(hFrameDataLeft, hBitBuf);
-        sbr_get_noise_floor_data(hFrameDataLeft, hBitBuf);
-        sbr_get_envelope(hFrameDataRight, hBitBuf);
-
-    }
-    else
-    {
-        err = extractFrameInfo(hBitBuf, hFrameDataRight);
-
-        if (err != SBRDEC_OK)
-        {
-            return err;
-        }
-
-
-        sbr_get_dir_control_data(hFrameDataLeft,  hBitBuf);
-        sbr_get_dir_control_data(hFrameDataRight, hBitBuf);
-
-        for (i = 0; i <  hFrameDataLeft->nNfb; i++)
-        {
-            hFrameDataLeft->sbr_invf_mode_prev[i]  = hFrameDataLeft->sbr_invf_mode[i];
-            hFrameDataLeft->sbr_invf_mode[i]  =
-                (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
-        }
-
-        for (i = 0; i <  hFrameDataRight->nNfb; i++)
-        {
-            hFrameDataRight->sbr_invf_mode_prev[i] = hFrameDataRight->sbr_invf_mode[i];
-
-            hFrameDataRight->sbr_invf_mode[i] =
-                (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
-        }
-        sbr_get_envelope(hFrameDataLeft,  hBitBuf);
-        sbr_get_envelope(hFrameDataRight, hBitBuf);
-
-        sbr_get_noise_floor_data(hFrameDataLeft,  hBitBuf);
-
-    }
-
-    sbr_get_noise_floor_data(hFrameDataRight, hBitBuf);
-
-    pv_memset((void *)hFrameDataLeft->addHarmonics,
-              0,
-              hFrameDataLeft->nSfb[HI]*sizeof(Int32));
-
-    pv_memset((void *)hFrameDataRight->addHarmonics,
-              0,
-              hFrameDataRight->nSfb[HI]*sizeof(Int32));
-
-    sbr_get_additional_data(hFrameDataLeft, hBitBuf);
-    sbr_get_additional_data(hFrameDataRight, hBitBuf);
-
-    sbr_extract_extended_data(hBitBuf
-#ifdef PARAMETRICSTEREO
-                              , NULL
-#endif
-                             );
-
-    return SBRDEC_OK;
-
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_cpe.h b/media/libstagefright/codecs/aacdec/sbr_get_cpe.h
deleted file mode 100644
index b6f99f8..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_cpe.h
+++ /dev/null
@@ -1,88 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_cpe.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_CPE_H
-#define SBR_GET_CPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-#include    "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_get_cpe(SBR_FRAME_DATA * hFrameDataLeft,
-                      SBR_FRAME_DATA * hFrameDataRight,
-                      BIT_BUFFER * hBitBuf);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp
deleted file mode 100644
index 3d7ad8c..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.cpp
+++ /dev/null
@@ -1,153 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_dir_control_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     h_frame_data - handle to struct SBR_FRAME_DATA
-                hBitBuf      - handle to struct BIT_BUF
-
- Return:        void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-  Reads direction control data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_dir_control_data.h"
-#include    "buf_getbits.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data,
-                              BIT_BUFFER     * hBitBuf)
-{
-    Int32 i;
-
-    h_frame_data->nNoiseFloorEnvelopes = h_frame_data->frameInfo[0] > 1 ? 2 : 1;
-
-
-    for (i = 0; i < h_frame_data->frameInfo[0]; i++)
-    {
-        h_frame_data->domain_vec1[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS);
-    }
-
-    for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++)
-    {
-        h_frame_data->domain_vec2[i] = buf_getbits(hBitBuf, SI_SBR_DOMAIN_BITS);
-    }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h b/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h
deleted file mode 100644
index 3b587dc..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_dir_control_data.h
+++ /dev/null
@@ -1,87 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_dir_control_data.h
- Funtions:
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_DIR_CONTROL_DATA_H
-#define SBR_GET_DIR_CONTROL_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_get_dir_control_data(SBR_FRAME_DATA * h_frame_data,
-                              BIT_BUFFER * hBitBuf);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp b/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp
deleted file mode 100644
index e92abb1..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_envelope.cpp
+++ /dev/null
@@ -1,265 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_envelope.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     h_frame_data - handle to struct SBR_FRAME_DATA
-                hBitBuf      - handle to struct BIT_BUF
-                channel      - channel number
-
- Return:        void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-          Reads envelope data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_envelope.h"
-#include    "s_huffman.h"
-#include    "e_coupling_mode.h"
-#include    "sbr_code_book_envlevel.h"
-#include    "buf_getbits.h"
-#include    "sbr_decode_huff_cw.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data,
-                      BIT_BUFFER * hBitBuf)
-{
-    Int32   i;
-    Int32   j;
-    Int32   tmp;
-    Int32   no_band[MAX_ENVELOPES];
-    Int32   delta = 0;
-    Int32   offset = 0;
-    Int32   ampRes;
-    Int32   envDataTableCompFactor;
-    Int32   start_bits;
-    Int32   start_bits_balance;
-    SbrHuffman    hcb_t;
-    SbrHuffman    hcb_f;
-    COUPLING_MODE coupling = h_frame_data->coupling;
-
-    h_frame_data->nScaleFactors = 0;
-
-    if ((h_frame_data->frameClass   == FIXFIX) &&
-            (h_frame_data->frameInfo[0] == 1))
-    {
-        h_frame_data->ampRes = SBR_AMP_RES_1_5;
-    }
-    else
-    {
-        h_frame_data->ampRes = h_frame_data->sbr_header.ampResolution;
-    }
-
-    ampRes = h_frame_data->ampRes;
-
-    /*
-     *    Set number of bits for first value depending on amplitude resolution
-     */
-    if (ampRes == SBR_AMP_RES_3_0)
-    {
-        start_bits         = SI_SBR_START_ENV_BITS_AMP_RES_3_0;
-        start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_3_0;
-    }
-    else
-    {
-        start_bits         = SI_SBR_START_ENV_BITS_AMP_RES_1_5;
-        start_bits_balance = SI_SBR_START_ENV_BITS_BALANCE_AMP_RES_1_5;
-    }
-
-    /*
-     *    Calculate number of values for each envelope and alltogether
-     */
-    for (i = 0; i < h_frame_data->frameInfo[0]; i++)
-    {
-        no_band[i] =
-            h_frame_data->nSfb[h_frame_data->frameInfo[h_frame_data->frameInfo[0] + 2 + i]];
-        h_frame_data->nScaleFactors += no_band[i];
-    }
-
-
-    /*
-     *    Select huffman codebook depending on coupling mode and amplitude resolution
-     */
-    if (coupling == COUPLING_BAL)
-    {
-        envDataTableCompFactor = 1;
-        if (ampRes == SBR_AMP_RES_1_5)
-        {
-            hcb_t = bookSbrEnvBalance10T;
-            hcb_f = bookSbrEnvBalance10F;
-        }
-        else
-        {
-            hcb_t = bookSbrEnvBalance11T;
-            hcb_f = bookSbrEnvBalance11F;
-        }
-    }
-    else
-    {
-        envDataTableCompFactor = 0;
-        if (ampRes == SBR_AMP_RES_1_5)
-        {
-            hcb_t = bookSbrEnvLevel10T;
-            hcb_f = bookSbrEnvLevel10F;
-        }
-        else
-        {
-            hcb_t = bookSbrEnvLevel11T;
-            hcb_f = bookSbrEnvLevel11F;
-        }
-    }
-
-    /*
-     *    Now read raw envelope data
-     */
-    for (j = 0; j < h_frame_data->frameInfo[0]; j++)
-    {
-        if (h_frame_data->domain_vec1[j] == FREQ)
-        {
-            if (coupling == COUPLING_BAL)
-            {
-                tmp = buf_getbits(hBitBuf, start_bits_balance);
-                h_frame_data->iEnvelope_man[offset] = tmp << envDataTableCompFactor;
-            }
-            else
-            {
-                tmp = buf_getbits(hBitBuf, start_bits);
-                h_frame_data->iEnvelope_man[offset] = tmp;
-            }
-        }
-
-        for (i = (1 - h_frame_data->domain_vec1[j]); i < no_band[j]; i++)
-        {
-
-            if (h_frame_data->domain_vec1[j] == FREQ)
-            {
-                delta = sbr_decode_huff_cw(hcb_f, hBitBuf);
-            }
-            else
-            {
-                delta = sbr_decode_huff_cw(hcb_t, hBitBuf);
-            }
-
-            h_frame_data->iEnvelope_man[offset + i] = delta << envDataTableCompFactor;
-        }
-        offset += no_band[j];
-    }
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_envelope.h b/media/libstagefright/codecs/aacdec/sbr_get_envelope.h
deleted file mode 100644
index b7a266a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_envelope.h
+++ /dev/null
@@ -1,93 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_envelope.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_ENVELOPE_H
-#define SBR_GET_ENVELOPE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void sbr_get_envelope(SBR_FRAME_DATA * h_frame_data,
-    BIT_BUFFER  * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp
deleted file mode 100644
index 42789ae..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_header_data.cpp
+++ /dev/null
@@ -1,221 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_header_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     h_sbr_header - handle to struct SBR_HEADER_DATA
-                hBitBuf      - handle to struct BIT_BUFFER
-                id_sbr       - SBR_ELEMENT_ID
-
- Return:        error status - 0 if ok
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Reads header data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_header_data.h"
-#include    "sbr_constants.h"
-#include    "buf_getbits.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA   * h_sbr_header,
-                                      BIT_BUFFER          * hBitBuf,
-                                      SBR_SYNC_STATE     syncState)
-{
-    SBR_HEADER_DATA lastHeader;
-    Int32 headerExtra1, headerExtra2;
-
-
-    /* Copy header to temporary header */
-    if (syncState == SBR_ACTIVE)
-    {
-        pv_memcpy(&lastHeader, h_sbr_header, sizeof(SBR_HEADER_DATA));
-    }
-    else
-    {
-        pv_memset((void *)&lastHeader, 0, sizeof(SBR_HEADER_DATA));
-    }
-
-
-    /* Read new header from bitstream */
-    h_sbr_header->ampResolution   = buf_getbits(hBitBuf, SI_SBR_AMP_RES_BITS);
-    h_sbr_header->startFreq       = buf_getbits(hBitBuf, SI_SBR_START_FREQ_BITS);
-    h_sbr_header->stopFreq        = buf_getbits(hBitBuf, SI_SBR_STOP_FREQ_BITS);
-    h_sbr_header->xover_band      = buf_getbits(hBitBuf, SI_SBR_XOVER_BAND_BITS);
-
-    buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_HDR);
-
-    headerExtra1    = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_1_BITS);
-    headerExtra2    = buf_getbits(hBitBuf, SI_SBR_HEADER_EXTRA_2_BITS);
-
-    /* handle extra header information */
-    if (headerExtra1)
-    {
-        h_sbr_header->freqScale   = buf_getbits(hBitBuf, SI_SBR_FREQ_SCALE_BITS);
-        h_sbr_header->alterScale  = buf_getbits(hBitBuf, SI_SBR_ALTER_SCALE_BITS);
-        h_sbr_header->noise_bands = buf_getbits(hBitBuf, SI_SBR_NOISE_BANDS_BITS);
-    }
-    else
-    { /* Set default values.*/
-        h_sbr_header->freqScale   = SBR_FREQ_SCALE_DEFAULT;
-        h_sbr_header->alterScale  = SBR_ALTER_SCALE_DEFAULT;
-        h_sbr_header->noise_bands = SBR_NOISE_BANDS_DEFAULT;
-    }
-
-
-    if (headerExtra2)
-    {
-        h_sbr_header->limiterBands    = buf_getbits(hBitBuf, SI_SBR_LIMITER_BANDS_BITS);
-        h_sbr_header->limiterGains    = buf_getbits(hBitBuf, SI_SBR_LIMITER_GAINS_BITS);
-        h_sbr_header->interpolFreq    = buf_getbits(hBitBuf, SI_SBR_INTERPOL_FREQ_BITS);
-        h_sbr_header->smoothingLength = buf_getbits(hBitBuf, SI_SBR_SMOOTHING_LENGTH_BITS);
-    }
-    else
-    { /* Set default values.*/
-        h_sbr_header->limiterBands    = SBR_LIMITER_BANDS_DEFAULT;
-        h_sbr_header->limiterGains    = SBR_LIMITER_GAINS_DEFAULT;
-        h_sbr_header->interpolFreq    = SBR_INTERPOL_FREQ_DEFAULT;
-        h_sbr_header->smoothingLength = SBR_SMOOTHING_LENGTH_DEFAULT;
-    }
-
-    if (syncState == SBR_ACTIVE)
-    {
-        h_sbr_header->status = HEADER_OK;
-
-        /* look for new settings */
-        if (lastHeader.startFreq   != h_sbr_header->startFreq   ||
-                lastHeader.stopFreq    != h_sbr_header->stopFreq    ||
-                lastHeader.xover_band  != h_sbr_header->xover_band  ||
-                lastHeader.freqScale   != h_sbr_header->freqScale   ||
-                lastHeader.alterScale  != h_sbr_header->alterScale  ||
-                lastHeader.noise_bands != h_sbr_header->noise_bands)
-        {
-            h_sbr_header->status = HEADER_RESET;
-        }
-    }
-    else
-    {
-        h_sbr_header->status = HEADER_RESET;
-    }
-
-    return h_sbr_header->status;
-}
-
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_header_data.h b/media/libstagefright/codecs/aacdec/sbr_get_header_data.h
deleted file mode 100644
index 7bfb272..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_header_data.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_header_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_HEADER_DATA_H
-#define SBR_GET_HEADER_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_header_data.h"
-#include    "e_sbr_element_id.h"
-#include    "e_sbr_sync_state.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-SBR_HEADER_STATUS sbr_get_header_data(SBR_HEADER_DATA   *h_sbr_header,
-                                      BIT_BUFFER  * hBitBuf,
-                                      SBR_SYNC_STATE     syncState);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp b/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp
deleted file mode 100644
index 8d86158..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.cpp
+++ /dev/null
@@ -1,218 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_noise_floor_data.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     h_frame_data - handle to struct SBR_FRAME_DATA
-                hBitBuf      - handle to struct BIT_BUF
-
- Return:        void
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Reads noise-floor-level data from bitstream
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_get_noise_floor_data.h"
-#include    "e_coupling_mode.h"
-#include    "buf_getbits.h"
-#include    "sbr_code_book_envlevel.h"
-#include    "s_huffman.h"
-#include    "sbr_decode_huff_cw.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data,
-                              BIT_BUFFER * hBitBuf)
-{
-    Int32 i;
-    Int32 j;
-    Int32 k;
-    Int32 tmp;
-    Int32 delta;
-    Int32 noNoiseBands = h_frame_data->nNfb;
-    Int32 envDataTableCompFactor;
-
-    COUPLING_MODE coupling = h_frame_data->coupling;
-
-    SbrHuffman hcb_noiseF;
-    SbrHuffman hcb_noise;
-
-
-    if (coupling == COUPLING_BAL)
-    {
-        hcb_noise  = bookSbrNoiseBalance11T;
-        hcb_noiseF = bookSbrEnvBalance11F;  /* "bookSbrNoiseBalance11F" */
-        envDataTableCompFactor = 1;
-    }
-    else
-    {
-        hcb_noise  = bookSbrNoiseLevel11T;
-        hcb_noiseF = bookSbrEnvLevel11F;  /* "bookSbrNoiseLevel11F" */
-        envDataTableCompFactor = 0;
-    }
-
-    /*
-     *  Calculate number of values alltogether
-     */
-    h_frame_data->nNoiseFactors = h_frame_data->frameInfo[((h_frame_data->frameInfo[0]) << 1) + 3] * noNoiseBands;
-
-
-    for (i = 0; i < h_frame_data->nNoiseFloorEnvelopes; i++)
-    {
-        k = i * noNoiseBands;
-        if (h_frame_data->domain_vec2[i] == FREQ)
-        {
-            if (coupling == COUPLING_BAL)
-            {
-                tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_BALANCE_AMP_RES_3_0) << 1;  /*  max. 62  */
-                h_frame_data->sbrNoiseFloorLevel_man[k] = tmp;
-                h_frame_data->sbrNoiseFloorLevel_exp[k] =   0;
-            }
-            else
-            {
-                tmp = buf_getbits(hBitBuf, SI_SBR_START_NOISE_BITS_AMP_RES_3_0);  /*  max. 31  */
-                h_frame_data->sbrNoiseFloorLevel_man[k] = tmp;
-                h_frame_data->sbrNoiseFloorLevel_exp[k] =   0;
-            }
-
-            for (j = 1; j < noNoiseBands; j++)
-            {
-                delta = sbr_decode_huff_cw(hcb_noiseF, hBitBuf); /*
-                                                                  *  -31 < delta < 31
-                                                                  *  -24 < delta < 24   COUPLING_BAL (incl. <<1)
-                                                                  */
-                h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor;
-                h_frame_data->sbrNoiseFloorLevel_exp[k+j] =   0;
-            }
-        }
-        else
-        {
-            for (j = 0; j < noNoiseBands; j++)
-            {
-                delta = sbr_decode_huff_cw(hcb_noise, hBitBuf);  /*
-                                                                  *  -31 < delta < 31
-                                                                  *  -24 < delta < 24   COUPLING_BAL (incl. <<1)
-                                                                  */
-                h_frame_data->sbrNoiseFloorLevel_man[k+j] = delta << envDataTableCompFactor;
-                h_frame_data->sbrNoiseFloorLevel_exp[k+j] =   0;
-            }
-        }
-    }
-}
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h b/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h
deleted file mode 100644
index e61abda..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_noise_floor_data.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_noise_floor_data.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_NOISE_FLOOR_DATA_H
-#define SBR_GET_NOISE_FLOOR_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    void sbr_get_noise_floor_data(SBR_FRAME_DATA * h_frame_data,
-    BIT_BUFFER * hBitBuf);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp b/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp
deleted file mode 100644
index ba514f4..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_sce.cpp
+++ /dev/null
@@ -1,202 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_sce.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Arguments:     hFrameData - handle to struct SBR_FRAME_DATA
-                hBitBuf    - handle to struct BIT_BUF
-
- Return:        SbrFrameOK
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-
-#include    "sbr_get_sce.h"
-#include    "sbr_get_additional_data.h"
-#include    "sbr_extract_extended_data.h"
-#include    "buf_getbits.h"
-#include    "sbr_get_envelope.h"
-#include    "sbr_get_noise_floor_data.h"
-#include    "extractframeinfo.h"
-#include    "sbr_get_dir_control_data.h"
-#include    "e_invf_mode.h"
-#include    "aac_mem_funcs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData,
-                      BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO
-                      , HANDLE_PS_DEC hParametricStereoDec
-#endif
-                     )
-{
-    Int32 i;
-    Int32 bits;
-    SBR_ERROR err =  SBRDEC_OK;
-
-    /* reserved bits */
-    bits = buf_getbits(hBitBuf, SI_SBR_RESERVED_PRESENT);
-
-    if (bits)
-    {
-        buf_getbits(hBitBuf, SI_SBR_RESERVED_BITS_DATA);
-    }
-
-    /* side info */
-    err = extractFrameInfo(hBitBuf, hFrameData);
-
-    if (err != SBRDEC_OK)
-    {
-        return err;
-    }
-
-
-    sbr_get_dir_control_data(hFrameData, hBitBuf);
-
-    for (i = 0; i < hFrameData->nNfb; i++)
-    {
-        hFrameData->sbr_invf_mode_prev[i] = hFrameData->sbr_invf_mode[i];
-        hFrameData->sbr_invf_mode[i] =
-            (INVF_MODE) buf_getbits(hBitBuf, SI_SBR_INVF_MODE_BITS);
-    }
-
-
-    /* raw data */
-    sbr_get_envelope(hFrameData, hBitBuf);
-
-    sbr_get_noise_floor_data(hFrameData, hBitBuf);
-
-    pv_memset((void *)hFrameData->addHarmonics,
-              0,
-              hFrameData->nSfb[HI]*sizeof(Int32));
-
-    sbr_get_additional_data(hFrameData, hBitBuf);
-
-    sbr_extract_extended_data(hBitBuf
-#ifdef PARAMETRICSTEREO
-                              , hParametricStereoDec
-#endif
-                             );
-
-    hFrameData->coupling = COUPLING_OFF;
-
-    return SBRDEC_OK;
-
-}
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_get_sce.h b/media/libstagefright/codecs/aacdec/sbr_get_sce.h
deleted file mode 100644
index 36adb04..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_get_sce.h
+++ /dev/null
@@ -1,102 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_get_sce.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_GET_SCE_H
-#define SBR_GET_SCE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_bit_buffer.h"
-#include    "s_sbr_frame_data.h"
-#include    "e_sbr_error.h"
-
-#ifdef PARAMETRICSTEREO
-#include    "s_ps_dec.h"
-#endif
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    SBR_ERROR sbr_get_sce(SBR_FRAME_DATA * hFrameData,
-    BIT_BUFFER * hBitBuf
-#ifdef PARAMETRICSTEREO
-    , HANDLE_PS_DEC hParametricStereoDec
-#endif
-                         );
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp b/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp
deleted file mode 100644
index 833ace3..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.cpp
+++ /dev/null
@@ -1,214 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_inv_filt_levelemphasis.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_inv_filt_levelemphasis.h"
-#include    "sbr_generate_high_freq.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-
-#define R_SHIFT     29
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-
-const Int32 InvFiltFactors[5] = {Qfmt(0.00f),    /* OFF_LEVEL */
-                                 Qfmt(0.60f),     /* TRANSITION_LEVEL */
-                                 Qfmt(0.75f),     /* LOW_LEVEL */
-                                 Qfmt(0.90f),     /* MID_LEVEL */
-                                 Qfmt(0.98f)
-                                };    /* HIGH_LEVEL */
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode,
-                                INVF_MODE *prevInvFiltMode,
-                                Int32 nNfb,
-                                Int32  BwVector[MAX_NUM_PATCHES],
-                                Int32  BwVectorOld[MAX_NUM_PATCHES])
-{
-    Int32 i;
-    Int32 j;
-    Int32 tmp;
-
-    for (i = 0; i < nNfb; i++)
-    {
-        switch (invFiltMode[i])
-        {
-            case INVF_LOW_LEVEL:
-                if (prevInvFiltMode[i] == INVF_OFF)
-                {
-                    j = 1;
-                }
-                else
-                {
-                    j = 2;
-                }
-                break;
-
-            case INVF_MID_LEVEL:
-                j = 3;
-                break;
-
-            case INVF_HIGH_LEVEL:
-                j = 4;
-                break;
-
-            default:
-                if (prevInvFiltMode[i] == INVF_LOW_LEVEL)
-                {
-                    j = 1;
-                }
-                else
-                {
-                    j = 0;
-                }
-        }
-
-        tmp  =  InvFiltFactors[j];
-
-        if (tmp < BwVectorOld[i])
-        {
-            tmp = ((tmp << 1) + tmp + BwVectorOld[i]) >> 2;
-        }
-        else
-        {
-            tmp =  fxp_mul32_Q29(Qfmt(0.90625f), tmp);
-            tmp =  fxp_mac32_Q29(Qfmt(0.09375f), BwVectorOld[i], tmp);
-        }
-
-        if (tmp < Qfmt(0.015625F))
-        {
-            tmp = 0;
-        }
-
-        if (tmp >= Qfmt(0.99609375f))
-        {
-            tmp = Qfmt(0.99609375f);
-        }
-
-        BwVector[i] = tmp;
-    }
-}
-
-
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h b/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h
deleted file mode 100644
index 586214c..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_inv_filt_levelemphasis.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_inv_filt_levelemphasis.h
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_INV_FILT_LEVELEMPHASIS_H
-#define SBR_INV_FILT_LEVELEMPHASIS_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "e_invf_mode.h"
-#include    "sbr_generate_high_freq.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-void sbr_inv_filt_levelemphasis(INVF_MODE *invFiltMode,
-                                INVF_MODE *prevInvFiltMode,
-                                Int32  nNfb,
-                                Int32  BwVector[MAX_NUM_PATCHES],
-                                Int32  BwVectorOld[MAX_NUM_PATCHES]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_open.cpp b/media/libstagefright/codecs/aacdec/sbr_open.cpp
deleted file mode 100644
index 868819a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_open.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_open.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_open.h"
-#include    "s_sbr_header_data.h"
-#include    "init_sbr_dec.h"
-#include    "e_sbr_error.h"
-#include    "aac_mem_funcs.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const SBR_HEADER_DATA defaultHeader =
-{
-    HEADER_NOT_INITIALIZED,   /* status */
-    MASTER_RESET,             /* masterStatus */
-    0,                        /* crcEnable */
-    UP_BY_2,                  /* sampleRateMode */
-    SBR_AMP_RES_3_0,          /* ampResolution */
-    5,                        /* startFreq */
-    0,                        /* stopFreq */
-    0,                        /* xover_band */
-    SBR_FREQ_SCALE_DEFAULT,   /* freqScale */
-    SBR_ALTER_SCALE_DEFAULT,  /* alterScale */
-    SBR_NOISE_BANDS_DEFAULT,  /* noise_bands */
-    0,                        /* noNoiseBands */
-    SBR_LIMITER_BANDS_DEFAULT,
-    SBR_LIMITER_GAINS_DEFAULT,
-    SBR_INTERPOL_FREQ_DEFAULT,
-    SBR_SMOOTHING_LENGTH_DEFAULT
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_open(Int32 sampleRate,
-              SBR_DEC *sbrDec,
-              SBRDECODER_DATA * self,
-              bool bDownSampledSbr)
-
-{
-    Int16 i ;
-
-    SBR_CHANNEL *SbrChannel;
-
-
-    SbrChannel = self->SbrChannel;
-
-    for (i = 0; i < MAX_NUM_CHANNELS; i++)
-    {
-        pv_memset((void *)&(SbrChannel[i]),
-                  0,
-                  sizeof(SBR_CHANNEL));
-
-        /* init a default header such that we can at least do upsampling later */
-
-        pv_memcpy(&(SbrChannel[i].frameData.sbr_header),
-                  &defaultHeader,
-                  sizeof(SBR_HEADER_DATA));
-
-        /* should be handled by sample rate mode bit */
-        if (sampleRate > 24000 || bDownSampledSbr)
-        {
-            SbrChannel[i].frameData.sbr_header.sampleRateMode = SINGLE_RATE;
-        }
-
-
-        SbrChannel[i].outFrameSize =
-            init_sbr_dec(sampleRate,
-                         self->SbrChannel[0].frameData.sbr_header.sampleRateMode,
-                         sbrDec,
-                         &(SbrChannel[i].frameData));
-
-        SbrChannel[i].syncState     = UPSAMPLING;
-
-        SbrChannel[i].frameData.sUp = 1;        /* reset mode */
-    }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_open.h b/media/libstagefright/codecs/aacdec/sbr_open.h
deleted file mode 100644
index 8d17ffa..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_open.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_open.h
- Funtions:
-    get_dse
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_OPEN_H
-#define SBR_OPEN_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "s_sbr_channel.h"
-#include "sbr_dec.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void sbr_open(Int32 sampleRate,
-              SBR_DEC *sbrDec,
-              SBRDECODER_DATA * self,
-              bool bDownSampledSbr);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_read_data.cpp b/media/libstagefright/codecs/aacdec/sbr_read_data.cpp
deleted file mode 100644
index 2220fce..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_read_data.cpp
+++ /dev/null
@@ -1,324 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_read_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    INPUT
-
-    SBRDECODER self,
-    SBRBITSTREAM * stream,
-    float *timeData,
-    int numChannels
-
-    OUTPUT
-
-    errorCode, noError if successful
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        sbr decoder processing, set up SBR decoder phase 2 in case of
-        different cotrol data
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_read_data.h"
-#include    "s_bit_buffer.h"
-#include    "buf_getbits.h"
-#include    "sbr_get_sce.h"
-#include    "sbr_get_cpe.h"
-#include    "sbr_reset_dec.h"
-#include    "sbr_get_header_data.h"
-#include    "sbr_crc_check.h"
-#include    "aac_mem_funcs.h"
-
-
-#include    "init_sbr_dec.h"  /*  !!! */
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_read_data(SBRDECODER_DATA * self,
-                        SBR_DEC * sbrDec,
-                        SBRBITSTREAM *stream)
-{
-    SBR_ERROR sbr_err =  SBRDEC_OK;
-    int32_t SbrFrameOK = 1;
-    int32_t sbrCRCAlwaysOn = 0;
-
-    UInt32 bs_header_flag = 0;
-
-    SBR_HEADER_STATUS headerStatus = HEADER_OK;
-
-    SBR_CHANNEL *SbrChannel = self->SbrChannel;
-
-    int32_t zeropadding_bits;
-
-    BIT_BUFFER bitBuf ;
-
-    /*
-     *  evaluate Bitstream
-     */
-
-    bitBuf.buffer_word    = 0;
-    bitBuf.buffered_bits  = 0;
-    bitBuf.nrBitsRead     = 0;
-
-    bitBuf.char_ptr  =  stream->sbrElement[0].Data;
-    bitBuf.bufferLen = (stream->sbrElement[0].Payload) << 3;
-
-
-    /*
-     *  we have to skip a nibble because the first element of Data only
-     *  contains a nibble of data !
-     */
-    buf_getbits(&bitBuf, LEN_NIBBLE);
-
-    if ((stream->sbrElement[0].ExtensionType == SBR_EXTENSION_CRC) ||
-            sbrCRCAlwaysOn)
-    {
-        int32_t CRCLen = ((stream->sbrElement[0].Payload - 1) << 3) + 4 - SI_SBR_CRC_BITS;
-        SbrFrameOK = sbr_crc_check(&bitBuf, CRCLen);
-    }
-
-
-    if (SbrFrameOK)
-    {
-        /*
-         *  The sbr data seems ok, if the header flag is set we read the header
-         *  and check if vital parameters have changed since the previous frame.
-         *  If the syncState equals UPSAMPLING, the SBR Tool has not been
-         *  initialised by SBR header data, and can only do upsampling
-         */
-
-        bs_header_flag = buf_getbits(&bitBuf, 1);  /* read Header flag */
-
-        if (bs_header_flag)
-        {
-            /*
-             *  If syncState == SBR_ACTIVE, it means that we've had a SBR header
-             *  before, and we will compare with the previous header to see if a
-             *  reset is required. If the syncState equals UPSAMPLING this means
-             *  that the SBR-Tool so far is only initialised to do upsampling
-             *  and hence we need to do a reset, and initialise the system
-             *  according to the present header.
-             */
-
-            headerStatus = sbr_get_header_data(&(SbrChannel[0].frameData.sbr_header),
-                                               &bitBuf,
-                                               SbrChannel[0].syncState);
-        }     /* if (bs_header_flag) */
-
-
-        switch (stream->sbrElement[0].ElementID)
-        {
-            case SBR_ID_SCE :
-
-                /* change of control data, reset decoder */
-                if (headerStatus == HEADER_RESET)
-                {
-                    sbr_err = sbr_reset_dec(&(SbrChannel[0].frameData),
-                                            sbrDec,
-                                            self->SbrChannel[0].frameData.sbr_header.sampleRateMode);
-
-                    if (sbr_err != SBRDEC_OK)
-                    {
-                        break;
-                    }
-                    /*
-                     * At this point we have a header and the system has been reset,
-                     * hence syncState from now on will be SBR_ACTIVE.
-                     */
-                    SbrChannel[0].syncState     = SBR_ACTIVE;
-                }
-
-                if ((SbrChannel[0].syncState == SBR_ACTIVE))
-                {
-                    sbr_err = sbr_get_sce(&(SbrChannel[0].frameData),
-                                          &bitBuf
-#ifdef PARAMETRICSTEREO
-                                          , self->hParametricStereoDec
-#endif
-                                         );
-
-                    if (sbr_err != SBRDEC_OK)
-                    {
-                        break;
-                    }
-                }
-
-                break;
-
-            case SBR_ID_CPE :
-
-                if (bs_header_flag)
-                {
-                    pv_memcpy(&(SbrChannel[1].frameData.sbr_header),
-                              &(SbrChannel[0].frameData.sbr_header),
-                              sizeof(SBR_HEADER_DATA));
-                }
-
-                /* change of control data, reset decoder */
-                if (headerStatus == HEADER_RESET)
-                {
-                    for (int32_t lr = 0 ; lr < 2 ; lr++)
-                    {
-                        sbr_err = sbr_reset_dec(&(SbrChannel[lr].frameData),
-                                                sbrDec,
-                                                self->SbrChannel[0].frameData.sbr_header.sampleRateMode);
-
-                        if (sbr_err != SBRDEC_OK)
-                        {
-                            break;
-                        }
-
-                        SbrChannel[lr].syncState = SBR_ACTIVE;
-                    }
-                }
-
-                if (SbrChannel[0].syncState == SBR_ACTIVE)
-                {
-                    sbr_err = sbr_get_cpe(&(SbrChannel[0].frameData),
-                                          &(SbrChannel[1].frameData),
-                                          &bitBuf);
-
-                    if (sbr_err != SBRDEC_OK)
-                    {
-                        break;
-                    }
-
-                }
-                break;
-
-            default:
-                sbr_err = SBRDEC_ILLEGAL_PLUS_ELE_ID;
-                break;
-        }
-
-    }           /* if (SbrFrameOK) */
-
-    /*
-     *  Check that the bits read did not go beyond SBR frame boundaries
-     */
-
-    zeropadding_bits = (8 - (bitBuf.nrBitsRead & 0x7)) & 0x7;
-
-    if ((bitBuf.nrBitsRead + zeropadding_bits)  > bitBuf.bufferLen)
-    {
-        sbr_err = SBRDEC_INVALID_BITSTREAM;
-    }
-
-    return sbr_err;
-}
-
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_read_data.h b/media/libstagefright/codecs/aacdec/sbr_read_data.h
deleted file mode 100644
index 74cf5b9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_read_data.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_read_data.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_READ_DATA
-#define SBR_READ_DATA
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_sbr_error.h"
-#include "s_sbr_channel.h"
-#include "s_sbrbitstream.h"
-#include "sbr_dec.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    SBR_ERROR sbr_read_data(SBRDECODER_DATA * self,
-    SBR_DEC * sbrDec,
-    SBRBITSTREAM *stream);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp b/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp
deleted file mode 100644
index 487496f..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.cpp
+++ /dev/null
@@ -1,183 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_requantize_envelope_data.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_constants.h"
-#include    "sbr_requantize_envelope_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define R_SHIFT     30
-#define Qfmt(x)   (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData)
-
-{
-    Int32 i;
-
-
-    Int32  nScaleFactors      =  hFrameData->nScaleFactors;
-    Int32  nNoiseFactors      =  hFrameData->nNoiseFactors;
-    Int32  ampRes             =  hFrameData->ampRes;
-    Int32 *iEnvelope_man      =  hFrameData->iEnvelope_man;
-    Int32 *iEnvelope_exp      =  hFrameData->iEnvelope_exp;
-    Int32 *sbrNoiseFloorLevel_man = hFrameData->sbrNoiseFloorLevel_man;
-    Int32 *sbrNoiseFloorLevel_exp = hFrameData->sbrNoiseFloorLevel_exp;
-
-    /*
-     *  ampRes could be 0 (resolution step = 1.5 dB) or
-     *                  1 (resolution step = 3 dB)
-     */
-    if (ampRes)
-    {
-        /*  iEnvelope[i] always positive  6 bits max */
-        for (i = 0; i < nScaleFactors; i++)
-        {
-
-            iEnvelope_exp[i] = iEnvelope_man[i] + 6;
-            iEnvelope_man[i] = Qfmt(1.000F);
-        }
-    }
-    else
-    {
-        /*  iEnvelope[i] always positive  7 bits max */
-        for (i = 0; i < nScaleFactors; i++)
-        {
-            iEnvelope_exp[i] = (iEnvelope_man[i] >> 1) + 6;
-            if (iEnvelope_man[i] & 0x1)   /*  odd */
-            {
-                iEnvelope_man[i] = Qfmt(1.41421356237310F);
-            }
-            else
-            {
-                iEnvelope_man[i] = Qfmt(1.000F);
-            }
-        }
-
-    }
-    for (i = 0; i < nNoiseFactors; i++)
-    {
-        /*  sbrNoiseFloorLevel[i] varies from -31 to 31 if no coupling is used */
-
-        sbrNoiseFloorLevel_exp[i] = NOISE_FLOOR_OFFSET - sbrNoiseFloorLevel_man[i];
-        sbrNoiseFloorLevel_man[i] = 0x40000000;
-    }
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h b/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h
deleted file mode 100644
index 2113586..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_requantize_envelope_data.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_requantize_envelope_data.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
-----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_REQUANTIZE_ENVELOPE_DATA_H
-#define SBR_REQUANTIZE_ENVELOPE_DATA_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sbr_frame_data.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_requantize_envelope_data(SBR_FRAME_DATA * hFrameData);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp b/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp
deleted file mode 100644
index 810a34a..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_reset_dec.cpp
+++ /dev/null
@@ -1,269 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_reset_dec.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    resets sbr decoder structure
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#ifdef AAC_PLUS
-
-#include    "sbr_dec.h"
-
-#include    "pv_log2.h"
-#include    "fxp_mul32.h"
-
-
-#include    "sbr_reset_dec.h"
-#include    "sbr_find_start_andstop_band.h"
-#include    "sbr_update_freq_scale.h"
-#include    "sbr_downsample_lo_res.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData,
-                        SBR_DEC * sbrDec,
-                        Int32 upsampleFac)
-{
-
-    SBR_ERROR err = SBRDEC_OK;
-    Int lsbM;
-    Int lsb;
-    Int usb;
-    Int32 i;
-    Int32 tmp_q1;
-
-    SBR_HEADER_DATA *headerData  = &(hFrameData->sbr_header);
-    Int32           samplingFreq = sbrDec->outSampleRate;
-
-    hFrameData->reset_flag = 1;
-
-    /*Calculate master frequency function */
-    err = sbr_find_start_andstop_band(samplingFreq,
-                                      headerData->startFreq,
-                                      headerData->stopFreq,
-                                      &lsbM,
-                                      &usb);
-
-    if (err != SBRDEC_OK)
-    {
-        return err;
-    }
-
-    /* Calculate new v_k_master if needed */
-    if (headerData->masterStatus == MASTER_RESET)
-    {
-        sbr_update_freq_scale(sbrDec->V_k_master,
-                              &(sbrDec->Num_Master),
-                              lsbM,
-                              usb,
-                              headerData->freqScale,
-                              headerData->alterScale,
-                              0);
-
-    }
-
-    /*Derive Hiresolution from master frequency function*/
-
-    sbrDec->NSfb[HI] = sbrDec->Num_Master - headerData->xover_band;
-
-    for (i = headerData->xover_band; i <= sbrDec->Num_Master; i++)
-    {
-        sbrDec->FreqBandTable[HI][i-headerData->xover_band] = (Int)sbrDec->V_k_master[i];
-    }
-
-
-    if ((sbrDec->NSfb[HI] & 0x01) == 0) /* if even number of hires bands */
-    {
-
-        sbrDec->NSfb[LO] = sbrDec->NSfb[HI] >> 1;
-        /* Use every second lo-res=hi-res[0,2,4...] */
-        for (i = 0; i <= sbrDec->NSfb[LO]; i++)
-        {
-            sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)];
-        }
-    }
-    else
-    {            /* odd number of hi-res which means xover is odd */
-
-        sbrDec->NSfb[LO] = (sbrDec->NSfb[HI] + 1) >> 1;
-        /* Use lo-res=hi-res[0,1,3,5 ...] */
-        sbrDec->FreqBandTable[LO][0] = sbrDec->FreqBandTable[HI][0];
-        for (i = 1; i <= sbrDec->NSfb[LO]; i++)
-        {
-            sbrDec->FreqBandTable[LO][i] = sbrDec->FreqBandTable[HI][(i<<1)-1];
-        }
-
-    }
-
-    lsb = sbrDec->FreqBandTable[LOW_RES][0];
-    usb = sbrDec->FreqBandTable[LOW_RES][sbrDec->NSfb[LOW_RES]];
-
-    sbrDec->lowSubband  = lsb;
-    sbrDec->highSubband = usb;
-    sbrDec->noSubbands  = usb - lsb;
-
-    if ((lsb > 32) || (sbrDec->noSubbands <= 0))
-    {
-        return SBRDEC_ILLEGAL_SCFACTORS;   /* invalid bands */
-    }
-
-    /* Calculate number of noise bands */
-    if (headerData->noise_bands == 0)
-    {
-        sbrDec->NoNoiseBands = 1;
-    }
-    else /* Calculate number of noise bands 1,2 or 3 bands/octave */
-    {
-
-        if (! lsb)
-        {
-            return SBRDEC_ILLEGAL_SCFACTORS;   /* avoid div by 0 */
-        }
-
-        tmp_q1 = pv_log2((usb << 20) / lsb);
-
-        tmp_q1 = fxp_mul32_Q15(headerData->noise_bands, tmp_q1);
-
-        sbrDec->NoNoiseBands = (tmp_q1 + 16) >> 5;
-
-        if (sbrDec->NoNoiseBands == 0)
-        {
-            sbrDec->NoNoiseBands = 1;
-        }
-    }
-
-    headerData->noNoiseBands = sbrDec->NoNoiseBands;
-
-    /* Get noise bands */
-    sbr_downsample_lo_res(sbrDec->FreqBandTableNoise,
-                          sbrDec->NoNoiseBands,
-                          sbrDec->FreqBandTable[LO],
-                          sbrDec->NSfb[LO]);
-
-    sbrDec->sbStopCodec = sbrDec->lowSubband;
-
-    if (sbrDec->sbStopCodec > (upsampleFac << 5))
-    {
-        sbrDec->sbStopCodec = (upsampleFac << 5);
-    }
-
-    hFrameData->nSfb[LO] = sbrDec->NSfb[LO];
-    hFrameData->nSfb[HI] = sbrDec->NSfb[HI];
-    hFrameData->nNfb     = hFrameData->sbr_header.noNoiseBands;
-    hFrameData->offset   = ((hFrameData->nSfb[LO]) << 1) - hFrameData->nSfb[HI];
-
-    return (SBRDEC_OK);
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_reset_dec.h b/media/libstagefright/codecs/aacdec/sbr_reset_dec.h
deleted file mode 100644
index 0ff94a5..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_reset_dec.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_reset_dec.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
- $Id: ct_envcalc.h,v 1.3 2002/11/29 16:11:49 kaehleof Exp $
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_RESET_DEC_H
-#define SBR_RESET_DEC_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include    "s_sbr_frame_data.h"
-#include    "sbr_dec.h"
-#include    "e_sbr_error.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-SBR_ERROR sbr_reset_dec(SBR_FRAME_DATA * hFrameData,
-                        SBR_DEC * sbrDec,
-                        Int32 upsampleFac);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp b/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp
deleted file mode 100644
index 18bd5d9..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.cpp
+++ /dev/null
@@ -1,364 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_update_freq_scale.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-SC 29 Software Copyright Licencing Disclaimer:
-
-This software module was originally developed by
-  Coding Technologies
-
-and edited by
-  -
-
-in the course of development of the ISO/IEC 13818-7 and ISO/IEC 14496-3
-standards for reference purposes and its performance may not have been
-optimized. This software module is an implementation of one or more tools as
-specified by the ISO/IEC 13818-7 and ISO/IEC 14496-3 standards.
-ISO/IEC gives users free license to this software module or modifications
-thereof for use in products claiming conformance to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International
-Standards. ISO/IEC gives users the same free license to this software module or
-modifications thereof for research purposes and further ISO/IEC standardisation.
-Those intending to use this software module in products are advised that its
-use may infringe existing patents. ISO/IEC have no liability for use of this
-software module or modifications thereof. Copyright is not released for
-products that do not conform to audiovisual and image-coding related ITU
-Recommendations and/or ISO/IEC International Standards.
-The original developer retains full right to modify and use the code for its
-own purpose, assign or donate the code to a third party and to inhibit third
-parties from using the code for products that do not conform to audiovisual and
-image-coding related ITU Recommendations and/or ISO/IEC International Standards.
-This copyright notice must be included in all copies or derivative works.
-Copyright (c) ISO/IEC 2002.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include    "sbr_update_freq_scale.h"
-#include    "shellsort.h"
-
-#include    "pv_pow2.h"
-#include    "pv_log2.h"
-
-#include "fxp_mul32.h"
-#define R_SHIFT     30
-#define Q_fmt(x)    (Int32)(x*((Int32)1<<R_SHIFT) + (x>=0?0.5F:-0.5F))
-#define Q28fmt(x)   (Int32)(x*((Int32)1<<28) + (x>=0?0.5F:-0.5F))
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void sbr_update_freq_scale(Int32 * v_k_master,
-                           Int32 *h_num_bands,
-                           const Int32 lsbM,
-                           const Int32 usb,
-                           const Int32 freqScale,
-                           const Int32 alterScale,
-                           const Int32 channelOffset)
-{
-    Int32 i;
-    Int32 numBands = 0;
-    Int32 numBands2;
-    Int32 tmp_q1;
-
-    if (freqScale > 0) /*Bark mode*/
-    {
-        Int32 reg;
-        Int32 regions;
-        Int32 b_p_o;
-        Int32 k[3];
-        Int32 d[MAX_SECOND_REGION];
-        Int32 d2[MAX_SECOND_REGION];
-        Int32 w[2] = {Q_fmt(1.0F), Q_fmt(1.0F)};
-
-
-        k[0] = lsbM;
-        k[1] = usb;
-        k[2] = usb;
-
-        b_p_o = (freqScale == 1)  ? 12 : 8;
-        b_p_o = (freqScale == 2)  ? 10 : b_p_o;
-
-        w[1]  = (alterScale == 0) ? Q_fmt(0.5f) : Q_fmt(0.384615384615386f);
-
-        if (usb > fxp_mul32_Q28(lsbM, Q28fmt(2.2449)))
-        {
-            regions = 2;
-            k[1] = (lsbM << 1);
-        }
-        else
-        {
-            regions = 1;
-        }
-
-        *h_num_bands = 0;
-        for (reg = 0; reg < regions; reg++)
-        {
-            if (reg == 0)
-            {
-
-                tmp_q1 = pv_log2((k[1] << 20) / k[0]);
-
-                tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o);
-                tmp_q1 = (tmp_q1 + 32) >> 6;
-
-                numBands = tmp_q1 << 1;
-
-
-                CalcBands(d, k[0], k[1], numBands);                                    /* CalcBands => d   */
-                shellsort(d, numBands);                                              /* SortBands sort d */
-                cumSum(k[0] - channelOffset,
-                       d,
-                       numBands,
-                       (v_k_master + *h_num_bands));   /* cumsum */
-
-                *h_num_bands += numBands;                                            /* Output nr of bands */
-            }
-            else
-            {
-                tmp_q1 = pv_log2((k[reg + 1] << 20) / k[reg]);
-
-                tmp_q1 = fxp_mul32_Q30(tmp_q1, w[reg]);
-                tmp_q1 = fxp_mul32_Q15(tmp_q1, b_p_o);
-                tmp_q1 = (tmp_q1 + 16) >> 5;
-
-                numBands2 = tmp_q1 << 1;
-
-                CalcBands(d2, k[reg], k[reg+1], numBands2);                            /* CalcBands => d   */
-                shellsort(d2, numBands2);                                              /* SortBands sort d */
-                if (d[numBands-1] > d2[0])
-                {
-
-                    Int32   change = d[numBands-1] - d2[0];
-                    /* Limit the change so that the last band cannot get narrower than the first one */
-                    if (change > (d2[numBands2-1] - d2[0]) >> 1)
-                    {
-                        change = (d2[numBands2-1] - d2[0]) >> 1;
-                    }
-
-                    d2[0] += change;
-                    d2[numBands2-1] -= change;
-                    shellsort(d2, numBands2);
-
-                }
-                cumSum(k[reg] - channelOffset,
-                       d2,
-                       numBands2,
-                       v_k_master + *h_num_bands);   /* cumsum */
-
-                *h_num_bands += numBands2;                                           /* Output nr of bands */
-            }
-        }
-    }
-    else
-    {                         /* Linear mode */
-        Int32     k2_achived;
-        Int32     k2_diff;
-        Int32     diff_tot[MAX_OCTAVE + MAX_SECOND_REGION];
-        Int32     dk;
-        Int32     incr = 0;
-
-
-        if (alterScale)
-        {
-            numBands = (usb - lsbM) >> 1;
-            dk = 1;
-            k2_achived = lsbM + numBands;
-        }
-        else
-        {
-            numBands = usb - lsbM;
-            if (numBands & 0x1) /* equivalent rounding */
-            {
-                numBands--;
-            }
-            dk = 2;
-            k2_achived = lsbM + (numBands << 1);
-        }
-
-        k2_diff = usb - k2_achived;
-
-        for (i = 0; i < numBands; i++)
-        {
-            diff_tot[i] = dk;
-        }
-
-        if (k2_diff < 0)        /* If linear scale wasn't achived */
-        {
-            incr = 1;           /* and we got too large SBR area */
-            i = 0;
-        }
-
-        if (k2_diff > 0)        /* If linear scale wasn't achived */
-        {
-            incr = -1;            /* and we got too small SBR area */
-            i = numBands - 1;
-        }
-
-        /* Adjust diff vector to get spec. SBR range */
-        while (k2_diff != 0)
-        {
-            diff_tot[i] -=  incr;
-            i += incr;
-            k2_diff += incr;
-        }
-
-        cumSum(lsbM,
-               diff_tot,
-               numBands,
-               v_k_master); /* cumsum */
-
-        *h_num_bands = numBands;                      /* Output nr of bands */
-    }
-}
-
-
-void CalcBands(Int32 * diff,
-               Int32 start,
-               Int32 stop,
-               Int32 num_bands)
-{
-    Int32 i;
-    Int32 previous;
-    Int32 current;
-    Int32 tmp_q1;
-
-
-    previous = start;
-
-    for (i = 1; i <= num_bands; i++)
-    {
-        /*              float temp=(start * pow( (float)stop/start, (float)i/num_bands)); */
-
-        tmp_q1 = pv_log2((stop << 20) / start);
-
-        tmp_q1 = fxp_mul32_Q20(tmp_q1, (i << 27) / num_bands);
-        tmp_q1 = pv_pow2(tmp_q1);
-
-        tmp_q1 = fxp_mul32_Q20(tmp_q1, start);
-
-        current = (tmp_q1 + 16) >> 5;
-
-        diff[i-1] = current - previous;
-        previous  = current;
-    }
-
-}  /* End CalcBands */
-
-
-void cumSum(Int32 start_value,
-            Int32 * diff,
-            Int32 length,
-            Int32 * start_adress)
-{
-    Int32 i;
-    Int32 *pt_start_adress   = start_adress;
-    Int32 *pt_start_adress_1 = start_adress;
-    Int32 *pt_diff           = diff;
-
-    if (length > 0)  /*  avoid possible error on loop */
-    {
-        *(pt_start_adress_1++) = start_value;
-
-        for (i = (length >> 1); i != 0; i--)
-        {
-            *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++);
-            *(pt_start_adress_1++) = *(pt_start_adress++) + *(pt_diff++);
-        }
-
-        if (length&1)
-        {
-            *(pt_start_adress_1) = *(pt_start_adress) + *(pt_diff);
-        }
-    }
-
-}   /* End cumSum */
-
-
-#endif
diff --git a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h b/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h
deleted file mode 100644
index 4acf3aa..0000000
--- a/media/libstagefright/codecs/aacdec/sbr_update_freq_scale.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: sbr_update_freq_scale.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SBR_UPDATE_FREQ_SCALE_H
-#define SBR_UPDATE_FREQ_SCALE_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define MAX_OCTAVE        29
-#define MAX_SECOND_REGION 50
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void sbr_update_freq_scale(Int32 * v_k_master,
-                           Int32 *h_num_bands,
-                           const Int32 lsbM,
-                           const Int32 usb,
-                           const Int32 freqScale,
-                           const Int32 alterScale,
-                           const Int32 channelOffset);
-
-
-void CalcBands(Int32 * diff,
-               Int32 start,
-               Int32 stop,
-               Int32 num_bands);
-
-void cumSum(Int32 start_value,
-            Int32 * diff,
-            Int32 length,
-            Int32 * start_adress);
-
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/set_mc_info.cpp b/media/libstagefright/codecs/aacdec/set_mc_info.cpp
deleted file mode 100644
index 5a11941..0000000
--- a/media/libstagefright/codecs/aacdec/set_mc_info.cpp
+++ /dev/null
@@ -1,309 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/set_mc_info.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified per review comments
-
- Description: Change audioObjectType from Int to enum types
-
- Who:                               Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    pMC_Info    = pointer to structure MC_Info that holds information of
-                  multiple channels' configurations
-                  Data type pointer to MC_Info
-
-    objectType  = variable that holds the Audio Object Type of current
-                  file/bitstream.
-                  Data type Int
-
-    sampling_rate_idx = variable that indicates the sampling rate of the
-                        source file being encoded
-                        Data Type Int
-
-    tag         = variable that stores the element instance tag of the
-                  first (front) channel element.
-                  Data type Int
-
-    is_cpe      = variable that indicates if a Channel Pair Element (CPE)
-                  or a Single Channel Element (SCE) is used.
-                  Data type Int (maybe Boolean)
-
-    pWinSeqInfo = array of pointers that points to structures holding
-                  frame information of long and short window sequences.
-                  Data type FrameInfo
-
-    pSfbwidth128 = array that will store the scalefactor bandwidth of
-                   short window sequence frame.
-                   Data type Int array
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    return SUCCESS
-
- Pointers and Buffers Modified:
-    pMC_Info->nch           contains the number of channels depending
-                            upon if CPE or SCE is used
-    pMC_Info->objectType    contents updated with the decoded Audio
-                            Object Type
-
-    pMC_Info->ch_info.tag   contents updated with the value of decoded
-                            channel element tag
-
-    PMC_Info->ch_info.cpe   contents updated depending upon if CPE or
-                            SCE is used
-
-    pWinSeqInfo             contents updated by calling infoinit if
-                            sampling_rate_idx is different from
-                            previous value
-
-    pSfbWidth128            contents updated by calling infoinit if
-                            sampling_rate_idx is different from
-                            previous value
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function initializes the channel configuration information. The
- structure MC_Info stores the number of channels, channel element tag.
- If sampling rate index is different from the previous value,
- The frame information will be updated by calling infoinit.c
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall update the relevant information on channel configs
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-  (2) ISO/IEC 14496-3: 1999(E)
-    Subpart 1   p20 Table 1.6.3
-    Subpart 4   p30 5.1.2.1
-    Subpart 4   p31 4.5.2.1.1
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    pMC_Info->nch   = 0;
-
-    pMC_Info->profile = objectType;
-
-    IF (pMC_Info->sampling_rate_idx != sampling_rate_idx)
-    THEN
-        pMC_Info->sampling_rate_idx = sampling_rate_idx;
-
-        CALL infoinit(
-                samp_rate_idx = sampling_rate_idx
-                ppWin_seq_info= pWinSeqInfo
-                pSfbwidth128  = pSfbwidth128)
-        MODIFYING(pWinSeqInfo, pSfbwidth128)
-        RETURNING(None)
-    ENDIF
-
-    pCh_Info = &pMC_Info->ch_info[0];
-    pCh_Info->tag = tag;
-
-    IF (is_cpe == FALSE)
-    THEN
-        pCh_Info->cpe = FALSE;
-
-        pMC_Info->nch = 1;
-
-    ELSE
-        pCh_Info->cpe = TRUE;
-        pCh_Info = &pMC_Info->ch_info[1];
-        pCh_Info->tag = tag;
-        pCh_Info->cpe = TRUE;
-
-        pMC_Info->nch = 2;
-
-    ENDIF
-
-    RETURN(SUCCESS)
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "set_mc_info.h"
-#include    "huffman.h"
-#include    "s_ch_info.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-Int set_mc_info(
-    MC_Info     *pMC_Info,
-    const tMP4AudioObjectType audioObjectType, /* used to be profile */
-    const Int    sampling_rate_idx,
-    const Int    tag,   /* always pass-in last element's value */
-    const Int    is_cpe,
-    FrameInfo   *pWinSeqInfo[],
-    Int          sfbwidth128[]
-)
-{
-    Ch_Info *pCh_Info; /*optional task: eliminate this structure */
-
-    /*
-     *   audioObjectType and sampling rate
-     *   re-configure if new sampling rate
-     *
-     */
-    pMC_Info->audioObjectType = audioObjectType;
-
-    if (pMC_Info->sampling_rate_idx != sampling_rate_idx)
-    {
-        pMC_Info->sampling_rate_idx = sampling_rate_idx;
-
-        Int status;
-        status = infoinit(sampling_rate_idx,
-                          pWinSeqInfo,
-                          sfbwidth128);
-        if (SUCCESS != status)
-        {
-            return 1;
-        }
-    }
-
-    /*
-     * first setup values for mono config, Single Channel Element (SCE)
-     * then if stereo, go inside if(is_cpe != FALSE) branch to setup
-     * values for stereo.
-     * set the channel counts
-     * save tag for left channel
-     */
-    pMC_Info->nch   = 1 + is_cpe;
-
-    pCh_Info = &pMC_Info->ch_info[0];
-    pCh_Info->tag = tag;
-    pCh_Info->cpe = is_cpe;
-
-    /* This if branch maybe deleted in the future */
-    if (is_cpe != FALSE)
-    {
-        /* Channel Pair Element (CPE) */
-        /* right channel*/
-        pCh_Info = &pMC_Info->ch_info[1];
-        pCh_Info->cpe = TRUE;
-
-    }
-
-    return(SUCCESS); /* possible future error checkings */
-}
diff --git a/media/libstagefright/codecs/aacdec/set_mc_info.h b/media/libstagefright/codecs/aacdec/set_mc_info.h
deleted file mode 100644
index 8043b3b..0000000
--- a/media/libstagefright/codecs/aacdec/set_mc_info.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/set_mc_info.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: (1) use enum type for audioObjectType (2) update revision history
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This file includes function declaration for set_mc_info.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SET_MC_INFO_H
-#define SET_MC_INFO_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_mc_info.h"
-#include    "s_frameinfo.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-Int set_mc_info(
-    MC_Info     *pMC_Info,
-    const tMP4AudioObjectType objectType, /* used to be profile */
-    const Int    sampling_rate_idx,
-    const Int    tag,   /* always pass-in last element's value */
-    const Int    is_cpe,
-    FrameInfo   *pWinSeqInfo[],
-    Int          pSfbwidth128[]
-);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/sfb.cpp b/media/libstagefright/codecs/aacdec/sfb.cpp
deleted file mode 100644
index f2d3a3e..0000000
--- a/media/libstagefright/codecs/aacdec/sfb.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/sfb.c
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: created to define the scalefactor bands for all sampling rates
-
- Description: Change short to Int16
-
- Description: Modified structure to avoid assigning addresses to constant
-              tables. This solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers
-              - Eliminated redundant vector sfb_96_128.
-              - Eliminated references to contant vector addresses in
-                samp_rate_info
-
- Who:                              Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
- Local Stores/Buffers/Pointers Needed:
-
- Global Stores/Buffers/Pointers Needed:
-
- Outputs:
-
- Pointers and Buffers Modified:
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function defines the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3: 1999(E)
-    Subpart 4       p66     (sfb tables)
-                    p111    (4.6.10)
-                    p200    (Annex 4.B.5)
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "sfb.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-const Int16 sfb_96_1024[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    32, 36, 40, 44, 48, 52, 56,
-    64, 72, 80, 88, 96, 108, 120,
-    132, 144, 156, 172, 188, 212, 240,
-    276, 320, 384, 448, 512, 576, 640,
-    704, 768, 832, 896, 960, 1024
-};         /* 41 scfbands */
-
-const Int16 sfb_64_1024[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    32, 36, 40, 44, 48, 52, 56,
-    64, 72, 80, 88, 100, 112, 124,
-    140, 156, 172, 192, 216, 240, 268,
-    304, 344, 384, 424, 464, 504, 544,
-    584, 624, 664, 704, 744, 784, 824,
-    864, 904, 944, 984, 1024
-};               /* 41 scfbands 47 */
-
-const Int16 sfb_64_128[] =
-{
-    4, 8, 12, 16, 20, 24, 32,
-    40, 48, 64, 92, 128
-};                   /* 12 scfbands */
-
-
-const Int16 sfb_48_1024[] =
-{
-    4,  8,  12, 16, 20, 24, 28,
-    32, 36, 40, 48, 56, 64, 72,
-    80, 88, 96, 108,    120,    132,    144,
-    160,    176,    196,    216,    240,    264,    292,
-    320,    352,    384,    416,    448,    480,    512,
-    544,    576,    608,    640,    672,    704,    736,
-    768,    800,    832,    864,    896,    928,    1024
-};
-/* 49  scfbands*/
-
-const Int16 sfb_48_128[] =
-{
-    4,  8,  12, 16, 20, 28, 36,
-    44, 56, 68, 80, 96, 112, 128
-};         /* 14 scfbands */
-
-const Int16 sfb_32_1024[] =
-{
-    4,  8,  12, 16, 20, 24, 28,
-    32, 36, 40, 48, 56, 64, 72,
-    80, 88, 96, 108,    120,    132,    144,
-    160,    176,    196,    216,    240,    264,    292,
-    320,    352,    384,    416,    448,    480,    512,
-    544,    576,    608,    640,    672,    704,    736,
-    768,    800,    832,    864,    896,    928,    960,
-    992,    1024
-};                         /* 51 scfbands */
-
-const Int16 sfb_24_1024[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    32, 36, 40, 44, 52, 60, 68,
-    76, 84, 92, 100, 108, 116, 124,
-    136, 148, 160, 172, 188, 204, 220,
-    240, 260, 284, 308, 336, 364, 396,
-    432, 468, 508, 552, 600, 652, 704,
-    768, 832, 896, 960, 1024
-};              /* 47 scfbands */
-
-const Int16 sfb_24_128[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    36, 44, 52, 64, 76, 92, 108,
-    128
-};                                   /* 15 scfbands */
-
-const Int16 sfb_16_1024[] =
-{
-    8, 16, 24, 32, 40, 48, 56,
-    64, 72, 80, 88, 100, 112, 124,
-    136, 148, 160, 172, 184, 196, 212,
-    228, 244, 260, 280, 300, 320, 344,
-    368, 396, 424, 456, 492, 532, 572,
-    616, 664, 716, 772, 832, 896, 960,
-    1024
-};                                  /* 43 scfbands */
-
-const Int16 sfb_16_128[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    32, 40, 48, 60, 72, 88, 108,
-    128
-};                                   /* 15 scfbands */
-
-const Int16 sfb_8_1024[] =
-{
-    12, 24, 36, 48, 60, 72, 84,
-    96, 108, 120, 132, 144, 156, 172,
-    188, 204, 220, 236, 252, 268, 288,
-    308, 328, 348, 372, 396, 420, 448,
-    476, 508, 544, 580, 620, 664, 712,
-    764, 820, 880, 944, 1024
-};               /* 40 scfbands */
-
-const Int16 sfb_8_128[] =
-{
-    4, 8, 12, 16, 20, 24, 28,
-    36, 44, 52, 60, 72, 88, 108,
-    128
-};                                   /* 15 scfbands */
-
-const SR_Info samp_rate_info[12] =
-{
-    /* sampling_frequency, #long sfb, #short sfb */
-    /* samp_rate, nsfb1024, nsfb128 */
-    {96000, 41, 12},       /* 96000 */
-    {88200, 41, 12},       /* 88200 */
-    {64000, 47, 12},       /* 64000 */
-    {48000, 49, 14},       /* 48000 */
-    {44100, 49, 14},       /* 44100 */
-    {32000, 51, 14},       /* 32000 */
-    {24000, 47, 15},       /* 24000 */
-    {22050, 47, 15},       /* 22050 */
-    {16000, 43, 15},       /* 16000 */
-    {12000, 43, 15},       /* 12000 */
-    {11025, 43, 15},       /* 11025 */
-    { 8000, 40, 15},       /* 8000  */
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
diff --git a/media/libstagefright/codecs/aacdec/sfb.h b/media/libstagefright/codecs/aacdec/sfb.h
deleted file mode 100644
index 0cc1707..0000000
--- a/media/libstagefright/codecs/aacdec/sfb.h
+++ /dev/null
@@ -1,117 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: sfb.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: created to declare scalefactor bands for all sampling rates
-
- Description: Change short to Int16
-
- Description: Eliminated declaration of sfb_96_128 array, values are equal
-              to array sfb_64_128
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- this file declares the scalefactor bands for all sampling rates
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SFB_H
-#define SFB_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_sr_info.h"
-#include    "e_progconfigconst.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-extern  const Int16 sfb_96_1024[];  /* 41 scfbands */
-
-extern const Int16 sfb_64_1024[];  /* 41 scfbands 47 */
-
-extern const Int16 sfb_64_128[];  /* 12 scfbands */
-
-
-extern const Int16 sfb_48_1024[]; /* 49 scfbands */
-
-extern const Int16 sfb_48_128[];  /* 14 scfbands */
-
-extern const Int16 sfb_32_1024[];  /* 51 scfbands */
-
-extern const Int16 sfb_24_1024[];  /* 47 scfbands */
-
-extern const Int16 sfb_24_128[];  /* 15 scfbands */
-
-extern const Int16 sfb_16_1024[];  /* 43 scfbands */
-
-extern const Int16 sfb_16_128[];  /* 15 scfbands */
-
-extern const Int16 sfb_8_1024[];  /* 40 scfbands */
-
-extern const Int16 sfb_8_128[];  /* 15 scfbands */
-
-extern const SR_Info samp_rate_info[12];
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/shellsort.cpp b/media/libstagefright/codecs/aacdec/shellsort.cpp
deleted file mode 100644
index 5feb803..0000000
--- a/media/libstagefright/codecs/aacdec/shellsort.cpp
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: shellsort.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-        Sorting routine
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "shellsort.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-void shellsort(Int32 in[], Int32 n)
-{
-
-    Int32     i;
-    Int32     j;
-    Int32     v;
-    Int32     inc = 1;
-
-    do
-    {
-        inc = 3 * inc + 1;
-    }
-    while (inc <= n);
-
-    do
-    {
-        inc = inc / 3;
-        for (i = inc + 1; i <= n; i++)
-        {
-            v = in[i-1];
-            j = i;
-            while (in[j-inc-1] > v)
-            {
-                in[j-1] = in[j-inc-1];
-                j -= inc;
-                if (j <= inc)
-                {
-                    break;
-                }
-            }
-            in[j-1] = v;
-        }
-    }
-    while (inc > 1);
-
-}
-
-#endif
-
diff --git a/media/libstagefright/codecs/aacdec/shellsort.h b/media/libstagefright/codecs/aacdec/shellsort.h
deleted file mode 100644
index a4658e3..0000000
--- a/media/libstagefright/codecs/aacdec/shellsort.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: shellsort.h
- Funtions:
-    get_dse
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-------------------------------------------------------------------------------
-
-
- ----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef SHELLSORT_H
-#define SHELLSORT_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-void shellsort(Int32 in[], Int32 n);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/stereo_2_mono.h b/media/libstagefright/codecs/aacdec/stereo_2_mono.h
deleted file mode 100644
index 3e27c70..0000000
--- a/media/libstagefright/codecs/aacdec/stereo_2_mono.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: stereo_2_mono.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the declaration of the function stereo_2_mono()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef STEREO_2_MONO_H
-#define STEREO_2_MONO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    void stereo_2_mono(
-        const Int16   sourceLeft[],
-        const Int16   sourceRight[],
-        Int16   outputBuffer[],
-        const Int     sourcePointsPerChannel);
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* STEREO_2_MONO_H */
-
diff --git a/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp b/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp
deleted file mode 100644
index c1418e3..0000000
--- a/media/libstagefright/codecs/aacdec/synthesis_sub_band.cpp
+++ /dev/null
@@ -1,483 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Filename: synthesis_sub_band.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
-
- Who:                                   Date: MM/DD/YYYY
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
-    Int32 vec[],            Input vector, 32-bit
-    const Int32 *cosTerms,  Cosine Terms
-    Int32 *scratch_mem      Scratch memory
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    Implement root squared of a number
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-#include "pv_audio_type_defs.h"
-#include "fxp_mul32.h"
-#include "dct64.h"
-#include "synthesis_sub_band.h"
-#include "mdst.h"
-#include "dct16.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-#define Qfmt_30(x)   (Int32)(x*((Int32)(1<<30)) + (x>=0?0.5F:-0.5F))
-#define Qfmt_25(x)   (Int32)(x*((Int32)(1<<25))*(1.5625F) + (x>=0?0.5F:-0.5F))
-
-#define SCALE_DOWN_LP   Qfmt_30(0.075000F)  /* 3/40 */
-#define SCALE_DOWN_HQ     Qfmt_30(0.009375F*0.64F)  /* 3/40 * 1/8 */
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-const Int32 CosTable_64[64] =
-{
-    Qfmt_25(0.50003765191555F),   Qfmt_25(40.74468810335183F),   Qfmt_25(0.50033903744282F),   Qfmt_25(13.58429025728446F),
-    Qfmt_25(0.50094271763809F),   Qfmt_25(8.15384860246681F),   Qfmt_25(0.50185051748424F),   Qfmt_25(5.82768837784465F),
-    Qfmt_25(0.50306519130137F),   Qfmt_25(4.53629093696936F),   Qfmt_25(0.50459044322165F),   Qfmt_25(3.71524273832697F),
-    Qfmt_25(0.50643095492855F),   Qfmt_25(3.14746219178191F),   Qfmt_25(0.50859242104981F),   Qfmt_25(2.73164502877394F),
-    Qfmt_25(0.51108159270668F),   Qfmt_25(2.41416000025008F),   Qfmt_25(0.51390632984754F),   Qfmt_25(2.16395781875198F),
-    Qfmt_25(0.51707566313349F),   Qfmt_25(1.96181784857117F),   Qfmt_25(0.52059986630189F),   Qfmt_25(1.79520521907789F),
-    Qfmt_25(0.52449054011472F),   Qfmt_25(1.65559652426412F),   Qfmt_25(0.52876070920749F),   Qfmt_25(1.53699410085250F),
-    Qfmt_25(0.53342493339713F),   Qfmt_25(1.43505508844143F),   Qfmt_25(0.53849943529198F),   Qfmt_25(1.34655762820629F),
-    Qfmt_25(0.54400224638178F),   Qfmt_25(1.26906117169912F),   Qfmt_25(0.54995337418324F),   Qfmt_25(1.20068325572942F),
-    Qfmt_25(0.55637499348989F),   Qfmt_25(1.13994867510150F),   Qfmt_25(0.56329166534170F),   Qfmt_25(1.08568506425801F),
-    Qfmt_25(0.57073058801215F),   Qfmt_25(1.03694904091039F),   Qfmt_25(0.57872188513482F),   Qfmt_25(0.99297296126755F),
-    Qfmt_25(0.58729893709379F),   Qfmt_25(0.95312587439212F),   Qfmt_25(0.59649876302446F),   Qfmt_25(0.91688444618465F),
-    Qfmt_25(0.60636246227215F),   Qfmt_25(0.88381100455962F),   Qfmt_25(0.61693572600507F),   Qfmt_25(0.85353675100661F),
-    Qfmt_25(0.62826943197077F),   Qfmt_25(0.82574877386279F),   Qfmt_25(0.64042033824166F),   Qfmt_25(0.80017989562169F),
-    Qfmt_25(0.65345189537513F),   Qfmt_25(0.77660065823396F),   Qfmt_25(0.66743520092634F),   Qfmt_25(0.75481293911653F),
-    Qfmt_25(0.68245012597642F),   Qfmt_25(0.73464482364786F),   Qfmt_25(0.69858665064723F),   Qfmt_25(0.71594645497057F),
-};
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void synthesis_sub_band_LC(Int32 Sr[], Int16 data[])
-{
-
-    Int32 *temp_o1 = (Int32 *) & data[0];
-
-    Int   i;
-    Int32 *pt_temp_e;
-    Int32 *pt_temp_o = temp_o1;
-    Int32 *pt_temp_x = &Sr[63];
-    Int32 temp1;
-    Int32 temp2;
-    Int32 temp3;
-    Int32 temp11;
-
-    Int16 *pt_data_1;
-    Int16 *pt_data_2;
-
-    Int32 *pt_Sr_1 = Sr;
-    Int16 tmp1;
-    Int16 tmp2;
-    Int16 tmp11;
-    Int16 tmp22;
-    const Int32 *pt_cosTerms = CosTable_48;
-
-
-    temp2 = *(pt_temp_x--);
-    for (i = 20; i != 0; i--)
-    {
-        temp1 = *(pt_Sr_1);
-        temp3 = *(pt_cosTerms++);
-        *(pt_Sr_1++) =   temp1  + temp2;
-        *(pt_temp_o++) = fxp_mul32_Q31((temp1 - temp2), temp3) << 1;
-        temp2 = *(pt_temp_x--);
-    }
-
-    for (i = 12; i != 0; i--)
-    {
-        temp1 = *(pt_Sr_1);
-        temp3 = *(pt_cosTerms++);
-        *(pt_Sr_1++) =   temp1  + temp2;
-        *(pt_temp_o++) = fxp_mul32_Q26((temp1 - temp2), temp3);
-        temp2 = *(pt_temp_x--);
-    }
-
-
-    pv_split_LC(temp_o1, &Sr[32]);
-
-    dct_16(temp_o1, 1);     // Even terms
-    dct_16(&Sr[32], 1);     // Odd  terms
-
-    /* merge */
-
-
-    pt_Sr_1 = &temp_o1[31];
-    pt_temp_e   =  &temp_o1[15];
-    pt_temp_o   =  &Sr[47];
-
-    temp1 = *(pt_temp_o--);
-    *(pt_Sr_1--) = temp1;
-    for (i = 5; i != 0; i--)
-    {
-        temp2 = *(pt_temp_o--);
-        *(pt_Sr_1--) = *(pt_temp_e--);
-        *(pt_Sr_1--) = temp1 + temp2;
-        temp3 = *(pt_temp_o--);
-        *(pt_Sr_1--) = *(pt_temp_e--);
-        *(pt_Sr_1--) = temp2 + temp3;
-        temp1 = *(pt_temp_o--);
-        *(pt_Sr_1--) = *(pt_temp_e--);
-        *(pt_Sr_1--) = temp1 + temp3;
-    }
-
-
-    pv_split_LC(Sr, &Sr[32]);
-
-    dct_16(Sr, 1);     // Even terms
-    dct_16(&Sr[32], 1);     // Odd  terms
-
-
-    pt_temp_x   =  &temp_o1[31];
-    pt_temp_e   =  &Sr[15];
-    pt_temp_o   =  &Sr[47];
-
-    pt_data_1 = &data[95];
-
-    temp2  = *(pt_temp_x--);
-    temp11 = *(pt_temp_x--);
-    temp1  = *(pt_temp_o--);
-
-    *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp2, SCALE_DOWN_LP);
-    *(pt_data_1--) = (Int16) fxp_mul32_Q31(temp1, SCALE_DOWN_LP);
-
-    for (i = 5; i != 0; i--)
-    {
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
-        temp3         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
-        temp2          = *(pt_temp_o--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP);
-        temp11         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp2), SCALE_DOWN_LP);
-
-
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp3), SCALE_DOWN_LP);
-        temp1         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
-        temp3          = *(pt_temp_o--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP);
-        temp11         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp2 + temp3), SCALE_DOWN_LP);
-
-
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp1), SCALE_DOWN_LP);
-        temp2         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e--), SCALE_DOWN_LP);
-        temp1          = *(pt_temp_o--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
-        temp11         = *(pt_temp_x--);
-        *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp1 + temp3), SCALE_DOWN_LP);
-    }
-
-    *(pt_data_1--) = (Int16) fxp_mul32_Q31((temp11 + temp2), SCALE_DOWN_LP);
-    *(pt_data_1--) = (Int16) fxp_mul32_Q31(*(pt_temp_e), SCALE_DOWN_LP);
-
-    /* ---- merge ends---- */
-
-
-    pt_data_1 = &data[95];
-    pt_data_2 = &data[96];
-
-    *(pt_data_2++) =   0;
-    tmp1  =  *(pt_data_1--);
-    tmp2  =  *(pt_data_1--);
-    tmp11 =  *(pt_data_1--);
-    tmp22 =  *(pt_data_1--);
-
-    for (i = 7; i != 0; i--)
-    {
-        *(pt_data_2++) = (-tmp1);
-        *(pt_data_2++) = (-tmp2);
-        *(pt_data_2++) = (-tmp11);
-        *(pt_data_2++) = (-tmp22);
-        tmp1  =  *(pt_data_1--);
-        tmp2  =  *(pt_data_1--);
-        tmp11 =  *(pt_data_1--);
-        tmp22 =  *(pt_data_1--);
-    }
-
-
-    *(pt_data_2++) = (-tmp1);
-    *(pt_data_2++) = (-tmp2);
-    *(pt_data_2++) = (-tmp11);
-
-    pt_data_2 = &data[0];
-
-    *(pt_data_2++) =  tmp22;
-    tmp1  =  *(pt_data_1--);
-    tmp2  =  *(pt_data_1--);
-    tmp11 =  *(pt_data_1--);
-    tmp22 =  *(pt_data_1--);
-
-    for (i = 7; i != 0; i--)
-    {
-        *(pt_data_2++) =  tmp1;
-        *(pt_data_2++) =  tmp2;
-        *(pt_data_2++) =  tmp11;
-        *(pt_data_2++) =  tmp22;
-        tmp1  =  *(pt_data_1--);
-        tmp2  =  *(pt_data_1--);
-        tmp11 =  *(pt_data_1--);
-        tmp22 =  *(pt_data_1--);
-    }
-
-    *(pt_data_2++) =  tmp1;
-    *(pt_data_2++) =  tmp2;
-    *(pt_data_2++) =  tmp11;
-    *(pt_data_2)   =  tmp22;
-
-}
-
-
-void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[])
-{
-
-    Int i ;
-    Int16 *pt_data_1;
-
-    pt_data_1 = &data[0];
-
-    dct_32(Sr);
-
-    for (i = 0; i < 16; i++)
-    {
-        pt_data_1[   i] = (Int16)(Sr[16-i] >> 5);
-        pt_data_1[16+i] = (Int16)(Sr[i] >> 5);
-        pt_data_1[32+i] = (Int16)(Sr[16+i] >> 5);
-    }
-    for (i = 0; i < 15; i++)
-    {
-        pt_data_1[49+i] = (Int16)(-Sr[31-i] >> 5);
-    }
-    pt_data_1[48] = 0;
-}
-
-
-#ifdef HQ_SBR
-
-void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[])
-{
-
-
-    Int32 i ;
-    Int16 *pt_data_1;
-    Int16 *pt_data_2;
-    Int32 *pt_Sr_1;
-    Int32 *pt_Sr_2;
-    Int32 *pt_Si_1;
-    Int32 *pt_Si_2;
-
-    Int32 tmp1;
-    Int32 tmp2;
-    Int32 tmp3;
-    Int32 tmp4;
-
-    Int32 cosx;
-    const Int32 *pt_CosTable = CosTable_64;
-
-
-    pt_Sr_1 = &Sr[0];
-    pt_Sr_2 = &Sr[63];
-
-    pt_Si_1 = &Si[0];
-    pt_Si_2 = &Si[63];
-
-
-    tmp3 = *pt_Sr_1;
-
-    for (i = 32; i != 0; i--)
-    {
-        tmp4 = *pt_Si_2;
-        cosx = *(pt_CosTable++);
-        *(pt_Sr_1++) = fxp_mul32_Q31(tmp3, cosx);
-        tmp3 = *pt_Si_1;
-        *(pt_Si_1++) = fxp_mul32_Q31(tmp4, cosx);
-        tmp4 = *pt_Sr_2;
-        cosx = *(pt_CosTable++);
-        *(pt_Si_2--) = fxp_mul32_Q31(tmp3, cosx);
-        *(pt_Sr_2--) = fxp_mul32_Q31(tmp4, cosx);
-        tmp3 = *pt_Sr_1;
-    }
-
-
-    dct_64(Sr, (Int32 *)data);
-    dct_64(Si, (Int32 *)data);
-
-
-    pt_data_1 = &data[0];
-    pt_data_2 = &data[127];
-
-    pt_Sr_1 = &Sr[0];
-    pt_Si_1 = &Si[0];
-
-    tmp1 = *(pt_Sr_1++);
-    tmp3 = *(pt_Sr_1++);
-    tmp2 = *(pt_Si_1++);
-    tmp4 = *(pt_Si_1++);
-
-    for (i = 32; i != 0; i--)
-    {
-        *(pt_data_1++) = (Int16) fxp_mul32_Q31((tmp2 - tmp1), SCALE_DOWN_HQ);
-        *(pt_data_1++) = (Int16) fxp_mul32_Q31(-(tmp3 + tmp4), SCALE_DOWN_HQ);
-        *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp1 + tmp2), SCALE_DOWN_HQ);
-        *(pt_data_2--) = (Int16) fxp_mul32_Q31((tmp3 - tmp4), SCALE_DOWN_HQ);
-
-        tmp1 = *(pt_Sr_1++);
-        tmp3 = *(pt_Sr_1++);
-        tmp2 = *(pt_Si_1++);
-        tmp4 = *(pt_Si_1++);
-    }
-
-}
-
-
-const Int32 exp_m0_25_phi[32] =
-{
-
-    0x7FFEFE6E,  0x7FEAFB4A, 0x7FC2F827, 0x7F87F505,
-    0x7F38F1E4,  0x7ED6EEC6, 0x7E60EBAB, 0x7DD6E892,
-    0x7D3AE57D,  0x7C89E26D, 0x7BC6DF61, 0x7AEFDC59,
-    0x7A06D958,  0x790AD65C, 0x77FBD367, 0x76D9D079,
-    0x75A6CD92,  0x7460CAB2, 0x7308C7DB, 0x719EC50D,
-    0x7023C248,  0x6E97BF8C, 0x6CF9BCDA, 0x6B4BBA33,
-    0x698CB796,  0x67BDB505, 0x65DEB27F, 0x63EFB005,
-    0x61F1AD97,  0x5FE4AB36, 0x5DC8A8E2, 0x5B9DA69C
-};
-
-void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[])
-{
-
-    Int16 k;
-    Int16 *pt_data_1;
-    Int32 exp_m0_25;
-    const Int32 *pt_exp = exp_m0_25_phi;
-
-    Int32 *XX = Sr;
-    Int32 *YY = (Int32 *)data;
-    Int32 tmp1;
-    Int32 tmp2;
-
-    for (k = 0; k < 32; k++)
-    {
-        exp_m0_25 = *(pt_exp++);
-        tmp1 = Sr[k];
-        tmp2 = Si[k];
-        XX[k]    = cmplx_mul32_by_16(-tmp1,  tmp2, exp_m0_25);
-        YY[31-k] = cmplx_mul32_by_16(tmp2,  tmp1, exp_m0_25);
-    }
-
-    mdct_32(XX);
-    mdct_32(YY);
-
-    for (k = 0; k < 32; k++)
-    {
-        Si[k] = YY[k];
-    }
-
-    pt_data_1 = data;
-
-    for (k = 0; k < 16; k++)
-    {
-        *(pt_data_1++)  = (Int16)((XX[2*k  ] + Si[2*k  ]) >> 14);
-        *(pt_data_1++)  = (Int16)((XX[2*k+1] - Si[2*k+1]) >> 14);
-    }
-
-    for (k = 15; k > -1; k--)
-    {
-        *(pt_data_1++)  = (Int16)(-(XX[2*k+1] + Si[2*k+1]) >> 14);
-        *(pt_data_1++)  = (Int16)(-(XX[2*k  ] - Si[2*k  ]) >> 14);
-    }
-
-}
-
-
-#endif      /* HQ_SBR */
-
-#endif      /*  AAC_PLUS */
-
-
diff --git a/media/libstagefright/codecs/aacdec/synthesis_sub_band.h b/media/libstagefright/codecs/aacdec/synthesis_sub_band.h
deleted file mode 100644
index 042c488..0000000
--- a/media/libstagefright/codecs/aacdec/synthesis_sub_band.h
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: synthesis_sub_band.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
-------------------------------------------------------------------------------
-*/
-
-#ifndef SYNTHESIS_SUB_BAND_H
-#define SYNTHESIS_SUB_BAND_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES AND SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-    void synthesis_sub_band_LC(Int32 Sr[], Int16 data[]);
-    void synthesis_sub_band_LC_down_sampled(Int32 Sr[], Int16 data[]);
-
-
-#ifdef HQ_SBR
-
-    void synthesis_sub_band(Int32 Sr[], Int32 Si[], Int16 data[]);
-    void synthesis_sub_band_down_sampled(Int32 Sr[], Int32 Si[], Int16 data[]);
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /* SYNTHESIS_SUB_BAND_H */
-
diff --git a/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp b/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp
deleted file mode 100644
index db31a63..0000000
--- a/media/libstagefright/codecs/aacdec/tns_ar_filter.cpp
+++ /dev/null
@@ -1,474 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_ar_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Implemented 24-bit fixed point version
-               Optimized C code
-
- Description:
-            - Added OVERFLOW_SHIFT_DOWN to avoid overflow.
-            - Increased precision by using the Q format of the LPC coefficient.
-            - Modified interface to add LPC Q format and scratch memory
-              for the state variables.
-            - Added pv_memset to clear state filter
-            - Updated format for comments (to PV standard)
-            - Updated copyright notice
-
- Description:
-            - Changed multiplication scheme to increase precision. This
-              works better than older version.
-
- Description:
-            - Include log2(order) as a scaling down parameter.
-
- Description:
-            Modified to reflect code review comments
-                - misspelled words, extra comments and explicit requirements
-
- Description:
-            deleted comment about fix Q format (L 107)
-
- Description:  Implemented a more efficient version, which eliminated the use
- of "scratch memory" via introducing a pointer that references the actual
- output.
-
- Description: Removed the parameter "scratch_Int32_buffer" as this space
- in memory is no longer needed by this function.
-
- Description: Removed references to "scratch_Int32_buffer" in the Inputs
- section.
-
- Description:
-    Modified casting to ensure proper operations for different platforms
-
- Description:
-    Per code review comment:
-    Eliminated casting to UInt and Int in b_low and b_high, they are
-    redundant and may add unncessary extra cycles in some platforms
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description: Changed the order of the unsigned * signed multiply so the
- casting to Int32 is performed on the unsigned operand.
-
- Description:
-    Modified 32 by 16 bit multiplications to avoid unnecessary moves to
-    registers. Also split the code (based on flag direction) to simplify
-    pointer's updates
-
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    spec  = spectral input to be shaped by the filter.
-            Fixed point format
-            Int32[]
-            length = spec_length
-
-    spec_length  = length of spec array.
-            const Int
-
-    direction = direction for application of tns filter.
-                +1  filters spectrum from low to high frequencies
-                    (first input to filter is spec[0])
-                -1  filters spectrum from high to low frequencies
-                    (first input to filter is spec[spec_length-1])
-                const Int
-
-    lpc   = array of lpc coefficients, minus lpc[0] which is assumed to be "1"
-            Fixed point format
-            const Int[]
-            length = TNS_MAX_ORDER
-
-    Q_lpc = Q format for the lpc coeffcients (for max. precision, it assumes
-            that all 16 bits are used)
-            const Int
-
-    order = order of the TNS filter (Range of 1 - TNS_MAX_ORDER)
-            Int
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    spec = contains spectral data after application of TNS filter
-           Int32 array
-           length = spec_length
-
-
- Local Stores Modified:
-
- Global Stores Modified:
-
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    A block of spectral data (Int32 spec[]) of length (const Int spec_length)
-    is processed by a simple all-pole filter defined by
-    LPC coefficients passed via (const Int lpc[])
-
-    TNS filter equation
-        y(n) =  x(n) - lpc(2)*y(n-1) - ... - lpc(order+1)*y(n-order)
-
-    The filter calculation is performed in place, i.e. the output is passed
-    back to the calling function via (Int32 spec[])
-
-    The filter's order is defined by the variable (const Int order)
-    The direction of the filter's application is defined by (const Int inc)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This function should match the functionality of the ISO code.
-    The implementation does support filter orders bigger or equal to 1.
-    The size of the spectral coeffcients has to be bigger or equal than 1.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-    FOR (i=0; i<order; i++)
-        state[i] = 0;
-    ENDFOR
-
-    IF (inc == -1)
-    THEN
-        spec = spec + spec_length - 1;
-    ENDIF
-
-    FOR (i=0; i<spec_length; i++)
-
-        y = *spec;
-
-        FOR (j=0; j<order; j++)
-
-            y -= lpc[j] * state[j];
-
-        ENDFOR
-
-        FOR (j=order-1; j>0; j--)
-
-            state[j] = state[j-1];
-
-        ENDFOR
-
-        state[0] = y;
-
-        *spec = y;
-
-        spec = spec + inc;
-
-    ENDFOR
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
-   When the code is written for a specific target processor
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "tns_ar_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define MASK_LOW16               0xFFFF
-#define UPPER16                      16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-Int tns_ar_filter(
-    Int32 spec[],
-    const Int spec_length,
-    const Int direction,
-    const Int32 lpc[],
-    const Int Q_lpc,
-    const Int order)
-{
-
-    Int i;
-    Int j;
-
-    /*
-     * Multiplication related variables
-     */
-
-    Int32 temp;
-
-    /*
-     *  Filter related variables
-     */
-    Int32 y0;
-
-    /*
-     *  Circular buffer to hold the filter's state
-     *  (y[n-1],y[n-2],y[n-3],etc.)
-     *
-     *  p_state and p_lpc should take advantage
-     *  of any special circular buffer instructions
-     *  if this code is hand-optimized in assembly.
-     */
-
-    Int32 *p_state = NULL;
-
-    const Int32 *p_lpc;
-
-
-    Int shift_up;
-    Int shift_down_amount;
-
-    /*
-     *  Pointer to the I/O memory space
-     */
-    Int32 *p_spec = spec;
-
-
-    i = 0;
-    j = order;
-
-    /*
-     *  get the power of 2 that is bigger than the order
-     *  i is the bit counter and j is modified until exceed
-     *  the power of 2 corresponding to TNS_MAX_ORDER
-     */
-
-    while (j < 0x010)
-    {
-        j <<= 1;
-        i++;
-    }
-
-    /*
-     *  5 is the number of bits needed to represent 0x010
-     *  TNS_MAX_ORDER = 20, power of 2 that include 20 is 5
-     */
-    shift_down_amount = 4 - i;
-
-    shift_up = UPPER16 - Q_lpc;
-
-    /*
-     *  shift_down_amount == power of 2 that is bigger than the order - 1
-     */
-
-    shift_down_amount += shift_up;
-
-    if (direction == -1)
-    {
-        p_spec += spec_length - 1;
-
-        for (i = order; i != 0; i--)
-        {
-
-            y0 = *p_spec >> shift_down_amount;
-
-            p_lpc = lpc;
-
-            /* 32 by 32 bit multiplication */
-            for (j = order; j > i; j--)
-            {
-                temp = *p_state++;
-                y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up;
-            }
-
-            /*
-            * Record the output in-place
-            */
-            p_state     = p_spec;
-            *(p_spec--) = y0;
-
-        }
-
-        if (spec_length > order)
-        {
-            for (i = (spec_length - order); i != 0; i--)
-            {
-                y0 = *p_spec >> shift_down_amount;
-
-                p_lpc = &(lpc[0]);
-
-                /* 32 by 32 bit multiplication */
-                for (j = order; j != 0; j--)
-                {
-                    temp = *p_state++;
-                    y0 -= fxp_mul32_Q31(temp, *(p_lpc++)) << shift_up;
-                }
-
-                /*
-                 * Record the output in-place
-                 */
-                p_state     = p_spec;
-                *(p_spec--) = y0;
-
-            } /* END for (i = (spec_length - order); i>0; i--) */
-        }
-
-    }
-    else
-    {
-        for (i = order; i != 0; i--)
-        {
-
-            p_lpc =  lpc;
-
-            y0 = 0;
-
-            /* 32 by 32 bit multiplication */
-            for (j = order; j > i; j--)
-            {
-                y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++));
-            }
-
-            p_state     = p_spec;
-            /*
-            * Record the output in-place
-            */
-            *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up);
-            p_spec++;
-        }
-
-        if (spec_length > order)
-        {
-            for (i = (spec_length - order); i != 0; i--)
-            {
-                p_lpc =  lpc;
-
-                y0 = 0;
-
-                /* 32 by 32 bit multiplication */
-                for (j = order; j != 0; j--)
-                {
-                    y0 -= fxp_mul32_Q31(*p_state--, *(p_lpc++));
-                }
-
-                p_state     = p_spec;
-                /*
-                 * Record the output in-place
-                 */
-                *(p_spec) = (*p_spec >> shift_down_amount) + (y0 << shift_up);
-                p_spec++;
-
-            } /* END for (i = (spec_length - order); i>0; i--) */
-        }
-    }
-
-    return(shift_down_amount);
-
-
-} /* tns_ar_filter */
diff --git a/media/libstagefright/codecs/aacdec/tns_ar_filter.h b/media/libstagefright/codecs/aacdec/tns_ar_filter.h
deleted file mode 100644
index 2538b4d..0000000
--- a/media/libstagefright/codecs/aacdec/tns_ar_filter.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_ar_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Per request of JT, the lpc coefficients q-format will now
- be transmitted to the function.
-
- Description: Removed the parameter "scratch_Int32_buffer" as this space
- in memory is no longer needed by this function.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for tns_ar_filter()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_AR_FILTER_H
-#define TNS_AR_FILTER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "e_tns_const.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    Int tns_ar_filter(
-        Int32 spec[],
-        const Int spec_length,
-        const Int inc,
-        const Int32 lpc[],
-        const Int lpc_qformat,
-        const Int order);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
diff --git a/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp b/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp
deleted file mode 100644
index 366cce5..0000000
--- a/media/libstagefright/codecs/aacdec/tns_decode_coef.cpp
+++ /dev/null
@@ -1,500 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_decode_coef.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Implemented in 16-bit Fixed Point
-
- Description:  Implemented in 24-bit Fixed Point
-
- Description:  Modified to return the calculated LPC coefficients "in place"
- This saves memory, cycles, etc. because it saves a large temporary
- array being declared on the stack in another function (tns_setup_filter)
-
- Description:  Modified to return the q-format of the lpc coefficients.
-
- Description:  Modified for more reliable overflow protection.  tns_decode_coef
- no longer relies on "reasonable" outputs.  This code should handle all
- possible inputs.
-
- Description:  Modified per review comments.
-
- Description:  Added check condition to avoid numbers with a Q bigger than
-        15 from being passed, otherwise in a 16-bit number the sign is lost.
-
- Description:  Modified to utilize scratch memory techniques, thereby
- eliminating two arrays of size TNS_MAX_ORDER, which were previously declared
- on the stack.
-
- Description: Updated the SW template to include the full pathname to the
- source file and a slightly modified copyright header.
-
- Description:
- (1) Changed the order of the unsigned * signed multiply so the
-     casting to Int32 is performed on the unsigned operand.
-
- (2) Removed some unnecessary casting.
- (3) Fixed a problem where a 16-bit value was casted to 32-bits AFTER
-     a shift.  It should have been cast to 32-bits BEFORE the shifting.
-
-
- Description:  modified precision of coefficients
-
- Who:                                   Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- The inputs and their range are defined in ISO/IEC 14496-3:1999(E)
-                                            Part 3 MPEG-4 Audio
-                                            Subpart 4
-
- Inputs:       order    = RANGE = 1-20
-               const Int
-
-               coef_res = RANGE = 0-1
-               const Int
-
-               lpc_coef = RANGE = -8 to 7 if coef_res = 1   compression OFF
-                                  -4 to 3 if coef_res = 1   compression ON
-                                  -4 to 3 if coef_res = 0   compression OFF
-                                  -2 to 1 if coef_res = 0   compression ON
-
-               [Int *, length TNS_MAX_ORDER]
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    q_lpc     = q_format for the calculated LPC coefs.
-    Int
-
- Pointers and Buffers Modified:
-    lpc_coef  = used to return the calculated LPC coefs in-place.
-    Int *
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-This function calculates the LPC coefs from the encoded coefs...
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-This function should match the functionality of the ISO source code within
-a reasonable tolerance for fixed point errors.
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.8 (Temporal Noise Shaping)
- (2) Markel & Gray Page 95
-     As referenced in the ISO source code
-
- (3) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
- PSEUDOCODE:  (ISO Reference Code)
-
-    int i, m;
-    Real iqfac, iqfac_m;
-    Real lpc_fp[TNS_MAX_ORDER+1];
-    Real sin_result_fp[TNS_MAX_ORDER+1], b[TNS_MAX_ORDER+1];
-
-    Inverse quantization
-    iqfac   = (Real)(((1 << (coef_res-1)) - 0.5) / (PI/2.0));
-    iqfac_m = (Real)(((1 << (coef_res-1)) + 0.5) / (PI/2.0));
-
-    for (i=0; i<order; i++)
-    {
-        sin_result[i+1] =
-        (Real)sin( coef[i] / ((coef[i] >= 0) ? iqfac : iqfac_m) );
-    }
-
-    lpc[0] = 1;
-    for (m=1; m<=order; m++)
-    {
-
-        b[0] = lpc[0];
-        for (i=1; i<m; i++)
-        {
-            b[i] = sin_result[m] * lpc[m-i];
-            b[i] += lpc[i];
-        }
-
-        b[m] = sin_result[m];
-
-
-        for (i=0; i<=m; i++)
-        {
-            lpc[i] = b[i];
-        }
-
-    }
-
-    return;
-
-}
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_tns_const.h"
-#include "tns_decode_coef.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define MASK_LOW16  0xffff
-#define UPPER16     16
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*
- * Derivation of tns_tables and q_tns_tables
- *
- * As defined in the ISO source code
- * (with the modification that our coef_res has a range[0,1]
- * The ISO code has a range of [3,4])
- *
- *               pi / 2                              pi / 2
- * iqfac =  --------------------      iqfac_m =  --------------------
- *          (coef_res + 2) - 1/                  (coef_res + 2) + 1/
- *         2                 /2                 2                 /2
- *
- *
- * ... Move 1/2 into denominator
- *
- *              pi                                   pi
- * iqfac =  --------------------      iqfac_m =  --------------------
- *          (coef_res + 3)                        (coef_res + 3)
- *         2               - 1                   2              + 1
- *
- *
- * if a coef is negative, it is multiplied by iqfac_m
- *           if positive, "   "     "         iqfac
- *
- * The range of coefs is limited to  -4:3 if coef_res = 0
- *                                   -8:7 if coef_res = 1
- *
- *
- *
- */
-
-
-const Int32 tns_table[2][16] =
-{
-    {
-        -2114858546,  -1859775393,  -1380375881,  -734482665,
-        0,    931758235,   1678970324,  2093641749
-    },
-    {
-        -2138322861,  -2065504841,  -1922348530,  -1713728946,
-        -1446750378,  -1130504462,   -775760571,   -394599085,
-        0,    446486956,    873460290,   1262259218,
-        1595891361,   1859775393,   2042378317,   2135719508
-    }
-};
-
-
-const Int neg_offset[2] = {4, 8};
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
- FUNCTION NAME: tns_decode_coef
-    Decoder transmitted coefficients for one TNS filter
-----------------------------------------------------------------------------*/
-
-Int tns_decode_coef(
-    const Int   order,
-    const Int   coef_res,
-    Int32 lpc_coef[TNS_MAX_ORDER],
-    Int32 scratchTnsDecCoefMem[2*TNS_MAX_ORDER])
-{
-
-    /* Simple loop counters */
-    Int i;
-    Int m;
-
-    /* Arrays for calculation of the LPC */
-    Int32 *pB = &(scratchTnsDecCoefMem[TNS_MAX_ORDER]);
-
-    Int32 *pA = scratchTnsDecCoefMem;
-
-    Int32 *temp_ptr = NULL;
-
-    /* Pointer for reading/storing the lpc_coef in place */
-    Int32 *pLPC;
-    Int q_lpc = Q_LPC;
-
-    /* TNS table related variables */
-    const Int32 *pTnsTable;
-    Int coef_offset;
-    Int32 table_index;
-    Int shift_amount;
-    Int32 sin_result;
-
-    Int32 tempInt32;
-
-    Int32 max;
-    Int32 mask;
-
-    Int32 mult_high;
-
-    /* Conversion to LPC coefficients Ref. (2) */
-    coef_offset = neg_offset[coef_res];
-    pTnsTable   = tns_table[coef_res];
-
-    m = 0;
-    pLPC = lpc_coef;
-
-
-    /*
-     *  Conversion to LPC coefficients
-     */
-
-    do
-    {
-        table_index = coef_offset + *(pLPC++);
-
-        /* Equiv. to sin_result  = tns_table[coef_res][table_index]; */
-        sin_result = *(pTnsTable + table_index);
-
-        /* sin_result has a range of -0.999 to +0.999 in Q-31 */
-
-        /*
-         * It is important that this for loop is not entered on the first
-         * iteration of the do-while( m < order ) loop.
-         */
-        for (i = m; i > 0; i--)
-        {
-
-            /*
-             * temp_ptr used to optimize index into pA
-             * mult = (Int32)( pA[m-i] * sin_result);
-             */
-
-            mult_high = fxp_mul32_Q31(*(temp_ptr--), sin_result);
-
-            /*
-             *  pB[i] = pA[i] + sin_result * pA[m-i]
-             *
-             *  (mult_high <<1)  eliminates extra sign bit
-             */
-
-            *(pB++) =  *(pA++) + (mult_high << 1);
-
-        } /* END for (i=m; i > 0; i--) */
-
-
-        /* Shift to place pB[m] in q_lpc format */
-
-        *pB =  sin_result >> 12;
-
-        /*
-         * Swapping the pointers here has the same effect
-         * as specifically copying the data from b to a
-         */
-
-        temp_ptr = pA;
-        pA       = pB;
-        pB       = temp_ptr;
-
-        /*
-         *  At this point, pA = pA[m]
-         *             and pB = pB[m]
-         */
-        temp_ptr = pA;
-
-        tempInt32 = *(pA);
-
-        mask = tempInt32 >> 31;
-        tempInt32 ^= mask;
-
-        max = tempInt32;
-
-        /*
-         * It is important that this for loop is not entered on the first
-         * iteration of the do-while( m < order ) loop.
-         */
-        for (i = m; i > 0; i--)
-        {
-            tempInt32 = *(--pA);
-
-            mask = tempInt32 >> 31;
-            tempInt32 ^= mask;
-
-            max |= tempInt32;
-        }
-
-        pB -= m;
-
-        /*
-         * Here, pA = &(pA[0])
-         * and   pB = &(pB[0])
-         */
-
-        if (max >= 0x40000000L)
-        {
-            max >>= 1;
-
-            for (i = m; i > 0; i--)
-            {
-                *(pA++) >>= 1;
-                *(pB++) >>= 1;
-            }
-
-            /* Shift the most recent entry down also */
-            *(pA) >>= 1;
-
-            q_lpc--;
-
-            pA -= m;
-            pB -= m;
-        }
-
-        m++;
-
-    }
-    while (m < order);
-
-
-    /*
-     * The following code compacts
-     * 32-bit LPC coefficients into 16-bit numbers,
-     * shifting by the minimum amount necessary.
-     */
-
-    shift_amount = 0;
-
-    while (max > 32767)
-    {
-        max >>= 1;
-        shift_amount++;
-    }
-
-    /*
-     * This while loop is for protective purposes only.
-     * I have not found data that causes it to be entered.
-     *
-     */
-    if (max != 0)
-    {
-        while (max < 16384)
-        {
-            max <<= 1;
-            shift_amount--;
-        }
-    }
-
-
-    pLPC = lpc_coef;
-
-    if (shift_amount >= 0)
-    {
-
-        for (m = order; m > 0; m--)
-        {
-            *(pLPC++) = *(pA++) << (16 - shift_amount);
-        }
-    }
-
-
-    q_lpc -= shift_amount;
-
-    /*
-     *  make sure that the numbers have some meaning, q_lpc can not be
-     *  bigger than 15 (15 bits + sign)
-     */
-
-    if (q_lpc > 15)
-    {
-        shift_amount = q_lpc - 15;
-        pLPC = lpc_coef;
-
-        for (m = order; m > 0; m--)
-        {
-            *(pLPC++) >>= shift_amount;
-        }
-
-        q_lpc -= shift_amount;
-    }
-
-    return (q_lpc);
-
-} /* tns_decode_coef */
diff --git a/media/libstagefright/codecs/aacdec/tns_decode_coef.h b/media/libstagefright/codecs/aacdec/tns_decode_coef.h
deleted file mode 100644
index a6bac6c..0000000
--- a/media/libstagefright/codecs/aacdec/tns_decode_coef.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_decode_coef.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Modified to return the LPC coefficients in-place, so the
- interface to tns_decode_coef is changed.
-
- Description: Modified to return the q-format of the LPC coefficients.
-
- Description: Modified so that only the function is declared here.  extern
- references to constant tables removed.  Also, new copyright header included.
-
- Description: Modified to include extra parameter, so tns_decode_coef can use
- scratch memory techniques.
-
- Description:
- (1) Modified to include the lines...
-
-    #ifdef __cplusplus
-    extern "C" {
-    #endif
-
-    #ifdef __cplusplus
-    }
-    #endif
-
- (2) Updated the copyright header.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This function includes the function declaration for tns_decode_coef()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_DECODE_COEF_H
-#define TNS_DECODE_COEF_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-    Int tns_decode_coef(
-        const Int   order,
-        const Int   coef_res,
-        Int32 lpc_coef[],
-        Int32 scratchTnsDecCoefMem[]);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* TNS_DECODE_COEF */
diff --git a/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp b/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp
deleted file mode 100644
index 631f887..0000000
--- a/media/libstagefright/codecs/aacdec/tns_inv_filter.cpp
+++ /dev/null
@@ -1,421 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_inv_filter.c
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Changes made per review comments.
-
- Description: As requested by JT, the q-format for the LPC coefficients is
- now passed via the parameter lpc_qformat.
-
- Description: For speed, the calculation of the shift amount was pulled
- outside of the loop.
-
- Description:
-    Modified casting to ensure proper operations for different platforms
-
- Description:
-    Simplified MAC operations for filter by eliminating extra variables
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-
-    coef           = spectral input to be shaped by the filter.
-                     Fixed point format
-                     [Int32[], length = num_coef]
-
-    num_coef       = length of spec array.
-                     [const Int]
-
-    direction      = direction for application of tns filter.
-                     +1 applies forward filter
-                     (first input to filter is coef[0])
-                     -1 applies reversed filter
-                     (first input to filter is coef[num_coef-1])
-                     [const Int]
-
-    lpc            = array of lpc coefficients.
-                     Fixed point format Q-11
-                     [const Int[], length = TNS_MAX_ORDER]
-
-    lpc_qformat    = The q-format of the lpc coefficients.
-                     [const Int]
-
-    order          = order of the TNS filter (Range of 1 : TNS_MAX_ORDER)
-                     [const Int]
-
-    scratch_memory = scratch_memory needed for filter operation
-                     [Int[], length = TNS_MAX_ORDER]
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    coef = contains spectral data after application of TNS filter
-           q-format is not modified.
-           Int32 array
-           length = num_coef
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-    A block of spectral data (Int32 coef[]) of length (const Int num_coef)
-    is processed by a simple all-zero filter defined by
-    LPC coefficients passed via (const Int lpc[])
-
-    TNS filter equation
-        y(n) =  x(n) + lpc(2)*x(n-1) + ... + lpc(order+1)*x(n-order)
-
-    The filter calculation is performed in place, i.e. the output is passed
-    back to the calling function via (Int32 coef[])
-
-    In order to avoid overflow, the filter input (Int32 coef[]) must utilize
-    only the lower 16-bits.  The upper 16-bits must be available.
-
-    The filter's order is defined by the variable (const Int order)
-
-    The direction of the filter's application is defined by
-    (const Int direction)
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    [Int32 coef] must store no more than 16 bits of data.
-
-    This is required to utilize methods that do not change the q-format of
-    the input data [Int32 coef], and to make use of a fast
-    16 x 16 bit multiply.
-
-    This function should not be called for order <= 0.
-
-    This function must not be called with lpc_qformat < 5
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.6.4.1 (LTP with TNS)
-        Subpart 4.6.8 (Temporal Noise Shaping)
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF (direction == -1)
-    THEN
-        pCoef = pCoef + (num_coef - 1);
-    END IF
-
-    FOR (i = order; i > 0; i--)
-
-        *(pFilterInput) = 0;
-        pFilterInput = pFilterInput + 1;
-
-    END FOR
-
-    wrap_point = 0;
-
-    shift_amt  = (lpc_qformat - 5);
-
-    FOR (i = num_coef; i > 0; i--)
-
-        pLPC = lpc;
-
-        mult = 0;
-
-        FOR (j = wrap_point; j>0; j--)
-
-           tempInt32 = (Int32)(*(pLPC) * *(pFilterInput));
-           tempInt32 = tempInt32 >> 5;
-
-           mult = mult + tempInt32;
-
-           pFilterInput = pFilterInput + 1;
-           pLPC = pLPC + 1;
-
-        ENDFOR
-
-        pFilterInput = scratch_memory;
-
-        FOR (j = (order - wrap_point); j>0; j--)
-
-           tempInt32 = (Int32)(*(pLPC) * *(pFilterInput));
-           tempInt32 = tempInt32 >> 5;
-
-           mult = mult + tempInt32;
-
-           pFilterInput = pFilterInput + 1;
-           pLPC = pLPC + 1;
-
-        ENDFOR
-
-        pFilterInput = pFilterInput - 1;
-        *(pFilterInput) = (Int)(*pCoef);
-
-        mult = mult >> shift_amt;
-
-        *(pCoef) = *(pCoef) + mult;
-
-        pCoef = pCoef + direction;
-
-        wrap_point = wrap_point + 1;
-
-        IF (wrap_point == order)
-        THEN
-            wrap_point = 0;
-        END IF
-
-    END FOR
-
-------------------------------------------------------------------------------
- RESOURCES USED
-
-   When the code is written for a specific target processor
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "tns_inv_filter.h"
-#include "fxp_mul32.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-void tns_inv_filter(
-    Int32 coef[],
-    const Int num_coef,
-    const Int direction,
-    const Int32 lpc[],
-    const Int lpc_qformat,
-    const Int order,
-    Int32 scratch_memory[])
-{
-
-    Int i;
-    Int j;
-    Int shift_amt;
-    Int wrap_point;
-
-    Int32 mult;
-
-    /*
-     * Circular buffer to hold the filter's input
-     *
-     * (x[n-1],x[n-2],x[n-3],etc.)
-     *
-     * This scratch space is necessary, because
-     * the filter's output is returned in-place.
-     *
-     * pFilterInput and pLPC should take advantage
-     * of any special circular buffer instructions
-     * if this code is hand-optimized in assembly.
-     *
-     */
-    Int32 *pFilterInput = scratch_memory;
-
-    const Int32 *pLPC;
-
-    /*
-     * Pointer to the I/O memory space
-     */
-    Int32 *pCoef = coef;
-
-    if (direction == -1)
-    {
-        pCoef += (num_coef - 1);
-    }
-
-    /* Make sure the scratch memory is "clean" */
-    for (i = order; i != 0; i--)
-    {
-        *(pFilterInput++) = 0;
-    }
-
-    wrap_point = 0;
-
-    shift_amt  = (lpc_qformat - 5);
-
-    for (i = num_coef; i > 0; i--)
-    {
-        /*
-         * Copy spectral input into special
-         * filter input buffer.
-         */
-        pLPC = lpc;
-
-        mult = 0;
-
-        /*
-         * wrap_point = 0 when this code is
-         * entered for the first iteration of
-         * for(i=num_coef; i>0; i--)
-         *
-         * So, this first for-loop will be
-         * skipped when i == num_coef.
-         */
-
-        for (j = wrap_point; j > 0; j--)
-        {
-            mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5;
-
-        } /* for (j = wrap_point; j>0; j--) */
-
-        /*
-         * pFilterInput has reached &scratch_memory[order-1]
-         * Reset pointer to beginning of filter's state memory
-         */
-        pFilterInput = scratch_memory;
-
-        for (j = (order - wrap_point); j > 0; j--)
-        {
-            mult += fxp_mul32_Q31(*(pLPC++), *(pFilterInput++)) >> 5;
-
-        } /* for (j = wrap_point; j>0; j--) */
-
-
-        /*
-         * Fill the filter's state buffer
-         * avoid obvious casting
-         */
-        *(--pFilterInput) = (*pCoef);
-
-
-        /* Scale the data down so the output q-format is not adjusted.
-         *
-         * Here is an equation, which shows how the spectral coefficients
-         * and lpc coefficients are multiplied and the spectral
-         * coefficient's q-format does not change.
-         *
-         * Q-(coef) * Q-(lpc_qformat) >> 5 = Q-(coef + lpc_q_format - 5)
-         *
-         * Q-(coef + lpc_q_format - 5) >> (lpc_qformat - 5) = Q-(coef)
-         */
-
-        /* Store output in place */
-        *(pCoef) += (mult >> shift_amt);
-
-        /* Adjust pointers and placeholders */
-        pCoef += direction;
-
-        wrap_point++;
-
-        if (wrap_point == order)
-        {
-            wrap_point = 0;
-        }
-
-    } /* for (i = num_coef; i > 0; i--) */
-
-} /* tns_inv_filter */
diff --git a/media/libstagefright/codecs/aacdec/tns_inv_filter.h b/media/libstagefright/codecs/aacdec/tns_inv_filter.h
deleted file mode 100644
index 1b57fc1..0000000
--- a/media/libstagefright/codecs/aacdec/tns_inv_filter.h
+++ /dev/null
@@ -1,99 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: tns_inv_filter.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Per request of JT, the lpc coefficients q-format will now
- be transmitted to the function.
-
- Description: The scratch memory was mistakenly declared here as type "Int32"
- It should have been "Int"
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This include file contains the function declaration for
- tns_inv_filter.c
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef TNS_INV_FILTER_H
-#define TNS_INV_FILTER_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-void tns_inv_filter(
-    Int32 coef[],
-    const Int   num_coef,
-    const Int   inc,
-    const Int32 lpc[],
-    const Int   lpc_qformat,
-    const Int   order,
-    Int32 scratch_memory[]);
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp b/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp
deleted file mode 100644
index 6ccc023..0000000
--- a/media/libstagefright/codecs/aacdec/trans4m_freq_2_time_fxp.cpp
+++ /dev/null
@@ -1,2604 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Pathname: trans4m_freq_2_time_fxp.c
-  Function: trans4m_freq_2_time_fxp
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-    changed to decrement loop
-    change wnd_shape from structure to passing parameters
-    modified window tables from UInt to UInt16 to assure proper operation
-    without dubious typecast
-    changed logic to hit most common states first.
-    modified Time_data from Int to Int32 to hold
-    possible overflow before saturation process.
-
- Description:
-    Increase processing on some loop by using more pointers
-    changed interface to avoid passing a pointer for wnd_shape_prev_bk, this
-    element is not change in this function because of this function use
-    in the LTP module
-
- Description:
-    Added rounding to multiplication
-
- Description:
-    Update input description and eliminate unneeded comments
-
- Description:
-    LONG_START_WINDOW was using SHORT_WINDOW instead of
-    HALF_SHORT_WINDOW, causing a for loop to exceed its count
-
- Description:
-    Modified structure of code so exp is not tested before it
-    is initialized.  Also, new structure avoids double-testing
-    of exp_freq = ALL_ZEROS_BUFFER.
-
- Description:
-    The result of a shift is undefined if the right operand is greater than
-    or equal to the number of bits in the left expression's type
-    To avoid undefined shift by 32, a check of the shift has been
-    added, so the function proceeds only when the exponent is less
-    than 32. By design the shift up is related to the global gain,
-    and controlled by the encoder, so saturation is not allowed.
-    In both short and long window, processing is skip if an all zero
-    input buffer or excessive down shift is detected.
-
- Description:
-    Changes according to code review comments. Also, modified if-else
-    structure so the imdct_fxp is not called with an all zero input buffer
-
- Description:
-    Replaced function buffer_normalization by buffer_adaptation, to ease
-    use of 16 bits. Function buffer_normalization becomes  obsolete.
-
- Description:
-    Modified call to imdct_fxp to reflect extended precision use. Added
-    routine buffer_adaptation to extract 16 MSB and keep highest.
-    precision. Modify casting to ensure proper operations for different
-    platforms
-
- Description:
-    Eliminate double access to memory by loading data directly to the
-    time array. Also reduced cycle count and added precision by combining
-    downshifting in only one operation. Added adaptive rounding factor.
-    Change exponent threshold when operations are waived. It is use to be 32
-    but by combining downshifting, this new threshold is now 16. This may
-    avoid unneeded calculations for extremely small numbers.
-
- Description:
-    Per review comments:
-        - Added comments to clarify buffer_adaptation function
-        - Deleted  reference to include file "buffer_normalization.h"
-        - Modified IF-ELSE so long_windows case is considered first
-        - Eliminated extra IF when computing the rounding, so when exp ==0
-          less cycles are used shifting than in an extra if-else
-        - Corrected negative shift when computing rounding factor
-        - Added condition when exp > 16 (for long windows)
-
- Description:
-    Modified IF-ELSE structure so now ALL_ZEROS_BUFFER condition is share
-    with exp > 16 condition. This avoid code duplication for both cases.
-
- Description:
-        - Modified function interface to add output_buffer
-        - Eliminated the 32 bit version of the current output, calculations
-          are placed directly in output_buffer. In this way the buffer
-          Time_data needs only to be 1024 Int32, instead of 2048 (per channel).
-          Also, added the limit macro inside the function (this reduces access
-          to memory).
-        - Updated Pseudo - Code
-
- Description:
-    Per review comments:
-          Corrected line sizes and mispelling,  added comments and swap
-          order or switch statement for ONLY_LONG_SEQUENCE.
-
- Description:
-    Eliminated adaptive rounding due to potential saturation.
-
- Description:
-    Eliminated use of buffer adaptation by shifting this functionality inside
-    the imdct_fxp() routine. Also modified the call to imdct_fxp to accomodate
-    new function interface.
-    Modified macro limit() to save cycles when testing the most common case:
-    no saturation.
-
- Description:
-    Changed new function interface for imdct_fxp().
-
- Description:
-    Replaced for-loop with memset and memcopy.
-
- Who:                         Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Frequency_data    =  vector with spectral information, size 2048
-                         type Int32
-
-    Time_data         =  buffer with data from previous Frequency to Time
-                         conversion, used for overlap and add, size 1024
-                         type Int32
-
-    Output_buffer     =  place holder for current output,  size 1024
-                         type Int16
-
-    wnd_seq           =  window sequence
-                         type WINDOW_SEQUENCE
-
-    wnd_shape_prev_bk =  previous window shape type
-                         type Int
-
-    wnd_shape_this_bk =  current window shape type
-                         type Int
-
-    Q_format          =  Q format for the input frequency data
-                         type Int
-
-    freq_2_time_buffer[] =  scratch memory for computing FFT
-                         type Int32
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    Output_buffer
-    Time_data
-    Frequency_data
-    pWnd_shape_prev_bk
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-The time/frequency representation of the signal is mapped onto the time
-domain by feeding it into the filterbank module. This module consists of
-an inverse modified discrete cosine transform (IMDCT), and a window and an
-overlap-add function. In order to adapt the time/frequency resolution of the
-filterbank to the characteristics of the input signal, a block switching tool
-is also adopted. N represents the window length, where N is a function of the
-window_sequence. For each channel, the N/2 time-frequency values are
-transformed into the N time domain values via the IMDCT. After applying the
-window function, for each channel, the first half of the sequence is added to
-the second half of the previous block windowed sequence to reconstruct the
-output samples for each channel outi,n.
-
-The adaptation of the time-frequency resolution of the filterbank to the
-characteristics of the input signal is done by shifting between transforms
-whose input lengths are either 2048 or 256 samples. By enabling the block
-switching tool, the following transitions are meaningful:
-
-from ONLY_LONG_SEQUENCE to   { LONG_START_SEQUENCE
-                               ONLY_LONG_SEQUENCE
-
-from LONG_START_SEQUENCE to  { LONG_STOP_SEQUENCE
-                               EIGHT_SHORT_SEQUENCE
-
-from LONG_STOP_SEQUENCE to   { LONG_START_SEQUENCE
-                               ONLY_LONG_SEQUENCE
-
-from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE
-                               EIGHT_SHORT_SEQUENCE
-
-Window shape decisions are made by the encoder on a frame-by-frame-basis.
-The window selected is applicable to the second half of the window function
-only, since the first half is constrained to use the appropriate window
-shape from the preceding frame.
-The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are
-the last 1024 values of the previous window_sequence concatenated with 1024
-values of the current block. The formula below shows this fact:
-
-                     |  x(i-1)(n+1024)      for    0 < n < 1024
-            x'(i)(n) {
-                     |  x(i)(n)             for 1024 < n < 2048
-
-
-Buffer Time_data data from previous Frequency to Time conversion, used
-for overlap and add
-
-Once the window shape is selected, the window_shape syntax element is
-initialized. Together with the chosen window_sequence all information needed
-for windowing exist.
-With the window halves described below all window_sequences can be assembled.
-For window_shape == 1, the window coefficients are given by the Kaiser -
-Bessel derived (KBD) window.
-Otherwise, for window_shape == 0, a sine window is employed.
-
-The window length N can be 2048 or 256 for the KBD and the sine window.
-All four window_sequences explained below have a total length of 2048
-samples.
-For all kinds of window_sequences the window_shape of the left half of
-the first transform window is determined by the window shape of the previous
-block.
-
-In the case of EIGHT_SHORT_SEQUENCE the processing is done in-place and
-in descendent order to avoid using extra memory.
-The ordering is as follows:
-
-                                            Pn: Previous data for window n
-                                            Cn:  Current data for window n
-
-
-                                                128 freq.
-                                                 samples
-                  FREQ                          ++++++
-IN                         ===========================
-                                                    \
-                                                      \
-                                                        ->  256 time
-                                                             samples
-
-                                                           P8    C8
-           8                                            #######++++++
-                                                    P7     C7
-           7                                     #######++++++
-           :                                :
-           :                                :
-                            P2    C2
-           2             #######++++++
-                     P1    C1
-           1      #######++++++
-                                                                          TIME
-OUT          ==============================================================
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This module shall implement a scheme to switch between window types
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] ISO 14496-3:1999, pag 111
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-
-
-    IF ( wnd_seq == EIGHT_SHORT_SEQUENCE)
-    THEN
-
-        FOR ( i=0; i<LONG_WINDOW; i++)
-            Time_data[LONG_WINDOW + i] = 0;
-        ENDFOR
-
-        FOR ( wnd=NUM_SHORT_WINDOWS-1; wnd>=0; wnd--)
-
-            pFreqInfo = &Frequency_data[ wnd*SHORT_WINDOW];
-
-            CALL IMDCT( pFreqInfo, SHORT_BLOCK1);
-            MODIFYING(pFreqInfo)
-
-
-            IF (wnd == 0)
-            THEN
-                pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0];
-            ELSE
-                pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0];
-            ENDIF
-
-            pShort_Window_2   =
-                    &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1];
-
-            FOR( i=0, j=SHORT_WINDOW; i<SHORT_WINDOW; i++, j--)
-                pFreqInfo[             i]  *= pShort_Window_1[i];
-                pFreqInfo[SHORT_WINDOW+i]  *= pShort_Window_2[j];
-            ENDFOR
-
-
-            FOR( i=0; i<SHORT_BLOCK1; i++)
-                Time_data[W_L_STOP_1 + SHORT_WINDOW*wnd + i] += pFreqInfo[i];
-            ENDFOR
-
-        ENDFOR
-
-        FOR ( i=0; i<LONG_WINDOW; i++)
-            temp              = Time_data[i];
-            Output_buffer[i]  = Time_data[i];
-            Time_data[i]      = temp;
-        ENDFOR
-    ELSE
-
-        CALL IMDCT( Frequency_data, LONG_BLOCK1)
-            MODIFYING(Frequency_data)
-
-        SWITCH ( wnd_seq)
-
-            CASE ( ONLY_LONG_SEQUENCE)
-
-                pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
-                pLong_Window_2 =
-                        &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-                FOR (i=0; i<LONG_WINDOW; i++)
-                    Frequency_data[            i] *= *pLong_Window_1++;
-                    Frequency_data[LONG_WINDOW+i] *= *pLong_Window_2--;
-                ENDFOR
-
-                BREAK
-
-            CASE ( LONG_START_SEQUENCE)
-
-                pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
-
-                FOR ( i=0; i<LONG_WINDOW; i++)
-                    Frequency_data[ i] *= *pLong_Window_1++;
-                ENDFOR
-
-                pShort_Window_1   =
-                        &Short_Window[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-                FOR ( i=0; i<SHORT_WINDOW; i++)
-                    Frequency_data[W_L_START_1 + i] *= *pShort_Window_1--;
-                ENDFOR
-
-                FOR ( i=W_L_START_2; i<LONG_BLOCK1; i++)
-                    Frequency_data[W_L_START_2 + i] = 0;
-                ENDFOR
-
-                BREAK
-
-
-            CASE ( LONG_STOP_SEQUENCE )
-
-                FOR ( i=0; i<W_L_STOP_1; i++)
-                    Frequency_data[ i] = 0;
-                ENDFOR
-
-                pShort_Window_1   = &Short_Window[wnd_shape_prev_bk][0];
-
-                FOR ( i=0; i<SHORT_WINDOW; i++)
-                    Frequency_data[W_L_STOP_1+ i] *= *pShort_Window_1++;
-                ENDFOR
-
-                pLong_Window_1 =
-                        &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-                FOR ( i=0; i<LONG_WINDOW; i++)
-                    Frequency_data[LONG_WINDOW + i]  *=  *pLong_Window_1--;
-                ENDFOR
-
-                BREAK
-
-        }
-
-
-        FOR ( i=0; i<LONG_WINDOW; i++)
-            Output_buffer[i]  = Frequency_data[i]  + Time_data[i];
-            Time_data[i] = Frequency_data[LONG_WINDOW+i];
-        ENDFOR
-
-    }
-
-    ENDIF
-
-
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-#include "imdct_fxp.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; limit(x) saturates any number that exceeds a 16-bit representation into a
-; 16 bit number.
-----------------------------------------------------------------------------*/
-
-#define  ROUNDING_SCALED     (ROUNDING<<(16 - SCALING))
-
-
-#if defined(PV_ARM_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
-    Int32 x;
-    Int32 z;
-    __asm
-    {
-        mov x, ROUNDING_SCALED
-        mov y, y, lsl #(15-SCALING)
-        qdadd z, x, y
-        mov y, z, lsr #16
-    }
-    return((Int16)y);
-}
-
-#define  limiter( y, x)   y = sat(x);
-
-
-
-#elif defined(PV_ARM_GCC_V5)
-
-
-__inline Int16 sat(Int32 y)
-{
-    register Int32 x;
-    register Int32 ra = (Int32)y;
-    register Int32 z = ROUNDING_SCALED;
-
-
-    asm volatile(
-        "mov %0, %1, lsl #5\n\t"    // (15-SCALING) assembler does not take symbols
-        "qdadd %0, %2, %0\n\t"
-        "mov %0, %0, lsr #16"
-    : "=&r*i"(x)
-                : "r"(ra),
-                "r"(z));
-
-    return ((Int16)x);
-}
-
-#define  limiter( y, x)   y = sat(x);
-
-
-#elif defined(PV_ARM_MSC_EVC_V5)
-
-
-#define  limiter( y, x)       z = x<< (15-SCALING); \
-                              y = _DAddSatInt( ROUNDING_SCALED, z)>>16;
-
-
-#else
-
-#define  limiter( y, x)   z = ((x + ROUNDING )>>SCALING); \
-                          if ((z>>15) != (z>>31))         \
-                          {                                    \
-                              z = (z >> 31) ^ INT16_MAX;       \
-                          } \
-                          y = (Int16)(z);
-
-#endif
-
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-#ifdef AAC_PLUS
-
-
-void trans4m_freq_2_time_fxp_1(
-    Int32               Frequency_data[],
-    Int32               Time_data[],
-    Int16               Output_buffer[],
-    WINDOW_SEQUENCE     wnd_seq,
-    Int                 wnd_shape_prev_bk,
-    Int                 wnd_shape_this_bk,
-    Int                 Q_format,
-    Int32               abs_max_per_window[],
-    Int32               freq_2_time_buffer[])
-
-{
-    Int exp;
-    Int shift;
-
-    Int  i;
-    Int  wnd;
-#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
-    Int32 z;
-#endif
-
-    Int16 *pFreqInfo;
-    Int32 temp;
-    Int32 test;
-
-    Int16 *pFreq_2_Time_data_1;
-    Int16 *pFreq_2_Time_data_2;
-
-    const Int16 *pLong_Window_1;
-    const Int16 *pLong_Window_2;
-    const Int16 *pShort_Window_1;
-    const Int16 *pShort_Window_2;
-
-    Int32 *pOverlap_and_Add_Buffer_1;
-    Int32 *pOverlap_and_Add_Buffer_2;
-
-    Int16  *pOutput_buffer;
-    Int16  *pOutput_buffer_2;
-
-    const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
-    const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
-    Long_Window_fxp[0] = Long_Window_sine_fxp;
-    Long_Window_fxp[1] = Long_Window_KBD_fxp;
-    Short_Window_fxp[0] = Short_Window_sine_fxp;
-    Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
-
-    if (wnd_seq != EIGHT_SHORT_SEQUENCE)
-    {
-
-        pFreqInfo = (Int16 *)Frequency_data;
-
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  LONG_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[0]);
-
-
-
-        /*
-         *  The C Programming Language, Second Edition, Kernighan & Ritchie,
-         *  page 206.
-         *  "The result [of a shift] is undefined if the right operand is
-         *  negative, or greater than or equal to the number of bits in the
-         *  left expression's type"
-         *   => avoid shift by 32 or 16
-         */
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = pFreqInfo;
-
-            switch (wnd_seq)
-            {
-
-                case ONLY_LONG_SEQUENCE:
-                default:
-
-                    pOutput_buffer = Output_buffer;
-
-                    pOverlap_and_Add_Buffer_1 = Time_data;
-
-                    {
-                        const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-                        Int32 * pFreq2T = (Int32 *)pFreqInfo;
-                        Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0];
-                        Int shift = exp + 15 - SCALING;
-
-
-                        Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW];
-
-
-                        for (i = HALF_LONG_WINDOW; i != 0; i--)
-                        {
-                            Int16 win1, win2;
-                            Int32  temp2, test2;
-
-                            Int32  winx;
-
-                            temp2 = *(pFreq2T++);
-                            winx = *(win++);
-
-                            test  = *(pOverlap_and_Add_Buffer_1++);
-                            test2 = *(pOverlap_and_Add_Buffer_1--);
-                            temp  =   fxp_mul_16_by_16bb(temp2, winx) >> shift;
-                            temp2 =   fxp_mul_16_by_16tt(temp2, winx) >> shift;
-                            limiter(*(pOutput_buffer++), (temp + test));
-                            limiter(*(pOutput_buffer++), (temp2 + test2));
-
-                            temp2 = *(pFreq2T_2++);
-
-                            win1  = *(pLong_Window_2--);
-                            win2  = *(pLong_Window_2--);
-                            temp  = fxp_mul_16_by_16bb(temp2, win1) >> shift;
-                            test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp;
-                            *(pOverlap_and_Add_Buffer_1++) = test2;
-
-                        }
-                    }
-
-                    break;
-
-                case LONG_START_SEQUENCE:
-
-
-                    pFreq_2_Time_data_2 =
-                        &pFreq_2_Time_data_1[ HALF_LONG_WINDOW];
-
-                    pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
-                    pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[0];
-                    pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW];
-
-                    pOutput_buffer   = Output_buffer;
-                    pOutput_buffer_2 = pOutput_buffer + HALF_LONG_WINDOW;
-
-
-                    shift = exp + 15 - SCALING;
-
-                    for (i = HALF_LONG_WINDOW; i != 0; i--)
-                    {
-
-                        Int16 win1, win2;
-                        Int16  dat1, dat2;
-                        Int32  test1, test2;
-
-                        dat1   = *(pFreq_2_Time_data_1++);
-                        win1   = *(pLong_Window_1++);
-                        test1  = *(pOverlap_and_Add_Buffer_1++);
-
-                        dat2  =  *(pFreq_2_Time_data_2++);
-                        win2  = *(pLong_Window_2++);
-                        test2 = *(pOverlap_and_Add_Buffer_2++);
-
-                        limiter(*(pOutput_buffer++), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift)));
-
-                        limiter(*(pOutput_buffer_2++), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift)));
-
-                    }
-
-                    /*
-                     *  data unchanged from  LONG_WINDOW to W_L_START_1
-                     *  only scaled accordingly
-                     */
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[0];
-                    pFreq_2_Time_data_1       = &pFreqInfo[LONG_WINDOW];
-
-                    exp -= SCALING;
-
-                    if (exp >= 0)
-                    {
-
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
-                        {
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++) >> exp;
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++) >> exp;
-
-                        }
-
-                    }
-                    else if (exp < 0)
-                    {
-
-                        Int shift = -exp;
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--)
-                        {
-                            Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp2;
-                            temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp2;
-                        }
-
-                    }
-                    else
-                    {
-
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
-                        {
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++);
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++);
-
-                        }
-
-                    }
-
-
-                    pFreq_2_Time_data_1  = &pFreqInfo[W_L_START_1];
-                    pFreq_2_Time_data_2  =
-                        &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
-                    pShort_Window_1   =
-                        &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-                    pShort_Window_2   = pShort_Window_1 - HALF_SHORT_WINDOW;
-
-                    pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 +
-                                                HALF_SHORT_WINDOW;
-
-
-                    for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                    {
-                        Int16 win1, win2;
-                        Int16  dat1, dat2;
-                        Int32  temp2;
-                        dat1  = (*pFreq_2_Time_data_1++);
-                        dat2  = (*pFreq_2_Time_data_2++);
-                        win1  = *(pShort_Window_1--);
-                        win2  = *(pShort_Window_2--);
-
-                        temp   =   fxp_mul_16_by_16(dat1, win1) >> shift;
-                        *(pOverlap_and_Add_Buffer_1++) = temp;
-
-                        temp2 =   fxp_mul_16_by_16(dat2, win2) >> shift;
-                        *(pOverlap_and_Add_Buffer_2++) = temp2;
-
-
-                    }
-
-
-                    pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW;
-
-                    pv_memset(
-                        pOverlap_and_Add_Buffer_1,
-                        0,
-                        (LONG_BLOCK1 - W_L_START_2)
-                        *sizeof(*pOverlap_and_Add_Buffer_1));
-
-
-                    break;
-
-
-                case LONG_STOP_SEQUENCE:
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2];
-
-                    pOutput_buffer         = &Output_buffer[W_L_STOP_2];
-
-                    pFreq_2_Time_data_1      = &pFreqInfo[W_L_STOP_2];
-
-                    exp -= SCALING; /*  !!!! */
-
-                    if (exp > 0)
-                    {
-                        Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pOutput_buffer++), (temp + tmp1));
-
-                            tmp1 = *(pFreq_2_Time_data_1++) >> exp;
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        }
-                    }
-                    else if (exp < 0)
-                    {
-                        shift = -exp;
-                        Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pOutput_buffer++), (temp + temp1));
-
-                            temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        }
-                    }
-                    else
-                    {
-                        Int16 tmp1 = *(pFreq_2_Time_data_1++);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pOutput_buffer++), (temp + tmp1));
-
-                            tmp1 = *(pFreq_2_Time_data_1++);
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        }
-                    }
-
-
-                    pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
-                    pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW];
-
-                    pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1];
-                    pFreq_2_Time_data_2 =
-                        &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1];
-                    pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
-                                                + HALF_SHORT_WINDOW;
-
-                    pOutput_buffer   = &Output_buffer[W_L_STOP_1];
-                    pOutput_buffer_2 = pOutput_buffer + HALF_SHORT_WINDOW;
-
-                    exp += SCALING;  /* +8 back to what it was */
-
-                    shift = exp + 15 - SCALING;
-
-
-                    for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                    {
-                        Int16 win1;
-                        Int16  dat1;
-
-                        dat1 = *(pFreq_2_Time_data_1++);
-                        win1 = *(pShort_Window_1++);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        test  = fxp_mul_16_by_16(dat1, win1);
-
-                        limiter(*(pOutput_buffer++), (temp + (test >> shift)));
-
-                        dat1 = *(pFreq_2_Time_data_2++);
-                        win1 = *(pShort_Window_2++);
-                        temp = *(pOverlap_and_Add_Buffer_2++);
-                        test =  fxp_mul_16_by_16(dat1, win1);
-                        limiter(*(pOutput_buffer_2++), (temp + (test >> shift)));
-
-                    }
-
-
-                    pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = Time_data;
-
-                    pOutput_buffer = Output_buffer;
-
-                    pLong_Window_2   =
-                        &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
-                    /*
-                     *  Copy previous time in current buffer, also copy overlap
-                     *  and add buffer
-                     */
-
-                    for (i = W_L_STOP_1; i != 0; i--)
-                    {
-                        Int16 win1;
-                        Int16 dat1;
-
-                        win1 = *(pLong_Window_2--);
-                        dat1 = *pFreq_2_Time_data_2++;
-
-                        limiter(*(pOutput_buffer++), *(pOverlap_and_Add_Buffer_1));
-
-
-                        temp = fxp_mul_16_by_16(dat1, win1) >> shift;
-                        *(pOverlap_and_Add_Buffer_1++) = temp ;
-
-                    }
-
-                    for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--)
-                    {
-                        temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift;
-                        *(pOverlap_and_Add_Buffer_1++) = temp ;
-                    }
-
-
-                    break;
-
-
-
-            } /* switch (wnd_seq) */
-
-        }   /*  if (exp < 16)  */
-
-        else
-        {
-            /* all zeros buffer or excessive down shift */
-
-            /* Overlap and add, setup buffer for next iteration */
-            pOverlap_and_Add_Buffer_1 = &Time_data[0];
-
-            pOutput_buffer = Output_buffer;
-
-            temp  = (*pOverlap_and_Add_Buffer_1++);
-
-            for (i = LONG_WINDOW; i != 0; i--)
-            {
-
-                limiter(*(pOutput_buffer++), temp);
-
-                temp = (*pOverlap_and_Add_Buffer_1++);
-
-            }
-
-            pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0]));
-
-
-        }
-
-    }
-    else
-    {
-
-        Int32 *pScrath_mem;
-        Int32 *pScrath_mem_entry;
-        Int32  *pFrequency_data = Frequency_data;
-
-        Int32 * pOverlap_and_Add_Buffer_1;
-        Int32 * pOverlap_and_Add_Buffer_2;
-        Int32 * pOverlap_and_Add_Buffer_1x;
-        Int32 * pOverlap_and_Add_Buffer_2x;
-
-        /*
-         *  Frequency_data is 2*LONG_WINDOW length but only
-         *  the first LONG_WINDOW elements are filled in,
-         *  then the second part can be used as scratch mem,
-         *  then grab data from one window at a time in
-         *  reverse order.
-         *  The upper LONG_WINDOW Int32 are used to hold the
-         *  computed overlap and add, used in the next call to
-         *  this function, and also as sctrach memory
-         */
-
-        /*
-         *  Frequency_data usage for the case EIGHT_SHORT_SEQUENCE
-
-          |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-|
-          |                              |  Store for next  |        |  memory |
-          |                              |  call            |        |         |
-          |                              |                  |        |         |
-          |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++|
-          |                              |                  |        |         |
-          0                         LONG_WINDOW        LONG_WINDOW   |   2*LONG_WINDOW
-                                                            +        |         |
-                                                       W_L_STOP_2    |         |
-                                                                     |<--   -->|
-                                                                      SHORT_WINDOW +
-                                                                    HALF_SHORT_WINDOW
-          *
-          */
-
-        pOverlap_and_Add_Buffer_1  = &pFrequency_data[
-                                         LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW];
-
-        /*
-         *  Initialize to zero, only the firt short window used in overlap
-         *  and add
-         */
-        pv_memset(
-            pOverlap_and_Add_Buffer_1,
-            0,
-            SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-
-        /*
-         *  Showt windows are evaluated in decresing order. Windows from 7
-         *  to 0 are break down in four cases: window numbers 7 to 5, 4, 3,
-         *  and 2 to 0.
-         *  The data from short windows 3 and 4 is situated at the boundary
-         *  between the 'overlap and add' buffer and the output buffer.
-         */
-        for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--)
-        {
-
-            pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-            exp = imdct_fxp(
-                      (Int32 *)pFreqInfo,
-                      freq_2_time_buffer,
-                      SHORT_BLOCK1,
-                      Q_format,
-                      abs_max_per_window[wnd]);
-
-            pOverlap_and_Add_Buffer_1 =
-                &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd];
-
-
-            pOverlap_and_Add_Buffer_2 =
-                pOverlap_and_Add_Buffer_1 + SHORT_WINDOW;
-
-            /*
-             *  If all element are zero or if the exponent is bigger than
-             *  16 ( it becomes an undefined shift) ->  skip
-             */
-
-            if (exp < 16)
-            {
-
-
-                pFreq_2_Time_data_1 = &pFreqInfo[0];
-                pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-                /*
-                 *  Each of the eight short blocks is windowed separately.
-                 *  Window shape decisions are made on a frame-by-frame
-                 *  basis.
-                 */
-
-                pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-                pShort_Window_2   =
-                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-
-
-                /*
-                 * For short windows from 7 to 5
-                 *                                      |   =========================
-                 *                                      |   |     5     6     7
-                 *               _--_  _--_  _--_  _--_ | _-|-_  _--_  _--_  _--_
-                 *              /    \/    \/    \/    \|/  |  \/    \/    \/    \
-                 *             /     /\    /\    /\    /|\  |  /\    /\    /\     \
-                 *            /     /  \  /  \  /  \  / | \ | /  \  /  \  /  \     \
-                 *           /     /    \/    \/    \/  |  \|/    \/    \     \     \
-                 *      --------------------------------|---[///////////////////////]--------
-                 *
-                 */
-
-
-                shift = exp + 15 - SCALING;
-
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    Int16 win1, win2;
-                    Int16  dat1, dat2;
-
-                    dat2 = *(pFreq_2_Time_data_2++);
-                    win2 = *(pShort_Window_2--);
-                    temp = *pOverlap_and_Add_Buffer_2;
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-
-                    *(pOverlap_and_Add_Buffer_2++) =  temp + (fxp_mul_16_by_16(dat2, win2) >> shift);
-
-                    *(pOverlap_and_Add_Buffer_1++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                }
-
-            }   /* if (exp < 16) */
-            else
-            {
-                pv_memset(
-                    pOverlap_and_Add_Buffer_1,
-                    0,
-                    SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-            }
-
-
-        }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */
-
-
-        wnd = NUM_SHORT_WINDOWS / 2;
-
-        pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-        /*
-         *  scratch memory is allocated in an unused part of memory
-         */
-
-
-        pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW];
-
-        pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
-        pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
-                                    + HALF_SHORT_WINDOW;
-
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  SHORT_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[wnd]);
-
-        /*
-         *  If all element are zero or if the exponent is bigger than
-         *  16 ( it becomes an undefined shift) ->  skip
-         */
-
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = &pFreqInfo[0];
-            pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-            pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-            pShort_Window_2 =
-                &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-            /*
-             * For short window 4
-             *                                    ====|===========
-             *                                        |   4
-             *                                    |   |   |      |
-             *                _--_  _--_  _--_  _-|-_ | _-|-_  _-|-_  _--_  _--_
-             *               /    \/    \/    \/  |  \|/  |  \/  |  \/    \/    \
-             *              /     /\    /\    /\  |  /|\  |  /\  |  /\    /\     \
-             *             /     /  \  /  \  /  \ | / | \ | /  \ | /  \  /  \     \
-             *            /     /    \/    \/    \|/  |  \|/    \|/    \/    \     \
-             *      ------------------------------[\\\|\\\|//////]-------------------
-             *           |                        | A | B |   C  |
-             *           |
-             *        W_L_STOP_1
-             */
-
-            shift = exp + 15 - SCALING;
-            {
-                Int16 win1;
-                Int16  dat1;
-                /* -------- segment A ---------------*/
-                dat1 = *(pFreq_2_Time_data_1++);
-                win1 = *(pShort_Window_1++);
-                for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pScrath_mem++)  =  fxp_mul_16_by_16(dat1, win1) >> (shift);
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-                }
-
-                /* -------- segment B ---------------*/
-                for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pOverlap_and_Add_Buffer_1++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-                }
-
-                /* -------- segment C ---------------*/
-                temp = *pOverlap_and_Add_Buffer_2;
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pOverlap_and_Add_Buffer_2++)  =  temp + (fxp_mul_16_by_16(dat1, win1) >> shift);
-
-                    temp = *pOverlap_and_Add_Buffer_2;
-                    dat1 = *(pFreq_2_Time_data_2++);
-                    win1 = *(pShort_Window_2--);
-                }
-            }
-
-        }   /* if (exp < 16) */
-        else
-        {
-            pv_memset(
-                pScrath_mem,
-                0,
-                HALF_SHORT_WINDOW*sizeof(*pScrath_mem));
-
-            pv_memset(
-                pOverlap_and_Add_Buffer_1,
-                0,
-                HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-        }
-
-
-        wnd = NUM_SHORT_WINDOWS / 2 - 1;
-
-        pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-        pScrath_mem_entry =
-            &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW];
-        pScrath_mem = pScrath_mem_entry;
-
-        pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
-        /* point to end of buffer less HALF_SHORT_WINDOW */
-
-        pOutput_buffer_2 = &Output_buffer[LONG_WINDOW - HALF_SHORT_WINDOW];
-        pOutput_buffer   = pOutput_buffer_2;
-
-        pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];  /* !!!! */
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  SHORT_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[wnd]);
-
-        /*
-         *  If all element are zero or if the exponent is bigger than
-         *  16 ( it becomes an undefined shift) ->  skip
-         */
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = &pFreqInfo[0];
-            pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-            /*
-             * For short window 3
-             *                             ===========|====
-             *                                    3   |
-             *                             |      |   |   |
-             *               _--_  _--_  _-|-_  _-|-_ | _-|-_  _--_  _--_  _--_
-             *              /    \/    \/  |  \/  |  \|/  |  \/    \/    \/    \
-             *             /     /\    /\  |  /\  |  /|\  |  /\    /\    /\     \
-             *            /     /  \  /  \ | /  \ | / | \ | /  \  /  \  /  \     \
-             *           /     /    \/    \|/    \|/  |  \|/    \/    \     \     \
-             *     -----|------------------[\\\\\\|///|///]--------------------------
-             *          |                  |   A  | B | C |
-             *
-             *      W_L_STOP_1
-             */
-
-
-            pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-            pShort_Window_2 =
-                &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-            shift = exp + 15 - SCALING;
-
-
-            Int16 win1;
-            Int16  dat1;
-            /* -------- segment A ---------------*/
-            dat1 = *(pFreq_2_Time_data_1++);
-            win1 = *(pShort_Window_1++);
-            for (i = SHORT_WINDOW; i != 0; i--)
-            {
-                *(pScrath_mem++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-                dat1 = *(pFreq_2_Time_data_1++);
-                win1 = *(pShort_Window_1++);
-            }
-
-            dat1 = *(pFreq_2_Time_data_2++);
-            win1 = *(pShort_Window_2--);
-
-            /* -------- segment B ---------------*/
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-                test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                temp =  *(pScrath_mem++) + test;
-
-
-                test = *(pOverlap_and_Add_Buffer_1x++);  /* !!!! */
-
-                limiter(*(pOutput_buffer++), (temp + test));
-
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-
-            }
-
-            /* -------- segment C ---------------*/
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-                temp = fxp_mul_16_by_16(dat1, win1) >> (shift);
-
-                *(pOverlap_and_Add_Buffer_1++) += temp;
-
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-            }
-
-        }   /* if (exp < 16) */
-        else
-        {
-
-            pv_memset(
-                pScrath_mem,
-                0,
-                SHORT_WINDOW*sizeof(*pScrath_mem));
-
-            pScrath_mem += SHORT_WINDOW;
-
-            temp = *(pScrath_mem++);
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-                limiter(*(pOutput_buffer++), temp);
-                temp = *(pScrath_mem++);
-
-
-            }
-        }
-
-
-        for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--)
-        {
-
-
-            pOutput_buffer_2 -= SHORT_WINDOW;
-            pOutput_buffer = pOutput_buffer_2;
-
-            /*
-             * The same memory is used as scratch in every iteration
-             */
-            pScrath_mem = pScrath_mem_entry;
-
-            pOverlap_and_Add_Buffer_2x =
-                &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
-            pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-
-
-            exp = imdct_fxp(
-                      (Int32 *)pFreqInfo,
-                      freq_2_time_buffer,
-                      SHORT_BLOCK1,
-                      Q_format,
-                      abs_max_per_window[wnd]);
-
-            /*
-             *  If all element are zero or if the exponent is bigger than
-             *  16 ( it becomes an undefined shift) ->  skip
-             */
-
-            if (exp < 16)
-            {
-
-                pFreq_2_Time_data_1 = &pFreqInfo[0];
-                pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-                /*
-                 *  Each of the eight short blocks is windowed separately.
-                 *  Window shape decisions are made on a frame-by-frame
-                 *  basis.
-                 */
-
-                pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-                if (wnd == 0)
-                {
-                    pShort_Window_1 =
-                        &Short_Window_fxp[wnd_shape_prev_bk][0];
-                }
-
-                pShort_Window_2   =
-                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-                /*
-                 * For short windows from 2 to 0
-                 *
-                 *          =========================
-                 *                                       |
-                 *                0     1     2      |   |
-                 *               _--_  _--_  _--_  _-|-_ | _--_  _--_  _--_  _--_
-                 *              /    \/    \/    \/  |  \|/    \/    \/    \/    \
-                 *             /     /\    /\    /\  |  /|\    /\    /\    /\     \
-                 *            /     /  \  /  \  /  \ | / | \  /  \  /  \  /  \     \
-                 *           /     /    \/    \/    \|/  |  \/    \/    \     \     \
-                 *      ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|-----------------------------
-                 *          |
-                 *
-                 *      W_L_STOP_1
-                 */
-
-                shift = exp + 15 - SCALING;
-
-                Int16 dat1 = *(pFreq_2_Time_data_2++);
-                Int16 win1 = *(pShort_Window_2--);
-
-                temp  =  *(pScrath_mem);
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    test  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                    temp += test;
-
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-
-                    limiter(*(pOutput_buffer++), (temp + *(pOverlap_and_Add_Buffer_2x++)));
-
-
-                    *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-                    dat1 = *(pFreq_2_Time_data_2++);
-                    win1 = *(pShort_Window_2--);
-                    temp  =  *(pScrath_mem);
-
-                }
-
-            }   /* if (exp < 16) */
-            else
-            {
-                test  = *(pScrath_mem);
-                temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    limiter(*(pOutput_buffer++), (temp + test));
-
-                    *(pScrath_mem++) = 0;
-                    test  =  *(pScrath_mem);
-                    temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-                }
-            }
-
-        }   /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */
-
-        pOverlap_and_Add_Buffer_2x =  &Time_data[W_L_STOP_1];
-
-        pScrath_mem = pScrath_mem_entry;
-
-        pOutput_buffer_2 -= SHORT_WINDOW;
-        pOutput_buffer = pOutput_buffer_2;
-
-        test  = *(pScrath_mem++);
-        temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-        for (i = SHORT_WINDOW; i != 0; i--)
-        {
-            limiter(*(pOutput_buffer++), (temp + test));
-
-            test  = *(pScrath_mem++);
-            temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-        }
-
-        pOverlap_and_Add_Buffer_1x = Time_data;
-
-        pOutput_buffer = Output_buffer;
-
-
-        temp = *(pOverlap_and_Add_Buffer_1x++);
-
-        for (i = W_L_STOP_1; i != 0; i--)
-        {
-            limiter(*(pOutput_buffer++), temp);
-
-            temp = *(pOverlap_and_Add_Buffer_1x++);
-        }
-
-        pOverlap_and_Add_Buffer_1x = &Time_data[0];
-
-        pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW];
-
-        /*
-         *  update overlap and add buffer,
-         *  so is ready for next iteration
-         */
-
-        for (int i = 0; i < W_L_STOP_2; i++)
-        {
-            temp = *(pOverlap_and_Add_Buffer_2++);
-            *(pOverlap_and_Add_Buffer_1x++) = temp;
-        }
-
-        pv_memset(
-            pOverlap_and_Add_Buffer_1x,
-            0,
-            W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x));
-
-    } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-}
-
-#endif
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-
-
-
-void trans4m_freq_2_time_fxp_2(
-    Int32               Frequency_data[],
-    Int32               Time_data[],
-    WINDOW_SEQUENCE     wnd_seq,
-    Int                 wnd_shape_prev_bk,
-    Int                 wnd_shape_this_bk,
-    Int                 Q_format,
-    Int32               abs_max_per_window[],
-    Int32               freq_2_time_buffer[],
-    Int16               *Interleaved_output)
-
-{
-
-    Int exp;
-    Int shift;
-
-    Int  i;
-    Int  wnd;
-#if !(defined( PV_ARM_GCC_V5)||(PV_ARM_V5))
-    Int32 z;
-#endif
-    Int16 *pFreqInfo;
-    Int32 temp;
-    Int32 test;
-
-    Int16 *pFreq_2_Time_data_1;
-    Int16 *pFreq_2_Time_data_2;
-
-    const Int16 *pLong_Window_1;
-    const Int16 *pLong_Window_2;
-    const Int16 *pShort_Window_1;
-    const Int16 *pShort_Window_2;
-
-    Int32 *pOverlap_and_Add_Buffer_1;
-    Int32 *pOverlap_and_Add_Buffer_2;
-
-    Int16  *pInterleaved_output;
-    Int16  *pInterleaved_output_2;
-
-
-    const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
-    const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
-    Long_Window_fxp[0] = Long_Window_sine_fxp;
-    Long_Window_fxp[1] = Long_Window_KBD_fxp;
-    Short_Window_fxp[0] = Short_Window_sine_fxp;
-    Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
-    if (wnd_seq != EIGHT_SHORT_SEQUENCE)
-    {
-
-        pFreqInfo = (Int16 *)Frequency_data;
-
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  LONG_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[0]);
-
-
-        /*
-         *  The C Programming Language, Second Edition, Kernighan & Ritchie,
-         *  page 206.
-         *  "The result [of a shift] is undefined if the right operand is
-         *  negative, or greater than or equal to the number of bits in the
-         *  left expression's type"
-         *   => avoid shift by 32 or 16
-         */
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = pFreqInfo;
-
-
-            switch (wnd_seq)
-            {
-
-                case ONLY_LONG_SEQUENCE:
-                default:
-
-                {
-                    pOverlap_and_Add_Buffer_1 = Time_data;
-
-                    pInterleaved_output = Interleaved_output;
-
-                    {
-
-                        const Int16 *pLong_Window_2 = &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-                        Int32 * pFreq2T   = (Int32 *)pFreqInfo;
-                        Int32 * pFreq2T_2 = &pFreq2T[HALF_LONG_WINDOW];
-                        Int32 * win = (Int32 *) & Long_Window_fxp[wnd_shape_prev_bk][0];
-
-                        Int shift = exp + 15 - SCALING;
-
-                        for (i = HALF_LONG_WINDOW; i != 0; i--)
-                        {
-                            Int16 win1, win2;
-                            Int32  temp2, test2;
-
-                            Int32  winx;
-
-                            temp2 = *(pFreq2T++);
-                            winx = *(win++);
-
-                            test  = *(pOverlap_and_Add_Buffer_1++);
-                            test2 = *(pOverlap_and_Add_Buffer_1--);
-                            temp  =   fxp_mul_16_by_16bb(temp2, winx) >> shift;
-                            temp2 =   fxp_mul_16_by_16tt(temp2, winx) >> shift;
-
-                            limiter(*(pInterleaved_output), (temp + test));
-
-                            limiter(*(pInterleaved_output + 2), (temp2 + test2));
-                            pInterleaved_output += 4;
-
-                            temp2 = *(pFreq2T_2++);
-
-                            win1  = *(pLong_Window_2--);
-                            win2  = *(pLong_Window_2--);
-                            temp  = fxp_mul_16_by_16bb(temp2, win1) >> shift;
-                            test2 = fxp_mul_16_by_16tb(temp2, win2) >> shift;
-
-                            *(pOverlap_and_Add_Buffer_1++) = temp;
-                            *(pOverlap_and_Add_Buffer_1++) = test2;
-                        }
-
-                    }
-
-                }
-
-                break;
-
-                case LONG_START_SEQUENCE:
-
-                    pFreq_2_Time_data_2 =
-                        &pFreq_2_Time_data_1[ HALF_LONG_WINDOW];
-
-                    pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
-                    pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[0];
-                    pOverlap_and_Add_Buffer_2 = &Time_data[HALF_LONG_WINDOW];
-
-
-                    pInterleaved_output   = Interleaved_output;
-                    pInterleaved_output_2 = pInterleaved_output + (2 * HALF_LONG_WINDOW);
-
-
-                    /*
-                     *  process first  LONG_WINDOW elements
-                     */
-
-                    shift = exp + 15 - SCALING;
-
-                    for (i = HALF_LONG_WINDOW; i != 0; i--)
-                    {
-                        Int16 win1, win2;
-                        Int16  dat1, dat2;
-                        Int32  test1, test2;
-
-                        dat1   = *(pFreq_2_Time_data_1++);
-                        win1   = *(pLong_Window_1++);
-                        test1  = *(pOverlap_and_Add_Buffer_1++);
-
-                        dat2  =  *(pFreq_2_Time_data_2++);
-                        win2  = *(pLong_Window_2++);
-                        test2 = *(pOverlap_and_Add_Buffer_2++);
-
-                        limiter(*(pInterleaved_output), (test1 + (fxp_mul_16_by_16(dat1, win1) >> shift)));
-
-                        pInterleaved_output   += 2;
-
-                        limiter(*(pInterleaved_output_2), (test2 + (fxp_mul_16_by_16(dat2, win2) >> shift)));
-
-                        pInterleaved_output_2    += 2;
-                    }
-
-
-                    /*
-                     *  data unchanged from  LONG_WINDOW to W_L_START_1
-                     *  only scaled accordingly
-                     */
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[0];
-                    pFreq_2_Time_data_1       = &pFreqInfo[LONG_WINDOW];
-
-                    exp -= SCALING;
-
-                    if (exp >= 0)
-                    {
-
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
-                        {
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++) >> exp;
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++) >> exp;
-
-                        }
-
-                    }
-                    else if (exp < 0)
-                    {
-
-                        Int shift = -exp;
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0 ; i--)
-                        {
-                            Int32 temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp2;
-                            temp2 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp2;
-                        }
-
-                    }
-                    else
-                    {
-
-                        for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
-                        {
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++);
-                            *(pOverlap_and_Add_Buffer_1++) =
-                                *(pFreq_2_Time_data_1++);
-
-                        }
-
-                    }
-
-
-                    pFreq_2_Time_data_1  = &pFreqInfo[W_L_START_1];
-                    pFreq_2_Time_data_2  =
-                        &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
-                    pShort_Window_1   =
-                        &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-                    pShort_Window_2   = pShort_Window_1 - HALF_SHORT_WINDOW;
-
-                    pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1 +
-                                                HALF_SHORT_WINDOW;
-
-                    {
-                        Int16 win1, win2;
-                        Int16  dat1, dat2;
-                        Int32  temp2;
-
-                        for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                        {
-
-                            dat1  = (*pFreq_2_Time_data_1++);
-                            dat2  = (*pFreq_2_Time_data_2++);
-                            win1  = *(pShort_Window_1--);
-                            win2  = *(pShort_Window_2--);
-
-                            temp   =   fxp_mul_16_by_16(dat1, win1) >> shift;
-                            *(pOverlap_and_Add_Buffer_1++) = temp;
-
-                            temp2 =   fxp_mul_16_by_16(dat2, win2) >> shift;
-                            *(pOverlap_and_Add_Buffer_2++) = temp2;
-
-                        }
-                    }
-
-                    pOverlap_and_Add_Buffer_1 += HALF_SHORT_WINDOW;
-
-
-                    pv_memset(
-                        pOverlap_and_Add_Buffer_1,
-                        0,
-                        (LONG_BLOCK1 - W_L_START_2)
-                        *sizeof(*pOverlap_and_Add_Buffer_1));
-
-
-                    break;
-
-
-                case LONG_STOP_SEQUENCE:
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_2];
-
-                    pInterleaved_output    = &Interleaved_output[2*W_L_STOP_2];
-
-                    pFreq_2_Time_data_1      = &pFreqInfo[W_L_STOP_2];
-
-                    exp -= SCALING;
-
-
-                    if (exp > 0)
-                    {
-                        Int16 tmp1 = (*(pFreq_2_Time_data_1++) >> exp);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pInterleaved_output), (temp + tmp1));
-
-                            pInterleaved_output += 2;
-                            tmp1 = *(pFreq_2_Time_data_1++) >> exp;
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-                        }
-                    }
-                    else if (exp < 0)
-                    {
-                        shift = -exp;
-
-                        Int32 temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pInterleaved_output), (temp + temp1));
-
-                            pInterleaved_output += 2;
-                            temp1 = ((Int32) * (pFreq_2_Time_data_1++)) << shift;
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-                        }
-                    }
-                    else
-                    {
-                        Int16 tmp1 = *(pFreq_2_Time_data_1++);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-                        for (i = (LONG_WINDOW - W_L_STOP_2); i != 0; i--)
-                        {
-                            limiter(*(pInterleaved_output), (temp + tmp1));
-
-                            pInterleaved_output += 2;
-                            tmp1 = *(pFreq_2_Time_data_1++);
-                            temp = *(pOverlap_and_Add_Buffer_1++);
-                        }
-                    }
-
-
-
-                    pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
-                    pShort_Window_2 = &pShort_Window_1[HALF_SHORT_WINDOW];
-
-                    pFreq_2_Time_data_1 = &pFreqInfo[W_L_STOP_1];
-                    pFreq_2_Time_data_2 =
-                        &pFreq_2_Time_data_1[HALF_SHORT_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = &Time_data[ W_L_STOP_1];
-                    pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
-                                                + HALF_SHORT_WINDOW;
-
-
-                    pInterleaved_output   = &Interleaved_output[2*W_L_STOP_1];
-                    pInterleaved_output_2 = pInterleaved_output + (2 * HALF_SHORT_WINDOW);
-
-                    exp += SCALING;  /* +8 back to what it was */
-                    shift = exp + 15 - SCALING;
-
-
-                    for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                    {
-
-                        Int16 win1;
-                        Int16 dat1;
-
-                        dat1 = *(pFreq_2_Time_data_1++);
-                        win1 = *(pShort_Window_1++);
-                        temp = *(pOverlap_and_Add_Buffer_1++);
-
-                        test  = fxp_mul_16_by_16(dat1, win1);
-
-                        limiter(*(pInterleaved_output), (temp + (test >> shift)));
-
-                        pInterleaved_output += 2;
-
-                        dat1 = *(pFreq_2_Time_data_2++);
-                        win1 = *(pShort_Window_2++);
-                        temp = *(pOverlap_and_Add_Buffer_2++);
-                        test =  fxp_mul_16_by_16(dat1, win1);
-
-                        limiter(*(pInterleaved_output_2), (temp + (test >> shift)));
-
-                        pInterleaved_output_2 += 2;
-
-                    }
-
-
-
-                    pFreq_2_Time_data_2 = &pFreqInfo[LONG_WINDOW];
-
-                    pOverlap_and_Add_Buffer_1 = Time_data;
-
-
-                    pInterleaved_output = Interleaved_output;
-
-                    pLong_Window_2   =
-                        &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
-                    /*
-                     *  Copy previous time in current buffer, also copy overlap
-                     *  and add buffer
-                     */
-
-                    for (i = W_L_STOP_1; i != 0; i--)
-                    {
-
-                        Int16 win1;
-                        Int16 dat1;
-
-                        win1 = *(pLong_Window_2--);
-                        dat1 = *pFreq_2_Time_data_2++;
-
-                        limiter(*(pInterleaved_output), *(pOverlap_and_Add_Buffer_1));
-
-                        pInterleaved_output += 2;
-
-                        temp = fxp_mul_16_by_16(dat1, win1) >> shift;
-                        *(pOverlap_and_Add_Buffer_1++) = temp ;
-
-                    }
-
-                    for (i = (LONG_WINDOW - W_L_STOP_1); i != 0; i--)
-                    {
-
-                        temp = fxp_mul_16_by_16(*pFreq_2_Time_data_2++, *(pLong_Window_2--)) >> shift;
-                        *(pOverlap_and_Add_Buffer_1++) = temp ;
-
-                    }
-
-                    break;
-
-
-
-            } /* switch (wnd_seq) */
-
-        }   /*  if (exp < 16)  */
-
-        else
-        {
-            /* all zeros buffer or excessive down shift */
-
-            /* Overlap and add, setup buffer for next iteration */
-            pOverlap_and_Add_Buffer_1 = &Time_data[0];
-
-            pInterleaved_output = Interleaved_output;
-
-
-            temp  = (*pOverlap_and_Add_Buffer_1++);
-            for (i = LONG_WINDOW; i != 0; i--)
-            {
-
-                limiter(*(pInterleaved_output), temp);
-
-                pInterleaved_output += 2;
-                temp  = (*pOverlap_and_Add_Buffer_1++);
-            }
-            pv_memset(Time_data, 0, LONG_WINDOW*sizeof(Time_data[0]));
-        }
-
-    }
-    else
-    {
-
-        Int32 *pScrath_mem;
-        Int32 *pScrath_mem_entry;
-        Int32  *pFrequency_data = Frequency_data;
-
-        Int32 * pOverlap_and_Add_Buffer_1;
-        Int32 * pOverlap_and_Add_Buffer_2;
-        Int32 * pOverlap_and_Add_Buffer_1x;
-        Int32 * pOverlap_and_Add_Buffer_2x;
-
-
-        /*
-         *  Frequency_data is 2*LONG_WINDOW length but only
-         *  the first LONG_WINDOW elements are filled in,
-         *  then the second part can be used as scratch mem,
-         *  then grab data from one window at a time in
-         *  reverse order.
-         *  The upper LONG_WINDOW Int32 are used to hold the
-         *  computed overlap and add, used in the next call to
-         *  this function, and also as sctrach memory
-         */
-
-        /*
-         *  Frequency_data usage for the case EIGHT_SHORT_SEQUENCE
-
-          |<----- Input Freq. data ----->|< Overlap & Add ->| Unused |-Scratch-|
-          |                              |  Store for next  |        |  memory |
-          |                              |  call            |        |         |
-          |                              |                  |        |         |
-          |//////////////////////////////|\\\\\\\\\\\\\\\\\\|--------|+++++++++|
-          |                              |                  |        |         |
-          0                         LONG_WINDOW        LONG_WINDOW   |   2*LONG_WINDOW
-                                                            +        |         |
-                                                       W_L_STOP_2    |         |
-                                                                     |<--   -->|
-                                                                      SHORT_WINDOW +
-                                                                    HALF_SHORT_WINDOW
-          *
-          */
-
-        pOverlap_and_Add_Buffer_1  = &pFrequency_data[
-                                         LONG_WINDOW + 3*SHORT_WINDOW + HALF_SHORT_WINDOW];
-
-        /*
-         *  Initialize to zero, only the firt short window used in overlap
-         *  and add
-         */
-        pv_memset(
-            pOverlap_and_Add_Buffer_1,
-            0,
-            SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-
-        /*
-         *  Showt windows are evaluated in decresing order. Windows from 7
-         *  to 0 are break down in four cases: window numbers 7 to 5, 4, 3,
-         *  and 2 to 0.
-         *  The data from short windows 3 and 4 is situated at the boundary
-         *  between the 'overlap and add' buffer and the output buffer.
-         */
-        for (wnd = NUM_SHORT_WINDOWS - 1; wnd >= NUM_SHORT_WINDOWS / 2 + 1; wnd--)
-        {
-
-            pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-            exp = imdct_fxp(
-                      (Int32 *)pFreqInfo,
-                      freq_2_time_buffer,
-                      SHORT_BLOCK1,
-                      Q_format,
-                      abs_max_per_window[wnd]);
-
-            /*  W_L_STOP_1 == (LONG_WINDOW - SHORT_WINDOW)>>1 */
-            pOverlap_and_Add_Buffer_1 =
-                &pFrequency_data[ W_L_STOP_1 + SHORT_WINDOW*wnd];
-
-
-            pOverlap_and_Add_Buffer_2 =
-                pOverlap_and_Add_Buffer_1 + SHORT_WINDOW;
-
-            /*
-             *  If all element are zero or if the exponent is bigger than
-             *  16 ( it becomes an undefined shift) ->  skip
-             */
-
-            if (exp < 16)
-            {
-
-
-                pFreq_2_Time_data_1 = &pFreqInfo[0];
-                pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-                /*
-                 *  Each of the eight short blocks is windowed separately.
-                 *  Window shape decisions are made on a frame-by-frame
-                 *  basis.
-                 */
-
-                pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-                pShort_Window_2   =
-                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-
-
-                /*
-                 * For short windows from 7 to 5
-                 *                                      |   =========================
-                 *                                      |   |     5     6     7
-                 *               _--_  _--_  _--_  _--_ | _-|-_  _--_  _--_  _--_
-                 *              /    \/    \/    \/    \|/  |  \/    \/    \/    \
-                 *             /     /\    /\    /\    /|\  |  /\    /\    /\     \
-                 *            /     /  \  /  \  /  \  / | \ | /  \  /  \  /  \     \
-                 *           /     /    \/    \/    \/  |  \|/    \/    \     \     \
-                 *      --------------------------------|---[///////////////////////]--------
-                 *
-                 */
-
-
-                shift = exp + 15 - SCALING;
-
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    Int16 win1, win2;
-                    Int16  dat1, dat2;
-
-                    dat2 = *(pFreq_2_Time_data_2++);
-                    win2 = *(pShort_Window_2--);
-                    temp = *pOverlap_and_Add_Buffer_2;
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-
-                    *(pOverlap_and_Add_Buffer_2++) =  temp + (fxp_mul_16_by_16(dat2, win2) >> shift);
-
-                    *(pOverlap_and_Add_Buffer_1++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                }
-
-            }   /* if (exp < 16) */
-            else
-            {
-                pv_memset(
-                    pOverlap_and_Add_Buffer_1,
-                    0,
-                    SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-            }
-
-
-        }/* for ( wnd=NUM_SHORT_WINDOWS-1; wnd>=NUM_SHORT_WINDOWS/2; wnd--) */
-
-
-        wnd = NUM_SHORT_WINDOWS / 2;
-
-        pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-        /*
-         *  scratch memory is allocated in an unused part of memory
-         */
-
-
-        pScrath_mem = &pFrequency_data[ 2*LONG_WINDOW - HALF_SHORT_WINDOW];
-
-        pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
-        pOverlap_and_Add_Buffer_2 = pOverlap_and_Add_Buffer_1
-                                    + HALF_SHORT_WINDOW;
-
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  SHORT_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[wnd]);
-
-        /*
-         *  If all element are zero or if the exponent is bigger than
-         *  16 ( it becomes an undefined shift) ->  skip
-         */
-
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = &pFreqInfo[0];
-            pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-            pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-            pShort_Window_2 =
-                &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-            /*
-             * For short window 4
-             *                                    ====|===========
-             *                                        |   4
-             *                                    |   |   |      |
-             *                _--_  _--_  _--_  _-|-_ | _-|-_  _-|-_  _--_  _--_
-             *               /    \/    \/    \/  |  \|/  |  \/  |  \/    \/    \
-             *              /     /\    /\    /\  |  /|\  |  /\  |  /\    /\     \
-             *             /     /  \  /  \  /  \ | / | \ | /  \ | /  \  /  \     \
-             *            /     /    \/    \/    \|/  |  \|/    \|/    \/    \     \
-             *      ------------------------------[\\\|\\\|//////]-------------------
-             *           |                        | A | B |   C  |
-             *           |
-             *        W_L_STOP_1
-             */
-
-            shift = exp + 15 - SCALING;
-            {
-                Int16 win1;
-                Int16  dat1;
-                /* -------- segment A ---------------*/
-                dat1 = *(pFreq_2_Time_data_1++);
-                win1 = *(pShort_Window_1++);
-                for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pScrath_mem++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-                }
-
-                /* -------- segment B ---------------*/
-                for (i = HALF_SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pOverlap_and_Add_Buffer_1++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-                }
-
-                /* -------- segment C ---------------*/
-                temp = *pOverlap_and_Add_Buffer_2;
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    *(pOverlap_and_Add_Buffer_2++)  =  temp + (fxp_mul_16_by_16(dat1, win1) >> shift);
-
-                    temp = *pOverlap_and_Add_Buffer_2;
-                    dat1 = *(pFreq_2_Time_data_2++);
-                    win1 = *(pShort_Window_2--);
-                }
-            }
-
-        }   /* if (exp < 16) */
-        else
-        {
-            pv_memset(
-                pScrath_mem,
-                0,
-                HALF_SHORT_WINDOW*sizeof(*pScrath_mem));
-
-            pv_memset(
-                pOverlap_and_Add_Buffer_1,
-                0,
-                HALF_SHORT_WINDOW*sizeof(*pOverlap_and_Add_Buffer_1));
-        }
-
-
-        wnd = NUM_SHORT_WINDOWS / 2 - 1;
-
-        pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-        pScrath_mem_entry =
-            &pFrequency_data[2*LONG_WINDOW - HALF_SHORT_WINDOW - SHORT_WINDOW];
-
-
-        pScrath_mem = pScrath_mem_entry;
-
-        pOverlap_and_Add_Buffer_1 = &pFrequency_data[ LONG_WINDOW];
-
-        /* point to end of buffer less HALF_SHORT_WINDOW */
-
-        pInterleaved_output_2 = &Interleaved_output[2*(LONG_WINDOW - HALF_SHORT_WINDOW)];
-        pInterleaved_output = pInterleaved_output_2;
-
-        pOverlap_and_Add_Buffer_1x = &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
-
-        exp = imdct_fxp(
-                  (Int32 *)pFreqInfo,
-                  freq_2_time_buffer,
-                  SHORT_BLOCK1,
-                  Q_format,
-                  abs_max_per_window[wnd]);
-
-        /*
-         *  If all element are zero or if the exponent is bigger than
-         *  16 ( it becomes an undefined shift) ->  skip
-         */
-
-        if (exp < 16)
-        {
-
-            pFreq_2_Time_data_1 = &pFreqInfo[0];
-            pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-            /*
-             * For short window 3
-             *                             ===========|====
-             *                                    3   |
-             *                             |      |   |   |
-             *               _--_  _--_  _-|-_  _-|-_ | _-|-_  _--_  _--_  _--_
-             *              /    \/    \/  |  \/  |  \|/  |  \/    \/    \/    \
-             *             /     /\    /\  |  /\  |  /|\  |  /\    /\    /\     \
-             *            /     /  \  /  \ | /  \ | / | \ | /  \  /  \  /  \     \
-             *           /     /    \/    \|/    \|/  |  \|/    \/    \     \     \
-             *     -----|------------------[\\\\\\|///|///]--------------------------
-             *          |                  |   A  | B | C |
-             *
-             *      W_L_STOP_1
-             */
-
-
-            pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-            pShort_Window_2 =
-                &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-            shift = exp + 15 - SCALING;
-
-            Int16 win1;
-            Int16  dat1;
-            /* -------- segment A ---------------*/
-            dat1 = *(pFreq_2_Time_data_1++);
-            win1 = *(pShort_Window_1++);
-            for (i = SHORT_WINDOW; i != 0; i--)
-            {
-                *(pScrath_mem++)  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-                dat1 = *(pFreq_2_Time_data_1++);
-                win1 = *(pShort_Window_1++);
-            }
-
-            dat1 = *(pFreq_2_Time_data_2++);
-            win1 = *(pShort_Window_2--);
-
-
-            /* -------- segment B ---------------*/
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-                test = fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                temp =  *(pScrath_mem++) + test;
-
-                test = *(pOverlap_and_Add_Buffer_1x++);
-                limiter(*(pInterleaved_output), (temp + test));
-
-
-                pInterleaved_output += 2;
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-
-            }
-
-            /* -------- segment C ---------------*/
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-
-                temp = fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                *(pOverlap_and_Add_Buffer_1++) += temp;
-
-                dat1 = *(pFreq_2_Time_data_2++);
-                win1 = *(pShort_Window_2--);
-            }
-
-
-        }   /* if (exp < 16) */
-        else
-        {
-
-            pv_memset(
-                pScrath_mem,
-                0,
-                SHORT_WINDOW*sizeof(*pScrath_mem));
-
-            pScrath_mem += SHORT_WINDOW;
-
-            temp = *(pScrath_mem++);
-            for (i = HALF_SHORT_WINDOW; i != 0; i--)
-            {
-                limiter(*(pInterleaved_output), (temp));
-
-                pInterleaved_output += 2;
-                temp = *(pScrath_mem++);
-
-            }
-        }
-
-
-        for (wnd = NUM_SHORT_WINDOWS / 2 - 2; wnd >= 0; wnd--)
-        {
-
-
-            pInterleaved_output_2 -= (SHORT_WINDOW * 2);
-            pInterleaved_output = pInterleaved_output_2;
-
-            /*
-             * The same memory is used as scratch in every iteration
-             */
-            pScrath_mem = pScrath_mem_entry;
-
-            pOverlap_and_Add_Buffer_2x =
-                &Time_data[W_L_STOP_1 + SHORT_WINDOW*(wnd+1)];
-
-            pFreqInfo = (Int16 *) & pFrequency_data[ wnd*SHORT_WINDOW];
-
-
-
-            exp = imdct_fxp(
-                      (Int32 *)pFreqInfo,
-                      freq_2_time_buffer,
-                      SHORT_BLOCK1,
-                      Q_format,
-                      abs_max_per_window[wnd]);
-
-            /*
-             *  If all element are zero or if the exponent is bigger than
-             *  16 ( it becomes an undefined shift) ->  skip
-             */
-
-            if (exp < 16)
-            {
-
-                pFreq_2_Time_data_1 = &pFreqInfo[0];
-                pFreq_2_Time_data_2 = &pFreqInfo[SHORT_WINDOW];
-
-
-                /*
-                 *  Each of the eight short blocks is windowed separately.
-                 *  Window shape decisions are made on a frame-by-frame
-                 *  basis.
-                 */
-
-                pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-
-                if (wnd == 0)
-                {
-                    pShort_Window_1 =
-                        &Short_Window_fxp[wnd_shape_prev_bk][0];
-                }
-
-                pShort_Window_2   =
-                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-
-                /*
-                 * For short windows from 2 to 0
-                 *
-                 *          =========================
-                 *                                       |
-                 *                0     1     2      |   |
-                 *               _--_  _--_  _--_  _-|-_ | _--_  _--_  _--_  _--_
-                 *              /    \/    \/    \/  |  \|/    \/    \/    \/    \
-                 *             /     /\    /\    /\  |  /|\    /\    /\    /\     \
-                 *            /     /  \  /  \  /  \ | / | \  /  \  /  \  /  \     \
-                 *           /     /    \/    \/    \|/  |  \/    \/    \     \     \
-                 *      ----[\\\\\\\\\\\\\\\\\\\\\\\\]---|-----------------------------
-                 *          |
-                 *
-                 *      W_L_STOP_1
-                 */
-
-                shift = exp + 15 - SCALING;
-
-                Int16 dat1 = *(pFreq_2_Time_data_2++);
-                Int16 win1 = *(pShort_Window_2--);
-
-                temp  =  *(pScrath_mem);
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    test  =  fxp_mul_16_by_16(dat1, win1) >> shift;
-
-                    temp += test;
-                    dat1 = *(pFreq_2_Time_data_1++);
-                    win1 = *(pShort_Window_1++);
-
-                    limiter(*(pInterleaved_output), (temp + *(pOverlap_and_Add_Buffer_2x++)));
-
-                    pInterleaved_output += 2;
-
-                    *(pScrath_mem++) = fxp_mul_16_by_16(dat1, win1) >> shift;
-                    dat1 = *(pFreq_2_Time_data_2++);
-                    win1 = *(pShort_Window_2--);
-                    temp  =  *(pScrath_mem);
-
-                }
-
-            }   /* if (exp < 16) */
-            else
-            {
-                test  = *(pScrath_mem);
-                temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-                for (i = SHORT_WINDOW; i != 0; i--)
-                {
-                    limiter(*(pInterleaved_output), (temp + test));
-
-                    pInterleaved_output += 2;
-
-                    *(pScrath_mem++) = 0;
-                    test  =  *(pScrath_mem);
-                    temp  = *(pOverlap_and_Add_Buffer_2x++);
-                }
-            }
-
-        }   /* for ( wnd=NUM_SHORT_WINDOWS/2-1; wnd>=0; wnd--) */
-
-        pOverlap_and_Add_Buffer_2x =  &Time_data[W_L_STOP_1];
-
-        pScrath_mem = pScrath_mem_entry;
-
-        pInterleaved_output_2 -= (SHORT_WINDOW * 2);
-        pInterleaved_output    = pInterleaved_output_2;
-
-        test  = *(pScrath_mem++);
-        temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-        for (i = SHORT_WINDOW; i != 0; i--)
-        {
-            limiter(*(pInterleaved_output), (temp + test));
-
-            pInterleaved_output += 2;
-            test  = *(pScrath_mem++);
-            temp  = *(pOverlap_and_Add_Buffer_2x++);
-
-        }
-
-        pOverlap_and_Add_Buffer_1x = Time_data;
-
-        pInterleaved_output = Interleaved_output;
-
-
-        temp = *(pOverlap_and_Add_Buffer_1x++);
-        for (i = W_L_STOP_1; i != 0; i--)
-        {
-            limiter(*(pInterleaved_output), temp);
-
-            pInterleaved_output += 2;
-            temp = *(pOverlap_and_Add_Buffer_1x++);
-
-        }
-
-        pOverlap_and_Add_Buffer_1x = &Time_data[0];
-
-        pOverlap_and_Add_Buffer_2 = &pFrequency_data[LONG_WINDOW];
-
-        /*
-         *  update overlap and add buffer,
-         *  so is ready for next iteration
-         */
-
-        for (int i = 0; i < W_L_STOP_2; i++)
-        {
-            temp = *(pOverlap_and_Add_Buffer_2++);
-            *(pOverlap_and_Add_Buffer_1x++) = temp;
-        }
-
-        pv_memset(
-            pOverlap_and_Add_Buffer_1x,
-            0,
-            W_L_STOP_1*sizeof(*pOverlap_and_Add_Buffer_1x));
-
-    } /* if ( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-
-
-
-}   /* trans4m_freq_2_time_fxp */
-
-
-
-
diff --git a/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp b/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp
deleted file mode 100644
index b1b44f0..0000000
--- a/media/libstagefright/codecs/aacdec/trans4m_time_2_freq_fxp.cpp
+++ /dev/null
@@ -1,663 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
-  Pathname: trans4m_time_2_freq_fxp.c
-  Function: trans4m_time_2_freq_fxp
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-        Modified normalization, so it now happen per window basis, eliminated
-        shifts left or rigth to accomodate TNS inverse filtering. The output
-        is 32 bits but only the lowest 16 are being used.
-        Modified fuction interface
-
- Description: Modified variable names with leading "p" for pointers
-
- Description:
-        Modified call to mdct_fxp to reflect extended precision use. Added routine
-        buffer_adaptation to extract 16 MSB and keep highest precision.
-        Modify casting to ensure proper operations for different platforms
-
- Description:
-        Added comments according to code review
-
- Description:
-        Removed include file "buffer_normalization.h"
-
- Description:
-        Eliminated buffer_adaptation() and embedded its functionality in other
-        functions. Commented out the short window section given that this is
-        not supported by the standards
-
- Description:
-        Added shift down operation for case when the window was equal to one.
-        This was not needed previuosly because buffer_adaptation() was doing
-        it.
-
- Description: Created local version of vectors Long_Window_fxp and
-              Short_Window_fxp. This solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers.
-
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-    Time2Freq_data    =  buffer with data in the time domain, it holds 2048
-                         points of input time data
-                         Output holds frequency (first 1024 points )
-                         type Int32
-
-    wnd_seq           =  window sequence
-                         type WINDOW_SEQUENCE
-
-    wnd_shape_prev_bk =  previous window shape type
-                         type Int
-
-    wnd_shape_this_bk =  current window shape type
-                         type Int
-
-    pQ_format          =  Holds the Q format of the data in, and data out
-                         type Int *
-
-    mem_4_in_place_FFT[] =  scratch memory for computing FFT, 1024 point
-                         type Int32
-
-
-
- Local Stores/Buffers/Pointers Needed:
-    None
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    Frequency information (1024 pts.) is returned in Time2Freq_data
-    pQ_format content spectral coefficients Q format
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
-The time/frequency representation of the signal is mapped onto the frequency
-domain by feeding it into the filterbank module. This module consists of
-a modified discrete cosine transform (MDCT), (windowing and DCT).
-In order to adapt the time/frequency resolution of the filterbank to the
- characteristics of the input signal, a block switching tool is also
-adopted. N represents the window length, where N is a function of the
-window_sequence. For each channel, the N time values are transformed into the
-N/2 frequency domain values via the MDCT.
-
-The adaptation of the time-frequency resolution of the filterbank to the
-characteristics of the input signal is done by shifting between transforms
-whose input lengths are either 2048 or 256 samples. By enabling the block
-switching tool, the following transitions are meaningful:
-
-from ONLY_LONG_SEQUENCE to   { LONG_START_SEQUENCE
-                               ONLY_LONG_SEQUENCE
-
-from LONG_START_SEQUENCE to  { LONG_STOP_SEQUENCE
-                               EIGHT_SHORT_SEQUENCE
-
-from LONG_STOP_SEQUENCE to   { LONG_START_SEQUENCE
-                               ONLY_LONG_SEQUENCE
-
-from EIGHT_SHORT_SEQUENCE to { LONG_STOP_SEQUENCE
-                               EIGHT_SHORT_SEQUENCE
-
-Window shape decisions are made by the encoder on a frame-by-frame-basis.
-The window selected is applicable to the second half of the window function
-only, since the first half is constrained to use the appropriate window
-shape from the preceding frame.
-The 2048 time-domain values x'(i)(n), (i window, n sample) to be windowed are
-the last 1024 values of the previous window_sequence concatenated with 1024
-values of the current block. The formula below shows this fact:
-
-                     |  x(i-1)(n+1024)      for    0 < n < 1024
-            x'(i)(n) {
-                     |  x(i)(n)             for 1024 < n < 2048
-
-
-
-Once the window shape is selected, the window_shape syntax element is
-initialized. Together with the chosen window_sequence all information needed
-for windowing exist.
-With the window halves described below all window_sequences can be assembled.
-For window_shape == 1, the window coefficients are given by the Kaiser -
-Bessel derived (KBD) window.
-Otherwise, for window_shape == 0, a sine window is employed.
-
-The window length N can be 2048 or 256 for the KBD and the sine window.
-All four window_sequences explained below have a total length of 2048
-samples.
-For all kinds of window_sequences the window_shape of the left half of
-the first transform window is determined by the window shape of the previous
-block.
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This module shall implement a scheme to switch between window types and
-    in turn perform time to frequency transformations
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] ISO 14496-3:1999, pag 111
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF ( wnd_seq == EIGHT_SHORT_SEQUENCE)
-    THEN
-
-
-        FOR ( wnd=0; wnd<NUM_SHORT_WINDOWS; wnd++)
-
-            time_info = &Time2Freq_data[ W_L_STOP_1 + wnd*SHORT_WINDOW]
-
-            FOR( i=0; i<SHORT_BLOCK1; i++)
-                aux_temp[i] = time_info[i]
-            ENDFOR
-
-
-            IF (wnd == 0)
-            THEN
-                pShort_Window_1 = &Short_Window[wnd_shape_prev_bk][0]
-            ELSE
-                pShort_Window_1 = &Short_Window[wnd_shape_this_bk][0]
-            ENDIF
-
-
-            pShort_Window_2   =
-                    &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1]
-
-            FOR( i=0, j=SHORT_WINDOW; i<SHORT_WINDOW; i++, j--)
-                aux_temp[             i]  *= pShort_Window_1[i]
-                aux_temp[SHORT_WINDOW+i]  *= pShort_Window_2[j]
-            ENDFOR
-
-
-            CALL MDCT( aux_temp, SHORT_BLOCK1)
-            MODIFYING( aux_temp)
-
-            FOR( i=0; i<SHORT_WINDOW; i++)
-                Time2Freq_data[wnd*SHORT_WINDOW + i] = aux_temp[i];
-            ENDFOR
-
-        ENDFOR
-
-    ELSE
-
-        SWITCH ( wnd_seq)
-
-            CASE ( ONLY_LONG_SEQUENCE)
-
-                pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0]
-                pLong_Window_2 =
-                        &Long_Window[wnd_shape_this_bk][LONG_WINDOW_m_1]
-
-                FOR (i=0; i<LONG_WINDOW; i++)
-                    Time2Freq_data[            i] *= *pLong_Window_1++
-                    Time2Freq_data[LONG_WINDOW+i] *= *pLong_Window_2--
-                ENDFOR
-
-                BREAK
-
-
-            CASE ( LONG_START_SEQUENCE)
-
-                pLong_Window_1 = &Long_Window[wnd_shape_prev_bk][0];
-
-                FOR ( i=0; i<LONG_WINDOW; i++)
-                    Time2Freq_data[ i] *= *pLong_Window_1++;
-                ENDFOR
-
-
-                pShort_Window_1   =
-                        &Short_Window[wnd_shape->this_bk][SHORT_WINDOW_m_1];
-
-                FOR ( i=0; i<SHORT_WINDOW; i++)
-                    Time2Freq_data[W_L_START_1 + i] *= *pShort_Window_1--;
-                ENDFOR
-
-
-                FOR ( i=W_L_START_2; i<LONG_BLOCK1; i++)
-                    Time2Freq_data[W_L_START_2 + i] = 0;
-                ENDFOR
-
-                BREAK
-
-
-            CASE ( LONG_STOP_SEQUENCE )
-
-                FOR ( i=0; i<W_L_STOP_1; i++)
-                    Time2Freq_data[ i] = 0;
-                ENDFOR
-
-
-                pShort_Window_1   = &Short_Window[wnd_shape->prev_bk][0];
-
-                FOR ( i=0; i<SHORT_WINDOW; i++)
-                    Time2Freq_data[W_L_STOP_1+ i] *= *pShort_Window_1++;
-                ENDFOR
-
-
-                pLong_Window_1 =
-                        &Long_Window[wnd_shape->this_bk][LONG_WINDOW_m_1];
-
-                FOR ( i=0; i<LONG_WINDOW; i++)
-                    Time2Freq_data[LONG_WINDOW + i]  *=  *pLong_Window_1--;
-                ENDFOR
-
-                BREAK
-
-
-        }
-
-        MDCT( Time2Freq_data, LONG_BLOCK1);
-        MODIFYING( Time2Freq_data)
-
-    ENDIF
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-
-#include "pv_audio_type_defs.h"
-#include "aac_mem_funcs.h"
-#include "window_block_fxp.h"
-#include "mdct_fxp.h"
-#include "long_term_prediction.h"
-#include    "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void trans4m_time_2_freq_fxp(
-    Int32   Time2Freq_data[],       /* time data size 2048 */
-    WINDOW_SEQUENCE wnd_seq,        /* window sequence */
-    Int     wnd_shape_prev_bk,      /* window shape, current and previous  */
-    Int     wnd_shape_this_bk,
-    Int     *pQ_format,
-    Int32   mem_4_in_place_FFT[])   /* scratch memory for computing FFT */
-{
-
-    Int  i;
-
-    Int32   *pAux_temp_1;
-    Int32   *pAux_temp_2;
-    Int32   *pAux_temp;
-//    Int32   temp;
-    const   Int16 *pLong_Window_1;
-    const   Int16 *pLong_Window_2;
-    const   Int16 *pShort_Window_1;
-    const   Int16 *pShort_Window_2;
-    Int     shift = *pQ_format - 1;
-
-    const Int16 * Long_Window_fxp[NUM_WINDOW_SHAPES];
-    const Int16 * Short_Window_fxp[NUM_WINDOW_SHAPES];
-
-    Long_Window_fxp[0] = Long_Window_sine_fxp;
-    Long_Window_fxp[1] = Long_Window_KBD_fxp;
-    Short_Window_fxp[0] = Short_Window_sine_fxp;
-    Short_Window_fxp[1] = Short_Window_KBD_fxp;
-
-    if (wnd_seq != EIGHT_SHORT_SEQUENCE)
-    {
-
-        pAux_temp = Time2Freq_data;
-
-        *pQ_format = LTP_Q_FORMAT - *pQ_format;
-
-        pAux_temp_1 = pAux_temp;
-
-        switch (wnd_seq)
-        {
-
-            case LONG_START_SEQUENCE:
-
-                pAux_temp_2 = &pAux_temp_1[HALF_LONG_WINDOW];
-
-                pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
-                pLong_Window_2 = &pLong_Window_1[ HALF_LONG_WINDOW];
-
-
-
-
-                for (i = HALF_LONG_WINDOW; i > 0; i--)
-                {
-
-                    *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift;
-                    pAux_temp_1++;
-                    *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2++) >> shift;
-                    pAux_temp_2++;
-
-                }
-
-
-                /* data unchanged from  LONG_WINDOW to W_L_START_1 */
-                pAux_temp_1 = &pAux_temp[LONG_WINDOW];
-                if (shift)
-                {
-                    for (i = (W_L_START_1 - LONG_WINDOW) >> 1; i != 0; i--)
-                    {
-                        *(pAux_temp_1++) >>= shift;
-                        *(pAux_temp_1++) >>= shift;
-                    }
-                }
-
-
-                pAux_temp_1 = &pAux_temp[W_L_START_1];
-                pAux_temp_2 = &pAux_temp_1[HALF_SHORT_WINDOW];
-
-                pShort_Window_1   =
-                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-
-                pShort_Window_2   = pShort_Window_1 - HALF_SHORT_WINDOW;
-
-                for (i = HALF_SHORT_WINDOW; i > 0; i--)
-                {
-
-                    *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1--) >> shift;
-                    pAux_temp_1++;
-                    *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2--) >> shift;
-                    pAux_temp_2++;
-
-                }
-
-                pAux_temp_1 = &pAux_temp[W_L_START_2];
-
-                pv_memset(
-                    pAux_temp_1,
-                    0,
-                    (LONG_BLOCK1 - W_L_START_2)*sizeof(*pAux_temp_1));
-
-                break;
-
-
-            case LONG_STOP_SEQUENCE:
-
-                pv_memset(
-                    pAux_temp_1,
-                    0,
-                    (W_L_STOP_1)*sizeof(*pAux_temp_1));
-
-                pShort_Window_1   = &Short_Window_fxp[wnd_shape_prev_bk][0];
-                pShort_Window_2   = &pShort_Window_1[HALF_SHORT_WINDOW];
-
-                pAux_temp_1      = &pAux_temp_1[W_L_STOP_1];
-                pAux_temp_2      = pAux_temp_1 + HALF_SHORT_WINDOW;
-
-                for (i = HALF_SHORT_WINDOW; i > 0; i--)
-                {
-
-                    *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pShort_Window_1++) >> shift;
-                    pAux_temp_1++;
-                    *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pShort_Window_2++) >> shift;
-                    pAux_temp_2++;
-
-
-                }
-
-                /* data unchanged from  W_L_STOP_2 to LONG_WINDOW */
-                pAux_temp_1 = &pAux_temp[W_L_STOP_2];
-
-                if (shift)
-                {
-                    for (i = ((LONG_WINDOW - W_L_STOP_2) >> 1); i != 0; i--)
-                    {
-                        *(pAux_temp_1++) >>= shift;
-                        *(pAux_temp_1++) >>= shift;
-                    }
-                }
-
-
-
-                pAux_temp_1 = &pAux_temp[LONG_WINDOW];
-                pAux_temp_2 =  pAux_temp_1 + HALF_LONG_WINDOW;
-
-                pLong_Window_1 =
-                    &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
-                pLong_Window_2   = &pLong_Window_1[-HALF_LONG_WINDOW];
-
-                for (i = HALF_LONG_WINDOW; i > 0; i--)
-                {
-                    *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1--) >> shift;
-                    pAux_temp_1++;
-                    *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift;
-                    pAux_temp_2++;
-
-                }
-
-                break;
-
-            case ONLY_LONG_SEQUENCE:
-            default:
-
-                pAux_temp_2 = &pAux_temp[LONG_WINDOW];
-
-                pLong_Window_1 = &Long_Window_fxp[wnd_shape_prev_bk][0];
-
-
-                pLong_Window_2 =
-                    &Long_Window_fxp[wnd_shape_this_bk][LONG_WINDOW_m_1];
-
-
-                for (i = LONG_WINDOW; i > 0; i--)
-                {
-
-                    *pAux_temp_1 = fxp_mul32_by_16((*pAux_temp_1), *pLong_Window_1++) >> shift;
-                    pAux_temp_1++;
-                    *pAux_temp_2 = fxp_mul32_by_16((*pAux_temp_2), *pLong_Window_2--) >> shift;
-                    pAux_temp_2++;
-                }
-
-                break;
-
-        }   /* end switch ( wnd_seq)  */
-
-
-
-        *pQ_format += mdct_fxp(
-                          pAux_temp,
-                          mem_4_in_place_FFT,
-                          LONG_BLOCK1);
-
-
-    }   /* end if( wnd_seq != EIGHT_SHORT_SEQUENCE) */
-
-
-
-    /*****************************************/
-    /* decoding process for short window */
-    /*****************************************/
-
-    /*
-     * For short window the following code will be applied
-     * in the future when short window is supported in the
-     * standards
-     */
-    /*-------------------------------------------------------------------------
-
-    *        pAux_temp = &mem_4_in_place_FFT[(2*SHORT_BLOCK1)];
-    *
-    *        for ( wnd=0; wnd<NUM_SHORT_WINDOWS; wnd++)
-    *        {
-    *
-    *            pShort_Window_1 = &Short_Window_fxp[wnd_shape_this_bk][0];
-    *
-    *            if (wnd == 0)
-    *            {
-    *                pShort_Window_1 = &Short_Window_fxp[wnd_shape_prev_bk][0];
-    *            }
-    *
-    *            pShort_Window_2   =
-    *                    &Short_Window_fxp[wnd_shape_this_bk][SHORT_WINDOW_m_1];
-    *
-    *            pAux_temp_1 =  pAux_temp;
-    *            pAux_temp_2 = pAux_temp_1 + SHORT_WINDOW;
-    *
-    *            Q_aux = 0;
-    *
-    *            buffer_adaptation (
-    *                &Q_aux,
-    *                &Time2Freq_data[ W_L_STOP_1 + wnd*SHORT_WINDOW],
-    *                (void *) pAux_temp,
-    *                SHORT_BLOCK1,
-    *                USING_INT,
-    *                16);
-    *
-    *
-    *            for ( i=SHORT_WINDOW; i>0; i--)
-    *            {
-    *                temp           = (*pAux_temp_1) * *pShort_Window_1++;
-    *                *pAux_temp_1++ = (temp + 0x08000L) >> 16;
-    *
-    *                temp           = (*pAux_temp_2) * *pShort_Window_2--;
-    *                *pAux_temp_2++ = (temp + 0x08000L) >> 16;
-    *
-    *            }
-    *
-    *
-    *            exp = mdct_fxp(
-    *                pAux_temp,
-    *                mem_4_in_place_FFT,
-    *                SHORT_BLOCK1);
-    *
-    *
-    *            exp += Q_aux;
-    *
-    *            pAux_temp_1  =  pAux_temp;
-    *            pAux_temp_2  =  pAux_temp_1  +  HALF_SHORT_WINDOW;
-    *            pTime_data_1 = &Time2Freq_data[wnd*SHORT_WINDOW];
-    *            pTime_data_2 =  pTime_data_1 + HALF_SHORT_WINDOW;
-    *
-    *
-    *            if (exp > 0)
-    *            {
-    *                for ( i=HALF_SHORT_WINDOW; i>0; i--)
-    *                {
-    *                    *pTime_data_1++ = (*pAux_temp_1++>>exp);
-    *                    *pTime_data_2++ = (*pAux_temp_2++>>exp);
-    *                }
-    *            }
-    *            else if (exp < 0)
-    *            {
-    *                exp = -exp;
-    *                for ( i=HALF_SHORT_WINDOW; i>0; i--)
-    *                {
-    *                    *pTime_data_1++ = (*pAux_temp_1++<<exp);
-    *                    *pTime_data_2++ = (*pAux_temp_2++<<exp);
-    *                }
-    *            }
-    *            else
-    *            {
-    *                for ( i=HALF_SHORT_WINDOW; i>0; i--)
-    *                {
-    *                    *pTime_data_1++ = (*pAux_temp_1++);
-    *                    *pTime_data_2++ = (*pAux_temp_2++);
-    *                }
-    *            }
-    *
-    *        }
-    *
-    *    }
-    *
-    *--------------------------------------------------------------------------*/
-
-}   /* trans4m_time_2_freq_fxp */
diff --git a/media/libstagefright/codecs/aacdec/unpack_idx.cpp b/media/libstagefright/codecs/aacdec/unpack_idx.cpp
deleted file mode 100644
index 9180994..0000000
--- a/media/libstagefright/codecs/aacdec/unpack_idx.cpp
+++ /dev/null
@@ -1,660 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./src/unpack_idx.c
- Function:  unpack_idx
-            unpack_idx_sgn
-            unpack_idx_esc
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:  Modified from original shareware code
-
- Description:  Eliminated 3 divisions and 1 multiplication through a table
- look-up method for calculating 1/mod and constant allocation of 1/mod^3
- and 1/mod^2.
- Eliminated 3 additions through simple optimizations in the code.
- Changed if/else  statement to a switch/case utilizing fall-through.
-
- Description:   Made changes per review comments.  Main improvements were
- in change of switch/case to if statement, and use of temporary variable
- to hold value of *pQuantSpec.
-
- Description: (1) Typecast codeword_indx to Int32 before multiplication, this
-              assures the shift operation happens on a 32-bit product on
-              TI-C55x processor.
-              (2) define temp_spec as Int32 to avoid overflow
-
- Description: Modified per review comments
-              (1) remove the two typecastings of codeword_indx when
-                  pHuffCodebook->dim == DIMENSION_4
-              (2) temp_spec is Int because the result never exceeds 16 bits
-
- Description: Break up and combine unpack index with sign bit reading and for
-              special escape code. Parent function must know which one of the
-              3 functions should be called.
-
- Description: Put back if-statement to get the max.
-
- Description: When searching for the max, there was some instances where the
-              max was compared against a negative number, so the max was never
-              updated (defaulted to 0), leading to block processing in other
-              magnitude sensitive stages.
-
- Who:                       Date:
- Description:
-------------------------------------------------------------------------------
- INPUT AND OUTPUT DEFINITIONS
-
- Inputs:
-          Int  quant_spec[]  = Array for storage of the quantized
-                               spectral coefficients.  Length is either 2 or 4.
-                               See Ref #1, Page 76 for a complete description.
-
-          Int  codeword_indx = The index into the Huffman table.
-                               Range is [1-288]
-
-    const Hcb *pHuffCodebook = Pointer to HuffmanCodebook information.
-
-          BITS  *pInputStream = Pointer to the bitstream buffer.
-          Int *max           = Pointer to maximum coefficient value.
-
- Local Stores/Buffers/Pointers Needed:
-    const UInt div_mod[18]   = An array with the values for 1/mod
-                               stored in Q-formats 13.
-
- Global Stores/Buffers/Pointers Needed:
-    None
-
- Outputs:
-    None
-
- Pointers and Buffers Modified:
-    Int quant_spec[] = Output (the quantized and signed spectral coefficients)
-                       returned via this pointer.
-
- Local Stores Modified:
-    None
-
- Global Stores Modified:
-    None
-
-------------------------------------------------------------------------------
- FUNCTION DESCRIPTION
-
- This function decodes quantized spectral coefficients and decode their signs
- from the input bitstream. Quantized spectral coefficients are transmitted as
- four-tuples or 2-tuples, and this information is conveyed to the function via
- the variable HuffCodebook->dim.
-
- See Reference #1 for a complete description
-------------------------------------------------------------------------------
- REQUIREMENTS
-
- This function shall correctly calculate pQuantSpec[], given the inputs
-
- codeword_indx     = {1-288};
- HuffCodebook->off = {0, 1, 4};
- HuffCodebook->mod = {3, 8, 9, 13, 17};
-
- mod =   LAV + 1 if unsigned codebook
- mod = 2*LAV + 1 if   signed codebook
-
- Range of values for LAV is {2,7,12,16} if unsigned
-                            {1,4}       if   signed
-
- Additionally,
-     LAV <= 2 if dim == 4
-
- This restricts mod ==  3                if dim == 4
-            and mod == {3, 8, 9, 13, 17} if dim == 2
-
- This function will NOT function correctly if fed values that do not
- meet the requirements as stated above.
-
- This limitation on the range of values was determined by analysis
- of Reference #1 (see below.)
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 14496-3:1999(E)
-     Part 3
-        Subpart 4.6.3.3   Decoding Process
-        Subpart 4.6.4     Tables
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC  gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her  own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
- PSEUDO-CODE
-
-    IF (pHuffCodebook->dim == 4)
-        *(pQuantSpec) = codeword_indx/(3^3);
-        codeword_indx = codeword_indx - *(pQuantSpec)*(3^3);
-        *(pQuantSpec) = *(pQuantSpec) - off;
-
-        pQuantSpec    = pQuantSpec + 1;
-
-        *(pQuantSpec) = codeword_indx/(3^2);
-        codeword_indx = codeword_indx - *(pQuantSpec)*(3^2);
-        *(pQuantSpec) = *(pQuantSpec) - off;
-
-        pQuantSpec    = pQuantSpec + 1;
-    ENDIF
-
-        *(pQuantSpec) = codeword_indx/mod;
-        codeword_indx = codeword_indx - (*pQuantSpec)*mod;
-        *(pQuantSpec) = *(pQuantSpec) - off;
-
-        pQuantSpec    = pQuantSpec + 1;
-
-        *(pQuantSpec) = codeword_indx - off;
-
-------------------------------------------------------------------------------
- RESOURCES USED
-   When the code is written for a specific target processor the
-     the resources used should be documented below.
-
- STACK USAGE: [stack count for this module] + [variable to represent
-          stack usage for each subroutine called]
-
-     where: [stack usage variable] = stack usage for [subroutine
-         name] (see [filename].ext)
-
- DATA MEMORY USED: x words
-
- PROGRAM MEMORY USED: x words
-
- CLOCK CYCLES: [cycle count equation for this module] + [variable
-           used to represent cycle count for each subroutine
-           called]
-
-     where: [cycle count variable] = cycle count for [subroutine
-        name] (see [filename].ext)
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "s_hcb.h"
-#include "ibstream.h"
-#include "unpack_idx.h"
-
-#include "fxp_mul32.h"
-
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-#define DIV_3_CUBED    19  /* 19 = 1/27 in Q-9 format    */
-#define THREE_CUBED    27  /* 27 = 3^3                   */
-
-#define DIV_3_SQUARED  57  /* 57 = 1/9  in Q-9 format    */
-#define THREE_SQUARED   9  /*  9 = 3^2                   */
-
-#define Q_FORMAT_MOD   13  /* Q-format for 1/mod table   */
-#define Q_FORMAT_MOD2   9  /* Q-format for DIV_3_SQUARED */
-#define Q_FORMAT_MOD3   9  /* Q-format for DIV_3_CUBED   */
-
-#define LOWER_5_BITS_MASK 0x1F
-
-
-#if ( defined(PV_ARM_V5) || defined(PV_ARM_V4))
-
-__inline Int32 abs1(Int32 x)
-{
-    Int32 z;
-    /*
-        z = x - (x<0);
-        x = z ^ sign(z)
-     */
-    __asm
-    {
-        sub  z, x, x, lsr #31
-        eor  x, z, z, asr #31
-    }
-    return (x);
-}
-
-#define pv_abs(x)   abs1(x)
-
-
-#else
-
-#define pv_abs(x)   ((x) > 0)? (x) : (-x)
-
-#endif
-
-
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL STORE/BUFFER/POINTER DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-/*--------------------------------------------------------------------------
-    Possible values for mod = {3,8,9,13,17}
-
-    There exists "empty" spaces in the table.  These can potentially
-    be utilized by other const tables, if available memory becomes an issue.
----------------------------------------------------------------------------*/
-
-const Int div_mod[18] =   /*   mod   index  Q-format */
-{
-    /* ----------------------- */
-    0xCC,                 /* |      |  0  |          */
-    0xCC,                 /* |      |  1  |          */
-    0xCC,                 /* |      |  2  |          */
-    2731,                 /* |  3   |  3  |   13     */
-    0xCC,                 /* |      |  4  |          */
-    0xCC,                 /* |      |  5  |          */
-    0xCC,                 /* |      |  6  |          */
-    0xCC,                 /* |      |  7  |          */
-    1025,                 /* |  8   |  8  |   13     */
-    911,                 /* |  9   |  9  |   13     */
-    0xCC,                 /* |      | 10  |          */
-    0xCC,                 /* |      | 11  |          */
-    0xCC,                 /* |      | 12  |          */
-    631,                 /* |  13  | 13  |   13     */
-    0xCC,                 /* |      | 14  |          */
-    0xCC,                 /* |      | 15  |          */
-    0xCC,                 /* |      | 16  |          */
-    482,                 /* |  17  | 17  |   13     */
-};
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; FUNCTION CODE
-----------------------------------------------------------------------------*/
-void unpack_idx(
-    Int16   quant_spec[],
-    Int codeword_indx,
-    const Hcb   *pHuffCodebook,
-    BITS  *pInputStream,
-    Int *max)
-{
-    Int16 *pQuantSpec = &quant_spec[0];
-    Int  temp_spec;
-
-    const Int mod = pHuffCodebook->mod;
-    const Int off = pHuffCodebook->off;
-
-    OSCL_UNUSED_ARG(pInputStream);
-
-
-    if (pHuffCodebook->dim == DIMENSION_4)
-    {
-        /* Calculate pQuantSpec[0] */
-
-        temp_spec      = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3;
-
-        codeword_indx -= temp_spec * THREE_CUBED;
-
-        temp_spec -= off;
-        *pQuantSpec++  = (Int16)temp_spec;
-
-        temp_spec = pv_abs(temp_spec);
-
-        if (temp_spec > *max)
-        {
-            *max = temp_spec;
-        }
-
-        /* Calculate pQuantSpec[1] */
-        temp_spec      = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2;
-
-        codeword_indx -= temp_spec * THREE_SQUARED;
-
-        temp_spec -= off;
-        *pQuantSpec++  = (Int16)temp_spec;
-
-        temp_spec = pv_abs(temp_spec);
-
-        if (temp_spec > *max)
-        {
-            *max = temp_spec;
-        }
-    }
-
-    /*
-     *  Calculate pQuantSpec[2] if dim == 4
-     *  Calculate pQuantSpec[0] if dim == 2
-     */
-
-    temp_spec      = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
-    codeword_indx -= temp_spec * mod;
-
-    temp_spec -= off;
-    *pQuantSpec++  = (Int16)temp_spec;
-
-    temp_spec = pv_abs(temp_spec);
-
-
-    if (temp_spec > *max)
-    {
-        *max = temp_spec;
-    }
-
-    /*
-    *  Calculate pQuantSpec[3] if dim == 4
-    *  Calculate pQuantSpec[1] if dim == 2
-    */
-    codeword_indx -= off;
-    *pQuantSpec    = (Int16)codeword_indx ;
-
-
-    codeword_indx = pv_abs(codeword_indx);
-
-    if (codeword_indx > *max)
-    {
-        *max = codeword_indx;
-    }
-
-
-    return ;
-} /* unpack_idx */
-
-
-void unpack_idx_sgn(
-    Int16   quant_spec[],
-    Int codeword_indx,
-    const Hcb   *pHuffCodebook,
-    BITS  *pInputStream,
-    Int *max)
-{
-    Int16 *pQuantSpec = &quant_spec[0];
-    Int  temp_spec;
-    Int  sgn;
-
-    const Int mod = pHuffCodebook->mod;
-    const Int off = pHuffCodebook->off;
-
-
-
-    if (pHuffCodebook->dim == DIMENSION_4)
-    {
-        /* Calculate pQuantSpec[0] */
-        preload_cache((Int32 *)pQuantSpec);
-        temp_spec      = (codeword_indx * DIV_3_CUBED) >> Q_FORMAT_MOD3;
-
-        codeword_indx -= temp_spec * THREE_CUBED;
-
-        temp_spec -= off;
-        if (temp_spec)
-        {
-            sgn = get1bits(pInputStream);
-
-
-            *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
-            temp_spec = pv_abs(temp_spec);
-
-            if (temp_spec > *max)
-            {
-                *max = temp_spec;
-            }
-
-        }
-        else
-        {
-            *pQuantSpec++ = 0;
-        }
-
-        /* Calculate pQuantSpec[1] */
-        temp_spec      = (codeword_indx * DIV_3_SQUARED) >> Q_FORMAT_MOD2;
-
-        codeword_indx -= temp_spec * THREE_SQUARED;
-
-        temp_spec -= off;
-        if (temp_spec)
-        {
-
-            sgn = get1bits(pInputStream);
-
-            *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
-            temp_spec = pv_abs(temp_spec);
-
-            if (temp_spec > *max)
-            {
-                *max = temp_spec;
-            }
-        }
-        else
-        {
-            *pQuantSpec++ = 0;
-        }
-    }
-
-    /*
-     *  Calculate pQuantSpec[2] if dim == 4
-     *  Calculate pQuantSpec[0] if dim == 2
-     */
-
-    temp_spec      = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
-    codeword_indx -= temp_spec * mod;
-
-    temp_spec -= off;
-    if (temp_spec)
-    {
-
-        sgn = get1bits(pInputStream);
-
-        *pQuantSpec++ = (Int16)((sgn) ? -temp_spec : temp_spec);
-
-        temp_spec = pv_abs(temp_spec);
-
-        if (temp_spec > *max)
-        {
-            *max = temp_spec;
-        }
-    }
-    else
-    {
-        *pQuantSpec++ = 0;
-    }
-
-    /*
-     *  Calculate pQuantSpec[3] if dim == 4
-     *  Calculate pQuantSpec[1] if dim == 2
-     */
-    codeword_indx -= off;
-    if (codeword_indx)
-    {
-
-        sgn = get1bits(pInputStream);
-
-        *pQuantSpec = (Int16)((sgn) ? -codeword_indx : codeword_indx);
-
-        codeword_indx = pv_abs(codeword_indx);
-
-        if (codeword_indx > *max)
-        {
-            *max = codeword_indx;
-        }
-    }
-    else
-    {
-        *pQuantSpec = 0;
-    }
-
-    return ;
-} /* unpack_idx_sgn */
-
-
-void unpack_idx_esc(
-    Int16   quant_spec[],
-    Int codeword_indx,
-    const Hcb   *pHuffCodebook,
-    BITS  *pInputStream,
-    Int *max)
-{
-    Int  temp_spec;
-    Int  sgn1 = 0, sgn2 = 0;
-    Int N;
-    Int32 esc_seq;
-
-    const Int mod = pHuffCodebook->mod;
-    const Int off = pHuffCodebook->off;
-
-
-    temp_spec      = ((Int32) codeword_indx * div_mod[mod]) >> Q_FORMAT_MOD;
-
-    codeword_indx -= temp_spec * mod;
-
-    temp_spec -= off;
-    if (temp_spec)
-    {
-        sgn1 = get1bits(pInputStream);
-    }
-
-    codeword_indx -= off;
-    if (codeword_indx)
-    {
-        sgn2 = get1bits(pInputStream);
-    }
-
-
-    if ((temp_spec & LOWER_5_BITS_MASK) == 16)
-    {
-        N = 3;
-        do
-        {
-            N++;
-
-            esc_seq = get1bits(pInputStream);
-
-        }
-        while (esc_seq != 0);
-
-        esc_seq  = getbits(N, pInputStream);
-
-        esc_seq += (1 << N);
-
-
-        temp_spec = (Int)((temp_spec * esc_seq) >> 4);
-
-    }
-
-
-    if (sgn1)
-    {
-        quant_spec[0]  = (Int16)(-temp_spec);
-    }
-    else
-    {
-        quant_spec[0]  = (Int16)temp_spec;
-    }
-
-    temp_spec = pv_abs(temp_spec);
-
-    if (temp_spec > *max)
-    {
-        *max = temp_spec;
-    }
-
-    if ((codeword_indx & LOWER_5_BITS_MASK) == 16)
-    {
-        N = 3;
-        do
-        {
-            N++;
-
-            esc_seq = get1bits(pInputStream);
-
-        }
-        while (esc_seq != 0);
-
-        esc_seq  = getbits(N, pInputStream);
-
-        esc_seq += (1 << N);
-
-        codeword_indx = (Int)((codeword_indx * esc_seq) >> 4);
-    }
-
-
-
-
-    if (sgn2)
-    {
-        quant_spec[1]    = (Int16)(-codeword_indx);
-    }
-    else
-    {
-        quant_spec[1]    = (Int16)codeword_indx;
-    }
-
-
-    codeword_indx = pv_abs(codeword_indx);
-
-    if (codeword_indx > *max)
-    {
-        *max = codeword_indx;
-    }
-
-
-    return ;
-} /* unpack_idx_esc */
diff --git a/media/libstagefright/codecs/aacdec/unpack_idx.h b/media/libstagefright/codecs/aacdec/unpack_idx.h
deleted file mode 100644
index a308c4a..0000000
--- a/media/libstagefright/codecs/aacdec/unpack_idx.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: ./include/unpack_idx.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Who:                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- This header file includes the function definition for unpack_idx()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef UNPACK_IDX_H
-#define UNPACK_IDX_H
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include    "pv_audio_type_defs.h"
-#include    "s_hcb.h"
-#include    "s_bits.h"
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here.
-----------------------------------------------------------------------------*/
-#define DIMENSION_4     4
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; SIMPLE TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; ENUMERATED TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; STRUCTURES TYPEDEF'S
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; GLOBAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-
-    void unpack_idx(
-        Int16  QuantSpec[],
-        Int  codeword_indx,
-        const Hcb *pHuffCodebook,
-        BITS  *pInputStream,
-        Int *max);
-    void unpack_idx_sgn(
-        Int16  quant_spec[],
-        Int  codeword_indx,
-        const Hcb *pHuffCodebook,
-        BITS  *pInputStream,
-        Int *max);
-    void unpack_idx_esc(
-        Int16  quant_spec[],
-        Int  codeword_indx,
-        const Hcb *pHuffCodebook,
-        BITS  *pInputStream,
-        Int *max);
-
-#ifdef __cplusplus
-}
-#endif
-
-/*----------------------------------------------------------------------------
-; END
-----------------------------------------------------------------------------*/
-#endif
-
-
diff --git a/media/libstagefright/codecs/aacdec/window_block_fxp.h b/media/libstagefright/codecs/aacdec/window_block_fxp.h
deleted file mode 100644
index f936199..0000000
--- a/media/libstagefright/codecs/aacdec/window_block_fxp.h
+++ /dev/null
@@ -1,231 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: window_block_fxp.h
-
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-    modified function definition: Time_data from Int to Int32
-    change wnd_shape from structure to passing parameters
-    delete definition of wnd_shape1, not needed.
-
- Description: Modified based on unit test comments
-
- Description: Change copyright, add () around constants.
-
- Description:
-    changed Long_Window_fxp and Short _Window_fxp tables definition, from
-    "const UInt16 *"  to "const UInt16 * const" to avoid global variable
-    definition.
-
- Description: Updated function trans4m_freq_2_time_fxp definition
-
- Description:  Modified function interface to add output_buffer
-
-
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for window and block switch
-
-
-------------------------------------------------------------------------------
- REFERENCES
-
- (1) ISO/IEC 13818-7 Part 7: Advanced Audo Coding (AAC)
-
-
- (2) MPEG-2 NBC Audio Decoder
-   "This software module was originally developed by AT&T, Dolby
-   Laboratories, Fraunhofer Gesellschaft IIS in the course of development
-   of the MPEG-2 NBC/MPEG-4 Audio standard ISO/IEC 13818-7, 14496-1,2 and
-   3. This software module is an implementation of a part of one or more
-   MPEG-2 NBC/MPEG-4 Audio tools as specified by the MPEG-2 NBC/MPEG-4
-   Audio standard. ISO/IEC gives users of the MPEG-2 NBC/MPEG-4 Audio
-   standards free license to this software module or modifications thereof
-   for use in hardware or software products claiming conformance to the
-   MPEG-2 NBC/MPEG-4 Audio  standards. Those intending to use this software
-   module in hardware or software products are advised that this use may
-   infringe existing patents. The original developer of this software
-   module and his/her company, the subsequent editors and their companies,
-   and ISO/IEC have no liability for use of this software module or
-   modifications thereof in an implementation. Copyright is not released
-   for non MPEG-2 NBC/MPEG-4 Audio conforming products.The original
-   developer retains full right to use the code for his/her own purpose,
-   assign or donate the code to a third party and to inhibit third party
-   from using the code for non MPEG-2 NBC/MPEG-4 Audio conforming products.
-   This copyright notice must be included in all copies or derivative
-   works."
-   Copyright(c)1996.
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef WINDOW_BLOCK_FXP_H
-#define WINDOW_BLOCK_FXP_H
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "e_window_shape.h"
-#include "e_window_sequence.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-#define LONG_WINDOW         (1024)
-#define SHORT_WINDOW        (128)
-
-#define HALF_LONG_WINDOW    (LONG_WINDOW>>1)
-#define HALF_SHORT_WINDOW   (SHORT_WINDOW>>1)
-
-#define NUM_SHORT_WINDOWS   (8)
-#define LONG_WINDOW_m_1     (LONG_WINDOW-1)
-#define SHORT_WINDOW_m_1    (SHORT_WINDOW-1)
-
-    /*
-     *  Limits for window sequences, they are used to build
-     *  each long window, they are defined in the standards
-     */
-#define W_L_START_1         ((3*LONG_WINDOW - SHORT_WINDOW)>>1)
-#define W_L_START_2         ((3*LONG_WINDOW + SHORT_WINDOW)>>1)
-#define W_L_STOP_1          ((LONG_WINDOW - SHORT_WINDOW)>>1)
-#define W_L_STOP_2          ((LONG_WINDOW + SHORT_WINDOW)>>1)
-
-
-#define LONG_BLOCK1          (2*LONG_WINDOW)
-#define SHORT_BLOCK1         (2*SHORT_WINDOW)
-
-
-#define  SCALING    10
-#define  ROUNDING     (1<<(SCALING-1))
-
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-    extern const Int16 Short_Window_KBD_fxp[ SHORT_WINDOW];
-    extern const Int16 Long_Window_KBD_fxp[ LONG_WINDOW];
-    extern const Int16 Short_Window_sine_fxp[ SHORT_WINDOW];
-    extern const Int16 Long_Window_sine_fxp[ LONG_WINDOW];
-
-    extern const Int16 * const Long_Window_fxp[];
-    extern const Int16 * const Short_Window_fxp[];
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-    void trans4m_freq_2_time_fxp(
-        Int32   Frequency_data[],
-        Int32   Time_data[],
-#ifdef AAC_PLUS
-        Int32   Output_buffer[],
-#else
-        Int16   Output_buffer[],
-#endif
-        WINDOW_SEQUENCE wnd_seq,
-        Int     wnd_shape_prev_bk,
-        Int     wnd_shape_this_bk,
-        Int     Q_format,
-        Int32   abs_max_per_window[],
-        Int32   freq_2_time_buffer[] ,
-        Int16   *Interleave_output
-    );
-
-
-
-    void trans4m_freq_2_time_fxp_1(
-        Int32   Frequency_data[],
-        Int32   Time_data[],
-        Int16   Output_buffer[],
-        WINDOW_SEQUENCE wnd_seq,
-        Int     wnd_shape_prev_bk,
-        Int     wnd_shape_this_bk,
-        Int     Q_format,
-        Int32   abs_max_per_window[],
-        Int32   freq_2_time_buffer[]
-    );
-
-
-    void trans4m_freq_2_time_fxp_2(
-        Int32   Frequency_data[],
-        Int32   Time_data[],
-        WINDOW_SEQUENCE wnd_seq,
-        Int     wnd_shape_prev_bk,
-        Int     wnd_shape_this_bk,
-        Int     Q_format,
-        Int32   abs_max_per_window[],
-        Int32   freq_2_time_buffer[] ,
-        Int16   *Interleave_output
-    );
-
-    void trans4m_time_2_freq_fxp(
-        Int32   Time2Freq_data[],
-        WINDOW_SEQUENCE wnd_seq,
-        Int     wnd_shape_prev_bk,
-        Int     wnd_shape_this_bk,
-        Int     *pQ_format,
-        Int32   mem_4_in_place_FFT[]);
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif  /*  WINDOW_BLOCK_FXP_H */
-
diff --git a/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp b/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp
deleted file mode 100644
index aa04225..0000000
--- a/media/libstagefright/codecs/aacdec/window_tables_fxp.cpp
+++ /dev/null
@@ -1,730 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: window_tables_fxp.c
- Funtions:
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description:
-    changed table content definition from UInt to UInt16.
-
- Description:
-    changed Long_Window_fxp and Short _Window_fxp tables definition, from
-    "const UInt16 *"  to "const UInt16 * const" to avoid global variable
-    definition.
-
- Description:
-    Improved rounding on table elements.
-
- Description: Eliminated structure to avoid assigning addresses to constant
-              tables. This solve linking problem when using the
-              /ropi option (Read-only position independent) for some
-              compilers
-              - Eliminated Long_Window_fxp and Short_Window_fxp as global
-                contants vectors
-
- Who:                       Date:
- Description:
-
-  ------------------------------------------------------------------------------
- MODULE DESCRIPTION
-
-    Window tables
-
-        For a sine table with N  points:
-
-            w_left  = sin(pi/N (n + 1/2))     for 0   =< n < N/2
-
-            w_rigth = sin(pi/N (n + 1/2))     for N/2 =< n < N
-
-
-        For Kaiser-Bessel derived (KBD)
-
-                               n             N/2
-            w_left  =  sqrt(( SUM W(p,a) )/( SUM W(p,a) )   for   0   =< n < N/2
-                              p=0            p=0
-
-
-                             N-n-1           N/2
-            w_rigth =  sqrt(( SUM W(p,a) )/( SUM W(p,a) )   for   N/2 =< n < N
-                              p=0            p=0
-
-
-            W(p,a) see ISO 14496-3, pag 113
-
-------------------------------------------------------------------------------
- REQUIREMENTS
-
-    This module shall implement the fix point verwion of the windowing tables
-
-------------------------------------------------------------------------------
- REFERENCES
-
-    [1] ISO 14496-3, pag 113
-
-------------------------------------------------------------------------------
-*/
-
-
-/*----------------------------------------------------------------------------
-; INCLUDES
-----------------------------------------------------------------------------*/
-#include "pv_audio_type_defs.h"
-#include "window_block_fxp.h"
-
-/*----------------------------------------------------------------------------
-; MACROS
-; Define module specific macros here
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; DEFINES
-; Include all pre-processor statements here. Include conditional
-; compile variables also.
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL FUNCTION DEFINITIONS
-; Function Prototype declaration
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; LOCAL VARIABLE DEFINITIONS
-; Variable declaration - defined here and used outside this module
-----------------------------------------------------------------------------*/
-
-
-/*----------------------------------------------------------------------------
-; EXTERNAL FUNCTION REFERENCES
-; Declare functions defined elsewhere and referenced in this module
-----------------------------------------------------------------------------*/
-
-/*----------------------------------------------------------------------------
-; EXTERNAL VARIABLES REFERENCES
-; Declare variables used in this module but defined elsewhere
-----------------------------------------------------------------------------*/
-
-
-const Int16 Long_Window_sine_fxp[LONG_WINDOW] =
-{
-
-
-    0x0019,  0x004B,  0x007E,  0x00B0,
-    0x00E2,  0x0114,  0x0147,  0x0179,
-    0x01AB,  0x01DD,  0x0210,  0x0242,
-    0x0274,  0x02A7,  0x02D9,  0x030B,
-    0x033D,  0x0370,  0x03A2,  0x03D4,
-    0x0406,  0x0438,  0x046B,  0x049D,
-    0x04CF,  0x0501,  0x0534,  0x0566,
-    0x0598,  0x05CA,  0x05FC,  0x062F,
-    0x0661,  0x0693,  0x06C5,  0x06F7,
-    0x072A,  0x075C,  0x078E,  0x07C0,
-    0x07F2,  0x0825,  0x0857,  0x0889,
-    0x08BB,  0x08ED,  0x091F,  0x0951,
-    0x0984,  0x09B6,  0x09E8,  0x0A1A,
-    0x0A4C,  0x0A7E,  0x0AB0,  0x0AE2,
-    0x0B14,  0x0B46,  0x0B78,  0x0BAB,
-    0x0BDD,  0x0C0F,  0x0C41,  0x0C73,
-    0x0CA5,  0x0CD7,  0x0D09,  0x0D3B,
-    0x0D6D,  0x0D9F,  0x0DD1,  0x0E03,
-    0x0E35,  0x0E67,  0x0E99,  0x0ECA,
-    0x0EFC,  0x0F2E,  0x0F60,  0x0F92,
-    0x0FC4,  0x0FF6,  0x1028,  0x105A,
-    0x108B,  0x10BD,  0x10EF,  0x1121,
-    0x1153,  0x1185,  0x11B6,  0x11E8,
-    0x121A,  0x124C,  0x127D,  0x12AF,
-    0x12E1,  0x1312,  0x1344,  0x1376,
-    0x13A8,  0x13D9,  0x140B,  0x143C,
-    0x146E,  0x14A0,  0x14D1,  0x1503,
-    0x1534,  0x1566,  0x1598,  0x15C9,
-    0x15FB,  0x162C,  0x165E,  0x168F,
-    0x16C1,  0x16F2,  0x1724,  0x1755,
-    0x1786,  0x17B8,  0x17E9,  0x181B,
-    0x184C,  0x187D,  0x18AF,  0x18E0,
-    0x1911,  0x1942,  0x1974,  0x19A5,
-    0x19D6,  0x1A07,  0x1A39,  0x1A6A,
-    0x1A9B,  0x1ACC,  0x1AFD,  0x1B2E,
-    0x1B60,  0x1B91,  0x1BC2,  0x1BF3,
-    0x1C24,  0x1C55,  0x1C86,  0x1CB7,
-    0x1CE8,  0x1D19,  0x1D4A,  0x1D7B,
-    0x1DAC,  0x1DDC,  0x1E0D,  0x1E3E,
-    0x1E6F,  0x1EA0,  0x1ED1,  0x1F01,
-    0x1F32,  0x1F63,  0x1F94,  0x1FC4,
-    0x1FF5,  0x2026,  0x2056,  0x2087,
-    0x20B7,  0x20E8,  0x2119,  0x2149,
-    0x217A,  0x21AA,  0x21DB,  0x220B,
-    0x223C,  0x226C,  0x229C,  0x22CD,
-    0x22FD,  0x232E,  0x235E,  0x238E,
-    0x23BE,  0x23EF,  0x241F,  0x244F,
-    0x247F,  0x24AF,  0x24E0,  0x2510,
-    0x2540,  0x2570,  0x25A0,  0x25D0,
-    0x2600,  0x2630,  0x2660,  0x2690,
-    0x26C0,  0x26F0,  0x2720,  0x274F,
-    0x277F,  0x27AF,  0x27DF,  0x280F,
-    0x283E,  0x286E,  0x289E,  0x28CD,
-    0x28FD,  0x292D,  0x295C,  0x298C,
-    0x29BB,  0x29EB,  0x2A1A,  0x2A4A,
-    0x2A79,  0x2AA8,  0x2AD8,  0x2B07,
-    0x2B37,  0x2B66,  0x2B95,  0x2BC4,
-    0x2BF4,  0x2C23,  0x2C52,  0x2C81,
-    0x2CB0,  0x2CDF,  0x2D0E,  0x2D3D,
-    0x2D6C,  0x2D9B,  0x2DCA,  0x2DF9,
-    0x2E28,  0x2E57,  0x2E86,  0x2EB5,
-    0x2EE3,  0x2F12,  0x2F41,  0x2F70,
-    0x2F9E,  0x2FCD,  0x2FFC,  0x302A,
-    0x3059,  0x3087,  0x30B6,  0x30E4,
-    0x3113,  0x3141,  0x316F,  0x319E,
-    0x31CC,  0x31FA,  0x3229,  0x3257,
-    0x3285,  0x32B3,  0x32E1,  0x330F,
-    0x333E,  0x336C,  0x339A,  0x33C8,
-    0x33F6,  0x3423,  0x3451,  0x347F,
-    0x34AD,  0x34DB,  0x3509,  0x3536,
-    0x3564,  0x3592,  0x35BF,  0x35ED,
-    0x361A,  0x3648,  0x3676,  0x36A3,
-    0x36D0,  0x36FE,  0x372B,  0x3759,
-    0x3786,  0x37B3,  0x37E0,  0x380E,
-    0x383B,  0x3868,  0x3895,  0x38C2,
-    0x38EF,  0x391C,  0x3949,  0x3976,
-    0x39A3,  0x39D0,  0x39FD,  0x3A29,
-    0x3A56,  0x3A83,  0x3AB0,  0x3ADC,
-    0x3B09,  0x3B35,  0x3B62,  0x3B8E,
-    0x3BBB,  0x3BE7,  0x3C14,  0x3C40,
-    0x3C6C,  0x3C99,  0x3CC5,  0x3CF1,
-    0x3D1D,  0x3D4A,  0x3D76,  0x3DA2,
-    0x3DCE,  0x3DFA,  0x3E26,  0x3E52,
-    0x3E7D,  0x3EA9,  0x3ED5,  0x3F01,
-    0x3F2D,  0x3F58,  0x3F84,  0x3FB0,
-    0x3FDB,  0x4007,  0x4032,  0x405E,
-    0x4089,  0x40B5,  0x40E0,  0x410B,
-    0x4136,  0x4162,  0x418D,  0x41B8,
-    0x41E3,  0x420E,  0x4239,  0x4264,
-    0x428F,  0x42BA,  0x42E5,  0x4310,
-    0x433B,  0x4365,  0x4390,  0x43BB,
-    0x43E5,  0x4410,  0x443B,  0x4465,
-    0x448F,  0x44BA,  0x44E4,  0x450F,
-    0x4539,  0x4563,  0x458D,  0x45B8,
-    0x45E2,  0x460C,  0x4636,  0x4660,
-    0x468A,  0x46B4,  0x46DE,  0x4707,
-    0x4731,  0x475B,  0x4785,  0x47AE,
-    0x47D8,  0x4802,  0x482B,  0x4855,
-    0x487E,  0x48A7,  0x48D1,  0x48FA,
-    0x4923,  0x494D,  0x4976,  0x499F,
-    0x49C8,  0x49F1,  0x4A1A,  0x4A43,
-    0x4A6C,  0x4A95,  0x4ABE,  0x4AE6,
-    0x4B0F,  0x4B38,  0x4B61,  0x4B89,
-    0x4BB2,  0x4BDA,  0x4C03,  0x4C2B,
-    0x4C53,  0x4C7C,  0x4CA4,  0x4CCC,
-    0x4CF4,  0x4D1D,  0x4D45,  0x4D6D,
-    0x4D95,  0x4DBD,  0x4DE5,  0x4E0D,
-    0x4E34,  0x4E5C,  0x4E84,  0x4EAB,
-    0x4ED3,  0x4EFB,  0x4F22,  0x4F4A,
-    0x4F71,  0x4F99,  0x4FC0,  0x4FE7,
-    0x500E,  0x5036,  0x505D,  0x5084,
-    0x50AB,  0x50D2,  0x50F9,  0x5120,
-    0x5147,  0x516D,  0x5194,  0x51BB,
-    0x51E2,  0x5208,  0x522F,  0x5255,
-    0x527C,  0x52A2,  0x52C8,  0x52EF,
-    0x5315,  0x533B,  0x5361,  0x5387,
-    0x53AE,  0x53D4,  0x53FA,  0x541F,
-    0x5445,  0x546B,  0x5491,  0x54B7,
-    0x54DC,  0x5502,  0x5527,  0x554D,
-    0x5572,  0x5598,  0x55BD,  0x55E2,
-    0x5608,  0x562D,  0x5652,  0x5677,
-    0x569C,  0x56C1,  0x56E6,  0x570B,
-    0x5730,  0x5754,  0x5779,  0x579E,
-    0x57C2,  0x57E7,  0x580C,  0x5830,
-    0x5854,  0x5879,  0x589D,  0x58C1,
-    0x58E5,  0x590A,  0x592E,  0x5952,
-    0x5976,  0x599A,  0x59BD,  0x59E1,
-    0x5A05,  0x5A29,  0x5A4C,  0x5A70,
-    0x5A94,  0x5AB7,  0x5ADA,  0x5AFE,
-    0x5B21,  0x5B44,  0x5B68,  0x5B8B,
-    0x5BAE,  0x5BD1,  0x5BF4,  0x5C17,
-    0x5C3A,  0x5C5D,  0x5C7F,  0x5CA2,
-    0x5CC5,  0x5CE7,  0x5D0A,  0x5D2C,
-    0x5D4F,  0x5D71,  0x5D94,  0x5DB6,
-    0x5DD8,  0x5DFA,  0x5E1C,  0x5E3E,
-    0x5E60,  0x5E82,  0x5EA4,  0x5EC6,
-    0x5EE8,  0x5F09,  0x5F2B,  0x5F4D,
-    0x5F6E,  0x5F90,  0x5FB1,  0x5FD2,
-    0x5FF4,  0x6015,  0x6036,  0x6057,
-    0x6078,  0x6099,  0x60BA,  0x60DB,
-    0x60FC,  0x611D,  0x613D,  0x615E,
-    0x617F,  0x619F,  0x61C0,  0x61E0,
-    0x6200,  0x6221,  0x6241,  0x6261,
-    0x6281,  0x62A1,  0x62C1,  0x62E1,
-    0x6301,  0x6321,  0x6341,  0x6360,
-    0x6380,  0x63A0,  0x63BF,  0x63DF,
-    0x63FE,  0x641D,  0x643D,  0x645C,
-    0x647B,  0x649A,  0x64B9,  0x64D8,
-    0x64F7,  0x6516,  0x6535,  0x6554,
-    0x6572,  0x6591,  0x65AF,  0x65CE,
-    0x65EC,  0x660B,  0x6629,  0x6647,
-    0x6666,  0x6684,  0x66A2,  0x66C0,
-    0x66DE,  0x66FC,  0x6719,  0x6737,
-    0x6755,  0x6772,  0x6790,  0x67AE,
-    0x67CB,  0x67E8,  0x6806,  0x6823,
-    0x6840,  0x685D,  0x687A,  0x6897,
-    0x68B4,  0x68D1,  0x68EE,  0x690B,
-    0x6927,  0x6944,  0x6961,  0x697D,
-    0x699A,  0x69B6,  0x69D2,  0x69EE,
-    0x6A0B,  0x6A27,  0x6A43,  0x6A5F,
-    0x6A7B,  0x6A97,  0x6AB2,  0x6ACE,
-    0x6AEA,  0x6B05,  0x6B21,  0x6B3C,
-    0x6B58,  0x6B73,  0x6B8E,  0x6BAA,
-    0x6BC5,  0x6BE0,  0x6BFB,  0x6C16,
-    0x6C31,  0x6C4C,  0x6C66,  0x6C81,
-    0x6C9C,  0x6CB6,  0x6CD1,  0x6CEB,
-    0x6D06,  0x6D20,  0x6D3A,  0x6D54,
-    0x6D6E,  0x6D88,  0x6DA2,  0x6DBC,
-    0x6DD6,  0x6DF0,  0x6E0A,  0x6E23,
-    0x6E3D,  0x6E56,  0x6E70,  0x6E89,
-    0x6EA2,  0x6EBC,  0x6ED5,  0x6EEE,
-    0x6F07,  0x6F20,  0x6F39,  0x6F52,
-    0x6F6B,  0x6F83,  0x6F9C,  0x6FB4,
-    0x6FCD,  0x6FE5,  0x6FFE,  0x7016,
-    0x702E,  0x7046,  0x705F,  0x7077,
-    0x708F,  0x70A6,  0x70BE,  0x70D6,
-    0x70EE,  0x7105,  0x711D,  0x7134,
-    0x714C,  0x7163,  0x717A,  0x7192,
-    0x71A9,  0x71C0,  0x71D7,  0x71EE,
-    0x7205,  0x721C,  0x7232,  0x7249,
-    0x7260,  0x7276,  0x728D,  0x72A3,
-    0x72B9,  0x72D0,  0x72E6,  0x72FC,
-    0x7312,  0x7328,  0x733E,  0x7354,
-    0x7369,  0x737F,  0x7395,  0x73AA,
-    0x73C0,  0x73D5,  0x73EB,  0x7400,
-    0x7415,  0x742A,  0x743F,  0x7454,
-    0x7469,  0x747E,  0x7493,  0x74A8,
-    0x74BC,  0x74D1,  0x74E5,  0x74FA,
-    0x750E,  0x7522,  0x7537,  0x754B,
-    0x755F,  0x7573,  0x7587,  0x759B,
-    0x75AE,  0x75C2,  0x75D6,  0x75E9,
-    0x75FD,  0x7610,  0x7624,  0x7637,
-    0x764A,  0x765E,  0x7671,  0x7684,
-    0x7697,  0x76A9,  0x76BC,  0x76CF,
-    0x76E2,  0x76F4,  0x7707,  0x7719,
-    0x772C,  0x773E,  0x7750,  0x7762,
-    0x7774,  0x7786,  0x7798,  0x77AA,
-    0x77BC,  0x77CE,  0x77DF,  0x77F1,
-    0x7803,  0x7814,  0x7825,  0x7837,
-    0x7848,  0x7859,  0x786A,  0x787B,
-    0x788C,  0x789D,  0x78AE,  0x78BE,
-    0x78CF,  0x78E0,  0x78F0,  0x7901,
-    0x7911,  0x7921,  0x7931,  0x7941,
-    0x7952,  0x7962,  0x7971,  0x7981,
-    0x7991,  0x79A1,  0x79B0,  0x79C0,
-    0x79CF,  0x79DF,  0x79EE,  0x79FD,
-    0x7A0D,  0x7A1C,  0x7A2B,  0x7A3A,
-    0x7A49,  0x7A57,  0x7A66,  0x7A75,
-    0x7A83,  0x7A92,  0x7AA0,  0x7AAF,
-    0x7ABD,  0x7ACB,  0x7AD9,  0x7AE7,
-    0x7AF5,  0x7B03,  0x7B11,  0x7B1F,
-    0x7B2D,  0x7B3A,  0x7B48,  0x7B55,
-    0x7B63,  0x7B70,  0x7B7D,  0x7B8B,
-    0x7B98,  0x7BA5,  0x7BB2,  0x7BBF,
-    0x7BCB,  0x7BD8,  0x7BE5,  0x7BF1,
-    0x7BFE,  0x7C0A,  0x7C17,  0x7C23,
-    0x7C2F,  0x7C3B,  0x7C47,  0x7C53,
-    0x7C5F,  0x7C6B,  0x7C77,  0x7C83,
-    0x7C8E,  0x7C9A,  0x7CA5,  0x7CB1,
-    0x7CBC,  0x7CC7,  0x7CD2,  0x7CDD,
-    0x7CE8,  0x7CF3,  0x7CFE,  0x7D09,
-    0x7D14,  0x7D1E,  0x7D29,  0x7D33,
-    0x7D3E,  0x7D48,  0x7D52,  0x7D5C,
-    0x7D67,  0x7D71,  0x7D7B,  0x7D84,
-    0x7D8E,  0x7D98,  0x7DA2,  0x7DAB,
-    0x7DB5,  0x7DBE,  0x7DC8,  0x7DD1,
-    0x7DDA,  0x7DE3,  0x7DEC,  0x7DF5,
-    0x7DFE,  0x7E07,  0x7E10,  0x7E18,
-    0x7E21,  0x7E29,  0x7E32,  0x7E3A,
-    0x7E42,  0x7E4B,  0x7E53,  0x7E5B,
-    0x7E63,  0x7E6B,  0x7E73,  0x7E7A,
-    0x7E82,  0x7E8A,  0x7E91,  0x7E99,
-    0x7EA0,  0x7EA7,  0x7EAF,  0x7EB6,
-    0x7EBD,  0x7EC4,  0x7ECB,  0x7ED2,
-    0x7ED8,  0x7EDF,  0x7EE6,  0x7EEC,
-    0x7EF3,  0x7EF9,  0x7EFF,  0x7F05,
-    0x7F0C,  0x7F12,  0x7F18,  0x7F1E,
-    0x7F23,  0x7F29,  0x7F2F,  0x7F35,
-    0x7F3A,  0x7F40,  0x7F45,  0x7F4A,
-    0x7F50,  0x7F55,  0x7F5A,  0x7F5F,
-    0x7F64,  0x7F69,  0x7F6D,  0x7F72,
-    0x7F77,  0x7F7B,  0x7F80,  0x7F84,
-    0x7F88,  0x7F8D,  0x7F91,  0x7F95,
-    0x7F99,  0x7F9D,  0x7FA1,  0x7FA4,
-    0x7FA8,  0x7FAC,  0x7FAF,  0x7FB3,
-    0x7FB6,  0x7FB9,  0x7FBD,  0x7FC0,
-    0x7FC3,  0x7FC6,  0x7FC9,  0x7FCC,
-    0x7FCE,  0x7FD1,  0x7FD4,  0x7FD6,
-    0x7FD9,  0x7FDB,  0x7FDD,  0x7FE0,
-    0x7FE2,  0x7FE4,  0x7FE6,  0x7FE8,
-    0x7FEA,  0x7FEB,  0x7FED,  0x7FEF,
-    0x7FF0,  0x7FF2,  0x7FF3,  0x7FF5,
-    0x7FF6,  0x7FF7,  0x7FF8,  0x7FF9,
-    0x7FFA,  0x7FFB,  0x7FFC,  0x7FFC,
-    0x7FFD,  0x7FFD,  0x7FFE,  0x7FFE,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF
-
-};
-
-
-const Int16 Short_Window_sine_fxp[SHORT_WINDOW] =
-{
-
-    0x00C9,  0x025B,  0x03ED,  0x057F,
-    0x0711,  0x08A2,  0x0A33,  0x0BC4,
-    0x0D54,  0x0EE3,  0x1072,  0x1201,
-    0x138F,  0x151C,  0x16A8,  0x1833,
-    0x19BE,  0x1B47,  0x1CCF,  0x1E57,
-    0x1FDD,  0x2161,  0x22E5,  0x2467,
-    0x25E8,  0x2767,  0x28E5,  0x2A61,
-    0x2BDC,  0x2D55,  0x2ECC,  0x3041,
-    0x31B5,  0x3326,  0x3496,  0x3604,
-    0x376F,  0x38D9,  0x3A40,  0x3BA5,
-    0x3D07,  0x3E68,  0x3FC5,  0x4121,
-    0x427A,  0x43D0,  0x4524,  0x4675,
-    0x47C3,  0x490F,  0x4A58,  0x4B9D,
-    0x4CE0,  0x4E20,  0x4F5D,  0x5097,
-    0x51CE,  0x5302,  0x5432,  0x5560,
-    0x568A,  0x57B0,  0x58D3,  0x59F3,
-    0x5B0F,  0x5C28,  0x5D3E,  0x5E4F,
-    0x5F5D,  0x6068,  0x616E,  0x6271,
-    0x6370,  0x646C,  0x6563,  0x6656,
-    0x6746,  0x6832,  0x6919,  0x69FD,
-    0x6ADC,  0x6BB7,  0x6C8E,  0x6D61,
-    0x6E30,  0x6EFB,  0x6FC1,  0x7083,
-    0x7140,  0x71F9,  0x72AE,  0x735E,
-    0x740A,  0x74B2,  0x7555,  0x75F3,
-    0x768D,  0x7722,  0x77B3,  0x783F,
-    0x78C7,  0x794A,  0x79C8,  0x7A41,
-    0x7AB6,  0x7B26,  0x7B91,  0x7BF8,
-    0x7C59,  0x7CB6,  0x7D0E,  0x7D62,
-    0x7DB0,  0x7DFA,  0x7E3E,  0x7E7E,
-    0x7EB9,  0x7EEF,  0x7F21,  0x7F4D,
-    0x7F74,  0x7F97,  0x7FB4,  0x7FCD,
-    0x7FE1,  0x7FF0,  0x7FF9,  0x7FFE
-};
-
-
-
-const Int16 Long_Window_KBD_fxp[LONG_WINDOW] =
-{
-
-    0x000A,  0x000E,  0x0012,  0x0015,
-    0x0019,  0x001C,  0x0020,  0x0023,
-    0x0026,  0x002A,  0x002D,  0x0030,
-    0x0034,  0x0038,  0x003B,  0x003F,
-    0x0043,  0x0047,  0x004B,  0x004F,
-    0x0053,  0x0057,  0x005B,  0x0060,
-    0x0064,  0x0069,  0x006D,  0x0072,
-    0x0077,  0x007C,  0x0081,  0x0086,
-    0x008B,  0x0091,  0x0096,  0x009C,
-    0x00A1,  0x00A7,  0x00AD,  0x00B3,
-    0x00B9,  0x00BF,  0x00C6,  0x00CC,
-    0x00D3,  0x00DA,  0x00E0,  0x00E7,
-    0x00EE,  0x00F5,  0x00FD,  0x0104,
-    0x010C,  0x0113,  0x011B,  0x0123,
-    0x012B,  0x0133,  0x013C,  0x0144,
-    0x014D,  0x0156,  0x015F,  0x0168,
-    0x0171,  0x017A,  0x0183,  0x018D,
-    0x0197,  0x01A1,  0x01AB,  0x01B5,
-    0x01BF,  0x01CA,  0x01D4,  0x01DF,
-    0x01EA,  0x01F5,  0x0200,  0x020C,
-    0x0217,  0x0223,  0x022F,  0x023B,
-    0x0247,  0x0253,  0x0260,  0x026D,
-    0x027A,  0x0287,  0x0294,  0x02A1,
-    0x02AF,  0x02BC,  0x02CA,  0x02D8,
-    0x02E7,  0x02F5,  0x0304,  0x0312,
-    0x0321,  0x0331,  0x0340,  0x034F,
-    0x035F,  0x036F,  0x037F,  0x038F,
-    0x03A0,  0x03B0,  0x03C1,  0x03D2,
-    0x03E3,  0x03F5,  0x0406,  0x0418,
-    0x042A,  0x043C,  0x044F,  0x0461,
-    0x0474,  0x0487,  0x049A,  0x04AE,
-    0x04C1,  0x04D5,  0x04E9,  0x04FD,
-    0x0512,  0x0526,  0x053B,  0x0550,
-    0x0566,  0x057B,  0x0591,  0x05A7,
-    0x05BD,  0x05D3,  0x05EA,  0x0601,
-    0x0618,  0x062F,  0x0646,  0x065E,
-    0x0676,  0x068E,  0x06A6,  0x06BF,
-    0x06D8,  0x06F1,  0x070A,  0x0723,
-    0x073D,  0x0757,  0x0771,  0x078C,
-    0x07A6,  0x07C1,  0x07DC,  0x07F7,
-    0x0813,  0x082F,  0x084B,  0x0867,
-    0x0884,  0x08A0,  0x08BD,  0x08DA,
-    0x08F8,  0x0916,  0x0933,  0x0952,
-    0x0970,  0x098F,  0x09AE,  0x09CD,
-    0x09EC,  0x0A0C,  0x0A2C,  0x0A4C,
-    0x0A6C,  0x0A8D,  0x0AAD,  0x0ACF,
-    0x0AF0,  0x0B11,  0x0B33,  0x0B55,
-    0x0B78,  0x0B9A,  0x0BBD,  0x0BE0,
-    0x0C03,  0x0C27,  0x0C4B,  0x0C6F,
-    0x0C93,  0x0CB8,  0x0CDD,  0x0D02,
-    0x0D27,  0x0D4D,  0x0D73,  0x0D99,
-    0x0DBF,  0x0DE6,  0x0E0C,  0x0E33,
-    0x0E5B,  0x0E82,  0x0EAA,  0x0ED2,
-    0x0EFB,  0x0F23,  0x0F4C,  0x0F75,
-    0x0F9F,  0x0FC8,  0x0FF2,  0x101C,
-    0x1047,  0x1071,  0x109C,  0x10C7,
-    0x10F3,  0x111E,  0x114A,  0x1176,
-    0x11A3,  0x11D0,  0x11FC,  0x122A,
-    0x1257,  0x1285,  0x12B3,  0x12E1,
-    0x130F,  0x133E,  0x136D,  0x139C,
-    0x13CB,  0x13FB,  0x142B,  0x145B,
-    0x148B,  0x14BC,  0x14ED,  0x151E,
-    0x1550,  0x1581,  0x15B3,  0x15E5,
-    0x1618,  0x164A,  0x167D,  0x16B0,
-    0x16E3,  0x1717,  0x174B,  0x177F,
-    0x17B3,  0x17E8,  0x181D,  0x1852,
-    0x1887,  0x18BC,  0x18F2,  0x1928,
-    0x195E,  0x1995,  0x19CB,  0x1A02,
-    0x1A39,  0x1A71,  0x1AA8,  0x1AE0,
-    0x1B18,  0x1B50,  0x1B89,  0x1BC1,
-    0x1BFA,  0x1C34,  0x1C6D,  0x1CA7,
-    0x1CE0,  0x1D1A,  0x1D55,  0x1D8F,
-    0x1DCA,  0x1E05,  0x1E40,  0x1E7B,
-    0x1EB7,  0x1EF2,  0x1F2E,  0x1F6B,
-    0x1FA7,  0x1FE4,  0x2020,  0x205D,
-    0x209B,  0x20D8,  0x2116,  0x2153,
-    0x2191,  0x21D0,  0x220E,  0x224D,
-    0x228B,  0x22CA,  0x2309,  0x2349,
-    0x2388,  0x23C8,  0x2408,  0x2448,
-    0x2488,  0x24C9,  0x2509,  0x254A,
-    0x258B,  0x25CC,  0x260E,  0x264F,
-    0x2691,  0x26D3,  0x2715,  0x2757,
-    0x2799,  0x27DC,  0x281F,  0x2861,
-    0x28A4,  0x28E8,  0x292B,  0x296E,
-    0x29B2,  0x29F6,  0x2A3A,  0x2A7E,
-    0x2AC2,  0x2B06,  0x2B4B,  0x2B8F,
-    0x2BD4,  0x2C19,  0x2C5E,  0x2CA3,
-    0x2CE9,  0x2D2E,  0x2D74,  0x2DB9,
-    0x2DFF,  0x2E45,  0x2E8B,  0x2ED1,
-    0x2F18,  0x2F5E,  0x2FA5,  0x2FEB,
-    0x3032,  0x3079,  0x30C0,  0x3107,
-    0x314E,  0x3195,  0x31DD,  0x3224,
-    0x326C,  0x32B4,  0x32FB,  0x3343,
-    0x338B,  0x33D3,  0x341B,  0x3463,
-    0x34AC,  0x34F4,  0x353D,  0x3585,
-    0x35CE,  0x3616,  0x365F,  0x36A8,
-    0x36F1,  0x373A,  0x3783,  0x37CC,
-    0x3815,  0x385E,  0x38A7,  0x38F0,
-    0x393A,  0x3983,  0x39CC,  0x3A16,
-    0x3A5F,  0x3AA9,  0x3AF2,  0x3B3C,
-    0x3B86,  0x3BCF,  0x3C19,  0x3C63,
-    0x3CAC,  0x3CF6,  0x3D40,  0x3D8A,
-    0x3DD3,  0x3E1D,  0x3E67,  0x3EB1,
-    0x3EFB,  0x3F45,  0x3F8E,  0x3FD8,
-    0x4022,  0x406C,  0x40B6,  0x4100,
-    0x414A,  0x4193,  0x41DD,  0x4227,
-    0x4271,  0x42BB,  0x4304,  0x434E,
-    0x4398,  0x43E1,  0x442B,  0x4475,
-    0x44BE,  0x4508,  0x4551,  0x459B,
-    0x45E4,  0x462E,  0x4677,  0x46C0,
-    0x4709,  0x4753,  0x479C,  0x47E5,
-    0x482E,  0x4877,  0x48C0,  0x4909,
-    0x4951,  0x499A,  0x49E3,  0x4A2B,
-    0x4A74,  0x4ABC,  0x4B04,  0x4B4D,
-    0x4B95,  0x4BDD,  0x4C25,  0x4C6D,
-    0x4CB5,  0x4CFC,  0x4D44,  0x4D8C,
-    0x4DD3,  0x4E1A,  0x4E62,  0x4EA9,
-    0x4EF0,  0x4F37,  0x4F7E,  0x4FC4,
-    0x500B,  0x5051,  0x5098,  0x50DE,
-    0x5124,  0x516A,  0x51B0,  0x51F6,
-    0x523B,  0x5281,  0x52C6,  0x530B,
-    0x5351,  0x5396,  0x53DA,  0x541F,
-    0x5464,  0x54A8,  0x54EC,  0x5530,
-    0x5574,  0x55B8,  0x55FC,  0x563F,
-    0x5683,  0x56C6,  0x5709,  0x574C,
-    0x578F,  0x57D1,  0x5814,  0x5856,
-    0x5898,  0x58DA,  0x591B,  0x595D,
-    0x599E,  0x59E0,  0x5A21,  0x5A61,
-    0x5AA2,  0x5AE3,  0x5B23,  0x5B63,
-    0x5BA3,  0x5BE3,  0x5C22,  0x5C62,
-    0x5CA1,  0x5CE0,  0x5D1F,  0x5D5D,
-    0x5D9C,  0x5DDA,  0x5E18,  0x5E56,
-    0x5E93,  0x5ED1,  0x5F0E,  0x5F4B,
-    0x5F87,  0x5FC4,  0x6000,  0x603D,
-    0x6079,  0x60B4,  0x60F0,  0x612B,
-    0x6166,  0x61A1,  0x61DC,  0x6216,
-    0x6250,  0x628A,  0x62C4,  0x62FE,
-    0x6337,  0x6370,  0x63A9,  0x63E2,
-    0x641A,  0x6452,  0x648A,  0x64C2,
-    0x64F9,  0x6531,  0x6568,  0x659E,
-    0x65D5,  0x660B,  0x6641,  0x6677,
-    0x66AD,  0x66E2,  0x6717,  0x674C,
-    0x6781,  0x67B5,  0x67E9,  0x681D,
-    0x6851,  0x6885,  0x68B8,  0x68EB,
-    0x691D,  0x6950,  0x6982,  0x69B4,
-    0x69E6,  0x6A17,  0x6A48,  0x6A79,
-    0x6AAA,  0x6ADB,  0x6B0B,  0x6B3B,
-    0x6B6A,  0x6B9A,  0x6BC9,  0x6BF8,
-    0x6C27,  0x6C55,  0x6C83,  0x6CB1,
-    0x6CDF,  0x6D0D,  0x6D3A,  0x6D67,
-    0x6D93,  0x6DC0,  0x6DEC,  0x6E18,
-    0x6E44,  0x6E6F,  0x6E9A,  0x6EC5,
-    0x6EF0,  0x6F1A,  0x6F44,  0x6F6E,
-    0x6F98,  0x6FC1,  0x6FEA,  0x7013,
-    0x703C,  0x7064,  0x708C,  0x70B4,
-    0x70DB,  0x7103,  0x712A,  0x7151,
-    0x7177,  0x719D,  0x71C3,  0x71E9,
-    0x720F,  0x7234,  0x7259,  0x727E,
-    0x72A2,  0x72C7,  0x72EB,  0x730E,
-    0x7332,  0x7355,  0x7378,  0x739B,
-    0x73BD,  0x73E0,  0x7402,  0x7424,
-    0x7445,  0x7466,  0x7487,  0x74A8,
-    0x74C9,  0x74E9,  0x7509,  0x7529,
-    0x7548,  0x7568,  0x7587,  0x75A5,
-    0x75C4,  0x75E2,  0x7601,  0x761E,
-    0x763C,  0x7659,  0x7676,  0x7693,
-    0x76B0,  0x76CC,  0x76E9,  0x7705,
-    0x7720,  0x773C,  0x7757,  0x7772,
-    0x778D,  0x77A8,  0x77C2,  0x77DC,
-    0x77F6,  0x780F,  0x7829,  0x7842,
-    0x785B,  0x7874,  0x788C,  0x78A5,
-    0x78BD,  0x78D5,  0x78EC,  0x7904,
-    0x791B,  0x7932,  0x7949,  0x795F,
-    0x7976,  0x798C,  0x79A2,  0x79B7,
-    0x79CD,  0x79E2,  0x79F7,  0x7A0C,
-    0x7A21,  0x7A35,  0x7A4A,  0x7A5E,
-    0x7A72,  0x7A85,  0x7A99,  0x7AAC,
-    0x7ABF,  0x7AD2,  0x7AE5,  0x7AF7,
-    0x7B09,  0x7B1B,  0x7B2D,  0x7B3F,
-    0x7B51,  0x7B62,  0x7B73,  0x7B84,
-    0x7B95,  0x7BA5,  0x7BB6,  0x7BC6,
-    0x7BD6,  0x7BE6,  0x7BF6,  0x7C05,
-    0x7C15,  0x7C24,  0x7C33,  0x7C42,
-    0x7C50,  0x7C5F,  0x7C6D,  0x7C7B,
-    0x7C89,  0x7C97,  0x7CA5,  0x7CB2,
-    0x7CC0,  0x7CCD,  0x7CDA,  0x7CE7,
-    0x7CF3,  0x7D00,  0x7D0C,  0x7D18,
-    0x7D25,  0x7D31,  0x7D3C,  0x7D48,
-    0x7D53,  0x7D5F,  0x7D6A,  0x7D75,
-    0x7D80,  0x7D8B,  0x7D95,  0x7DA0,
-    0x7DAA,  0x7DB4,  0x7DBE,  0x7DC8,
-    0x7DD2,  0x7DDC,  0x7DE5,  0x7DEF,
-    0x7DF8,  0x7E01,  0x7E0A,  0x7E13,
-    0x7E1C,  0x7E25,  0x7E2D,  0x7E36,
-    0x7E3E,  0x7E46,  0x7E4E,  0x7E56,
-    0x7E5E,  0x7E66,  0x7E6D,  0x7E75,
-    0x7E7C,  0x7E83,  0x7E8B,  0x7E92,
-    0x7E99,  0x7EA0,  0x7EA6,  0x7EAD,
-    0x7EB3,  0x7EBA,  0x7EC0,  0x7EC6,
-    0x7ECD,  0x7ED3,  0x7ED9,  0x7EDE,
-    0x7EE4,  0x7EEA,  0x7EF0,  0x7EF5,
-    0x7EFA,  0x7F00,  0x7F05,  0x7F0A,
-    0x7F0F,  0x7F14,  0x7F19,  0x7F1E,
-    0x7F23,  0x7F27,  0x7F2C,  0x7F30,
-    0x7F35,  0x7F39,  0x7F3D,  0x7F41,
-    0x7F46,  0x7F4A,  0x7F4E,  0x7F52,
-    0x7F55,  0x7F59,  0x7F5D,  0x7F60,
-    0x7F64,  0x7F68,  0x7F6B,  0x7F6E,
-    0x7F72,  0x7F75,  0x7F78,  0x7F7B,
-    0x7F7E,  0x7F81,  0x7F84,  0x7F87,
-    0x7F8A,  0x7F8D,  0x7F90,  0x7F92,
-    0x7F95,  0x7F97,  0x7F9A,  0x7F9C,
-    0x7F9F,  0x7FA1,  0x7FA4,  0x7FA6,
-    0x7FA8,  0x7FAA,  0x7FAC,  0x7FAE,
-    0x7FB1,  0x7FB3,  0x7FB5,  0x7FB6,
-    0x7FB8,  0x7FBA,  0x7FBC,  0x7FBE,
-    0x7FBF,  0x7FC1,  0x7FC3,  0x7FC4,
-    0x7FC6,  0x7FC8,  0x7FC9,  0x7FCB,
-    0x7FCC,  0x7FCD,  0x7FCF,  0x7FD0,
-    0x7FD1,  0x7FD3,  0x7FD4,  0x7FD5,
-    0x7FD6,  0x7FD8,  0x7FD9,  0x7FDA,
-    0x7FDB,  0x7FDC,  0x7FDD,  0x7FDE,
-    0x7FDF,  0x7FE0,  0x7FE1,  0x7FE2,
-    0x7FE3,  0x7FE4,  0x7FE4,  0x7FE5,
-    0x7FE6,  0x7FE7,  0x7FE8,  0x7FE8,
-    0x7FE9,  0x7FEA,  0x7FEA,  0x7FEB,
-    0x7FEC,  0x7FEC,  0x7FED,  0x7FEE,
-    0x7FEE,  0x7FEF,  0x7FEF,  0x7FF0,
-    0x7FF0,  0x7FF1,  0x7FF1,  0x7FF2,
-    0x7FF2,  0x7FF3,  0x7FF3,  0x7FF4,
-    0x7FF4,  0x7FF4,  0x7FF5,  0x7FF5,
-    0x7FF6,  0x7FF6,  0x7FF6,  0x7FF7,
-    0x7FF7,  0x7FF7,  0x7FF8,  0x7FF8,
-    0x7FF8,  0x7FF8,  0x7FF9,  0x7FF9,
-    0x7FF9,  0x7FF9,  0x7FFA,  0x7FFA,
-    0x7FFA,  0x7FFA,  0x7FFA,  0x7FFB,
-    0x7FFB,  0x7FFB,  0x7FFB,  0x7FFB,
-    0x7FFC,  0x7FFC,  0x7FFC,  0x7FFC,
-    0x7FFC,  0x7FFC,  0x7FFC,  0x7FFC,
-    0x7FFD,  0x7FFD,  0x7FFD,  0x7FFD,
-    0x7FFD,  0x7FFD,  0x7FFD,  0x7FFD,
-    0x7FFD,  0x7FFD,  0x7FFE,  0x7FFE,
-    0x7FFE,  0x7FFE,  0x7FFE,  0x7FFE,
-    0x7FFE,  0x7FFE,  0x7FFE,  0x7FFE,
-    0x7FFE,  0x7FFE,  0x7FFE,  0x7FFE,
-    0x7FFE,  0x7FFE,  0x7FFE,  0x7FFE,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF
-
-};
-
-
-
-
-const Int16 Short_Window_KBD_fxp[SHORT_WINDOW] =
-{
-
-    0x0001,  0x0004,  0x0008,  0x000D,
-    0x0014,  0x001D,  0x0029,  0x0039,
-    0x004C,  0x0063,  0x0080,  0x00A2,
-    0x00CB,  0x00FB,  0x0133,  0x0174,
-    0x01BE,  0x0214,  0x0275,  0x02E3,
-    0x035E,  0x03E8,  0x0481,  0x052B,
-    0x05E7,  0x06B4,  0x0795,  0x088A,
-    0x0993,  0x0AB2,  0x0BE7,  0x0D32,
-    0x0E94,  0x100E,  0x119F,  0x1347,
-    0x1507,  0x16DE,  0x18CC,  0x1AD0,
-    0x1CEB,  0x1F1A,  0x215F,  0x23B6,
-    0x2620,  0x289C,  0x2B27,  0x2DC0,
-    0x3066,  0x3317,  0x35D2,  0x3894,
-    0x3B5C,  0x3E28,  0x40F6,  0x43C4,
-    0x468F,  0x4956,  0x4C18,  0x4ED1,
-    0x5181,  0x5425,  0x56BC,  0x5944,
-    0x5BBB,  0x5E21,  0x6073,  0x62B1,
-    0x64DA,  0x66EC,  0x68E7,  0x6ACB,
-    0x6C96,  0x6E49,  0x6FE4,  0x7166,
-    0x72D0,  0x7421,  0x755B,  0x767E,
-    0x778A,  0x7881,  0x7962,  0x7A30,
-    0x7AEA,  0x7B92,  0x7C29,  0x7CB0,
-    0x7D28,  0x7D92,  0x7DF0,  0x7E42,
-    0x7E89,  0x7EC7,  0x7EFC,  0x7F2A,
-    0x7F50,  0x7F71,  0x7F8C,  0x7FA3,
-    0x7FB6,  0x7FC5,  0x7FD2,  0x7FDC,
-    0x7FE4,  0x7FEB,  0x7FF0,  0x7FF4,
-    0x7FF7,  0x7FF9,  0x7FFB,  0x7FFC,
-    0x7FFD,  0x7FFE,  0x7FFE,  0x7FFE,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF,
-    0x7FFF,  0x7FFF,  0x7FFF,  0x7FFF
-};
-
diff --git a/media/libstagefright/codecs/aacdec/write_output.h b/media/libstagefright/codecs/aacdec/write_output.h
deleted file mode 100644
index 0085a63..0000000
--- a/media/libstagefright/codecs/aacdec/write_output.h
+++ /dev/null
@@ -1,138 +0,0 @@
-/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
- * express or implied.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- * -------------------------------------------------------------------
- */
-/*
-
- Pathname: write_output.h
-
-------------------------------------------------------------------------------
- REVISION HISTORY
-
- Description: Change function prototype.
-
- Description: Remove CR/LF from unknown editor
-
- Who:                                       Date:
- Description:
-
-------------------------------------------------------------------------------
- INCLUDE DESCRIPTION
-
- Header file for the declaration of the function write_output()
-
-------------------------------------------------------------------------------
-*/
-
-/*----------------------------------------------------------------------------
-; CONTINUE ONLY IF NOT ALREADY DEFINED
-----------------------------------------------------------------------------*/
-#ifndef WRITE_OUTPUT_H
-#define WRITE_OUTPUT_H
-
-#include "pv_audio_type_defs.h"
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; INCLUDES
-    ----------------------------------------------------------------------------*/
-#include "pvmp4audiodecoder_api.h"
-
-    /*----------------------------------------------------------------------------
-    ; MACROS
-    ; Define module specific macros here
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; DEFINES
-    ; Include all pre-processor statements here.
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; EXTERNAL VARIABLES REFERENCES
-    ; Declare variables used in this module but defined elsewhere
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; SIMPLE TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; ENUMERATED TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; STRUCTURES TYPEDEF'S
-    ----------------------------------------------------------------------------*/
-
-    /*----------------------------------------------------------------------------
-    ; GLOBAL FUNCTION DEFINITIONS
-    ; Function Prototype declaration
-    ----------------------------------------------------------------------------*/
-
-#ifndef AAC_PLUS
-
-    Int write_output(
-        const Int16   sourceLeft[],
-        const Int16   sourceRight[],
-        Int16   outputBuffer[],
-        const Int     sourcePointsPerChannel,
-        const Int     sourceChannels,
-        const Int     requestedChannels,
-        const tPVMP4AudioDecoderOutputFormat  outputFormat);
-
-#else
-
-    Int write_output(
-        const Int16   sourceLeft[],
-        const Int16   sourceRight[],
-        Int16   outputBuffer[],
-        const Int     sourcePointsPerChannel,
-        const Int     sourceChannels,
-        const Int     requestedChannels,
-#ifdef PARAMETRICSTEREO
-        Int32 sbrEnablePS,
-#endif
-        const tPVMP4AudioDecoderOutputFormat  outputFormat);
-
-#ifdef AAC_32_BIT_INTERFACE
-
-    Int write_output_1(
-        const Int32   sourceLeft[],
-        const Int32   sourceRight[],
-        Int16   outputBuffer[],
-        const Int     sourcePointsPerChannel,
-        const Int     sourceChannels,
-        const Int     requestedChannels,
-        const tPVMP4AudioDecoderOutputFormat  outputFormat);
-#endif
-
-#endif
-
-    /*----------------------------------------------------------------------------
-    ; END
-    ----------------------------------------------------------------------------*/
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* WRITE_OUTPUT_H */
-
-
diff --git a/media/libstagefright/codecs/avc/enc/Android.mk b/media/libstagefright/codecs/avc/enc/Android.mk
index 48923cf..0aecfa8 100644
--- a/media/libstagefright/codecs/avc/enc/Android.mk
+++ b/media/libstagefright/codecs/avc/enc/Android.mk
@@ -42,6 +42,7 @@
 
 LOCAL_C_INCLUDES := \
         frameworks/av/media/libstagefright/include \
+        frameworks/native/include/media/hardware \
         frameworks/native/include/media/openmax \
         $(LOCAL_PATH)/src \
         $(LOCAL_PATH)/include \
@@ -63,6 +64,7 @@
         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 259562b..a2ef3a1 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 @@
       mVideoFrameRate(30),
       mVideoBitRate(192000),
       mVideoColorFormat(OMX_COLOR_FormatYUV420Planar),
+      mStoreMetaDataInBuffers(false),
       mIDRFrameRefreshIntervalInSec(1),
       mAVCEncProfile(AVC_BASELINE),
       mAVCEncLevel(AVC_LEVEL2),
@@ -451,7 +456,7 @@
                 return OMX_ErrorUndefined;
             }
 
-            if (formatParams->nIndex > 1) {
+            if (formatParams->nIndex > 2) {
                 return OMX_ErrorNoMore;
             }
 
@@ -459,8 +464,10 @@
                 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::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 @@
             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 @@
                 return OMX_ErrorUndefined;
             }
 
-            if (formatParams->nIndex > 1) {
+            if (formatParams->nIndex > 2) {
                 return OMX_ErrorNoMore;
             }
 
@@ -622,7 +632,9 @@
                     ((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 @@
             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 @@
             }
         }
 
+        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 @@
                 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 @@
                     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 @@
             if (encoderStatus < AVCENC_SUCCESS) {
                 ALOGE("encoderStatus = %d at line %d", encoderStatus, __LINE__);
                 mSignalledError = true;
+                releaseGrallocData(srcBuffer);
                 notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
                 return;
             }
@@ -841,6 +903,7 @@
 
         inQueue.erase(inQueue.begin());
         inInfo->mOwnedByUs = false;
+        releaseGrallocData(srcBuffer);
         notifyEmptyBufferDone(inHeader);
 
         outQueue.erase(outQueue.begin());
@@ -884,6 +947,47 @@
     ALOGV("signalBufferReturned: %p", buffer);
 }
 
+OMX_ERRORTYPE SoftAVCEncoder::getExtensionIndex(
+        const char *name, OMX_INDEXTYPE *index) {
+    if (!strcmp(name, "OMX.google.android.index.storeMetaDataInBuffers")) {
+        *(int32_t*)index = kStoreMetaDataExtensionIndex;
+        return OMX_ErrorNone;
+    }
+    return OMX_ErrorUndefined;
+}
+
+uint8_t *SoftAVCEncoder::extractGrallocData(void *data, buffer_handle_t *buffer) {
+    OMX_U32 type = *(OMX_U32*)data;
+    status_t res;
+    if (type != kMetadataBufferTypeGrallocSource) {
+        ALOGE("Data passed in with metadata mode does not have type "
+                "kMetadataBufferTypeGrallocSource (%d), has type %ld instead",
+                kMetadataBufferTypeGrallocSource, type);
+        return NULL;
+    }
+    buffer_handle_t imgBuffer = *(buffer_handle_t*)((uint8_t*)data + 4);
+
+    const Rect rect(mVideoWidth, mVideoHeight);
+    uint8_t *img;
+    res = GraphicBufferMapper::get().lock(imgBuffer,
+            GRALLOC_USAGE_HW_VIDEO_ENCODER,
+            rect, (void**)&img);
+    if (res != OK) {
+        ALOGE("%s: Unable to lock image buffer %p for access", __FUNCTION__,
+                imgBuffer);
+        return NULL;
+    }
+
+    *buffer = imgBuffer;
+    return img;
+}
+
+void SoftAVCEncoder::releaseGrallocData(buffer_handle_t buffer) {
+    if (mStoreMetaDataInBuffers) {
+        GraphicBufferMapper::get().unlock(buffer);
+    }
+}
+
 }  // namespace android
 
 android::SoftOMXComponent *createSoftOMXComponent(
diff --git a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
index a2587c6..23d5ff1 100644
--- a/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
+++ b/media/libstagefright/codecs/avc/enc/SoftAVCEncoder.h
@@ -45,6 +45,10 @@
 
     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 @@
         kNumBuffers = 2,
     };
 
+    enum {
+        kStoreMetaDataExtensionIndex = OMX_IndexVendorStartUnused + 1
+    };
+
     // OMX input buffer's timestamp and flags
     typedef struct {
         int64_t mTimeUs;
@@ -74,6 +82,7 @@
     int32_t  mVideoFrameRate;
     int32_t  mVideoBitRate;
     int32_t  mVideoColorFormat;
+    bool     mStoreMetaDataInBuffers;
     int32_t  mIDRFrameRefreshIntervalInSec;
     AVCProfile mAVCEncProfile;
     AVCLevel   mAVCEncLevel;
@@ -100,6 +109,9 @@
     OMX_ERRORTYPE releaseEncoder();
     void releaseOutputBuffers();
 
+    uint8_t* extractGrallocData(void *data, buffer_handle_t *buffer);
+    void releaseGrallocData(buffer_handle_t buffer);
+
     DISALLOW_EVIL_CONSTRUCTORS(SoftAVCEncoder);
 };
 
diff --git a/media/libstagefright/codecs/m4v_h263/enc/Android.mk b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
index 484180d..865cc9c 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/Android.mk
+++ b/media/libstagefright/codecs/m4v_h263/enc/Android.mk
@@ -45,6 +45,7 @@
 LOCAL_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 @@
         libstagefright_foundation \
         libstagefright_omx \
         libutils \
+        libui
 
 
 LOCAL_MODULE := libstagefright_soft_mpeg4enc
diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
index a5a2332..8bc0275 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
+++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.cpp
@@ -21,11 +21,15 @@
 #include "mp4enc_api.h"
 #include "OMX_Video.h"
 
+#include <HardwareAPI.h>
+#include <MetadataBufferType.h>
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MediaErrors.h>
 #include <media/stagefright/MetaData.h>
 #include <media/stagefright/Utils.h>
+#include <ui/Rect.h>
+#include <ui/GraphicBufferMapper.h>
 
 #include "SoftMPEG4Encoder.h"
 
@@ -82,6 +86,7 @@
       mVideoFrameRate(30),
       mVideoBitRate(192000),
       mVideoColorFormat(OMX_COLOR_FormatYUV420Planar),
+      mStoreMetaDataInBuffers(false),
       mIDRFrameRefreshIntervalInSec(1),
       mNumInputFrames(-1),
       mStarted(false),
@@ -321,7 +326,7 @@
                 return OMX_ErrorUndefined;
             }
 
-            if (formatParams->nIndex > 1) {
+            if (formatParams->nIndex > 2) {
                 return OMX_ErrorNoMore;
             }
 
@@ -329,8 +334,10 @@
                 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::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 @@
             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 @@
                 return OMX_ErrorUndefined;
             }
 
-            if (formatParams->nIndex > 1) {
+            if (formatParams->nIndex > 2) {
                 return OMX_ErrorNoMore;
             }
 
@@ -514,7 +524,9 @@
                     ((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 @@
             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 @@
             mSawInputEOS = true;
         }
 
+        buffer_handle_t srcBuffer; // for MetaDataMode only
         if (inHeader->nFilledLen > 0) {
-            const void *inData = inHeader->pBuffer + inHeader->nOffset;
-            uint8_t *inputData = (uint8_t *) inData;
+            uint8_t *inputData = NULL;
+            if (mStoreMetaDataInBuffers) {
+                if (inHeader->nFilledLen != 8) {
+                    ALOGE("MetaData buffer is wrong size! "
+                            "(got %lu bytes, expected 8)", inHeader->nFilledLen);
+                    mSignalledError = true;
+                    notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+                    return;
+                }
+                inputData =
+                        extractGrallocData(inHeader->pBuffer + inHeader->nOffset,
+                                &srcBuffer);
+                if (inputData == NULL) {
+                    ALOGE("Unable to extract gralloc buffer in metadata mode");
+                    mSignalledError = true;
+                    notify(OMX_EventError, OMX_ErrorUndefined, 0, 0);
+                        return;
+                }
+                // TODO: Verify/convert pixel format enum
+            } else {
+                inputData = (uint8_t *)inHeader->pBuffer + inHeader->nOffset;
+            }
+
             if (mVideoColorFormat != OMX_COLOR_FormatYUV420Planar) {
                 ConvertYUV420SemiPlanarToYUV420Planar(
                     inputData, mInputFrameData, mVideoWidth, mVideoHeight);
@@ -683,6 +742,7 @@
 
         inQueue.erase(inQueue.begin());
         inInfo->mOwnedByUs = false;
+        releaseGrallocData(srcBuffer);
         notifyEmptyBufferDone(inHeader);
 
         outQueue.erase(outQueue.begin());
@@ -697,6 +757,47 @@
     }
 }
 
+OMX_ERRORTYPE SoftMPEG4Encoder::getExtensionIndex(
+        const char *name, OMX_INDEXTYPE *index) {
+    if (!strcmp(name, "OMX.google.android.index.storeMetaDataInBuffers")) {
+        *(int32_t*)index = kStoreMetaDataExtensionIndex;
+        return OMX_ErrorNone;
+    }
+    return OMX_ErrorUndefined;
+}
+
+uint8_t *SoftMPEG4Encoder::extractGrallocData(void *data, buffer_handle_t *buffer) {
+    OMX_U32 type = *(OMX_U32*)data;
+    status_t res;
+    if (type != kMetadataBufferTypeGrallocSource) {
+        ALOGE("Data passed in with metadata mode does not have type "
+                "kMetadataBufferTypeGrallocSource (%d), has type %ld instead",
+                kMetadataBufferTypeGrallocSource, type);
+        return NULL;
+    }
+    buffer_handle_t imgBuffer = *(buffer_handle_t*)((uint8_t*)data + 4);
+
+    const Rect rect(mVideoWidth, mVideoHeight);
+    uint8_t *img;
+    res = GraphicBufferMapper::get().lock(imgBuffer,
+            GRALLOC_USAGE_HW_VIDEO_ENCODER,
+            rect, (void**)&img);
+    if (res != OK) {
+        ALOGE("%s: Unable to lock image buffer %p for access", __FUNCTION__,
+                imgBuffer);
+        return NULL;
+    }
+
+    *buffer = imgBuffer;
+    return img;
+}
+
+void SoftMPEG4Encoder::releaseGrallocData(buffer_handle_t buffer) {
+    if (mStoreMetaDataInBuffers) {
+        GraphicBufferMapper::get().unlock(buffer);
+    }
+}
+
 }  // namespace android
 
 android::SoftOMXComponent *createSoftOMXComponent(
diff --git a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
index 3e90d54..cc4ea8f 100644
--- a/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
+++ b/media/libstagefright/codecs/m4v_h263/enc/SoftMPEG4Encoder.h
@@ -43,6 +43,11 @@
 
     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 @@
         kNumBuffers = 2,
     };
 
+    enum {
+        kStoreMetaDataExtensionIndex = OMX_IndexVendorStartUnused + 1
+    };
+
     // OMX input buffer's timestamp and flags
     typedef struct {
         int64_t mTimeUs;
@@ -63,6 +72,7 @@
     int32_t  mVideoFrameRate;
     int32_t  mVideoBitRate;
     int32_t  mVideoColorFormat;
+    bool     mStoreMetaDataInBuffers;
     int32_t  mIDRFrameRefreshIntervalInSec;
 
     int64_t  mNumInputFrames;
@@ -80,6 +90,9 @@
     OMX_ERRORTYPE initEncoder();
     OMX_ERRORTYPE releaseEncoder();
 
+    uint8_t* extractGrallocData(void *data, buffer_handle_t *buffer);
+    void releaseGrallocData(buffer_handle_t buffer);
+
     DISALLOW_EVIL_CONSTRUCTORS(SoftMPEG4Encoder);
 };
 
diff --git a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
index 8f2a3aa..fb1135c 100644
--- a/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
+++ b/media/libstagefright/codecs/mp3dec/SoftMP3.cpp
@@ -191,10 +191,19 @@
             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 @@
             // 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/colorconversion/SoftwareRenderer.cpp b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
index 8673bad..2704a37 100644
--- a/media/libstagefright/colorconversion/SoftwareRenderer.cpp
+++ b/media/libstagefright/colorconversion/SoftwareRenderer.cpp
@@ -141,13 +141,12 @@
         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 @@
 
     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/AMessage.cpp b/media/libstagefright/foundation/AMessage.cpp
index 8b01ac6..dc42f91 100644
--- a/media/libstagefright/foundation/AMessage.cpp
+++ b/media/libstagefright/foundation/AMessage.cpp
@@ -25,6 +25,7 @@
 #include "AString.h"
 
 #include <binder/Parcel.h>
+#include <media/stagefright/foundation/hexdump.h>
 
 namespace android {
 
@@ -399,9 +400,20 @@
                         "RefBase *%s = %p", item.mName, item.u.refValue);
                 break;
             case kTypeBuffer:
-                tmp = StringPrintf(
-                        "ABuffer *%s = %p", item.mName, item.u.refValue);
+            {
+                sp<ABuffer> buffer = static_cast<ABuffer *>(item.u.refValue);
+
+                if (buffer != NULL && buffer->size() <= 64) {
+                    tmp = StringPrintf("Buffer %s = {\n", item.mName);
+                    hexdump(buffer->data(), buffer->size(), indent + 4, &tmp);
+                    appendIndent(&tmp, indent + 2);
+                    tmp.append("}");
+                } else {
+                    tmp = StringPrintf(
+                            "Buffer *%s = %p", item.mName, buffer.get());
+                }
                 break;
+            }
             case kTypeMessage:
                 tmp = StringPrintf(
                         "AMessage %s = %s",
diff --git a/media/libstagefright/foundation/hexdump.cpp b/media/libstagefright/foundation/hexdump.cpp
index 16c1ca5..a44d832 100644
--- a/media/libstagefright/foundation/hexdump.cpp
+++ b/media/libstagefright/foundation/hexdump.cpp
@@ -29,13 +29,25 @@
 
 namespace android {
 
-void hexdump(const void *_data, size_t size) {
+static void appendIndent(AString *s, int32_t indent) {
+    static const char kWhitespace[] =
+        "                                        "
+        "                                        ";
+
+    CHECK_LT((size_t)indent, sizeof(kWhitespace));
+
+    s->append(kWhitespace, indent);
+}
+
+void hexdump(const void *_data, size_t size, size_t indent, AString *appendTo) {
     const uint8_t *data = (const uint8_t *)_data;
 
     size_t offset = 0;
     while (offset < size) {
         AString line;
 
+        appendIndent(&line, indent);
+
         char tmp[32];
         sprintf(tmp, "%08lx:  ", (unsigned long)offset);
 
@@ -67,7 +79,12 @@
             }
         }
 
-        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/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index 68380a8..1422687 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -166,6 +166,7 @@
     sp<MediaSource> mVideoTrack;
     sp<MediaSource> mVideoSource;
     sp<AwesomeRenderer> mVideoRenderer;
+    bool mVideoRenderingStarted;
     bool mVideoRendererIsPreview;
 
     ssize_t mActiveAudioTrackIndex;
diff --git a/media/libstagefright/include/chromium_http_stub.h b/media/libstagefright/include/chromium_http_stub.h
new file mode 100644
index 0000000..869d4ac
--- /dev/null
+++ b/media/libstagefright/include/chromium_http_stub.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef CHROMIUM_HTTP_STUB_H_
+#define CHROMIUM_HTTP_STUB_H_
+
+#include <include/HTTPBase.h>
+#include <media/stagefright/DataSource.h>
+
+namespace android {
+extern "C" {
+HTTPBase *createChromiumHTTPDataSource(uint32_t flags);
+DataSource *createDataUriSource(const char *uri);
+}
+}
+
+#endif
diff --git a/media/libstagefright/omx/OMX.cpp b/media/libstagefright/omx/OMX.cpp
index 681e321..29bc733 100644
--- a/media/libstagefright/omx/OMX.cpp
+++ b/media/libstagefright/omx/OMX.cpp
@@ -252,13 +252,16 @@
 status_t OMX::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 @@
 
     {
         Mutex::Autolock autoLock(mLock);
-        index = mDispatchers.indexOfKey(node);
+        ssize_t index = mDispatchers.indexOfKey(node);
         CHECK(index >= 0);
         mDispatchers.removeItemsAt(index);
     }
diff --git a/media/libstagefright/omx/tests/OMXHarness.cpp b/media/libstagefright/omx/tests/OMXHarness.cpp
index fab1771..4b369ed 100644
--- a/media/libstagefright/omx/tests/OMXHarness.cpp
+++ b/media/libstagefright/omx/tests/OMXHarness.cpp
@@ -515,7 +515,10 @@
 
 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 +574,22 @@
     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/tests/Android.mk b/media/libstagefright/tests/Android.mk
index a1e6be7..57fff0b 100644
--- a/media/libstagefright/tests/Android.mk
+++ b/media/libstagefright/tests/Android.mk
@@ -20,9 +20,10 @@
 	libgui \
 	libmedia \
 	libstagefright \
-	libstagefright_omx \
 	libstagefright_foundation \
+	libstagefright_omx \
 	libstlport \
+	libsync \
 	libui \
 	libutils \
 
diff --git a/media/libstagefright/tests/SurfaceMediaSource_test.cpp b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
index 466f521..cc2aca7 100644
--- a/media/libstagefright/tests/SurfaceMediaSource_test.cpp
+++ b/media/libstagefright/tests/SurfaceMediaSource_test.cpp
@@ -509,31 +509,31 @@
 // 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 @@
     ANativeWindowBuffer* anb;
 
     // Note: make sure we get an ERROR back when dequeuing!
-    ASSERT_NE(NO_ERROR, mANW->dequeueBuffer(mANW.get(), &anb));
+    ASSERT_NE(NO_ERROR, native_window_dequeue_buffer_and_wait(mANW.get(), &anb));
 }
 
 // pass multiple buffers from the native_window the SurfaceMediaSource
diff --git a/media/libstagefright/timedtext/TimedTextDriver.cpp b/media/libstagefright/timedtext/TimedTextDriver.cpp
index 42ca1f5..54ce7ac 100644
--- a/media/libstagefright/timedtext/TimedTextDriver.cpp
+++ b/media/libstagefright/timedtext/TimedTextDriver.cpp
@@ -61,7 +61,7 @@
     source = mTextSourceVector.valueFor(index);
     mPlayer->setDataSource(source);
     if (mState == UNINITIALIZED) {
-        mState = PAUSED;
+        mState = PREPARED;
     }
     mCurrentTrackIndex = index;
     return OK;
@@ -74,42 +74,47 @@
             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 +133,50 @@
 }
 
 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;
+    switch (mState) {
+        case UNINITIALIZED:
+            return INVALID_OPERATION;
+        case PLAYING:
+            mPlayer->pause();
+            mState = UNINITIALIZED;
+            return OK;
+        case PREPARED:
+        case PAUSED:
+            mState = UNINITIALIZED;
+            return OK;
+        default:
+            TRESPASS();
     }
-    Mutex::Autolock autoLock(mLock);
-    mState = UNINITIALIZED;
-    return OK;
+    return UNKNOWN_ERROR;
 }
 
 status_t TimedTextDriver::seekToAsync(int64_t timeUs) {
-    mPlayer->seekToAsync(timeUs);
-    return OK;
+    Mutex::Autolock autoLock(mLock);
+    ALOGV("%s() is called", __FUNCTION__);
+    switch (mState) {
+        case UNINITIALIZED:
+            return INVALID_OPERATION;
+        case PREPARED:
+            mPlayer->seekToAsync(timeUs);
+            mPlayer->pause();
+            mState = PAUSED;
+            return OK;
+        case PAUSED:
+            mPlayer->seekToAsync(timeUs);
+            mPlayer->pause();
+            return OK;
+        case PLAYING:
+            mPlayer->seekToAsync(timeUs);
+            return OK;
+        defaut:
+            TRESPASS();
+    }
+    return UNKNOWN_ERROR;
 }
 
 status_t TimedTextDriver::addInBandTextSource(
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.cpp b/media/libstagefright/timedtext/TimedTextPlayer.cpp
index 9b001cc..e3bdd8a 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 @@
 }
 
 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::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 @@
             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 @@
                     seekTimeUs = positionMs * 1000ll;
                 }
             }
+            if (mPaused) {
+                mPendingSeekTimeUs = seekTimeUs;
+                break;
+            }
+            mSendSubtitleGeneration++;
             doSeekAndRead(seekTimeUs);
             break;
         }
@@ -108,8 +157,19 @@
             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)) {
@@ -162,12 +222,14 @@
     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 +247,58 @@
 }
 
 void TimedTextPlayer::postTextEvent(const sp<ParcelEvent>& parcel, int64_t timeUs) {
-    sp<MediaPlayerBase> listener = mListener.promote();
-    if (listener != NULL) {
-        int64_t positionUs, delayUs;
-        int32_t positionMs = 0;
-        listener->getCurrentPosition(&positionMs);
-        positionUs = positionMs * 1000ll;
-
-        if (timeUs <= positionUs + kAdjustmentProcessingTimeUs) {
-            delayUs = 0;
-        } else {
-            delayUs = timeUs - positionUs - kAdjustmentProcessingTimeUs;
-        }
-        postTextEventDelayUs(parcel, delayUs);
+    int64_t delayUs = delayUsFromCurrentTime(timeUs);
+    sp<AMessage> msg = new AMessage(kWhatSendSubtitle, id());
+    msg->setInt32("generation", mSendSubtitleGeneration);
+    if (parcel != NULL) {
+        msg->setObject("subtitle", parcel);
     }
+    msg->setInt64("fireTimeUs", timeUs);
+    msg->post(delayUs);
 }
 
-void TimedTextPlayer::postTextEventDelayUs(const sp<ParcelEvent>& parcel, int64_t delayUs) {
+int64_t TimedTextPlayer::delayUsFromCurrentTime(int64_t fireTimeUs) {
     sp<MediaPlayerBase> listener = mListener.promote();
-    if (listener != NULL) {
-        sp<AMessage> msg = new AMessage(kWhatSendSubtitle, id());
-        msg->setInt32("generation", mSendSubtitleGeneration);
-        if (parcel != NULL) {
-            msg->setObject("subtitle", parcel);
+    if (listener == NULL) {
+        // TODO: it may be better to return kInvalidTimeUs
+        ALOGE("%s: Listener is NULL. (fireTimeUs = %lld)",
+              __FUNCTION__, fireTimeUs);
+        return 0;
+    }
+    int32_t positionMs = 0;
+    listener->getCurrentPosition(&positionMs);
+    int64_t positionUs = positionMs * 1000ll;
+
+    if (fireTimeUs <= positionUs + kAdjustmentProcessingTimeUs) {
+        return 0;
+    } else {
+        int64_t delayUs = fireTimeUs - positionUs - kAdjustmentProcessingTimeUs;
+        if (delayUs > kMaxDelayUs) {
+            return kMaxDelayUs;
         }
-        msg->post(delayUs);
+        return delayUs;
     }
 }
 
 void TimedTextPlayer::notifyError(int error) {
     sp<MediaPlayerBase> listener = mListener.promote();
-    if (listener != NULL) {
-        listener->sendEvent(MEDIA_INFO, MEDIA_INFO_TIMED_TEXT_ERROR, error);
+    if (listener == NULL) {
+        ALOGE("%s(error=%d): Listener is NULL.", __FUNCTION__, error);
+        return;
     }
+    listener->sendEvent(MEDIA_INFO, MEDIA_INFO_TIMED_TEXT_ERROR, error);
 }
 
 void TimedTextPlayer::notifyListener(const Parcel *parcel) {
     sp<MediaPlayerBase> listener = mListener.promote();
-    if (listener != NULL) {
-        if (parcel != NULL && (parcel->dataSize() > 0)) {
-            listener->sendEvent(MEDIA_TIMED_TEXT, 0, 0, parcel);
-        } else {  // send an empty timed text to clear the screen
-            listener->sendEvent(MEDIA_TIMED_TEXT);
-        }
+    if (listener == NULL) {
+        ALOGE("%s: Listener is NULL.", __FUNCTION__);
+        return;
+    }
+    if (parcel != NULL && (parcel->dataSize() > 0)) {
+        listener->sendEvent(MEDIA_TIMED_TEXT, 0, 0, parcel);
+    } else {  // send an empty timed text to clear the screen
+        listener->sendEvent(MEDIA_TIMED_TEXT);
     }
 }
 
diff --git a/media/libstagefright/timedtext/TimedTextPlayer.h b/media/libstagefright/timedtext/TimedTextPlayer.h
index b7e15f8..ec8ed25 100644
--- a/media/libstagefright/timedtext/TimedTextPlayer.h
+++ b/media/libstagefright/timedtext/TimedTextPlayer.h
@@ -40,6 +40,7 @@
 
     void start();
     void pause();
+    void resume();
     void seekToAsync(int64_t timeUs);
     void setDataSource(sp<TimedTextSource> source);
 
@@ -49,6 +50,8 @@
 private:
     enum {
         kWhatPause = 'paus',
+        kWhatResume = 'resm',
+        kWhatStart = 'strt',
         kWhatSeek = 'seek',
         kWhatRetryRead = 'read',
         kWhatSendSubtitle = 'send',
@@ -62,13 +65,15 @@
 
     wp<MediaPlayerBase> mListener;
     sp<TimedTextSource> mSource;
+    int64_t mPendingSeekTimeUs;
+    bool mPaused;
     int32_t mSendSubtitleGeneration;
 
     void doSeekAndRead(int64_t seekTimeUs);
     void doRead(MediaSource::ReadOptions* options = NULL);
     void onTextEvent();
     void postTextEvent(const sp<ParcelEvent>& parcel = NULL, int64_t timeUs = -1);
-    void postTextEventDelayUs(const sp<ParcelEvent>& parcel = NULL, int64_t delayUs = -1);
+    int64_t delayUsFromCurrentTime(int64_t fireTimeUs);
     void notifyError(int error = 0);
     void notifyListener(const Parcel *parcel = NULL);
 
diff --git a/media/libstagefright/timedtext/TimedTextSRTSource.cpp b/media/libstagefright/timedtext/TimedTextSRTSource.cpp
index 1f5d037..eac23ba 100644
--- a/media/libstagefright/timedtext/TimedTextSRTSource.cpp
+++ b/media/libstagefright/timedtext/TimedTextSRTSource.cpp
@@ -79,6 +79,10 @@
     return OK;
 }
 
+sp<MetaData> TimedTextSRTSource::getFormat() {
+    return mMetaData;
+}
+
 status_t TimedTextSRTSource::scanFile() {
     off64_t offset = 0;
     int64_t startTimeUs;
@@ -155,18 +159,16 @@
     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 @@
     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 @@
     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 @@
     return OK;
 }
 
-sp<MetaData> TimedTextSRTSource::getFormat() {
-    return mMetaData;
+int TimedTextSRTSource::compareExtendedRangeAndTime(size_t index, int64_t timeUs) {
+    CHECK_LT(index, mTextVector.size());
+    int64_t endTimeUs = mTextVector.valueAt(index).endTimeUs;
+    int64_t startTimeUs = (index > 0) ?
+            mTextVector.valueAt(index - 1).endTimeUs : 0;
+    if (timeUs >= startTimeUs && timeUs < endTimeUs) {
+        return 0;
+    } else if (endTimeUs <= timeUs) {
+        return -1;
+    } else {
+        return 1;
+    }
 }
 
 }  // namespace android
diff --git a/media/libstagefright/timedtext/TimedTextSRTSource.h b/media/libstagefright/timedtext/TimedTextSRTSource.h
index 9eeab39..598c200 100644
--- a/media/libstagefright/timedtext/TimedTextSRTSource.h
+++ b/media/libstagefright/timedtext/TimedTextSRTSource.h
@@ -70,6 +70,25 @@
     status_t extractAndAppendLocalDescriptions(
             int64_t timeUs, const AString &text, Parcel *parcel);
 
+    // Compares the time range of the subtitle at index to the given timeUs.
+    // The time range of the subtitle to match with given timeUs is extended to
+    // [endTimeUs of the previous subtitle, endTimeUs of current subtitle).
+    //
+    // This compare function is used to find a next subtitle when read() is
+    // called with seek options. Note that timeUs within gap ranges, such as
+    // [200, 300) in the below example, will be matched to the closest future
+    // subtitle, [300, 400).
+    //
+    // For instance, assuming there are 3 subtitles in mTextVector,
+    // 0: [100, 200)      ----> [0, 200)
+    // 1: [300, 400)      ----> [200, 400)
+    // 2: [500, 600)      ----> [400, 600)
+    // If the 'index' parameter contains 1, this function
+    // returns 0, if timeUs is in [200, 400)
+    // returns -1, if timeUs >= 400,
+    // returns 1, if timeUs < 200.
+    int compareExtendedRangeAndTime(size_t index, int64_t timeUs);
+
     DISALLOW_EVIL_CONSTRUCTORS(TimedTextSRTSource);
 };
 
diff --git a/media/libstagefright/timedtext/test/Android.mk b/media/libstagefright/timedtext/test/Android.mk
new file mode 100644
index 0000000..a5e7ba2
--- /dev/null
+++ b/media/libstagefright/timedtext/test/Android.mk
@@ -0,0 +1,27 @@
+LOCAL_PATH:= $(call my-dir)
+
+# ================================================================
+# Unit tests for libstagefright_timedtext
+# See also /development/testrunner/test_defs.xml
+# ================================================================
+
+# ================================================================
+# A test for TimedTextSRTSource
+# ================================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := TimedTextSRTSource_test
+
+LOCAL_MODULE_TAGS := eng tests
+
+LOCAL_SRC_FILES := TimedTextSRTSource_test.cpp
+
+LOCAL_C_INCLUDES := \
+    $(TOP)/external/expat/lib \
+    $(TOP)/frameworks/base/media/libstagefright/timedtext
+
+LOCAL_SHARED_LIBRARIES := \
+    libexpat \
+    libstagefright
+
+include $(BUILD_NATIVE_TEST)
diff --git a/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp b/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp
new file mode 100644
index 0000000..40e93c7
--- /dev/null
+++ b/media/libstagefright/timedtext/test/TimedTextSRTSource_test.cpp
@@ -0,0 +1,224 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define LOG_TAG "TimedTextSRTSource_test"
+#include <utils/Log.h>
+
+#include <gtest/gtest.h>
+
+#include <binder/Parcel.h>
+#include <media/stagefright/foundation/AString.h>
+#include <media/stagefright/DataSource.h>
+#include <media/stagefright/MediaErrors.h>
+#include <utils/misc.h>
+
+#include <TimedTextSource.h>
+#include <TimedTextSRTSource.h>
+
+namespace android {
+namespace test {
+
+static const int kSecToUsec = 1000000;
+static const int kSecToMsec = 1000;
+static const int kMsecToUsec = 1000;
+
+/* SRT format (http://en.wikipedia.org/wiki/SubRip)
+ *   Subtitle number
+ *   Start time --> End time
+ *   Text of subtitle (one or more lines)
+ *   Blank lines
+ */
+static const char *kSRTString =
+    "1\n00:00:1,000 --> 00:00:1,500\n1\n\n"
+    "2\n00:00:2,000 --> 00:00:2,500\n2\n\n"
+    "3\n00:00:3,000 --> 00:00:3,500\n3\n\n"
+    "4\n00:00:4,000 --> 00:00:4,500\n4\n\n"
+    "5\n00:00:5,000 --> 00:00:5,500\n5\n\n"
+    // edge case : previos end time = next start time
+    "6\n00:00:5,500 --> 00:00:5,800\n6\n\n"
+    "7\n00:00:5,800 --> 00:00:6,000\n7\n\n"
+    "8\n00:00:6,000 --> 00:00:7,000\n8\n\n";
+
+class SRTDataSourceStub : public DataSource {
+public:
+    SRTDataSourceStub(const char *data, size_t size) :
+        mData(data), mSize(size) {}
+    virtual ~SRTDataSourceStub() {}
+
+    virtual status_t initCheck() const {
+        return OK;
+    }
+
+    virtual ssize_t readAt(off64_t offset, void *data, size_t size) {
+        if (offset >= mSize) return 0;
+
+        ssize_t avail = mSize - offset;
+        if (avail > size) {
+            avail = size;
+        }
+        memcpy(data, mData + offset, avail);
+        return avail;
+    }
+
+private:
+    const char *mData;
+    size_t mSize;
+};
+
+class TimedTextSRTSourceTest : public testing::Test {
+protected:
+    void SetUp() {
+        sp<DataSource> stub= new SRTDataSourceStub(
+                kSRTString,
+                strlen(kSRTString));
+        mSource = new TimedTextSRTSource(stub);
+        mSource->start();
+    }
+
+    void CheckStartTimeMs(const Parcel& parcel, int32_t timeMs) {
+        int32_t intval;
+        parcel.setDataPosition(8);
+        parcel.readInt32(&intval);
+        EXPECT_EQ(timeMs, intval);
+    }
+
+    void CheckDataEquals(const Parcel& parcel, const char* content) {
+        int32_t intval;
+        parcel.setDataPosition(16);
+        parcel.readInt32(&intval);
+        parcel.setDataPosition(24);
+        const char* data = (const char*) parcel.readInplace(intval);
+
+        int32_t content_len = strlen(content);
+        EXPECT_EQ(content_len, intval);
+        EXPECT_TRUE(strncmp(data, content, content_len) == 0);
+    }
+
+    sp<TimedTextSource> mSource;
+    int64_t startTimeUs;
+    int64_t endTimeUs;
+    Parcel parcel;
+    AString subtitle;
+    status_t err;
+};
+
+TEST_F(TimedTextSRTSourceTest, readAll) {
+    for (int i = 1; i <= 5; i++) {
+        err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+        EXPECT_EQ(OK, err);
+        CheckStartTimeMs(parcel, i * kSecToMsec);
+        subtitle = StringPrintf("%d\n\n", i);
+        CheckDataEquals(parcel, subtitle.c_str());
+    }
+    // read edge cases
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+    EXPECT_EQ(OK, err);
+    CheckStartTimeMs(parcel, 5500);
+    subtitle = StringPrintf("6\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+    EXPECT_EQ(OK, err);
+    CheckStartTimeMs(parcel, 5800);
+    subtitle = StringPrintf("7\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+    EXPECT_EQ(OK, err);
+    CheckStartTimeMs(parcel, 6000);
+    subtitle = StringPrintf("8\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel);
+    EXPECT_EQ(ERROR_END_OF_STREAM, err);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsEarlierThanFirst) {
+    MediaSource::ReadOptions options;
+    options.setSeekTo(500, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(OK, err);
+    EXPECT_EQ(1 * kSecToUsec, startTimeUs);
+    CheckStartTimeMs(parcel, 1 * kSecToMsec);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsLaterThanLast) {
+    MediaSource::ReadOptions options;
+    options.setSeekTo(7 * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(ERROR_END_OF_STREAM, err);
+
+    options.setSeekTo(8 * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(ERROR_END_OF_STREAM, err);
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeIsMatched) {
+    for (int i = 1; i <= 5; i++) {
+        MediaSource::ReadOptions options;
+        options.setSeekTo(i * kSecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+        err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+        EXPECT_EQ(OK, err);
+        EXPECT_EQ(i * kSecToUsec, startTimeUs);
+
+        options.setSeekTo(i * kSecToUsec + 100, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+        err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+        EXPECT_EQ(OK, err);
+        EXPECT_EQ(i * kSecToUsec, startTimeUs);
+    }
+}
+
+TEST_F(TimedTextSRTSourceTest, seekTimeInBetweenTwo) {
+    for (int i = 1; i <= 4; i++) {
+        MediaSource::ReadOptions options;
+        options.setSeekTo(i * kSecToUsec + 500000, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+        err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+        EXPECT_EQ(OK, err);
+        EXPECT_EQ((i + 1) * kSecToUsec, startTimeUs);
+
+        options.setSeekTo(i * kSecToUsec + 600000, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+        err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+        EXPECT_EQ(OK, err);
+        EXPECT_EQ((i + 1) * kSecToUsec, startTimeUs);
+    }
+}
+
+TEST_F(TimedTextSRTSourceTest, checkEdgeCase) {
+    MediaSource::ReadOptions options;
+    options.setSeekTo(5500 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(OK, err);
+    EXPECT_EQ(5500 * kMsecToUsec, startTimeUs);
+    subtitle = StringPrintf("6\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+
+    options.setSeekTo(5800 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(OK, err);
+    EXPECT_EQ(5800 * kMsecToUsec, startTimeUs);
+    subtitle = StringPrintf("7\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+
+    options.setSeekTo(6000 * kMsecToUsec, MediaSource::ReadOptions::SEEK_PREVIOUS_SYNC);
+    err = mSource->read(&startTimeUs, &endTimeUs, &parcel, &options);
+    EXPECT_EQ(OK, err);
+    EXPECT_EQ(6000 * kMsecToUsec, startTimeUs);
+    subtitle = StringPrintf("8\n\n");
+    CheckDataEquals(parcel, subtitle.c_str());
+}
+
+}  // namespace test
+}  // namespace android
diff --git a/media/mtp/MtpDevice.cpp b/media/mtp/MtpDevice.cpp
index bf7795c..d672dff 100644
--- a/media/mtp/MtpDevice.cpp
+++ b/media/mtp/MtpDevice.cpp
@@ -667,7 +667,7 @@
 // reads the object's data and writes it to the specified file path
 bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int group, int perm) {
     ALOGD("readObject: %s", destPath);
-    int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC);
+    int fd = ::open(destPath, O_RDWR | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
     if (fd < 0) {
         ALOGE("open failed for %s", destPath);
         return false;
diff --git a/media/mtp/MtpServer.cpp b/media/mtp/MtpServer.cpp
index 5606187..662a93d 100644
--- a/media/mtp/MtpServer.cpp
+++ b/media/mtp/MtpServer.cpp
@@ -931,7 +931,7 @@
     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 8473fab..c2d2790 100644
--- a/services/audioflinger/Android.mk
+++ b/services/audioflinger/Android.mk
@@ -89,7 +89,7 @@
 
 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
diff --git a/services/audioflinger/AudioBufferProviderSource.cpp b/services/audioflinger/AudioBufferProviderSource.cpp
index 4342171..613e924 100644
--- a/services/audioflinger/AudioBufferProviderSource.cpp
+++ b/services/audioflinger/AudioBufferProviderSource.cpp
@@ -46,14 +46,16 @@
     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 @@
     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 @@
         // 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 @@
             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/AudioBufferProviderSource.h b/services/audioflinger/AudioBufferProviderSource.h
index 2b39937..1435a84 100644
--- a/services/audioflinger/AudioBufferProviderSource.h
+++ b/services/audioflinger/AudioBufferProviderSource.h
@@ -42,8 +42,9 @@
     //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/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index aab9984..7e5f102 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -83,13 +83,7 @@
 #include "PipeReader.h"
 #include "SourceAudioBufferProvider.h"
 
-#ifdef HAVE_REQUEST_PRIORITY
 #include "SchedulingPolicyService.h"
-#endif
-
-#ifdef SOAKER
-#include "Soaker.h"
-#endif
 
 // ----------------------------------------------------------------------------
 
@@ -167,6 +161,10 @@
 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;
+
 // ----------------------------------------------------------------------------
 
 #ifdef ADD_BATTERY_DATA
@@ -216,9 +214,8 @@
 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 +244,17 @@
     }
 
     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(mRecordThreads.keyAt(0));
     }
     while (!mPlaybackThreads.isEmpty()) {
         // closeOutput() will remove first entry from mPlaybackThreads
-        closeOutput(mPlaybackThreads.keyAt(0));
+        closeOutput_nonvirtual(mPlaybackThreads.keyAt(0));
     }
 
     for (size_t i = 0; i < mAudioHwDevs.size(); i++) {
@@ -278,7 +271,9 @@
 };
 #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
@@ -289,22 +284,23 @@
         }
     } 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();
+        AudioHwDevice *audioHwDevice = mAudioHwDevs.valueAt(i);
+        audio_hw_device_t *dev = audioHwDevice->hwDevice();
         if ((dev->get_supported_devices(dev) & devices) == devices)
-            return dev;
+            return audioHwDevice;
     }
 
     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 +323,10 @@
         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 +339,9 @@
                             (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 +352,6 @@
             IPCThreadState::self()->getCallingUid());
     result.append(buffer);
     write(fd, result.string(), result.size());
-    return NO_ERROR;
 }
 
 static bool tryLock(Mutex& mutex)
@@ -440,7 +433,7 @@
         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,
@@ -610,30 +603,27 @@
         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 +646,9 @@
 
     { // 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 +675,9 @@
     }
 
     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 +691,44 @@
 
     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 +741,6 @@
     return masterVolume_l();
 }
 
-float AudioFlinger::masterVolumeSW() const
-{
-    Mutex::Autolock _l(mLock);
-    return masterVolumeSW_l();
-}
-
 bool AudioFlinger::masterMute() const
 {
     Mutex::Autolock _l(mLock);
@@ -741,23 +749,14 @@
 
 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 +875,19 @@
             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->device() & AUDIO_DEVICE_IN_ALL;
+                    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 +909,7 @@
     {
         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 +965,8 @@
     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 +977,17 @@
     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 +1010,9 @@
     }
 
     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;
@@ -1124,7 +1124,7 @@
 // ----------------------------------------------------------------------------
 
 AudioFlinger::ThreadBase::ThreadBase(const sp<AudioFlinger>& audioFlinger, audio_io_handle_t id,
-        uint32_t device, type_t type)
+        audio_devices_t device, type_t type)
     :   Thread(false),
         mType(type),
         mAudioFlinger(audioFlinger), mSampleRate(0), mFrameCount(0), mNormalFrameCount(0),
@@ -1132,8 +1132,7 @@
         mChannelCount(0),
         mFrameSize(1), mFormat(AUDIO_FORMAT_INVALID),
         mParamStatus(NO_ERROR),
-        mStandby(false), mId(id),
-        mDevice(device),
+        mStandby(false), mDevice(device), mId(id),
         mDeathRecipient(new PMDeathRecipient(this))
 {
 }
@@ -1226,7 +1225,7 @@
     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];
@@ -1283,10 +1282,9 @@
     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 +1299,6 @@
             chain->dump(fd, args);
         }
     }
-    return NO_ERROR;
 }
 
 void AudioFlinger::ThreadBase::acquireWakeLock()
@@ -1397,8 +1394,8 @@
         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 +1421,7 @@
 
     if (suspend) {
         if (index >= 0) {
-            sessionEffects = mSuspendedSessions.editValueAt(index);
+            sessionEffects = mSuspendedSessions.valueAt(index);
         } else {
             mSuspendedSessions.add(sessionId, sessionEffects);
         }
@@ -1432,7 +1429,7 @@
         if (index < 0) {
             return;
         }
-        sessionEffects = mSuspendedSessions.editValueAt(index);
+        sessionEffects = mSuspendedSessions.valueAt(index);
     }
 
 
@@ -1449,7 +1446,7 @@
         } 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 +1506,12 @@
 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),
         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 +1522,25 @@
 {
     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 +1559,14 @@
     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 +1614,9 @@
     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 +1640,6 @@
     fdprintf(fd, "Fast track availMask=%#x\n", mFastTrackAvailMask);
 
     dumpBase(fd, args);
-
-    return NO_ERROR;
 }
 
 // Thread virtuals
@@ -1660,7 +1665,7 @@
         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,
@@ -1715,7 +1720,7 @@
                 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 +1794,7 @@
             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;
         }
@@ -1804,18 +1809,16 @@
         }
     }
 
-#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);
+        int err = requestPriority(callingPid, tid, kPriorityAudioApp);
         if (err != 0) {
             ALOGW("Policy SCHED_FIFO priority %d is unavailable for pid %d tid %d; error %d",
-                    1, callingPid, tid, err);
+                    kPriorityAudioApp, callingPid, tid, err);
         }
     }
-#endif
 
     lStatus = NO_ERROR;
 
@@ -1857,13 +1860,25 @@
 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)
@@ -2192,28 +2207,25 @@
 // ----------------------------------------------------------------------------
 
 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 +2279,6 @@
         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 +2310,12 @@
 
         // 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 +2323,10 @@
         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,12 +2373,6 @@
         delete fastTrack->mBufferProvider;
         sq->end(false /*didModify*/);
         delete mFastMixer;
-#ifdef SOAKER
-        if (mSoaker != NULL) {
-            mSoaker->requestExitAndWait();
-        }
-        delete mSoaker;
-#endif
         if (mAudioWatchdog != 0) {
             mAudioWatchdog->requestExit();
             mAudioWatchdog->requestExitAndWait();
@@ -2508,9 +2505,6 @@
 
     // MIXER
     nsecs_t lastWarning = 0;
-if (mType == MIXER) {
-    longStandbyExit = false;
-}
 
     // DUPLICATING
     // FIXME could this be made local to while loop?
@@ -2519,9 +2513,9 @@
     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,7 +2542,7 @@
 
             // put audio hardware into standby after short delay
             if (CC_UNLIKELY((!mActiveTracks.size() && systemTime() > standbyTime) ||
-                        mSuspended > 0)) {
+                        isSuspended())) {
                 if (!mStandby) {
 
                     threadLoop_standby();
@@ -2602,7 +2596,7 @@
             threadLoop_sleepTime();
         }
 
-        if (mSuspended > 0) {
+        if (isSuspended()) {
             sleepTime = suspendSleepTimeUs();
         }
 
@@ -2635,11 +2629,6 @@
                             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 +2656,13 @@
         // 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();
 
@@ -2794,7 +2781,7 @@
 // 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 +2791,10 @@
     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 +2835,10 @@
         } 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
 }
@@ -3229,7 +3216,7 @@
             }
 
             //ALOGV("track %d u=%08x, s=%08x [NOT READY] on thread %p", name, cblk->user, cblk->server, this);
-            if ((track->sharedBuffer() != 0) || track->isTerminated() ||
+            if ((track->sharedBuffer() != 0) ||
                     track->isStopped() || track->isPaused()) {
                 // We have consumed all the buffers of this track.
                 // Remove it from the list of active tracks.
@@ -3249,8 +3236,8 @@
                 track->mUnderrunCount++;
                 // No buffers for this track. Give it a few chances to
                 // fill a buffer, then remove it from active list.
-                if (--(track->mRetryCount) <= 0) {
-                    ALOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", name, this);
+                if (--(track->mRetryCount) <= 0 || track->isTerminated()) {
+                    ALOGV_IF(track->mRetryCount <= 0, "BUFFER TIMEOUT: remove(%d) from active list on thread %p", name, this);
                     tracksToRemove->add(track);
                     // indicate to client process that the track was disabled because of underrun;
                     // it will then automatically call start() when data is available
@@ -3373,7 +3360,7 @@
     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());
@@ -3460,14 +3447,14 @@
 #ifdef ADD_BATTERY_DATA
             // when changing the audio output device, call addBatteryData to notify
             // the change
-            if ((int)mDevice != value) {
+            if (mDevice != 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,7 +3469,7 @@
 
             // forward device change to effects that have requested to be
             // aware of attached audio device.
-            mDevice = (uint32_t)value;
+            mDevice = value;
             for (size_t i = 0; i < mEffectChains.size(); i++) {
                 mEffectChains[i]->setDevice_l(mDevice);
             }
@@ -3505,7 +3492,7 @@
                 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);
                     if (name < 0) break;
                     mTracks[i]->mName = name;
                     // limit track sample rate to 2 x new output sample rate
@@ -3539,7 +3526,7 @@
     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 +3580,8 @@
 #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 +3590,7 @@
                     }
                     break;
                 }
-                ALOG_ASSERT(actual <= count);
+                ALOG_ASSERT(actual <= (ssize_t)count);
                 write(teeFd, buffer, actual * channelCount * sizeof(short));
                 total += actual;
             }
@@ -3624,8 +3612,6 @@
         AudioWatchdogDump wdCopy = mAudioWatchdogDump;
         wdCopy.dump(fd);
     }
-
-    return NO_ERROR;
 }
 
 uint32_t AudioFlinger::MixerThread::idleSleepTimeUs() const
@@ -3651,7 +3637,7 @@
 
 // ----------------------------------------------------------------------------
 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
 {
@@ -3751,7 +3737,7 @@
             }
 
             //ALOGV("track %d u=%08x, s=%08x [NOT READY]", track->name(), cblk->user, cblk->server);
-            if ((track->sharedBuffer() != 0) || track->isTerminated() ||
+            if ((track->sharedBuffer() != 0) ||
                     track->isStopped() || track->isPaused()) {
                 // We have consumed all the buffers of this track.
                 // Remove it from the list of active tracks.
@@ -3769,8 +3755,8 @@
             } else {
                 // No buffers for this track. Give it a few chances to
                 // fill a buffer, then remove it from active list.
-                if (--(track->mRetryCount) <= 0) {
-                    ALOGV("BUFFER TIMEOUT: remove(%d) from active list", track->name());
+                if (--(track->mRetryCount) <= 0 || track->isTerminated()) {
+                    ALOGV_IF(track->mRetryCount <= 0, "BUFFER TIMEOUT: remove(%d) from active list", track->name());
                     trackToRemove = track;
                 } else {
                     mixerStatus = MIXER_TRACKS_ENABLED;
@@ -4070,6 +4056,7 @@
             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 +4086,7 @@
             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 +4261,7 @@
             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 +4287,7 @@
         // 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);
         mCblk->mName = mName;
         if (mName < 0) {
             ALOGE("no more track names available");
@@ -4329,11 +4316,6 @@
 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 +4478,6 @@
         }
 
         buffer->raw = getBuffer(s, framesReq);
-        if (buffer->raw == NULL) goto getNextBuffer_exit;
-
         buffer->frameCount = framesReq;
         return NO_ERROR;
     }
@@ -4821,12 +4801,12 @@
             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 +4819,7 @@
             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 +5041,7 @@
     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 +5056,7 @@
 
         // 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 +5083,7 @@
                 // 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 +5092,7 @@
             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 +5314,7 @@
             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 +5335,7 @@
 
 AudioFlinger::RecordThread::RecordTrack::~RecordTrack()
 {
-    sp<ThreadBase> thread = mThread.promote();
-    if (thread != 0) {
-        AudioSystem::releaseInput(thread->id());
-    }
+    ALOGV("%s", __func__);
 }
 
 // AudioBufferProvider interface
@@ -5389,8 +5366,6 @@
         }
 
         buffer->raw = getBuffer(s, framesReq);
-        if (buffer->raw == NULL) goto getNextBuffer_exit;
-
         buffer->frameCount = framesReq;
         return NO_ERROR;
     }
@@ -5418,14 +5393,26 @@
     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\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",
@@ -5448,7 +5435,7 @@
             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 +5823,10 @@
         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 +5865,8 @@
             }
         }
         // 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 +5896,24 @@
 }
 
 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 +5929,13 @@
 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) :
+                                         audio_devices_t device) :
     ThreadBase(audioFlinger, id, device, RECORD),
-    mInput(input), mTrack(NULL), mResampler(NULL), mRsmpOutBuffer(NULL), mRsmpInBuffer(NULL),
+    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,6 +5973,7 @@
 
     nsecs_t lastWarning = 0;
 
+    inputStandBy();
     acquireWakeLock();
 
     // start recording
@@ -5996,10 +5985,7 @@
             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,10 +5999,7 @@
             }
             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) {
@@ -6034,6 +6017,9 @@
                         mStartStopCond.broadcast();
                     }
                     mStandby = false;
+                } else if (mActiveTrack->mState == TrackBase::TERMINATED) {
+                    removeTrack_l(mActiveTrack);
+                    mActiveTrack.clear();
                 }
             }
             lockEffectChains_l(effectChains);
@@ -6068,18 +6054,12 @@
                                 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);
                                 }
                             }
                         }
@@ -6097,7 +6077,7 @@
                                 if (mActiveTrack->mState == TrackBase::ACTIVE) {
                                     // 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;
@@ -6120,12 +6100,8 @@
                     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 +6127,7 @@
                         }
                     }
                 }
-                mActiveTrack->overflow();
+                mActiveTrack->clearOverflow();
             }
             // client isn't retrieving buffers fast enough
             else {
@@ -6173,12 +6149,13 @@
         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 +6163,28 @@
     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 +6196,8 @@
         goto Exit;
     }
 
+    // FIXME use flags and tid similar to createTrack_l()
+
     { // scope for mLock
         Mutex::Autolock _l(mLock);
 
@@ -6215,11 +6208,11 @@
             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(mDevice & AUDIO_DEVICE_IN_ALL) &&
+                        mAudioFlinger->btNrecIsOff();
         setEffectSuspended_l(FX_IID_AEC, suspend, sessionId);
         setEffectSuspended_l(FX_IID_NS, suspend, sessionId);
     }
@@ -6337,27 +6330,23 @@
     }
 }
 
-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)
@@ -6371,16 +6360,63 @@
         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()) {
+            track->setSyncEvent(event);
+            ret = NO_ERROR;
+        }
     }
-    return NAME_NOT_FOUND;
+    return ret;
 }
 
-status_t AudioFlinger::RecordThread::dump(int fd, const Vector<String16>& args)
+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);
+    }
+}
+
+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 +6426,6 @@
     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 +6436,41 @@
         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
@@ -6432,7 +6487,7 @@
             if (mActiveTrack->mState == TrackBase::ACTIVE) {
                 // 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;
@@ -6508,25 +6563,30 @@
             // 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()
+            audio_devices_t newDevice = mDevice;
             if (value & AUDIO_DEVICE_OUT_ALL) {
-                mDevice &= (uint32_t)~(value & AUDIO_DEVICE_OUT_ALL);
+                newDevice &= ~(value & AUDIO_DEVICE_OUT_ALL);
                 status = BAD_VALUE;
             } else {
-                mDevice &= (uint32_t)~(value & AUDIO_DEVICE_IN_ALL);
+                newDevice &= ~(value & AUDIO_DEVICE_IN_ALL);
                 // disable AEC and NS if the device is a BT SCO headset supporting those pre processings
-                if (mTrack != NULL) {
+                if (mTracks.size() > 0) {
                     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());
+                    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;
+            newDevice |= value;
+            mDevice = newDevice;    // since mDevice is read by other threads, only write to it once
         }
         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());
             }
@@ -6656,23 +6716,28 @@
         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()
 {
+    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 +6795,52 @@
         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);
@@ -6764,11 +6865,11 @@
         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 +6885,12 @@
     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 +6934,8 @@
 
             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 +6966,11 @@
 
 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 +7002,7 @@
         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 +7043,7 @@
                                           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 +7056,7 @@
     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 +7068,10 @@
     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 +7087,9 @@
         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 +7098,7 @@
         // 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 +7111,6 @@
         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 +7121,18 @@
 
 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 +7147,7 @@
     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 +7156,11 @@
 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 +7254,14 @@
             }
         }
         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 +7299,14 @@
     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();
 
@@ -7401,7 +7463,7 @@
                     // 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 +7479,7 @@
             // 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 +7498,7 @@
         }
 
         // 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.
@@ -7670,7 +7732,7 @@
         }
         // 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();
         }
@@ -7810,7 +7872,7 @@
 }
 
 void AudioFlinger::ThreadBase::disconnectEffect(const sp<EffectModule>& effect,
-                                                    const wp<EffectHandle>& handle,
+                                                    EffectHandle *handle,
                                                     bool unpinIfLast) {
 
     Mutex::Autolock _l(mLock);
@@ -8002,16 +8064,18 @@
                                         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 +8089,6 @@
         goto Error;
     }
 
-    if (mSessionId > AUDIO_SESSION_OUTPUT_MIX) {
-        mPinned = true;
-    }
     ALOGV("Constructor success name %s, Interface %p", mDescriptor.name, mEffectInterface);
     return;
 Error:
@@ -8055,38 +8116,41 @@
     }
 }
 
-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 +8161,44 @@
     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 +8208,7 @@
             thread->disconnectEffect(keep, handle, unpinIfLast);
         }
     }
+    return mHandles.size();
 }
 
 void AudioFlinger::EffectModule::updateState() {
@@ -8240,7 +8306,6 @@
 
 status_t AudioFlinger::EffectModule::configure()
 {
-    uint32_t channels;
     if (mEffectInterface == NULL) {
         return NO_INIT;
     }
@@ -8251,18 +8316,14 @@
     }
 
     // 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 +8513,8 @@
     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 +8524,14 @@
 
 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 +8566,8 @@
             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,14 +8640,14 @@
     return status;
 }
 
-status_t AudioFlinger::EffectModule::setDevice(uint32_t device)
+status_t AudioFlinger::EffectModule::setDevice(audio_devices_t device)
 {
     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;
+        audio_devices_t dev = device & AUDIO_DEVICE_OUT_ALL;
         if (dev) {
             status_t cmdStatus;
             uint32_t size = sizeof(status_t);
@@ -8649,7 +8716,23 @@
     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 +8798,8 @@
     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 +8812,6 @@
     if (locked) {
         mLock.unlock();
     }
-
-    return NO_ERROR;
 }
 
 // ----------------------------------------------------------------------------
@@ -8746,7 +8827,7 @@
                                         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 +8852,15 @@
 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 +8931,8 @@
     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 +9362,7 @@
 }
 
 // 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++) {
@@ -9350,7 +9437,7 @@
     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 +9471,6 @@
     if (locked) {
         mLock.unlock();
     }
-
-    return NO_ERROR;
 }
 
 // must be called with ThreadBase::mLock held
@@ -9401,7 +9486,7 @@
             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 +9513,12 @@
                 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 cfd718f..e5176a9 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -91,7 +91,7 @@
                                 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 @@
                                 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 @@
     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 @@
 
     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,
@@ -255,6 +256,8 @@
                                         void *cookie);
 
 private:
+    class AudioHwDevice;    // fwd declaration for findSuitableHwDev_l
+
                audio_mode_t getMode() const { return mMode; }
 
                 bool        btNrecIsOff() const { return mBtNrecIsOff; }
@@ -268,17 +271,17 @@
     // 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 +353,11 @@
             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 device, 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 +383,14 @@
                                         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 +415,17 @@
 
             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 {
@@ -455,7 +465,7 @@
             bool                mStepServerFailed;
             const int           mSessionId;
             uint8_t             mChannelCount;
-            uint32_t            mChannelMask;
+            audio_channel_mask_t mChannelMask;
             Vector < sp<SyncEvent> >mSyncEvents;
         };
 
@@ -483,14 +493,20 @@
         };
 
         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.
                     size_t      frameCount() const { return mNormalFrameCount; }
-                    void        wakeUp()    { mWaitWorkCV.broadcast(); }
+
         // Should be "virtual status_t requestExitAndWait()" and override same
         // method in Thread, but Thread::requestExitAndWait() is not yet virtual.
                     void        exit();
@@ -501,9 +517,11 @@
                     void        sendConfigEvent(int event, int param = 0);
                     void        sendConfigEvent_l(int event, int param = 0);
                     void        processConfigEvents();
-                    audio_io_handle_t id() const { return mId;}
+
+                    // see note at declaration of mStandby and mDevice
                     bool        standby() const { return mStandby; }
-                    uint32_t    device() const { return mDevice; }
+                    audio_devices_t device() const { return mDevice; }
+
         virtual     audio_stream_t* stream() const = 0;
 
                     sp<EffectHandle> createEffect_l(
@@ -515,7 +533,7 @@
                                         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)
@@ -598,7 +616,7 @@
                     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,
@@ -617,7 +635,7 @@
                     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;
@@ -646,11 +664,19 @@
                     status_t                mParamStatus;
 
                     Vector<ConfigEvent>     mConfigEvents;
-                    bool                    mStandby;
+
+                    // These fields are written and read by thread itself without lock or barrier,
+                    // and read by other threads without lock or barrier via standby() and device().
+                    // 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         mDevice;    // output device for PlaybackThread
+                                                        // input + output devices for RecordThread
+
                     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 +717,7 @@
                                         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 +734,7 @@
                     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 +791,14 @@
             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 +841,11 @@
                                          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 +884,7 @@
                        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 +933,7 @@
                                         DuplicatingThread *sourceThread,
                                         uint32_t sampleRate,
                                         audio_format_t format,
-                                        uint32_t channelMask,
+                                        audio_channel_mask_t channelMask,
                                         int frameCount);
             virtual             ~OutputTrack();
 
@@ -936,10 +964,10 @@
         };  // 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();
@@ -984,7 +1012,7 @@
                                     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 +1024,19 @@
                     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);
@@ -1018,10 +1056,19 @@
 
                     virtual status_t setSyncEvent(const sp<SyncEvent>& event);
                     virtual bool     isValidSyncEvent(const sp<SyncEvent>& event);
+                            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
@@ -1069,13 +1116,14 @@
 
         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 +1148,6 @@
 
         // 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,15 +1186,14 @@
         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);
@@ -1167,9 +1213,6 @@
 
                     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 +1241,7 @@
     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
@@ -1287,7 +1330,7 @@
                                      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);
 
@@ -1331,18 +1374,22 @@
                                         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,18 +1402,24 @@
             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();
 
+        // 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
         virtual bool        threadLoop();
         virtual status_t    readyToRun();
@@ -1379,17 +1432,22 @@
                         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;
 
@@ -1406,7 +1464,11 @@
         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();
+
+                // 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();
 
         virtual status_t setSyncEvent(const sp<SyncEvent>& event);
         virtual bool     isValidSyncEvent(const sp<SyncEvent>& event);
@@ -1417,9 +1479,16 @@
     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 +1514,15 @@
         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 +1582,7 @@
             return mSessionId;
         }
         status_t    setEnabled(bool enabled);
+        status_t    setEnabled_l(bool enabled);
         bool isEnabled() const;
         bool isProcessEnabled() const;
 
@@ -1521,14 +1594,14 @@
         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         start();
@@ -1536,12 +1609,15 @@
         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 +1635,14 @@
 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 +1700,8 @@
         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 +1720,8 @@
         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,7 +1764,7 @@
         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 setInBuffer(int16_t *buffer, bool ownsBuffer = false) {
@@ -1703,12 +1783,12 @@
 
         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 +1805,7 @@
 
         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 +1840,11 @@
         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 +1861,59 @@
         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 +1925,6 @@
         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 +1934,7 @@
                 // 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 +1958,8 @@
         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
@@ -1885,8 +1970,6 @@
 
                 // both are protected by mLock
                 float                               mMasterVolume;
-                float                               mMasterVolumeSW;
-                master_volume_support               mMasterVolumeSupportLvl;
                 bool                                mMasterMute;
 
                 DefaultKeyedVector< audio_io_handle_t, sp<RecordThread> >    mRecordThreads;
@@ -1900,8 +1983,7 @@
                 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 +1992,9 @@
 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 3e4c55e..a9814a1 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -416,7 +416,7 @@
     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);
diff --git a/services/audioflinger/AudioPolicyService.cpp b/services/audioflinger/AudioPolicyService.cpp
index 0d13970..3a2dbe2 100644
--- a/services/audioflinger/AudioPolicyService.cpp
+++ b/services/audioflinger/AudioPolicyService.cpp
@@ -223,7 +223,7 @@
 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 +231,7 @@
     }
     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 +271,7 @@
 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 +282,9 @@
         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 +373,7 @@
     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 +391,7 @@
     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 +412,7 @@
     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 +441,7 @@
     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 +450,7 @@
     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,
@@ -512,7 +514,7 @@
     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) {
@@ -778,7 +780,6 @@
     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 +791,6 @@
     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 +811,6 @@
     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",
@@ -841,11 +836,6 @@
     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",
@@ -868,11 +858,6 @@
     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);
@@ -891,6 +876,7 @@
     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 +922,7 @@
             } else {
                 data2->mKeyValuePairs = param2.toString();
             }
+            time = command2->mTime;
         } break;
 
         case SET_VOLUME: {
@@ -946,6 +933,7 @@
             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 +955,17 @@
     }
     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 +1421,7 @@
     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 fbca000..a086734 100644
--- a/services/audioflinger/AudioPolicyService.h
+++ b/services/audioflinger/AudioPolicyService.h
@@ -64,7 +64,7 @@
     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 @@
     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 @@
     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,
diff --git a/services/audioflinger/AudioStreamOutSink.cpp b/services/audioflinger/AudioStreamOutSink.cpp
index 8a5aa0c..bc2d15b 100644
--- a/services/audioflinger/AudioStreamOutSink.cpp
+++ b/services/audioflinger/AudioStreamOutSink.cpp
@@ -67,4 +67,16 @@
     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/AudioStreamOutSink.h b/services/audioflinger/AudioStreamOutSink.h
index 1eff3f6..5976b18 100644
--- a/services/audioflinger/AudioStreamOutSink.h
+++ b/services/audioflinger/AudioStreamOutSink.h
@@ -47,6 +47,11 @@
 
     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/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 7652132..fbcc11a 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -222,8 +222,8 @@
                     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;
@@ -399,8 +399,13 @@
                 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;
diff --git a/services/audioflinger/MonoPipe.cpp b/services/audioflinger/MonoPipe.cpp
index f3fc19a..bd876b4 100644
--- a/services/audioflinger/MonoPipe.cpp
+++ b/services/audioflinger/MonoPipe.cpp
@@ -17,17 +17,22 @@
 #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 "AudioBufferProvider.h"
 #include "MonoPipe.h"
 #include "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))),
@@ -38,6 +43,37 @@
         mSetpoint((reqFrames * 11) / 16),
         mWriteCanBlock(writeCanBlock)
 {
+    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()
@@ -162,4 +198,102 @@
     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;
+}
+
 }   // namespace android
diff --git a/services/audioflinger/MonoPipe.h b/services/audioflinger/MonoPipe.h
index f6e2cb3..c47bf6c 100644
--- a/services/audioflinger/MonoPipe.h
+++ b/services/audioflinger/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,6 +57,20 @@
     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; }
@@ -63,20 +78,42 @@
             size_t  maxFrames() const { return mMaxFrames; }
 
 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;
 };
 
 }   // namespace android
diff --git a/services/audioflinger/MonoPipeReader.cpp b/services/audioflinger/MonoPipeReader.cpp
index b80d0c0..39a07de 100644
--- a/services/audioflinger/MonoPipeReader.cpp
+++ b/services/audioflinger/MonoPipeReader.cpp
@@ -43,11 +43,25 @@
     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 @@
                 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/MonoPipeReader.h b/services/audioflinger/MonoPipeReader.h
index 9bb0a94..0e1c992 100644
--- a/services/audioflinger/MonoPipeReader.h
+++ b/services/audioflinger/MonoPipeReader.h
@@ -47,7 +47,7 @@
 
     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.cpp b/services/audioflinger/NBAIO.cpp
index 9d71eae..2c07ebf 100644
--- a/services/audioflinger/NBAIO.cpp
+++ b/services/audioflinger/NBAIO.cpp
@@ -128,7 +128,8 @@
 }
 
 // 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 @@
         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/NBAIO.h b/services/audioflinger/NBAIO.h
index b5ae0f1..81f42ed 100644
--- a/services/audioflinger/NBAIO.h
+++ b/services/audioflinger/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 @@
 
 // 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 @@
     //  < 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 @@
     // 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 @@
     //  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 @@
     //  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 @@
     //  > 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/Soaker.h b/services/audioflinger/Soaker.h
deleted file mode 100644
index 43d9d2f..0000000
--- a/services/audioflinger/Soaker.h
+++ /dev/null
@@ -1,45 +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.
- */
-
-#ifndef _ANDROID_AUDIO_SOAKER_H
-#define _ANDROID_AUDIO_SOAKER_H
-
-#include <utils/Thread.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;
-    }
-};
-
-}   // namespace android
-
-#endif  // _ANDROID_AUDIO_SOAKER_H
diff --git a/services/audioflinger/SourceAudioBufferProvider.cpp b/services/audioflinger/SourceAudioBufferProvider.cpp
index e9d6d2c..3343b53 100644
--- a/services/audioflinger/SourceAudioBufferProvider.cpp
+++ b/services/audioflinger/SourceAudioBufferProvider.cpp
@@ -65,7 +65,7 @@
         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/camera/libcameraservice/Android.mk b/services/camera/libcameraservice/Android.mk
index 3cae1f5..c14ae22 100644
--- a/services/camera/libcameraservice/Android.mk
+++ b/services/camera/libcameraservice/Android.mk
@@ -7,7 +7,11 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:=               \
-    CameraService.cpp
+    CameraService.cpp \
+    CameraClient.cpp \
+    Camera2Client.cpp \
+    Camera2Device.cpp \
+    MediaConsumer.cpp
 
 LOCAL_SHARED_LIBRARIES:= \
     libui \
@@ -18,7 +22,12 @@
     libmedia_native \
     libcamera_client \
     libgui \
-    libhardware
+    libhardware \
+    libsync \
+    libcamera_metadata
+
+LOCAL_C_INCLUDES += \
+    system/media/camera/include
 
 LOCAL_MODULE:= libcameraservice
 
diff --git a/services/camera/libcameraservice/Camera2Client.cpp b/services/camera/libcameraservice/Camera2Client.cpp
new file mode 100644
index 0000000..9c2fbcb
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Client.cpp
@@ -0,0 +1,3480 @@
+/*
+ * 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 "Camera2Client"
+#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 <media/hardware/MetadataBufferType.h>
+
+#include <math.h>
+
+#include "Camera2Client.h"
+
+namespace android {
+
+#define ALOG1(...) ALOGD_IF(gLogLevel >= 1, __VA_ARGS__);
+#define ALOG2(...) ALOGD_IF(gLogLevel >= 2, __VA_ARGS__);
+
+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):
+        Client(cameraService, cameraClient,
+                cameraId, cameraFacing, clientPid),
+        mState(DISCONNECTED),
+        mPreviewStreamId(NO_STREAM),
+        mPreviewRequest(NULL),
+        mCaptureStreamId(NO_STREAM),
+        mCaptureRequest(NULL),
+        mRecordingStreamId(NO_STREAM),
+        mRecordingRequest(NULL),
+        mRecordingHeapCount(kDefaultRecordingHeapCount)
+{
+    ATRACE_CALL();
+
+    mDevice = new Camera2Device(cameraId);
+}
+
+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: E", __FUNCTION__);
+    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);
+
+    res = buildDefaultParameters();
+    if (res != OK) {
+        ALOGE("%s: Camera %d: unable to build defaults: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return NO_INIT;
+    }
+
+    if (gLogLevel >= 1) {
+        LockedParameters::Key k(mParameters);
+        ALOGD("%s: Default parameters converted from camera %d:", __FUNCTION__,
+              mCameraId);
+        ALOGD("%s", k.mParameters.paramsFlattened.string());
+    }
+
+    mState = STOPPED;
+
+    return OK;
+}
+
+Camera2Client::~Camera2Client() {
+    ATRACE_CALL();
+    ALOGV("%s: Camera %d: Shutting down", __FUNCTION__, mCameraId);
+
+    mDestructionStarted = true;
+
+    // Rewrite mClientPid to allow shutdown by CameraService
+    mClientPid = getCallingPid();
+    disconnect();
+}
+
+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.unsafeUnlock();
+
+    result.append(getStateName(mState));
+
+    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_AUTO)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_INCANDESCENT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_FLUORESCENT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_WARM_FLUORESCENT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_DAYLIGHT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_CLOUDY_DAYLIGHT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_TWILIGHT)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AWB_SHADE)
+        default: result.append("UNKNOWN\n");
+    }
+
+    result.append("    Effect mode: ");
+    switch (p.effectMode) {
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_OFF)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_MONO)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_NEGATIVE)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_SOLARIZE)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_SEPIA)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_POSTERIZE)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_WHITEBOARD)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_BLACKBOARD)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_EFFECT_AQUA)
+        default: result.append("UNKNOWN\n");
+    }
+
+    result.append("    Antibanding mode: ");
+    switch (p.antibandingMode) {
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_AUTO)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_OFF)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_50HZ)
+        CASE_APPEND_ENUM(ANDROID_CONTROL_AE_ANTIBANDING_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("    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", mPreviewStreamId);
+    result.appendFormat("    Capture stream ID: %d\n", mCaptureStreamId);
+    result.appendFormat("    Recording stream ID: %d\n", mRecordingStreamId);
+
+    result.append("  Current requests:\n");
+    if (mPreviewRequest != NULL) {
+        result.append("    Preview request:\n");
+        write(fd, result.string(), result.size());
+        dump_indented_camera_metadata(mPreviewRequest, fd, 2, 6);
+    } else {
+        result.append("    Preview request: undefined\n");
+        write(fd, result.string(), result.size());
+    }
+
+    if (mCaptureRequest != NULL) {
+        result = "    Capture request:\n";
+        write(fd, result.string(), result.size());
+        dump_indented_camera_metadata(mCaptureRequest, fd, 2, 6);
+    } else {
+        result = "    Capture request: undefined\n";
+        write(fd, result.string(), result.size());
+    }
+
+    if (mRecordingRequest != NULL) {
+        result = "    Recording request:\n";
+        write(fd, result.string(), result.size());
+        dump_indented_camera_metadata(mRecordingRequest, fd, 2, 6);
+    } else {
+        result = "    Recording request: undefined\n";
+        write(fd, result.string(), result.size());
+    }
+
+    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;
+}
+
+const char* Camera2Client::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
+}
+
+// ICamera interface
+
+void Camera2Client::disconnect() {
+    ATRACE_CALL();
+    ALOGV("%s: E", __FUNCTION__);
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return;
+
+    if (mDevice == 0) return;
+
+    stopPreviewL();
+
+    mDevice->waitUntilDrained();
+
+    if (mPreviewStreamId != NO_STREAM) {
+        mDevice->deleteStream(mPreviewStreamId);
+        mPreviewStreamId = NO_STREAM;
+    }
+
+    if (mCaptureStreamId != NO_STREAM) {
+        mDevice->deleteStream(mCaptureStreamId);
+        mCaptureStreamId = NO_STREAM;
+    }
+
+    if (mRecordingStreamId != NO_STREAM) {
+        mDevice->deleteStream(mRecordingStreamId);
+        mRecordingStreamId = NO_STREAM;
+    }
+
+    mDevice.clear();
+    mState = DISCONNECTED;
+
+    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;
+
+    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);
+
+    // TODO: Check for uninterruptable conditions
+
+    if (mClientPid == getCallingPid()) {
+        mClientPid = 0;
+        mCameraClient.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;
+    }
+
+    switch (mState) {
+        case DISCONNECTED:
+        case RECORD:
+        case STILL_CAPTURE:
+        case VIDEO_SNAPSHOT:
+            ALOGE("%s: Camera %d: Cannot set preview display while in state %s",
+                    __FUNCTION__, mCameraId, getStateName(mState));
+            return INVALID_OPERATION;
+        case STOPPED:
+        case WAITING_FOR_PREVIEW_WINDOW:
+            // OK
+            break;
+        case PREVIEW:
+            // Already running preview - need to stop and create a new stream
+            // TODO: Optimize this so that we don't wait for old stream to drain
+            // before spinning up new stream
+            mDevice->setStreamingRequest(NULL);
+            mState = WAITING_FOR_PREVIEW_WINDOW;
+            break;
+    }
+
+    if (mPreviewStreamId != NO_STREAM) {
+        res = mDevice->waitUntilDrained();
+        if (res != OK) {
+            ALOGE("%s: Error waiting for preview to drain: %s (%d)",
+                    __FUNCTION__, strerror(-res), res);
+            return res;
+        }
+        res = mDevice->deleteStream(mPreviewStreamId);
+        if (res != OK) {
+            ALOGE("%s: Unable to delete old preview stream: %s (%d)",
+                    __FUNCTION__, strerror(-res), res);
+            return res;
+        }
+        mPreviewStreamId = NO_STREAM;
+    }
+
+    mPreviewSurface = binder;
+    mPreviewWindow = window;
+
+    if (mState == WAITING_FOR_PREVIEW_WINDOW) {
+        return startPreviewL();
+    }
+
+    return OK;
+}
+
+void Camera2Client::setPreviewCallbackFlag(int flag) {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return;
+}
+
+status_t Camera2Client::startPreview() {
+    ATRACE_CALL();
+    ALOGV("%s: E", __FUNCTION__);
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+    return startPreviewL();
+}
+
+status_t Camera2Client::startPreviewL() {
+    ATRACE_CALL();
+    status_t res;
+    if (mState >= PREVIEW) {
+        ALOGE("%s: Can't start preview in state %s",
+                __FUNCTION__, getStateName(mState));
+        return INVALID_OPERATION;
+    }
+
+    if (mPreviewWindow == 0) {
+        mState = WAITING_FOR_PREVIEW_WINDOW;
+        return OK;
+    }
+    mState = STOPPED;
+
+    LockedParameters::Key k(mParameters);
+
+    res = updatePreviewStream(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update preview stream: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    if (mPreviewRequest == NULL) {
+        res = updatePreviewRequest(k.mParameters);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to create preview request: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    res = updateEntry(mPreviewRequest,
+            ANDROID_REQUEST_OUTPUT_STREAMS,
+            &mPreviewStreamId, 1);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set up preview request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+    res = sort_camera_metadata(mPreviewRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Error sorting preview request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    res = mDevice->setStreamingRequest(mPreviewRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set preview request to start preview: "
+                "%s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+    mState = 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();
+    switch (mState) {
+        case DISCONNECTED:
+            ALOGE("%s: Camera %d: Call before initialized",
+                    __FUNCTION__, mCameraId);
+            break;
+        case STOPPED:
+            break;
+        case STILL_CAPTURE:
+            ALOGE("%s: Camera %d: Cannot stop preview during still capture.",
+                    __FUNCTION__, mCameraId);
+            break;
+        case RECORD:
+            // TODO: Handle record stop here
+        case PREVIEW:
+            mDevice->setStreamingRequest(NULL);
+            mDevice->waitUntilDrained();
+        case WAITING_FOR_PREVIEW_WINDOW:
+            mState = STOPPED;
+            break;
+        default:
+            ALOGE("%s: Camera %d: Unknown state %d", __FUNCTION__, mCameraId,
+                    mState);
+    }
+}
+
+bool Camera2Client::previewEnabled() {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return false;
+
+    return mState == PREVIEW;
+}
+
+status_t Camera2Client::storeMetaDataInBuffers(bool enabled) {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+    switch (mState) {
+        case RECORD:
+        case VIDEO_SNAPSHOT:
+            ALOGE("%s: Camera %d: Can't be called in state %s",
+                    __FUNCTION__, mCameraId, getStateName(mState));
+            return INVALID_OPERATION;
+        default:
+            // OK
+            break;
+    }
+    LockedParameters::Key k(mParameters);
+
+    k.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;
+
+    switch (mState) {
+        case STOPPED:
+            res = startPreviewL();
+            if (res != OK) return res;
+            break;
+        case PREVIEW:
+            // Ready to go
+            break;
+        case RECORD:
+        case VIDEO_SNAPSHOT:
+            // OK to call this when recording is already on
+            return OK;
+            break;
+        default:
+            ALOGE("%s: Camera %d: Can't start recording in state %s",
+                    __FUNCTION__, mCameraId, getStateName(mState));
+            return INVALID_OPERATION;
+    };
+
+    LockedParameters::Key k(mParameters);
+
+    if (!k.mParameters.storeMetadataInBuffers) {
+        ALOGE("%s: Camera %d: Recording only supported in metadata mode, but "
+                "non-metadata recording mode requested!", __FUNCTION__,
+                mCameraId);
+        return INVALID_OPERATION;
+    }
+
+    res = updateRecordingStream(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update recording stream: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    if (mRecordingRequest == NULL) {
+        res = updateRecordingRequest(k.mParameters);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to create recording request: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    uint8_t outputStreams[2] = { mPreviewStreamId, mRecordingStreamId };
+    res = updateEntry(mRecordingRequest,
+            ANDROID_REQUEST_OUTPUT_STREAMS,
+            outputStreams, 2);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set up recording request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+    res = sort_camera_metadata(mRecordingRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Error sorting recording request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    res = mDevice->setStreamingRequest(mRecordingRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set recording request to start "
+                "recording: %s (%d)", __FUNCTION__, mCameraId,
+                strerror(-res), res);
+        return res;
+    }
+    mState = RECORD;
+
+    return OK;
+}
+
+void Camera2Client::stopRecording() {
+    ATRACE_CALL();
+    ALOGV("%s: E", __FUNCTION__);
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return;
+
+    switch (mState) {
+        case RECORD:
+            // OK to stop
+            break;
+        case STOPPED:
+        case PREVIEW:
+        case STILL_CAPTURE:
+        case VIDEO_SNAPSHOT:
+        default:
+            ALOGE("%s: Camera %d: Can't stop recording in state %s",
+                    __FUNCTION__, mCameraId, getStateName(mState));
+            return;
+    };
+
+    // Back to preview. Since record can only be reached through preview,
+    // all preview stream setup should be up to date.
+    res = mDevice->setStreamingRequest(mPreviewRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to switch back to preview request: "
+                "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+        return;
+    }
+
+    // TODO: Should recording heap be freed? Can't do it yet since requests
+    // could still be in flight.
+
+    mState = PREVIEW;
+}
+
+bool Camera2Client::recordingEnabled() {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+
+    if ( checkPid(__FUNCTION__) != OK) return false;
+
+    return recordingEnabledL();
+}
+
+bool Camera2Client::recordingEnabledL() {
+    ATRACE_CALL();
+
+    return (mState == RECORD || mState == VIDEO_SNAPSHOT);
+}
+
+void Camera2Client::releaseRecordingFrame(const sp<IMemory>& mem) {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( checkPid(__FUNCTION__) != OK) return;
+    // 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__, mCameraId,
+                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__, mCameraId, type, kMetadataBufferTypeGrallocSource);
+        return;
+    }
+    buffer_handle_t imgBuffer = *(buffer_handle_t*)(data + 4);
+    ALOGV("%s: Camera %d: Freeing buffer_handle_t %p", __FUNCTION__, mCameraId,
+            imgBuffer);
+    res = mRecordingConsumer->freeBuffer(imgBuffer);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to free recording frame (buffer_handle_t: %p):"
+                "%s (%d)",
+                __FUNCTION__, mCameraId, imgBuffer, strerror(-res), res);
+        return;
+    }
+
+    mRecordingHeapFree++;
+}
+
+status_t Camera2Client::autoFocus() {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+    int triggerId;
+    {
+        LockedParameters::Key k(mParameters);
+        k.mParameters.currentAfTriggerId = ++k.mParameters.afTriggerCounter;
+        triggerId = k.mParameters.currentAfTriggerId;
+    }
+
+    mDevice->triggerAutofocus(triggerId);
+
+    return OK;
+}
+
+status_t Camera2Client::cancelAutoFocus() {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+    int triggerId;
+    {
+        LockedParameters::Key k(mParameters);
+        triggerId = ++k.mParameters.afTriggerCounter;
+    }
+
+    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;
+
+    switch (mState) {
+        case DISCONNECTED:
+        case STOPPED:
+        case WAITING_FOR_PREVIEW_WINDOW:
+            ALOGE("%s: Camera %d: Cannot take picture without preview enabled",
+                    __FUNCTION__, mCameraId);
+            return INVALID_OPERATION;
+        case PREVIEW:
+        case RECORD:
+            // Good to go for takePicture
+            break;
+        case STILL_CAPTURE:
+        case VIDEO_SNAPSHOT:
+            ALOGE("%s: Camera %d: Already taking a picture",
+                    __FUNCTION__, mCameraId);
+            return INVALID_OPERATION;
+    }
+
+    LockedParameters::Key k(mParameters);
+
+    res = updateCaptureStream(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Can't set up still image stream: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    if (mCaptureRequest == NULL) {
+        res = updateCaptureRequest(k.mParameters);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Can't create still image capture request: "
+                    "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    camera_metadata_entry_t outputStreams;
+    if (mState == PREVIEW) {
+        uint8_t streamIds[2] = { mPreviewStreamId, mCaptureStreamId };
+        res = updateEntry(mCaptureRequest, ANDROID_REQUEST_OUTPUT_STREAMS,
+                &streamIds, 2);
+    } else if (mState == RECORD) {
+        uint8_t streamIds[3] = { mPreviewStreamId, mRecordingStreamId,
+                                 mCaptureStreamId };
+        res = updateEntry(mCaptureRequest, ANDROID_REQUEST_OUTPUT_STREAMS,
+                &streamIds, 3);
+    }
+
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set up still image capture request: "
+                "%s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+    res = sort_camera_metadata(mCaptureRequest);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to sort capture request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    camera_metadata_t *captureCopy = clone_camera_metadata(mCaptureRequest);
+    if (captureCopy == NULL) {
+        ALOGE("%s: Camera %d: Unable to copy capture request for HAL device",
+                __FUNCTION__, mCameraId);
+        return NO_MEMORY;
+    }
+
+    if (mState == PREVIEW) {
+        res = mDevice->setStreamingRequest(NULL);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to stop preview for still capture: "
+                    "%s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+    // TODO: Capture should be atomic with setStreamingRequest here
+    res = mDevice->capture(captureCopy);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to submit still image capture request: "
+                "%s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    switch (mState) {
+        case PREVIEW:
+            mState = STILL_CAPTURE;
+            break;
+        case RECORD:
+            mState = VIDEO_SNAPSHOT;
+            break;
+        default:
+            ALOGE("%s: Camera %d: Unknown state for still capture!",
+                    __FUNCTION__, mCameraId);
+            return INVALID_OPERATION;
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::setParameters(const String8& params) {
+    ATRACE_CALL();
+    ALOGV("%s: E", __FUNCTION__);
+    Mutex::Autolock icl(mICameraLock);
+    status_t res;
+    if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
+
+    LockedParameters::Key k(mParameters);
+
+    CameraParameters newParams(params);
+
+    // 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;
+
+    // PREVIEW_SIZE
+    int previewWidth, previewHeight;
+    newParams.getPreviewSize(&previewWidth, &previewHeight);
+
+    if (previewWidth != k.mParameters.previewWidth ||
+            previewHeight != k.mParameters.previewHeight) {
+        if (mState >= PREVIEW) {
+            ALOGE("%s: Preview size cannot be updated when preview "
+                    "is active! (Currently %d x %d, requested %d x %d",
+                    __FUNCTION__,
+                    k.mParameters.previewWidth, k.mParameters.previewHeight,
+                    previewWidth, previewHeight);
+            return BAD_VALUE;
+        }
+        camera_metadata_entry_t availablePreviewSizes =
+            staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES);
+        for (i = 0; i < availablePreviewSizes.count; i += 2 ) {
+            if (availablePreviewSizes.data.i32[i] == previewWidth &&
+                    availablePreviewSizes.data.i32[i+1] == previewHeight) break;
+        }
+        if (i == availablePreviewSizes.count) {
+            ALOGE("%s: Requested preview size %d x %d is not supported",
+                    __FUNCTION__, previewWidth, previewHeight);
+            return BAD_VALUE;
+        }
+    }
+
+    // PREVIEW_FPS_RANGE
+    int previewFpsRange[2];
+    int previewFps = 0;
+    bool fpsRangeChanged = false;
+    newParams.getPreviewFpsRange(&previewFpsRange[0], &previewFpsRange[1]);
+    if (previewFpsRange[0] != k.mParameters.previewFpsRange[0] ||
+            previewFpsRange[1] != k.mParameters.previewFpsRange[1]) {
+        fpsRangeChanged = true;
+        camera_metadata_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] ==
+                    previewFpsRange[0]) &&
+                (availablePreviewFpsRanges.data.i32[i+1] ==
+                    previewFpsRange[1]) ) {
+                break;
+            }
+        }
+        if (i == availablePreviewFpsRanges.count) {
+            ALOGE("%s: Requested preview FPS range %d - %d is not supported",
+                __FUNCTION__, previewFpsRange[0], previewFpsRange[1]);
+            return BAD_VALUE;
+        }
+        previewFps = previewFpsRange[0];
+    }
+
+    // PREVIEW_FORMAT
+    int previewFormat = formatStringToEnum(newParams.getPreviewFormat());
+    if (previewFormat != k.mParameters.previewFormat) {
+        if (mState >= PREVIEW) {
+            ALOGE("%s: Preview format cannot be updated when preview "
+                    "is active!", __FUNCTION__);
+            return BAD_VALUE;
+        }
+        camera_metadata_entry_t availableFormats =
+            staticInfo(ANDROID_SCALER_AVAILABLE_FORMATS);
+        for (i = 0; i < availableFormats.count; i++) {
+            if (availableFormats.data.i32[i] == previewFormat) break;
+        }
+        if (i == availableFormats.count) {
+            ALOGE("%s: Requested preview format %s (0x%x) is not supported",
+                    __FUNCTION__, newParams.getPreviewFormat(), 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) {
+        previewFps = newParams.getPreviewFrameRate();
+        if (previewFps != k.mParameters.previewFps) {
+            camera_metadata_entry_t availableFrameRates =
+                staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES);
+            for (i = 0; i < availableFrameRates.count; i+=2) {
+                if (availableFrameRates.data.i32[i] == previewFps) break;
+            }
+            if (i == availableFrameRates.count) {
+                ALOGE("%s: Requested preview frame rate %d is not supported",
+                        __FUNCTION__, previewFps);
+                return BAD_VALUE;
+            }
+            previewFpsRange[0] = availableFrameRates.data.i32[i];
+            previewFpsRange[1] = availableFrameRates.data.i32[i+1];
+        }
+    }
+
+    // PICTURE_SIZE
+    int pictureWidth, pictureHeight;
+    newParams.getPictureSize(&pictureWidth, &pictureHeight);
+    if (pictureWidth == k.mParameters.pictureWidth ||
+            pictureHeight == k.mParameters.pictureHeight) {
+        camera_metadata_entry_t availablePictureSizes =
+            staticInfo(ANDROID_SCALER_AVAILABLE_JPEG_SIZES);
+        for (i = 0; i < availablePictureSizes.count; i+=2) {
+            if (availablePictureSizes.data.i32[i] == pictureWidth &&
+                    availablePictureSizes.data.i32[i+1] == pictureHeight) break;
+        }
+        if (i == availablePictureSizes.count) {
+            ALOGE("%s: Requested picture size %d x %d is not supported",
+                    __FUNCTION__, pictureWidth, pictureHeight);
+            return BAD_VALUE;
+        }
+    }
+
+    // JPEG_THUMBNAIL_WIDTH/HEIGHT
+    int jpegThumbSize[2];
+    jpegThumbSize[0] =
+            newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH);
+    jpegThumbSize[1] =
+            newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT);
+    if (jpegThumbSize[0] != k.mParameters.jpegThumbSize[0] ||
+            jpegThumbSize[1] != k.mParameters.jpegThumbSize[1]) {
+        camera_metadata_entry_t availableJpegThumbSizes =
+            staticInfo(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES);
+        for (i = 0; i < availableJpegThumbSizes.count; i+=2) {
+            if (availableJpegThumbSizes.data.i32[i] == jpegThumbSize[0] &&
+                    availableJpegThumbSizes.data.i32[i+1] == jpegThumbSize[1]) {
+                break;
+            }
+        }
+        if (i == availableJpegThumbSizes.count) {
+            ALOGE("%s: Requested JPEG thumbnail size %d x %d is not supported",
+                    __FUNCTION__, jpegThumbSize[0], jpegThumbSize[1]);
+            return BAD_VALUE;
+        }
+    }
+
+    // JPEG_THUMBNAIL_QUALITY
+    int jpegThumbQuality =
+            newParams.getInt(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY);
+    if (jpegThumbQuality < 0 || jpegThumbQuality > 100) {
+        ALOGE("%s: Requested JPEG thumbnail quality %d is not supported",
+                __FUNCTION__, jpegThumbQuality);
+        return BAD_VALUE;
+    }
+
+    // JPEG_QUALITY
+    int jpegQuality =
+            newParams.getInt(CameraParameters::KEY_JPEG_QUALITY);
+    if (jpegQuality < 0 || jpegQuality > 100) {
+        ALOGE("%s: Requested JPEG quality %d is not supported",
+                __FUNCTION__, jpegQuality);
+        return BAD_VALUE;
+    }
+
+    // ROTATION
+    int jpegRotation =
+            newParams.getInt(CameraParameters::KEY_ROTATION);
+    if (jpegRotation != 0 &&
+            jpegRotation != 90 &&
+            jpegRotation != 180 &&
+            jpegRotation != 270) {
+        ALOGE("%s: Requested picture rotation angle %d is not supported",
+                __FUNCTION__, jpegRotation);
+        return BAD_VALUE;
+    }
+
+    // GPS
+    bool gpsEnabled = false;
+    double gpsCoordinates[3] = {0,0,0};
+    int64_t gpsTimestamp = 0;
+    String8 gpsProcessingMethod;
+    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;
+        gpsCoordinates[0] = strtod(gpsLatStr, &endPtr);
+        if (errno || endPtr == gpsLatStr) {
+            ALOGE("%s: Malformed GPS latitude: %s", __FUNCTION__, gpsLatStr);
+            return BAD_VALUE;
+        }
+        errno = 0;
+        gpsCoordinates[1] = strtod(gpsLongStr, &endPtr);
+        if (errno || endPtr == gpsLongStr) {
+            ALOGE("%s: Malformed GPS longitude: %s", __FUNCTION__, gpsLongStr);
+            return BAD_VALUE;
+        }
+        errno = 0;
+        gpsCoordinates[2] = strtod(gpsAltitudeStr, &endPtr);
+        if (errno || endPtr == gpsAltitudeStr) {
+            ALOGE("%s: Malformed GPS altitude: %s", __FUNCTION__,
+                    gpsAltitudeStr);
+            return BAD_VALUE;
+        }
+        errno = 0;
+        gpsTimestamp = strtoll(gpsTimeStr, &endPtr, 10);
+        if (errno || endPtr == gpsTimeStr) {
+            ALOGE("%s: Malformed GPS timestamp: %s", __FUNCTION__, gpsTimeStr);
+            return BAD_VALUE;
+        }
+        gpsProcessingMethod = gpsProcMethodStr;
+
+        gpsEnabled = true;
+    }
+
+    // WHITE_BALANCE
+    int wbMode = wbModeStringToEnum(
+        newParams.get(CameraParameters::KEY_WHITE_BALANCE) );
+    if (wbMode != k.mParameters.wbMode) {
+        camera_metadata_entry_t availableWbModes =
+            staticInfo(ANDROID_CONTROL_AWB_AVAILABLE_MODES);
+        for (i = 0; i < availableWbModes.count; i++) {
+            if (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;
+        }
+    }
+
+    // EFFECT
+    int effectMode = effectModeStringToEnum(
+        newParams.get(CameraParameters::KEY_EFFECT) );
+    if (effectMode != k.mParameters.effectMode) {
+        camera_metadata_entry_t availableEffectModes =
+            staticInfo(ANDROID_CONTROL_AVAILABLE_EFFECTS);
+        for (i = 0; i < availableEffectModes.count; i++) {
+            if (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
+    int antibandingMode = abModeStringToEnum(
+        newParams.get(CameraParameters::KEY_ANTIBANDING) );
+    if (antibandingMode != k.mParameters.antibandingMode) {
+        camera_metadata_entry_t availableAbModes =
+            staticInfo(ANDROID_CONTROL_AE_AVAILABLE_ANTIBANDING_MODES);
+        for (i = 0; i < availableAbModes.count; i++) {
+            if (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
+    int sceneMode = sceneModeStringToEnum(
+        newParams.get(CameraParameters::KEY_SCENE_MODE) );
+    if (sceneMode != k.mParameters.sceneMode) {
+        camera_metadata_entry_t availableSceneModes =
+            staticInfo(ANDROID_CONTROL_AVAILABLE_SCENE_MODES);
+        for (i = 0; i < availableSceneModes.count; i++) {
+            if (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;
+        }
+    }
+
+    // FLASH_MODE
+    Parameters::flashMode_t flashMode = flashModeStringToEnum(
+        newParams.get(CameraParameters::KEY_FLASH_MODE) );
+    if (flashMode != k.mParameters.flashMode) {
+        camera_metadata_entry_t flashAvailable =
+            staticInfo(ANDROID_FLASH_AVAILABLE, 1, 1);
+        if (!flashAvailable.data.u8[0] &&
+                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 (flashMode == Parameters::FLASH_MODE_RED_EYE) {
+            camera_metadata_entry_t availableAeModes =
+                staticInfo(ANDROID_CONTROL_AE_AVAILABLE_MODES);
+            for (i = 0; i < availableAeModes.count; i++) {
+                if (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 (flashMode == -1) {
+            ALOGE("%s: Requested flash mode \"%s\" is unknown",
+                    __FUNCTION__,
+                    newParams.get(CameraParameters::KEY_FLASH_MODE));
+            return BAD_VALUE;
+        }
+    }
+
+    // FOCUS_MODE
+    Parameters::focusMode_t focusMode = focusModeStringToEnum(
+        newParams.get(CameraParameters::KEY_FOCUS_MODE));
+    if (focusMode != k.mParameters.focusMode) {
+        if (focusMode != Parameters::FOCUS_MODE_FIXED) {
+            camera_metadata_entry_t minFocusDistance =
+                staticInfo(ANDROID_LENS_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 (focusMode != Parameters::FOCUS_MODE_INFINITY) {
+                camera_metadata_entry_t availableFocusModes =
+                    staticInfo(ANDROID_CONTROL_AF_AVAILABLE_MODES);
+                for (i = 0; i < availableFocusModes.count; i++) {
+                    if (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;
+                }
+            }
+        }
+    }
+
+    // FOCUS_AREAS
+    Vector<Parameters::Area> focusingAreas;
+    res = parseAreas(newParams.get(CameraParameters::KEY_FOCUS_AREAS),
+            &focusingAreas);
+    size_t max3aRegions =
+        (size_t)staticInfo(ANDROID_CONTROL_MAX_REGIONS, 1, 1).data.i32[0];
+    if (res == OK) res = validateAreas(focusingAreas, max3aRegions);
+    if (res != OK) {
+        ALOGE("%s: Requested focus areas are malformed: %s",
+                __FUNCTION__, newParams.get(CameraParameters::KEY_FOCUS_AREAS));
+        return BAD_VALUE;
+    }
+
+    // EXPOSURE_COMPENSATION
+    int exposureCompensation =
+        newParams.getInt(CameraParameters::KEY_EXPOSURE_COMPENSATION);
+    camera_metadata_entry_t exposureCompensationRange =
+        staticInfo(ANDROID_CONTROL_AE_EXP_COMPENSATION_RANGE);
+    if (exposureCompensation < exposureCompensationRange.data.i32[0] ||
+            exposureCompensation > exposureCompensationRange.data.i32[1]) {
+        ALOGE("%s: Requested exposure compensation index is out of bounds: %d",
+                __FUNCTION__, exposureCompensation);
+        return BAD_VALUE;
+    }
+
+    // AUTO_EXPOSURE_LOCK (always supported)
+    bool autoExposureLock = boolFromString(
+        newParams.get(CameraParameters::KEY_AUTO_EXPOSURE_LOCK));
+
+    // AUTO_WHITEBALANCE_LOCK (always supported)
+    bool autoWhiteBalanceLock = boolFromString(
+        newParams.get(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK));
+
+    // METERING_AREAS
+    Vector<Parameters::Area> meteringAreas;
+    res = parseAreas(newParams.get(CameraParameters::KEY_METERING_AREAS),
+            &meteringAreas);
+    if (res == OK) res = validateAreas(focusingAreas, max3aRegions);
+    if (res != OK) {
+        ALOGE("%s: Requested metering areas are malformed: %s",
+                __FUNCTION__,
+                newParams.get(CameraParameters::KEY_METERING_AREAS));
+        return BAD_VALUE;
+    }
+
+    // ZOOM
+    int zoom = newParams.getInt(CameraParameters::KEY_ZOOM);
+    if (zoom < 0 || zoom > (int)NUM_ZOOM_STEPS) {
+        ALOGE("%s: Requested zoom level %d is not supported",
+                __FUNCTION__, zoom);
+        return BAD_VALUE;
+    }
+
+    // VIDEO_SIZE
+    int videoWidth, videoHeight;
+    newParams.getVideoSize(&videoWidth, &videoHeight);
+    if (videoWidth != k.mParameters.videoWidth ||
+            videoHeight != k.mParameters.videoHeight) {
+        if (mState == RECORD) {
+            ALOGE("%s: Video size cannot be updated when recording is active!",
+                    __FUNCTION__);
+            return BAD_VALUE;
+        }
+        camera_metadata_entry_t availableVideoSizes =
+            staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES);
+        for (i = 0; i < availableVideoSizes.count; i += 2 ) {
+            if (availableVideoSizes.data.i32[i] == videoWidth &&
+                    availableVideoSizes.data.i32[i+1] == videoHeight)  break;
+        }
+        if (i == availableVideoSizes.count) {
+            ALOGE("%s: Requested video size %d x %d is not supported",
+                    __FUNCTION__, videoWidth, videoHeight);
+            return BAD_VALUE;
+        }
+    }
+
+    // RECORDING_HINT (always supported)
+    bool recordingHint = boolFromString(
+        newParams.get(CameraParameters::KEY_RECORDING_HINT) );
+
+    // VIDEO_STABILIZATION
+    bool videoStabilization = boolFromString(
+        newParams.get(CameraParameters::KEY_VIDEO_STABILIZATION) );
+    camera_metadata_entry_t availableVideoStabilizationModes =
+        staticInfo(ANDROID_CONTROL_AVAILABLE_VIDEO_STABILIZATION_MODES);
+    if (videoStabilization && availableVideoStabilizationModes.count == 1) {
+        ALOGE("%s: Video stabilization not supported", __FUNCTION__);
+    }
+
+    /** Update internal parameters */
+
+    k.mParameters.previewWidth = previewWidth;
+    k.mParameters.previewHeight = previewHeight;
+    k.mParameters.previewFpsRange[0] = previewFpsRange[0];
+    k.mParameters.previewFpsRange[1] = previewFpsRange[1];
+    k.mParameters.previewFps = previewFps;
+    k.mParameters.previewFormat = previewFormat;
+
+    k.mParameters.pictureWidth = pictureWidth;
+    k.mParameters.pictureHeight = pictureHeight;
+
+    k.mParameters.jpegThumbSize[0] = jpegThumbSize[0];
+    k.mParameters.jpegThumbSize[1] = jpegThumbSize[1];
+    k.mParameters.jpegQuality = jpegQuality;
+    k.mParameters.jpegThumbQuality = jpegThumbQuality;
+
+    k.mParameters.gpsEnabled = gpsEnabled;
+    k.mParameters.gpsCoordinates[0] = gpsCoordinates[0];
+    k.mParameters.gpsCoordinates[1] = gpsCoordinates[1];
+    k.mParameters.gpsCoordinates[2] = gpsCoordinates[2];
+    k.mParameters.gpsTimestamp = gpsTimestamp;
+    k.mParameters.gpsProcessingMethod = gpsProcessingMethod;
+
+    k.mParameters.wbMode = wbMode;
+    k.mParameters.effectMode = effectMode;
+    k.mParameters.antibandingMode = antibandingMode;
+    k.mParameters.sceneMode = sceneMode;
+
+    k.mParameters.flashMode = flashMode;
+    if (focusMode != k.mParameters.focusMode) {
+        k.mParameters.currentAfTriggerId = -1;
+    }
+    k.mParameters.focusMode = focusMode;
+
+    k.mParameters.focusingAreas = focusingAreas;
+    k.mParameters.exposureCompensation = exposureCompensation;
+    k.mParameters.autoExposureLock = autoExposureLock;
+    k.mParameters.autoWhiteBalanceLock = autoWhiteBalanceLock;
+    k.mParameters.meteringAreas = meteringAreas;
+    k.mParameters.zoom = zoom;
+
+    k.mParameters.videoWidth = videoWidth;
+    k.mParameters.videoHeight = videoHeight;
+
+    k.mParameters.recordingHint = recordingHint;
+    k.mParameters.videoStabilization = videoStabilization;
+
+    res = updatePreviewRequest(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update preview request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+    res = updateCaptureRequest(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update capture request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    res = updateRecordingRequest(k.mParameters);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update recording request: %s (%d)",
+                __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    if (mState == PREVIEW) {
+        res = mDevice->setStreamingRequest(mPreviewRequest);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error streaming new preview request: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    } else if (mState == RECORD || mState == VIDEO_SNAPSHOT) {
+        res = mDevice->setStreamingRequest(mRecordingRequest);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error streaming new record request: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    k.mParameters.paramsFlattened = params;
+
+    return OK;
+}
+
+String8 Camera2Client::getParameters() const {
+    ATRACE_CALL();
+    Mutex::Autolock icl(mICameraLock);
+    if ( checkPid(__FUNCTION__) != OK) return String8();
+
+    LockedParameters::ReadKey k(mParameters);
+
+    // TODO: Deal with focus distances
+    return k.mParameters.paramsFlattened;
+}
+
+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:
+            return commandStopFaceDetectionL();
+        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) {
+    LockedParameters::Key k(mParameters);
+    int transform = 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;
+    }
+    if (transform != k.mParameters.previewTransform &&
+            mPreviewStreamId != NO_STREAM) {
+        mDevice->setStreamTransform(mPreviewStreamId, transform);
+    }
+    k.mParameters.previewTransform = transform;
+    return OK;
+}
+
+status_t Camera2Client::commandEnableShutterSoundL(bool enable) {
+    LockedParameters::Key k(mParameters);
+    if (enable) {
+        k.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;
+        }
+    }
+
+    k.mParameters.playShutterSound = false;
+    return OK;
+}
+
+status_t Camera2Client::commandPlayRecordingSoundL() {
+    mCameraService->playSound(CameraService::SOUND_RECORDING);
+    return OK;
+}
+
+status_t Camera2Client::commandStartFaceDetectionL(int type) {
+    ALOGE("%s: Unimplemented!", __FUNCTION__);
+    return OK;
+}
+
+status_t Camera2Client::commandStopFaceDetectionL() {
+    ALOGE("%s: Unimplemented!", __FUNCTION__);
+    return OK;
+}
+
+status_t Camera2Client::commandEnableFocusMoveMsgL(bool enable) {
+    LockedParameters::Key k(mParameters);
+    k.mParameters.enableFocusMoveMessages = enable;
+
+    return OK;
+}
+
+status_t Camera2Client::commandPingL() {
+    // Always ping back if access is proper and device is alive
+    if (mState != 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;
+    }
+
+    // 32 is the current upper limit on the video buffer count for BufferQueue
+    if (count > 32) {
+        ALOGE("%s: Camera %d: Error setting %d as video buffer count value",
+                __FUNCTION__, mCameraId, count);
+        return BAD_VALUE;
+    }
+
+    // Need to reallocate memory for heap
+    if (mRecordingHeapCount != count) {
+        if  (mRecordingHeap != 0) {
+            mRecordingHeap.clear();
+            mRecordingHeap = NULL;
+        }
+        mRecordingHeapCount = count;
+    }
+
+    return OK;
+}
+
+/** 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;
+    {
+        LockedParameters::Key k(mParameters);
+        switch (k.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 != k.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;
+                        k.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 != k.mParameters.currentAfTriggerId) break;
+                        sendCompletedMessage = true;
+                        afInMotion = false;
+                        if (k.mParameters.enableFocusMoveMessages &&
+                                k.mParameters.afInMotion) {
+                            sendMovingMessage = true;
+                        }
+                        k.mParameters.currentAfTriggerId = -1;
+                        break;
+                    case ANDROID_CONTROL_AF_STATE_INACTIVE:
+                        // Cancel was called, or we switched state; care if
+                        // currently moving
+                        afInMotion = false;
+                        if (k.mParameters.enableFocusMoveMessages &&
+                                k.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 (k.mParameters.enableFocusMoveMessages) {
+                            sendMovingMessage = true;
+                        }
+                        break;
+                }
+                k.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, k.mParameters.focusMode);
+                }
+        }
+    }
+    if (sendMovingMessage) {
+        mCameraClient->notifyCallback(CAMERA_MSG_FOCUS_MOVE,
+                afInMotion ? 1 : 0, 0);
+    }
+    if (sendCompletedMessage) {
+        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);
+}
+
+void Camera2Client::notifyAutoWhitebalance(uint8_t newState, int triggerId) {
+    ALOGV("%s: Auto-whitebalance state now %d, last trigger %d",
+            __FUNCTION__, newState, triggerId);
+}
+
+void Camera2Client::onCaptureAvailable() {
+    ATRACE_CALL();
+    status_t res;
+    sp<ICameraClient> currentClient;
+    ALOGV("%s: Camera %d: Still capture available", __FUNCTION__, mCameraId);
+
+    CpuConsumer::LockedBuffer imgBuffer;
+    {
+        Mutex::Autolock icl(mICameraLock);
+
+        // TODO: Signal errors here upstream
+        if (mState != STILL_CAPTURE && mState != VIDEO_SNAPSHOT) {
+            ALOGE("%s: Camera %d: Still image produced unexpectedly!",
+                    __FUNCTION__, mCameraId);
+            return;
+        }
+
+        res = mCaptureConsumer->lockNextBuffer(&imgBuffer);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error receiving still image buffer: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return;
+        }
+
+        if (imgBuffer.format != HAL_PIXEL_FORMAT_BLOB) {
+            ALOGE("%s: Camera %d: Unexpected format for still image: "
+                    "%x, expected %x", __FUNCTION__, mCameraId,
+                    imgBuffer.format,
+                    HAL_PIXEL_FORMAT_BLOB);
+            mCaptureConsumer->unlockBuffer(imgBuffer);
+            return;
+        }
+
+        // TODO: Optimize this to avoid memcopy
+        void* captureMemory = mCaptureHeap->mHeap->getBase();
+        size_t size = mCaptureHeap->mHeap->getSize();
+        memcpy(captureMemory, imgBuffer.data, size);
+
+        mCaptureConsumer->unlockBuffer(imgBuffer);
+
+        currentClient = mCameraClient;
+        switch (mState) {
+            case STILL_CAPTURE:
+                mState = STOPPED;
+                break;
+            case VIDEO_SNAPSHOT:
+                mState = RECORD;
+                break;
+            default:
+                ALOGE("%s: Camera %d: Unexpected state %d", __FUNCTION__,
+                        mCameraId, mState);
+                break;
+        }
+    }
+    // Call outside mICameraLock to allow re-entrancy from notification
+    if (currentClient != 0) {
+        currentClient->dataCallback(CAMERA_MSG_COMPRESSED_IMAGE,
+                mCaptureHeap->mBuffers[0], NULL);
+    }
+}
+
+void Camera2Client::onRecordingFrameAvailable() {
+    ATRACE_CALL();
+    status_t res;
+    sp<ICameraClient> currentClient;
+    size_t heapIdx = 0;
+    nsecs_t timestamp;
+    {
+        Mutex::Autolock icl(mICameraLock);
+        // TODO: Signal errors here upstream
+        bool discardData = false;
+        if (mState != RECORD && mState != VIDEO_SNAPSHOT) {
+            ALOGV("%s: Camera %d: Discarding recording image buffers received after "
+                    "recording done",
+                    __FUNCTION__, mCameraId);
+            discardData = true;
+        }
+
+        buffer_handle_t imgBuffer;
+        res = mRecordingConsumer->getNextBuffer(&imgBuffer, &timestamp);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error receiving recording buffer: %s (%d)",
+                    __FUNCTION__, mCameraId, strerror(-res), res);
+            return;
+        }
+
+        if (discardData) {
+            mRecordingConsumer->freeBuffer(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__, mCameraId,
+                    mRecordingHeapCount, bufferSize);
+            if (mRecordingHeap != 0) {
+                ALOGV("%s: Camera %d: Previous heap has size %d "
+                        "(new will be %d) bytes", __FUNCTION__, mCameraId,
+                        mRecordingHeap->mHeap->getSize(),
+                        bufferSize * mRecordingHeapCount);
+            }
+            // Need to allocate memory for heap
+            mRecordingHeap.clear();
+
+            mRecordingHeap = new Camera2Heap(bufferSize, mRecordingHeapCount,
+                    "Camera2Client::RecordingHeap");
+            if (mRecordingHeap->mHeap->getSize() == 0) {
+                ALOGE("%s: Camera %d: Unable to allocate memory for recording",
+                        __FUNCTION__, mCameraId);
+                mRecordingConsumer->freeBuffer(imgBuffer);
+                return;
+            }
+            mRecordingHeapHead = 0;
+            mRecordingHeapFree = mRecordingHeapCount;
+        }
+
+        if ( mRecordingHeapFree == 0) {
+            ALOGE("%s: Camera %d: No free recording buffers, dropping frame",
+                    __FUNCTION__, mCameraId);
+            mRecordingConsumer->freeBuffer(imgBuffer);
+            return;
+        }
+        heapIdx = mRecordingHeapHead;
+        mRecordingHeapHead = (mRecordingHeapHead + 1) % mRecordingHeapCount;
+        mRecordingHeapFree--;
+
+        ALOGV("%s: Camera %d: Timestamp %lld",
+                __FUNCTION__, mCameraId, 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;
+        memcpy(data, &type, 4);
+        memcpy(data + 4, &imgBuffer, sizeof(buffer_handle_t));
+        ALOGV("%s: Camera %d: Sending out buffer_handle_t %p",
+                __FUNCTION__, mCameraId, imgBuffer);
+        currentClient = mCameraClient;
+    }
+    // Call outside mICameraLock to allow re-entrancy from notification
+    if (currentClient != 0) {
+        currentClient->dataCallbackTimestamp(timestamp,
+                CAMERA_MSG_VIDEO_FRAME,
+                mRecordingHeap->mBuffers[heapIdx]);
+    }
+}
+
+camera_metadata_entry_t Camera2Client::staticInfo(uint32_t tag,
+        size_t minCount, size_t maxCount) {
+    status_t res;
+    camera_metadata_entry_t entry;
+    res = find_camera_metadata_entry(mDevice->info(),
+            tag,
+            &entry);
+    if (CC_UNLIKELY( res != OK )) {
+        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): %s (%d)",
+                tagSection, tagName, tag, strerror(-res), res);
+        entry.count = 0;
+        entry.data.u8 = NULL;
+    } 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);
+        entry.count = 0;
+        entry.data.u8 = NULL;
+    }
+
+    return entry;
+}
+
+/** Utility methods */
+
+
+status_t Camera2Client::buildDefaultParameters() {
+    ATRACE_CALL();
+    LockedParameters::Key k(mParameters);
+
+    status_t res;
+    CameraParameters params;
+
+    camera_metadata_entry_t availableProcessedSizes =
+        staticInfo(ANDROID_SCALER_AVAILABLE_PROCESSED_SIZES, 2);
+    if (!availableProcessedSizes.count) return NO_INIT;
+
+    // TODO: Pick more intelligently
+    k.mParameters.previewWidth = availableProcessedSizes.data.i32[0];
+    k.mParameters.previewHeight = availableProcessedSizes.data.i32[1];
+    k.mParameters.videoWidth = k.mParameters.previewWidth;
+    k.mParameters.videoHeight = k.mParameters.previewHeight;
+
+    params.setPreviewSize(k.mParameters.previewWidth, k.mParameters.previewHeight);
+    params.setVideoSize(k.mParameters.videoWidth, k.mParameters.videoHeight);
+    params.set(CameraParameters::KEY_PREFERRED_PREVIEW_SIZE_FOR_VIDEO,
+            String8::format("%dx%d",
+                    k.mParameters.previewWidth, k.mParameters.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_entry_t availableFpsRanges =
+        staticInfo(ANDROID_CONTROL_AE_AVAILABLE_TARGET_FPS_RANGES, 2);
+    if (!availableFpsRanges.count) return NO_INIT;
+
+    k.mParameters.previewFpsRange[0] = availableFpsRanges.data.i32[0];
+    k.mParameters.previewFpsRange[1] = availableFpsRanges.data.i32[1];
+
+    params.set(CameraParameters::KEY_PREVIEW_FPS_RANGE,
+            String8::format("%d,%d",
+                    k.mParameters.previewFpsRange[0],
+                    k.mParameters.previewFpsRange[1]));
+
+    {
+        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],
+                    availableFpsRanges.data.i32[i+1]);
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FPS_RANGE,
+                supportedPreviewFpsRange);
+    }
+
+    k.mParameters.previewFormat = HAL_PIXEL_FORMAT_YCrCb_420_SP;
+    params.set(CameraParameters::KEY_PREVIEW_FORMAT,
+            formatEnumToString(k.mParameters.previewFormat)); // NV21
+
+    k.mParameters.previewTransform = degToTransform(0,
+            mCameraFacing == CAMERA_FACING_FRONT);
+
+    camera_metadata_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__, mCameraId, 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
+
+    params.set(CameraParameters::KEY_PREVIEW_FRAME_RATE,
+            k.mParameters.previewFpsRange[0]);
+
+    {
+        String8 supportedPreviewFrameRates;
+        for (size_t i=0; i < availableFpsRanges.count; i += 2) {
+            if (i != 0) supportedPreviewFrameRates += ",";
+            supportedPreviewFrameRates += String8::format("%d",
+                    availableFpsRanges.data.i32[i]);
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_FRAME_RATES,
+                supportedPreviewFrameRates);
+    }
+
+    camera_metadata_entry_t availableJpegSizes =
+        staticInfo(ANDROID_SCALER_AVAILABLE_JPEG_SIZES, 2);
+    if (!availableJpegSizes.count) return NO_INIT;
+
+    // TODO: Pick maximum
+    k.mParameters.pictureWidth = availableJpegSizes.data.i32[0];
+    k.mParameters.pictureHeight = availableJpegSizes.data.i32[1];
+
+    params.setPictureSize(k.mParameters.pictureWidth,
+            k.mParameters.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_entry_t availableJpegThumbnailSizes =
+        staticInfo(ANDROID_JPEG_AVAILABLE_THUMBNAIL_SIZES, 2);
+    if (!availableJpegThumbnailSizes.count) return NO_INIT;
+
+    // TODO: Pick default thumbnail size sensibly
+    k.mParameters.jpegThumbSize[0] = availableJpegThumbnailSizes.data.i32[0];
+    k.mParameters.jpegThumbSize[1] = availableJpegThumbnailSizes.data.i32[1];
+
+    params.set(CameraParameters::KEY_JPEG_THUMBNAIL_WIDTH,
+            k.mParameters.jpegThumbSize[0]);
+    params.set(CameraParameters::KEY_JPEG_THUMBNAIL_HEIGHT,
+            k.mParameters.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);
+    }
+
+    k.mParameters.jpegThumbQuality = 90;
+    params.set(CameraParameters::KEY_JPEG_THUMBNAIL_QUALITY,
+            k.mParameters.jpegThumbQuality);
+    k.mParameters.jpegQuality = 90;
+    params.set(CameraParameters::KEY_JPEG_QUALITY,
+            k.mParameters.jpegQuality);
+    k.mParameters.jpegRotation = 0;
+    params.set(CameraParameters::KEY_ROTATION,
+            k.mParameters.jpegRotation);
+
+    k.mParameters.gpsEnabled = false;
+    k.mParameters.gpsProcessingMethod = "unknown";
+    // GPS fields in CameraParameters are not set by implementation
+
+    k.mParameters.wbMode = ANDROID_CONTROL_AWB_AUTO;
+    params.set(CameraParameters::KEY_WHITE_BALANCE,
+            CameraParameters::WHITE_BALANCE_AUTO);
+
+    camera_metadata_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_AUTO:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_AUTO;
+                break;
+            case ANDROID_CONTROL_AWB_INCANDESCENT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_INCANDESCENT;
+                break;
+            case ANDROID_CONTROL_AWB_FLUORESCENT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_FLUORESCENT;
+                break;
+            case ANDROID_CONTROL_AWB_WARM_FLUORESCENT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT;
+                break;
+            case ANDROID_CONTROL_AWB_DAYLIGHT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_DAYLIGHT;
+                break;
+            case ANDROID_CONTROL_AWB_CLOUDY_DAYLIGHT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT;
+                break;
+            case ANDROID_CONTROL_AWB_TWILIGHT:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_TWILIGHT;
+                break;
+            case ANDROID_CONTROL_AWB_SHADE:
+                supportedWhiteBalance +=
+                    CameraParameters::WHITE_BALANCE_SHADE;
+                break;
+            // Skipping values not mappable to v1 API
+            case ANDROID_CONTROL_AWB_OFF:
+                addComma = false;
+                break;
+            default:
+                ALOGW("%s: Camera %d: Unknown white balance value: %d",
+                        __FUNCTION__, mCameraId,
+                        availableWhiteBalanceModes.data.u8[i]);
+                addComma = false;
+                break;
+            }
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_WHITE_BALANCE,
+                supportedWhiteBalance);
+    }
+
+    k.mParameters.effectMode = ANDROID_CONTROL_EFFECT_OFF;
+    params.set(CameraParameters::KEY_EFFECT,
+            CameraParameters::EFFECT_NONE);
+
+    camera_metadata_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_OFF:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_NONE;
+                    break;
+                case ANDROID_CONTROL_EFFECT_MONO:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_MONO;
+                    break;
+                case ANDROID_CONTROL_EFFECT_NEGATIVE:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_NEGATIVE;
+                    break;
+                case ANDROID_CONTROL_EFFECT_SOLARIZE:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_SOLARIZE;
+                    break;
+                case ANDROID_CONTROL_EFFECT_SEPIA:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_SEPIA;
+                    break;
+                case ANDROID_CONTROL_EFFECT_POSTERIZE:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_POSTERIZE;
+                    break;
+                case ANDROID_CONTROL_EFFECT_WHITEBOARD:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_WHITEBOARD;
+                    break;
+                case ANDROID_CONTROL_EFFECT_BLACKBOARD:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_BLACKBOARD;
+                    break;
+                case ANDROID_CONTROL_EFFECT_AQUA:
+                    supportedEffects +=
+                        CameraParameters::EFFECT_AQUA;
+                    break;
+                default:
+                    ALOGW("%s: Camera %d: Unknown effect value: %d",
+                        __FUNCTION__, mCameraId, availableEffects.data.u8[i]);
+                    addComma = false;
+                    break;
+            }
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_EFFECTS, supportedEffects);
+    }
+
+    k.mParameters.antibandingMode = ANDROID_CONTROL_AE_ANTIBANDING_AUTO;
+    params.set(CameraParameters::KEY_ANTIBANDING,
+            CameraParameters::ANTIBANDING_AUTO);
+
+    camera_metadata_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_OFF:
+                    supportedAntibanding +=
+                        CameraParameters::ANTIBANDING_OFF;
+                    break;
+                case ANDROID_CONTROL_AE_ANTIBANDING_50HZ:
+                    supportedAntibanding +=
+                        CameraParameters::ANTIBANDING_50HZ;
+                    break;
+                case ANDROID_CONTROL_AE_ANTIBANDING_60HZ:
+                    supportedAntibanding +=
+                        CameraParameters::ANTIBANDING_60HZ;
+                    break;
+                case ANDROID_CONTROL_AE_ANTIBANDING_AUTO:
+                    supportedAntibanding +=
+                        CameraParameters::ANTIBANDING_AUTO;
+                    break;
+                default:
+                    ALOGW("%s: Camera %d: Unknown antibanding value: %d",
+                        __FUNCTION__, mCameraId,
+                            availableAntibandingModes.data.u8[i]);
+                    addComma = false;
+                    break;
+            }
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_ANTIBANDING,
+                supportedAntibanding);
+    }
+
+    k.mParameters.sceneMode = ANDROID_CONTROL_OFF;
+    params.set(CameraParameters::KEY_SCENE_MODE,
+            CameraParameters::SCENE_MODE_AUTO);
+
+    camera_metadata_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__, mCameraId,
+                            availableSceneModes.data.u8[i]);
+                    addComma = false;
+                    break;
+            }
+        }
+        if (!noSceneModes) {
+            params.set(CameraParameters::KEY_SUPPORTED_SCENE_MODES,
+                    supportedSceneModes);
+        }
+    }
+
+    camera_metadata_entry_t flashAvailable =
+        staticInfo(ANDROID_FLASH_AVAILABLE, 1, 1);
+    if (!flashAvailable.count) return NO_INIT;
+
+    camera_metadata_entry_t availableAeModes =
+        staticInfo(ANDROID_CONTROL_AE_AVAILABLE_MODES);
+    if (!availableAeModes.count) return NO_INIT;
+
+    if (flashAvailable.data.u8[0]) {
+        k.mParameters.flashMode = Parameters::FLASH_MODE_AUTO;
+        params.set(CameraParameters::KEY_FLASH_MODE,
+                CameraParameters::FLASH_MODE_AUTO);
+
+        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_ON_AUTO_FLASH_REDEYE) {
+                supportedFlashModes = supportedFlashModes + "," +
+                    CameraParameters::FLASH_MODE_RED_EYE;
+                break;
+            }
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_FLASH_MODES,
+                supportedFlashModes);
+    } else {
+        k.mParameters.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_entry_t minFocusDistance =
+        staticInfo(ANDROID_LENS_MINIMUM_FOCUS_DISTANCE, 1, 1);
+    if (!minFocusDistance.count) return NO_INIT;
+
+    camera_metadata_entry_t availableAfModes =
+        staticInfo(ANDROID_CONTROL_AF_AVAILABLE_MODES);
+    if (!availableAfModes.count) return NO_INIT;
+
+    if (minFocusDistance.data.f[0] == 0) {
+        // Fixed-focus lens
+        k.mParameters.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 {
+        k.mParameters.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_AUTO:
+                    supportedFocusModes +=
+                        CameraParameters::FOCUS_MODE_AUTO;
+                    break;
+                case ANDROID_CONTROL_AF_MACRO:
+                    supportedFocusModes +=
+                        CameraParameters::FOCUS_MODE_MACRO;
+                    break;
+                case ANDROID_CONTROL_AF_CONTINUOUS_VIDEO:
+                    supportedFocusModes +=
+                        CameraParameters::FOCUS_MODE_CONTINUOUS_VIDEO;
+                    break;
+                case ANDROID_CONTROL_AF_CONTINUOUS_PICTURE:
+                    supportedFocusModes +=
+                        CameraParameters::FOCUS_MODE_CONTINUOUS_PICTURE;
+                    break;
+                case ANDROID_CONTROL_AF_EDOF:
+                    supportedFocusModes +=
+                        CameraParameters::FOCUS_MODE_EDOF;
+                    break;
+                // Not supported in old API
+                case ANDROID_CONTROL_AF_OFF:
+                    addComma = false;
+                    break;
+                default:
+                    ALOGW("%s: Camera %d: Unknown AF mode value: %d",
+                        __FUNCTION__, mCameraId, availableAfModes.data.u8[i]);
+                    addComma = false;
+                    break;
+            }
+        }
+        params.set(CameraParameters::KEY_SUPPORTED_FOCUS_MODES,
+                supportedFocusModes);
+    }
+
+    camera_metadata_entry_t max3aRegions =
+        staticInfo(ANDROID_CONTROL_MAX_REGIONS, 1, 1);
+    if (!max3aRegions.count) return NO_INIT;
+
+    params.set(CameraParameters::KEY_MAX_NUM_FOCUS_AREAS,
+            max3aRegions.data.i32[0]);
+    params.set(CameraParameters::KEY_FOCUS_AREAS,
+            "(0,0,0,0,0)");
+    k.mParameters.focusingAreas.clear();
+    k.mParameters.focusingAreas.add(Parameters::Area(0,0,0,0,0));
+
+    camera_metadata_entry_t availableFocalLengths =
+        staticInfo(ANDROID_LENS_AVAILABLE_FOCAL_LENGTHS);
+    if (!availableFocalLengths.count) return NO_INIT;
+
+    float minFocalLength = availableFocalLengths.data.f[0];
+    params.setFloat(CameraParameters::KEY_FOCAL_LENGTH, minFocalLength);
+
+    camera_metadata_entry_t sensorSize =
+        staticInfo(ANDROID_SENSOR_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);
+
+    k.mParameters.exposureCompensation = 0;
+    params.set(CameraParameters::KEY_EXPOSURE_COMPENSATION,
+                k.mParameters.exposureCompensation);
+
+    camera_metadata_entry_t exposureCompensationRange =
+        staticInfo(ANDROID_CONTROL_AE_EXP_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_entry_t exposureCompensationStep =
+        staticInfo(ANDROID_CONTROL_AE_EXP_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);
+
+    k.mParameters.autoExposureLock = false;
+    params.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK,
+            CameraParameters::FALSE);
+    params.set(CameraParameters::KEY_AUTO_EXPOSURE_LOCK_SUPPORTED,
+            CameraParameters::TRUE);
+
+    k.mParameters.autoWhiteBalanceLock = false;
+    params.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK,
+            CameraParameters::FALSE);
+    params.set(CameraParameters::KEY_AUTO_WHITEBALANCE_LOCK_SUPPORTED,
+            CameraParameters::TRUE);
+
+    k.mParameters.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)");
+
+    k.mParameters.zoom = 0;
+    params.set(CameraParameters::KEY_ZOOM, k.mParameters.zoom);
+    params.set(CameraParameters::KEY_MAX_ZOOM, NUM_ZOOM_STEPS - 1);
+
+    camera_metadata_entry_t maxDigitalZoom =
+        staticInfo(ANDROID_SCALER_AVAILABLE_MAX_ZOOM, 1, 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::TRUE);
+
+    params.set(CameraParameters::KEY_FOCUS_DISTANCES,
+            "Infinity,Infinity,Infinity");
+
+    camera_metadata_entry_t maxFacesDetected =
+        staticInfo(ANDROID_STATS_MAX_FACE_COUNT, 1, 1);
+    params.set(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_HW,
+            maxFacesDetected.data.i32[0]);
+    params.set(CameraParameters::KEY_MAX_NUM_DETECTED_FACES_SW,
+            0);
+
+    params.set(CameraParameters::KEY_VIDEO_FRAME_FORMAT,
+            CameraParameters::PIXEL_FORMAT_ANDROID_OPAQUE);
+
+    params.set(CameraParameters::KEY_RECORDING_HINT,
+            CameraParameters::FALSE);
+
+    params.set(CameraParameters::KEY_VIDEO_SNAPSHOT_SUPPORTED,
+            CameraParameters::TRUE);
+
+    params.set(CameraParameters::KEY_VIDEO_STABILIZATION,
+            CameraParameters::FALSE);
+
+    camera_metadata_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
+
+    k.mParameters.storeMetadataInBuffers = true;
+    k.mParameters.playShutterSound = true;
+    k.mParameters.afTriggerCounter = 0;
+    k.mParameters.currentAfTriggerId = -1;
+
+    k.mParameters.paramsFlattened = params.flatten();
+
+    return OK;
+}
+
+status_t Camera2Client::updatePreviewStream(const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+
+    if (mPreviewStreamId != NO_STREAM) {
+        // Check if stream parameters have to change
+        uint32_t currentWidth, currentHeight;
+        res = mDevice->getStreamInfo(mPreviewStreamId,
+                &currentWidth, &currentHeight, 0);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error querying preview stream info: "
+                    "%s (%d)", __FUNCTION__, mCameraId, 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__, mCameraId, currentWidth, currentHeight,
+                    params.previewWidth, params.previewHeight);
+            res = mDevice->waitUntilDrained();
+            if (res != OK) {
+                ALOGE("%s: Camera %d: Error waiting for preview to drain: "
+                        "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+                return res;
+            }
+            res = mDevice->deleteStream(mPreviewStreamId);
+            if (res != OK) {
+                ALOGE("%s: Camera %d: Unable to delete old output stream "
+                        "for preview: %s (%d)", __FUNCTION__, mCameraId,
+                        strerror(-res), res);
+                return res;
+            }
+            mPreviewStreamId = NO_STREAM;
+        }
+    }
+
+    if (mPreviewStreamId == NO_STREAM) {
+        res = mDevice->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__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    res = mDevice->setStreamTransform(mPreviewStreamId,
+            params.previewTransform);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to set preview stream transform: "
+                "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+        return res;
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::updatePreviewRequest(const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+    if (mPreviewRequest == NULL) {
+        res = mDevice->createDefaultRequest(CAMERA2_TEMPLATE_PREVIEW,
+                &mPreviewRequest);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to create default preview request: "
+                    "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    res = updateRequestCommon(mPreviewRequest, params);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update common entries of preview "
+                "request: %s (%d)", __FUNCTION__, mCameraId,
+                strerror(-res), res);
+        return res;
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::updateCaptureStream(const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+    // Find out buffer size for JPEG
+    camera_metadata_entry_t maxJpegSize =
+            staticInfo(ANDROID_JPEG_MAX_SIZE);
+    if (maxJpegSize.count == 0) {
+        ALOGE("%s: Camera %d: Can't find ANDROID_JPEG_MAX_SIZE!",
+                __FUNCTION__, mCameraId);
+        return INVALID_OPERATION;
+    }
+
+    if (mCaptureConsumer == 0) {
+        // Create CPU buffer queue endpoint
+        mCaptureConsumer = new CpuConsumer(1);
+        mCaptureConsumer->setFrameAvailableListener(new CaptureWaiter(this));
+        mCaptureConsumer->setName(String8("Camera2Client::CaptureConsumer"));
+        mCaptureWindow = new SurfaceTextureClient(
+            mCaptureConsumer->getProducerInterface());
+        // Create memory for API consumption
+        mCaptureHeap = new Camera2Heap(maxJpegSize.data.i32[0], 1,
+                                       "Camera2Client::CaptureHeap");
+        if (mCaptureHeap->mHeap->getSize() == 0) {
+            ALOGE("%s: Camera %d: Unable to allocate memory for capture",
+                    __FUNCTION__, mCameraId);
+            return NO_MEMORY;
+        }
+    }
+
+    if (mCaptureStreamId != NO_STREAM) {
+        // Check if stream parameters have to change
+        uint32_t currentWidth, currentHeight;
+        res = mDevice->getStreamInfo(mCaptureStreamId,
+                &currentWidth, &currentHeight, 0);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error querying capture output stream info: "
+                    "%s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+        if (currentWidth != (uint32_t)params.pictureWidth ||
+                currentHeight != (uint32_t)params.pictureHeight) {
+            res = mDevice->deleteStream(mCaptureStreamId);
+            if (res != OK) {
+                ALOGE("%s: Camera %d: Unable to delete old output stream "
+                        "for capture: %s (%d)", __FUNCTION__, mCameraId,
+                        strerror(-res), res);
+                return res;
+            }
+            mCaptureStreamId = NO_STREAM;
+        }
+    }
+
+    if (mCaptureStreamId == NO_STREAM) {
+        // Create stream for HAL production
+        res = mDevice->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__, mCameraId, strerror(-res), res);
+            return res;
+        }
+
+    }
+    return OK;
+}
+
+status_t Camera2Client::updateCaptureRequest(const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+    if (mCaptureRequest == NULL) {
+        res = mDevice->createDefaultRequest(CAMERA2_TEMPLATE_STILL_CAPTURE,
+                &mCaptureRequest);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to create default still image request:"
+                    " %s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    res = updateRequestCommon(mCaptureRequest, params);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update common entries of capture "
+                "request: %s (%d)", __FUNCTION__, mCameraId,
+                strerror(-res), res);
+        return res;
+    }
+
+    res = updateEntry(mCaptureRequest,
+            ANDROID_JPEG_THUMBNAIL_SIZE,
+            params.jpegThumbSize, 2);
+    if (res != OK) return res;
+    res = updateEntry(mCaptureRequest,
+            ANDROID_JPEG_THUMBNAIL_QUALITY,
+            &params.jpegThumbQuality, 1);
+    if (res != OK) return res;
+    res = updateEntry(mCaptureRequest,
+            ANDROID_JPEG_QUALITY,
+            &params.jpegQuality, 1);
+    if (res != OK) return res;
+    res = updateEntry(mCaptureRequest,
+            ANDROID_JPEG_ORIENTATION,
+            &params.jpegRotation, 1);
+    if (res != OK) return res;
+
+    if (params.gpsEnabled) {
+        res = updateEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_COORDINATES,
+                params.gpsCoordinates, 3);
+        if (res != OK) return res;
+        res = updateEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_TIMESTAMP,
+                &params.gpsTimestamp, 1);
+        if (res != OK) return res;
+        res = updateEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_PROCESSING_METHOD,
+                params.gpsProcessingMethod.string(),
+                params.gpsProcessingMethod.size());
+        if (res != OK) return res;
+    } else {
+        res = deleteEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_COORDINATES);
+        if (res != OK) return res;
+        res = deleteEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_TIMESTAMP);
+        if (res != OK) return res;
+        res = deleteEntry(mCaptureRequest,
+                ANDROID_JPEG_GPS_PROCESSING_METHOD);
+        if (res != OK) return res;
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::updateRecordingRequest(const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+    if (mRecordingRequest == NULL) {
+        res = mDevice->createDefaultRequest(CAMERA2_TEMPLATE_VIDEO_RECORD,
+                &mRecordingRequest);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Unable to create default recording request:"
+                    " %s (%d)", __FUNCTION__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    res = updateRequestCommon(mRecordingRequest, params);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to update common entries of recording "
+                "request: %s (%d)", __FUNCTION__, mCameraId,
+                strerror(-res), res);
+        return res;
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::updateRecordingStream(const Parameters &params) {
+    status_t res;
+
+    if (mRecordingConsumer == 0) {
+        // Create CPU buffer queue endpoint
+        mRecordingConsumer = new MediaConsumer(mRecordingHeapCount);
+        mRecordingConsumer->setFrameAvailableListener(new RecordingWaiter(this));
+        mRecordingConsumer->setName(String8("Camera2Client::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 = mDevice->getStreamInfo(mRecordingStreamId,
+                &currentWidth, &currentHeight, 0);
+        if (res != OK) {
+            ALOGE("%s: Camera %d: Error querying recording output stream info: "
+                    "%s (%d)", __FUNCTION__, mCameraId, 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 = mDevice->deleteStream(mRecordingStreamId);
+            if (res != OK) {
+                ALOGE("%s: Camera %d: Unable to delete old output stream "
+                        "for recording: %s (%d)", __FUNCTION__, mCameraId,
+                        strerror(-res), res);
+                return res;
+            }
+            mRecordingStreamId = NO_STREAM;
+        }
+    }
+
+    if (mRecordingStreamId == NO_STREAM) {
+        res = mDevice->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__, mCameraId, strerror(-res), res);
+            return res;
+        }
+    }
+
+    return OK;
+}
+
+status_t Camera2Client::updateRequestCommon(camera_metadata_t *request,
+        const Parameters &params) {
+    ATRACE_CALL();
+    status_t res;
+    res = updateEntry(request,
+            ANDROID_CONTROL_AE_TARGET_FPS_RANGE, params.previewFpsRange, 2);
+    if (res != OK) return res;
+
+    uint8_t wbMode = params.autoWhiteBalanceLock ?
+            ANDROID_CONTROL_AWB_LOCKED : params.wbMode;
+    res = updateEntry(request,
+            ANDROID_CONTROL_AWB_MODE, &wbMode, 1);
+    if (res != OK) return res;
+    res = updateEntry(request,
+            ANDROID_CONTROL_EFFECT_MODE, &params.effectMode, 1);
+    if (res != OK) return res;
+    res = updateEntry(request,
+            ANDROID_CONTROL_AE_ANTIBANDING_MODE,
+            &params.antibandingMode, 1);
+    if (res != OK) return res;
+
+    uint8_t controlMode =
+            (params.sceneMode == ANDROID_CONTROL_SCENE_MODE_UNSUPPORTED) ?
+            ANDROID_CONTROL_AUTO : ANDROID_CONTROL_USE_SCENE_MODE;
+    res = updateEntry(request,
+            ANDROID_CONTROL_MODE, &controlMode, 1);
+    if (res != OK) return res;
+    if (controlMode == ANDROID_CONTROL_USE_SCENE_MODE) {
+        res = updateEntry(request,
+                ANDROID_CONTROL_SCENE_MODE,
+                &params.sceneMode, 1);
+        if (res != OK) return res;
+    }
+
+    uint8_t flashMode = ANDROID_FLASH_OFF;
+    uint8_t aeMode;
+    switch (params.flashMode) {
+        case Parameters::FLASH_MODE_OFF:
+            aeMode = ANDROID_CONTROL_AE_ON; break;
+        case Parameters::FLASH_MODE_AUTO:
+            aeMode = ANDROID_CONTROL_AE_ON_AUTO_FLASH; break;
+        case Parameters::FLASH_MODE_ON:
+            aeMode = ANDROID_CONTROL_AE_ON_ALWAYS_FLASH; break;
+        case Parameters::FLASH_MODE_TORCH:
+            aeMode = ANDROID_CONTROL_AE_ON;
+            flashMode = ANDROID_FLASH_TORCH;
+            break;
+        case Parameters::FLASH_MODE_RED_EYE:
+            aeMode = ANDROID_CONTROL_AE_ON_AUTO_FLASH_REDEYE; break;
+        default:
+            ALOGE("%s: Camera %d: Unknown flash mode %d", __FUNCTION__,
+                    mCameraId, params.flashMode);
+            return BAD_VALUE;
+    }
+    if (params.autoExposureLock) aeMode = ANDROID_CONTROL_AE_LOCKED;
+
+    res = updateEntry(request,
+            ANDROID_FLASH_MODE, &flashMode, 1);
+    if (res != OK) return res;
+    res = updateEntry(request,
+            ANDROID_CONTROL_AE_MODE, &aeMode, 1);
+    if (res != OK) return res;
+
+    float focusDistance = 0; // infinity focus in diopters
+    uint8_t focusMode;
+    switch (params.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:
+            focusMode = params.focusMode;
+            break;
+        case Parameters::FOCUS_MODE_INFINITY:
+        case Parameters::FOCUS_MODE_FIXED:
+            focusMode = ANDROID_CONTROL_AF_OFF;
+            break;
+        default:
+            ALOGE("%s: Camera %d: Unknown focus mode %d", __FUNCTION__,
+                    mCameraId, params.focusMode);
+            return BAD_VALUE;
+    }
+    res = updateEntry(request,
+            ANDROID_LENS_FOCUS_DISTANCE, &focusDistance, 1);
+    if (res != OK) return res;
+    res = updateEntry(request,
+            ANDROID_CONTROL_AF_MODE, &focusMode, 1);
+    if (res != OK) return res;
+
+    size_t focusingAreasSize = params.focusingAreas.size() * 5;
+    int32_t *focusingAreas = new int32_t[focusingAreasSize];
+    for (size_t i = 0; i < focusingAreasSize; i += 5) {
+        focusingAreas[i + 0] = params.focusingAreas[i].left;
+        focusingAreas[i + 1] = params.focusingAreas[i].top;
+        focusingAreas[i + 2] = params.focusingAreas[i].right;
+        focusingAreas[i + 3] = params.focusingAreas[i].bottom;
+        focusingAreas[i + 4] = params.focusingAreas[i].weight;
+    }
+    res = updateEntry(request,
+            ANDROID_CONTROL_AF_REGIONS, focusingAreas,focusingAreasSize);
+    if (res != OK) return res;
+    delete[] focusingAreas;
+
+    res = updateEntry(request,
+            ANDROID_CONTROL_AE_EXP_COMPENSATION,
+            &params.exposureCompensation, 1);
+    if (res != OK) return res;
+
+    size_t meteringAreasSize = params.meteringAreas.size() * 5;
+    int32_t *meteringAreas = new int32_t[meteringAreasSize];
+    for (size_t i = 0; i < meteringAreasSize; i += 5) {
+        meteringAreas[i + 0] = params.meteringAreas[i].left;
+        meteringAreas[i + 1] = params.meteringAreas[i].top;
+        meteringAreas[i + 2] = params.meteringAreas[i].right;
+        meteringAreas[i + 3] = params.meteringAreas[i].bottom;
+        meteringAreas[i + 4] = params.meteringAreas[i].weight;
+    }
+    res = updateEntry(request,
+            ANDROID_CONTROL_AE_REGIONS, meteringAreas, meteringAreasSize);
+    if (res != OK) return res;
+
+    res = updateEntry(request,
+            ANDROID_CONTROL_AWB_REGIONS, meteringAreas, meteringAreasSize);
+    if (res != OK) return res;
+    delete[] meteringAreas;
+
+    // Need to convert zoom index into a crop rectangle. The rectangle is
+    // chosen to maximize its area on the sensor
+
+    camera_metadata_entry_t maxDigitalZoom =
+            staticInfo(ANDROID_SCALER_AVAILABLE_MAX_ZOOM);
+    float zoomIncrement = (maxDigitalZoom.data.f[0] - 1) /
+            (NUM_ZOOM_STEPS-1);
+    float zoomRatio = 1 + zoomIncrement * params.zoom;
+
+    camera_metadata_entry_t activePixelArraySize =
+            staticInfo(ANDROID_SENSOR_ACTIVE_ARRAY_SIZE, 2, 2);
+    int32_t arrayWidth = activePixelArraySize.data.i32[0];
+    int32_t arrayHeight = activePixelArraySize.data.i32[1];
+    float zoomLeft, zoomTop, zoomWidth, zoomHeight;
+    if (params.previewWidth >= params.previewHeight) {
+        zoomWidth =  arrayWidth / zoomRatio;
+        zoomHeight = zoomWidth *
+                params.previewHeight / params.previewWidth;
+    } else {
+        zoomHeight = arrayHeight / zoomRatio;
+        zoomWidth = zoomHeight *
+                params.previewWidth / params.previewHeight;
+    }
+    zoomLeft = (arrayWidth - zoomWidth) / 2;
+    zoomTop = (arrayHeight - zoomHeight) / 2;
+
+    int32_t cropRegion[3] = { zoomLeft, zoomTop, zoomWidth };
+    res = updateEntry(request,
+            ANDROID_SCALER_CROP_REGION, cropRegion, 3);
+    if (res != OK) return res;
+
+    // TODO: Decide how to map recordingHint, or whether just to ignore it
+
+    uint8_t vstabMode = params.videoStabilization ?
+            ANDROID_CONTROL_VIDEO_STABILIZATION_ON :
+            ANDROID_CONTROL_VIDEO_STABILIZATION_OFF;
+    res = updateEntry(request,
+            ANDROID_CONTROL_VIDEO_STABILIZATION_MODE,
+            &vstabMode, 1);
+    if (res != OK) return res;
+
+    return OK;
+}
+
+status_t Camera2Client::updateEntry(camera_metadata_t *buffer,
+        uint32_t tag, const void *data, size_t data_count) {
+    camera_metadata_entry_t entry;
+    status_t res;
+    res = find_camera_metadata_entry(buffer, tag, &entry);
+    if (res == NAME_NOT_FOUND) {
+        res = add_camera_metadata_entry(buffer,
+                tag, data, data_count);
+    } else if (res == OK) {
+        res = update_camera_metadata_entry(buffer,
+                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;
+}
+
+status_t Camera2Client::deleteEntry(camera_metadata_t *buffer, uint32_t tag) {
+    camera_metadata_entry_t entry;
+    status_t res;
+    res = find_camera_metadata_entry(buffer, 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(buffer, 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;
+}
+
+int Camera2Client::formatStringToEnum(const char *format) {
+    return
+        !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* Camera2Client::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 Camera2Client::wbModeStringToEnum(const char *wbMode) {
+    return
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_AUTO) ?
+            ANDROID_CONTROL_AWB_AUTO :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_INCANDESCENT) ?
+            ANDROID_CONTROL_AWB_INCANDESCENT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_FLUORESCENT) ?
+            ANDROID_CONTROL_AWB_FLUORESCENT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_WARM_FLUORESCENT) ?
+            ANDROID_CONTROL_AWB_WARM_FLUORESCENT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_DAYLIGHT) ?
+            ANDROID_CONTROL_AWB_DAYLIGHT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_CLOUDY_DAYLIGHT) ?
+            ANDROID_CONTROL_AWB_CLOUDY_DAYLIGHT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_TWILIGHT) ?
+            ANDROID_CONTROL_AWB_TWILIGHT :
+        !strcmp(wbMode, CameraParameters::WHITE_BALANCE_SHADE) ?
+            ANDROID_CONTROL_AWB_SHADE :
+        -1;
+}
+
+int Camera2Client::effectModeStringToEnum(const char *effectMode) {
+    return
+        !strcmp(effectMode, CameraParameters::EFFECT_NONE) ?
+            ANDROID_CONTROL_EFFECT_OFF :
+        !strcmp(effectMode, CameraParameters::EFFECT_MONO) ?
+            ANDROID_CONTROL_EFFECT_MONO :
+        !strcmp(effectMode, CameraParameters::EFFECT_NEGATIVE) ?
+            ANDROID_CONTROL_EFFECT_NEGATIVE :
+        !strcmp(effectMode, CameraParameters::EFFECT_SOLARIZE) ?
+            ANDROID_CONTROL_EFFECT_SOLARIZE :
+        !strcmp(effectMode, CameraParameters::EFFECT_SEPIA) ?
+            ANDROID_CONTROL_EFFECT_SEPIA :
+        !strcmp(effectMode, CameraParameters::EFFECT_POSTERIZE) ?
+            ANDROID_CONTROL_EFFECT_POSTERIZE :
+        !strcmp(effectMode, CameraParameters::EFFECT_WHITEBOARD) ?
+            ANDROID_CONTROL_EFFECT_WHITEBOARD :
+        !strcmp(effectMode, CameraParameters::EFFECT_BLACKBOARD) ?
+            ANDROID_CONTROL_EFFECT_BLACKBOARD :
+        !strcmp(effectMode, CameraParameters::EFFECT_AQUA) ?
+            ANDROID_CONTROL_EFFECT_AQUA :
+        -1;
+}
+
+int Camera2Client::abModeStringToEnum(const char *abMode) {
+    return
+        !strcmp(abMode, CameraParameters::ANTIBANDING_AUTO) ?
+            ANDROID_CONTROL_AE_ANTIBANDING_AUTO :
+        !strcmp(abMode, CameraParameters::ANTIBANDING_OFF) ?
+            ANDROID_CONTROL_AE_ANTIBANDING_OFF :
+        !strcmp(abMode, CameraParameters::ANTIBANDING_50HZ) ?
+            ANDROID_CONTROL_AE_ANTIBANDING_50HZ :
+        !strcmp(abMode, CameraParameters::ANTIBANDING_60HZ) ?
+            ANDROID_CONTROL_AE_ANTIBANDING_60HZ :
+        -1;
+}
+
+int Camera2Client::sceneModeStringToEnum(const char *sceneMode) {
+    return
+        !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;
+}
+
+Camera2Client::Parameters::flashMode_t Camera2Client::flashModeStringToEnum(
+        const char *flashMode) {
+    return
+        !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;
+}
+
+Camera2Client::Parameters::focusMode_t Camera2Client::focusModeStringToEnum(
+        const char *focusMode) {
+    return
+        !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;
+}
+
+status_t Camera2Client::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 Camera2Client::validateAreas(const Vector<Parameters::Area> &areas,
+                                      size_t maxRegions) {
+    // 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;
+        }
+    }
+    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 Camera2Client::boolFromString(const char *boolStr) {
+    return !boolStr ? false :
+        !strcmp(boolStr, CameraParameters::TRUE) ? true :
+        false;
+}
+
+int Camera2Client::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;
+}
+
+} // namespace android
diff --git a/services/camera/libcameraservice/Camera2Client.h b/services/camera/libcameraservice/Camera2Client.h
new file mode 100644
index 0000000..dffd4ab
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Client.h
@@ -0,0 +1,416 @@
+/*
+ * 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 "camera/CameraParameters.h"
+#include <binder/MemoryBase.h>
+#include <binder/MemoryHeapBase.h>
+#include <gui/CpuConsumer.h>
+#include "MediaConsumer.h"
+
+namespace android {
+
+/**
+ * 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);
+    virtual ~Camera2Client();
+
+    status_t initialize(camera_module_t *module);
+
+    virtual status_t dump(int fd, const Vector<String16>& args);
+
+    // Interface used by CameraDevice
+
+    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);
+
+private:
+    enum State {
+        DISCONNECTED,
+        STOPPED,
+        WAITING_FOR_PREVIEW_WINDOW,
+        PREVIEW,
+        RECORD,
+        STILL_CAPTURE,
+        VIDEO_SNAPSHOT
+    } mState;
+
+    static const char *getStateName(State state);
+
+    /** 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;
+
+    status_t setPreviewWindowL(const sp<IBinder>& binder,
+            sp<ANativeWindow> window);
+
+    void stopPreviewL();
+    status_t startPreviewL();
+
+    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();
+    status_t commandEnableFocusMoveMsgL(bool enable);
+    status_t commandPingL();
+    status_t commandSetVideoBufferCountL(size_t count);
+
+    // Current camera state; this is the contents of the CameraParameters object
+    // in a more-efficient format. 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 {
+        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];
+        int32_t jpegQuality, jpegThumbQuality;
+        int32_t jpegRotation;
+
+        bool gpsEnabled;
+        double gpsCoordinates[3];
+        int64_t gpsTimestamp;
+        String8 gpsProcessingMethod;
+
+        int wbMode;
+        int effectMode;
+        int antibandingMode;
+        int sceneMode;
+
+        enum flashMode_t {
+            FLASH_MODE_OFF = 0,
+            FLASH_MODE_AUTO,
+            FLASH_MODE_ON,
+            FLASH_MODE_TORCH,
+            FLASH_MODE_RED_EYE = ANDROID_CONTROL_AE_ON_AUTO_FLASH_REDEYE,
+            FLASH_MODE_INVALID = -1
+        } flashMode;
+
+        enum focusMode_t {
+            FOCUS_MODE_AUTO = ANDROID_CONTROL_AF_AUTO,
+            FOCUS_MODE_MACRO = ANDROID_CONTROL_AF_MACRO,
+            FOCUS_MODE_CONTINUOUS_VIDEO = ANDROID_CONTROL_AF_CONTINUOUS_VIDEO,
+            FOCUS_MODE_CONTINUOUS_PICTURE =
+                ANDROID_CONTROL_AF_CONTINUOUS_PICTURE,
+            FOCUS_MODE_EDOF = ANDROID_CONTROL_AF_EDOF,
+            FOCUS_MODE_INFINITY,
+            FOCUS_MODE_FIXED,
+            FOCUS_MODE_INVALID = -1
+        } focusMode;
+
+        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) {}
+        };
+        Vector<Area> focusingAreas;
+
+        int32_t exposureCompensation;
+        bool autoExposureLock;
+        bool autoWhiteBalanceLock;
+
+        Vector<Area> meteringAreas;
+
+        int zoom;
+
+        int videoWidth, videoHeight;
+
+        bool recordingHint;
+        bool videoStabilization;
+
+        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 enableFocusMoveMessages;
+
+        int afTriggerCounter;
+        int currentAfTriggerId;
+        bool afInMotion;
+    };
+
+    class LockedParameters {
+      public:
+        class Key {
+          public:
+            Key(LockedParameters &p):
+                    mParameters(p.mParameters),
+                    mLockedParameters(p) {
+                mLockedParameters.mLock.lock();
+            }
+
+            ~Key() {
+                mLockedParameters.mLock.unlock();
+            }
+            Parameters &mParameters;
+          private:
+            // Disallow copying, default construction
+            Key();
+            Key(const Key &);
+            Key &operator=(const Key &);
+            LockedParameters &mLockedParameters;
+        };
+        class ReadKey {
+          public:
+            ReadKey(const LockedParameters &p):
+                    mParameters(p.mParameters),
+                    mLockedParameters(p) {
+                mLockedParameters.mLock.lock();
+            }
+
+            ~ReadKey() {
+                mLockedParameters.mLock.unlock();
+            }
+            const Parameters &mParameters;
+          private:
+            // Disallow copying, default construction
+            ReadKey();
+            ReadKey(const ReadKey &);
+            ReadKey &operator=(const ReadKey &);
+            const LockedParameters &mLockedParameters;
+        };
+
+        // Only use for dumping or other debugging
+        const Parameters &unsafeUnlock() {
+            return mParameters;
+        }
+      private:
+        Parameters mParameters;
+        mutable Mutex mLock;
+
+    } mParameters;
+
+    /** Camera device-related private members */
+
+    class Camera2Heap;
+
+    // Number of zoom steps to simulate
+    static const unsigned int NUM_ZOOM_STEPS = 10;
+    // Used with stream IDs
+    static const int NO_STREAM = -1;
+
+    /* Preview related members */
+
+    int mPreviewStreamId;
+    camera_metadata_t *mPreviewRequest;
+    sp<IBinder> mPreviewSurface;
+    sp<ANativeWindow> mPreviewWindow;
+
+    status_t updatePreviewRequest(const Parameters &params);
+    status_t updatePreviewStream(const Parameters &params);
+
+    /* Still image capture related members */
+
+    int mCaptureStreamId;
+    sp<CpuConsumer>    mCaptureConsumer;
+    sp<ANativeWindow>  mCaptureWindow;
+    // Simple listener that forwards frame available notifications from
+    // a CPU consumer to the capture notification
+    class CaptureWaiter: public CpuConsumer::FrameAvailableListener {
+      public:
+        CaptureWaiter(Camera2Client *parent) : mParent(parent) {}
+        void onFrameAvailable() { mParent->onCaptureAvailable(); }
+      private:
+        Camera2Client *mParent;
+    };
+    sp<CaptureWaiter>  mCaptureWaiter;
+    camera_metadata_t *mCaptureRequest;
+    sp<Camera2Heap>    mCaptureHeap;
+    // Handle captured image buffers
+    void onCaptureAvailable();
+
+    status_t updateCaptureRequest(const Parameters &params);
+    status_t updateCaptureStream(const Parameters &params);
+
+    /* Recording related members */
+
+    int mRecordingStreamId;
+    sp<MediaConsumer>    mRecordingConsumer;
+    sp<ANativeWindow>  mRecordingWindow;
+    // Simple listener that forwards frame available notifications from
+    // a CPU consumer to the recording notification
+    class RecordingWaiter: public MediaConsumer::FrameAvailableListener {
+      public:
+        RecordingWaiter(Camera2Client *parent) : mParent(parent) {}
+        void onFrameAvailable() { mParent->onRecordingFrameAvailable(); }
+      private:
+        Camera2Client *mParent;
+    };
+    sp<RecordingWaiter>  mRecordingWaiter;
+    camera_metadata_t *mRecordingRequest;
+    sp<Camera2Heap> mRecordingHeap;
+
+    static const size_t kDefaultRecordingHeapCount = 8;
+    size_t mRecordingHeapCount;
+    size_t mRecordingHeapHead, mRecordingHeapFree;
+    // Handle new recording image buffers
+    void onRecordingFrameAvailable();
+
+    status_t updateRecordingRequest(const Parameters &params);
+    status_t updateRecordingStream(const Parameters &params);
+
+    /** Notification-related members */
+
+    bool mAfInMotion;
+
+    /** Camera2Device instance wrapping HAL2 entry */
+
+    sp<Camera2Device> mDevice;
+
+    /** Utility members */
+
+    // Verify that caller is the owner of the camera
+    status_t checkPid(const char *checkLocation) const;
+
+    // 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;
+    };
+
+    // Get values for static camera info entry. 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_entry_t staticInfo(uint32_t tag,
+            size_t minCount=0, size_t maxCount=0);
+
+    // Convert static camera info from a camera2 device to the
+    // old API parameter map.
+    status_t buildDefaultParameters();
+
+    // Update parameters all requests use, based on mParameters
+    status_t updateRequestCommon(camera_metadata_t *request, const Parameters &params);
+
+    // Update specific metadata entry with new values. Adds entry if it does not
+    // exist, which will invalidate sorting
+    static status_t updateEntry(camera_metadata_t *buffer,
+            uint32_t tag, const void *data, size_t data_count);
+
+    // Remove metadata entry. Will invalidate sorting. If entry does not exist,
+    // does nothing.
+    static status_t deleteEntry(camera_metadata_t *buffer,
+            uint32_t tag);
+
+    // Convert camera1 preview format string to camera2 enum
+    static int formatStringToEnum(const char *format);
+    static const char *formatEnumToString(int format);
+
+    static int wbModeStringToEnum(const char *wbMode);
+    static int effectModeStringToEnum(const char *effectMode);
+    static int abModeStringToEnum(const char *abMode);
+    static int sceneModeStringToEnum(const char *sceneMode);
+    static Parameters::flashMode_t flashModeStringToEnum(const char *flashMode);
+    static Parameters::focusMode_t focusModeStringToEnum(const char *focusMode);
+    static status_t parseAreas(const char *areasCStr,
+            Vector<Parameters::Area> *areas);
+    static status_t validateAreas(const Vector<Parameters::Area> &areas,
+                                  size_t maxRegions);
+    static bool boolFromString(const char *boolStr);
+
+    // Map from camera orientation + facing to gralloc transform enum
+    static int degToTransform(int degrees, bool mirror);
+
+};
+
+}; // namespace android
+
+#endif
diff --git a/services/camera/libcameraservice/Camera2Device.cpp b/services/camera/libcameraservice/Camera2Device.cpp
new file mode 100644
index 0000000..7c97e1e
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Device.cpp
@@ -0,0 +1,1068 @@
+/*
+ * 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 "Camera2Device"
+//#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 "Camera2Device.h"
+
+namespace android {
+
+Camera2Device::Camera2Device(int id):
+        mId(id),
+        mDevice(NULL)
+{
+    ALOGV("%s: E", __FUNCTION__);
+}
+
+Camera2Device::~Camera2Device()
+{
+    ALOGV("%s: E", __FUNCTION__);
+    if (mDevice) {
+        status_t res;
+        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;
+    }
+}
+
+status_t Camera2Device::initialize(camera_module_t *module)
+{
+    ALOGV("%s: E", __FUNCTION__);
+
+    status_t res;
+    char name[10];
+    snprintf(name, sizeof(name), "%d", mId);
+
+    res = module->common.methods->open(&module->common, name,
+            reinterpret_cast<hw_device_t**>(&mDevice));
+
+    if (res != OK) {
+        ALOGE("%s: Could not open camera %d: %s (%d)", __FUNCTION__,
+                mId, strerror(-res), res);
+        return res;
+    }
+
+    if (mDevice->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,
+                mDevice->common.version);
+        return BAD_VALUE;
+    }
+
+    camera_info info;
+    res = module->get_camera_info(mId, &info);
+    if (res != OK ) return res;
+
+    if (info.device_version != mDevice->common.version) {
+        ALOGE("%s: HAL reporting mismatched camera_info version (%x)"
+                " and device version (%x).", __FUNCTION__,
+                mDevice->common.version, info.device_version);
+        return BAD_VALUE;
+    }
+
+    mDeviceInfo = info.static_camera_characteristics;
+
+    res = mRequestQueue.setConsumerDevice(mDevice);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to connect request queue to device: %s (%d)",
+                __FUNCTION__, mId, strerror(-res), res);
+        return res;
+    }
+    res = mFrameQueue.setProducerDevice(mDevice);
+    if (res != OK) {
+        ALOGE("%s: Camera %d: Unable to connect frame queue to device: %s (%d)",
+                __FUNCTION__, mId, strerror(-res), res);
+        return res;
+    }
+
+    res = mDevice->ops->get_metadata_vendor_tag_ops(mDevice, &mVendorTagOps);
+    if (res != OK ) {
+        ALOGE("%s: Camera %d: Unable to retrieve tag ops from device: %s (%d)",
+                __FUNCTION__, mId, strerror(-res), res);
+        return res;
+    }
+
+    setNotifyCallback(NULL);
+
+    return OK;
+}
+
+status_t Camera2Device::dump(int fd, const Vector<String16>& args) {
+
+    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;
+}
+
+camera_metadata_t *Camera2Device::info() {
+    ALOGVV("%s: E", __FUNCTION__);
+
+    return mDeviceInfo;
+}
+
+status_t Camera2Device::capture(camera_metadata_t* request) {
+    ALOGV("%s: E", __FUNCTION__);
+
+    mRequestQueue.enqueue(request);
+    return OK;
+}
+
+
+status_t Camera2Device::setStreamingRequest(camera_metadata_t* request) {
+    ALOGV("%s: E", __FUNCTION__);
+
+    mRequestQueue.setStreamSlot(request);
+    return OK;
+}
+
+status_t Camera2Device::createStream(sp<ANativeWindow> consumer,
+        uint32_t width, uint32_t height, int format, size_t size, int *id) {
+    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::getStreamInfo(int id,
+        uint32_t *width, uint32_t *height, uint32_t *format) {
+    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) {
+    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) {
+    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::createDefaultRequest(int templateId,
+        camera_metadata_t **request) {
+    ALOGV("%s: E", __FUNCTION__);
+    return mDevice->ops->construct_default_request(
+        mDevice, templateId, request);
+}
+
+status_t Camera2Device::waitUntilDrained() {
+    static const uint32_t kSleepTime = 50000; // 50 ms
+    static const uint32_t kMaxSleepTime = 10000000; // 10 s
+    ALOGV("%s: E", __FUNCTION__);
+    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, requests still in flight", __FUNCTION__,
+                    totalTime);
+            return TIMED_OUT;
+        }
+    }
+    return OK;
+}
+
+status_t Camera2Device::setNotifyCallback(NotificationListener *listener) {
+    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) {
+    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::triggerAutofocus(uint32_t id) {
+    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) {
+    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) {
+    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;
+}
+
+/**
+ * Camera2Device::NotificationListener
+ */
+
+Camera2Device::NotificationListener::~NotificationListener() {
+}
+
+/**
+ * Camera2Device::MetadataQueue
+ */
+
+Camera2Device::MetadataQueue::MetadataQueue():
+            mDevice(NULL),
+            mFrameCount(0),
+            mCount(0),
+            mStreamSlotCount(0),
+            mSignalConsumer(true)
+{
+    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() {
+    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) {
+    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) {
+    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) {
+    ALOGVV("%s: E", __FUNCTION__);
+    Mutex::Autolock l(mMutex);
+
+    mCount++;
+    mEntries.push_back(buf);
+
+    return signalConsumerLocked();
+}
+
+int Camera2Device::MetadataQueue::getBufferCount() {
+    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)
+{
+    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) {
+        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++;
+    }
+
+    *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::setStreamSlot(camera_metadata_t *buf)
+{
+    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)
+{
+    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) {
+    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() {
+    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)
+{
+    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)
+{
+    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)
+{
+    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)
+{
+    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() {
+    if (mState != RELEASED) {
+        release();
+    }
+}
+
+status_t Camera2Device::StreamAdapter::connectToDevice(
+        sp<ANativeWindow> consumer,
+        uint32_t width, uint32_t height, int format, size_t size) {
+    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() {
+    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);
+        if (res != OK) {
+            ALOGE("%s: Unable to disconnect stream %d from native window",
+                    __FUNCTION__, mId);
+            return res;
+        }
+    }
+    mId = -1;
+    mState = RELEASED;
+    return OK;
+}
+
+status_t Camera2Device::StreamAdapter::setTransform(int transform) {
+    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) {
+    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) {
+    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) {
+    StreamAdapter *stream =
+            const_cast<StreamAdapter*>(static_cast<const StreamAdapter*>(w));
+    ALOGVV("Stream %d enqueue: Buffer %p captured at %lld ns",
+            stream->mId, (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->mFrameCount++;
+    stream->mLastTimestamp = timestamp;
+    return OK;
+}
+
+int Camera2Device::StreamAdapter::cancel_buffer(const camera2_stream_ops_t* w,
+        buffer_handle_t* buffer) {
+    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) {
+    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);
+}
+
+
+}; // namespace android
diff --git a/services/camera/libcameraservice/Camera2Device.h b/services/camera/libcameraservice/Camera2Device.h
new file mode 100644
index 0000000..9be370f
--- /dev/null
+++ b/services/camera/libcameraservice/Camera2Device.h
@@ -0,0 +1,338 @@
+/*
+ * 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"
+
+namespace android {
+
+class Camera2Device : public virtual RefBase {
+  public:
+    Camera2Device(int id);
+
+    ~Camera2Device();
+
+    status_t initialize(camera_module_t *module);
+
+    status_t dump(int fd, const Vector<String16>& args);
+
+    /**
+     * Get a pointer to the device's static characteristics metadata buffer
+     */
+    camera_metadata_t* info();
+
+    /**
+     * Submit request for capture. The Camera2Device takes ownership of the
+     * passed-in buffer.
+     */
+    status_t capture(camera_metadata_t *request);
+
+    /**
+     * Submit request for streaming. The Camera2Device makes a copy of the
+     * passed-in buffer and the caller retains ownership.
+     */
+    status_t setStreamingRequest(camera_metadata_t *request);
+
+    /**
+     * 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);
+
+    /**
+     * 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);
+
+    /**
+     * Create a metadata buffer with fields that the HAL device believes are
+     * best for the given use case
+     */
+    status_t createDefaultRequest(int templateId,
+            camera_metadata_t **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);
+
+    /**
+     * 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);
+
+  private:
+
+    const int mId;
+    camera2_device_t *mDevice;
+
+    camera_metadata_t *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 = true);
+        int      getBufferCount();
+        status_t waitForBuffer(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;
+
+        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;
+
+    // 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 0000000..562384d
--- /dev/null
+++ b/services/camera/libcameraservice/CameraClient.cpp
@@ -0,0 +1,961 @@
+/*
+ * 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):
+        Client(cameraService, cameraClient,
+                cameraId, cameraFacing, clientPid)
+{
+    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);
+        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);
+
+    // set mClientPid to let disconnet() tear down the hardware
+    mClientPid = callingPid;
+    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);
+
+    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();
+
+    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:
+                enableShutterSound(false);
+                break;
+            case 1:
+                enableShutterSound(true);
+                break;
+            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 0000000..256298d
--- /dev/null
+++ b/services/camera/libcameraservice/CameraClient.h
@@ -0,0 +1,155 @@
+/*
+ * 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);
+    ~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 87a0802..05ac9fa 100644
--- a/services/camera/libcameraservice/CameraHardwareInterface.h
+++ b/services/camera/libcameraservice/CameraHardwareInterface.h
@@ -569,7 +569,7 @@
         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 @@
                       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 @@
     {
         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 @@
     {
         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 cdfb2f5..0000000
--- 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 c6d8756..0000000
--- 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 385be50..878afde 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 @@
 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,16 +186,31 @@
         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;
+    }
 
-    hardware = new CameraHardwareInterface(camera_device_name);
-    if (hardware->initialize(&mModule->common) != OK) {
-        hardware.clear();
+    switch(deviceVersion) {
+      case CAMERA_DEVICE_API_VERSION_1_0:
+        client = new CameraClient(this, cameraClient, cameraId,
+                info.facing, callingPid);
+        break;
+      case CAMERA_DEVICE_API_VERSION_2_0:
+        client = new Camera2Client(this, cameraClient, cameraId,
+                info.facing, callingPid);
+        break;
+      default:
+        ALOGE("Unknown camera device HAL version: %d", deviceVersion);
         return NULL;
     }
 
-    client = new Client(this, cameraClient, hardware, cameraId, info.facing, callingPid);
+    if (client->initialize(mModule) != OK) {
+        return NULL;
+    }
+
     mClient[cameraId] = client;
     LOG1("CameraService::connect X (id %d)", cameraId);
     return client;
@@ -335,34 +350,17 @@
 
 CameraService::Client::Client(const sp<CameraService>& cameraService,
         const sp<ICameraClient>& cameraClient,
-        const sp<CameraHardwareInterface>& hardware,
         int cameraId, int cameraFacing, int clientPid) {
     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;
     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 +368,7 @@
 
 // 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;
 }
 
 // ----------------------------------------------------------------------------
@@ -967,311 +390,12 @@
     // 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;
+void CameraService::Client::disconnect() {
+    mCameraService->removeClient(mCameraClient);
+    mCameraService->setCameraFree(mCameraId);
 }
 
 // ----------------------------------------------------------------------------
@@ -1293,41 +417,81 @@
 }
 
 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;
-        for (int i = 0; i < mNumberOfCameras; i++) {
-            sp<Client> client = mClient[i].promote();
-            if (client == 0) continue;
-            hasClient = true;
-            sprintf(buffer, "Client[%d] (%p) PID: %d\n",
-                    i,
-                    client->getCameraClient()->asBinder().get(),
-                    client->mClientPid);
-            result.append(buffer);
+        if (!mModule) {
+            result = String8::format("No camera module available!\n");
             write(fd, result.string(), result.size());
-            client->mHardware->dump(fd, args);
+            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) {
+                result = String8::format("  Device is closed, no client instance\n");
+                write(fd, result.string(), result.size());
+                continue;
+            }
+            hasClient = true;
+            result = String8::format("  Device is open. Client instance dump:\n");
+            write(fd, result.string(), result.size());
+            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,14 +500,16 @@
         // 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;
 }
diff --git a/services/camera/libcameraservice/CameraService.h b/services/camera/libcameraservice/CameraService.h
index 95ac197..630fca7 100644
--- a/services/camera/libcameraservice/CameraService.h
+++ b/services/camera/libcameraservice/CameraService.h
@@ -27,17 +27,18 @@
 
 namespace android {
 
+extern volatile int32_t gLogLevel;
+
 class MemoryHeapBase;
 class MediaPlayer;
-class CameraHardwareInterface;
 
 class CameraService :
     public BinderService<CameraService>,
     public BnCameraService
 {
-    class Client;
     friend class BinderService<CameraService>;
 public:
+    class Client;
     static char const* getServiceName() { return "media.camera"; }
 
                         CameraService();
@@ -68,6 +69,68 @@
     void                playSound(sound_kind kind);
     void                releaseSound();
 
+    class Client : public BnCamera
+    {
+    public:
+        // ICamera interface (see ICamera for details)
+        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);
+        ~Client();
+
+        // return our camera client
+        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);
+
+        // 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
+        sp<ICameraClient>               mCameraClient;
+        int                             mCameraId;       // immutable after constructor
+        int                             mCameraFacing;   // immutable after constructor
+        pid_t                           mClientPid;
+
+    };
+
 private:
     Mutex               mServiceLock;
     wp<Client>          mClient[MAX_CAMERAS];  // protected by mServiceLock
@@ -86,147 +149,6 @@
     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();
-
-        // 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);
-        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);
-
-        // these are initialized in the constructor.
-        sp<CameraService>               mCameraService;  // immutable after constructor
-        sp<ICameraClient>               mCameraClient;
-        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;
-
-        // 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);
-    };
-
     camera_module_t *mModule;
 };
 
diff --git a/services/camera/libcameraservice/CannedJpeg.h b/services/camera/libcameraservice/CannedJpeg.h
deleted file mode 100644
index 6dd99c1..0000000
--- 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 f3a6a67..0000000
--- 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 724de20..0000000
--- 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/MediaConsumer.cpp b/services/camera/libcameraservice/MediaConsumer.cpp
new file mode 100644
index 0000000..0d857cf
--- /dev/null
+++ b/services/camera/libcameraservice/MediaConsumer.cpp
@@ -0,0 +1,196 @@
+/*
+ * 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 "MediaConsumer"
+#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <utils/Log.h>
+
+#include "MediaConsumer.h"
+
+#define MC_LOGV(x, ...) ALOGV("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define MC_LOGD(x, ...) ALOGD("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define MC_LOGI(x, ...) ALOGI("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define MC_LOGW(x, ...) ALOGW("[%s] "x, mName.string(), ##__VA_ARGS__)
+#define MC_LOGE(x, ...) ALOGE("[%s] "x, mName.string(), ##__VA_ARGS__)
+
+namespace android {
+
+// Get an ID that's unique within this process.
+static int32_t createProcessUniqueId() {
+    static volatile int32_t globalCounter = 0;
+    return android_atomic_inc(&globalCounter);
+}
+
+MediaConsumer::MediaConsumer(uint32_t maxLockedBuffers) :
+    mMaxLockedBuffers(maxLockedBuffers),
+    mCurrentLockedBuffers(0)
+{
+    mName = String8::format("mc-unnamed-%d-%d", getpid(),
+            createProcessUniqueId());
+
+    mBufferQueue = new BufferQueue(true);
+
+    wp<BufferQueue::ConsumerListener> listener;
+    sp<BufferQueue::ConsumerListener> proxy;
+    listener = static_cast<BufferQueue::ConsumerListener*>(this);
+    proxy = new BufferQueue::ProxyConsumerListener(listener);
+
+    status_t err = mBufferQueue->consumerConnect(proxy);
+    if (err != NO_ERROR) {
+        ALOGE("MediaConsumer: error connecting to BufferQueue: %s (%d)",
+                strerror(-err), err);
+    } else {
+        mBufferQueue->setSynchronousMode(true);
+        mBufferQueue->setConsumerUsageBits(GRALLOC_USAGE_HW_VIDEO_ENCODER);
+        mBufferQueue->setConsumerName(mName);
+    }
+}
+
+MediaConsumer::~MediaConsumer()
+{
+    Mutex::Autolock _l(mMutex);
+    for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
+        freeBufferLocked(i);
+    }
+    mBufferQueue->consumerDisconnect();
+    mBufferQueue.clear();
+}
+
+void MediaConsumer::setName(const String8& name) {
+    Mutex::Autolock _l(mMutex);
+    mName = name;
+    mBufferQueue->setConsumerName(name);
+}
+
+status_t MediaConsumer::getNextBuffer(buffer_handle_t *buffer, nsecs_t *timestamp) {
+    status_t err;
+
+    if (!buffer) return BAD_VALUE;
+    if (mCurrentLockedBuffers == mMaxLockedBuffers) {
+        return INVALID_OPERATION;
+    }
+
+    BufferQueue::BufferItem b;
+
+    Mutex::Autolock _l(mMutex);
+
+    err = mBufferQueue->acquireBuffer(&b);
+    if (err != OK) {
+        if (err == BufferQueue::NO_BUFFER_AVAILABLE) {
+            return BAD_VALUE;
+        } else {
+            MC_LOGE("Error acquiring buffer: %s (%d)", strerror(err), err);
+            return err;
+        }
+    }
+
+    int buf = b.mBuf;
+
+    if (b.mGraphicBuffer != NULL) {
+        mBufferSlot[buf] = b.mGraphicBuffer;
+    }
+
+    if (b.mFence.get()) {
+        err = b.mFence->wait(Fence::TIMEOUT_NEVER);
+        if (err != OK) {
+            MC_LOGE("Failed to wait for fence of acquired buffer: %s (%d)",
+                    strerror(-err), err);
+            return err;
+        }
+    }
+
+    *buffer = mBufferSlot[buf]->handle;
+    *timestamp = b.mTimestamp;
+
+    mCurrentLockedBuffers++;
+
+    return OK;
+}
+
+status_t MediaConsumer::freeBuffer(buffer_handle_t buffer) {
+    Mutex::Autolock _l(mMutex);
+    int buf = 0;
+    status_t err;
+
+    for (; buf < BufferQueue::NUM_BUFFER_SLOTS; buf++) {
+        if (buffer == mBufferSlot[buf]->handle) break;
+    }
+    if (buf == BufferQueue::NUM_BUFFER_SLOTS) {
+        MC_LOGE("%s: Can't find buffer to free", __FUNCTION__);
+        return BAD_VALUE;
+    }
+
+    err = mBufferQueue->releaseBuffer(buf, EGL_NO_DISPLAY, EGL_NO_SYNC_KHR,
+            Fence::NO_FENCE);
+    if (err == BufferQueue::STALE_BUFFER_SLOT) {
+        freeBufferLocked(buf);
+    } else if (err != OK) {
+        MC_LOGE("%s: Unable to release graphic buffer %d to queue", __FUNCTION__,
+                buf);
+        return err;
+    }
+
+    mCurrentLockedBuffers--;
+
+    return OK;
+}
+
+void MediaConsumer::setFrameAvailableListener(
+        const sp<FrameAvailableListener>& listener) {
+    MC_LOGV("setFrameAvailableListener");
+    Mutex::Autolock lock(mMutex);
+    mFrameAvailableListener = listener;
+}
+
+
+void MediaConsumer::onFrameAvailable() {
+    MC_LOGV("onFrameAvailable");
+    sp<FrameAvailableListener> listener;
+    { // scope for the lock
+        Mutex::Autolock _l(mMutex);
+        listener = mFrameAvailableListener;
+    }
+
+    if (listener != NULL) {
+        MC_LOGV("actually calling onFrameAvailable");
+        listener->onFrameAvailable();
+    }
+}
+
+void MediaConsumer::onBuffersReleased() {
+    MC_LOGV("onBuffersReleased");
+
+    Mutex::Autolock lock(mMutex);
+
+    uint32_t mask = 0;
+    mBufferQueue->getReleasedBuffers(&mask);
+    for (int i = 0; i < BufferQueue::NUM_BUFFER_SLOTS; i++) {
+        if (mask & (1 << i)) {
+            freeBufferLocked(i);
+        }
+    }
+
+}
+
+status_t MediaConsumer::freeBufferLocked(int buf) {
+    status_t err = OK;
+
+    mBufferSlot[buf] = NULL;
+    return err;
+}
+
+} // namespace android
diff --git a/services/camera/libcameraservice/MediaConsumer.h b/services/camera/libcameraservice/MediaConsumer.h
new file mode 100644
index 0000000..3377d94
--- /dev/null
+++ b/services/camera/libcameraservice/MediaConsumer.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_MEDIACONSUMER_H
+#define ANDROID_SERVERS_CAMERA_MEDIACONSUMER_H
+
+#include <gui/BufferQueue.h>
+
+#include <ui/GraphicBuffer.h>
+
+#include <utils/String8.h>
+#include <utils/Vector.h>
+#include <utils/threads.h>
+
+#define ANDROID_GRAPHICS_MEDIACONSUMER_JNI_ID "mMediaConsumer"
+
+namespace android {
+
+/**
+ * MediaConsumer is a BufferQueue consumer endpoint that makes it
+ * straightforward to bridge Camera 2 to the existing media recording framework.
+ * This queue is synchronous by default.
+ *
+ * TODO: This is a temporary replacement for the full camera->media recording
+ * path using SurfaceMediaEncoder or equivalent.
+ */
+
+class MediaConsumer: public virtual RefBase,
+                     protected BufferQueue::ConsumerListener
+{
+  public:
+    struct FrameAvailableListener : public virtual RefBase {
+        // onFrameAvailable() is called each time an additional frame becomes
+        // available for consumption. A new frame queued will always trigger the
+        // callback, whether the queue is empty or not.
+        //
+        // This is called without any lock held and can be called concurrently
+        // by multiple threads.
+        virtual void onFrameAvailable() = 0;
+    };
+
+    // Create a new media consumer. The maxBuffers parameter specifies
+    // how many buffers can be locked for user access at the same time.
+    MediaConsumer(uint32_t maxBuffers);
+
+    virtual ~MediaConsumer();
+
+    // set the name of the MediaConsumer that will be used to identify it in
+    // log messages.
+    void setName(const String8& name);
+
+    // Gets the next graphics buffer from the producer. Returns BAD_VALUE if no
+    // new buffer is available, and INVALID_OPERATION if the maximum number of
+    // buffers is already in use.
+    //
+    // Only a fixed number of buffers can be available at a time, determined by
+    // the construction-time maxBuffers parameter. If INVALID_OPERATION is
+    // returned by getNextBuffer, then old buffers must be returned to the
+    // queue by calling freeBuffer before more buffers can be acquired.
+    status_t getNextBuffer(buffer_handle_t *buffer, nsecs_t *timestamp);
+
+    // Returns a buffer to the queue, allowing it to be reused. Since
+    // only a fixed number of buffers may be locked at a time, old buffers must
+    // be released by calling unlockBuffer to ensure new buffers can be acquired by
+    // lockNextBuffer.
+    status_t freeBuffer(buffer_handle_t buffer);
+
+    // setFrameAvailableListener sets the listener object that will be notified
+    // when a new frame becomes available.
+    void setFrameAvailableListener(const sp<FrameAvailableListener>& listener);
+
+    sp<ISurfaceTexture> getProducerInterface() const { return mBufferQueue; }
+  protected:
+
+    // Implementation of the BufferQueue::ConsumerListener interface.  These
+    // calls are used to notify the MediaConsumer of asynchronous events in the
+    // BufferQueue.
+    virtual void onFrameAvailable();
+    virtual void onBuffersReleased();
+
+  private:
+    // Free local buffer state
+    status_t freeBufferLocked(int buf);
+
+    // Maximum number of buffers that can be locked at a time
+    uint32_t mMaxLockedBuffers;
+
+    // mName is a string used to identify the SurfaceTexture in log messages.
+    // It can be set by the setName method.
+    String8 mName;
+
+    // mFrameAvailableListener is the listener object that will be called when a
+    // new frame becomes available. If it is not NULL it will be called from
+    // queueBuffer.
+    sp<FrameAvailableListener> mFrameAvailableListener;
+
+    // Underlying buffer queue
+    sp<BufferQueue> mBufferQueue;
+
+    // Array for caching buffers from the buffer queue
+    sp<GraphicBuffer> mBufferSlot[BufferQueue::NUM_BUFFER_SLOTS];
+    // Count of currently outstanding buffers
+    uint32_t mCurrentLockedBuffers;
+
+    // mMutex is the mutex used to prevent concurrent access to the member
+    // variables of MediaConsumer objects. It must be locked whenever the
+    // member variables are accessed.
+    mutable Mutex mMutex;
+};
+
+} // namespace android
+
+#endif // ANDROID_SERVERS_CAMERA_MEDIACONSUMER_H