Move codec code out of omx plugin directories
separate actual codec code for amrnb, amrwb, m4v_h263, and mp3dec from
the OMX plugins.
Bug: 147679485
Test: build
Change-Id: I8b6005384872e667cdcf5f700a848beba355a395
diff --git a/media/codecs/mp3dec/Android.bp b/media/codecs/mp3dec/Android.bp
new file mode 100644
index 0000000..1acf0a6
--- /dev/null
+++ b/media/codecs/mp3dec/Android.bp
@@ -0,0 +1,115 @@
+cc_library_static {
+ name: "libstagefright_mp3dec",
+ vendor_available: true,
+ min_sdk_version: "29",
+
+ host_supported:true,
+ srcs: [
+ "src/pvmp3_normalize.cpp",
+ "src/pvmp3_alias_reduction.cpp",
+ "src/pvmp3_crc.cpp",
+ "src/pvmp3_decode_header.cpp",
+ "src/pvmp3_decode_huff_cw.cpp",
+ "src/pvmp3_getbits.cpp",
+ "src/pvmp3_dequantize_sample.cpp",
+ "src/pvmp3_framedecoder.cpp",
+ "src/pvmp3_get_main_data_size.cpp",
+ "src/pvmp3_get_side_info.cpp",
+ "src/pvmp3_get_scale_factors.cpp",
+ "src/pvmp3_mpeg2_get_scale_data.cpp",
+ "src/pvmp3_mpeg2_get_scale_factors.cpp",
+ "src/pvmp3_mpeg2_stereo_proc.cpp",
+ "src/pvmp3_huffman_decoding.cpp",
+ "src/pvmp3_huffman_parsing.cpp",
+ "src/pvmp3_tables.cpp",
+ "src/pvmp3_imdct_synth.cpp",
+ "src/pvmp3_mdct_6.cpp",
+ "src/pvmp3_dct_6.cpp",
+ "src/pvmp3_poly_phase_synthesis.cpp",
+ "src/pvmp3_equalizer.cpp",
+ "src/pvmp3_seek_synch.cpp",
+ "src/pvmp3_stereo_proc.cpp",
+ "src/pvmp3_reorder.cpp",
+
+ "src/pvmp3_polyphase_filter_window.cpp",
+ "src/pvmp3_mdct_18.cpp",
+ "src/pvmp3_dct_9.cpp",
+ "src/pvmp3_dct_16.cpp",
+ ],
+
+ arch: {
+ arm: {
+ exclude_srcs: [
+ "src/pvmp3_polyphase_filter_window.cpp",
+ "src/pvmp3_mdct_18.cpp",
+ "src/pvmp3_dct_9.cpp",
+ "src/pvmp3_dct_16.cpp",
+ ],
+ srcs: [
+ "src/asm/pvmp3_polyphase_filter_window_gcc.s",
+ "src/asm/pvmp3_mdct_18_gcc.s",
+ "src/asm/pvmp3_dct_9_gcc.s",
+ "src/asm/pvmp3_dct_16_gcc.s",
+ ],
+
+ instruction_set: "arm",
+ },
+ },
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ cfi: true,
+ },
+
+ include_dirs: ["frameworks/av/media/libstagefright/include"],
+
+ export_include_dirs: [
+ "include",
+ "src",
+ ],
+
+ cflags: [
+ "-DOSCL_UNUSED_ARG(x)=(void)(x)",
+ "-Werror",
+ ],
+
+ target: {
+ darwin: {
+ enabled: false,
+ },
+ },
+}
+
+//###############################################################################
+cc_test {
+ name: "libstagefright_mp3dec_test",
+ gtest: false,
+
+ srcs: [
+ "test/mp3dec_test.cpp",
+ "test/mp3reader.cpp",
+ ],
+
+ cflags: ["-Wall", "-Werror"],
+
+ local_include_dirs: [
+ "src",
+ "include",
+ ],
+
+ sanitize: {
+ misc_undefined: [
+ "signed-integer-overflow",
+ ],
+ cfi: true,
+ },
+
+ static_libs: [
+ "libstagefright_mp3dec",
+ "libsndfile",
+ ],
+
+ shared_libs: ["libaudioutils"],
+}
diff --git a/media/codecs/mp3dec/MODULE_LICENSE_APACHE2 b/media/codecs/mp3dec/MODULE_LICENSE_APACHE2
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/media/codecs/mp3dec/MODULE_LICENSE_APACHE2
diff --git a/media/codecs/mp3dec/NOTICE b/media/codecs/mp3dec/NOTICE
new file mode 100644
index 0000000..c5b1efa
--- /dev/null
+++ b/media/codecs/mp3dec/NOTICE
@@ -0,0 +1,190 @@
+
+ Copyright (c) 2005-2008, The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
diff --git a/media/codecs/mp3dec/TEST_MAPPING b/media/codecs/mp3dec/TEST_MAPPING
new file mode 100644
index 0000000..4ef4317
--- /dev/null
+++ b/media/codecs/mp3dec/TEST_MAPPING
@@ -0,0 +1,9 @@
+// mappings for frameworks/av/media/libstagefright/codecs/mp3dec
+{
+ // tests which require dynamic content
+ // invoke with: atest -- --enable-module-dynamic-download=true
+ // TODO(b/148094059): unit tests not allowed to download content
+ "dynamic-presubmit": [
+ { "name": "Mp3DecoderTest"}
+ ]
+}
diff --git a/media/codecs/mp3dec/fuzzer/Android.bp b/media/codecs/mp3dec/fuzzer/Android.bp
new file mode 100644
index 0000000..79fa1e9
--- /dev/null
+++ b/media/codecs/mp3dec/fuzzer/Android.bp
@@ -0,0 +1,39 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2020 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.
+ *
+ *****************************************************************************
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
+ */
+
+cc_fuzz {
+ name: "mp3_dec_fuzzer",
+ host_supported: true,
+
+ static_libs: [
+ "libstagefright_mp3dec",
+ ],
+
+ srcs: [
+ "mp3_dec_fuzzer.cpp",
+ ],
+
+ fuzz_config: {
+ cc: [
+ "android-media-fuzzing-reports@google.com",
+ ],
+ componentid: 155276,
+ },
+}
diff --git a/media/codecs/mp3dec/fuzzer/README.md b/media/codecs/mp3dec/fuzzer/README.md
new file mode 100644
index 0000000..09dd5c3
--- /dev/null
+++ b/media/codecs/mp3dec/fuzzer/README.md
@@ -0,0 +1,56 @@
+# Fuzzer for libstagefright_mp3dec decoder
+
+## Plugin Design Considerations
+The fuzzer plugin for mp3 decoder is designed based on the understanding of the
+codec and tries to achieve the following:
+
+##### Maximize code coverage
+
+This fuzzer makes use of the following config parameters:
+1. Equalizer type (parameter name: `equalizerType`)
+
+| Parameter| Valid Values| Configured Value|
+|------------- |-------------| ----- |
+| `equalizerType` | 0. `flat ` 1. `bass_boost ` 2. `rock ` 3. `pop ` 4. `jazz ` 5. `classical ` 6. `talk ` 7. `flat_ ` | Bits 0, 1 and 2 of first byte of input stream |
+| `crcEnabled` | 0. `false ` 1. `true `| Bit 0 of second byte of input stream |
+
+##### Maximize utilization of input data
+The plugin feeds the entire input data to the codec using a loop.
+ * If the decode operation was successful, the input is advanced by the number
+ of bytes used by the decoder.
+ * If the decode operation was un-successful, the input is advanced by 1 byte
+ till it reaches a valid frame or end of stream.
+
+This ensures that the plugin tolerates any kind of input (empty, huge,
+malformed, etc) and doesnt `exit()` on any input and thereby increasing the
+chance of identifying vulnerabilities.
+
+## Build
+
+This describes steps to build mp3_dec_fuzzer binary.
+
+### Android
+
+#### Steps to build
+Build the fuzzer
+```
+ $ mm -j$(nproc) mp3_dec_fuzzer
+```
+
+#### Steps to run
+Create a directory CORPUS_DIR and copy some mp3 files to that folder.
+Push this directory to device.
+
+To run on device
+```
+ $ adb sync data
+ $ adb shell /data/fuzz/arm64/mp3_dec_fuzzer/mp3_dec_fuzzer CORPUS_DIR
+```
+To run on host
+```
+ $ $ANDROID_HOST_OUT/fuzz/x86_64/mp3_dec_fuzzer/mp3_dec_fuzzer CORPUS_DIR
+```
+
+## References:
+ * http://llvm.org/docs/LibFuzzer.html
+ * https://github.com/google/oss-fuzz
diff --git a/media/codecs/mp3dec/fuzzer/mp3_dec_fuzzer.cpp b/media/codecs/mp3dec/fuzzer/mp3_dec_fuzzer.cpp
new file mode 100644
index 0000000..847c8c4
--- /dev/null
+++ b/media/codecs/mp3dec/fuzzer/mp3_dec_fuzzer.cpp
@@ -0,0 +1,237 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2020 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.
+ *
+ *****************************************************************************
+ * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
+ */
+
+#include <stdlib.h>
+#include <algorithm>
+
+#include <pvmp3decoder_api.h>
+
+constexpr int kMaxFrameSamples = 4608;
+constexpr int kMaxChannels = 2;
+constexpr e_equalization kEqualizerTypes[] = {flat, bass_boost, rock, pop,
+ jazz, classical, talk, flat_};
+
+static bool parseMp3Header(uint32_t header, size_t *frame_size,
+ uint32_t *out_sampling_rate = nullptr, uint32_t *out_channels = nullptr,
+ uint32_t *out_bitrate = nullptr, uint32_t *out_num_samples = nullptr) {
+ *frame_size = 0;
+ if (out_sampling_rate) *out_sampling_rate = 0;
+ if (out_channels) *out_channels = 0;
+ if (out_bitrate) *out_bitrate = 0;
+ if (out_num_samples) *out_num_samples = 0;
+
+ if ((header & 0xffe00000) != 0xffe00000) {
+ return false;
+ }
+ unsigned version = (header >> 19) & 3;
+ if (version == 0x01) {
+ return false;
+ }
+ unsigned layer = (header >> 17) & 3;
+ if (layer == 0x00) {
+ return false;
+ }
+ unsigned bitrate_index = (header >> 12) & 0x0f;
+ if (bitrate_index == 0 || bitrate_index == 0x0f) {
+ return false;
+ }
+ unsigned sampling_rate_index = (header >> 10) & 3;
+ if (sampling_rate_index == 3) {
+ return false;
+ }
+ static const int kSamplingRateV1[] = {44100, 48000, 32000};
+ int sampling_rate = kSamplingRateV1[sampling_rate_index];
+ if (version == 2 /* V2 */) {
+ sampling_rate /= 2;
+ } else if (version == 0 /* V2.5 */) {
+ sampling_rate /= 4;
+ }
+
+ unsigned padding = (header >> 9) & 1;
+
+ if (layer == 3) { // layer I
+ static const int kBitrateV1[] = {32, 64, 96, 128, 160, 192, 224,
+ 256, 288, 320, 352, 384, 416, 448};
+ static const int kBitrateV2[] = {32, 48, 56, 64, 80, 96, 112,
+ 128, 144, 160, 176, 192, 224, 256};
+
+ int bitrate =
+ (version == 3 /* V1 */) ? kBitrateV1[bitrate_index - 1] : kBitrateV2[bitrate_index - 1];
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+ *frame_size = (12000 * bitrate / sampling_rate + padding) * 4;
+ if (out_num_samples) {
+ *out_num_samples = 384;
+ }
+ } else { // layer II or III
+ static const int kBitrateV1L2[] = {32, 48, 56, 64, 80, 96, 112,
+ 128, 160, 192, 224, 256, 320, 384};
+ static const int kBitrateV1L3[] = {32, 40, 48, 56, 64, 80, 96,
+ 112, 128, 160, 192, 224, 256, 320};
+ static const int kBitrateV2[] = {8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160};
+ int bitrate;
+ if (version == 3 /* V1 */) {
+ bitrate =
+ (layer == 2 /* L2 */) ? kBitrateV1L2[bitrate_index - 1] : kBitrateV1L3[bitrate_index - 1];
+
+ if (out_num_samples) {
+ *out_num_samples = 1152;
+ }
+ } else { // V2 (or 2.5)
+ bitrate = kBitrateV2[bitrate_index - 1];
+ if (out_num_samples) {
+ *out_num_samples = (layer == 1 /* L3 */) ? 576 : 1152;
+ }
+ }
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+
+ if (version == 3 /* V1 */) {
+ *frame_size = 144000 * bitrate / sampling_rate + padding;
+ } else { // V2 or V2.5
+ size_t tmp = (layer == 1 /* L3 */) ? 72000 : 144000;
+ *frame_size = tmp * bitrate / sampling_rate + padding;
+ }
+ }
+
+ if (out_sampling_rate) {
+ *out_sampling_rate = sampling_rate;
+ }
+
+ if (out_channels) {
+ int channel_mode = (header >> 6) & 3;
+ *out_channels = (channel_mode == 3) ? 1 : 2;
+ }
+
+ return true;
+}
+
+static uint32_t U32_AT(const uint8_t *ptr) {
+ return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
+}
+
+static bool checkHeader(uint8 *header, size_t inSize) {
+ size_t frameSize;
+ size_t totalInSize = 0;
+ bool isValidBuffer = false;
+
+ while (totalInSize + 4 < inSize) {
+ isValidBuffer = true;
+ uint32_t val = U32_AT(header + totalInSize);
+ if (!parseMp3Header(val, &frameSize, nullptr, nullptr, nullptr, nullptr)) {
+ return false;
+ }
+ totalInSize += frameSize;
+ }
+
+ return (isValidBuffer);
+}
+
+class Codec {
+ public:
+ Codec() = default;
+ ~Codec() { deInitDecoder(); }
+
+ bool initDecoder();
+ void decodeFrames(uint8_t *data, size_t size);
+ void deInitDecoder();
+
+ private:
+ tPVMP3DecoderExternal *mConfig = nullptr;
+ void *mDecoderBuf = nullptr;
+};
+
+bool Codec::initDecoder() {
+ mConfig = new tPVMP3DecoderExternal{};
+ if (!mConfig) {
+ return false;
+ }
+ size_t decoderBufSize = pvmp3_decoderMemRequirements();
+ mDecoderBuf = malloc(decoderBufSize);
+ if (!mDecoderBuf) {
+ return false;
+ }
+ memset(mDecoderBuf, 0x0, decoderBufSize);
+ pvmp3_InitDecoder(mConfig, mDecoderBuf);
+ return true;
+}
+
+void Codec::decodeFrames(uint8_t *data, size_t size) {
+ uint8_t equalizerTypeValue = (data[0] & 0x7);
+ mConfig->equalizerType = kEqualizerTypes[equalizerTypeValue];
+ mConfig->crcEnabled = data[1] & 0x1;
+
+ while (size > 0) {
+ bool status = checkHeader(data, size);
+ if (!status) {
+ size--;
+ data++;
+ continue;
+ }
+ size_t outBufSize = kMaxFrameSamples * kMaxChannels;
+ size_t usedBytes = 0;
+ int16_t outputBuf[outBufSize];
+ mConfig->inputBufferCurrentLength = size;
+ mConfig->inputBufferUsedLength = 0;
+ mConfig->inputBufferMaxLength = 0;
+ mConfig->pInputBuffer = data;
+ mConfig->pOutputBuffer = outputBuf;
+ mConfig->outputFrameSize = outBufSize / sizeof(int16_t);
+
+ ERROR_CODE decoderErr;
+ decoderErr = pvmp3_framedecoder(mConfig, mDecoderBuf);
+ if (decoderErr != NO_DECODING_ERROR) {
+ size--;
+ data++;
+ } else {
+ usedBytes = std::min((int32_t)size, mConfig->inputBufferUsedLength);
+ size -= usedBytes;
+ data += usedBytes;
+ }
+ }
+}
+
+void Codec::deInitDecoder() {
+ if (mDecoderBuf) {
+ free(mDecoderBuf);
+ mDecoderBuf = nullptr;
+ }
+ delete mConfig;
+ mConfig = nullptr;
+}
+
+extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
+ if (size < 4) {
+ return 0;
+ }
+ Codec *codec = new Codec();
+ if (!codec) {
+ return 0;
+ }
+ if (codec->initDecoder()) {
+ codec->decodeFrames(const_cast<uint8_t *>(data), size);
+ }
+ delete codec;
+ return 0;
+}
diff --git a/media/codecs/mp3dec/include/mp3_decoder_selection.h b/media/codecs/mp3dec/include/mp3_decoder_selection.h
new file mode 100644
index 0000000..e287433
--- /dev/null
+++ b/media/codecs/mp3dec/include/mp3_decoder_selection.h
@@ -0,0 +1,30 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*! \file mp3_decoder_selection.h
+ * \brief select mp3 decoder
+ *
+ */
+
+#ifndef MP3_DECODER_SELECTION_H
+#define MP3_DECODER_SELECTION_H
+
+
+#define NEW_PV_MP3_DECODER 1 // 1 == PV mp3 decoder
+
+#endif
+
diff --git a/media/codecs/mp3dec/include/pvmp3_audio_type_defs.h b/media/codecs/mp3dec/include/pvmp3_audio_type_defs.h
new file mode 100644
index 0000000..2d94384
--- /dev/null
+++ b/media/codecs/mp3dec/include/pvmp3_audio_type_defs.h
@@ -0,0 +1,77 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_audio_type_defs.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ 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 PVMP3_AUDIO_TYPE_DEFS_H
+#define PVMP3_AUDIO_TYPE_DEFS_H
+
+#include <stdint.h>
+
+typedef int8_t int8;
+typedef uint8_t uint8;
+typedef int16_t int16;
+typedef uint16_t uint16;
+typedef int32_t int32;
+typedef uint32_t uint32;
+typedef int64_t int64;
+typedef uint64_t uint64;
+
+typedef int32_t Int32;
+
+#endif /* PVMP3_AUDIO_TYPE_DEFS_H */
diff --git a/media/codecs/mp3dec/include/pvmp3decoder_api.h b/media/codecs/mp3dec/include/pvmp3decoder_api.h
new file mode 100644
index 0000000..1568e7c
--- /dev/null
+++ b/media/codecs/mp3dec/include/pvmp3decoder_api.h
@@ -0,0 +1,259 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3decoder_api.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines the structure tPVMP3DecoderExternal
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3DECODER_API_H
+#define PVMP3DECODER_API_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3_dec_defs.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
+ ----------------------------------------------------------------------------*/
+ typedef enum
+ {
+ flat = 0,
+ bass_boost = 1,
+ rock = 2,
+ pop = 3,
+ jazz = 4,
+ classical = 5,
+ talk = 6,
+ flat_ = 7
+
+ } e_equalization;
+
+
+
+ typedef enum ERROR_CODE
+ {
+ NO_DECODING_ERROR = 0,
+ UNSUPPORTED_LAYER = 1,
+ UNSUPPORTED_FREE_BITRATE = 2,
+ FILE_OPEN_ERROR = 3, /* error opening file */
+ CHANNEL_CONFIG_ERROR = 4, /* error in channel configuration */
+ SYNTHESIS_WINDOW_ERROR = 5, /* error in synthesis window table */
+ READ_FILE_ERROR = 6, /* error reading input file */
+ SIDE_INFO_ERROR = 7, /* error in side info */
+ HUFFMAN_TABLE_ERROR = 8, /* error in Huffman table */
+ COMMAND_LINE_ERROR = 9, /* error in command line */
+ MEMORY_ALLOCATION_ERROR = 10, /* error allocating memory */
+ NO_ENOUGH_MAIN_DATA_ERROR = 11,
+ SYNCH_LOST_ERROR = 12,
+ OUTPUT_BUFFER_TOO_SMALL = 13 /* output buffer can't hold output */
+ } ERROR_CODE;
+
+ /*----------------------------------------------------------------------------
+ ; STRUCTURES TYPEDEF'S
+ ----------------------------------------------------------------------------*/
+
+ typedef struct
+#ifdef __cplusplus
+ tPVMP3DecoderExternal
+#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.
+ */
+ uint8 *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 MP3 library.
+ */
+ int32 inputBufferCurrentLength;
+
+ /*
+ * INPUT/OUTPUT:
+ * Number of elements used by the library, initially set to zero by
+ * the function pvmp3_resetDecoder(), and modified by each
+ * call to pvmp3_framedecoder().
+ */
+ int32 inputBufferUsedLength;
+
+ /*
+ * OUTPUT:
+ * holds the predicted frame size. It used on the test console, for parsing
+ * purposes.
+ */
+ uint32 CurrentFrameLength;
+
+ /*
+ * INPUT:
+ * This variable holds the type of equalization used
+ *
+ *
+ */
+ e_equalization equalizerType;
+
+
+ /*
+ * 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.
+ */
+ int32 inputBufferMaxLength;
+
+ /*
+ * OUTPUT:
+ * The number of channels decoded from the bitstream.
+ */
+ int16 num_channels;
+
+ /*
+ * OUTPUT:
+ * The number of channels decoded from the bitstream.
+ */
+ int16 version;
+
+ /*
+ * OUTPUT:
+ * The sampling rate decoded from the bitstream, in units of
+ * samples/second.
+ */
+ 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;
+
+ /*
+ * INPUT/OUTPUT:
+ * In: Inform decoder how much more room is available in the output buffer in int16 samples
+ * Out: Size of the output frame in 16-bit words, This value depends on the mp3 version
+ */
+ int32 outputFrameSize;
+
+ /*
+ * INPUT:
+ * Flag to enable/disable crc error checking
+ */
+ int32 crcEnabled;
+
+ /*
+ * OUTPUT:
+ * This value is used to accumulate bit processed and compute an estimate of the
+ * bitrate. For debugging purposes only, as it will overflow for very long clips
+ */
+ uint32 totalNumberOfBitsUsed;
+
+
+ /*
+ * 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.
+ */
+
+ int16 *pOutputBuffer;
+
+ } tPVMP3DecoderExternal;
+
+uint32 pvmp3_decoderMemRequirements(void);
+
+void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem);
+
+void pvmp3_resetDecoder(void *pMem);
+
+ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
diff --git a/media/codecs/mp3dec/patent_disclaimer.txt b/media/codecs/mp3dec/patent_disclaimer.txt
new file mode 100644
index 0000000..b4bf11d
--- /dev/null
+++ b/media/codecs/mp3dec/patent_disclaimer.txt
@@ -0,0 +1,9 @@
+
+THIS IS NOT A GRANT OF PATENT RIGHTS.
+
+Google makes no representation or warranty that the codecs for which
+source code is made available hereunder are unencumbered by
+third-party patents. Those intending to use this source code in
+hardware or software products are advised that implementations of
+these codecs, including in open source software or shareware, may
+require patent licenses from the relevant patent holders.
diff --git a/media/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s b/media/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s
new file mode 100644
index 0000000..e61c8d3
--- /dev/null
+++ b/media/codecs/mp3dec/src/asm/pvmp3_dct_16_gcc.s
@@ -0,0 +1,476 @@
+@ ------------------------------------------------------------------
+@ Copyright (C) 1998-2009 PacketVideo
+@
+@ Licensed under the Apache License, Version 2.0 (the "License");
+@ you may not use this file except in compliance with the License.
+@ You may obtain a copy of the License at
+@
+@ http://www.apache.org/licenses/LICENSE-2.0
+@
+@ Unless required by applicable law or agreed to in writing, software
+@ distributed under the License is distributed on an "AS IS" BASIS,
+@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+@ express or implied.
+@ See the License for the specific language governing permissions
+@ and limitations under the License.
+@ -------------------------------------------------------------------
+
+@
+@
+@ Filename: pvmp3_dct_16_gcc.s
+@
+@
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who: Date: MM/DD/YYYY
+@ Description:
+@
+@------------------------------------------------------------------------------
+
+.arm
+
+.align 4
+
+.text
+
+.extern pvmp3_dct_16
+.extern pvmp3_merge_in_place_N32
+.extern pvmp3_split
+
+
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_dct_16
+
+pvmp3_dct_16:
+ stmfd sp!,{r0,r1,r4-r11,lr}
+ ldr r1,[r0]
+ ldr r3,[r0,#0x3c]
+ ldr r12,constant1
+ sub r2,r1,r3
+ smull lr,r2,r12,r2
+ sub sp,sp,#0x1c
+ str r2,[sp,#0x14]
+ ldr r2,[r0,#0x1c]
+ ldr r12,[r0,#0x20]
+ add r1,r1,r3
+ sub r3,r2,r12
+ ldr lr,constant2
+ mov r3,r3,lsl #3
+ smull r4,r3,lr,r3
+ ldr r6,constant5
+ str r3,[sp]
+ add r3,r2,r12
+ sub r2,r1,r3
+ ldr r12,constant3
+ add r3,r1,r3
+ smull lr,r2,r12,r2
+ ldr r12,[r0,#0x38]
+ ldr r1,[r0,#4]
+ ldr lr,constant4
+ sub r4,r1,r12
+ add r1,r1,r12
+ ldr r12,[r0,#0x18]
+ smull r4,r5,lr,r4
+ ldr lr,[r0,#0x24]
+ ldr r10,constant10
+ sub r4,r12,lr
+ mov r4,r4,lsl #1
+ smull r7,r4,r6,r4
+ add r12,r12,lr
+ add r7,r1,r12
+ sub r12,r1,r12
+ ldr r1,constant6
+ str r4,[sp,#4]
+ smull r12,r4,r1,r12
+ ldr r1,[r0,#8]
+ ldr r12,[r0,#0x34]
+ ldr r6,constant7
+ sub lr,r1,r12
+ smull r8,lr,r6,lr
+ add r1,r1,r12
+ str lr,[sp,#0x10]
+ ldr r12,[r0,#0x14]
+ ldr lr,[r0,#0x28]
+ ldr r8,constant8
+ sub r6,r12,lr
+ mov r6,r6,lsl #1
+ smull r9,r6,r8,r6
+ add r12,r12,lr
+ ldr r9,constant9
+ add r8,r1,r12
+ sub r12,r1,r12
+ smull r12,lr,r9,r12
+ ldr r12,[r0,#0x30]
+ ldr r1,[r0,#0xc]
+ sub r9,r1,r12
+ smull r11,r9,r10,r9
+ add r12,r1,r12
+ str r9,[sp,#0xc]
+ ldr r9,[r0,#0x10]
+ ldr r10,constant11
+ str r9,[sp,#0x18]
+ ldr r1,[r0,#0x2c]
+ sub r9,r9,r1
+ smull r11,r9,r10,r9
+ ldr r10,constant12
+ str r9,[sp,#8]
+ ldr r9,[sp,#0x18]
+ ldr r11,constant14
+ add r9,r9,r1
+ add r1,r12,r9
+ sub r12,r12,r9
+ mov r12,r12,lsl #2
+ smull r9,r12,r10,r12
+ ldr r10,constant13
+ add r9,r3,r1
+ sub r1,r3,r1
+ smull r1,r3,r10,r1
+ sub r1,r7,r8
+ mov r1,r1,lsl #1
+ smull r1,r10,r11,r1
+ add r1,r7,r8
+ add r8,r9,r1
+ sub r7,r9,r1
+ mov r8,r8,asr #1
+ ldr r1,constant15
+ str r8,[r0]
+ smull r7,r8,r1,r7
+ sub r7,r3,r10
+ str r8,[r0,#0x20]
+ mov r7,r7,lsl #1
+ smull r8,r7,r1,r7
+ add r3,r3,r10
+ add r3,r3,r7
+ str r3,[r0,#0x10]
+ sub r3,r2,r12
+ str r7,[r0,#0x30]
+ add r2,r2,r12
+ ldr r7,constant13
+ sub r12,r4,lr
+ mov r3,r3,lsl #1
+ smull r8,r3,r7,r3
+ add lr,r4,lr
+ sub r4,r2,lr
+ mov r12,r12,lsl #2
+ smull r7,r12,r11,r12
+ add lr,lr,r2
+ sub r2,r3,r12
+ mov r2,r2,lsl #1
+ smull r7,r2,r1,r2
+ mov r4,r4,lsl #1
+ add r12,r12,r2
+ add r3,r12,r3
+ smull r7,r4,r1,r4
+ add r12,r3,lr
+ add r3,r3,r4
+ str r3,[r0,#0x18]
+ add r3,r2,r4
+ str r2,[r0,#0x38]
+ str r3,[r0,#0x28]
+ str r12,[r0,#8]
+ ldr r2,[sp,#0x14]
+ ldr r3,[sp,#0]
+ ldr lr,[sp,#4]
+ sub r2,r2,r3
+ ldr r3,constant3
+ mov r2,r2,lsl #1
+ smull r12,r2,r3,r2
+ ldr r3,[sp,#0x14]
+ ldr r12,[sp,#0]
+ ldr r4,constant6
+ add r12,r3,r12
+ ldr r3,[sp,#4]
+ sub lr,r5,lr
+ mov lr,lr,lsl #1
+ add r3,r5,r3
+ smull r5,lr,r4,lr
+ ldr r4,[sp,#0x10]
+ ldr r5,[sp,#0x10]
+ add r4,r4,r6
+ sub r5,r5,r6
+ ldr r6,constant9
+ mov r5,r5,lsl #1
+ smull r7,r5,r6,r5
+ ldr r6,[sp,#8]
+ ldr r9,[sp,#0xc]
+ ldr r10,constant12
+ sub r6,r9,r6
+ mov r6,r6,lsl #3
+ smull r7,r6,r10,r6
+ ldr r8,[sp,#0x20]
+ ldr r7,[sp,#8]
+ cmp r8,#0
+ add r7,r9,r7
+
+ bne no_flag_proc
+ rsb r12,r12,#0
+ rsb r2,r2,#0
+ rsb r3,r3,#0
+ rsb lr,lr,#0
+ rsb r4,r4,#0
+ rsb r5,r5,#0
+ rsb r7,r7,#0
+ rsb r6,r6,#0
+no_flag_proc:
+
+ sub r8,r2,r6
+ add r2,r6,r2
+ sub r6,r12,r7
+ ldr r9,constant13
+ add r12,r12,r7
+ sub r7,r3,r4
+ mov r6,r6,lsl #1
+ mov r8,r8,lsl #1
+ smull r10,r8,r9,r8
+ add r3,r3,r4
+ smull r10,r6,r9,r6
+ sub r4,lr,r5
+ mov r7,r7,lsl #2
+ smull r9,r7,r11,r7
+ add lr,lr,r5
+ sub r5,r6,r7
+ add r6,r6,r7
+ sub r7,r12,r3
+ add r3,r12,r3
+ sub r12,r2,lr
+ mov r4,r4,lsl #2
+ smull r9,r4,r11,r4
+ add lr,r2,lr
+ sub r2,r8,r4
+ mov r2,r2,lsl #1
+ mov r5,r5,lsl #1
+ mov r12,r12,lsl #1
+ mov r7,r7,lsl #1
+ smull r9,r5,r1,r5
+ smull r9,r2,r1,r2
+ add r6,r6,r5
+ smull r9,r7,r1,r7
+ smull r9,r12,r1,r12
+ add r1,r4,r2
+ add r1,r1,r8
+ add lr,lr,r1
+ add r3,r3,lr
+ str r3,[r0,#4]
+ add r3,r6,lr
+ str r3,[r0,#0xc]
+ add r1,r1,r12
+ add r3,r6,r1
+ add r1,r7,r1
+ str r1,[r0,#0x1c]
+ str r3,[r0,#0x14]
+ add r1,r12,r2
+ add r3,r7,r1
+ add r1,r5,r1
+ str r1,[r0,#0x2c]
+ str r3,[r0,#0x24]!
+ add r1,r5,r2
+ str r1,[r0,#0x10]
+ str r2,[r0,#0x18]
+ add sp,sp,#0x24
+ ldmfd sp!,{r4-r11,pc}
+
+
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_merge_in_place_N32
+
+
+
+pvmp3_merge_in_place_N32:
+ stmfd sp!,{r4,lr}
+ ldr r1,[r0,#0x1c]
+ ldr r2,[r0,#0x38]
+ str r1,[r0,#0x38]
+ ldr r1,[r0,#0x18]
+ ldr r3,[r0,#0x30]
+ str r1,[r0,#0x30]
+ ldr r12,[r0,#0x14]
+ ldr r1,[r0,#0x28]
+ str r12,[r0,#0x28]
+ ldr r12,[r0,#0x10]
+ ldr lr,[r0,#0x20]
+ str r12,[r0,#0x20]
+ ldr r12,[r0,#0xc]
+ str r12,[r0,#0x18]
+ ldr r12,[r0,#8]
+ str r12,[r0,#0x10]
+ ldr r12,[r0,#4]
+ str r12,[r0,#8]
+ ldr r4,[r0,#0x40]
+ ldr r12,[r0,#0x44]
+ add r4,r4,r12
+ str r4,[r0,#4]
+ str lr,[r0,#0x40]
+ ldr lr,[r0,#0x48]
+ add r12,lr,r12
+ str r12,[r0,#0xc]
+ ldr r12,[r0,#0x4c]
+ add lr,r12,lr
+ str lr,[r0,#0x14]
+ ldr lr,[r0,#0x24]
+ str lr,[r0,#0x48]
+ ldr lr,[r0,#0x50]
+ add r12,lr,r12
+ str r12,[r0,#0x1c]
+ ldr r12,[r0,#0x54]
+ str r1,[r0,#0x50]
+ add lr,r12,lr
+ str lr,[r0,#0x24]
+ ldr r1,[r0,#0x58]
+ ldr r4,[r0,#0x2c]
+ ldr lr,[r0,#0x34]
+ add r12,r1,r12
+ str r12,[r0,#0x2c]
+ ldr r12,[r0,#0x5c]
+ add r1,r12,r1
+ str r1,[r0,#0x34]
+ str r4,[r0,#0x58]
+ ldr r1,[r0,#0x60]
+ ldr r4,[r0,#0x3c]
+ add r12,r1,r12
+ str r12,[r0,#0x3c]
+ ldr r12,[r0,#0x64]
+ add r1,r12,r1
+ str r1,[r0,#0x44]
+ ldr r1,[r0,#0x68]
+ add r12,r1,r12
+ str r12,[r0,#0x4c]
+ ldr r12,[r0,#0x6c]
+ add r1,r12,r1
+ str r1,[r0,#0x54]
+ ldr r1,[r0,#0x70]
+ str r3,[r0,#0x60]
+ add r12,r1,r12
+ str r12,[r0,#0x5c]
+ ldr r3,[r0,#0x74]
+ add r1,r3,r1
+ str r1,[r0,#0x64]
+ str lr,[r0,#0x68]
+ ldr r1,[r0,#0x78]
+ str r2,[r0,#0x70]
+ add r3,r1,r3
+ str r3,[r0,#0x6c]
+ ldr r2,[r0,#0x7c]
+ add r1,r1,r2
+ str r1,[r0,#0x74]
+ str r4,[r0,#0x78]
+ ldmfd sp!,{r4,pc}
+
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_split
+
+
+pvmp3_split:
+ stmfd sp!,{r4,r5,lr}
+ adr r1,constant16
+ ldr r2,[r1]
+ add r2,r1
+ sub r1,r0,#4
+ mov r3,#3
+loop1:
+ ldr r12,[r0]
+ ldr lr,[r1]
+ ldr r4,[r2],#-4
+ add r5,lr,r12
+ sub r12,lr,r12
+ smull r12,lr,r4,r12
+ str r5,[r1],#-4
+ mov r12,r12,lsr #27
+ add r12,r12,lr,lsl #5
+ str r12,[r0],#4
+ ldr r12,[r0]
+ ldr lr,[r1]
+ ldr r4,[r2],#-4
+ add r5,lr,r12
+ sub r12,lr,r12
+ smull r12,lr,r4,r12
+ str r5,[r1],#-4
+ mov r12,r12,lsr #27
+ add r12,r12,lr,lsl #5
+ str r12,[r0],#4
+ subs r3,r3,#1
+ bne loop1
+ mov r3,#5
+loop2:
+ ldr r12,[r0]
+ ldr lr,[r1]
+ ldr r4,[r2],#-4
+ add r5,lr,r12
+ sub r12,lr,r12
+ mov r12,r12,lsl #1
+ smull lr,r12,r4,r12
+ str r5,[r1],#-4
+ str r12,[r0],#4
+ ldr r12,[r0]
+ ldr lr,[r1]
+ ldr r4,[r2],#-4
+ add r5,lr,r12
+ sub r12,lr,r12
+ mov r12,r12,lsl #1
+ smull lr,r12,r4,r12
+ str r5,[r1],#-4
+ str r12,[r0],#4
+ subs r3,r3,#1
+ bne loop2
+ ldmfd sp!,{r4,r5,pc}
+constant1:
+ .word 0x404f4680
+constant2:
+ .word 0x519e4e00
+constant3:
+ .word 0x4140fb80
+constant4:
+ .word 0x42e13c00
+constant5:
+ .word 0x6e3c9300
+constant6:
+ .word 0x4cf8de80
+constant7:
+ .word 0x48919f80
+constant8:
+ .word 0x43e22480
+constant9:
+ .word 0x73326b80
+constant10:
+ .word 0x52cb0e80
+constant11:
+ .word 0x64e24000
+constant12:
+ .word 0x52036780
+constant13:
+ .word 0x4545ea00
+constant14:
+ .word 0x539eba80
+constant15:
+ .word 0x5a827980
+constant16:
+ .word (CosTable_dct32 + 60)-constant16
+
+
+
+CosTable_dct32:
+ .word 0x4013c280
+ .word 0x40b34580
+ .word 0x41fa2d80
+ .word 0x43f93400
+ .word 0x46cc1c00
+ .word 0x4a9d9d00
+ .word 0x4fae3700
+ .word 0x56601e80
+ .word 0x5f4cf700
+ .word 0x6b6fcf00
+ .word 0x07c7d1d8
+ .word 0x095b0350
+ .word 0x0bdf91b0
+ .word 0x107655e0
+ .word 0x1b42c840
+ .word 0x51852300
+
+
diff --git a/media/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s b/media/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s
new file mode 100644
index 0000000..618c50e
--- /dev/null
+++ b/media/codecs/mp3dec/src/asm/pvmp3_dct_9_gcc.s
@@ -0,0 +1,193 @@
+@ ------------------------------------------------------------------
+@ Copyright (C) 1998-2009 PacketVideo
+@
+@ Licensed under the Apache License, Version 2.0 (the "License");
+@ you may not use this file except in compliance with the License.
+@ You may obtain a copy of the License at
+@
+@ http://www.apache.org/licenses/LICENSE-2.0
+@
+@ Unless required by applicable law or agreed to in writing, software
+@ distributed under the License is distributed on an "AS IS" BASIS,
+@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+@ express or implied.
+@ See the License for the specific language governing permissions
+@ and limitations under the License.
+@ -------------------------------------------------------------------
+
+@
+@
+@ Filename: pvmp3_dct_9_gcc.s
+@
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who: Date: MM/DD/YYYY
+@ Description:
+@
+@------------------------------------------------------------------------------
+
+.arm
+
+.align 4
+
+.text
+
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_dct_9
+
+pvmp3_dct_9:
+ stmfd sp!,{r4-r11,lr}
+ ldr r2, [r0, #0x20]
+ ldr r3, [r0, #0]
+ ldr r12,[r0, #4]
+ add r1,r2,r3
+ sub lr,r2,r3
+ ldr r3,[r0, #0x1c]
+ ldr r4,[r0, #0x18]
+ add r2,r3,r12
+ ldr r5,[r0,#8]
+ sub r3,r3,r12
+ add r12,r4,r5
+ sub r4,r4,r5
+ ldr r5,[r0, #0x14]
+ ldr r7,[r0, #0xc]
+ ldr r9,[r0, #0x10]
+ add r6,r5,r7
+ sub r5,r5,r7
+ add r7,r1,r12
+ add r8,r9,r2
+ add r7,r7,r6
+ add r10,r7,r8
+ rsb r7,r8,r7,asr #1
+ str r7,[r0, #0x18]
+ rsb r2,r9,r2,asr #1
+ str r10,[r0,#0]
+ ldr r11,cos_2pi_9
+ rsb r7,r2,#0
+
+ ldr r10,cos_4pi_9
+ mov r9,r1,lsl #1
+ mov r8,r7
+
+@ vec[4] = fxp_mac32_Q32( vec[4], tmp0<<1, cos_2pi_9)@
+
+ smlal r1,r8,r11,r9
+ ldr r11,cos_pi_9
+ mov r1,r9 @@@@@@ !!!!!!
+
+@ vec[8] = fxp_mac32_Q32( vec[8], tmp0<<1, cos_4pi_9)@
+
+ smlal r1,r7,r10,r9
+
+ mov r1,r12,lsl #1
+
+
+@ vec[2] = fxp_mac32_Q32( vec[2], tmp0<<1, cos_pi_9)@
+
+ smlal r9,r2,r11,r9
+ rsb r9,r10,#0
+ ldr r11,cos_5pi_9
+
+ smlal r12,r2,r9,r1
+
+
+
+@ vec[2] = fxp_mac32_Q32( vec[2], tmp2<<1, cos_5pi_9)@
+
+ ldr r9,cos_2pi_9
+ mov r12,r1 @@@@@@ !!!!!!
+ smlal r12,r8,r11,r1
+
+
+@ vec[8] = fxp_mac32_Q32( vec[8], tmp2<<1, cos_2pi_9)@
+
+ smlal r1,r7,r9,r1
+ mov r1,r6,lsl #1
+ smlal r12,r7,r11,r1
+ and r6,r10,r11,asr #14
+ smlal r12,r8,r6,r1
+ ldr r10,cos_11pi_18
+ add r12,r11,r6
+ smlal r1,r2,r12,r1
+ ldr r9,cos_8pi_9
+ str r2,[r0,#8]
+ mov r1,r5,lsl #1
+
+@ vec[8] = fxp_mac32_Q32( vec[8], tmp3<<1, cos_8pi_9)@
+
+ smull r2,r6,r9,r1
+ str r7,[r0,#0x20]
+ mov r2,r4,lsl #1
+ ldr r7,cos_13pi_18
+ smlal r12,r6,r10,r2
+
+ mov r3,r3,lsl #1
+
+@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@
+
+ smlal r12,r6,r7,r3
+ add r4,r5,r4
+ mov r12,lr,lsl #1
+ sub lr,r4,lr
+ ldr r7,cos_17pi_18
+ str r8,[r0, #0x10]
+ ldr r4,cos_pi_6
+
+ mov lr,lr,lsl #1
+
+@ vec[1] = fxp_mac32_Q32( vec[1], tmp8<<1, cos_17pi_18)@
+
+ smlal r8,r6,r7,r12
+
+@ vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8)<<1, cos_pi_6)@
+
+ smull r5,lr,r4,lr
+ str r6,[r0, #4]
+ str lr,[r0, #0xc]
+
+
+@ vec[5] = fxp_mul32_Q32(tmp5<<1, cos_17pi_18)@
+ smull r5,lr,r7,r1
+ rsb r6,r9,#0
+@ vec[5] = fxp_mac32_Q32( vec[5], tmp6<<1, cos_7pi_18)@
+ smlal r5,lr,r6,r2
+@ vec[5] = fxp_mac32_Q32( vec[5], tmp7<<1, cos_pi_6)@
+ smlal r5,lr,r4,r3
+@ vec[5] = fxp_mac32_Q32( vec[5], tmp8<<1, cos_13pi_18)@
+ smlal r5,lr,r10,r12
+ str lr,[r0, #0x14]
+ rsb lr,r10,#0
+
+@ vec[7] = fxp_mul32_Q32(tmp5<<1, cos_5pi_18)@
+ smull r5,r1,lr,r1
+@ vec[7] = fxp_mac32_Q32( vec[7], tmp6<<1, cos_17pi_18)@
+ smlal r2,r1,r7,r2
+@ vec[7] = fxp_mac32_Q32( vec[7], tmp7<<1, cos_pi_6)@
+ smlal r3,r1,r4,r3
+@ vec[7] = fxp_mac32_Q32( vec[7], tmp8<<1, cos_11pi_18)@
+ smlal r12,r1,r9,r12
+ str r1,[r0, #0x1c]
+ ldmfd sp!,{r4-r11,pc}
+cos_2pi_9:
+ .word 0x620dbe80
+cos_4pi_9:
+ .word 0x163a1a80
+cos_pi_9:
+ .word 0x7847d900
+cos_5pi_9:
+ .word 0x87b82700
+cos_8pi_9:
+ .word 0xd438af00
+cos_11pi_18:
+ .word 0xadb92280
+cos_13pi_18:
+ .word 0x91261480
+cos_17pi_18:
+ .word 0x81f1d200
+cos_pi_6:
+ .word 0x6ed9eb80
+
diff --git a/media/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s b/media/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s
new file mode 100644
index 0000000..575acd6
--- /dev/null
+++ b/media/codecs/mp3dec/src/asm/pvmp3_mdct_18_gcc.s
@@ -0,0 +1,357 @@
+@ ------------------------------------------------------------------
+@ Copyright (C) 1998-2009 PacketVideo
+@
+@ Licensed under the Apache License, Version 2.0 (the "License");
+@ you may not use this file except in compliance with the License.
+@ You may obtain a copy of the License at
+@
+@ http://www.apache.org/licenses/LICENSE-2.0
+@
+@ Unless required by applicable law or agreed to in writing, software
+@ distributed under the License is distributed on an "AS IS" BASIS,
+@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+@ express or implied.
+@ See the License for the specific language governing permissions
+@ and limitations under the License.
+@ -------------------------------------------------------------------
+
+@
+@
+@ Filename: pvmp3_dct_18_gcc.s
+@
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who: Date: MM/DD/YYYY
+@ Description:
+@
+@------------------------------------------------------------------------------
+
+.arm
+
+.align 4
+
+.text
+
+.extern pvmp3_dct_9
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_mdct_18
+
+pvmp3_mdct_18:
+ stmfd sp!,{r4-r11,lr}
+ mov r7,r2
+ adr r2,constdata$1
+ mov r6,r1
+ add r3,r2,#0x24
+ add r12,r3,#0x44
+ add r1,r0,#0x44
+ mov r5,r0
+
+@ for ( i=9@ i!=0@ i--)
+@ {
+
+ mov r4,#9
+Loop_1:
+
+@ tmp = *(pt_vec)
+@ tmp1 = *(pt_vec_o)
+
+ ldr lr,[r0] @@ tmp == lr
+ ldr r8,[r3],#4 @@ tmp1 == r8
+
+@ tmp = fxp_mul32_Q32( tmp<<1, *(pt_cos++ ))
+@ tmp1 = fxp_mul32_Q27( tmp1, *(pt_cos_x--))
+
+ mov lr,lr,lsl #1
+ smull r10,lr,r8,lr
+ ldr r8,[r12],#-4
+ ldr r9,[r1]
+ subs r4,r4,#1
+ smull r9,r10,r8,r9
+ mov r8,r9,lsr #27
+ add r8,r8,r10,lsl #5
+
+@ *(pt_vec++) = tmp + tmp1
+@ *(pt_vec_o--) = fxp_mul32_Q28( (tmp - tmp1), *(pt_cos_split++))
+
+ add r9,lr,r8
+ sub r8,lr,r8
+ ldr lr,[r2],#4
+ str r9,[r0],#4
+ smull r8,r9,lr,r8
+ mov lr,r8,lsr #28
+ add lr,lr,r9,lsl #4
+ str lr,[r1],#-4
+ bne Loop_1
+
+@ }
+
+ mov r0,r5 @@ r0 = vec
+ bl pvmp3_dct_9
+ add r0,r5,#0x24 @@ r0 = &vec[9]
+ bl pvmp3_dct_9
+
+ ldr r0,[r5,#0x20]
+ ldr r2,[r5,#0x40]
+ str r0,[r5,#0x40]
+ ldr r0,[r5,#0x1c]
+ ldr r3,[r5,#0x38]
+ str r0,[r5,#0x38]
+ ldr r1,[r5,#0x18]
+ ldr r0,[r5,#0x30]
+ str r1,[r5,#0x30]
+ ldr r12,[r5,#0x14]
+ ldr r1,[r5,#0x28]
+ str r12,[r5,#0x28]
+ ldr r12,[r5,#0x10]
+ str r12,[r5,#0x20]
+ ldr r12,[r5,#0xc]
+ str r12,[r5,#0x18]
+ ldr r12,[r5,#8]
+ str r12,[r5,#0x10]
+ ldr r12,[r5,#4]
+ str r12,[r5,#8]
+ ldr r12,[r5,#0x24]
+ sub r12,r12,r1
+ str r12,[r5,#4]
+ ldr r12,[r5,#0x2c]
+ sub r1,r12,r1
+ str r1,[r5,#0xc]
+ sub r1,r12,r0
+ str r1,[r5,#0x14]
+ ldr r1,[r5,#0x34]
+ sub r0,r1,r0
+ str r0,[r5,#0x1c]
+ sub r0,r1,r3
+ str r0,[r5,#0x24]
+ ldr r1,[r5,#0x3c]
+ sub r3,r1,r3
+ sub r1,r1,r2
+ str r1,[r5,#0x34]
+ str r3,[r5,#0x2c]
+ ldr r1,[r5,#0x44]
+ sub r1,r1,r2
+ str r1,[r5,#0x3c]
+ ldr r12,[r5,#0]
+
+Loop_2:
+ add r1,r5,r4,lsl #2
+ ldr r2,[r1,#0x28]
+ ldr r3,[r6,r4,lsl #2]
+ add r0,r0,r2
+ str r0,[r1,#0x28]
+ ldr lr,[r7,r4,lsl #2]
+ ldr r1,[r1,#4]
+ smlal r0,r3,lr,r0
+ mov r0,r2
+ add r2,r12,r1
+ rsb r2,r2,#0
+ str r3,[r5,r4,lsl #2]
+ str r2,[r6,r4,lsl #2]
+ add r4,r4,#1
+ cmp r4,#6
+ mov r12,r1
+
+ blt Loop_2
+
+ ldr r1,[r5,#0x40]
+ ldr r2,[r6,#0x18]
+ add r3,r0,r1
+ str r3,[r5,#0x40]
+ ldr lr,[r7,r4,lsl #2]
+ mov r3,r3,lsl #1
+ ldr r0,[r5,#0x1c]
+ smlal r3,r2,lr,r3
+ add r3,r12,r0
+ str r2,[r5,#0x18]
+ ldr r2,[r6,#0x1c]
+ rsb r3,r3,#0
+ str r3,[r6,#0x18]
+ ldr r3,[r5,#0x20]
+ add r0,r3,r0
+ rsb r0,r0,#0
+ str r0,[r6,#0x1c]
+ ldr r3,[r5,#0x44]
+ ldr r0,[r6,#0x20]
+ add r3,r3,r1
+ mov r1,r2
+ ldr r10,[r7,#0x1c]
+ mov r2,r3,lsl #1
+ smlal r12,r1,r10,r2
+ str r1,[r5,#0x1c]
+ ldr r1,[r5,#0x20]
+ ldr r3,[r5,#0x24]
+ add r1,r1,r3
+ rsb r1,r1,#0
+ str r1,[r6,#0x20]
+ ldr r1,[r5,#0x44]
+ ldr r3,[r7,#0x20]
+ mov r1,r1,lsl #1
+ smlal r12,r0,r3,r1
+ ldr lr,[r7,#0x24]
+ ldr r3,[r6,#0x24]
+ str r0,[r5,#0x20]
+ smlal r1,r3,lr,r1
+ ldr r0,[r6,#0x40]
+ ldr r12,[r6,#0x44]
+ str r3,[r5,#0x24]
+ ldr r1,[r5,#0x28]
+ ldr r3,[r7,#0x44]
+ mov r1,r1,lsl #1
+ smlal r1,r12,r3,r1
+ ldr r1,[r5,#0x40]
+ str r12,[r5,#0x44]
+ rsb r8,r1,#0
+ str r8,[r5,#0x28]
+ ldr r1,[r5,#0x2c]
+ ldr r3,[r7,#0x40]
+ mov r1,r1,lsl #1
+ smlal r1,r0,r3,r1
+ str r0,[r5,#0x40]
+ ldr r0,[r5,#0x3c]
+ ldr r1,[r6,#0x38]
+ ldr r3,[r6,#0x3c]
+ rsb r9,r0,#0
+ str r9,[r5,#0x2c]
+ ldr r0,[r5,#0x30]
+ ldr r12,[r7,#0x3c]
+ mov r0,r0,lsl #1
+ smlal r0,r3,r12,r0
+ str r3,[r5,#0x3c]
+ ldr r0,[r5,#0x38]
+ rsb r0,r0,#0
+ str r0,[r5,#0x30]
+ ldr r3,[r5,#0x34]
+ ldr r12,[r7,#0x38]
+ mov r3,r3,lsl #1
+ smlal r3,r1,r12,r3
+ mov r0,r0,lsl #1
+ str r1,[r5,#0x38]
+ ldr r4,[r7,#0x34]
+ ldr r1,[r6,#0x34]
+ ldr r3,[r6,#0x30]
+ smlal r0,r1,r4,r0
+ ldr r12,[r6,#0x2c]
+ ldr lr,[r6,#0x28]
+ str r1,[r5,#0x34]
+ ldr r1,[r7,#0x30]
+ mov r0,r9,lsl #1
+ smlal r0,r3,r1,r0
+ mov r0,r8,lsl #1
+ ldr r1,[r7,#0x2c]
+ str r3,[r5,#0x30]
+ smlal r0,r12,r1,r0
+ ldr r0,[r7,#0x28]
+ str r12,[r5,#0x2c]
+ smlal r2,lr,r0,r2
+ str lr,[r5,#0x28]
+ ldr r1,[r6,#4]
+ ldr r12,[r7,#0x48]
+ mov r2,r1,lsl #1
+ ldr r1,[r6,#0x20]
+ ldr r0,[r6,#0]
+ mov r1,r1,lsl #1
+ smull r4,lr,r12,r1
+ ldr r3,[r6,#0x1c]
+ str lr,[r6,#0]
+ ldr r12,[r7,#0x4c]
+ mov r3,r3,lsl #1
+ smull r4,lr,r12,r3
+ mov r0,r0,lsl #1
+ ldr r12,[r7,#0x64]
+ str lr,[r6,#4]
+ smull r4,lr,r12,r2
+ ldr r12,[r7,#0x68]
+ str lr,[r6,#0x1c]
+ smull r4,lr,r12,r0
+ ldr r12,[r7,#0x6c]
+ str lr,[r6,#0x20]
+ smull lr,r0,r12,r0
+ ldr r12,[r7,#0x70]
+ str r0,[r6,#0x24]
+ smull r0,r2,r12,r2
+ ldr r0,[r7,#0x88]
+ str r2,[r6,#0x28]
+ smull r3,r2,r0,r3
+ ldr r0,[r7,#0x8c]
+ str r2,[r6,#0x40]
+ smull r2,r1,r0,r1
+ str r1,[r6,#0x44]
+ ldr r0,[r6,#0x18]
+ ldr lr,[r7,#0x50]
+ mov r1,r0,lsl #1
+ ldr r0,[r6,#0x14]
+ smull r5,r4,lr,r1
+ mov r3,r0,lsl #1
+ ldr r0,[r6,#0x10]
+ mov r12,r0,lsl #1
+ ldr r0,[r6,#0xc]
+ mov r2,r0,lsl #1
+ ldr r0,[r6,#8]
+ str r4,[r6,#8]
+ ldr lr,[r7,#0x54]
+ mov r0,r0,lsl #1
+ smull r5,r4,lr,r3
+ ldr lr,[r7,#0x58]
+ str r4,[r6,#0xc]
+ smull r5,r4,lr,r12
+ ldr lr,[r7,#0x5c]
+ str r4,[r6,#0x10]
+ smull r5,r4,lr,r2
+ ldr lr,[r7,#0x60]
+ str r4,[r6,#0x14]
+ smull r5,r4,lr,r0
+ ldr lr,[r7,#0x74]
+ str r4,[r6,#0x18]
+ smull r4,r0,lr,r0
+ ldr lr,[r7,#0x78]
+ str r0,[r6,#0x2c]
+ smull r0,r2,lr,r2
+ ldr r0,[r7,#0x7c]
+ str r2,[r6,#0x30]
+ smull r12,r2,r0,r12
+ ldr r0,[r7,#0x80]
+ str r2,[r6,#0x34]
+ smull r3,r2,r0,r3
+ ldr r0,[r7,#0x84]
+ str r2,[r6,#0x38]
+ smull r2,r1,r0,r1
+ str r1,[r6,#0x3c]
+ ldmfd sp!,{r4-r11,pc}
+
+@------------------------------------------------------------------------------
+
+constdata$1:
+cosTerms_dct18:
+ .word 0x0807d2b0
+ .word 0x08483ee0
+ .word 0x08d3b7d0
+ .word 0x09c42570
+ .word 0x0b504f30
+ .word 0x0df29440
+ .word 0x12edfb20
+ .word 0x1ee8dd40
+ .word 0x5bca2a00
+cosTerms_1_ov_cos_phi:
+ .word 0x400f9c00
+ .word 0x408d6080
+ .word 0x418dcb80
+ .word 0x431b1a00
+ .word 0x4545ea00
+ .word 0x48270680
+ .word 0x4be25480
+ .word 0x50ab9480
+ .word 0x56ce4d80
+ .word 0x05ebb630
+ .word 0x06921a98
+ .word 0x0771d3a8
+ .word 0x08a9a830
+ .word 0x0a73d750
+ .word 0x0d4d5260
+ .word 0x127b1ca0
+ .word 0x1ea52b40
+ .word 0x5bb3cc80
+
diff --git a/media/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s b/media/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
new file mode 100644
index 0000000..1140ed7
--- /dev/null
+++ b/media/codecs/mp3dec/src/asm/pvmp3_polyphase_filter_window_gcc.s
@@ -0,0 +1,233 @@
+@ ------------------------------------------------------------------
+@ Copyright (C) 1998-2009 PacketVideo
+@
+@ Licensed under the Apache License, Version 2.0 (the "License");
+@ you may not use this file except in compliance with the License.
+@ You may obtain a copy of the License at
+@
+@ http://www.apache.org/licenses/LICENSE-2.0
+@
+@ Unless required by applicable law or agreed to in writing, software
+@ distributed under the License is distributed on an "AS IS" BASIS,
+@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+@ express or implied.
+@ See the License for the specific language governing permissions
+@ and limitations under the License.
+@ -------------------------------------------------------------------
+
+@
+@
+@ Filename: pvmp3_polyphase_filter_window.s
+@
+@------------------------------------------------------------------------------
+@ REVISION HISTORY
+@
+@
+@ Who: Date: MM/DD/YYYY
+@ Description:
+@
+@------------------------------------------------------------------------------
+
+.arm
+
+.align 4
+
+.text
+
+.extern pqmfSynthWin
+.hidden pqmfSynthWin
+
+
+
+@------------------------------------------------------------------------------
+
+.global pvmp3_polyphase_filter_window
+
+pvmp3_polyphase_filter_window:
+ stmfd sp!,{r0-r2,r4-r11,lr}
+
+ sub sp,sp,#4
+ adr r2,PolyPh_filter_coeff
+ ldr r1,[r2]
+ add r1,r2
+ ldr r2,[sp,#0xc]
+
+ sub r2,r2,#1
+ mov r10,#1
+ str r2,[sp]
+
+@ Accumulators r9, r11::> Initialization
+
+Loop_j:
+ mov r9, #0x20
+ mov r11, #0x20
+ mov r4, #0x10
+Loop_i:
+ add r2,r4,r10
+ add r3,r0,r2,lsl #2
+ sub r2,r4,r10
+ ldr r5,[r3]
+ ldr lr,[r1]
+ add r12,r0,r2,lsl #2
+ ldr r6,[r12,#0x780]
+ smlal r2,r9,lr,r5
+ smlal r2,r11,lr,r6
+ ldr r2,[r1,#4]
+ ldr r7,[r12,#0x80]
+ smlal r5,r11,r2,r5
+ smull r6,r5,r2,r6
+ sub r9,r9,r5
+ ldr r5,[r1,#8]
+ ldr r8,[r3,#0x700]
+ add r4,r4,#0x200
+ smlal r6,r9,r5,r7
+ smull r6,r2,r5,r8
+ ldr r5,[r1,#0xc]
+ sub r11,r11,r2
+ smlal r8,r9,r5,r8
+ smlal r7,r11,r5,r7
+ ldr r5,[r3,#0x100]
+ ldr r2,[r1,#0x10]
+ ldr r6,[r12,#0x680]
+ smlal lr,r9,r2,r5
+ smlal lr,r11,r2,r6
+ ldr r2,[r1,#0x14]
+ ldr r7,[r12,#0x180]
+ smlal r5,r11,r2,r5
+ smull r6,r5,r2,r6
+ ldr r6,[r1,#0x18]
+ ldr r8,[r3,#0x600]
+ sub r9,r9,r5
+ smlal r5,r9,r6,r7
+ smull r2,r5,r6,r8
+ ldr r6,[r1,#0x1c]
+ sub r11,r11,r5
+ smlal r8,r9,r6,r8
+ ldr r2,[r1,#0x20]
+ ldr r5,[r3,#0x200]
+ smlal r7,r11,r6,r7
+ ldr r6,[r12,#0x580]
+ smlal lr,r9,r2,r5
+ smlal lr,r11,r2,r6
+ ldr r2,[r1,#0x24]
+ ldr r7,[r12,#0x280]
+ smlal r5,r11,r2,r5
+ smull r6,r5,r2,r6
+ ldr r6,[r1,#0x28]
+ ldr r8,[r3,#0x500]
+ sub r9,r9,r5
+ smlal r5,r9,r6,r7
+ smull r2,r5,r6,r8
+ ldr r6,[r1,#0x2c]
+ sub r11,r11,r5
+
+ smlal r8,r9,r6,r8
+ smlal r7,r11,r6,r7
+ ldr r5,[r3,#0x300]
+ ldr r8,[r1,#0x30]
+ ldr r6,[r12,#0x480]
+ smlal r7,r9,r8,r5
+ smlal r7,r11,r8,r6
+ ldr r8,[r1,#0x34]
+ ldr r12,[r12,#0x380]
+ smlal r5,r11,r8,r5
+ smull r6,r5,r8,r6
+ ldr r6,[r1,#0x38]
+
+
+ ldr r3,[r3,#0x400]
+ sub r9,r9,r5
+ smlal r7,r9,r6,r12
+ smull r8,r7,r6,r3
+ cmp r4,#0x210
+ sub r11,r11,r7
+
+ ldr r2,[r1,#0x3c]
+ add r1,r1,#0x40
+ smlal r3,r9,r2,r3
+ smlal r12,r11,r2,r12
+
+ blt Loop_i
+
+ mov r3,r9, asr #6
+ mov r4,r3, asr #15
+ teq r4,r3, asr #31
+ ldr r12,LOW_16BITS
+ ldr r2,[sp]
+ eorne r3,r12,r3,asr #31
+ ldr r4,[sp,#8]
+ mov r2,r10,lsl r2
+ add r4,r4,r2,lsl #1
+ strh r3,[r4]
+
+ mov r3,r11,asr #6
+ mov r4,r3,asr #15
+ teq r4,r3,asr #31
+ eorne r3,r12,r3,asr #31
+ ldr r12,[sp,#0xc]
+ ldr r11,[sp,#8]
+ rsb r2,r2,r12,lsl #5
+ add r2,r11,r2,lsl #1
+ strh r3,[r2]
+
+ add r10,r10,#1
+ cmp r10,#0x10
+ blt Loop_j
+
+@ Accumulators r4, r5 Initialization
+
+ mov r4,#0x20
+ mov r5,#0x20
+ mov r3,#0x10
+PolyPh_filter_loop2:
+ add r2,r0,r3,lsl #2
+ ldr r12,[r2]
+ ldr r8,[r1]
+ ldr r6,[r2,#0x80]
+ smlal r12,r4,r8,r12
+ ldr r12,[r1,#4]
+ ldr r7,[r2,#0x40]
+ smlal r6,r4,r12,r6
+
+ ldr r12,[r1,#8]
+ ldr r6,[r2,#0x180]
+ smlal r7,r5,r12,r7
+ ldr r12,[r2,#0x100]
+ ldr r7,[r1,#0xc]
+ ldr r2,[r2,#0x140]
+ smlal r12,r4,r7,r12
+ ldr r12,[r1,#0x10]
+ add r3,r3,#0x80
+ smlal r6,r4,r12,r6
+ ldr r6,[r1,#0x14]
+ cmp r3,#0x210
+ smlal r2,r5,r6,r2
+ add r1,r1,#0x18
+
+ blt PolyPh_filter_loop2
+ mov r0,r4,asr #6
+ mov r2,r0,asr #15
+ teq r2,r0,asr #31
+ ldrne r12,LOW_16BITS
+ ldr r1,[sp,#8]
+ eorne r0,r12,r0,asr #31
+ strh r0,[r1,#0]
+ mov r0,r5,asr #6
+ mov r2,r0,asr #15
+ teq r2,r0,asr #31
+ ldrne r12,LOW_16BITS
+ ldr r2,[sp]
+ mov r1,#0x10
+ eorne r0,r12,r0,asr #31
+ ldr r12,[sp,#8]
+ mov r1,r1,lsl r2
+ add r1,r12,r1,lsl #1
+ strh r0,[r1]
+ add sp,sp,#0x10
+ ldmfd sp!,{r4-r11,pc}
+
+PolyPh_filter_coeff:
+ .word pqmfSynthWin-PolyPh_filter_coeff
+LOW_16BITS:
+ .word 0x00007fff
+
diff --git a/media/codecs/mp3dec/src/mp3_mem_funcs.h b/media/codecs/mp3dec/src/mp3_mem_funcs.h
new file mode 100644
index 0000000..46e8022
--- /dev/null
+++ b/media/codecs/mp3dec/src/mp3_mem_funcs.h
@@ -0,0 +1,81 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: mp3_mem_funcs.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+------------------------------------------------------------------------------
+
+
+----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+
+#ifndef MP3_MEM_FUNCS_H
+#define MP3_MEM_FUNCS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include <string.h>
+
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES AND SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+
+#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)
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+
+#endif
diff --git a/media/codecs/mp3dec/src/pv_mp3_huffman.h b/media/codecs/mp3dec/src/pv_mp3_huffman.h
new file mode 100644
index 0000000..31102ea
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3_huffman.h
@@ -0,0 +1,115 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pv_mp3_huffman.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+*/
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+
+#ifndef PV_MP3_HUFFMAN_H
+#define PV_MP3_HUFFMAN_H
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+#include "s_tmp3dec_file.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES AND SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ int32 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ granuleInfo *grInfo,
+ tmp3dec_file *pVars,
+ int32 part2_start,
+ mp3Header *info);
+
+
+ void pvmp3_huffman_quad_decoding(struct huffcodetab *h,
+ int32 *is,
+ tmp3Bits *pMainData);
+
+ void pvmp3_huffman_pair_decoding(struct huffcodetab *h,
+ int32 *is,
+ tmp3Bits *pMainData);
+
+
+ void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h,
+ int32 *is,
+ tmp3Bits *pMainData);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
+
diff --git a/media/codecs/mp3dec/src/pv_mp3dec_fxd_op.h b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op.h
new file mode 100644
index 0000000..f14e2de
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op.h
@@ -0,0 +1,84 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pv_mp3dec_fxd_op.h
+
+ Date: 09/21/2007
+
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This file select the associated fixed point functions with the OS/ARCH.
+
+
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PV_MP3DEC_FXD_OP_H
+#define PV_MP3DEC_FXD_OP_H
+
+#include "pvmp3_audio_type_defs.h"
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
+
+#include "pv_mp3dec_fxd_op_arm.h"
+
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
+
+#include "pv_mp3dec_fxd_op_arm_gcc.h"
+
+#elif (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4))
+
+#include "pv_mp3dec_fxd_op_msc_evc.h"
+
+#else
+
+#ifndef C_EQUIVALENT
+#define C_EQUIVALENT
+#endif
+
+#include "pv_mp3dec_fxd_op_c_equivalent.h"
+
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+#endif /* PV_MP3DEC_FXD_OP_H */
diff --git a/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h
new file mode 100644
index 0000000..76a8229
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm.h
@@ -0,0 +1,203 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm.h
+
+ Date: 08/20/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This file select the associated fixed point functions with the OS/ARCH.
+
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PV_MP3DEC_FXD_OP_ARM
+#define PV_MP3DEC_FXD_OP_ARM
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "pvmp3_audio_type_defs.h"
+
+
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
+
+
+ __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_lo, result64_lo, lsr #30
+ add result64_hi, result64_lo, result64_hi, asl #2
+ }
+ 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);
+ }
+
+
+
+#define Qfmt_31(a) (Int32)(a*0x7FFFFFFF + (a>=0?0.5F:-0.5F))
+
+
+
+ __inline Int32 fxp_mul32_Q32(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_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_lo, result64_lo, lsr #28
+ add result64_hi, result64_lo, result64_hi, asl #4
+ }
+ 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_lo, result64_lo, lsr #27
+ add result64_hi, result64_lo, result64_hi, asl #5
+ }
+ return (result64_hi);
+ }
+
+
+ __inline Int32 fxp_mul32_Q26(Int32 L_var1, Int32 L_var2)
+ {
+
+ Int32 result64_hi;
+ Int32 result64_lo;
+ __asm
+ {
+ smull result64_lo, result64_hi, L_var2, L_var1
+ mov result64_lo, result64_lo, lsr #26
+ add result64_hi, result64_lo, result64_hi, asl #6
+ }
+ return (result64_hi);
+ }
+
+
+
+ __inline Int32 fxp_mac32_Q32(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_msb32_Q32(Int32 L_sub, Int32 L_var1, Int32 L_var2)
+ {
+
+ __asm
+ {
+ smull L_var2, L_var1, L_var2, L_var1
+ sub L_sub, L_sub, L_var1
+ }
+ return L_sub;
+ }
+
+
+ __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_lo, result64_lo, lsr #29
+ add result64_hi, result64_lo, result64_hi, asl #3
+ }
+ return (result64_hi);
+ }
+
+
+ __inline int32 pv_abs(int32 a)
+ {
+ Int32 b;
+ /*
+ b = a - (a<0);
+ a = b ^ sign(b)
+ */
+ __asm
+ {
+ sub b, a, a, lsr #31
+ eor a, b, b, asr #31
+ }
+ return (a);
+ }
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* PV_MP3DEC_FXD_OP_ARM */
+
diff --git a/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h
new file mode 100644
index 0000000..71fbd20
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_arm_gcc.h
@@ -0,0 +1,252 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./cpp/include/pv_mp3dec_fxd_op_arm_gcc.h
+
+ Date: 08/20/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This file select the associated fixed point functions with the OS/ARCH.
+
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PV_MP3DEC_FXD_OP_ARM_GCC_H
+#define PV_MP3DEC_FXD_OP_ARM_GCC_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "pvmp3_audio_type_defs.h"
+
+
+#if (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
+
+#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))
+
+ 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 %1, %1, lsr #30\n\t"
+ "add %0, %1, %0, asl #2"
+ : "=&r*i"(result64_hi),
+ "=&r*i"(result64_lo)
+ : "r"(ra),
+ "r"(rb));
+ return (result64_hi);
+ }
+
+
+ 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_mul32_Q32(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_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 %1, %1, lsr #29\n\t"
+ "add %0, %1, %0, asl #3"
+ : "=&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 %1, %1, lsr #28\n\t"
+ "add %0, %1, %0, asl #4"
+ : "=&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 %1, %1, lsr #27\n\t"
+ "add %0, %1, %0, asl #5"
+ : "=&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 %1, %1, lsr #26\n\t"
+ "add %0, %1, %0, asl #6"
+ : "=&r*i"(result64_hi),
+ "=&r*i"(result64_lo)
+ : "r"(ra),
+ "r"(rb));
+ return (result64_hi);
+
+ }
+
+
+
+ static inline int32 fxp_mac32_Q32(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_msb32_Q32(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);
+ }
+
+
+ __inline int32 pv_abs(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);
+ }
+
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* PV_MP3DEC_FXD_OP_ARM_GCC_H */
+
diff --git a/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h
new file mode 100644
index 0000000..f9d91b1
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_c_equivalent.h
@@ -0,0 +1,133 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./cpp/include/pv_mp3dec_fxd_op_c_equivalent.h
+
+ Date: 12/06/2005
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PV_MP3DEC_FXD_OP_C_EQUIVALENT
+#define PV_MP3DEC_FXD_OP_C_EQUIVALENT
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "pvmp3_audio_type_defs.h"
+#define Qfmt_31(a) (Int32)((float)(a)*(float)0x7FFFFFFF)
+
+#define Qfmt15(x) (Int16)((x)*((Int32)1<<15) + ((x)>=0?0.5F:-0.5F))
+
+
+
+ __attribute__((no_sanitize("integer")))
+ __inline int32 pv_abs(int32 a)
+ {
+ int32 b = (a < 0) ? -a : a;
+ return b;
+ }
+
+
+
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q30(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 30);
+ }
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mac32_Q30(const Int32 a, const Int32 b, Int32 L_add)
+ {
+ return (L_add + (Int32)(((int64)(a) * b) >> 30));
+ }
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q32(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 32);
+ }
+
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q28(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 28);
+ }
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q27(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 27);
+ }
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q26(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 26);
+ }
+
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mac32_Q32(Int32 L_add, const Int32 a, const Int32 b)
+ {
+ return (L_add + (Int32)(((int64)(a) * b) >> 32));
+ }
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_msb32_Q32(Int32 L_sub, const Int32 a, const Int32 b)
+ {
+ return (L_sub - ((Int32)(((int64)(a) * b) >> 32)));
+ }
+
+
+ __attribute__((no_sanitize("integer")))
+ __inline Int32 fxp_mul32_Q29(const Int32 a, const Int32 b)
+ {
+ return (Int32)(((int64)(a) * b) >> 29);
+ }
+
+
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* PV_MP3DEC_FXD_OP_C_EQUIVALENT */
+
+
+
diff --git a/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h
new file mode 100644
index 0000000..271e6b7
--- /dev/null
+++ b/media/codecs/mp3dec/src/pv_mp3dec_fxd_op_msc_evc.h
@@ -0,0 +1,132 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./cpp/include/pv_mp3dec_fxd_op_msc_evc.h
+
+ Date: 08/20/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This file select the associated fixed point functions with the OS/ARCH.
+
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PV_MP3DEC_FXD_OP_MSC_EVC_H
+#define PV_MP3DEC_FXD_OP_MSC_EVC_H
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "pvmp3_audio_type_defs.h"
+
+
+#if (defined(PV_ARM_MSC_EVC_V5)||defined(PV_ARM_MSC_EVC_V4))
+#include "armintr.h"
+#include "cmnintrin.h"
+
+
+ __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));
+ }
+
+
+#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))
+
+#define fxp_mul32_Q32( a, b) _MulHigh( b, a)
+
+
+
+ __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_mac32_Q32(int32 L_add, const int32 a, const int32 b)
+ {
+ return (L_add + _MulHigh(b, a));
+ }
+
+
+ __inline int32 fxp_msb32_Q32(int32 L_sub, const int32 a, const int32 b)
+ {
+ return (L_sub - _MulHigh(b, a));
+ }
+
+
+
+ __inline int32 fxp_mul32_Q29(const int32 a, const int32 b)
+ {
+ return (int32)(((int64)(a) * b) >> 29);
+ }
+
+
+
+ __inline int32 pv_abs(int32 a)
+ {
+ int32 b = (a < 0) ? -a : a;
+ return b;
+ }
+
+
+
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* PV_MP3DEC_FXD_OP_MSC_EVC_H */
+
diff --git a/media/codecs/mp3dec/src/pvmp3_alias_reduction.cpp b/media/codecs/mp3dec/src/pvmp3_alias_reduction.cpp
new file mode 100644
index 0000000..6c8102b
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_alias_reduction.cpp
@@ -0,0 +1,261 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_alias_reduction.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ int32 *input_buffer, Ptr to fequency lines of current channel
+ struct gr_info_s *gr_info, structure with granuke information for the
+ input
+ mp3Header *info mp3 header information
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Alias Reduction
+
+
+
+ Alias reduction before processing by the IMDCT
+
+ Csi +
+ >---------0---------0-------->
+ \ / -
+ Cai \ /
+ \ /
+ \ /
+ \
+ / \
+ Cai / \
+ / \ +
+ >--------0---------0---------->
+ Csi +
+
+ Aliasing Butterfly
+ Alias reduction is not applied to short blocks
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+ 1 ci
+ csi = ---------------- csi = ----------------
+ sqrt( 1 + (ci^2)) sqrt( 1 + (ci^2))
+
+
+ ci = -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037
+
+ ------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_alias_reduction.h"
+#include "pv_mp3dec_fxd_op.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define NUM_BUTTERFLIES 8
+
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const int32 c_signal [ NUM_BUTTERFLIES ] =
+{
+
+ Q31_fmt(0.85749292571254f), Q31_fmt(0.88174199731771f),
+ Q31_fmt(0.94962864910273f), Q31_fmt(0.98331459249179f),
+ Q31_fmt(0.99551781606759f), Q31_fmt(0.99916055817815f),
+ Q31_fmt(0.99989919524445f), Q31_fmt(0.99999315507028f)
+
+};
+
+
+const int32 c_alias [ NUM_BUTTERFLIES ] =
+{
+
+ Q31_fmt(-0.51449575542753f), Q31_fmt(-0.47173196856497f),
+ Q31_fmt(-0.31337745420390f), Q31_fmt(-0.18191319961098f),
+ Q31_fmt(-0.09457419252642f), Q31_fmt(-0.04096558288530f),
+ Q31_fmt(-0.01419856857247f), Q31_fmt(-0.00369997467376f)
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 pvmp3_alias_reduction(int32 *input_buffer, /* Ptr to spec values of current channel */
+ granuleInfo *gr_info,
+ int32 *used_freq_lines,
+ mp3Header *info)
+{
+ int32 *ptr1;
+ int32 *ptr2;
+ int32 *ptr3;
+ int32 *ptr4;
+ const int32 *ptr_csi;
+ const int32 *ptr_csa;
+ int32 sblim;
+
+ int32 i, j;
+
+ *used_freq_lines = fxp_mul32_Q32(*used_freq_lines << 16, (int32)((float)0x7FFFFFFF / (float)18 - 1.0f)) >> 15;
+
+
+ if (gr_info->window_switching_flag && gr_info->block_type == 2)
+ {
+ if (gr_info->mixed_block_flag)
+ {
+ sblim = ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2)) ? 3 : 1;
+ }
+ else
+ {
+ return; /* illegal parameter */
+ }
+ }
+ else
+ {
+ sblim = *used_freq_lines + 1;
+
+ if (sblim > SUBBANDS_NUMBER - 1)
+ {
+ sblim = SUBBANDS_NUMBER - 1; /* default */
+ }
+
+ }
+
+
+ ptr3 = &input_buffer[17];
+ ptr4 = &input_buffer[18];
+ ptr_csi = c_signal;
+ ptr_csa = c_alias;
+
+ /* NUM_BUTTERFLIES (=8) butterflies between each pair of sub-bands*/
+
+ for (i = NUM_BUTTERFLIES >> 1; i != 0; i--)
+ {
+ int32 csi1 = *ptr_csi++;
+ int32 csi2 = *ptr_csi++;
+ int32 csa1 = *ptr_csa++;
+ int32 csa2 = *ptr_csa++;
+
+ ptr1 = ptr3;
+ ptr3 -= 2;
+ ptr2 = ptr4;
+ ptr4 += 2;
+
+ /*
+ * "sblim" alias-reduction operations between each
+ * pair of sub-bands
+ */
+
+ for (j = sblim >> 1; j != 0; j--)
+ {
+ int32 y = *ptr2;
+ int32 x = *ptr1 << 1;
+ *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1);
+ *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1);
+ y = *ptr2;
+ x = *ptr1 << 1;
+ *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2);
+ *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2);
+ ptr1 += 19;
+ ptr2 += 17;
+ y = *ptr2;
+ x = *ptr1 << 1;
+ *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1);
+ *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1);
+ y = *ptr2;
+ x = *ptr1 << 1;
+ *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2);
+ *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2);
+ ptr1 += 19;
+ ptr2 += 17;
+
+ }
+
+ if (sblim & 1)
+ {
+ int32 x = *ptr1 << 1;
+ int32 y = *ptr2;
+ *ptr1-- = fxp_msb32_Q32(fxp_mul32_Q32(x, csi1), y << 1, csa1);
+ *ptr2++ = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi1), x, csa1);
+
+ x = *ptr1 << 1;
+ y = *ptr2;
+ *ptr1 = fxp_msb32_Q32(fxp_mul32_Q32(x, csi2), y << 1, csa2);
+ *ptr2 = fxp_mac32_Q32(fxp_mul32_Q32(y << 1, csi2), x, csa2);
+ }
+ }
+
+}
diff --git a/media/codecs/mp3dec/src/pvmp3_alias_reduction.h b/media/codecs/mp3dec/src/pvmp3_alias_reduction.h
new file mode 100644
index 0000000..2292d5f
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_alias_reduction.h
@@ -0,0 +1,100 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_alias_reduction.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_ALIAS_REDUCTION_H
+#define PVMP3_ALIAS_REDUCTION_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ void pvmp3_alias_reduction(int32 *input_buffer,
+ granuleInfo *gr_info,
+ int32 *used_freq_lines,
+ mp3Header *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_crc.cpp b/media/codecs/mp3dec/src/pvmp3_crc.cpp
new file mode 100644
index 0000000..20d0d82
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_crc.cpp
@@ -0,0 +1,161 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_crc.cpp
+
+ Functions:
+ getbits_crc
+ calculate_crc
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+getbits_crc
+
+Input
+ tbits *inputStream, bit stream structure
+ int32 neededBits, number of bits to read from the bit stream
+ uint32 *crc, memory location holding calculated crc value
+ uint32 crc_enabled flag to enable/disable crc checking
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+calculate_crc
+
+Input
+ uint32 data, data vector
+ uint32 length, number of element upon the crc will be calculated
+ uint32 *crc, memory location holding calculated crc value
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+ ------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_getbits.h"
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+
+uint32 getbits_crc(tmp3Bits *inputStream, /* bit stream structure */
+ int32 neededBits, /* number of bits to read from the bit stream */
+ uint32 *crc,
+ uint32 crc_enabled)
+{
+ uint32 bits = getNbits(inputStream, neededBits);
+
+ if (crc_enabled)
+ {
+ calculate_crc(bits, neededBits, crc);
+ }
+ return(bits);
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+void calculate_crc(uint32 data,
+ uint32 length,
+ uint32 *crc)
+{
+ uint32 carry;
+ uint32 masking = 1 << length;
+
+ while ((masking >>= 1))
+ {
+ carry = *crc & 0x8000;
+ *crc <<= 1;
+ if (!carry ^ !(data & masking))
+ {
+ *crc ^= CRC16_POLYNOMIAL;
+ }
+ }
+ *crc &= 0xffff;
+}
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_crc.h b/media/codecs/mp3dec/src/pvmp3_crc.h
new file mode 100644
index 0000000..b7c277a
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_crc.h
@@ -0,0 +1,110 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_crc.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_CRC_H
+#define PVMP3_CRC_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+#include "pvmp3decoder_api.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define CRC16_POLYNOMIAL 0x8005
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; STRUCTURES TYPEDEF'S
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ uint32 getbits_crc(tmp3Bits *inputStream,
+ int32 neededBits,
+ uint32 *crc,
+ uint32 crc_enabled);
+
+
+ void calculate_crc(uint32 data,
+ uint32 length,
+ uint32 *crc);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_dct_16.cpp b/media/codecs/mp3dec/src/pvmp3_dct_16.cpp
new file mode 100644
index 0000000..cc99d5c
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dct_16.cpp
@@ -0,0 +1,413 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dct_16.cpp
+
+ Functions:
+ dct_16
+ pv_merge_in_place_N32
+ pv_split
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ dct_16
+
+Input
+ int32 vec[], input vector length 16
+ Int flag processing direction: forward (1), backward ( 0)
+ Returns
+
+ int32 vec[], dct length 16
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ pv_merge_in_place_N32
+
+Input
+ int32 vec[], input vector length 16
+
+ Returns
+
+ int32 vec[], merged output of two dct 16 to create a dct 32
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ pv_split
+
+Input
+ int32 vec[], input vector length 16
+
+ Returns
+
+ int32 vec[], splitted even/odd and pre processing rotation
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ dct 16 and tools to assemble a dct32 output
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) )
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dct_16.h"
+#include "pv_mp3dec_fxd_op.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<<27))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const int32 CosTable_dct32[16] =
+{
+ Qfmt_31(0.50060299823520F) , Qfmt_31(0.50547095989754F) ,
+ Qfmt_31(0.51544730992262F) , Qfmt_31(0.53104259108978F) ,
+ Qfmt_31(0.55310389603444F) , Qfmt_31(0.58293496820613F) ,
+ Qfmt_31(0.62250412303566F) , Qfmt_31(0.67480834145501F) ,
+ Qfmt_31(0.74453627100230F) , Qfmt_31(0.83934964541553F) ,
+
+ Qfmt(0.97256823786196F) , Qfmt(1.16943993343288F) ,
+ Qfmt(1.48416461631417F) , Qfmt(2.05778100995341F) ,
+ Qfmt(3.40760841846872F) , Qfmt(10.19000812354803F)
+};
+
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_dct_16(int32 vec[], int32 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_Q32((vec[ 0] - vec[15]), Qfmt_31(0.50241928618816F));
+ tmp0 = vec[ 0] + vec[15];
+
+ tmp_o7 = fxp_mul32_Q32((vec[ 7] - vec[ 8]) << 3, Qfmt_31(0.63764357733614F));
+ tmp7 = vec[ 7] + vec[ 8];
+
+ itmp_e0 = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.50979557910416F));
+ tmp7 = (tmp0 + tmp7);
+
+ tmp_o1 = fxp_mul32_Q32((vec[ 1] - vec[14]), Qfmt_31(0.52249861493969F));
+ tmp1 = vec[ 1] + vec[14];
+
+ tmp_o6 = fxp_mul32_Q32((vec[ 6] - vec[ 9]) << 1, Qfmt_31(0.86122354911916F));
+ tmp6 = vec[ 6] + vec[ 9];
+
+
+
+ itmp_e1 = (tmp1 + tmp6);
+ tmp6 = fxp_mul32_Q32((tmp1 - tmp6), Qfmt_31(0.60134488693505F));
+
+
+
+ tmp_o2 = fxp_mul32_Q32((vec[ 2] - vec[13]), Qfmt_31(0.56694403481636F));
+ tmp2 = vec[ 2] + vec[13];
+ tmp_o5 = fxp_mul32_Q32((vec[ 5] - vec[10]) << 1, Qfmt_31(0.53033884299517F));
+ tmp5 = vec[ 5] + vec[10];
+
+ itmp_e2 = (tmp2 + tmp5);
+ tmp5 = fxp_mul32_Q32((tmp2 - tmp5), Qfmt_31(0.89997622313642F));
+
+ tmp_o3 = fxp_mul32_Q32((vec[ 3] - vec[12]), Qfmt_31(0.64682178335999F));
+ tmp3 = vec[ 3] + vec[12];
+ tmp_o4 = fxp_mul32_Q32((vec[ 4] - vec[11]), Qfmt_31(0.78815462345125F));
+ tmp4 = vec[ 4] + vec[11];
+
+ tmp1 = (tmp3 + tmp4);
+ tmp4 = fxp_mul32_Q32((tmp3 - tmp4) << 2, Qfmt_31(0.64072886193538F));
+
+ /* split even part of tmp_e */
+
+ tmp0 = (tmp7 + tmp1);
+ tmp1 = fxp_mul32_Q32((tmp7 - tmp1), Qfmt_31(0.54119610014620F));
+
+ tmp3 = fxp_mul32_Q32((itmp_e1 - itmp_e2) << 1, Qfmt_31(0.65328148243819F));
+ tmp7 = (itmp_e1 + itmp_e2);
+
+ vec[ 0] = (tmp0 + tmp7) >> 1;
+ vec[ 8] = fxp_mul32_Q32((tmp0 - tmp7), Qfmt_31(0.70710678118655F));
+ tmp0 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
+ vec[ 4] = tmp1 + tmp3 + tmp0;
+ vec[12] = tmp0;
+
+ /* split odd part of tmp_e */
+
+ tmp1 = fxp_mul32_Q32((itmp_e0 - tmp4) << 1, Qfmt_31(0.54119610014620F));
+ tmp7 = itmp_e0 + tmp4;
+
+ tmp3 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
+ tmp6 += tmp5;
+
+ tmp4 = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F));
+ tmp6 += tmp7;
+ tmp7 = fxp_mul32_Q32((tmp1 - tmp3) << 1, Qfmt_31(0.70710678118655F));
+
+ tmp1 += tmp3 + tmp7;
+ vec[ 2] = tmp1 + tmp6;
+ vec[ 6] = tmp1 + tmp4;
+ vec[10] = tmp7 + tmp4;
+ vec[14] = tmp7;
+
+
+ // dct8;
+
+ tmp1 = fxp_mul32_Q32((tmp_o0 - tmp_o7) << 1, Qfmt_31(0.50979557910416F));
+ tmp7 = tmp_o0 + tmp_o7;
+
+ tmp6 = tmp_o1 + tmp_o6;
+ tmp_o1 = fxp_mul32_Q32((tmp_o1 - tmp_o6) << 1, Qfmt_31(0.60134488693505F));
+
+ tmp5 = tmp_o2 + tmp_o5;
+ tmp_o5 = fxp_mul32_Q32((tmp_o2 - tmp_o5) << 1, Qfmt_31(0.89997622313642F));
+
+ tmp0 = fxp_mul32_Q32((tmp_o3 - tmp_o4) << 3, Qfmt_31(0.6407288619354F));
+ tmp4 = tmp_o3 + tmp_o4;
+
+ if (!flag)
+ {
+ tmp7 = -tmp7;
+ tmp1 = -tmp1;
+ tmp6 = -tmp6;
+ tmp_o1 = -tmp_o1;
+ tmp5 = -tmp5;
+ tmp_o5 = -tmp_o5;
+ tmp4 = -tmp4;
+ tmp0 = -tmp0;
+ }
+
+
+ tmp2 = fxp_mul32_Q32((tmp1 - tmp0) << 1, Qfmt_31(0.54119610014620F));
+ tmp0 += tmp1;
+ tmp1 = fxp_mul32_Q32((tmp7 - tmp4) << 1, Qfmt_31(0.54119610014620F));
+ tmp7 += tmp4;
+ tmp4 = fxp_mul32_Q32((tmp6 - tmp5) << 2, Qfmt_31(0.65328148243819F));
+ tmp6 += tmp5;
+ tmp5 = fxp_mul32_Q32((tmp_o1 - tmp_o5) << 2, Qfmt_31(0.65328148243819F));
+ tmp_o1 += tmp_o5;
+
+
+ vec[13] = fxp_mul32_Q32((tmp1 - tmp4) << 1, Qfmt_31(0.70710678118655F));
+ vec[ 5] = tmp1 + tmp4 + vec[13];
+
+ vec[ 9] = fxp_mul32_Q32((tmp7 - tmp6) << 1, Qfmt_31(0.70710678118655F));
+ vec[ 1] = tmp7 + tmp6;
+
+ tmp4 = fxp_mul32_Q32((tmp0 - tmp_o1) << 1, Qfmt_31(0.70710678118655F));
+ tmp0 += tmp_o1;
+ tmp6 = fxp_mul32_Q32((tmp2 - tmp5) << 1, Qfmt_31(0.70710678118655F));
+ tmp2 += tmp5 + tmp6;
+ tmp0 += tmp2;
+
+ vec[ 1] += tmp0;
+ vec[ 3] = tmp0 + vec[ 5];
+ tmp2 += tmp4;
+ vec[ 5] = tmp2 + vec[ 5];
+ vec[ 7] = tmp2 + vec[ 9];
+ tmp4 += tmp6;
+ vec[ 9] = tmp4 + vec[ 9];
+ vec[11] = tmp4 + vec[13];
+ vec[13] = tmp6 + vec[13];
+ vec[15] = tmp6;
+
+}
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+__attribute__((no_sanitize("integer")))
+void pvmp3_merge_in_place_N32(int32 vec[])
+{
+
+
+ int32 temp0;
+ int32 temp1;
+ int32 temp2;
+ int32 temp3;
+
+ temp0 = vec[14];
+ vec[14] = vec[ 7];
+ temp1 = vec[12];
+ vec[12] = vec[ 6];
+ temp2 = vec[10];
+ vec[10] = vec[ 5];
+ temp3 = 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] = temp3;
+ vec[ 3] = (vec[18] + vec[17]);
+ vec[ 5] = (vec[19] + vec[18]);
+ vec[18] = vec[9];
+
+ vec[ 7] = (vec[20] + vec[19]);
+ vec[ 9] = (vec[21] + vec[20]);
+ vec[20] = temp2;
+ temp2 = vec[13];
+ temp3 = vec[11];
+ vec[11] = (vec[22] + vec[21]);
+ vec[13] = (vec[23] + vec[22]);
+ vec[22] = temp3;
+ temp3 = 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[24] = temp1;
+ vec[25] = (vec[29] + vec[28]);
+ vec[26] = temp2;
+ vec[27] = (vec[30] + vec[29]);
+ vec[28] = temp0;
+ vec[29] = (vec[30] + vec[31]);
+ vec[30] = temp3;
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_split(int32 *vect)
+{
+
+ int32 i;
+ const int32 *pt_cosTerms = &CosTable_dct32[15];
+ int32 *pt_vect = vect;
+ int32 *pt_vect_2 = pt_vect - 1;
+
+ for (i = 3; i != 0; i--)
+ {
+ int32 tmp2 = *(pt_vect);
+ int32 tmp1 = *(pt_vect_2);
+ int32 cosx = *(pt_cosTerms--);
+ *(pt_vect_2--) = (tmp1 + tmp2);
+ *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx);
+
+ tmp2 = *(pt_vect);
+ tmp1 = *(pt_vect_2);
+ cosx = *(pt_cosTerms--);
+ *(pt_vect_2--) = (tmp1 + tmp2);
+ *(pt_vect++) = fxp_mul32_Q27((tmp1 - tmp2), cosx);
+
+ }
+
+ for (i = 5; i != 0; i--)
+ {
+ int32 tmp2 = *(pt_vect);
+ int32 tmp1 = *(pt_vect_2);
+ int32 cosx = *(pt_cosTerms--);
+ *(pt_vect_2--) = (tmp1 + tmp2);
+ *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx);
+
+ tmp2 = *(pt_vect);
+ tmp1 = *(pt_vect_2);
+ cosx = *(pt_cosTerms--);
+ *(pt_vect_2--) = (tmp1 + tmp2);
+ *(pt_vect++) = fxp_mul32_Q32((tmp1 - tmp2) << 1, cosx);
+ }
+
+}
+
+#endif
diff --git a/media/codecs/mp3dec/src/pvmp3_dct_16.h b/media/codecs/mp3dec/src/pvmp3_dct_16.h
new file mode 100644
index 0000000..e8bf76e
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dct_16.h
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dct_16.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_DCT_16_H
+#define PVMP3_DCT_16_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ void pvmp3_dct_16(int32 vec[], int32 flag);
+
+ void pvmp3_merge_in_place_N32(int32 vec[]);
+
+ void pvmp3_split(int32 *vect);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_dct_6.cpp b/media/codecs/mp3dec/src/pvmp3_dct_6.cpp
new file mode 100644
index 0000000..c306873
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dct_6.cpp
@@ -0,0 +1,153 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dct6.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ Int32 vec[] vector of 6 32-bit integers
+Returns
+ Int32 vec[] dct computation in-place
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Returns the dct of length 6 of the input vector
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_mdct_6.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define Qfmt30(a) (Int32)((a)*((Int32)1<<30) + ((a)>=0?0.5F:-0.5F))
+
+#define cos_pi_6 Qfmt30( 0.86602540378444f)
+#define cos_2_pi_6 Qfmt30( 0.5f)
+#define cos_7_pi_12 Qfmt30( -0.25881904510252f)
+#define cos_3_pi_12 Qfmt30( 0.70710678118655f)
+#define cos_11_pi_12 Qfmt30( -0.96592582628907f)
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_dct_6(int32 vec[])
+{
+
+ Int32 tmp0;
+ Int32 tmp1;
+ Int32 tmp2;
+ Int32 tmp3;
+ Int32 tmp4;
+ Int32 tmp5;
+
+
+ /* split input vector */
+
+ tmp0 = vec[5] + vec[0];
+ tmp5 = vec[5] - vec[0];
+ tmp1 = vec[4] + vec[1];
+ tmp4 = vec[4] - vec[1];
+ tmp2 = vec[3] + vec[2];
+ tmp3 = vec[3] - vec[2];
+
+ vec[0] = tmp0 + tmp2 ;
+ vec[2] = fxp_mul32_Q30(tmp0 - tmp2, cos_pi_6);
+ vec[4] = (vec[0] >> 1) - tmp1;
+ vec[0] += tmp1;
+
+ tmp0 = fxp_mul32_Q30(tmp3, cos_7_pi_12);
+ tmp0 = fxp_mac32_Q30(tmp4, -cos_3_pi_12, tmp0);
+ vec[1] = fxp_mac32_Q30(tmp5, cos_11_pi_12, tmp0);
+
+ vec[3] = fxp_mul32_Q30((tmp3 + tmp4 - tmp5), cos_3_pi_12);
+ tmp0 = fxp_mul32_Q30(tmp3, cos_11_pi_12);
+ tmp0 = fxp_mac32_Q30(tmp4, cos_3_pi_12, tmp0);
+ vec[5] = fxp_mac32_Q30(tmp5, cos_7_pi_12, tmp0);
+
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_dct_9.cpp b/media/codecs/mp3dec/src/pvmp3_dct_9.cpp
new file mode 100644
index 0000000..9cd0e91
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dct_9.cpp
@@ -0,0 +1,168 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dct_9.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ int32 vec[] vector of 9 32-bit integers
+Returns
+ int32 vec[] dct computation in-place
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Returns the dct of length 9 of the input vector
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_mdct_18.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define Qfmt31(a) (int32)((a)*((float)0x7FFFFFFF))
+
+#define cos_pi_9 Qfmt31( 0.93969262078591f)
+#define cos_2pi_9 Qfmt31( 0.76604444311898f)
+#define cos_4pi_9 Qfmt31( 0.17364817766693f)
+#define cos_5pi_9 Qfmt31(-0.17364817766693f)
+#define cos_7pi_9 Qfmt31(-0.76604444311898f)
+#define cos_8pi_9 Qfmt31(-0.93969262078591f)
+#define cos_pi_6 Qfmt31( 0.86602540378444f)
+#define cos_5pi_6 Qfmt31(-0.86602540378444f)
+#define cos_5pi_18 Qfmt31( 0.64278760968654f)
+#define cos_7pi_18 Qfmt31( 0.34202014332567f)
+#define cos_11pi_18 Qfmt31(-0.34202014332567f)
+#define cos_13pi_18 Qfmt31(-0.64278760968654f)
+#define cos_17pi_18 Qfmt31(-0.98480775301221f)
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_dct_9(int32 vec[])
+{
+
+ /* split input vector */
+
+ int32 tmp0 = vec[8] + vec[0];
+ int32 tmp8 = vec[8] - vec[0];
+ int32 tmp1 = vec[7] + vec[1];
+ int32 tmp7 = vec[7] - vec[1];
+ int32 tmp2 = vec[6] + vec[2];
+ int32 tmp6 = vec[6] - vec[2];
+ int32 tmp3 = vec[5] + vec[3];
+ int32 tmp5 = vec[5] - vec[3];
+
+ vec[0] = (tmp0 + tmp2 + tmp3) + (tmp1 + vec[4]);
+ vec[6] = ((tmp0 + tmp2 + tmp3) >> 1) - (tmp1 + vec[4]);
+ vec[2] = (tmp1 >> 1) - vec[4];
+ vec[4] = -vec[2];
+ vec[8] = -vec[2];
+ vec[4] = fxp_mac32_Q32(vec[4], tmp0 << 1, cos_2pi_9);
+ vec[8] = fxp_mac32_Q32(vec[8], tmp0 << 1, cos_4pi_9);
+ vec[2] = fxp_mac32_Q32(vec[2], tmp0 << 1, cos_pi_9);
+ vec[2] = fxp_mac32_Q32(vec[2], tmp2 << 1, cos_5pi_9);
+ vec[4] = fxp_mac32_Q32(vec[4], tmp2 << 1, cos_8pi_9);
+ vec[8] = fxp_mac32_Q32(vec[8], tmp2 << 1, cos_2pi_9);
+ vec[8] = fxp_mac32_Q32(vec[8], tmp3 << 1, cos_8pi_9);
+ vec[4] = fxp_mac32_Q32(vec[4], tmp3 << 1, cos_4pi_9);
+ vec[2] = fxp_mac32_Q32(vec[2], tmp3 << 1, cos_7pi_9);
+
+ vec[1] = fxp_mul32_Q32(tmp5 << 1, cos_11pi_18);
+ vec[1] = fxp_mac32_Q32(vec[1], tmp6 << 1, cos_13pi_18);
+ vec[1] = fxp_mac32_Q32(vec[1], tmp7 << 1, cos_5pi_6);
+ vec[1] = fxp_mac32_Q32(vec[1], tmp8 << 1, cos_17pi_18);
+ vec[3] = fxp_mul32_Q32((tmp5 + tmp6 - tmp8) << 1, cos_pi_6);
+ vec[5] = fxp_mul32_Q32(tmp5 << 1, cos_17pi_18);
+ vec[5] = fxp_mac32_Q32(vec[5], tmp6 << 1, cos_7pi_18);
+ vec[5] = fxp_mac32_Q32(vec[5], tmp7 << 1, cos_pi_6);
+ vec[5] = fxp_mac32_Q32(vec[5], tmp8 << 1, cos_13pi_18);
+ vec[7] = fxp_mul32_Q32(tmp5 << 1, cos_5pi_18);
+ vec[7] = fxp_mac32_Q32(vec[7], tmp6 << 1, cos_17pi_18);
+ vec[7] = fxp_mac32_Q32(vec[7], tmp7 << 1, cos_pi_6);
+ vec[7] = fxp_mac32_Q32(vec[7], tmp8 << 1, cos_11pi_18);
+
+}
+
+
+
+#endif // If not assembly
diff --git a/media/codecs/mp3dec/src/pvmp3_dec_defs.h b/media/codecs/mp3dec/src/pvmp3_dec_defs.h
new file mode 100644
index 0000000..2be9ab9
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dec_defs.h
@@ -0,0 +1,199 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dec_defs.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file has the mp3 decoder common defines.
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_DEC_DEFS_H
+#define PVMP3_DEC_DEFS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3decoder_api.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+#define module(x, POW2) ((x)&((POW2)-1))
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define BUFSIZE 8192 // big enough to hold 4608 bytes == biggest mp3 frame
+
+#define CHAN 2
+#define GRAN 2
+
+
+#define SUBBANDS_NUMBER 32
+#define FILTERBANK_BANDS 18
+#define HAN_SIZE 512
+
+
+/* MPEG Header Definitions - ID Bit Values */
+
+#define MPEG_1 0
+#define MPEG_2 1
+#define MPEG_2_5 2
+#define INVALID_VERSION (-1)
+
+/* MPEG Header Definitions - Mode Values */
+
+#define MPG_MD_STEREO 0
+#define MPG_MD_JOINT_STEREO 1
+#define MPG_MD_DUAL_CHANNEL 2
+#define MPG_MD_MONO 3
+
+
+
+#define LEFT 0
+#define RIGHT 1
+
+
+#define SYNC_WORD (int32)0x7ff
+#define SYNC_WORD_LNGTH 11
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ /*----------------------------------------------------------------------------
+ ; STRUCTURES TYPEDEF'S
+ ----------------------------------------------------------------------------*/
+
+ /* Header Information Structure */
+
+ typedef struct
+ {
+ int32 version_x;
+ int32 layer_description;
+ int32 error_protection;
+ int32 bitrate_index;
+ int32 sampling_frequency;
+ int32 padding;
+ int32 extension;
+ int32 mode;
+ int32 mode_ext;
+ int32 copyright;
+ int32 original;
+ int32 emphasis;
+ } mp3Header;
+
+
+ /* Layer III side information. */
+
+ typedef struct
+ {
+ uint32 part2_3_length;
+ uint32 big_values;
+ int32 global_gain;
+ uint32 scalefac_compress;
+ uint32 window_switching_flag;
+ uint32 block_type;
+ uint32 mixed_block_flag;
+ uint32 table_select[3];
+ uint32 subblock_gain[3];
+ uint32 region0_count;
+ uint32 region1_count;
+ uint32 preflag;
+ uint32 scalefac_scale;
+ uint32 count1table_select;
+
+ } granuleInfo;
+
+ typedef struct
+ {
+ uint32 scfsi[4];
+ granuleInfo gran[2];
+
+ } channelInfo;
+
+ /* Layer III side info. */
+
+ typedef struct
+ {
+ uint32 main_data_begin;
+ uint32 private_bits;
+ channelInfo ch[2];
+
+ } mp3SideInfo;
+
+ /* Layer III scale factors. */
+ typedef struct
+ {
+ int32 l[23]; /* [cb] */
+ int32 s[3][13]; /* [window][cb] */
+
+ } mp3ScaleFactors;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_decode_header.cpp b/media/codecs/mp3dec/src/pvmp3_decode_header.cpp
new file mode 100644
index 0000000..bc5fd79
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_decode_header.cpp
@@ -0,0 +1,194 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_decode_header.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ tbits *inputStream, bit stream
+ mp3Header *info,
+ uint32 *crc
+ Returns
+
+ mp3Header *info, structure holding the parsed mp3 header info
+ uint32 *crc initialized crc computation
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ gets mp3 header information
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_decode_header.h"
+#include "pvmp3_crc.h"
+#include "pvmp3_getbits.h"
+#include "pvmp3_seek_synch.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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
+----------------------------------------------------------------------------*/
+
+ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream,
+ mp3Header *info,
+ uint32 *crc)
+{
+
+ ERROR_CODE err = NO_DECODING_ERROR;
+ uint32 temp;
+
+ /*
+ * Verify that at least the header is complete
+ * Note that SYNC_WORD_LNGTH is in unit of bits, but inputBufferCurrentLength
+ * is in unit of bytes.
+ */
+ if (inputStream->inputBufferCurrentLength < ((SYNC_WORD_LNGTH + 21) >> 3))
+ {
+ return NO_ENOUGH_MAIN_DATA_ERROR;
+ }
+
+ /*
+ * MPEG Audio Version ID
+ */
+ temp = getUpTo17bits(inputStream, SYNC_WORD_LNGTH);
+ if ((temp & SYNC_WORD) != SYNC_WORD)
+ {
+ err = pvmp3_header_sync(inputStream);
+
+ if (err != NO_DECODING_ERROR)
+ {
+ return err;
+ }
+ }
+
+ temp = getNbits(inputStream, 21); // to avoid multiple bitstream accesses
+
+
+ switch (temp >> 19) /* 2 */
+ {
+ case 0:
+ info->version_x = MPEG_2_5;
+ break;
+ case 2:
+ info->version_x = MPEG_2;
+ break;
+ case 3:
+ info->version_x = MPEG_1;
+ break;
+ default:
+ info->version_x = INVALID_VERSION;
+ err = UNSUPPORTED_LAYER;
+ break;
+ }
+
+ info->layer_description = 4 - ((temp << 13) >> 30); /* 2 */
+ info->error_protection = !((temp << 15) >> 31); /* 1 */
+
+ if (info->error_protection)
+ {
+ *crc = 0xffff; /* CRC start value */
+ calculate_crc((temp << 16) >> 16, 16, crc);
+ }
+
+ info->bitrate_index = (temp << 16) >> 28; /* 4 */
+ info->sampling_frequency = (temp << 20) >> 30; /* 2 */
+ info->padding = (temp << 22) >> 31; /* 1 */
+ info->extension = (temp << 23) >> 31; /* 1 */
+ info->mode = (temp << 24) >> 30; /* 2 */
+ info->mode_ext = (temp << 26) >> 30; /* 2 */
+ info->copyright = (temp << 27) >> 31; /* 1 */
+ info->original = (temp << 28) >> 31; /* 1 */
+ info->emphasis = (temp << 30) >> 30; /* 2 */
+
+
+ if (!info->bitrate_index || info->bitrate_index == 15 || info->sampling_frequency == 3)
+ {
+ err = UNSUPPORTED_FREE_BITRATE;
+ }
+
+ return(err);
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_decode_header.h b/media/codecs/mp3dec/src/pvmp3_decode_header.h
new file mode 100644
index 0000000..2c2e89e
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_decode_header.h
@@ -0,0 +1,101 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_decode_header.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_DECODE_HEADER_H
+#define PVMP3_DECODE_HEADER_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3_dec_defs.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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
+
+ ERROR_CODE pvmp3_decode_header(tmp3Bits *inputStream,
+ mp3Header *info,
+ uint32 *crc);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp b/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp
new file mode 100644
index 0000000..6e45a18
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.cpp
@@ -0,0 +1,758 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_decode_huff_cw.cpp
+
+ Funtions:
+ pvmp3_decode_huff_cw_tab0
+ pvmp3_decode_huff_cw_tab1
+ pvmp3_decode_huff_cw_tab2
+ pvmp3_decode_huff_cw_tab3
+ pvmp3_decode_huff_cw_tab5
+ pvmp3_decode_huff_cw_tab6
+ pvmp3_decode_huff_cw_tab7
+ pvmp3_decode_huff_cw_tab8
+ pvmp3_decode_huff_cw_tab9
+ pvmp3_decode_huff_cw_tab10
+ pvmp3_decode_huff_cw_tab11
+ pvmp3_decode_huff_cw_tab12
+ pvmp3_decode_huff_cw_tab13
+ pvmp3_decode_huff_cw_tab15
+ pvmp3_decode_huff_cw_tab16
+ pvmp3_decode_huff_cw_tab24
+ pvmp3_decode_huff_cw_tab32
+ pvmp3_decode_huff_cw_tab33
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+ BITS *pMainData = pointer to input mp3 Main data bit stream
+
+
+ Outputs:
+ cw = bit field extracted from a leaf entry of packed mp3 Huffman Tables
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ These functions are used to decode huffman codewords from the input
+ bitstream using combined binary search and look-up table approach.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+ [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
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_tables.h"
+#include "pvmp3_getbits.h"
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+
+uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *pMainData)
+{
+ OSCL_UNUSED_ARG(pMainData);
+ return(0);
+
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 3); /* hufftable1 */
+
+ cw = *(huffTable_1 + tmp);
+ pMainData->usedBits -= (3 - (cw & 0xFF));
+ return(cw >> 8);
+
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */
+
+ if (tmp >> 3)
+ {
+ tmp = (tmp >> 3) - 1;
+ }
+ else
+ {
+ tmp = tmp + 7;
+ }
+
+ cw = *(huffTable_2 + tmp);
+ pMainData->usedBits -= (6 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 6); /* huffTable_2,3 */
+
+ if (tmp >> 3)
+ {
+ tmp = (tmp >> 3) - 1;
+ }
+ else
+ {
+ tmp = tmp + 7;
+ }
+
+ cw = *(huffTable_3 + tmp);
+ pMainData->usedBits -= (6 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 8); /* huffTable_5 */
+
+ if ((tmp >> 5))
+ {
+ tmp = (tmp >> 5) - 1;
+ }
+ else if ((tmp >> 1) >= 2)
+ {
+ tmp = (tmp >> 1) - 2 + 7;
+ }
+ else
+ {
+ tmp = (tmp & 3) + 21;
+ }
+
+ cw = *(huffTable_5 + tmp);
+ pMainData->usedBits -= (8 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 7); /* huffTable_6 */
+ if ((tmp >> 3) >= 3)
+ {
+ tmp = (tmp >> 3) - 3;
+ }
+ else if (tmp >> 1)
+ {
+ tmp = (tmp >> 1) - 1 + 13;
+ }
+ else
+ {
+ tmp = tmp + 24;
+ }
+
+ cw = *(huffTable_6 + tmp);
+ pMainData->usedBits -= (7 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 10); /* huffTable_7 */
+ if ((tmp >> 7) >= 2)
+ {
+ tmp = (tmp >> 7) - 2;
+ }
+ else if ((tmp >> 4) >= 7)
+ {
+ tmp = (tmp >> 4) - 7 + 6;
+ }
+ else if ((tmp >> 1) >= 2)
+ {
+ tmp = (tmp >> 1) - 2 + 15;
+ }
+ else
+ {
+ tmp = (tmp & 3) + 69;
+ }
+
+ cw = *(huffTable_7 + tmp);
+ pMainData->usedBits -= (10 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 11); /* huffTable_8 */
+ if ((tmp >> 7) >= 2)
+ {
+ tmp = (tmp >> 7) - 2;
+ }
+ else if ((tmp >> 5) >= 5)
+ {
+ tmp = (tmp >> 5) - 5 + 14;
+ }
+ else if ((tmp >> 2) >= 3)
+ {
+ tmp = (tmp >> 2) - 3 + 17;
+ }
+ else
+ {
+ tmp = (tmp) + 54;
+ }
+
+ cw = *(huffTable_8 + tmp);
+ pMainData->usedBits -= (11 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo9bits(pMainData, 9); /* huffTable_9 */
+ if ((tmp >> 5) >= 5)
+ {
+ tmp = (tmp >> 5) - 5;
+ }
+ else if ((tmp >> 3) >= 6)
+ {
+ tmp = (tmp >> 3) - 6 + 11;
+ }
+ else if ((tmp >> 1) >= 4)
+ {
+ tmp = (tmp >> 1) - 4 + 25;
+ }
+ else
+ {
+ tmp = tmp + 45;
+ }
+
+ cw = *(huffTable_9 + tmp);
+ pMainData->usedBits -= (9 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 11); /* huffTable_10 */
+ if (tmp >> 10)
+ {
+ tmp = (tmp >> 10) - 1;
+ }
+ else if ((tmp >> 7) >= 3)
+ {
+ tmp = (tmp >> 7) - 3 + 1;
+ }
+ else if ((tmp >> 5) >= 8)
+ {
+ tmp = (tmp >> 5) - 8 + 6;
+ }
+ else if ((tmp >> 3) >= 18)
+ {
+ tmp = (tmp >> 3) - 18 + 10;
+ }
+ else if ((tmp >> 2) >= 24)
+ {
+ tmp = (tmp >> 2) - 24 + 24;
+ }
+ else if ((tmp >> 1) >= 12)
+ {
+ tmp = (tmp >> 1) - 12 + 36;
+ }
+ else
+ {
+ tmp = (tmp) + 72;
+ }
+
+ cw = *(huffTable_10 + tmp);
+ pMainData->usedBits -= (11 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 11); /* huffTable_11 */
+ if ((tmp >> 8) >= 3)
+ {
+ tmp = (tmp >> 8) - 3;
+ }
+ else if ((tmp >> 6) >= 7)
+ {
+ tmp = (tmp >> 6) - 7 + 5;
+ }
+ else if ((tmp >> 3) >= 32)
+ {
+ tmp = (tmp >> 3) - 32 + 10;
+ }
+ else if ((tmp >> 2) >= 10)
+ {
+ tmp = (tmp >> 2) - 10 + 34;
+ }
+ else if ((tmp >> 1) >= 8)
+ {
+ tmp = (tmp >> 1) - 8 + 88;
+ }
+ else
+ {
+ tmp = (tmp & 0xFF) + 100;
+ }
+ cw = *(huffTable_11 + tmp);
+ pMainData->usedBits -= (11 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 10); /* huffTable_12 */
+ if ((tmp >> 7) >= 5)
+ {
+ tmp = (tmp >> 7) - 5;
+ }
+ else if ((tmp >> 5) >= 12)
+ {
+ tmp = (tmp >> 5) - 12 + 3;
+ }
+ else if ((tmp >> 4) >= 17)
+ {
+ tmp = (tmp >> 4) - 17 + 11;
+ }
+ else if ((tmp >> 2) >= 32)
+ {
+ tmp = (tmp >> 2) - 32 + 18;
+ }
+ else if ((tmp >> 1) >= 16)
+ {
+ tmp = (tmp >> 1) - 16 + 54;
+ }
+ else
+ {
+ tmp = (tmp & 0x1F) + 102;
+
+ }
+ cw = *(huffTable_12 + tmp);
+ pMainData->usedBits -= (10 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getNbits(pMainData, 19); /* huffTable_13 */
+ if (tmp >> 18)
+ {
+ tmp = 0;
+ }
+ else if ((tmp >> 15) >= 4)
+ {
+ tmp = (tmp >> 15) - 4 + 1;
+ }
+ else if ((tmp >> 11) >= 32)
+ {
+ tmp = (tmp >> 11) - 32 + 5;
+ }
+ else if ((tmp >> 9) >= 64)
+ {
+ tmp = (tmp >> 9) - 64 + 37;
+ }
+ else if ((tmp >> 8) >= 64)
+ {
+ tmp = (tmp >> 8) - 64 + 101;
+ }
+ else if ((tmp >> 7) >= 64)
+ {
+ tmp = (tmp >> 7) - 64 + 165;
+ }
+ else if ((tmp >> 6) >= 32)
+ {
+ tmp = (tmp >> 6) - 32 + 229;
+ }
+ else if ((tmp >> 5) >= 32)
+ {
+ tmp = (tmp >> 5) - 32 + 325;
+ }
+ else if ((tmp >> 4) >= 32)
+ {
+ tmp = (tmp >> 4) - 32 + 357;
+ }
+ else if ((tmp >> 3) >= 32)
+ {
+ tmp = (tmp >> 3) - 32 + 389;
+ }
+ else if ((tmp >> 2) >= 2)
+ {
+ tmp = (tmp >> 2) - 2 + 421;
+ }
+ else
+ {
+ tmp = (tmp & 0x7) + 483;
+ }
+
+ cw = *(huffTable_13 + tmp);
+ pMainData->usedBits -= (19 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 13); /* huffTable_15 */
+ if ((tmp >> 9) >= 10)
+ {
+ tmp = (tmp >> 9) - 10;
+ }
+ else if ((tmp >> 6) >= 39)
+ {
+ tmp = (tmp >> 6) - 39 + 6;
+ }
+ else if ((tmp >> 4) >= 62)
+ {
+ tmp = (tmp >> 4) - 62 + 47;
+ }
+ else if ((tmp >> 3) >= 60)
+ {
+ tmp = (tmp >> 3) - 60 + 141;
+ }
+ else if ((tmp >> 2) >= 64)
+ {
+ tmp = (tmp >> 2) - 64 + 205;
+ }
+ else if ((tmp >> 1) >= 32)
+ {
+ tmp = (tmp >> 1) - 32 + 261;
+ }
+ else
+ {
+ tmp = (tmp & 0x3f) + 357;
+ }
+
+ cw = *(huffTable_15 + tmp);
+ pMainData->usedBits -= (13 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 17); /* huffTable_16 */
+ if (tmp >> 16)
+ {
+ tmp = 0;
+ }
+ else if ((tmp >> 13) >= 4)
+ {
+ tmp = (tmp >> 13) - 4 + 1;
+ }
+ else if ((tmp >> 9) >= 38)
+ {
+ tmp = (tmp >> 9) - 38 + 5;
+ }
+ else if ((tmp >> 7) >= 94)
+ {
+ tmp = (tmp >> 7) - 94 + 31;
+ }
+ else if ((tmp >> 5) >= 214)
+ {
+ tmp = (tmp >> 5) - 214 + 89;
+ }
+ else if ((tmp >> 3) >= 704)
+ {
+ if ((tmp >> 4) >= 384)
+ {
+ tmp = (tmp >> 4) - 384 + 315;
+ }
+ else
+ {
+ tmp = (tmp >> 3) - 704 + 251;
+ }
+ }
+ else if ((tmp >> 8) >= 14)
+ {
+ tmp = (tmp >> 8) - 14 + 359;
+ }
+ else if ((tmp) >= 3456)
+ {
+ if ((tmp >> 2) >= 868)
+ {
+ tmp = (tmp >> 2) - 868 + 383;
+ }
+ else
+ {
+ tmp = (tmp) - 3456 + 367;
+ }
+ }
+ else
+ {
+ tmp = ((tmp >> 6) & 0x3f) + 411;
+ }
+
+ cw = *(huffTable_16 + tmp);
+ pMainData->usedBits -= (17 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *pMainData)
+{
+ uint32 tmp;
+ uint16 cw;
+
+ tmp = getUpTo17bits(pMainData, 12); /* huffTable_24 */
+ if ((tmp >> 6) >= 41)
+ {
+ tmp = (tmp >> 6) - 41;
+ }
+ else if ((tmp >> 3) >= 218)
+ {
+ tmp = (tmp >> 3) - 218 + 23;
+ }
+ else if ((tmp >> 2) >= 336)
+ {
+ tmp = (tmp >> 2) - 336 + 133;
+ }
+ else if ((tmp >> 1) >= 520)
+ {
+ tmp = (tmp >> 1) - 520 + 233;
+ }
+ else if ((tmp) >= 1024)
+ {
+ tmp = (tmp) - 1024 + 385;
+ }
+ else if ((tmp >> 1) >= 352)
+ {
+ if ((tmp >> 8) == 3)
+ {
+ tmp = (tmp >> 8) - 3 + 433;
+ }
+ else
+ {
+ tmp = (tmp >> 1) - 352 + 401;
+ }
+ }
+ else
+ {
+ tmp = ((tmp >> 4) & 0x3f) + 434;
+ }
+
+ cw = *(huffTable_24 + tmp);
+ pMainData->usedBits -= (12 - (cw & 0xFF));
+
+ return(cw >> 8);
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *pMainData)
+{
+ uint32 tmp = getUpTo9bits(pMainData, 6); /* huffTable_32 */
+ if ((tmp >> 5))
+ {
+ pMainData->usedBits -= 5;
+ return(0);
+ }
+ else
+ {
+ uint16 cw = *(huffTable_32 + (tmp & 0x1f));
+ pMainData->usedBits -= (6 - (cw & 0xFF));
+
+ return(cw >> 8);
+ }
+
+}
+
+
+uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *pMainData)
+{
+
+ uint16 tmp = getUpTo9bits(pMainData, 4); /* huffTable_33 */
+
+ return((0x0f - tmp));
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.h b/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.h
new file mode 100644
index 0000000..941ca6d
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_decode_huff_cw.h
@@ -0,0 +1,114 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_decode_huff_cw.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_DECODE_HUFF_CW_H
+#define PVMP3_DECODE_HUFF_CW_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3_dec_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
+
+ uint16 pvmp3_decode_huff_cw_tab0(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab1(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab2(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab3(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab5(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab6(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab7(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab8(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab9(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab10(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab11(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab12(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab13(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab15(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab16(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab24(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab32(tmp3Bits *);
+ uint16 pvmp3_decode_huff_cw_tab33(tmp3Bits *);
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp b/media/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp
new file mode 100644
index 0000000..639df81
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dequantize_sample.cpp
@@ -0,0 +1,452 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dequantize_sample.cpp
+
+ Functions:
+ power_1_third
+ pvmp3_dequantize_sample
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+power_1_third
+int32 power_1_third( int32 xx)
+
+Input
+ int32 xx, int32 in the [0, 8192] range
+
+ Returns
+
+ int32 xx^(1/3) int32 Q26 number representing
+ the 1/3 power of the input
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+pvmp3_dequantize_sample
+
+Input
+ int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac, scale factor structure
+ struct gr_info_s *gr_info, granule structure informatiom
+ mp3Header *info mp3 header info
+
+ Returns
+
+ int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS], dequantize output as (.)^(4/3)
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ dequantize sample
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_dequantize_sample.h"
+#include "pvmp3_normalize.h"
+#include "mp3_mem_funcs.h"
+#include "pvmp3_tables.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define Q30_fmt(a)(int32(double(0x40000000)*(a)))
+#define Q29_fmt(a)(int32(double(0x20000000)*(a)))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const int32 pretab[22] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 3, 3, 3, 2, 0};
+
+const int32 pow_2_1_fourth[4] =
+{
+ Q30_fmt(1.0), Q30_fmt(1.18920711500272),
+ Q30_fmt(1.41421356237310), Q30_fmt(1.68179283050743)
+};
+
+const int32 two_cubic_roots[7] =
+{
+ Q29_fmt(0), Q29_fmt(1.25992104989487),
+ Q29_fmt(1.58740105196820), Q29_fmt(2.00000000000000),
+ Q29_fmt(2.51984209978975), Q29_fmt(3.17480210393640),
+ Q29_fmt(3.99999999999999)
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 power_1_third(int32 xx)
+{
+
+ if (xx <= 512)
+ {
+ return (power_one_third[xx] >> 1);
+ }
+ else
+ {
+ if (xx >> 15)
+ {
+ return 0x7FFFFFFF; /* saturate any value over 32767 */
+ }
+ else
+ {
+ int32 x = xx;
+ int32 m = 22 - pvmp3_normalize(xx);
+
+ xx >>= m;
+ xx = (power_one_third[xx]) + (((power_one_third[xx+1] - power_one_third[xx]) >> m) * (x & ((1 << m) - 1)));
+ return (fxp_mul32_Q30(xx, two_cubic_roots[m]));
+ }
+
+ }
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+
+void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac,
+ granuleInfo *gr_info,
+ int32 used_freq_lines,
+ mp3Header *info)
+{
+ int32 ss;
+ int32 cb = 0;
+ int32 global_gain;
+ int32 sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1);
+
+ /* apply formula per block type */
+
+ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
+ {
+ int32 next_cb_boundary;
+ int32 cb_begin = 0;
+ int32 cb_width = 0;
+ int32 mixstart = 8; /* added 2003/08/21 efs */
+
+ if (info->version_x != MPEG_1)
+ {
+ mixstart = 6; /* different value in MPEG2 LSF */
+ }
+
+ if (gr_info->mixed_block_flag)
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].l[1]; /* LONG blocks: 0,1,3 */
+ }
+ else
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].s[1] * 3; /* pure SHORT block */
+ cb_width = 0;
+ }
+
+ global_gain = gr_info->global_gain;
+ int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3];
+ global_gain = 12 + (global_gain >> 2);
+
+ for (ss = 0 ; ss < used_freq_lines ; ss++)
+ {
+ if (ss == next_cb_boundary)
+ {
+ cb++; /* critical band counter */
+ if (gr_info->mixed_block_flag)
+ {
+ if (next_cb_boundary == mp3_sfBandIndex[sfreq].l[mixstart])
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].s[4] * 3;
+
+ cb_begin = mp3_sfBandIndex[sfreq].s[3] * 3;
+ cb_width = 3;
+ cb = 3;
+ }
+ else if (ss < mp3_sfBandIndex[sfreq].l[mixstart])
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].l[cb+1];
+ }
+ else
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3;
+
+ cb_width = cb;
+ cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3;
+ }
+
+ if (ss < 2*FILTERBANK_BANDS)
+ { /* 1st 2 subbands of switched blocks */
+ global_gain = (gr_info->global_gain);
+ global_gain -= (1 + gr_info->scalefac_scale) *
+ (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1;
+
+ two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3];
+ global_gain = 12 + (global_gain >> 2);
+ }
+ }
+ else
+ {
+ next_cb_boundary = mp3_sfBandIndex[sfreq].s[cb+1] * 3;
+ cb_width = cb;
+ cb_begin = mp3_sfBandIndex[sfreq].s[cb] * 3;
+ }
+
+ } /* end-if ( ss == next_cb_boundary) */
+
+ /* Do long/short dependent scaling operations. */
+ if ((gr_info->mixed_block_flag == 0) || (gr_info->mixed_block_flag && (ss >= 2*FILTERBANK_BANDS)))
+ {
+ int32 temp2 = fxp_mul32_Q32((ss - cb_begin) << 16, mp3_shortwindBandWidths[sfreq][cb_width]);
+ temp2 = (temp2 + 1) >> 15;
+
+ global_gain = (gr_info->global_gain);
+ global_gain -= gr_info->subblock_gain[temp2] << 3;
+ global_gain -= (1 + gr_info->scalefac_scale) * (scalefac->s[temp2][cb] << 1);
+
+ two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3];
+ global_gain = 12 + (global_gain >> 2);
+
+ }
+
+
+ /*
+ * xr[sb][ss] = 2^(global_gain/4)
+ */
+
+ /* Scale quantized value. */
+
+ /* 0 < abs(is[ss]) < 8192 */
+
+ int32 tmp = fxp_mul32_Q30((is[ss] << 16), power_1_third(pv_abs(is[ ss])));
+
+ tmp = fxp_mul32_Q30(tmp, two_raise_one_fourth);
+
+ if (global_gain < 0)
+ {
+ int32 temp = - global_gain;
+ if (temp < 32)
+ {
+ is[ss] = (tmp >> temp);
+ }
+ else
+ {
+ is[ss] = 0;
+ }
+ }
+ else
+ {
+ is[ss] = (tmp << global_gain);
+ }
+
+ } /* for (ss=0 ; ss < used_freq_lines ; ss++) */
+
+ }
+ else
+ {
+
+ for (cb = 0 ; cb < 22 ; cb++)
+ {
+
+ /* Compute overall (global) scaling. */
+
+ global_gain = (gr_info->global_gain);
+
+ global_gain -= (1 + gr_info->scalefac_scale) *
+ (scalefac->l[cb] + gr_info->preflag * pretab[cb]) << 1;
+
+
+ int32 two_raise_one_fourth = pow_2_1_fourth[global_gain&0x3];
+ global_gain = 12 + (global_gain >> 2);
+
+ /*
+ * xr[sb][ss] = 2^(global_gain/4)
+ */
+
+ /* Scale quantized value. */
+
+ if (used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1])
+ {
+ if (global_gain <= 0)
+ {
+ global_gain = - global_gain;
+ if (global_gain < 32)
+ {
+ for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2)
+ {
+ int32 tmp = is[ss];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain;
+ }
+ tmp = is[ss+1];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain;
+ }
+ }
+ }
+ else
+ {
+ pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]],
+ 0,
+ (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is));
+ }
+ }
+ else
+ {
+ for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < mp3_sfBandIndex[sfreq].l[cb+1]; ss += 2)
+ {
+ int32 tmp = is[ss];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain;
+ }
+
+ tmp = is[ss+1];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain;
+ }
+ }
+ }
+ }
+ else
+ {
+ if (global_gain <= 0)
+ {
+ global_gain = - global_gain;
+ if (global_gain < 32)
+ {
+ for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss += 2)
+ {
+ int32 tmp = is[ss];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain;
+ }
+ tmp = is[ss+1];
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss+1] = fxp_mul32_Q30(tmp, two_raise_one_fourth) >> global_gain;
+ }
+ }
+
+ }
+ else
+ {
+ pv_memset(&is[ mp3_sfBandIndex[sfreq].l[cb]],
+ 0,
+ (mp3_sfBandIndex[sfreq].l[cb+1] - mp3_sfBandIndex[sfreq].l[cb])*sizeof(*is));
+ }
+ }
+ else
+ {
+ for (ss = mp3_sfBandIndex[sfreq].l[cb]; ss < used_freq_lines; ss++)
+ {
+ int32 tmp = is[ss];
+
+ if (tmp)
+ {
+ tmp = fxp_mul32_Q30((tmp << 16), power_1_third(pv_abs(tmp)));
+ is[ss] = fxp_mul32_Q30(tmp, two_raise_one_fourth) << global_gain;
+ }
+ }
+ }
+
+ cb = 22; // force breaking out of the loop
+
+ } /* if ( used_freq_lines >= mp3_sfBandIndex[sfreq].l[cb+1]) */
+
+ } /* for (cb=0 ; cb < 22 ; cb++) */
+
+ } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */
+
+
+ pv_memset(&is[used_freq_lines],
+ 0,
+ (FILTERBANK_BANDS*SUBBANDS_NUMBER - used_freq_lines)*sizeof(*is));
+
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_dequantize_sample.h b/media/codecs/mp3dec/src/pvmp3_dequantize_sample.h
new file mode 100644
index 0000000..9393eb1
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_dequantize_sample.h
@@ -0,0 +1,106 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_dequantize_sample.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_DEQUANTIZE_SAMPLE_H
+#define PVMP3_DEQUANTIZE_SAMPLE_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_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 power_1_third(int32 xx);
+
+ void pvmp3_dequantize_sample(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac,
+ granuleInfo *gr_info,
+ int32 num_lines,
+ mp3Header *info);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_equalizer.cpp b/media/codecs/mp3dec/src/pvmp3_equalizer.cpp
new file mode 100644
index 0000000..61aef30
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_equalizer.cpp
@@ -0,0 +1,415 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_equalizer.cpp
+
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Input
+ int32 *inData, pointer to the spectrum frequency-line
+ e_equalization equalizerType, equalization mode
+ int32 *pt_work_buff
+
+ Output
+ int32 *pt_work_buff pointer to the equalized frequency-line
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Equalizer
+ Each subband sample is scaled according to a spectrum shape setting
+ defined by "equalizerType"
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_equalizer.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define LEVEL__0__dB 0.999999970f
+#define LEVEL__1_5dB 0.841395142f
+#define LEVEL__3__dB 0.707106781f
+#define LEVEL__4_5dB 0.595662143f
+#define LEVEL__6__dB 0.500000000f
+#define LEVEL__7_5dB 0.421696503f
+#define LEVEL__9__dB 0.353553393f
+#define LEVEL_12__dB 0.250000000f
+#define LEVEL_15__dB 0.176776695f
+#define LEVEL_18__dB 0.125000000f
+#define LEVEL_21__dB 0.088388347f
+#define LEVEL_30__dB 0.031250000f
+#define LEVEL_45__dB 0.005524271f
+#define LEVEL_60__dB 0.000976562f
+
+#define Qmf31( x) (int32)((x)*(float)0x7FFFFFFF)
+
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+
+const int32 equalizerTbl[8][SUBBANDS_NUMBER] =
+{
+ /* FLAT */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB)
+ },
+ /* BASS BOOST */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB),
+
+ Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB)
+ },
+ /* ROCK */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__3__dB),
+
+ Qmf31(LEVEL__4_5dB), Qmf31(LEVEL__6__dB),
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB)
+ },
+ /* POP */
+ {
+ Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+
+ Qmf31(LEVEL__1_5dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB)
+ },
+ /* JAZZ */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB)
+ },
+ /* CLASSICAL */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+ Qmf31(LEVEL__9__dB), Qmf31(LEVEL__9__dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__1_5dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB)
+ },
+ /* TALK */
+ {
+ Qmf31(LEVEL__9__dB),
+
+ Qmf31(LEVEL__6__dB), Qmf31(LEVEL__6__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__1_5dB),
+
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB), Qmf31(LEVEL__3__dB),
+ Qmf31(LEVEL__3__dB)
+ },
+ /* FLAT */
+ {
+ Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB), Qmf31(LEVEL__0__dB),
+ Qmf31(LEVEL__0__dB)
+ }
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 pvmp3_equalizer(int32 *circ_buffer,
+ e_equalization equalizerType,
+ int32 *work_buff)
+{
+
+ if (equalizerType == flat)
+ {
+ for (int32 band = 0; band < FILTERBANK_BANDS; band += 2)
+ {
+
+ int32 *pt_work_buff = &work_buff[band];
+ int32 *inData = &circ_buffer[544 - (band<<5)];
+
+ int32 i;
+ for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2)
+ {
+ int32 temp1 = (pt_work_buff[ i ]);
+ int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]);
+ int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]);
+ int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]);
+ *(inData++) = temp1;
+ *(inData++) = temp2;
+ *(inData++) = temp3;
+ *(inData++) = temp4;
+ }
+
+ inData -= SUBBANDS_NUMBER << 1;
+ pt_work_buff++;
+
+ for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2)
+ {
+ int32 temp1 = (pt_work_buff[ i ]);
+ int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]);
+ int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]);
+ int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]);
+ *(inData++) = temp1;
+ *(inData++) = temp2;
+ *(inData++) = temp3;
+ *(inData++) = temp4;
+ }
+ }
+ }
+ else
+ {
+ const int32 *pt_equalizer = equalizerTbl[equalizerType&7];
+
+
+ for (int32 band = 0; band < FILTERBANK_BANDS; band += 3)
+ {
+ int32 *inData = &circ_buffer[544 - (band<<5)];
+
+ int32 *pt_work_buff = &work_buff[band];
+ int32 i;
+
+ for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2)
+ {
+ int32 temp1 = (pt_work_buff[ i ]);
+ int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]);
+ int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]);
+ int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]);
+ *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++));
+ }
+
+ pt_equalizer -= SUBBANDS_NUMBER;
+
+ inData -= SUBBANDS_NUMBER << 1;
+ pt_work_buff++;
+
+ for (i = 0; i < SUBBANDS_NUMBER*FILTERBANK_BANDS; i += FILTERBANK_BANDS << 2)
+ {
+ int32 temp1 = (pt_work_buff[ i ]);
+ int32 temp2 = (pt_work_buff[ i + FILTERBANK_BANDS ]);
+ int32 temp3 = (pt_work_buff[ i + 2*FILTERBANK_BANDS ]);
+ int32 temp4 = (pt_work_buff[ i + 3*FILTERBANK_BANDS ]);
+ *(inData++) = fxp_mul32_Q32(temp1 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp2 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp3 << 1, *(pt_equalizer++));
+ *(inData++) = fxp_mul32_Q32(temp4 << 1, *(pt_equalizer++));
+ }
+ pt_equalizer -= SUBBANDS_NUMBER;
+
+ }
+ }
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_equalizer.h b/media/codecs/mp3dec/src/pvmp3_equalizer.h
new file mode 100644
index 0000000..bbf134f
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_equalizer.h
@@ -0,0 +1,101 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_equalizer.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_EQUALIZER_H
+#define PVMP3_EQUALIZER_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3decoder_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
+----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ void pvmp3_equalizer(int32 *inData,
+ e_equalization equalizerType,
+ int32 *pt_work_buff);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_framedecoder.cpp b/media/codecs/mp3dec/src/pvmp3_framedecoder.cpp
new file mode 100644
index 0000000..a5c7f5e
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_framedecoder.cpp
@@ -0,0 +1,830 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_framedecoder.cpp
+
+ Functions:
+ pvmp3_framedecoder
+ pvmp3_InitDecoder
+ pvmp3_resetDecoder
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ pExt = pointer to the external interface structure. See the file
+ pvmp3decoder_api.h for a description of each field.
+ Data type of pointer to a tPVMP3DecoderExternal
+ structure.
+
+ pMem = void pointer to hide the internal implementation of the library
+ It is cast back to a tmp3dec_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 tmp3dec_file
+ structure.
+
+
+ Outputs:
+ status = ERROR condition. see structure ERROR_CODE
+
+ Pointers and Buffers Modified:
+ pMem contents are modified.
+ pExt: (more detail in the file pvmp3decoder_api.h)
+ inputBufferUsedLength - number of array elements used up by the stream.
+ samplingRate - sampling rate in samples per sec
+ bitRate - bit rate in bits per second, varies frame to frame.
+
+
+
+------------------------------------------------------------------------------
+ FUNCTIONS DESCRIPTION
+
+ pvmp3_framedecoder
+ frame decoder library driver
+ pvmp3_InitDecoder
+ Decoder Initialization
+ pvmp3_resetDecoder
+ Reset Decoder
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+
+#include "pvmp3_framedecoder.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_poly_phase_synthesis.h"
+#include "pvmp3_tables.h"
+#include "pvmp3_imdct_synth.h"
+#include "pvmp3_alias_reduction.h"
+#include "pvmp3_reorder.h"
+#include "pvmp3_dequantize_sample.h"
+#include "pvmp3_stereo_proc.h"
+#include "pvmp3_mpeg2_stereo_proc.h"
+#include "pvmp3_get_side_info.h"
+#include "pvmp3_get_scale_factors.h"
+#include "pvmp3_mpeg2_get_scale_factors.h"
+#include "pvmp3_decode_header.h"
+#include "pvmp3_get_main_data_size.h"
+#include "s_tmp3dec_file.h"
+#include "pvmp3_getbits.h"
+#include "mp3_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
+----------------------------------------------------------------------------*/
+
+ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem)
+{
+
+ ERROR_CODE errorCode = NO_DECODING_ERROR;
+
+ int32 crc_error_count = 0;
+ uint32 sent_crc = 0;
+ uint32 computed_crc = 0;
+
+ tmp3dec_chan *pChVars[CHAN];
+ tmp3dec_file *pVars = (tmp3dec_file *)pMem;
+
+ mp3Header info_data;
+ mp3Header *info = &info_data;
+
+ pVars->inputStream.pBuffer = pExt->pInputBuffer;
+
+
+ pVars->inputStream.usedBits = pExt->inputBufferUsedLength << 3;
+ pVars->inputStream.inputBufferCurrentLength = pExt->inputBufferCurrentLength;
+
+
+ errorCode = pvmp3_decode_header(&pVars->inputStream,
+ info,
+ &computed_crc);
+
+ if (errorCode != NO_DECODING_ERROR)
+ {
+ pExt->outputFrameSize = 0;
+ return errorCode;
+ }
+
+ pVars->num_channels = (info->mode == MPG_MD_MONO) ? 1 : 2;
+ pExt->num_channels = pVars->num_channels;
+
+ int32 outputFrameSize = (info->version_x == MPEG_1) ?
+ 2 * SUBBANDS_NUMBER * FILTERBANK_BANDS :
+ SUBBANDS_NUMBER * FILTERBANK_BANDS;
+
+ outputFrameSize = (info->mode == MPG_MD_MONO) ? outputFrameSize : outputFrameSize << 1;
+
+
+ /*
+ * Check if output buffer has enough room to hold output PCM
+ */
+ if (pExt->outputFrameSize >= outputFrameSize)
+ {
+ pExt->outputFrameSize = outputFrameSize;
+ }
+ else
+ {
+ pExt->outputFrameSize = 0;
+ return OUTPUT_BUFFER_TOO_SMALL;
+ }
+
+
+ pChVars[ LEFT] = &pVars->perChan[ LEFT];
+ pChVars[RIGHT] = &pVars->perChan[RIGHT];
+
+
+
+
+ if (info->error_protection)
+ {
+ /*
+ * Get crc content
+ */
+ sent_crc = getUpTo17bits(&pVars->inputStream, 16);
+ }
+
+
+ if (info->layer_description == 3)
+ {
+ int32 gr;
+ int32 ch;
+ uint32 main_data_end;
+ int32 bytes_to_discard;
+ int16 *ptrOutBuffer = pExt->pOutputBuffer;
+
+ /*
+ * Side Information must be extracted from the bitstream and store for use
+ * during the decoded of the associated frame
+ */
+
+ errorCode = pvmp3_get_side_info(&pVars->inputStream,
+ &pVars->sideInfo,
+ info,
+ &computed_crc);
+
+ if (errorCode != NO_DECODING_ERROR)
+ {
+ pExt->outputFrameSize = 0;
+ return errorCode;
+ }
+
+ /*
+ * If CRC was sent, check that matches the one got while parsing data
+ * disable crc if this is the desired mode
+ */
+ if (info->error_protection)
+ {
+ if ((computed_crc != sent_crc) && pExt->crcEnabled)
+ {
+ crc_error_count++;
+ }
+ }
+
+ /*
+ * main data (scalefactors, Huffman coded, etc,) are not necessarily located
+ * adjacent to the side-info. Beginning of main data is located using
+ * field "main_data_begin" of the current frame. The length does not include
+ * header and side info.
+ * "main_data_begin" points to the first bit of main data of a frame. It is a negative
+ * offset in bytes from the first byte of the sync word
+ * main_data_begin = 0 <===> main data start rigth after side info.
+ */
+
+ int32 temp = pvmp3_get_main_data_size(info, pVars);
+
+
+ /*
+ * Check if available data holds a full frame, if not flag an error
+ */
+
+ if ((uint32)pVars->predicted_frame_size > pVars->inputStream.inputBufferCurrentLength)
+ {
+ pExt->outputFrameSize = 0;
+ return NO_ENOUGH_MAIN_DATA_ERROR;
+ }
+
+ /*
+ * Fill in internal circular buffer
+ */
+ fillMainDataBuf(pVars, temp);
+
+
+ main_data_end = pVars->mainDataStream.usedBits >> 3; /* in bytes */
+ if ((main_data_end << 3) < pVars->mainDataStream.usedBits)
+ {
+ main_data_end++;
+ pVars->mainDataStream.usedBits = main_data_end << 3;
+ }
+
+
+ // force signed computation; buffer sizes and offsets are all going to be
+ // well within the constraints of 32-bit signed math.
+ bytes_to_discard = pVars->frame_start
+ - ((int32)pVars->sideInfo.main_data_begin)
+ - ((int32)main_data_end);
+
+
+ if (main_data_end > BUFSIZE) /* check overflow on the buffer */
+ {
+ pVars->frame_start -= BUFSIZE;
+
+ pVars->mainDataStream.usedBits -= (BUFSIZE << 3);
+ }
+
+ pVars->frame_start += temp;
+
+
+ if (bytes_to_discard < 0 || crc_error_count)
+ {
+ /*
+ * Not enough data to decode, then we should avoid reading this
+ * data ( getting/ignoring sido info and scale data)
+ * Main data could be located in the previous frame, so an unaccounted
+ * frame can cause incorrect processing
+ * Just run the polyphase filter to "clean" the history buffer
+ */
+ errorCode = NO_ENOUGH_MAIN_DATA_ERROR;
+
+ /*
+ * Clear the input to these filters
+ */
+
+ pv_memset((void*)pChVars[RIGHT]->work_buf_int32,
+ 0,
+ SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[RIGHT]->work_buf_int32[0]));
+
+ pv_memset((void*)pChVars[LEFT]->work_buf_int32,
+ 0,
+ SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[LEFT]->work_buf_int32[0]));
+
+ /* clear circular buffers, to avoid any glitch */
+ pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576],
+ 0,
+ 480*sizeof(pChVars[ LEFT]->circ_buffer[0]));
+ pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576],
+ 0,
+ 480*sizeof(pChVars[RIGHT]->circ_buffer[0]));
+
+ pChVars[ LEFT]->used_freq_lines = 575;
+ pChVars[RIGHT]->used_freq_lines = 575;
+
+ }
+ else
+ {
+ pVars->mainDataStream.usedBits += (bytes_to_discard << 3);
+ }
+
+ /*
+ * if (fr_ps->header->version_x == MPEG_1), use 2 granules, otherwise just 1
+ */
+ for (gr = 0; gr < (1 + !(info->version_x)); gr++)
+ {
+ if (errorCode != NO_ENOUGH_MAIN_DATA_ERROR)
+ {
+ for (ch = 0; ch < pVars->num_channels; ch++)
+ {
+ int32 part2_start = pVars->mainDataStream.usedBits;
+
+ if (info->version_x == MPEG_1)
+ {
+
+ pvmp3_get_scale_factors(&pVars->scaleFactors[ch],
+ &pVars->sideInfo,
+ gr,
+ ch,
+ &pVars->mainDataStream);
+ }
+ else
+ {
+ int32 * tmp = pVars->Scratch_mem;
+ pvmp3_mpeg2_get_scale_factors(&pVars->scaleFactors[ch],
+ &pVars->sideInfo,
+ gr,
+ ch,
+ info,
+ (uint32 *)tmp,
+ &pVars->mainDataStream);
+ }
+
+ pChVars[ch]->used_freq_lines = pvmp3_huffman_parsing(pChVars[ch]->work_buf_int32,
+ &pVars->sideInfo.ch[ch].gran[gr],
+ pVars,
+ part2_start,
+ info);
+
+
+ pvmp3_dequantize_sample(pChVars[ch]->work_buf_int32,
+ &pVars->scaleFactors[ch],
+ &pVars->sideInfo.ch[ch].gran[gr],
+ pChVars[ch]->used_freq_lines,
+ info);
+
+
+
+
+ } /* for (ch=0; ch<stereo; ch++) */
+
+ if (pVars->num_channels == 2)
+ {
+
+ int32 used_freq_lines = (pChVars[ LEFT]->used_freq_lines >
+ pChVars[RIGHT]->used_freq_lines) ?
+ pChVars[ LEFT]->used_freq_lines :
+ pChVars[RIGHT]->used_freq_lines;
+
+ pChVars[ LEFT]->used_freq_lines = used_freq_lines;
+ pChVars[RIGHT]->used_freq_lines = used_freq_lines;
+
+ if (info->version_x == MPEG_1)
+ {
+ pvmp3_stereo_proc(pChVars[ LEFT]->work_buf_int32,
+ pChVars[RIGHT]->work_buf_int32,
+ &pVars->scaleFactors[RIGHT],
+ &pVars->sideInfo.ch[LEFT].gran[gr],
+ used_freq_lines,
+ info);
+ }
+ else
+ {
+ int32 * tmp = pVars->Scratch_mem;
+ pvmp3_mpeg2_stereo_proc(pChVars[ LEFT]->work_buf_int32,
+ pChVars[RIGHT]->work_buf_int32,
+ &pVars->scaleFactors[RIGHT],
+ &pVars->sideInfo.ch[ LEFT].gran[gr],
+ &pVars->sideInfo.ch[RIGHT].gran[gr],
+ (uint32 *)tmp,
+ used_freq_lines,
+ info);
+ }
+ }
+
+ } /* if ( errorCode != NO_ENOUGH_MAIN_DATA_ERROR) */
+
+ for (ch = 0; ch < pVars->num_channels; ch++)
+ {
+
+ pvmp3_reorder(pChVars[ch]->work_buf_int32,
+ &pVars->sideInfo.ch[ch].gran[gr],
+ &pChVars[ ch]->used_freq_lines,
+ info,
+ pVars->Scratch_mem);
+
+ pvmp3_alias_reduction(pChVars[ch]->work_buf_int32,
+ &pVars->sideInfo.ch[ch].gran[gr],
+ &pChVars[ ch]->used_freq_lines,
+ info);
+
+
+ /*
+ * IMDCT
+ */
+ /* set mxposition
+ * In case of mixed blocks, # of bands with long
+ * blocks (2 or 4) else 0
+ */
+ uint16 mixedBlocksLongBlocks = 0; /* 0 = long or short, 2=mixed, 4=mixed 2.5@8000 */
+ if (pVars->sideInfo.ch[ch].gran[gr].mixed_block_flag &&
+ pVars->sideInfo.ch[ch].gran[gr].window_switching_flag)
+ {
+ if ((info->version_x == MPEG_2_5) && (info->sampling_frequency == 2))
+ {
+ mixedBlocksLongBlocks = 4; /* mpeg2.5 @ 8 KHz */
+ }
+ else
+ {
+ mixedBlocksLongBlocks = 2;
+ }
+ }
+
+ pvmp3_imdct_synth(pChVars[ch]->work_buf_int32,
+ pChVars[ch]->overlap,
+ pVars->sideInfo.ch[ch].gran[gr].block_type,
+ mixedBlocksLongBlocks,
+ pChVars[ ch]->used_freq_lines,
+ pVars->Scratch_mem);
+
+
+ /*
+ * Polyphase synthesis
+ */
+
+ pvmp3_poly_phase_synthesis(pChVars[ch],
+ pVars->num_channels,
+ pExt->equalizerType,
+ &ptrOutBuffer[ch]);
+
+
+ }/* end ch loop */
+
+ ptrOutBuffer += pVars->num_channels * SUBBANDS_NUMBER * FILTERBANK_BANDS;
+ } /* for (gr=0;gr<Max_gr;gr++) */
+
+ /* skip ancillary data */
+ if (info->bitrate_index > 0)
+ { /* if not free-format */
+
+ int32 ancillary_data_lenght = pVars->predicted_frame_size << 3;
+
+ ancillary_data_lenght -= pVars->inputStream.usedBits;
+
+ /* skip ancillary data */
+ if (ancillary_data_lenght > 0)
+ {
+ pVars->inputStream.usedBits += ancillary_data_lenght;
+ }
+
+ }
+
+ /*
+ * This overrides a possible NO_ENOUGH_MAIN_DATA_ERROR
+ */
+ errorCode = NO_DECODING_ERROR;
+
+ }
+ else
+ {
+ /*
+ * The info on the header leads to an unsupported layer, more data
+ * will not fix this, so this is a bad frame,
+ */
+
+ pExt->outputFrameSize = 0;
+ return UNSUPPORTED_LAYER;
+ }
+
+ pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3;
+ pExt->totalNumberOfBitsUsed += pVars->inputStream.usedBits;
+ pExt->version = info->version_x;
+ pExt->samplingRate = mp3_s_freq[info->version_x][info->sampling_frequency];
+ pExt->bitRate = mp3_bitrate[pExt->version][info->bitrate_index];
+
+
+ /*
+ * Always verify buffer overrun condition
+ */
+
+ if (pExt->inputBufferUsedLength > pExt->inputBufferCurrentLength)
+ {
+ pExt->outputFrameSize = 0;
+ errorCode = NO_ENOUGH_MAIN_DATA_ERROR;
+ }
+
+ return errorCode;
+
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+__inline void fillDataBuf(tmp3Bits *pMainData,
+ uint32 val) /* val to write into the buffer */
+{
+ pMainData->pBuffer[module(pMainData->offset++, BUFSIZE)] = (uint8)val;
+}
+
+
+void fillMainDataBuf(void *pMem, int32 temp)
+{
+ tmp3dec_file *pVars = (tmp3dec_file *)pMem;
+
+
+ int32 offset = (pVars->inputStream.usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
+
+ /*
+ * Check if input circular buffer boundaries need to be enforced
+ */
+ if ((offset + temp) < BUFSIZE)
+ {
+ uint8 * ptr = pVars->inputStream.pBuffer + offset;
+
+ offset = pVars->mainDataStream.offset;
+
+ /*
+ * Check if main data circular buffer boundaries need to be enforced
+ */
+ if ((offset + temp) < BUFSIZE)
+ {
+ pv_memcpy((pVars->mainDataStream.pBuffer + offset), ptr, temp*sizeof(uint8));
+ pVars->mainDataStream.offset += temp;
+ }
+ else
+ {
+ int32 tmp1 = *(ptr++);
+ for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */
+ {
+ int32 tmp2 = *(ptr++);
+ fillDataBuf(&pVars->mainDataStream, tmp1);
+ fillDataBuf(&pVars->mainDataStream, tmp2);
+ tmp1 = *(ptr++);
+ }
+
+ if (temp&1)
+ {
+ fillDataBuf(&pVars->mainDataStream, tmp1);
+ }
+
+ /* adjust circular buffer counter */
+ pVars->mainDataStream.offset = module(pVars->mainDataStream.offset, BUFSIZE);
+ }
+ }
+ else
+ {
+ for (int32 nBytes = temp >> 1; nBytes != 0; nBytes--) /* read main data. */
+ {
+ fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE)));
+ fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset++ , BUFSIZE)));
+ }
+ if (temp&1)
+ {
+ fillDataBuf(&pVars->mainDataStream, *(pVars->inputStream.pBuffer + module(offset , BUFSIZE)));
+ }
+ }
+
+
+ pVars->inputStream.usedBits += (temp) << INBUF_ARRAY_INDEX_SHIFT;
+}
+
+
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+uint32 pvmp3_decoderMemRequirements(void)
+{
+ uint32 size;
+
+ size = (uint32) sizeof(tmp3dec_file);
+ return (size);
+}
+
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_decode_huff_cw.h"
+
+void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem)
+{
+
+ tmp3dec_file *pVars;
+ huffcodetab *pHuff;
+
+ pVars = (tmp3dec_file *)pMem;
+ memset(pVars, 0, sizeof(*pVars));
+
+ pExt->totalNumberOfBitsUsed = 0;
+ pExt->inputBufferCurrentLength = 0;
+ pExt->inputBufferUsedLength = 0;
+
+ pVars->inputStream.pBuffer = pExt->pInputBuffer;
+
+ /*
+ * Initialize huffman decoding table
+ */
+
+ pHuff = pVars->ht;
+ pHuff[0].linbits = 0;
+ pHuff[0].pdec_huff_tab = pvmp3_decode_huff_cw_tab0;
+ pHuff[1].linbits = 0;
+ pHuff[1].pdec_huff_tab = pvmp3_decode_huff_cw_tab1;
+ pHuff[2].linbits = 0;
+ pHuff[2].pdec_huff_tab = pvmp3_decode_huff_cw_tab2;
+ pHuff[3].linbits = 0;
+ pHuff[3].pdec_huff_tab = pvmp3_decode_huff_cw_tab3;
+ pHuff[4].linbits = 0;
+ pHuff[4].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 4 is not used */
+ pHuff[5].linbits = 4;
+ pHuff[5].pdec_huff_tab = pvmp3_decode_huff_cw_tab5;
+ pHuff[6].linbits = 0;
+ pHuff[6].pdec_huff_tab = pvmp3_decode_huff_cw_tab6;
+ pHuff[7].linbits = 0;
+ pHuff[7].pdec_huff_tab = pvmp3_decode_huff_cw_tab7;
+ pHuff[8].linbits = 0;
+ pHuff[8].pdec_huff_tab = pvmp3_decode_huff_cw_tab8;
+ pHuff[9].linbits = 0;
+ pHuff[9].pdec_huff_tab = pvmp3_decode_huff_cw_tab9;
+ pHuff[10].linbits = 0;
+ pHuff[10].pdec_huff_tab = pvmp3_decode_huff_cw_tab10;
+ pHuff[11].linbits = 0;
+ pHuff[11].pdec_huff_tab = pvmp3_decode_huff_cw_tab11;
+ pHuff[12].linbits = 0;
+ pHuff[12].pdec_huff_tab = pvmp3_decode_huff_cw_tab12;
+ pHuff[13].linbits = 0;
+ pHuff[13].pdec_huff_tab = pvmp3_decode_huff_cw_tab13;
+ pHuff[14].linbits = 0;
+ pHuff[14].pdec_huff_tab = pvmp3_decode_huff_cw_tab0; /* tbl 14 is not used */
+ pHuff[15].linbits = 0;
+ pHuff[15].pdec_huff_tab = pvmp3_decode_huff_cw_tab15;
+ pHuff[16].linbits = 1;
+ pHuff[16].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[17].linbits = 2;
+ pHuff[17].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[18].linbits = 3;
+ pHuff[18].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[19].linbits = 4;
+ pHuff[19].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[20].linbits = 6;
+ pHuff[20].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[21].linbits = 8;
+ pHuff[21].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[22].linbits = 10;
+ pHuff[22].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[23].linbits = 13;
+ pHuff[23].pdec_huff_tab = pvmp3_decode_huff_cw_tab16;
+ pHuff[24].linbits = 4;
+ pHuff[24].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[25].linbits = 5;
+ pHuff[25].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[26].linbits = 6;
+ pHuff[26].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[27].linbits = 7;
+ pHuff[27].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[28].linbits = 8;
+ pHuff[28].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[29].linbits = 9;
+ pHuff[29].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[30].linbits = 11;
+ pHuff[30].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[31].linbits = 13;
+ pHuff[31].pdec_huff_tab = pvmp3_decode_huff_cw_tab24;
+ pHuff[32].linbits = 0;
+ pHuff[32].pdec_huff_tab = pvmp3_decode_huff_cw_tab32;
+ pHuff[33].linbits = 0;
+ pHuff[33].pdec_huff_tab = pvmp3_decode_huff_cw_tab33;
+
+ /*
+ * Initialize polysynthesis circular buffer mechanism
+ */
+ /* clear buffers */
+
+ pvmp3_resetDecoder(pMem);
+
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+void pvmp3_resetDecoder(void *pMem)
+{
+
+ tmp3dec_file *pVars;
+ tmp3dec_chan *pChVars[CHAN];
+
+ pVars = (tmp3dec_file *)pMem;
+ pChVars[ LEFT] = &pVars->perChan[ LEFT];
+ pChVars[RIGHT] = &pVars->perChan[RIGHT];
+
+ pVars->frame_start = 0;
+
+ pVars->mainDataStream.offset = 0;
+
+ pVars->mainDataStream.pBuffer = pVars->mainDataBuffer;
+ pVars->mainDataStream.usedBits = 0;
+
+
+ pVars->inputStream.usedBits = 0; // in bits
+
+
+ pChVars[ LEFT]->used_freq_lines = 575;
+ pChVars[RIGHT]->used_freq_lines = 575;
+
+
+ /*
+ * Initialize polysynthesis circular buffer mechanism
+ */
+
+ pv_memset((void*)&pChVars[ LEFT]->circ_buffer[576],
+ 0,
+ 480*sizeof(pChVars[ LEFT]->circ_buffer[0]));
+ pv_memset((void*)&pChVars[RIGHT]->circ_buffer[576],
+ 0,
+ 480*sizeof(pChVars[RIGHT]->circ_buffer[0]));
+
+
+ pv_memset((void*)pChVars[ LEFT]->overlap,
+ 0,
+ SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ LEFT]->overlap[0]));
+
+
+ pv_memset((void*)pChVars[ RIGHT]->overlap,
+ 0,
+ SUBBANDS_NUMBER*FILTERBANK_BANDS*sizeof(pChVars[ RIGHT]->overlap[0]));
+
+
+
+
+
+ /*
+ * Clear all the structures
+ */
+
+
+ pv_memset((void*)&pVars->scaleFactors[RIGHT],
+ 0,
+ sizeof(mp3ScaleFactors));
+
+ pv_memset((void*)&pVars->scaleFactors[LEFT],
+ 0,
+ sizeof(mp3ScaleFactors));
+
+ pv_memset((void*)&pVars->sideInfo,
+ 0,
+ sizeof(mp3SideInfo));
+
+ pv_memset((void*)&pVars->sideInfo,
+ 0,
+ sizeof(mp3SideInfo));
+
+}
diff --git a/media/codecs/mp3dec/src/pvmp3_framedecoder.h b/media/codecs/mp3dec/src/pvmp3_framedecoder.h
new file mode 100644
index 0000000..f6d4a35
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_framedecoder.h
@@ -0,0 +1,115 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_framedecoder.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_FRAMEDECODER_H
+#define PVMP3_FRAMEDECODER_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3decoder_api.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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
+
+
+ ERROR_CODE pvmp3_framedecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem);
+
+
+
+ uint32 pvmp3_decoderMemRequirements(void);
+
+ void pvmp3_InitDecoder(tPVMP3DecoderExternal *pExt,
+ void *pMem);
+
+
+ void pvmp3_resetDecoder(void *pMem);
+
+
+ void fillMainDataBuf(void *pMem, int32 temp);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp b/media/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp
new file mode 100644
index 0000000..423a7b1
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_main_data_size.cpp
@@ -0,0 +1,180 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_main_data_size.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Input
+ mp3Header *info, pointer to mp3 header info structure
+ tmp3dec_file *pVars
+ 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
+
+ Returns
+
+ main data frame size
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ get main data frame size
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_tables.h"
+#include "pvmp3_get_main_data_size.h"
+#include "pv_mp3dec_fxd_op.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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 pvmp3_get_main_data_size(mp3Header *info,
+ tmp3dec_file *pVars)
+{
+
+
+ int32 numBytes = fxp_mul32_Q28(mp3_bitrate[info->version_x][info->bitrate_index] << 20,
+ inv_sfreq[info->sampling_frequency]);
+
+
+ numBytes >>= (20 - info->version_x);
+
+ /*
+ * Remove the size of the side information from the main data total
+ */
+ if (info->version_x == MPEG_1)
+ {
+ pVars->predicted_frame_size = numBytes;
+ if (info->mode == MPG_MD_MONO)
+ {
+ numBytes -= 17;
+ }
+ else
+ {
+ numBytes -= 32;
+ }
+ }
+ else
+ {
+ numBytes >>= 1;
+ pVars->predicted_frame_size = numBytes;
+
+ if (info->mode == MPG_MD_MONO)
+ {
+ numBytes -= 9;
+ }
+ else
+ {
+ numBytes -= 17;
+ }
+ }
+
+ if (info->padding)
+ {
+ numBytes++;
+ pVars->predicted_frame_size++;
+ }
+
+ if (info->error_protection)
+ {
+ numBytes -= 6;
+ }
+ else
+ {
+ numBytes -= 4;
+ }
+
+
+ if (numBytes < 0)
+ {
+ numBytes = 0;
+ }
+
+ return(numBytes);
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_main_data_size.h b/media/codecs/mp3dec/src/pvmp3_get_main_data_size.h
new file mode 100644
index 0000000..8e9eaa8
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_main_data_size.h
@@ -0,0 +1,101 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_main_data_size.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_GET_MAIN_DATA_SIZE_H
+#define PVMP3_GET_MAIN_DATA_SIZE_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "s_tmp3dec_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
+----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ int32 pvmp3_get_main_data_size(mp3Header *info,
+ tmp3dec_file *pVars);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp b/media/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp
new file mode 100644
index 0000000..d4a2060
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_scale_factors.cpp
@@ -0,0 +1,226 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_scale_factors.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Input
+ mp3ScaleFactors *scalefac,
+ mp3SideInfo *si, side info
+ int32 gr, granule
+ int32 ch, channel
+ tbits *pMainData bit stream
+
+ Returns
+
+ mp3ScaleFactors *scalefac, scale factors
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ get scale factors
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_get_scale_factors.h"
+#include "pvmp3_getbits.h"
+#include "mp3_mem_funcs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define Qfmt_28(a)(int32(double(0x10000000)*(a)))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const int32 slen[2][16] =
+{
+ {0, 0, 0, 0, 3, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4},
+ {0, 1, 2, 3, 0, 1, 2, 3, 1, 2, 3, 1, 2, 3, 2, 3}
+};
+
+const struct
+{
+ int32 l[5];
+ int32 s[3];
+} sfbtable =
+{
+ {0, 6, 11, 16, 21},
+ {0, 6, 12}
+};
+
+const int32 long_sfbtable[4] = { 6, 5, 5, 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
+----------------------------------------------------------------------------*/
+
+void pvmp3_get_scale_factors(mp3ScaleFactors *scalefac,
+ mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ tmp3Bits *pMainData)
+{
+ int32 sfb;
+ int32 i;
+ int32 window;
+ granuleInfo *gr_info = &(si->ch[ch].gran[gr]);
+
+ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
+ {
+ if (gr_info->mixed_block_flag)
+ { /* MIXED */
+ for (sfb = 0; sfb < 8; sfb++)
+ {
+ scalefac->l[sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]);
+ }
+
+ for (sfb = 3; sfb < 6; sfb++)
+ {
+ for (window = 0; window < 3; window++)
+ {
+ scalefac->s[window][sfb] = getNbits(pMainData, slen[0][gr_info->scalefac_compress]);
+ }
+ }
+ for (sfb = 6; sfb < 12; sfb++)
+ {
+ for (window = 0; window < 3; window++)
+ {
+ scalefac->s[window][sfb] = getNbits(pMainData, slen[1][gr_info->scalefac_compress]);
+ }
+ }
+ }
+ else
+ { /* SHORT*/
+ for (i = 0; i < 2; i++)
+ {
+ for (sfb = sfbtable.s[i]; sfb < sfbtable.s[i+1]; sfb++)
+ {
+ for (window = 0; window < 3; window++)
+ {
+ scalefac->s[window][sfb] = getNbits(pMainData, slen[i][gr_info->scalefac_compress]);
+ }
+ }
+ }
+ }
+
+ scalefac->s[0][12] = 0; /* sfb = 12 win= 0 */
+ scalefac->s[1][12] = 0; /* sfb = 12 win= 1 */
+ scalefac->s[2][12] = 0; /* sfb = 12 win= 2 */
+ }
+ else
+ { /* LONG types 0,1,3 */
+
+ int32 *ptr = &scalefac->l[0];
+
+ for (i = 0; i < 4; i++)
+ {
+ int32 tmp4 = long_sfbtable[i];
+
+ if ((si->ch[ch].scfsi[i] == 0) || (gr == 0))
+ {
+ int32 tmp1 = slen[(i>>1)][gr_info->scalefac_compress];
+
+ if (tmp1)
+ {
+ int32 tmp2 = tmp1 * tmp4;
+ uint32 tmp3 = getNbits(pMainData, tmp2);
+ tmp4 = 32 - tmp1;
+ for (; tmp2 > 0; tmp2 -= tmp1)
+ {
+ *(ptr++) = (tmp3 << (32 - tmp2)) >> tmp4;
+ }
+ }
+ else
+ {
+ for (sfb = tmp4; sfb != 0; sfb--)
+ {
+ *(ptr++) = 0;
+ }
+
+ }
+ }
+ else
+ {
+ ptr += tmp4;
+ }
+ }
+ scalefac->l[21] = 0;
+ scalefac->l[22] = 0;
+ }
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_scale_factors.h b/media/codecs/mp3dec/src/pvmp3_get_scale_factors.h
new file mode 100644
index 0000000..d4f262bf
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_scale_factors.h
@@ -0,0 +1,104 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_scale_factors.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_GET_SCALE_FACTORS_H
+#define PVMP3_GET_SCALE_FACTORS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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 pvmp3_get_scale_factors(mp3ScaleFactors *scalefac,
+ mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ tmp3Bits *pMainData);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_side_info.cpp b/media/codecs/mp3dec/src/pvmp3_get_side_info.cpp
new file mode 100644
index 0000000..d644207
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_side_info.cpp
@@ -0,0 +1,285 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_side_info.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ mp3SideInfo *si,
+ mp3Header *info, mp3 header information
+ uint32 *crc initialized crc value (if enabled)
+
+
+ Returns
+
+ mp3SideInfo *si, side information
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ acquires side information
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_get_side_info.h"
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+
+ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream,
+ mp3SideInfo *si,
+ mp3Header *info,
+ uint32 *crc)
+{
+ int32 ch, gr;
+ uint32 tmp;
+
+ int stereo = (info->mode == MPG_MD_MONO) ? 1 : 2;
+
+ if (info->version_x == MPEG_1)
+ {
+ if (stereo == 1)
+ {
+ tmp = getbits_crc(inputStream, 14, crc, info->error_protection);
+ si->main_data_begin = (tmp << 18) >> 23; /* 9 */
+ si->private_bits = (tmp << 27) >> 27; /* 5 */
+ }
+ else
+ {
+ tmp = getbits_crc(inputStream, 12, crc, info->error_protection);
+ si->main_data_begin = (tmp << 20) >> 23; /* 9 */
+ si->private_bits = (tmp << 29) >> 29; /* 3 */
+
+ }
+
+ for (ch = 0; ch < stereo; ch++)
+ {
+ tmp = getbits_crc(inputStream, 4, crc, info->error_protection);
+ si->ch[ch].scfsi[0] = (tmp << 28) >> 31; /* 1 */
+ si->ch[ch].scfsi[1] = (tmp << 29) >> 31; /* 1 */
+ si->ch[ch].scfsi[2] = (tmp << 30) >> 31; /* 1 */
+ si->ch[ch].scfsi[3] = tmp & 1; /* 1 */
+ }
+
+ for (gr = 0; gr < 2 ; gr++)
+ {
+ for (ch = 0; ch < stereo; ch++)
+ {
+ si->ch[ch].gran[gr].part2_3_length = getbits_crc(inputStream, 12, crc, info->error_protection);
+ tmp = getbits_crc(inputStream, 22, crc, info->error_protection);
+
+ si->ch[ch].gran[gr].big_values = (tmp << 10) >> 23; /* 9 */
+ si->ch[ch].gran[gr].global_gain = (int32)((tmp << 19) >> 24) - 210; /* 8 */
+ si->ch[ch].gran[gr].scalefac_compress = (tmp << 27) >> 28; /* 4 */
+ si->ch[ch].gran[gr].window_switching_flag = tmp & 1; /* 1 */
+
+ if (si->ch[ch].gran[gr].window_switching_flag)
+ {
+ tmp = getbits_crc(inputStream, 22, crc, info->error_protection);
+
+ si->ch[ch].gran[gr].block_type = (tmp << 10) >> 30; /* 2 */;
+ si->ch[ch].gran[gr].mixed_block_flag = (tmp << 12) >> 31; /* 1 */;
+
+ si->ch[ch].gran[gr].table_select[0] = (tmp << 13) >> 27; /* 5 */;
+ si->ch[ch].gran[gr].table_select[1] = (tmp << 18) >> 27; /* 5 */;
+
+ si->ch[ch].gran[gr].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */;
+ si->ch[ch].gran[gr].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */;
+ si->ch[ch].gran[gr].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */;
+
+ /* Set region_count parameters since they are implicit in this case. */
+
+ if (si->ch[ch].gran[gr].block_type == 0)
+ {
+ return(SIDE_INFO_ERROR);
+ }
+ else if ((si->ch[ch].gran[gr].block_type == 2)
+ && (si->ch[ch].gran[gr].mixed_block_flag == 0))
+ {
+ si->ch[ch].gran[gr].region0_count = 8; /* MI 9; */
+ si->ch[ch].gran[gr].region1_count = 12;
+ }
+ else
+ {
+ si->ch[ch].gran[gr].region0_count = 7; /* MI 8; */
+ si->ch[ch].gran[gr].region1_count = 13;
+ }
+ }
+ else
+ {
+ tmp = getbits_crc(inputStream, 22, crc, info->error_protection);
+
+ si->ch[ch].gran[gr].table_select[0] = (tmp << 10) >> 27; /* 5 */;
+ si->ch[ch].gran[gr].table_select[1] = (tmp << 15) >> 27; /* 5 */;
+ si->ch[ch].gran[gr].table_select[2] = (tmp << 20) >> 27; /* 5 */;
+
+ si->ch[ch].gran[gr].region0_count = (tmp << 25) >> 28; /* 4 */;
+ si->ch[ch].gran[gr].region1_count = (tmp << 29) >> 29; /* 3 */;
+
+ si->ch[ch].gran[gr].block_type = 0;
+ }
+
+ tmp = getbits_crc(inputStream, 3, crc, info->error_protection);
+ si->ch[ch].gran[gr].preflag = (tmp << 29) >> 31; /* 1 */
+ si->ch[ch].gran[gr].scalefac_scale = (tmp << 30) >> 31; /* 1 */
+ si->ch[ch].gran[gr].count1table_select = tmp & 1; /* 1 */
+ }
+ }
+ }
+ else /* Layer 3 LSF */
+ {
+ si->main_data_begin = getbits_crc(inputStream, 8, crc, info->error_protection);
+ si->private_bits = getbits_crc(inputStream, stereo, crc, info->error_protection);
+
+ for (ch = 0; ch < stereo; ch++)
+ {
+ tmp = getbits_crc(inputStream, 21, crc, info->error_protection);
+ si->ch[ch].gran[0].part2_3_length = (tmp << 11) >> 20; /* 12 */
+ si->ch[ch].gran[0].big_values = (tmp << 23) >> 23; /* 9 */
+
+ tmp = getbits_crc(inputStream, 18, crc, info->error_protection);
+ si->ch[ch].gran[0].global_gain = ((tmp << 14) >> 24) - 210; /* 8 */
+ si->ch[ch].gran[0].scalefac_compress = (tmp << 22) >> 23; /* 9 */
+ si->ch[ch].gran[0].window_switching_flag = tmp & 1; /* 1 */
+
+ if (si->ch[ch].gran[0].window_switching_flag)
+ {
+
+ tmp = getbits_crc(inputStream, 22, crc, info->error_protection);
+
+ si->ch[ch].gran[0].block_type = (tmp << 10) >> 30; /* 2 */;
+ si->ch[ch].gran[0].mixed_block_flag = (tmp << 12) >> 31; /* 1 */;
+
+ si->ch[ch].gran[0].table_select[0] = (tmp << 13) >> 27; /* 5 */;
+ si->ch[ch].gran[0].table_select[1] = (tmp << 18) >> 27; /* 5 */;
+
+ si->ch[ch].gran[0].subblock_gain[0] = (tmp << 23) >> 29; /* 3 */;
+ si->ch[ch].gran[0].subblock_gain[1] = (tmp << 26) >> 29; /* 3 */;
+ si->ch[ch].gran[0].subblock_gain[2] = (tmp << 29) >> 29; /* 3 */;
+
+ /* Set region_count parameters since they are implicit in this case. */
+
+ if (si->ch[ch].gran[0].block_type == 0)
+ {
+ return(SIDE_INFO_ERROR);
+ }
+ else if ((si->ch[ch].gran[0].block_type == 2)
+ && (si->ch[ch].gran[0].mixed_block_flag == 0))
+ {
+ si->ch[ch].gran[0].region0_count = 8; /* MI 9; */
+ si->ch[ch].gran[0].region1_count = 12;
+ }
+ else
+ {
+ si->ch[ch].gran[0].region0_count = 7; /* MI 8; */
+ si->ch[ch].gran[0].region1_count = 13;
+ }
+ }
+ else
+ {
+ tmp = getbits_crc(inputStream, 22, crc, info->error_protection);
+
+ si->ch[ch].gran[0].table_select[0] = (tmp << 10) >> 27; /* 5 */;
+ si->ch[ch].gran[0].table_select[1] = (tmp << 15) >> 27; /* 5 */;
+ si->ch[ch].gran[0].table_select[2] = (tmp << 20) >> 27; /* 5 */;
+
+ si->ch[ch].gran[0].region0_count = (tmp << 25) >> 28; /* 4 */;
+ si->ch[ch].gran[0].region1_count = (tmp << 29) >> 29; /* 3 */;
+
+ si->ch[ch].gran[0].block_type = 0;
+ }
+
+ tmp = getbits_crc(inputStream, 2, crc, info->error_protection);
+ si->ch[ch].gran[0].scalefac_scale = tmp >> 1; /* 1 */
+ si->ch[ch].gran[0].count1table_select = tmp & 1; /* 1 */
+
+ }
+ }
+ return (NO_DECODING_ERROR);
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_get_side_info.h b/media/codecs/mp3dec/src/pvmp3_get_side_info.h
new file mode 100644
index 0000000..2d6ccd8
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_get_side_info.h
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_get_side_info.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_GET_SIDE_INFO_H
+#define PVMP3_GET_SIDE_INFO_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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
+
+ ERROR_CODE pvmp3_get_side_info(tmp3Bits *inputStream,
+ mp3SideInfo *si,
+ mp3Header *info,
+ uint32 *crc);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_getbits.cpp b/media/codecs/mp3dec/src/pvmp3_getbits.cpp
new file mode 100644
index 0000000..8ff7953
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_getbits.cpp
@@ -0,0 +1,257 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_getbits.cpp
+
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+
+ tmp3Bits *inputStream, structure holding the input stream parameters
+ int32 neededBits number of bits to read from the bit stream
+
+ Outputs:
+
+ word parsed from teh bitstream, with size neededBits-bits,
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_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 getNbits(tmp3Bits *ptBitStream,
+ int32 neededBits) /* number of bits to read from the bitstream (up to 25) */
+{
+
+ uint32 offset;
+ uint32 bitIndex;
+ uint8 Elem; /* Needs to be same type as pInput->pBuffer */
+ uint8 Elem1;
+ uint8 Elem2;
+ uint8 Elem3;
+ uint32 returnValue = 0;
+
+ if (!neededBits)
+ {
+ return (returnValue);
+ }
+
+ offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
+
+ Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE));
+ Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE));
+ Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE));
+ Elem3 = *(ptBitStream->pBuffer + module(offset + 3, BUFSIZE));
+
+
+ returnValue = (((uint32)(Elem)) << 24) |
+ (((uint32)(Elem1)) << 16) |
+ (((uint32)(Elem2)) << 8) |
+ ((uint32)(Elem3));
+
+ /* Remove extra high bits by shifting up */
+ bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH);
+
+ /* This line is faster than to mask off the high bits. */
+ returnValue <<= bitIndex;
+
+ /* Move the field down. */
+ returnValue >>= (32 - neededBits);
+
+ ptBitStream->usedBits += neededBits;
+
+ return (returnValue);
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+uint16 getUpTo9bits(tmp3Bits *ptBitStream,
+ int32 neededBits) /* number of bits to read from the bit stream 2 to 9 */
+{
+
+ uint32 offset;
+ uint32 bitIndex;
+ uint8 Elem; /* Needs to be same type as pInput->pBuffer */
+ uint8 Elem1;
+ uint16 returnValue;
+
+ offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
+
+ Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE));
+ Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE));
+
+
+ returnValue = (((uint16)(Elem)) << 8) |
+ ((uint16)(Elem1));
+
+ /* Remove extra high bits by shifting up */
+ bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH);
+
+ ptBitStream->usedBits += neededBits;
+ /* This line is faster than to mask off the high bits. */
+ returnValue = (returnValue << (bitIndex));
+
+ /* Move the field down. */
+
+ return (uint16)(returnValue >> (16 - neededBits));
+
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+uint32 getUpTo17bits(tmp3Bits *ptBitStream,
+ int32 neededBits) /* number of bits to read from the bit stream 2 to 8 */
+{
+
+ uint32 offset;
+ uint32 bitIndex;
+ uint8 Elem; /* Needs to be same type as pInput->pBuffer */
+ uint8 Elem1;
+ uint8 Elem2;
+ uint32 returnValue;
+
+ offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
+
+ Elem = *(ptBitStream->pBuffer + module(offset , BUFSIZE));
+ Elem1 = *(ptBitStream->pBuffer + module(offset + 1, BUFSIZE));
+ Elem2 = *(ptBitStream->pBuffer + module(offset + 2, BUFSIZE));
+
+
+ returnValue = (((uint32)(Elem)) << 16) |
+ (((uint32)(Elem1)) << 8) |
+ ((uint32)(Elem2));
+
+ /* Remove extra high bits by shifting up */
+ bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH);
+
+ ptBitStream->usedBits += neededBits;
+ /* This line is faster than to mask off the high bits. */
+ returnValue = 0xFFFFFF & (returnValue << (bitIndex));
+
+ /* Move the field down. */
+
+ return (uint32)(returnValue >> (24 - neededBits));
+
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+uint8 get1bit(tmp3Bits *ptBitStream) /* number of bits to read from the bit stream */
+{
+
+ uint32 offset;
+ uint32 bitIndex;
+ uint8 returnValue;
+
+ offset = (ptBitStream->usedBits) >> INBUF_ARRAY_INDEX_SHIFT;
+
+ returnValue = *(ptBitStream->pBuffer + module(offset , BUFSIZE));
+
+ /* Remove extra high bits by shifting up */
+ bitIndex = module(ptBitStream->usedBits, INBUF_BIT_WIDTH);
+ ptBitStream->usedBits++;
+
+ /* This line is faster than to mask off the high bits. */
+ returnValue = (returnValue << (bitIndex));
+
+ return (uint8)(returnValue >> 7);
+
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_getbits.h b/media/codecs/mp3dec/src/pvmp3_getbits.h
new file mode 100644
index 0000000..b058b00
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_getbits.h
@@ -0,0 +1,112 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_getbits.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_GETBITS_H
+#define PVMP3_GETBITS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_dec_defs.h"
+#include "s_mp3bits.h"
+#include "pvmp3_audio_type_defs.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)
+
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; STRUCTURES TYPEDEF'S
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ uint32 getNbits(tmp3Bits *pMainData,
+ int32 neededBits);
+
+ uint16 getUpTo9bits(tmp3Bits *pMainData,
+ int32 neededBits);
+
+ uint32 getUpTo17bits(tmp3Bits *pMainData,
+ int32 neededBits);
+
+ uint8 get1bit(tmp3Bits *pMainData);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp b/media/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp
new file mode 100644
index 0000000..5d58cd2
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_huffman_decoding.cpp
@@ -0,0 +1,304 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_huffman_decoding.cpp
+
+ Funtions:
+ pvmp3_huffman_quad_decoding
+ pvmp3_huffman_pair_decoding
+ pvmp3_huffman_pair_decoding_linbits
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+ struct huffcodetab *h, pointer to huffman code record
+ int32 *x, returns decoded x value
+ int32 *y, returns decoded y value
+ int32 *v, returns decoded v value (only in quad function)
+ int32 *w, returns decoded w value (only in quad function)
+ tbits *pMainData bit stream
+
+ Outputs:
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ These functions are used to decode huffman codewords from the input
+ bitstream using combined binary search and look-up table approach.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_dec_defs.h"
+#include "pv_mp3_huffman.h"
+#include "pvmp3_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 pvmp3_huffman_quad_decoding(struct huffcodetab *h,
+ int32 *is,
+ tmp3Bits *pMainData)
+{
+
+ int32 x;
+ int32 y;
+ int32 v;
+ int32 w;
+
+ y = (*h->pdec_huff_tab)(pMainData);
+
+
+ if (y)
+ {
+ v = (y >> 3);
+
+ if (v)
+ {
+ if (get1bit(pMainData))
+ {
+ v = -v;
+ }
+ }
+ w = (y >> 2) & 1;
+ if (w)
+ {
+ if (get1bit(pMainData))
+ {
+ w = -w;
+ }
+ }
+ x = (y >> 1) & 1;
+ if (x)
+ {
+ if (get1bit(pMainData))
+ {
+ x = -x;
+ }
+ }
+ y = y & 1;
+ if (y)
+ {
+ if (get1bit(pMainData))
+ {
+ y = -y;
+ }
+ }
+
+ }
+ else
+ {
+ v = 0;
+ w = 0;
+ x = 0;
+
+ }
+
+ *is = v;
+ *(is + 1) = w;
+ *(is + 2) = x;
+ *(is + 3) = y;
+
+}
+
+
+
+void pvmp3_huffman_pair_decoding(struct huffcodetab *h, /* pointer to huffman code record */
+ int32 *is,
+ tmp3Bits *pMainData)
+{
+ /* Lookup in Huffman table. */
+ int32 x;
+ int32 y;
+
+ uint16 cw = (*h->pdec_huff_tab)(pMainData);
+
+ /* Process sign and escape encodings for dual tables. */
+
+
+ if (cw)
+ {
+ x = cw >> 4;
+
+ if (x)
+ {
+ if (get1bit(pMainData))
+ {
+ x = -x;
+ }
+ y = cw & 0xf;
+ if (y && get1bit(pMainData))
+ {
+ y = -y;
+ }
+
+ }
+ else
+ {
+ y = cw & 0xf;
+ if (get1bit(pMainData))
+ {
+ y = -y;
+ }
+ }
+
+ *is = x;
+ *(is + 1) = y;
+ }
+ else
+ {
+ *is = 0;
+ *(is + 1) = 0;
+ }
+
+
+
+}
+
+
+
+
+void pvmp3_huffman_pair_decoding_linbits(struct huffcodetab *h, /* pointer to huffman code record */
+ int32 *is,
+ tmp3Bits *pMainData)
+{
+ int32 x;
+ int32 y;
+
+ uint16 cw;
+ /* Lookup in Huffman table. */
+
+
+ cw = (*h->pdec_huff_tab)(pMainData);
+ x = cw >> 4;
+
+ /* Process sign and escape encodings for dual tables. */
+
+
+ if (15 == (uint32)x)
+ {
+ int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1));
+ x += tmp >> 1;
+ if (tmp&1)
+ {
+ x = -x;
+ }
+ }
+ else if (x)
+ {
+ if (get1bit(pMainData))
+ {
+ x = -x;
+ }
+ }
+
+ y = cw & 0xf;
+ if (15 == (uint32)y)
+ {
+ int32 tmp = getUpTo17bits(pMainData, (h->linbits + 1));
+ y += tmp >> 1;
+ if (tmp&1)
+ {
+ y = -y;
+ }
+ }
+ else if (y)
+ {
+ if (get1bit(pMainData))
+ {
+ y = -y;
+ }
+ }
+
+ *is = x;
+ *(is + 1) = y;
+
+}
+
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp b/media/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp
new file mode 100644
index 0000000..ff815dc
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_huffman_parsing.cpp
@@ -0,0 +1,328 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_huffman_decoding.cpp
+
+ Funtions:
+ pvmp3_huffman_quad_decoding
+ pvmp3_huffman_pair_decoding
+ pvmp3_huffman_pair_decoding_linbits
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+ int32 is[],
+ granuleInfo *grInfo, information for the given channel and granule
+ tmp3dec_file *pVars, decoder state structure
+ int32 part2_start, index to beginning of part 2 data
+ mp3Header *info mp3 header info
+
+ Outputs:
+ int32 is[], uncompressed data
+
+ Return:
+ non zero frequency lines
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ These functions are used to decode huffman codewords from the input
+ bitstream using combined binary search and look-up table approach.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_mp3_huffman.h"
+#include "s_mp3bits.h"
+#include "mp3_mem_funcs.h"
+#include "pvmp3_tables.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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 pvmp3_huffman_parsing(int32 is[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ granuleInfo *grInfo,
+ tmp3dec_file *pVars,
+ int32 part2_start,
+ mp3Header *info)
+
+
+{
+ int32 i;
+ int32 region1Start;
+ int32 region2Start;
+ int32 sfreq;
+ uint32 grBits;
+ void(*pt_huff)(struct huffcodetab *, int32 *, tmp3Bits *);
+ struct huffcodetab *h;
+
+ tmp3Bits *pMainData = &pVars->mainDataStream;
+
+
+ /*int32 bt = (*si).ch[ch].gr[gr].window_switching_flag && ((*si).ch[ch].gr[gr].block_type == 2);*/
+
+ sfreq = info->sampling_frequency + info->version_x + (info->version_x << 1);
+
+ /* Find region boundary for short block case. */
+
+
+ if ((grInfo->window_switching_flag) && (grInfo->block_type == 2))
+ {
+ if (info->version_x == MPEG_1)
+ {
+ /* Region2. */
+ region1Start = 12;
+ }
+ else
+ {
+ /* Region2. */
+ i = grInfo->region0_count + 1;
+ region1Start = mp3_sfBandIndex[sfreq].s[i/3];
+ }
+
+ region1Start += region1Start << 1;
+ region2Start = 576; /* No Region2 for short block case. */
+ }
+ else
+ { /* Find region boundary for long block case. */
+ i = grInfo->region0_count + 1;
+ region1Start = mp3_sfBandIndex[sfreq].l[i];
+ region2Start = mp3_sfBandIndex[sfreq].l[i + grInfo->region1_count + 1];
+ }
+
+ /* Read bigvalues area. */
+
+
+ if (grInfo->big_values > (FILTERBANK_BANDS*SUBBANDS_NUMBER >> 1))
+ {
+ grInfo->big_values = (FILTERBANK_BANDS * SUBBANDS_NUMBER >> 1);
+ }
+
+ if ((grInfo->big_values << 1) > (uint32)region2Start)
+ {
+ h = &(pVars->ht[grInfo->table_select[0]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+
+ for (i = 0; i < region1Start; i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+
+ h = &(pVars->ht[grInfo->table_select[1]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+
+ for (; i < region2Start; i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+
+ h = &(pVars->ht[grInfo->table_select[2]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+
+ for (; (uint32)i < (grInfo->big_values << 1); i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+ }
+ else if ((grInfo->big_values << 1) > (uint32)region1Start)
+ {
+ h = &(pVars->ht[grInfo->table_select[0]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+ for (i = 0; i < region1Start; i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+
+ h = &(pVars->ht[grInfo->table_select[1]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+ for (; (uint32)i < (grInfo->big_values << 1); i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+ }
+ else
+ {
+ h = &(pVars->ht[grInfo->table_select[0]]);
+ if (h->linbits)
+ {
+ pt_huff = pvmp3_huffman_pair_decoding_linbits;
+ }
+ else
+ {
+ pt_huff = pvmp3_huffman_pair_decoding;
+ }
+
+ for (i = 0; (uint32)i < (grInfo->big_values << 1); i += 2)
+ {
+ (*pt_huff)(h, &is[i], pMainData);
+ }
+ }
+
+
+
+ /* Read count1 area. */
+ h = &(pVars->ht[grInfo->count1table_select+32]);
+
+ grBits = part2_start + grInfo->part2_3_length;
+
+ while ((pMainData->usedBits < grBits) &&
+ (i < FILTERBANK_BANDS*SUBBANDS_NUMBER - 4))
+ {
+ pvmp3_huffman_quad_decoding(h, &is[i], pMainData);
+ i += 4;
+ }
+
+ if ((pMainData->usedBits < grBits) &&
+ (i < FILTERBANK_BANDS*SUBBANDS_NUMBER))
+ {
+ pvmp3_huffman_quad_decoding(h, &is[i], pMainData);
+ i += 4;
+
+ if ((i - 2) >= FILTERBANK_BANDS*SUBBANDS_NUMBER)
+ {
+ i -= 2;
+ is[i] = 0;
+ is[(i+1)] = 0;
+ }
+ }
+
+ if (pMainData->usedBits > grBits)
+ {
+ i -= 4;
+
+ if (i < 0 || i > FILTERBANK_BANDS*SUBBANDS_NUMBER - 4)
+ {
+ /* illegal parameters may cause invalid access, set i to 0 */
+ i = 0;
+ }
+
+ is[i] = 0;
+ is[(i+1)] = 0;
+ is[(i+2)] = 0;
+ is[(i+3)] = 0;
+
+ }
+
+ pMainData->usedBits = grBits;
+
+ return (i);
+
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_imdct_synth.cpp b/media/codecs/mp3dec/src/pvmp3_imdct_synth.cpp
new file mode 100644
index 0000000..11961d1
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_imdct_synth.cpp
@@ -0,0 +1,376 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_imdct_synth.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Input
+ int32 in[], Pointer to spec values of current channel
+ int32 overlap[], Pointer to overlap values of current channel
+ uint32 blk_type, Block type
+ int16 mx_band, In case of mixed blocks, # of bands with long
+ blocks (2 or 4) else 0
+ int32 *Scratch_mem
+ Returns
+
+ int32 in[],
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ The frequency lines are preprocessed by the "alias reduction" scheme
+ and fed into the IMDCT matrix, each 18 into one transform block.
+ The first half of the output values are added to the stored overlap
+ values from the last block. These values are new output values and
+ are input values for the polyphase filterbank. The second half of the
+ output values is stored for overlap with the next data granule.
+ The number of windowed samples is 12 for short blocks, and 36 for long
+ blocks
+
+Windowing
+
+ Depending on window_switching_flag[gr][ch], block_type[gr][ch] and
+ mixed_block_flag[gr][ch] different shapes of windows are used.
+ normal window
+ start window
+ stop window
+ short windows
+ Each of the three short blocks is windowed separately.
+ The windowed short blocks must be overlapped and concatenated.
+
+Overlapping and adding with previous block
+
+ The first half (18 values) of the current block (36 values) has to be
+ overlapped with the second half of the previous block. The second half
+ of the current block has to be stored for overlapping with the next block
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_imdct_synth.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_mdct_18.h"
+#include "pvmp3_mdct_6.h"
+#include "mp3_mem_funcs.h"
+
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define LONG 0
+#define START 1
+#define SHORT 2
+#define STOP 3
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+/*
+ * sin(pi/36*(k+0.5)),k=0..35
+ */
+
+const int32 normal_win[36] =
+{
+ Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f),
+ Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f),
+ Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f),
+ Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f),
+ Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f),
+ Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f),
+ Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f),
+ Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f),
+ Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f),
+ Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f),
+ Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f),
+ Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f)
+};
+
+
+const int32 start_win[36] =
+{
+ /* k=0..17 sin(pi/36*(k+0.5)), */
+ Qfmt_31(0.08723877473068f), Qfmt_31(0.26105238444010f), Qfmt_31(0.43287922787620f),
+ Qfmt_31(0.60141159900854f), Qfmt_31(0.76536686473018f), Qfmt_31(0.92349722647006f),
+ Qfmt_31(0.53729960834682f), Qfmt_31(0.60876142900872f), Qfmt_31(0.67559020761566f),
+ Qfmt_31(-0.73727733681012f), Qfmt_31(-0.79335334029124f), Qfmt_31(0.84339144581289f),
+ Qfmt_31(0.88701083317822f), Qfmt_31(0.92387953251129f), Qfmt_31(-0.95371695074823f),
+ Qfmt_31(-0.97629600711993f), Qfmt_31(-0.99144486137381f), Qfmt_31(-0.99904822158186f),
+
+ Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f),
+ Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f),
+ /* k=24..29; sin(pi/12*(k-18+0.5)) */
+ Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f),
+ Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f),
+
+ Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f),
+ Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f)
+};
+
+
+const int32 stop_win[36] =
+{
+ Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f),
+ Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f), Qfmt_31(0.00000000000000f),
+ /* k=6..11; sin(pi/12*(k-6+0.5)) */
+ Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f),
+ Qfmt_31(-0.79335334029124f), Qfmt_31(-0.92387953251129f), Qfmt_31(0.99144486137381f),
+
+ Qfmt_31(0.99999990000000f), Qfmt_31(0.99999990000000f), Qfmt_31(-0.99999990000000f),
+ Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f), Qfmt_31(-0.99999990000000f),
+ /* k=18..35 sin(pi/36*(k+0.5)), */
+ Qfmt_31(0.99904822158186f), Qfmt_31(0.99144486137381f), Qfmt_31(0.97629600711993f),
+ Qfmt_31(0.95371695074823f), Qfmt_31(0.92387953251129f), Qfmt_31(0.88701083317822f),
+ Qfmt_31(0.84339144581289f), Qfmt_31(0.79335334029124f), Qfmt_31(0.73727733681012f),
+ Qfmt_31(0.67559020761566f), Qfmt_31(0.60876142900872f), Qfmt_31(0.53729960834682f),
+ Qfmt_31(0.46174861323503f), Qfmt_31(0.38268343236509f), Qfmt_31(0.30070579950427f),
+ Qfmt_31(0.21643961393810f), Qfmt_31(0.13052619222005f), Qfmt_31(0.04361938736534f)
+};
+
+
+const int32 short_win[12] =
+{
+ /* k=0..11; sin(pi/12*(k+0.5)) */
+ Qfmt_31(0.13052619222005f), Qfmt_31(0.38268343236509f), Qfmt_31(0.60876142900872f),
+ Qfmt_31(0.79335334029124f), Qfmt_31(0.92387953251129f), Qfmt_31(0.99144486137381f),
+ Qfmt_31(0.99144486137381f), Qfmt_31(0.92387953251129f), Qfmt_31(0.79335334029124f),
+ Qfmt_31(0.60876142900872f), Qfmt_31(0.38268343236509f), Qfmt_31(0.13052619222005f),
+};
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ uint32 blk_type,
+ int16 mx_band,
+ int32 used_freq_lines,
+ int32 *Scratch_mem)
+{
+
+ int32 band;
+ int32 bands2process = used_freq_lines + 2;
+
+ if (bands2process > SUBBANDS_NUMBER)
+ {
+ bands2process = SUBBANDS_NUMBER; /* default */
+ }
+
+
+ /*
+ * in case of mx_poly_band> 0, do
+ * long transforms
+ */
+
+
+ for (band = 0; band < bands2process; band++)
+ {
+ uint32 current_blk_type = (band < mx_band) ? LONG : blk_type;
+
+ int32 * out = in + (band * FILTERBANK_BANDS);
+ int32 * history = overlap + (band * FILTERBANK_BANDS);
+
+ switch (current_blk_type)
+ {
+ case LONG:
+
+ pvmp3_mdct_18(out, history, normal_win);
+
+ break;
+
+ case START:
+
+ pvmp3_mdct_18(out, history, start_win);
+
+ break;
+
+ case STOP:
+
+ pvmp3_mdct_18(out, history, stop_win);
+
+ break;
+
+ case SHORT:
+ {
+ int32 *tmp_prev_ovr = &Scratch_mem[FILTERBANK_BANDS];
+ int32 i;
+
+ for (i = 0; i < 6; i++)
+ {
+ Scratch_mem[i ] = out[(i*3)];
+ Scratch_mem[6 +i] = out[(i*3) + 1];
+ Scratch_mem[12 +i] = out[(i*3) + 2];
+ }
+
+ pvmp3_mdct_6(&Scratch_mem[ 0], &tmp_prev_ovr[ 0]);
+ pvmp3_mdct_6(&Scratch_mem[ 6], &tmp_prev_ovr[ 6]);
+ pvmp3_mdct_6(&Scratch_mem[12], &tmp_prev_ovr[12]);
+
+ for (i = 0; i < 6; i++)
+ {
+ int32 temp = history[i];
+ /* next iteration overlap */
+ history[i] = fxp_mul32_Q32(tmp_prev_ovr[ 6+i] << 1, short_win[6+i]);
+ history[i] += fxp_mul32_Q32(Scratch_mem[12+i] << 1, short_win[ i]);
+ out[i] = temp;
+ }
+
+ for (i = 0; i < 6; i++)
+ {
+ out[i+6] = fxp_mul32_Q32(Scratch_mem[i] << 1, short_win[i]);
+ out[i+6] += history[i+6];
+ /* next iteration overlap */
+ history[i+6] = fxp_mul32_Q32(tmp_prev_ovr[12+i] << 1, short_win[6+i]);
+
+ }
+ for (i = 0; i < 6; i++)
+ {
+ out[i+12] = fxp_mul32_Q32(tmp_prev_ovr[ i] << 1, short_win[6+i]);
+ out[i+12] += fxp_mul32_Q32(Scratch_mem[6+i] << 1, short_win[ i]);
+ out[i+12] += history[i+12];
+ history[12+i] = 0;
+ }
+ }
+
+ break;
+ }
+
+ /*
+ * Compensation for frequency inversion of polyphase filterbank
+ * every odd time sample of every odd odd subband is mulitplied by -1 before
+ * processing by the polyphase filter
+ */
+
+ if (band & 1)
+ {
+ for (int32 slot = 1; slot < FILTERBANK_BANDS; slot += 6)
+ {
+ int32 temp1 = out[slot ];
+ int32 temp2 = out[slot+2];
+ int32 temp3 = out[slot+4];
+ out[slot ] = -temp1;
+ out[slot+2] = -temp2;
+ out[slot+4] = -temp3;
+ }
+ }
+ }
+
+
+ for (band = bands2process; band < SUBBANDS_NUMBER; band++)
+ {
+ int32 * out = in + (band * FILTERBANK_BANDS);
+ int32 * history = overlap + (band * FILTERBANK_BANDS);
+ int32 slot;
+
+ if (band & 1)
+ {
+ for (slot = 0; slot < FILTERBANK_BANDS; slot += 6)
+ {
+ int32 temp1 = history[slot ];
+ int32 temp2 = history[slot+1];
+ int32 temp3 = history[slot+2];
+ out[slot ] = temp1;
+ out[slot+1] = -temp2;
+ out[slot+2] = temp3;
+
+ temp1 = history[slot+3];
+ temp2 = history[slot+4];
+ temp3 = history[slot+5];
+ out[slot+3] = -temp1;
+ out[slot+4] = temp2;
+ out[slot+5] = -temp3;
+ }
+ }
+ else
+ {
+ for (slot = 0; slot < FILTERBANK_BANDS; slot += 3)
+ {
+ int32 temp1 = history[slot ];
+ int32 temp2 = history[slot+1];
+ int32 temp3 = history[slot+2];
+ out[slot ] = temp1;
+ out[slot+1] = temp2;
+ out[slot+2] = temp3;
+ }
+ }
+
+ pv_memset(history, 0, FILTERBANK_BANDS*sizeof(*overlap));
+ }
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_imdct_synth.h b/media/codecs/mp3dec/src/pvmp3_imdct_synth.h
new file mode 100644
index 0000000..ea42e49
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_imdct_synth.h
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_imdct_synth.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+*/
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+
+#ifndef PVMP3_IMDCT_SYNTH_H
+#define PVMP3_IMDCT_SYNTH_H
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES AND SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ void pvmp3_imdct_synth(int32 in[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ uint32 blk_type,
+ int16 mx_band,
+ int32 used_freq_lines,
+ int32 *Scratch_mem);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mdct_18.cpp b/media/codecs/mp3dec/src/pvmp3_mdct_18.cpp
new file mode 100644
index 0000000..324290e
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mdct_18.cpp
@@ -0,0 +1,290 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: mdct_18.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ int32 vec[], input vector of length 18
+ int32 *history input for overlap and add, vector updated with
+ next overlap and add values
+ const int32 *window sine window used in the mdct, three types are allowed
+ noraml, start and stop
+Returns
+ none mdct computation in-place
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Returns the mdct of length 18 of the input vector, as well as the overlap
+ vector for next iteration ( on history[])
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_mdct_18.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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 cosTerms_dct18[9] =
+{
+ Qfmt(0.50190991877167f), Qfmt(0.51763809020504f), Qfmt(0.55168895948125f),
+ Qfmt(0.61038729438073f), Qfmt(0.70710678118655f), Qfmt(0.87172339781055f),
+ Qfmt(1.18310079157625f), Qfmt(1.93185165257814f), Qfmt(5.73685662283493f)
+};
+
+
+const int32 cosTerms_1_ov_cos_phi[18] =
+{
+
+ Qfmt1(0.50047634258166f), Qfmt1(0.50431448029008f), Qfmt1(0.51213975715725f),
+ Qfmt1(0.52426456257041f), Qfmt1(0.54119610014620f), Qfmt1(0.56369097343317f),
+ Qfmt1(0.59284452371708f), Qfmt1(0.63023620700513f), Qfmt1(0.67817085245463f),
+
+ Qfmt2(0.74009361646113f), Qfmt2(0.82133981585229f), Qfmt2(0.93057949835179f),
+ Qfmt2(1.08284028510010f), Qfmt2(1.30656296487638f), Qfmt2(1.66275476171152f),
+ Qfmt2(2.31011315767265f), Qfmt2(3.83064878777019f), Qfmt2(11.46279281302667f)
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window)
+{
+ int32 i;
+ int32 tmp;
+ int32 tmp1;
+ int32 tmp2;
+ int32 tmp3;
+ int32 tmp4;
+
+
+
+ const int32 *pt_cos_split = cosTerms_dct18;
+ const int32 *pt_cos = cosTerms_1_ov_cos_phi;
+ const int32 *pt_cos_x = &cosTerms_1_ov_cos_phi[17];
+ int32 *pt_vec = vec;
+ int32 *pt_vec_o = &vec[17];
+
+
+ for (i = 9; i != 0; i--)
+ {
+ tmp = *(pt_vec);
+ tmp1 = *(pt_vec_o);
+ tmp = fxp_mul32_Q32(tmp << 1, *(pt_cos++));
+ tmp1 = fxp_mul32_Q27(tmp1, *(pt_cos_x--));
+ *(pt_vec++) = tmp + tmp1 ;
+ *(pt_vec_o--) = fxp_mul32_Q28((tmp - tmp1), *(pt_cos_split++));
+ }
+
+
+ pvmp3_dct_9(vec); // Even terms
+ pvmp3_dct_9(&vec[9]); // Odd terms
+
+
+ tmp3 = vec[16]; //
+ vec[16] = vec[ 8];
+ tmp4 = vec[14]; //
+ vec[14] = vec[ 7];
+ tmp = vec[12];
+ vec[12] = vec[ 6];
+ tmp2 = vec[10]; // vec[10]
+ vec[10] = vec[ 5];
+ vec[ 8] = vec[ 4];
+ vec[ 6] = vec[ 3];
+ vec[ 4] = vec[ 2];
+ vec[ 2] = vec[ 1];
+ vec[ 1] = vec[ 9] - tmp2; // vec[9] + vec[10]
+ vec[ 3] = vec[11] - tmp2;
+ vec[ 5] = vec[11] - tmp;
+ vec[ 7] = vec[13] - tmp;
+ vec[ 9] = vec[13] - tmp4;
+ vec[11] = vec[15] - tmp4;
+ vec[13] = vec[15] - tmp3;
+ vec[15] = vec[17] - tmp3;
+
+
+ /* overlap and add */
+
+ tmp2 = vec[0];
+ tmp3 = vec[9];
+
+ for (i = 0; i < 6; i++)
+ {
+ tmp = history[ i];
+ tmp4 = vec[i+10];
+ vec[i+10] = tmp3 + tmp4;
+ tmp1 = vec[i+1];
+ vec[ i] = fxp_mac32_Q32(tmp, (vec[i+10]), window[ i]);
+ tmp3 = tmp4;
+ history[i ] = -(tmp2 + tmp1);
+ tmp2 = tmp1;
+ }
+
+ tmp = history[ 6];
+ tmp4 = vec[16];
+ vec[16] = tmp3 + tmp4;
+ tmp1 = vec[7];
+ vec[ 6] = fxp_mac32_Q32(tmp, vec[16] << 1, window[ i]);
+ tmp = history[ 7];
+ history[6] = -(tmp2 + tmp1);
+ history[7] = -(tmp1 + vec[8]);
+
+ tmp1 = history[ 8];
+ tmp4 = vec[17] + tmp4;
+ vec[ 7] = fxp_mac32_Q32(tmp, tmp4 << 1, window[ 7]);
+ history[8] = -(vec[8] + vec[9]);
+ vec[ 8] = fxp_mac32_Q32(tmp1, vec[17] << 1, window[ 8]);
+
+ tmp = history[9];
+ tmp1 = history[17];
+ tmp2 = history[16];
+ vec[ 9] = fxp_mac32_Q32(tmp, vec[17] << 1, window[ 9]);
+
+ vec[17] = fxp_mac32_Q32(tmp1, vec[10] << 1, window[17]);
+ vec[10] = -vec[ 16];
+ vec[16] = fxp_mac32_Q32(tmp2, vec[11] << 1, window[16]);
+ tmp1 = history[15];
+ tmp2 = history[14];
+ vec[11] = -vec[ 15];
+ vec[15] = fxp_mac32_Q32(tmp1, vec[12] << 1, window[15]);
+ vec[12] = -vec[ 14];
+ vec[14] = fxp_mac32_Q32(tmp2, vec[13] << 1, window[14]);
+
+ tmp = history[13];
+ tmp1 = history[12];
+ tmp2 = history[11];
+ tmp3 = history[10];
+ vec[13] = fxp_mac32_Q32(tmp, vec[12] << 1, window[13]);
+ vec[12] = fxp_mac32_Q32(tmp1, vec[11] << 1, window[12]);
+ vec[11] = fxp_mac32_Q32(tmp2, vec[10] << 1, window[11]);
+ vec[10] = fxp_mac32_Q32(tmp3, tmp4 << 1, window[10]);
+
+
+ /* next iteration overlap */
+
+ tmp1 = history[ 8];
+ tmp3 = history[ 7];
+ tmp2 = history[ 1];
+ tmp = history[ 0];
+ tmp1 <<= 1;
+ tmp3 <<= 1;
+
+ history[ 0] = fxp_mul32_Q32(tmp1, window[18]);
+ history[17] = fxp_mul32_Q32(tmp1, window[35]);
+ history[ 1] = fxp_mul32_Q32(tmp3, window[19]);
+ history[16] = fxp_mul32_Q32(tmp3, window[34]);
+
+ tmp2 <<= 1;
+ tmp <<= 1;
+ history[ 7] = fxp_mul32_Q32(tmp2, window[25]);
+ history[10] = fxp_mul32_Q32(tmp2, window[28]);
+ history[ 8] = fxp_mul32_Q32(tmp, window[26]);
+ history[ 9] = fxp_mul32_Q32(tmp, window[27]);
+
+ tmp1 = history[ 6];
+ tmp3 = history[ 5];
+ tmp4 = history[ 4];
+ tmp2 = history[ 3];
+ tmp = history[ 2];
+
+ tmp1 <<= 1;
+ tmp3 <<= 1;
+ tmp4 <<= 1;
+
+ history[ 2] = fxp_mul32_Q32(tmp1, window[20]);
+ history[15] = fxp_mul32_Q32(tmp1, window[33]);
+ history[ 3] = fxp_mul32_Q32(tmp3, window[21]);
+ history[14] = fxp_mul32_Q32(tmp3, window[32]);
+ history[ 4] = fxp_mul32_Q32(tmp4, window[22]);
+ history[13] = fxp_mul32_Q32(tmp4, window[31]);
+ tmp2 <<= 1;
+ tmp <<= 1;
+ history[ 5] = fxp_mul32_Q32(tmp2, window[23]);
+ history[12] = fxp_mul32_Q32(tmp2, window[30]);
+ history[ 6] = fxp_mul32_Q32(tmp, window[24]);
+ history[11] = fxp_mul32_Q32(tmp, window[29]);
+}
+
+#endif // If not assembly
diff --git a/media/codecs/mp3dec/src/pvmp3_mdct_18.h b/media/codecs/mp3dec/src/pvmp3_mdct_18.h
new file mode 100644
index 0000000..2f2f65c
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mdct_18.h
@@ -0,0 +1,109 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./include/pvmp3_mdct_18.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines function mdct_18, dct9, mdct_6 and dct_6
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef MDCT_18_H
+#define MDCT_18_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define Qfmt(a) (Int32)((a)*((Int32)1<<28) )
+#define Qfmt1(a) (Int32)((a)*((Int32)0x7FFFFFFF))
+#define Qfmt2(a) (Int32)((a)*((Int32)1<<27))
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; 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 pvmp3_mdct_18(int32 vec[], int32 *history, const int32 *window);
+
+ void pvmp3_dct_9(int32 vec[]);
+
+ void pvmp3_mdct_6(int32 vec[], int32 *overlap);
+
+ void pvmp3_dct_6(int32 vec[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mdct_6.cpp b/media/codecs/mp3dec/src/pvmp3_mdct_6.cpp
new file mode 100644
index 0000000..1ba080d
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mdct_6.cpp
@@ -0,0 +1,165 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+ Filename: mdct_18.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ int32 vec[], input vector of length 6
+ int32 *history input for overlap and add, vector updated with
+ next overlap and add values
+Returns
+ none mdct computation in-place
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ Returns the mdct of length 6 of the input vector, as well as the overlap
+ vector for next iteration ( on history[])
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_mdct_6.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define QFORMAT 29
+#define Qfmt29(a) (int32)((a)*((int32)1<<QFORMAT) + ((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
+----------------------------------------------------------------------------*/
+/*
+ * (1./(2*cos((pi/(2*N))*(2*i+1)))), N = 12, i = [0:N/2-1]
+ */
+
+const int32 cosTerms_1_ov_cos_phi_N6[6] =
+{
+
+ Qfmt29(0.50431448029008f), Qfmt29(0.54119610014620f),
+ Qfmt29(0.63023620700513f), Qfmt29(0.82133981585229f),
+ Qfmt29(1.30656296487638f), Qfmt29(3.83064878777019f)
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+__attribute__((no_sanitize("integer")))
+void pvmp3_mdct_6(int32 vec[], int32 *history)
+{
+ int32 i;
+ int32 tmp;
+ int32 tmp1;
+ int32 tmp2;
+
+ int32 *pt_vec = vec;
+ int32 *pt_vec_o = vec;
+ const int32 *pt_cos = cosTerms_1_ov_cos_phi_N6;
+
+ for (i = 2; i != 0; i--)
+ {
+ tmp = *(pt_vec++);
+ tmp1 = *(pt_vec++);
+ tmp2 = *(pt_vec++);
+ *(pt_vec_o++) = fxp_mul32_Q29(tmp, *(pt_cos++));
+ *(pt_vec_o++) = fxp_mul32_Q29(tmp1, *(pt_cos++));
+ *(pt_vec_o++) = fxp_mul32_Q29(tmp2, *(pt_cos++));
+ }
+
+
+ pvmp3_dct_6(vec); // Even terms
+
+
+ tmp = -(vec[0] + vec[1]);
+ history[3] = tmp;
+ history[2] = tmp;
+ tmp = -(vec[1] + vec[2]);
+ vec[0] = vec[3] + vec[4];
+ vec[1] = vec[4] + vec[5];
+ history[4] = tmp;
+ history[1] = tmp;
+ tmp = -(vec[2] + vec[3]);
+ vec[4] = -vec[1];
+ history[5] = tmp;
+ history[0] = tmp;
+
+ vec[2] = vec[5];
+ vec[3] = -vec[5];
+ vec[5] = -vec[0];
+
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mdct_6.h b/media/codecs/mp3dec/src/pvmp3_mdct_6.h
new file mode 100644
index 0000000..af4f286
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mdct_6.h
@@ -0,0 +1,106 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Pathname: ./include/pvmp3_mdct_6.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines function mdct_18, dct9, mdct_6 and dct_6
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_MDCT_6_H
+#define PVMP3_MDCT_6_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define Qfmt(a) (Int32)((a)*((Int32)1<<28) )
+#define Qfmt1(a) (Int32)((a)*((Int32)0x7FFFFFFF))
+#define Qfmt2(a) (Int32)((a)*((Int32)1<<27))
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; 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 pvmp3_mdct_6(int32 vec[], int32 *overlap);
+
+ void pvmp3_dct_6(int32 vec[]);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp
new file mode 100644
index 0000000..499672b
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.cpp
@@ -0,0 +1,247 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_get_scale_data.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+ mp3SideInfo *si, side information
+ int32 gr, granule
+ int32 ch, channel
+ mp3Header *info, mp3 header information
+ uint32 *scalefac_buffer,
+ uint32 *scalefac_IIP_buffer,
+ tbits *pMainData bit stream Data
+
+ Returns
+
+ uint32 *scalefac_buffer, acquired scale band data
+ uint32 *scalefac_IIP_buffer, auxiliary scale data
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ get scale data for mpeg2 layer III LSF extension
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_mpeg2_get_scale_data.h"
+#include "pvmp3_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
+----------------------------------------------------------------------------*/
+
+const uint32 nr_of_sfb_block[6][3][4] =
+{ {{ 6, 5, 5, 5}, { 9, 9, 9, 9}, { 6, 9, 9, 9}},
+ {{ 6, 5, 7, 3}, { 9, 9, 12, 6}, { 6, 9, 12, 6}},
+ {{11, 10, 0, 0}, { 18, 18, 0, 0}, {15, 18, 0, 0}},
+ {{ 7, 7, 7, 0}, { 12, 12, 12, 0}, { 6, 15, 12, 0}},
+ {{ 6, 6, 6, 3}, { 12, 9, 9, 6}, { 6, 12, 9, 6}},
+ {{ 8, 8, 5, 0}, { 15, 12, 9, 0}, { 6, 18, 9, 0}}
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 pvmp3_mpeg2_get_scale_data(mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ mp3Header *info,
+ uint32 *scalefac_buffer,
+ uint32 *scalefac_IIP_buffer,
+ tmp3Bits *pMainData)
+{
+ int16 i;
+ int16 j;
+ int16 k;
+ int16 blocktypenumber = 0;
+ int16 blocknumber = 0;
+
+ granuleInfo *gr_info = &(si->ch[ch].gran[gr]);
+ uint32 scalefac_comp, int_scalefac_comp, new_slen[4] = { 0,0,0,0 };
+
+ scalefac_comp = gr_info->scalefac_compress;
+
+
+
+ if ((((info->mode_ext &1)) && (ch == 1)))
+ {
+ /* intensity_scale = scalefac_comp %2; */
+ int_scalefac_comp = scalefac_comp >> 1;
+
+ if (int_scalefac_comp < 180)
+ {
+ new_slen[0] = int_scalefac_comp / 36;
+ new_slen[1] = (int_scalefac_comp % 36) / 6;
+ new_slen[2] = int_scalefac_comp % 6;
+ blocknumber = 3;
+ }
+ else if (int_scalefac_comp < 244)
+ {
+ int_scalefac_comp -= 180;
+ new_slen[0] = (int_scalefac_comp & 63) >> 4;
+ new_slen[1] = (int_scalefac_comp & 15) >> 2;
+ new_slen[2] = int_scalefac_comp & 3;
+ blocknumber = 4;
+ }
+ else if (int_scalefac_comp <= 255)
+ {
+ int_scalefac_comp -= 244;
+ new_slen[0] = (int_scalefac_comp) / 3;
+ new_slen[1] = (int_scalefac_comp) % 3;
+ new_slen[2] = 0;
+ blocknumber = 5;
+ }
+ new_slen[3] = 0;
+ si->ch[ch].gran[gr].preflag = 0;
+ }
+ else
+ {
+ if (scalefac_comp < 400)
+ {
+ new_slen[0] = (scalefac_comp >> 4) / 5;
+ new_slen[1] = (scalefac_comp >> 4) % 5;
+ new_slen[2] = (scalefac_comp & 15) >> 2 ;
+ new_slen[3] = (scalefac_comp & 3);
+ si->ch[ch].gran[gr].preflag = 0;
+
+ blocknumber = 0;
+ }
+ else if (scalefac_comp < 500)
+ {
+ scalefac_comp -= 400;
+ new_slen[0] = (scalefac_comp >> 2) / 5;
+ new_slen[1] = (scalefac_comp >> 2) % 5;
+ new_slen[2] = scalefac_comp & 3;
+ new_slen[3] = 0;
+ si->ch[ch].gran[gr].preflag = 0;
+ blocknumber = 1;
+ }
+ else if (scalefac_comp < 512)
+ {
+ scalefac_comp -= 500;
+ new_slen[0] = scalefac_comp / 3;
+ new_slen[1] = scalefac_comp % 3;
+ new_slen[2] = 0 ;
+ new_slen[3] = 0;
+ si->ch[ch].gran[gr].preflag = 1;
+ blocknumber = 2;
+ }
+ }
+
+ if (gr_info->block_type == 2)
+ {
+ if (gr_info->mixed_block_flag)
+ {
+ blocktypenumber = 2;
+ }
+ else
+ {
+ blocktypenumber = 1;
+ }
+ }
+
+ k = 0;
+ for (i = 0; i < 4; i++)
+ {
+ if (new_slen[i])
+ {
+ for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++)
+ {
+ scalefac_buffer[k] = getNbits(pMainData, new_slen[i]);
+ scalefac_IIP_buffer[k] = (1L << new_slen[i]) - 1;
+ k++;
+ }
+ }
+ else
+ {
+ for (j = 0; j < (int16)nr_of_sfb_block[blocknumber][blocktypenumber][i]; j++)
+ {
+ scalefac_buffer[k] = 0;
+ scalefac_IIP_buffer[k] = 0;
+ k++;
+ }
+ }
+ }
+}
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h
new file mode 100644
index 0000000..630ed61
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_data.h
@@ -0,0 +1,105 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_get_scale_data.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_MPEG2_GET_SCALE_DATA_H
+#define PVMP3_MPEG2_GET_SCALE_DATA_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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 pvmp3_mpeg2_get_scale_data(mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ mp3Header *info,
+ uint32 *scalefac_buffer,
+ uint32 *scalefac_IIP_buffer,
+ tmp3Bits *pMainData);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp
new file mode 100644
index 0000000..e4d29d6
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.cpp
@@ -0,0 +1,202 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_get_scale_factors.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ mp3ScaleFactors *scalefac,
+ mp3SideInfo *si, side information
+ int32 gr, granule
+ int32 ch, channel
+ mp3Header *info, mp3 header information
+ uint32 *scalefac_IIP_buffer, auxiliary scale data
+ tbits *pMainData bit stream Data
+
+ Returns
+
+ III_scalefac_t *scalefac, scale factor
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ get scale factor for mpe2 layer III LSF extension
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_mpeg2_get_scale_factors.h"
+#include "pvmp3_mpeg2_get_scale_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
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+void pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac,
+ mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ mp3Header *info,
+ uint32 *scalefac_IIP_buffer,
+ tmp3Bits *pMainData)
+{
+
+ int32 sfb;
+ int32 k = 0;
+ int32 window;
+ uint32 *scalefac_buffer = &scalefac_IIP_buffer[56];
+
+ granuleInfo *gr_info = &(si->ch[ch].gran[gr]);
+
+ pvmp3_mpeg2_get_scale_data(si,
+ gr,
+ ch,
+ info,
+ (uint32 *)scalefac_buffer,
+ (uint32 *)scalefac_IIP_buffer,
+ pMainData);
+
+
+ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
+ {
+ if (gr_info->mixed_block_flag)
+ {
+ for (sfb = 0; sfb < 6; sfb++)
+ {
+ scalefac->l[sfb] = scalefac_buffer[sfb];
+ }
+
+
+ k = 6;
+ for (sfb = 3; sfb < 12; sfb++)
+ {
+ for (window = 0; window < 3; window++)
+ {
+ scalefac->s[window][sfb] = scalefac_buffer[k];
+ k++;
+ }
+ }
+
+
+ /* adjust position of "illegal position" information in scalefac_IIP_buffer[] */
+ /* in mixed blocks mode for short sfb, move them 3 places up. efs 3002-07-04 */
+ for (sfb = 11; sfb >= 3; sfb--)
+ {
+ scalefac_IIP_buffer[3*sfb + 2] = scalefac_IIP_buffer[3*sfb - 1];
+ scalefac_IIP_buffer[3*sfb + 1] = scalefac_IIP_buffer[3*sfb - 2];
+ scalefac_IIP_buffer[3*sfb ] = scalefac_IIP_buffer[3*sfb - 3];
+
+ }
+ }
+ else
+ { /* SHORT*/
+ for (sfb = 0; sfb < 12; sfb++)
+ {
+ for (window = 0; window < 3; window++)
+ {
+ scalefac->s[window][sfb] = scalefac_buffer[k];
+ k++;
+ }
+ }
+ }
+
+ scalefac->s[0][12] = 0;
+ scalefac->s[1][12] = 0;
+ scalefac->s[2][12] = 0;
+
+ }
+ else
+ { /* LONG types 0,1,3 */
+ for (sfb = 0; sfb < 21; sfb++)
+ {
+ scalefac->l[sfb] = scalefac_buffer[sfb];
+ }
+ scalefac->l[21] = 0;
+ scalefac->l[22] = 0;
+
+ }
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h
new file mode 100644
index 0000000..46d16b3
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_get_scale_factors.h
@@ -0,0 +1,105 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_get_scale_factors.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_MPEG2_GET_SCALE_FACTORS_H
+#define PVMP3_MPEG2_GET_SCALE_FACTORS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_audio_type_defs.h"
+#include "s_mp3bits.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-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 pvmp3_mpeg2_get_scale_factors(mp3ScaleFactors *scalefac,
+ mp3SideInfo *si,
+ int32 gr,
+ int32 ch,
+ mp3Header *info,
+ uint32 *scalefac_IIP_buffer,
+ tmp3Bits *pMainData);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp b/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp
new file mode 100644
index 0000000..a70e716
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.cpp
@@ -0,0 +1,700 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_stereo_proc.cpp
+
+ Functions:
+
+ pvmp3_st_intensity_ver2
+ pvmp3_mpeg2_stereo_proc
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+
+------------------------------------------------------------------------------
+
+pvmp3_st_intensity_ver2
+
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ int32 xr[], input channel
+ int32 xl[],
+ int32 m, selecting index: io = 2(1/4) (m=0), io = 2(1/8) (m=1)
+ int32 is_pos, index on table is_pos_pow_eitgh_root_of_2
+ int32 Start, Location of first element where stereo intensity is applied
+ int32 Number number of elements affected
+
+ Returns
+
+ int32 xl[], generated stereo channel
+
+
+
+
+------------------------------------------------------------------------------
+
+pvmp3_mpeg2_stereo_proc
+
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ int32 xr[], input channel
+ int32 xl[],
+ mp3ScaleFactors *scalefac, scale factors structure for Right channel
+ granuleInfo *gr_info_l, granule structure for the left channel
+ granuleInfo *gr_info_r, granule structure for the rigth channel
+ uint32 *scalefac_IIP_buffer, auxiliary scale factor vector
+ mp3Header *info mp3 header info
+ Returns
+
+ int32 xl[], generated stereo channel
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ stereo processing for mpeg2 layer III LSF extension
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_mpeg2_stereo_proc.h"
+#include "pvmp3_stereo_proc.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_tables.h"
+#include "mp3_mem_funcs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+const int32 is_pos_pow_eitgh_root_of_2[8] =
+{
+ /* --- 2^(1/8) ----- */
+ Q31_fmt(1.00000000000000), Q31_fmt(0.91700404320467), Q31_fmt(0.84089641525371),
+ Q31_fmt(0.77110541270397), Q31_fmt(0.70710678118655), Q31_fmt(0.64841977732550),
+ Q31_fmt(0.59460355750136), Q31_fmt(0.54525386633263)
+};
+
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions 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 pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 m,
+ int32 is_pos,
+ int32 Start,
+ int32 Number)
+{
+ int32 k[2];
+
+ /* pow(io, ((is_pos + 1)>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */
+ k[0] = is_pos_pow_eitgh_root_of_2[((is_pos+1)&(3+(m<<2)))<<(1-m)] >> ((is_pos + 1) >> (2 + m));
+ /* pow(io, (is_pos>>1)); io = 2(1/4) (m=0), io = 2(1/8) (m=1) */
+ k[1] = is_pos_pow_eitgh_root_of_2[(is_pos&(3+(m<<2)))<<(1-m)] >> (is_pos >> (2 + m));
+
+
+ int32 *pt_xr = &xr[Start];
+ int32 *pt_xl = &xl[Start];
+
+ if (is_pos == 0) /* 0 < is_pos < 31 */
+ {
+ pv_memcpy(pt_xl, pt_xr, Number*sizeof(*pt_xr));
+ }
+ else if (is_pos & 1)
+ {
+ for (int32 i = Number >> 1; i != 0; i--)
+ {
+ *(pt_xl++) = (*pt_xr);
+ *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]);
+ pt_xr++;
+ *(pt_xl++) = (*pt_xr);
+ *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]);
+ pt_xr++;
+ }
+ if (Number&1)
+ {
+ *(pt_xl) = (*pt_xr);
+ *(pt_xr) = fxp_mul32_Q32((*pt_xr) << 1, k[0]);
+ }
+ }
+ else
+ {
+ for (int32 i = Number >> 1; i != 0; i--)
+ {
+ *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]);
+ *(pt_xl++) = fxp_mul32_Q32((*(pt_xr++)) << 1, k[1]);
+ }
+ if (Number&1)
+ {
+ *(pt_xl) = fxp_mul32_Q32((*pt_xr) << 1, k[1]);
+ }
+ }
+
+}
+
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac_R,
+ granuleInfo *gr_info_l,
+ granuleInfo *gr_info_r,
+ uint32 *scalefac_IIP_buffer,
+ int32 used_freq_lines,
+ mp3Header *info)
+{
+
+ int32 sfreq;
+ int32 sb;
+ int32 ss;
+ int32 sfbNo;
+ int32 sfbStart;
+ int32 sfb;
+ int32 sfbTemp;
+ int32 i;
+ int32 j;
+ int32 io;
+
+
+ int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) &&
+ (info->mode_ext & 0x1);
+
+ int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) &&
+ (info->mode_ext & 0x2);
+
+
+ if (i_stereo)
+ {
+ if (gr_info_r->scalefac_compress & 1)
+ {
+ io = 0; /* 2^(-1/4) */
+ }
+ else
+ {
+ io = 1; /* 2^(-1/8) */
+ }
+
+ sfreq = info->version_x + (info->version_x << 1);
+ sfreq += info->sampling_frequency;
+
+ if (gr_info_l->window_switching_flag && (gr_info_l->block_type == 2))
+ {
+ if (gr_info_l->mixed_block_flag)
+ {
+ /*
+ * mixed blocks processing
+ */
+ i = 31;
+ ss = 17;
+ sb = -1;
+
+ while (i >= 0)
+ {
+ if (xl[(i*FILTERBANK_BANDS) + ss])
+ {
+ sb = (i << 4) + (i << 1) + ss;
+ i = -1;
+ }
+ else
+ {
+ ss--;
+ if (ss < 0)
+ {
+ i--;
+ ss = 17;
+ }
+ }
+ } /* now sb is the number of highest line with value != 0 */
+ /* can be between -1 (all lines zero) and 575 (no line zero) */
+
+ if (sb < 36) /* was (sb <= 36) */
+ {
+ /*
+ * mixed blocks processing: intensity bound inside long blocks
+ */
+ /* 1. long blocks up to intensity border: Stereo or M/S */
+ if (mp3_sfBandIndex[sfreq].l[4] <= sb)
+ {
+ i = 4;
+ }
+ else
+ {
+ i = 0;
+ }
+
+ while (mp3_sfBandIndex[sfreq].l[i] <= sb)
+ {
+ i++;
+ }
+ sfbTemp = i; /* from that (long) sfb on we have intensity stereo */
+
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* number of lines to process */
+
+ /* from sfbStart up sfbNo lines do ms_stereo or normal stereo */
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, sfbNo);
+ }
+
+ /* 2. long blocks from intensity border up to sfb band 6: intensity */
+ /* calc. MPEG_1_2_Factor[0], MPEG_1_2_Factor[1] */
+
+ for (sfb = sfbTemp; sfb < 6; sfb++)
+ {
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* = Start in 0 ... 575 */
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */
+
+ if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb])
+ {
+ pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+
+ /* 3. now process all sfb with short blocks (3...12), all in intensity mode */
+
+ for (j = 0; j < 3; j++)
+ {
+ /* first calculate directional factors for intensity stereo,
+ * for all sfb in intensity mode, but only
+ * if they do not have "illegal" position:
+ */
+ /* to do this for all sfb we have to get information for last scale factor band:
+ * here we clearly have more than one sfb in intensity mode,
+ * so copy factors and legal/illegal information from sfb11 to sfb12
+ */
+ (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]);
+ scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */
+
+ for (sfb = 3; sfb < 13; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
+
+ if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])
+ {
+ pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+ } /* for (j = 0; j < 3; j++) */
+ }
+ else /* else then (sb >= 36) */
+ {
+ /*
+ * mixed blocks processing: intensity bound outside long blocks
+ */
+
+ /* 2. short blocks, do for all 3 */
+ /* ------------------------------ */
+ for (j = 0; j < 3; j++)
+ {
+ int32 sfbcnt = -1;
+
+ for (sfb = 12; sfb >= 3; sfb--)
+ {
+ int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+
+ i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1;
+
+ while (lines > 0)
+ {
+ if (xl[i])
+ {
+ sfbcnt = sfb;
+ sfb = -10;
+ lines = -10;
+ }
+ lines--;
+ i--;
+ }
+ }
+
+ sfbcnt += 1;
+ if (sfbcnt < 3)
+ {
+ sfbcnt = 3; /* should not be necessary */
+ }
+
+ sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */
+ /* can have values between 3 (all short sfb in intensity) */
+ /* and 13 (no short sfb in intensity mode) */
+
+ /* 3. from sfbTemp to last sfb calculate is_ratio values: */
+ /* first calculate directional factors for intensity stereo, */
+ /* for all sfb in intensity mode, but only */
+ /* if they do not have "illegal" position: */
+
+ /* to do this for all sfb we have to get information for last scale factor band: */
+ /* get factors for last scale factor band: */
+ /* more than one sfb in intensity mode,
+ copy factors and legal/illegal information from sfb11 to sfb12 */
+ if (sfbTemp < 12)
+ {
+ (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]);
+ scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */
+ }
+ else if (sfbTemp == sfb)
+ /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */
+ {
+ (scalefac_R->s[j][12]) = 0;
+ scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */
+ }
+ /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */
+
+
+ /* 4. do normal stereo or MS stereo from sfb 3 to < sfbTemp: */
+ for (sfb = 3; sfb < sfbTemp; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+
+ /* 5. now intensity stereo processing of the remaining sfb's: */
+
+ for (sfb = sfbTemp; sfb < 13; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
+ if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])
+ {
+ pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+ /* end of correction by efs 2003-07-04 */
+ } /* for (j = 0; j < 3; j++) */
+
+
+ /* long blocks 0 up to sfb band 6: no intensity */
+
+ sfbNo = mp3_sfBandIndex[sfreq].l[6]; /* number of lines to process */
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, sfbNo);
+ }
+
+ } /* if intensity bound inside or outside long blocks */
+ } /* if (gr_info->mixed_block_flag) */
+ else
+ {
+ /*
+ * short block processing
+ */
+ for (j = 0; j < 3; j++)
+ {
+ int32 sfbcnt = -1;
+
+ for (sfb = 12; sfb >= 0; sfb--)
+ {
+ int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+ i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1;
+
+ while (lines > 0)
+ {
+ if (xl[i])
+ {
+ sfbcnt = sfb;
+ sfb = -10;
+ lines = -10;
+ }
+ lines--;
+ i--;
+ }
+ }
+
+ sfbcnt += 1;
+
+ /* start of corrected version by efs 2003-07-04 */
+ sfbTemp = sfbcnt; /* from this (short) sfb on we have intensity mode */
+ /* can have values between 3 (all short sfb in intensity) */
+ /* and 13 (no short sfb in intensity mode) */
+
+ /* first calculate directional factors for intensity stereo,
+ for all sfb in intensity mode, but only
+ if they do not have "illegal" position: */
+
+ /* to do this for all sfb we have to get information for last scale factor band: */
+ /* get factors for last scale factor band: */
+ /* more than one sfb in intensity mode,
+ copy factors and legal/illegal information from sfb11 to sfb12 */
+ if (sfbTemp < 12)
+ {
+ (scalefac_R->s[j][12]) = (scalefac_R->s[j][11]);
+ scalefac_IIP_buffer[36 + j] = scalefac_IIP_buffer[33 + j]; /* legal/illegal in sfb 12 same as in sfb 11 */
+ }
+ else if (sfbTemp == 12)
+ /* only sfb 12 in intensity mode, use factors corresponding to is_pos[12] == 0 */
+ {
+ (scalefac_R->s[j][12]) = 0;
+ scalefac_IIP_buffer[36 + j] = 1; /* the scf value 0 in sfb12 is "legal" */
+ }
+ /* if sfbTemp > sfb (no sfb in intensity mode): do nothing */
+
+
+ /* Now process audio samples */
+ /* first process lower sfb's not in intensity mode */
+ for (sfb = 0; sfb < sfbTemp; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+
+ /* now intensity stereo processing of the remaining sfb's: */
+ for (sfb = sfbTemp; sfb < 13; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfb] + j * sfbNo;
+
+ if ((uint32)(scalefac_R->s[j][sfb]) != scalefac_IIP_buffer[3*sfb + j])
+ {
+ pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->s[j][sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+
+ } /* for (j = 0; j < 3; j++) */
+
+ } /* end of else ( gr_info->mixed_block_flag) */
+
+ } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */
+ else
+ {
+ /*
+ * long block processing
+ */
+ i = 31;
+ ss = 17;
+ sb = 0;
+
+ while (i >= 0)
+ {
+ if (xl[(i*FILTERBANK_BANDS) + ss])
+ {
+ sb = (i << 4) + (i << 1) + ss;
+ /* i = -1 patched RF 24-09-2002 */
+ i = -2;
+ }
+ else
+ {
+ ss--;
+ if (ss < 0)
+ {
+ i--;
+ ss = 17;
+ }
+ }
+ }
+
+ /* patched RF 24-09-2002 */
+ if (sb)
+ {
+ if (mp3_sfBandIndex[sfreq].l[14] <= sb)
+ {
+ i = 14;
+ }
+ else if (mp3_sfBandIndex[sfreq].l[7] <= sb)
+ {
+ i = 7;
+ }
+ else
+ {
+ i = 0;
+ }
+
+ while (mp3_sfBandIndex[sfreq].l[i] <= sb)
+ {
+ i++;
+ }
+ }
+
+ else
+ {
+ if (i == -1)
+ {
+ /* all xr[1][][] are 0: set IS bound sfb to 0 */
+ i = 0;
+ }
+ else
+ {
+ /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */
+ i = 1;
+ }
+ }
+ /* corrected version by efs 2003-07-04 */
+ sfbTemp = i; /* from this (long) sfb on we have intensity mode */
+ /* can have values between 0 (all long sfb in intensity) */
+ /* and 22 (no long sfb in intensity mode) */
+
+ /* first calculate directional factors for intensity stereo,
+ for all sfb in intensity mode, but only if they
+ do not have "illegal" position: */
+
+ /* to do this for all sfb we have to get information for last scale factor band: */
+ if (sfbTemp < 21)
+ /* more than one sfb in intensity mode, */
+ /* copy factors and legal/illegal information from sfb20 to sfb21 */
+ {
+ (scalefac_R->l[21]) = (scalefac_R->l[20]);
+ scalefac_IIP_buffer[21] = scalefac_IIP_buffer[20]; /* legal/illegal in sfb 21 same as in sfb 20 */
+ }
+ else if (sfbTemp == 21)
+ /* only sfb 21 in intensity mode, is_pos[21] = 0 */
+ {
+ (scalefac_R->l[21]) = 0;
+ scalefac_IIP_buffer[21] = 1; /* the scf value 0 in sfb21 is "legal" */
+ }
+ /* if sfbTemp > 21 (no sfb in intensity mode): do nothing */
+
+
+ /* Now process audio samples */
+ /* first process lower sfb's not in intensity mode */
+
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp] - mp3_sfBandIndex[sfreq].l[0];
+ sfbStart = mp3_sfBandIndex[sfreq].l[0];
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ /* now intensity stereo processing of the remaining sfb's: */
+ for (sfb = sfbTemp; sfb < 22; sfb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* number of lines to process */
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfb]; /* start of sfb */
+
+ if ((uint32)(scalefac_R->l[sfb]) != scalefac_IIP_buffer[sfb]) /* "legal" position ? */
+ {
+ pvmp3_st_intensity_ver2(xr, xl, io, scalefac_R->l[sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (sfb = sfbTemp; sfb < 22; sfb++) */
+
+ } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */
+
+ } /* if (i_stereo) */
+ else
+ {
+ /*
+ * normal or ms stereo processing
+ */
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, used_freq_lines);
+ }
+
+ } /* if (i_stereo) */
+
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h b/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h
new file mode 100644
index 0000000..7db0c53
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_mpeg2_stereo_proc.h
@@ -0,0 +1,112 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_mpeg2_stereo_proc.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_MPEG2_STEREO_PROC_H
+#define PVMP3_MPEG2_STEREO_PROC_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_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 pvmp3_mpeg2_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac,
+ granuleInfo *gr_info_l,
+ granuleInfo *gr_info_r,
+ uint32 *scalefac_IIP_buffer,
+ int32 used_freq_lines,
+ mp3Header *info);
+
+
+ void pvmp3_st_intensity_ver2(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 m,
+ int32 is_pos,
+ int32 Start,
+ int32 Number);
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_normalize.cpp b/media/codecs/mp3dec/src/pvmp3_normalize.cpp
new file mode 100644
index 0000000..885ab08
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_normalize.cpp
@@ -0,0 +1,174 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_normalize.cpp
+
+ Date: 10/02/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ 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 "pvmp3_audio_type_defs.h"
+#include "pvmp3_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(PV_ARM_V5)||defined(PV_ARM_V4))
+#elif (defined(PV_ARM_GCC_V5)||defined(PV_ARM_GCC_V4))
+
+
+/* function is inlined in header file */
+
+
+#else
+
+int32 pvmp3_normalize(int32 x)
+{
+ /*----------------------------------------------------------------------------
+ ; Define all local variables
+ ----------------------------------------------------------------------------*/
+ int32 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++;
+ break;
+
+ default:
+ ;
+ }
+
+ return i;
+
+}
+
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_normalize.h b/media/codecs/mp3dec/src/pvmp3_normalize.h
new file mode 100644
index 0000000..5471771
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_normalize.h
@@ -0,0 +1,108 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_normalize.h
+
+ Date: 10/02/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PVMP3_NORMALIZE_H
+#define PVMP3_NORMALIZE_H
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES AND SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
+
+__inline int32 pvmp3_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 int32 pvmp3_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
+
+ int32 pvmp3_normalize(int32 x);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
+
+#endif /* PV_NORMALIZE_H */
diff --git a/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp b/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp
new file mode 100644
index 0000000..33c8e61
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp
@@ -0,0 +1,187 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_poly_phase_synthesis.cpp
+
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Input
+ tmp3dec_chan *pChVars, decoder state structure per channel
+ int32 numChannels, number of channels
+ e_equalization equalizerType, equalization mode
+ int16 *outPcm pointer to the PCM output data
+
+ Output
+ int16 *outPcm pointer to the PCM output data
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ polyphase synthesis
+ Each time the subband samples for all 32 polyphase subbands of one
+ channel have been calculated, they can be applied to the synthesis
+ subband filter and 32 consecutive audio samples can be calculated
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_poly_phase_synthesis.h"
+#include "pvmp3_polyphase_filter_window.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_dct_16.h"
+#include "pvmp3_equalizer.h"
+#include "mp3_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 pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars,
+ int32 numChannels,
+ e_equalization equalizerType,
+ int16 *outPcm)
+{
+ /*
+ * Equalizer
+ */
+ pvmp3_equalizer(pChVars->circ_buffer,
+ equalizerType,
+ pChVars->work_buf_int32);
+
+
+ int16 * ptr_out = outPcm;
+
+
+ for (int32 band = 0; band < FILTERBANK_BANDS; band += 2)
+ {
+ int32 *inData = &pChVars->circ_buffer[544 - (band<<5)];
+
+ /*
+ * DCT 32
+ */
+
+ pvmp3_split(&inData[16]);
+
+ pvmp3_dct_16(&inData[16], 0);
+ pvmp3_dct_16(inData, 1); // Even terms
+
+ pvmp3_merge_in_place_N32(inData);
+
+ pvmp3_polyphase_filter_window(inData,
+ ptr_out,
+ numChannels);
+
+ inData -= SUBBANDS_NUMBER;
+
+ /*
+ * DCT 32
+ */
+
+ pvmp3_split(&inData[16]);
+
+ pvmp3_dct_16(&inData[16], 0);
+ pvmp3_dct_16(inData, 1); // Even terms
+
+ pvmp3_merge_in_place_N32(inData);
+
+ pvmp3_polyphase_filter_window(inData,
+ ptr_out + (numChannels << 5),
+ numChannels);
+
+ ptr_out += (numChannels << 6);
+
+ inData -= SUBBANDS_NUMBER;
+
+ }/* end band loop */
+
+ pv_memmove(&pChVars->circ_buffer[576],
+ pChVars->circ_buffer,
+ 480*sizeof(*pChVars->circ_buffer));
+
+}
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h b/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h
new file mode 100644
index 0000000..166cffd
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.h
@@ -0,0 +1,102 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_poly_phase_synthesis.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_POLY_PHASE_SYNTHESIS_H
+#define PVMP3_POLY_PHASE_SYNTHESIS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "s_tmp3dec_chan.h"
+#include "pvmp3decoder_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
+----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ void pvmp3_poly_phase_synthesis(tmp3dec_chan *pChVars,
+ int32 numChannels,
+ e_equalization equalizerType,
+ int16 *outPcm);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp b/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp
new file mode 100644
index 0000000..8380437
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.cpp
@@ -0,0 +1,239 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_polyphase_filter_window.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+
+Input
+ int32 *synth_buffer, synthesis input buffer
+ int16 *outPcm, generated output ( 32 values)
+ int32 numChannels number of channels
+ Returns
+
+ int16 *outPcm
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ apply polyphase filter window
+ Input 32 subband samples
+ Calculate 64 values
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+#if ( !defined(PV_ARM_GCC_V5) && !defined(PV_ARM_GCC_V4) && !defined(PV_ARM_V5) && !defined(PV_ARM_V4) )
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_polyphase_filter_window.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_tables.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module1 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 module1
+----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------
+; EXTERNAL FUNCTION REFERENCES
+; Declare functions defined elsewhere and referenced in this module_x
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL GLOBAL STORE/BUFFER/POINTER REFERENCES
+; Declare variables used in this module_x but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+void pvmp3_polyphase_filter_window(int32 *synth_buffer,
+ int16 *outPcm,
+ int32 numChannels)
+{
+ int32 sum1;
+ int32 sum2;
+ const int32 *winPtr = pqmfSynthWin;
+ int32 i;
+
+
+ for (int16 j = 1; j < SUBBANDS_NUMBER / 2; j++)
+ {
+ sum1 = 0x00000020;
+ sum2 = 0x00000020;
+
+
+ for (i = (SUBBANDS_NUMBER >> 1);
+ i < HAN_SIZE + (SUBBANDS_NUMBER >> 1);
+ i += SUBBANDS_NUMBER << 4)
+ {
+ int32 *pt_1 = &synth_buffer[ i+j];
+ int32 *pt_2 = &synth_buffer[ i-j];
+ int32 temp1 = pt_1[ 0];
+ int32 temp3 = pt_2[ SUBBANDS_NUMBER*15 ];
+ int32 temp2 = pt_2[ SUBBANDS_NUMBER* 1 ];
+ int32 temp4 = pt_1[ SUBBANDS_NUMBER*14 ];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 0]);
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 0]);
+ sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 1]);
+ sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 1]);
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 2]);
+ sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 2]);
+ sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 3]);
+ sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 3]);
+
+ temp1 = pt_1[ SUBBANDS_NUMBER* 2];
+ temp3 = pt_2[ SUBBANDS_NUMBER*13];
+ temp2 = pt_2[ SUBBANDS_NUMBER* 3];
+ temp4 = pt_1[ SUBBANDS_NUMBER*12];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 4]);
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 4]);
+ sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 5]);
+ sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 5]);
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[ 6]);
+ sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[ 6]);
+ sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[ 7]);
+ sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[ 7]);
+
+ temp1 = pt_1[ SUBBANDS_NUMBER* 4 ];
+ temp3 = pt_2[ SUBBANDS_NUMBER*11 ];
+ temp2 = pt_2[ SUBBANDS_NUMBER* 5 ];
+ temp4 = pt_1[ SUBBANDS_NUMBER*10 ];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[ 8]);
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[ 8]);
+ sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[ 9]);
+ sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[ 9]);
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[10]);
+ sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[10]);
+ sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[11]);
+ sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[11]);
+
+ temp1 = pt_1[ SUBBANDS_NUMBER*6 ];
+ temp3 = pt_2[ SUBBANDS_NUMBER*9 ];
+ temp2 = pt_2[ SUBBANDS_NUMBER*7 ];
+ temp4 = pt_1[ SUBBANDS_NUMBER*8 ];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[12]);
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[12]);
+ sum2 = fxp_mac32_Q32(sum2, temp1, winPtr[13]);
+ sum1 = fxp_msb32_Q32(sum1, temp3, winPtr[13]);
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[14]);
+ sum2 = fxp_msb32_Q32(sum2, temp4, winPtr[14]);
+ sum2 = fxp_mac32_Q32(sum2, temp2, winPtr[15]);
+ sum1 = fxp_mac32_Q32(sum1, temp4, winPtr[15]);
+
+ winPtr += 16;
+ }
+
+
+
+ int32 k = j << (numChannels - 1);
+ outPcm[k] = saturate16(sum1 >> 6);
+ outPcm[(numChannels<<5) - k] = saturate16(sum2 >> 6);
+ }
+
+
+
+ sum1 = 0x00000020;
+ sum2 = 0x00000020;
+
+
+ for (i = 16; i < HAN_SIZE + 16; i += (SUBBANDS_NUMBER << 2))
+ {
+ int32 *pt_synth = &synth_buffer[i];
+ int32 temp1 = pt_synth[ 0 ];
+ int32 temp2 = pt_synth[ SUBBANDS_NUMBER ];
+ int32 temp3 = pt_synth[ SUBBANDS_NUMBER/2];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[0]) ;
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[1]) ;
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[2]) ;
+
+ temp1 = pt_synth[ SUBBANDS_NUMBER<<1 ];
+ temp2 = pt_synth[ 3*SUBBANDS_NUMBER ];
+ temp3 = pt_synth[ SUBBANDS_NUMBER*5/2];
+
+ sum1 = fxp_mac32_Q32(sum1, temp1, winPtr[3]) ;
+ sum1 = fxp_mac32_Q32(sum1, temp2, winPtr[4]) ;
+ sum2 = fxp_mac32_Q32(sum2, temp3, winPtr[5]) ;
+
+ winPtr += 6;
+ }
+
+
+ outPcm[0] = saturate16(sum1 >> 6);
+ outPcm[(SUBBANDS_NUMBER/2)<<(numChannels-1)] = saturate16(sum2 >> 6);
+
+
+}
+
+#endif // If not assembly
+
diff --git a/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h b/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h
new file mode 100644
index 0000000..b9eccad
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_polyphase_filter_window.h
@@ -0,0 +1,138 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_decode_header.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_POLYPHASE_FILTER_WINDOW_H
+#define PVMP3_POLYPHASE_FILTER_WINDOW_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_audio_type_defs.h"
+#include "s_tmp3dec_chan.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define MAX_16BITS_INT 0x7FFF
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; 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
+
+
+#if (defined(PV_ARM_V5)||defined(PV_ARM_V4))
+
+
+ __inline int16 saturate16(int32 sample)
+ {
+ int32 a;
+ int32 b = 31;
+ __asm
+ {
+ mov a, sample, asr#15
+ teq a, sample, asr b
+ eorne sample, MAX_16BITS_INT, sample, asr#31
+ }
+ return sample ;
+ }
+
+#else
+
+ inline int16 saturate16(int32 sample)
+ {
+
+ if ((sample >> 15) ^(sample >> 31))
+ {
+ sample = MAX_16BITS_INT ^(sample >> 31);
+ }
+ return sample;
+
+ }
+#endif
+
+
+ void pvmp3_polyphase_filter_window(int32 *synth_buffer,
+ int16 *outPcm,
+ int32 numChannels);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_reorder.cpp b/media/codecs/mp3dec/src/pvmp3_reorder.cpp
new file mode 100644
index 0000000..286c636
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_reorder.cpp
@@ -0,0 +1,197 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_reorder.cpp
+
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+ Inputs:
+
+ int32 xr[ ], rescaled data
+ struct gr_info_s *gr_info, granule structure
+ mp3Header *info, mp3 header info
+ int32 Scratch_mem[198] for temporary usage
+
+ Outputs:
+
+ int32 xr[ ], reordered data
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ If short blocks are used (block_type[gr][ch]=='10'), the rescaled data
+ xr[scf_band][window][freq_line] shall be reordered in polyphase subband
+ order, xr[subband][window][freq_line], prior to the IMDCT operation.
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_reorder.h"
+#include "pvmp3_tables.h"
+#include "mp3_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 pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ granuleInfo *gr_info,
+ int32 *used_freq_lines,
+ mp3Header *info,
+ int32 Scratch_mem[198])
+{
+ int32 sfreq = info->version_x + (info->version_x << 1);
+ sfreq += info->sampling_frequency;
+
+ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
+ {
+ int32 sfb_lines;
+ int32 freq;
+ int32 src_line;
+ int32 sfb;
+ if (gr_info->mixed_block_flag)
+ {
+ /* REORDERING FOR REST SWITCHED SHORT */
+ sfb = 3; /* no reorder for low 2 subbands */
+ src_line = 36;
+ }
+ else
+ { /* pure short */
+ sfb = 0;
+ src_line = 0;
+ }
+ int16 ct = src_line;
+
+ for (; sfb < 13; sfb++)
+ {
+ if (*used_freq_lines > 3*mp3_sfBandIndex[sfreq].s[sfb+1])
+ {
+ sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+
+ for (freq = 0; freq < 3*sfb_lines; freq += 3)
+ {
+ int32 tmp1 = xr[src_line];
+ int32 tmp2 = xr[src_line+(sfb_lines)];
+ int32 tmp3 = xr[src_line+(sfb_lines<<1)];
+ src_line++;
+ Scratch_mem[freq ] = tmp1;
+ Scratch_mem[freq+1] = tmp2;
+ Scratch_mem[freq+2] = tmp3;
+ }
+ src_line += (sfb_lines << 1);
+
+ pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32));
+ ct += sfb_lines + (sfb_lines << 1);
+
+ }
+ else
+ {
+
+ sfb_lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+
+ for (freq = 0; freq < 3*sfb_lines; freq += 3)
+ {
+ int32 tmp1 = xr[src_line];
+ int32 tmp2 = xr[src_line+(sfb_lines)];
+ int32 tmp3 = xr[src_line+(sfb_lines<<1)];
+ src_line++;
+ Scratch_mem[freq ] = tmp1;
+ Scratch_mem[freq+1] = tmp2;
+ Scratch_mem[freq+2] = tmp3;
+ }
+
+ pv_memcpy(&xr[ct], Scratch_mem, sfb_lines*3*sizeof(int32));
+
+ *used_freq_lines = mp3_sfBandIndex[sfreq].s[sfb+1] * 3;
+
+ sfb = 13; /* force out of the for-loop */
+ }
+ }
+ }
+}
+
+
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_reorder.h b/media/codecs/mp3dec/src/pvmp3_reorder.h
new file mode 100644
index 0000000..5248951
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_reorder.h
@@ -0,0 +1,103 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_reorder.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_REORDER_H
+#define PVMP3_REORDER_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_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 pvmp3_reorder(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ granuleInfo *gr_info,
+ int32 *used_freq_lines,
+ mp3Header *info,
+ int32 Scratch_mem[198]);
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_seek_synch.cpp b/media/codecs/mp3dec/src/pvmp3_seek_synch.cpp
new file mode 100644
index 0000000..82faafd
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_seek_synch.cpp
@@ -0,0 +1,308 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_seek_synch.cpp
+
+ Functions:
+ pvmp3_seek_synch
+ pvmp3_header_sync
+
+
+ Date: 9/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+pvmp3_frame_synch
+
+Input
+ pExt = pointer to the external interface structure. See the file
+ pvmp3decoder_api.h for a description of each field.
+ Data type of pointer to a tPVMP3DecoderExternal
+ structure.
+
+ pMem = void pointer to hide the internal implementation of the library
+ It is cast back to a tmp3dec_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 tmp3dec_file
+ structure.
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ search mp3 sync word, when found, it verifies, based on header parameters,
+ the locations of the very next sync word,
+ - if fails, then indicates a false sync,
+ - otherwise, it confirm synchronization of at least 2 consecutives frames
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_seek_synch.h"
+#include "pvmp3_getbits.h"
+#include "s_tmp3dec_file.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_tables.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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
+----------------------------------------------------------------------------*/
+
+
+
+ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt,
+ void *pMem) /* bit stream structure */
+{
+ uint16 val;
+ ERROR_CODE err;
+
+ tmp3dec_file *pVars;
+
+ pVars = (tmp3dec_file *)pMem;
+
+ pVars->inputStream.pBuffer = pExt->pInputBuffer;
+ pVars->inputStream.usedBits = (pExt->inputBufferUsedLength << 3); // in bits
+
+
+ pVars->inputStream.inputBufferCurrentLength = (pExt->inputBufferCurrentLength); // in bits
+
+ err = pvmp3_header_sync(&pVars->inputStream);
+
+ if (err == NO_DECODING_ERROR)
+ {
+ /* validate synchronization by checking two consecutive sync words */
+
+ // to avoid multiple bitstream accesses
+ uint32 temp = getNbits(&pVars->inputStream, 21);
+ // put back whole header
+ pVars->inputStream.usedBits -= 21 + SYNC_WORD_LNGTH;
+
+ int32 version;
+
+ switch (temp >> 19) /* 2 */
+ {
+ case 0:
+ version = MPEG_2_5;
+ break;
+ case 2:
+ version = MPEG_2;
+ break;
+ case 3:
+ version = MPEG_1;
+ break;
+ default:
+ version = INVALID_VERSION;
+ break;
+ }
+
+ int32 freq_index = (temp << 20) >> 30;
+
+ if (version != INVALID_VERSION && (freq_index != 3))
+ {
+ int32 numBytes = fxp_mul32_Q28(mp3_bitrate[version][(temp<<16)>>28] << 20,
+ inv_sfreq[freq_index]);
+
+ numBytes >>= (20 - version);
+
+ if (version != MPEG_1)
+ {
+ numBytes >>= 1;
+ }
+ if ((temp << 22) >> 31)
+ {
+ numBytes++;
+ }
+
+ if (numBytes > (int32)pVars->inputStream.inputBufferCurrentLength)
+ {
+ /* frame should account for padding and 2 bytes to check sync */
+ pExt->CurrentFrameLength = numBytes + 3;
+ return (SYNCH_LOST_ERROR);
+ }
+ else if (numBytes == (int32)pVars->inputStream.inputBufferCurrentLength)
+ {
+ /* No enough data to validate, but current frame appears to be correct ( EOF case) */
+ pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3;
+ return (NO_DECODING_ERROR);
+ }
+ else
+ {
+
+ int32 offset = pVars->inputStream.usedBits + ((numBytes) << 3);
+
+ offset >>= INBUF_ARRAY_INDEX_SHIFT;
+ uint8 *pElem = pVars->inputStream.pBuffer + offset;
+ uint16 tmp1 = *(pElem++);
+ uint16 tmp2 = *(pElem);
+
+ val = (tmp1 << 3);
+ val |= (tmp2 >> 5);
+ }
+ }
+ else
+ {
+ val = 0; // force mismatch
+ }
+
+ if (val == SYNC_WORD)
+ {
+ pExt->inputBufferUsedLength = pVars->inputStream.usedBits >> 3; /// !!!!!
+ err = NO_DECODING_ERROR;
+ }
+ else
+ {
+ pExt->inputBufferCurrentLength = 0;
+ err = SYNCH_LOST_ERROR;
+ }
+ }
+ else
+ {
+ pExt->inputBufferCurrentLength = 0;
+ }
+
+ return(err);
+
+}
+
+/*
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+------------------------------------------------------------------------------
+ INPUT AND OUTPUT DEFINITIONS
+
+pvmp3_header_sync
+
+Input
+ tmp3Bits *inputStream, structure holding the input stream parameters
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ search mp3 sync word
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+
+ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream)
+{
+ uint16 val;
+ uint32 availableBits = (inputStream->inputBufferCurrentLength << 3); // in bits
+
+ // byte aligment
+ inputStream->usedBits = (inputStream->usedBits + 7) & 8;
+
+ val = (uint16)getUpTo17bits(inputStream, SYNC_WORD_LNGTH);
+
+ while (((val&SYNC_WORD) != SYNC_WORD) && (inputStream->usedBits < availableBits))
+ {
+ val <<= 8;
+ val |= getUpTo9bits(inputStream, 8);
+ }
+
+ if ((val&SYNC_WORD) == SYNC_WORD && (inputStream->usedBits < availableBits))
+ {
+ return(NO_DECODING_ERROR);
+ }
+ else
+ {
+ return(SYNCH_LOST_ERROR);
+ }
+
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_seek_synch.h b/media/codecs/mp3dec/src/pvmp3_seek_synch.h
new file mode 100644
index 0000000..8097cee
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_seek_synch.h
@@ -0,0 +1,106 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_seek_synch.h
+
+ Date: 09/21/2007
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_SEEK_SYNCH_H
+#define PVMP3_SEEK_SYNCH_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3decoder_api.h"
+#include "s_tmp3dec_file.h"
+#include "pvmp3_dec_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
+
+ ERROR_CODE pvmp3_frame_synch(tPVMP3DecoderExternal *pExt,
+ void *pMem);
+
+ ERROR_CODE pvmp3_header_sync(tmp3Bits *inputStream);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif /* DECODE_READ_INPUT_H */
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_stereo_proc.cpp b/media/codecs/mp3dec/src/pvmp3_stereo_proc.cpp
new file mode 100644
index 0000000..4338c43
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_stereo_proc.cpp
@@ -0,0 +1,680 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_stereo_proc.cpp
+
+ Functions:
+
+ pvmp3_st_mid_side
+ pvmp3_st_intensity
+ pvmp3_stereo_proc
+
+------------------------------------------------------------------------------
+
+pvmp3_st_mid_side
+
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ int32 xr[], input channel
+ int32 xl[],
+ int32 Start, Location of first element where stereo intensity is applied
+ int32 Number number of elements affected
+
+ Returns
+
+ int32 xl[], generated stereo channel
+
+
+------------------------------------------------------------------------------
+
+pvmp3_st_intensity
+
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ int32 xr[], input channel
+ int32 xl[],
+ int32 is_pos, index to table is_ratio_factor[]
+ int32 Start, Location of first element where stereo intensity is applied
+ int32 Number number of elements affected
+
+ Returns
+
+ int32 xl[], generated stereo channel
+
+
+------------------------------------------------------------------------------
+
+pvmp3_stereo_proc
+
+ INPUT AND OUTPUT DEFINITIONS
+
+Input
+
+ int32 xr[], input channel
+ int32 xl[],
+ mp3ScaleFactors *scalefac, scale factors structure
+ struct gr_info_s *gr_info, granule structure
+ mp3Header *info mp3 header info
+ Returns
+
+ int32 xl[], generated stereo channel
+
+
+------------------------------------------------------------------------------
+ FUNCTION DESCRIPTION
+
+ stereo processing for mpeg1 layer III
+ After requantization, the reconstructed values are processed for ms_stereo
+ or intensity_stereo modes or both, before passing them to the synthesis
+ filterbank
+
+ In ms_stereo mode the values of the normalized middle/side channels
+ M[l] and S[l] are transmitted instead of the left/right channel values
+ L[l] and R[l]. From here, L[l] and R[l] are reconstructed
+
+ Intensity_stereo is done by specifying the magnitude (via the
+ scalefactors of the left channel) and a stereo position is_pos[sfb],
+ which is transmitted instead of scalefactors of the right channel.
+ The stereo position is used to derive the left and right channel signals
+
+------------------------------------------------------------------------------
+ REQUIREMENTS
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+ PSEUDO-CODE
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_stereo_proc.h"
+#include "pv_mp3dec_fxd_op.h"
+#include "pvmp3_tables.h"
+
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here. Include conditional
+; compile variables also.
+----------------------------------------------------------------------------*/
+#define N31 31
+
+#define Q31_fmt(a) (int32(double(0x7FFFFFFF)*(a)))
+
+/*----------------------------------------------------------------------------
+; LOCAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; LOCAL STORE/BUFFER/POINTER DEFINITIONS
+; Variable declaration - defined here and used outside this module
+----------------------------------------------------------------------------*/
+/*
+ * TmpFac= tan(is_pos * (PI /12));
+ *
+ * TmpFac /= (1 + TmpFac);
+ *
+ */
+
+const int32 is_ratio_factor[8] = {0,
+ Q31_fmt(0.21132486540519), Q31_fmt(0.36602540378444), Q31_fmt(0.50000000000000),
+ Q31_fmt(0.63397459621556), Q31_fmt(0.78867513459481), Q31_fmt(1.00000000000000),
+ 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
+----------------------------------------------------------------------------*/
+
+#if __has_attribute(no_sanitize)
+// deliberately playing near overflow points of int32
+__attribute__((no_sanitize("integer")))
+#endif
+void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 Start,
+ int32 Number)
+{
+
+ int32 *pt_xr = &xr[Start];
+ int32 *pt_xl = &xl[Start];
+
+ for (int32 i = Number >> 1; i != 0; i--)
+ {
+ int32 xxr = *(pt_xr) << 1;
+ int32 xxl = *(pt_xl) << 1;
+ *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */
+ *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */
+ xxr = *(pt_xr) << 1;
+ xxl = *(pt_xl) << 1;
+ *(pt_xr++) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */
+ *(pt_xl++) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */
+ }
+
+
+ if (Number&1)
+ {
+ int32 xxr = *(pt_xr) << 1;
+ int32 xxl = *(pt_xl) << 1;
+ *(pt_xr) = fxp_mul32_Q32((xxr + xxl), Q31_fmt(0.70710678118655)); /* Sum */
+ *(pt_xl) = fxp_mul32_Q32((xxr - xxl), Q31_fmt(0.70710678118655)); /* Diff */
+ }
+
+}
+
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+
+void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 is_pos,
+ int32 Start,
+ int32 Number)
+{
+
+ int32 TmpFac = is_ratio_factor[ is_pos & 7];
+
+ int32 *pt_xr = &xr[Start];
+ int32 *pt_xl = &xl[Start];
+
+ for (int32 i = Number >> 1; i != 0; i--)
+ {
+ int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac);
+ *(pt_xl++) = (*pt_xr) - tmp;
+ *(pt_xr++) = tmp;
+ tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac);
+ *(pt_xl++) = (*pt_xr) - tmp;
+ *(pt_xr++) = tmp;
+ }
+
+ if (Number&1)
+ {
+ int32 tmp = fxp_mul32_Q32((*pt_xr) << 1, TmpFac);
+ *(pt_xl) = (*pt_xr) - tmp;
+ *(pt_xr) = tmp;
+ }
+
+}
+
+/*----------------------------------------------------------------------------
+; FUNCTION CODE
+----------------------------------------------------------------------------*/
+void pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac,
+ granuleInfo *gr_info,
+ int32 used_freq_lines,
+ mp3Header *info)
+{
+
+
+ int32 sb;
+ int32 ss;
+ int32 sfbNo;
+ int32 sfbStart;
+
+ int32 sfb;
+ int32 sfbTemp;
+ int32 i;
+ int32 j;
+
+
+ int32 i_stereo = (info->mode == MPG_MD_JOINT_STEREO) &&
+ (info->mode_ext & 0x1);
+
+ int32 ms_stereo = (info->mode == MPG_MD_JOINT_STEREO) &&
+ (info->mode_ext & 0x2);
+
+ int32 sfreq = info->version_x + (info->version_x << 1);
+ sfreq += info->sampling_frequency;
+
+
+
+
+ if (i_stereo)
+ {
+ if (gr_info->window_switching_flag && (gr_info->block_type == 2))
+ {
+ if (gr_info->mixed_block_flag)
+ {
+ /*
+ * mixed blocks processing
+ */
+ i = 31;
+ ss = 17;
+ sb = 0;
+ while (i >= 0)
+ {
+ if (xl[(i*FILTERBANK_BANDS) + ss])
+ {
+ sb = (i << 4) + (i << 1) + ss;
+ i = -1;
+ }
+ else
+ {
+ ss--;
+ if (ss < 0)
+ {
+ i--;
+ ss = 17;
+ }
+ }
+ }
+
+ if (sb < 36)
+ {
+ /*
+ * mixed blocks processing: intensity bound inside long blocks
+ */
+ /* 1. long blocks up to intensity border: not intensity */
+
+ if (mp3_sfBandIndex[sfreq].l[4] <= sb)
+ {
+ sfb = 4;
+ }
+ else
+ {
+ sfb = 0;
+ }
+
+ while (mp3_sfBandIndex[sfreq].l[sfb] < sb)
+ {
+ sfb++;
+ }
+
+ /* from that sfb on intensity stereo */
+ sfbTemp = sfb; /* save for later use */
+
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfb];
+
+ /* from 0 up to sfbStart do ms_stereo or normal stereo */
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, sfbStart);
+ }
+
+ /* 2. long blocks from intensity border up to sfb band 8: intensity */
+ /* calc. is_ratio */
+
+
+ /* Start of intensity stereo of remaining sfc bands: */
+ for (; sfbTemp < 8; sfbTemp++)
+ {
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfbTemp]; /* = Start in 0 ... 575 */
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfbTemp+1] - mp3_sfBandIndex[sfreq].l[sfbTemp]; /* No of lines to process */
+
+ if (scalefac->l[sfbTemp] != 7)
+ {
+ pvmp3_st_intensity(xr, xl, scalefac->l[sfbTemp], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (; sfbTemp < 8; sfbTemp++) */
+
+ for (j = 0; j < 3; j++)
+ {
+ /* 3. short blocks from sfbcnt to last sfb do intensity stereo */
+ for (sfbTemp = 3; sfbTemp < 13; sfbTemp++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo;
+
+ if (scalefac->s[j][sfbTemp] != 7)
+ {
+ pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (; sfbTemp < 22; sfbTemp++) */
+ } /* for (j = 0; j < 3; j++) */
+ }
+ else /* else for (sb >= 36) */
+ {
+ /*
+ * mixed blocks processing: intensity bound outside long blocks
+ */
+
+
+ /*
+ * 2. short blocks from sfb band 3 up to intensity border: normal stereo, ms stereo and intensity
+ */
+ for (j = 0; j < 3; j++)
+ {
+ int32 sfbcnt;
+ sfbcnt = -1;
+
+ for (sfb = 12; sfb >= 3; sfb--)
+ {
+ int32 lines;
+ lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+ i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1;
+
+ while (lines > 0)
+ {
+ if (xl[i])
+ {
+ sfbcnt = sfb;
+ sfb = -10;
+ lines = -10;
+ }
+ lines--;
+ i--;
+ }
+ }
+
+ sfbcnt += 1;
+ if (sfbcnt < 3)
+ {
+ sfbcnt = 3;
+ }
+
+ sfbTemp = sfbcnt; /* for later use */
+
+
+ /*
+ * do normal stereo or MS stereo from sfb 3 to < sfbcnt:
+ */
+ for (sb = 3; sb < sfbcnt; sb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb];
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo;
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ }
+
+ /* from sfbcnt to last sfb do intensity stereo */
+ for (; sfbTemp < 13; sfbTemp++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo;
+
+ if (scalefac->s[j][sfbTemp] != 7)
+ {
+ pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (; sfbTemp < 22; sfbTemp++) */
+
+ } /* for (j = 0; j < 3; j++) */
+
+ /* 1. long blocks up to sfb band 8: not intensity */
+ /* from 0 to sfb 8 ms_stereo or normal stereo */
+
+ sfbStart = mp3_sfBandIndex[sfreq].l[8];
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, sfbStart);
+ }
+
+ }
+ } /* if (gr_info->mixed_block_flag) */
+ else
+ {
+ /*
+ * short block processing
+ */
+ for (j = 0; j < 3; j++)
+ {
+ int32 sfbcnt = -1;
+
+ for (sfb = 12; sfb >= 0; sfb--)
+ {
+ int32 lines = mp3_sfBandIndex[sfreq].s[sfb+1] - mp3_sfBandIndex[sfreq].s[sfb];
+ i = 3 * mp3_sfBandIndex[sfreq].s[sfb] + (j + 1) * lines - 1;
+
+ while (lines > 0)
+ {
+ if (xl[i])
+ {
+ sfbcnt = sfb;
+ sfb = -10;
+ lines = -10;
+ }
+ lines--;
+ i--;
+ }
+ }
+
+ sfbcnt += 1;
+ sfbTemp = sfbcnt; /* for later use */
+
+ /* do normal stereo or MS stereo from 0 to sfbcnt */
+ for (sb = 0; sb < sfbcnt; sb++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sb+1] - mp3_sfBandIndex[sfreq].s[sb];
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sb] + j * sfbNo;
+
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+ }
+
+
+ /* from sfbcnt to last sfb do intensity stereo */
+ for (; sfbTemp < 13; sfbTemp++)
+ {
+ sfbNo = mp3_sfBandIndex[sfreq].s[sfbTemp+1] - mp3_sfBandIndex[sfreq].s[sfbTemp]; /* No of lines to process */
+ sfbStart = 3 * mp3_sfBandIndex[sfreq].s[sfbTemp] + j * sfbNo;
+
+ if (scalefac->s[j][sfbTemp] != 7)
+ {
+ pvmp3_st_intensity(xr, xl, scalefac->s[j][sfbTemp], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (; sfbTemp < 22; sfbTemp++) */
+
+ } /* for (j = 0; j < 3; j++) */
+
+ } /* if( gr_info->mixed_block_flag) */
+
+
+
+ } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */
+ else
+ {
+ /*
+ * long block processing
+ */
+ i = 31;
+ ss = 17;
+ sb = 0;
+
+ while (i >= 0)
+ {
+ if (xl[(i*FILTERBANK_BANDS) + ss] != 0)
+ {
+ sb = (i << 4) + (i << 1) + ss;
+ i = -2;
+ }
+ else
+ {
+ ss--;
+ if (ss < 0)
+ {
+ i--;
+ ss = 17;
+ }
+ }
+ }
+
+ if (sb)
+ {
+ if (mp3_sfBandIndex[sfreq].l[14] <= sb)
+ {
+ sfb = 14;
+ }
+ else if (mp3_sfBandIndex[sfreq].l[7] <= sb)
+ {
+ sfb = 7;
+ }
+ else
+ {
+ sfb = 0;
+ }
+
+
+ while (mp3_sfBandIndex[sfreq].l[sfb] <= sb)
+ {
+ sfb++;
+ }
+ }
+ else
+ {
+ if (i == -1)
+ {
+ /* all xr[1][][] are 0: set IS bound sfb to 0 */
+ sfb = 0;
+ }
+ else
+ {
+ /* xr[1][0][0] is unequal 0 and all others are 0: set IS bound sfb to 1 */
+ sfb = 1;
+ }
+ }
+
+ sfbTemp = sfb; /* save for later use */
+
+
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfb];
+
+ /* from 0 to sfbStart ms_stereo or normal stereo */
+ if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, 0, sfbStart);
+ }
+
+ /* now intensity stereo of the remaining sfb's: */
+ for (; sfb < 21; sfb++)
+ {
+ sfbStart = mp3_sfBandIndex[sfreq].l[sfb];
+ sfbNo = mp3_sfBandIndex[sfreq].l[sfb+1] - mp3_sfBandIndex[sfreq].l[sfb]; /* No of lines to process */
+
+ if (scalefac->l[sfb] != 7)
+ {
+ pvmp3_st_intensity(xr, xl, scalefac->l[sfb], sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* for (; sfbTemp < 22; sfbTemp++) */
+
+
+
+ sfbStart = mp3_sfBandIndex[sfreq].l[21];
+ sfbNo = mp3_sfBandIndex[sfreq].l[22] - mp3_sfBandIndex[sfreq].l[21]; /* No of lines to process */
+
+ if (scalefac->l[21] != 7)
+ {
+ if (sfbTemp < 21)
+ {
+ sfbTemp = scalefac->l[20];
+ }
+ else
+ {
+ sfbTemp = 0; /* if scalefac[20] is not an intensity position, is_pos = 0 */
+ }
+
+ pvmp3_st_intensity(xr, xl, sfbTemp, sfbStart, sfbNo);
+ }
+ else if (ms_stereo)
+ {
+ pvmp3_st_mid_side(xr, xl, sfbStart, sfbNo);
+ }
+
+ } /* if (gr_info->window_switching_flag && (gr_info->block_type == 2)) */
+
+
+ } /* if (i_stereo) */
+ else
+ {
+ /*
+ * normal or ms stereo processing
+ */
+ if (ms_stereo)
+ {
+
+ pvmp3_st_mid_side(xr, xl, 0, used_freq_lines);
+
+ }
+
+ } /* if (i_stereo) */
+
+}
+
diff --git a/media/codecs/mp3dec/src/pvmp3_stereo_proc.h b/media/codecs/mp3dec/src/pvmp3_stereo_proc.h
new file mode 100644
index 0000000..bfaf1a1
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_stereo_proc.h
@@ -0,0 +1,114 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_stereo_proc.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef PVMP3_STEREO_PROC_H
+#define PVMP3_STEREO_PROC_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pvmp3_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 pvmp3_stereo_proc(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ mp3ScaleFactors *scalefac,
+ granuleInfo *gr_info,
+ int32 used_freq_lines,
+ mp3Header *info);
+
+ void pvmp3_st_intensity(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 is_pos,
+ int32 Start,
+ int32 Number);
+
+ void pvmp3_st_mid_side(int32 xr[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 xl[SUBBANDS_NUMBER*FILTERBANK_BANDS],
+ int32 Start,
+ int32 Number);
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/pvmp3_tables.cpp b/media/codecs/mp3dec/src/pvmp3_tables.cpp
new file mode 100644
index 0000000..91113e3
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_tables.cpp
@@ -0,0 +1,2934 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: pvmp3_tables.cpp
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+
+ Description:
+
+
+------------------------------------------------------------------------------
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+------------------------------------------------------------------------------
+*/
+
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_tables.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; 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 mp3_s_freq[4][4] =
+{
+ {44100, 48000, 32000, 0},
+ {22050, 24000, 16000, 0},
+ {11025, 12000, 8000, 0}
+}; // MPEG-2.5
+
+
+/*
+ * 144000./s_freq
+ */
+const int32 inv_sfreq[4] =
+{
+ Qfmt_28(3.26530612244898),
+ Qfmt_28(3.0),
+ Qfmt_28(4.5),
+ 0
+};
+
+
+/* 1: MPEG-1, 0: MPEG-2 LSF, 1995-07-11 shn */
+
+
+const int16 mp3_bitrate[3][15] =
+{
+ {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160},
+ {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160}
+};
+
+
+const mp3_scaleFactorBandIndex mp3_sfBandIndex[9] =
+{
+
+ /* MPEG 1 */
+
+ {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 52, 62, 74, 90, 110, 134, 162, 196, 238, 288, 342, 418, 576},
+ {0, 4, 8, 12, 16, 22, 30, 40, 52, 66, 84, 106, 136, 192}},
+ {{0, 4, 8, 12, 16, 20, 24, 30, 36, 42, 50, 60, 72, 88, 106, 128, 156, 190, 230, 276, 330, 384, 576},
+ {0, 4, 8, 12, 16, 22, 28, 38, 50, 64, 80, 100, 126, 192}},
+ {{0, 4, 8, 12, 16, 20, 24, 30, 36, 44, 54, 66, 82, 102, 126, 156, 194, 240, 296, 364, 448, 550, 576},
+ {0, 4, 8, 12, 16, 22, 30, 42, 58, 78, 104, 138, 180, 192}},
+
+ /* MPEG 2 - LSF */
+
+ {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+ {0, 4, 8, 12, 18, 24, 32, 42, 56, 74, 100, 132, 174, 192}},
+ {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 114, 136, 162, 194, 232, 278, 332, 394, 464, 540, 576},
+ {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 136, 180, 192}},
+ {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+ {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}},
+
+ /* MPEG 2.5 extension */
+
+ {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+ {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}},
+ {{0, 6, 12, 18, 24, 30, 36, 44, 54, 66, 80, 96, 116, 140, 168, 200, 238, 284, 336, 396, 464, 522, 576},
+ {0, 4, 8, 12, 18, 26, 36, 48, 62, 80, 104, 134, 174, 192}},
+ {{0, 12, 24, 36, 48, 60, 72, 88, 108, 132, 160, 192, 232, 280, 336, 400, 476, 566, 568, 570, 572, 574, 576},
+ {0, 8, 16, 24, 36, 52, 72, 96, 124, 160, 162, 164, 166, 192}}
+
+};
+
+#define INV_Q31( x) (int32)(0x7FFFFFFF/(float)(x) - 1.0f)
+
+const int32 mp3_shortwindBandWidths[9][13] =
+{
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10),
+ INV_Q31(12), INV_Q31(14), INV_Q31(18), INV_Q31(22), INV_Q31(30), INV_Q31(56)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(10),
+ INV_Q31(12), INV_Q31(14), INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(66)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(12),
+ INV_Q31(16), INV_Q31(20), INV_Q31(26), INV_Q31(34), INV_Q31(42), INV_Q31(12)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(6), INV_Q31(8), INV_Q31(10),
+ INV_Q31(14), INV_Q31(18), INV_Q31(26), INV_Q31(32), INV_Q31(42), INV_Q31(18)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12),
+ INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(32), INV_Q31(44), INV_Q31(12)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12),
+ INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12),
+ INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)},
+ { INV_Q31(4), INV_Q31(4), INV_Q31(4), INV_Q31(6), INV_Q31(8), INV_Q31(10), INV_Q31(12),
+ INV_Q31(14), INV_Q31(18), INV_Q31(24), INV_Q31(30), INV_Q31(40), INV_Q31(18)},
+ { INV_Q31(8), INV_Q31(8), INV_Q31(8), INV_Q31(12), INV_Q31(16), INV_Q31(20), INV_Q31(24),
+ INV_Q31(28), INV_Q31(36), INV_Q31(2), INV_Q31(2), INV_Q31(2), INV_Q31(26)}
+};
+
+
+#define Q30_fmt(a) (int32((0x40000000)*(a)))
+
+const int32 pqmfSynthWin[(HAN_SIZE/2) + 8] =
+{
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000396729F), Q30_fmt(0.000473022F), Q30_fmt(0.003173828F),
+ Q30_fmt(0.003326416F), Q30_fmt(0.006118770F), Q30_fmt(0.007919310F), Q30_fmt(0.031478880F),
+ Q30_fmt(0.030517578F), Q30_fmt(0.073059080F), Q30_fmt(0.084182740F), Q30_fmt(0.108856200F),
+ Q30_fmt(0.090927124F), Q30_fmt(0.543823240F), Q30_fmt(0.600219727F), Q30_fmt(1.144287109F),
+
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000366211F), Q30_fmt(0.000534058F), Q30_fmt(0.003082275F),
+ Q30_fmt(0.003387451F), Q30_fmt(0.005294800F), Q30_fmt(0.008865360F), Q30_fmt(0.031738280F),
+ Q30_fmt(0.029785160F), Q30_fmt(0.067520140F), Q30_fmt(0.089706420F), Q30_fmt(0.116577150F),
+ Q30_fmt(0.080688480F), Q30_fmt(0.515609740F), Q30_fmt(0.628295900F), Q30_fmt(1.142211914F),
+
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000320435F), Q30_fmt(0.000579834F), Q30_fmt(0.002990723F),
+ Q30_fmt(0.003433228F), Q30_fmt(0.004486080F), Q30_fmt(0.009841920F), Q30_fmt(0.031845090F),
+ Q30_fmt(0.028884890F), Q30_fmt(0.061996460F), Q30_fmt(0.095169070F), Q30_fmt(0.123474120F),
+ Q30_fmt(0.069595340F), Q30_fmt(0.487472530F), Q30_fmt(0.656219480F), Q30_fmt(1.138763428F),
+
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000289917F), Q30_fmt(0.000625610F), Q30_fmt(0.002899170F),
+ Q30_fmt(0.003463745F), Q30_fmt(0.003723140F), Q30_fmt(0.010849000F), Q30_fmt(0.031814580F),
+ Q30_fmt(0.027801510F), Q30_fmt(0.056533810F), Q30_fmt(0.100540160F), Q30_fmt(0.129577640F),
+ Q30_fmt(0.057617190F), Q30_fmt(0.459472660F), Q30_fmt(0.683914180F), Q30_fmt(1.133926392F),
+
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000259399F), Q30_fmt(0.000686646F), Q30_fmt(0.002792358F),
+ Q30_fmt(0.003479004F), Q30_fmt(0.003005981F), Q30_fmt(0.011886600F), Q30_fmt(0.031661990F),
+ Q30_fmt(0.026535030F), Q30_fmt(0.051132200F), Q30_fmt(0.105819700F), Q30_fmt(0.134887700F),
+ Q30_fmt(0.044784550F), Q30_fmt(0.431655880F), Q30_fmt(0.711318970F), Q30_fmt(1.127746582F),
+
+ Q30_fmt(-0.000015259F), Q30_fmt(0.000244141F), Q30_fmt(0.000747681F), Q30_fmt(0.002685547F),
+ Q30_fmt(0.003479004F), Q30_fmt(0.002334595F), Q30_fmt(0.012939450F), Q30_fmt(0.031387330F),
+ Q30_fmt(0.025085450F), Q30_fmt(0.045837400F), Q30_fmt(0.110946660F), Q30_fmt(0.139450070F),
+ Q30_fmt(0.031082153F), Q30_fmt(0.404083250F), Q30_fmt(0.738372800F), Q30_fmt(1.120223999F),
+
+ Q30_fmt(-0.000030518F), Q30_fmt(0.000213623F), Q30_fmt(0.000808716F), Q30_fmt(0.002578735F),
+ Q30_fmt(0.003463745F), Q30_fmt(0.001693726F), Q30_fmt(0.014022830F), Q30_fmt(0.031005860F),
+ Q30_fmt(0.023422240F), Q30_fmt(0.040634160F), Q30_fmt(0.115921020F), Q30_fmt(0.143264770F),
+ Q30_fmt(0.016510010F), Q30_fmt(0.376800540F), Q30_fmt(0.765029907F), Q30_fmt(1.111373901F),
+
+ Q30_fmt(-0.000030518F), Q30_fmt(0.000198364F), Q30_fmt(0.000885010F), Q30_fmt(0.002456665F),
+ Q30_fmt(0.003417969F), Q30_fmt(0.001098633F), Q30_fmt(0.015121460F), Q30_fmt(0.030532840F),
+ Q30_fmt(0.021575930F), Q30_fmt(0.035552980F), Q30_fmt(0.120697020F), Q30_fmt(0.146362300F),
+ Q30_fmt(0.001068120F), Q30_fmt(0.349868770F), Q30_fmt(0.791213990F), Q30_fmt(1.101211548F),
+
+ Q30_fmt(-0.000030518F), Q30_fmt(0.000167847F), Q30_fmt(0.000961304F), Q30_fmt(0.002349854F),
+ Q30_fmt(0.003372192F), Q30_fmt(0.000549316F), Q30_fmt(0.016235350F), Q30_fmt(0.029937740F),
+ Q30_fmt(0.019531250F), Q30_fmt(0.030609130F), Q30_fmt(0.125259400F), Q30_fmt(0.148773190F),
+ Q30_fmt(-0.015228270F), Q30_fmt(0.323318480F), Q30_fmt(0.816864010F), Q30_fmt(1.089782715F),
+
+ Q30_fmt(-0.000030518F), Q30_fmt(0.000152588F), Q30_fmt(0.001037598F), Q30_fmt(0.002243042F),
+ Q30_fmt(0.003280640F), Q30_fmt(0.000030518F), Q30_fmt(0.017349240F), Q30_fmt(0.029281620F),
+ Q30_fmt(0.017257690F), Q30_fmt(0.025817870F), Q30_fmt(0.129562380F), Q30_fmt(0.150497440F),
+ Q30_fmt(-0.032379150F), Q30_fmt(0.297210693F), Q30_fmt(0.841949463F), Q30_fmt(1.077117920F),
+
+ Q30_fmt(-0.000045776F), Q30_fmt(0.000137329F), Q30_fmt(0.001113892F), Q30_fmt(0.002120972F),
+ Q30_fmt(0.003173828F), Q30_fmt(-0.000442505F), Q30_fmt(0.018463130F), Q30_fmt(0.028533940F),
+ Q30_fmt(0.014801030F), Q30_fmt(0.021179200F), Q30_fmt(0.133590700F), Q30_fmt(0.151596070F),
+ Q30_fmt(-0.050354000F), Q30_fmt(0.271591190F), Q30_fmt(0.866363530F), Q30_fmt(1.063217163F),
+
+ Q30_fmt(-0.000045776F), Q30_fmt(0.000122070F), Q30_fmt(0.001205444F), Q30_fmt(0.002014160F),
+ Q30_fmt(0.003051758F), Q30_fmt(-0.000869751F), Q30_fmt(0.019577030F), Q30_fmt(0.027725220F),
+ Q30_fmt(0.012115480F), Q30_fmt(0.016708370F), Q30_fmt(0.137298580F), Q30_fmt(0.152069090F),
+ Q30_fmt(-0.069168090F), Q30_fmt(0.246505740F), Q30_fmt(0.890090940F), Q30_fmt(1.048156738F),
+
+ Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001296997F), Q30_fmt(0.001907349F),
+ Q30_fmt(0.002883911F), Q30_fmt(-0.001266479F), Q30_fmt(0.020690920F), Q30_fmt(0.026840210F),
+ Q30_fmt(0.009231570F), Q30_fmt(0.012420650F), Q30_fmt(0.140670780F), Q30_fmt(0.151962280F),
+ Q30_fmt(-0.088775630F), Q30_fmt(0.221984860F), Q30_fmt(0.913055420F), Q30_fmt(1.031936646F),
+
+ Q30_fmt(-0.000061035F), Q30_fmt(0.000106812F), Q30_fmt(0.001388550F), Q30_fmt(0.001785278F),
+ Q30_fmt(0.002700806F), Q30_fmt(-0.001617432F), Q30_fmt(0.021789550F), Q30_fmt(0.025909420F),
+ Q30_fmt(0.006134030F), Q30_fmt(0.008316040F), Q30_fmt(0.143676760F), Q30_fmt(0.151306150F),
+ Q30_fmt(-0.109161380F), Q30_fmt(0.198059080F), Q30_fmt(0.935195920F), Q30_fmt(1.014617920F),
+
+ Q30_fmt(-0.000076294F), Q30_fmt(0.000091553F), Q30_fmt(0.001480103F), Q30_fmt(0.001693726F),
+ Q30_fmt(0.002487183F), Q30_fmt(-0.001937866F), Q30_fmt(0.022857670F), Q30_fmt(0.024932860F),
+ Q30_fmt(0.002822880F), Q30_fmt(0.004394530F), Q30_fmt(0.146255490F), Q30_fmt(0.150115970F),
+ Q30_fmt(-0.130310060F), Q30_fmt(0.174789430F), Q30_fmt(0.956481930F), Q30_fmt(0.996246338F),
+
+ Q30_fmt(0.000000000F), Q30_fmt(0.000442505F), Q30_fmt(0.001586910F), Q30_fmt(0.003250122F),
+ Q30_fmt(0.007003780F), Q30_fmt(0.023910525F), Q30_fmt(0.031082153F), Q30_fmt(0.078628545F),
+ Q30_fmt(0.148422240F), Q30_fmt(0.100311279F), Q30_fmt(0.572036740F), Q30_fmt(0.976852417F),
+ Q30_fmt(1.144989014F), Q30_fmt(-0.572036745F), Q30_fmt(-0.152206421F), Q30_fmt(0.100311279F),
+
+ Q30_fmt(-0.078628540F), Q30_fmt(-0.000686646F), Q30_fmt(0.031082153F), Q30_fmt(-0.007003785F),
+ Q30_fmt(0.002227783F), Q30_fmt(0.003250122F), Q30_fmt(-0.000442500F), Q30_fmt(-0.000076294F),
+};
+
+
+
+
+
+const uint16 huffTable_1[8] =
+{
+ 0x1103, 0x0103, 0x1002, 0x1002,
+ 0x0001, 0x0001, 0x0001, 0x0001
+};
+
+const uint16 huffTable_2[15] =
+{
+ 0x1103, 0x0103, 0x1003, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x2206,
+ 0x0206, 0x1205, 0x1205, 0x2105,
+ 0x2105, 0x2005, 0x2005
+};
+
+const uint16 huffTable_3[15] =
+{
+
+ 0x1003, 0x1102, 0x1102, 0x0102,
+ 0x0102, 0x0002, 0x0002, 0x2206,
+ 0x0206, 0x1205, 0x1205, 0x2105,
+ 0x2105, 0x2005, 0x2005
+};
+
+const uint16 huffTable_5[25] =
+{
+
+ 0x1103, 0x0103, 0x1003, 0x0001,
+ 0x0001, 0x0001, 0x0001, 0x3106,
+ 0x3106, 0x1307, 0x0307, 0x3007,
+ 0x2207, 0x1206, 0x1206, 0x2106,
+ 0x2106, 0x0206, 0x0206, 0x2006,
+ 0x2006, 0x3308, 0x2308, 0x3207,
+ 0x3207
+};
+
+
+const uint16 huffTable_6[26] =
+{
+
+ 0x1204, 0x2104, 0x2004, 0x0103,
+ 0x0103, 0x1102, 0x1102, 0x1102,
+ 0x1102, 0x1003, 0x1003, 0x0003,
+ 0x0003, 0x2306, 0x3206, 0x3006,
+ 0x1305, 0x1305, 0x3105, 0x3105,
+ 0x2205, 0x2205, 0x0205, 0x0205,
+ 0x3307, 0x0307
+};
+
+
+
+const uint16 huffTable_7[73] =
+{
+ 0x0103,
+ 0x1003,
+ 0x0001,
+ 0x0001,
+ 0x0001,
+ 0x0001,
+ 0x1206,
+ 0x2105,
+ 0x2105,
+ 0x0206,
+ 0x2006,
+ 0x1104,
+ 0x1104,
+ 0x1104,
+ 0x1104,
+ 0x3509,
+ 0x4409,
+ 0x2509,
+ 0x5209,
+ 0x1508,
+ 0x1508,
+ 0x5108,
+ 0x5108,
+ 0x0509,
+ 0x3409,
+ 0x5008,
+ 0x5008,
+ 0x4309,
+ 0x3309,
+ 0x2408,
+ 0x2408,
+ 0x4208,
+ 0x4208,
+ 0x1407,
+ 0x1407,
+ 0x1407,
+ 0x1407,
+ 0x4107,
+ 0x4107,
+ 0x4107,
+ 0x4107,
+ 0x4007,
+ 0x4007,
+ 0x4007,
+ 0x4007,
+ 0x0408,
+ 0x0408,
+ 0x2308,
+ 0x2308,
+ 0x3208,
+ 0x3208,
+ 0x0308,
+ 0x0308,
+ 0x1307,
+ 0x1307,
+ 0x1307,
+ 0x1307,
+ 0x3107,
+ 0x3107,
+ 0x3107,
+ 0x3107,
+ 0x3007,
+ 0x3007,
+ 0x3007,
+ 0x3007,
+ 0x2207,
+ 0x2207,
+ 0x2207,
+ 0x2207,
+ 0x550a,
+ 0x450a,
+ 0x540a,
+ 0x530a
+};
+
+const uint16 huffTable_8[66] =
+{
+ 0x1204,
+ 0x2104,
+ 0x1102,
+ 0x1102,
+ 0x1102,
+ 0x1102,
+ 0x0103,
+ 0x0103,
+ 0x1003,
+ 0x1003,
+ 0x0002,
+ 0x0002,
+ 0x0002,
+ 0x0002,
+ 0x2206,
+ 0x0206,
+ 0x2006,
+ 0x2509,
+ 0x5209,
+ 0x0509,
+ 0x1508,
+ 0x1508,
+ 0x5108,
+ 0x5108,
+ 0x3409,
+ 0x4309,
+ 0x5009,
+ 0x3309,
+ 0x2408,
+ 0x2408,
+ 0x4208,
+ 0x4208,
+ 0x1408,
+ 0x1408,
+ 0x4107,
+ 0x4107,
+ 0x4107,
+ 0x4107,
+ 0x0408,
+ 0x0408,
+ 0x4008,
+ 0x4008,
+ 0x2308,
+ 0x2308,
+ 0x3208,
+ 0x3208,
+ 0x1308,
+ 0x1308,
+ 0x3108,
+ 0x3108,
+ 0x0308,
+ 0x0308,
+ 0x3008,
+ 0x3008,
+ 0x550b,
+ 0x540b,
+ 0x450a,
+ 0x450a,
+ 0x5309,
+ 0x5309,
+ 0x5309,
+ 0x5309,
+ 0x350a,
+ 0x350a,
+ 0x440a,
+ 0x440a
+
+};
+
+
+const uint16 huffTable_9[53] =
+{
+ 0x1204,
+ 0x2104,
+ 0x2004,
+ 0x1103,
+ 0x1103,
+ 0x0103,
+ 0x0103,
+ 0x1003,
+ 0x1003,
+ 0x0003,
+ 0x0003,
+ 0x1406,
+ 0x4106,
+ 0x2306,
+ 0x3206,
+ 0x1305,
+ 0x1305,
+ 0x3105,
+ 0x3105,
+ 0x0306,
+ 0x3006,
+ 0x2205,
+ 0x2205,
+ 0x0205,
+ 0x0205,
+ 0x4408,
+ 0x2508,
+ 0x5208,
+ 0x1508,
+ 0x5107,
+ 0x5107,
+ 0x3407,
+ 0x3407,
+ 0x4307,
+ 0x4307,
+ 0x5008,
+ 0x0408,
+ 0x2407,
+ 0x2407,
+ 0x4207,
+ 0x4207,
+ 0x3307,
+ 0x3307,
+ 0x4007,
+ 0x4007,
+ 0x5509,
+ 0x4509,
+ 0x3508,
+ 0x3508,
+ 0x5308,
+ 0x5308,
+ 0x5409,
+ 0x0509
+
+};
+
+
+const uint16 huffTable_10[96] =
+{
+ 0x0001,
+ 0x1104,
+ 0x0103,
+ 0x0103,
+ 0x1003,
+ 0x1003,
+ 0x1206,
+ 0x2106,
+ 0x0206,
+ 0x2006,
+ 0x1408,
+ 0x4108,
+ 0x4008,
+ 0x2308,
+ 0x3208,
+ 0x0308,
+ 0x1307,
+ 0x1307,
+ 0x3107,
+ 0x3107,
+ 0x3007,
+ 0x3007,
+ 0x2207,
+ 0x2207,
+ 0x1608,
+ 0x1608,
+ 0x6108,
+ 0x6108,
+ 0x6008,
+ 0x6008,
+ 0x0509,
+ 0x5009,
+ 0x2409,
+ 0x4209,
+ 0x3309,
+ 0x0409,
+ 0x2709,
+ 0x2709,
+ 0x7209,
+ 0x7209,
+ 0x640a,
+ 0x070a,
+ 0x7009,
+ 0x7009,
+ 0x6209,
+ 0x6209,
+ 0x450a,
+ 0x350a,
+ 0x0609,
+ 0x0609,
+ 0x530a,
+ 0x440a,
+ 0x1708,
+ 0x1708,
+ 0x1708,
+ 0x1708,
+ 0x7108,
+ 0x7108,
+ 0x7108,
+ 0x7108,
+ 0x3609,
+ 0x3609,
+ 0x2609,
+ 0x2609,
+ 0x250a,
+ 0x520a,
+ 0x1509,
+ 0x1509,
+ 0x5109,
+ 0x5109,
+ 0x340a,
+ 0x430a,
+ 0x770b,
+ 0x670b,
+ 0x760b,
+ 0x570b,
+ 0x750b,
+ 0x660b,
+ 0x470a,
+ 0x470a,
+ 0x740a,
+ 0x740a,
+ 0x560a,
+ 0x560a,
+ 0x650a,
+ 0x650a,
+ 0x370a,
+ 0x370a,
+ 0x730a,
+ 0x730a,
+ 0x460a,
+ 0x460a,
+ 0x550b,
+ 0x540b,
+ 0x630a,
+ 0x630a
+};
+
+
+const uint16 huffTable_11[116] =
+{
+ 0x1103,
+ 0x0103,
+ 0x1003,
+ 0x0002,
+ 0x0002,
+ 0x2105,
+ 0x1204, /* 0100 */
+ 0x1204, /* 010 */
+ 0x0205, /* 01010 */
+ 0x2005, /* 01011 */
+ 0x1408, /* 10 */
+ 0x4108, /* 00 */
+ 0x0408, /* 0 0 */
+ 0x4008, /* 0 1 */
+ 0x2307, /* 0 */
+ 0x2307, /* */
+ 0x3207, /* 1 */
+ 0x3207, /* */
+ 0x1306, /* 010 */
+ 0x1306, /* 01 */
+ 0x1306, /* 01 */
+ 0x1306, /* 01 */
+ 0x3106, /* 011 */
+ 0x3106, /* 01 */
+ 0x3106, /* 01 */
+ 0x3106, /* 01 */
+ 0x0307, /* 1000 */
+ 0x0307, /* 100 */
+ 0x3007, /* 1 */
+ 0x3007, /* 100 */
+ 0x2206, /* 101 */
+ 0x2206, /* 10 */
+ 0x2206, /* 10 */
+ 0x2206, /* 10 */
+ 0x2708,
+ 0x2708, /* 000 0 */
+ 0x7208, /* 000 10 */
+ 0x7208, /* 000 1 */
+ 0x6409, /* 000 110 */
+ 0x0709,
+ 0x7107,
+ 0x7107,
+ 0x7107, /* 00 0 */
+ 0x7107, /* 00 0 */
+ 0x1708,
+ 0x1708, /* 00 01 */
+ 0x7008,
+ 0x7008,
+ 0x3608,
+ 0x3608, /* 00 10 */
+ 0x6308, /* 00 101 */
+ 0x6308, /* 00 10 */
+ 0x6008,
+ 0x6008, /* 00 11 */
+ 0x4409,
+ 0x2509,
+ 0x5209, /* 0 */
+ 0x0509, /* 0 00 */
+ 0x1508, /* 0 0 */
+ 0x1508, /* 0 000 */
+ 0x6207, /* 0 */
+ 0x6207, /* 0 00 */
+ 0x6207, /* 0 00 */
+ 0x6207, /* 0 00 */
+ 0x2608,
+ 0x2608, /* 0 010 */
+ 0x0608,
+ 0x0608,
+ 0x1607,
+ 0x1607,
+ 0x1607,
+ 0x1607,
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x5108,
+ 0x5108,
+ 0x3408,
+ 0x3408,
+ 0x5008,
+ 0x5008,
+ 0x4309,
+ 0x3309,
+ 0x2408,
+ 0x2408, /* 0 111 */
+ 0x4208, /* 0 1111 */
+ 0x4208, /* 0 111 */
+ 0x560a,
+ 0x650a,
+ 0x3709,
+ 0x3709,
+ 0x7309,
+ 0x7309,
+ 0x4609,
+ 0x4609,
+ 0x450a,
+ 0x540a, /* 000 0 */
+ 0x350a, /* 000 0 */
+ 0x530a, /* 000 1 */
+ 0x770a,
+ 0x770a,
+ 0x670a,
+ 0x670a,
+ 0x760a, /* 0 */
+ 0x760a, /* */
+ 0x750a, /* 1 */
+ 0x750a, /* */
+ 0x660a, /* 00 */
+ 0x660a, /* 0 */
+ 0x470a, /* 01 */
+ 0x470a, /* 0 */
+ 0x740a, /* 10 */
+ 0x740a, /* 1 */
+ 0x570b, /* 110 */
+ 0x550b /* 111 */
+
+};
+
+const uint16 huffTable_12[134] =
+{
+
+ 0x1103, /* 101 */
+ 0x0103, /* 110 */
+ 0x1003, /* 111 */
+ 0x1204,
+ 0x1204, /* 011 */
+ 0x2104, /* 0111 */
+ 0x2104, /* 011 */
+ 0x0205, /* 10000 */
+ 0x2005, /* 10 */
+ 0x0004, /* 1 */
+ 0x0004, /* 100 */
+ 0x3006,
+ 0x1305, /* 01 */
+ 0x1305, /* 0100 */
+ 0x3105,
+ 0x3105,
+ 0x2205,
+ 0x2205, /* 0101 */
+ 0x1507,
+ 0x1507, /* 000 */
+ 0x5107, /* 0 */
+ 0x5107, /* 000 */
+ 0x3407, /* 0 */
+ 0x3407, /* */
+ 0x4307, /* 1 */
+ 0x4307, /* */
+ 0x5008,
+ 0x0408,
+ 0x2407,
+ 0x2407, /* 010 */
+ 0x4207,
+ 0x4207,
+ 0x1407, /* 0111 */
+ 0x1407, /* 011 */
+ 0x3306,
+ 0x3306,
+ 0x3306,
+ 0x3306,
+ 0x4106,
+ 0x4106,
+ 0x4106,
+ 0x4106,
+ 0x2306,
+ 0x2306,
+ 0x2306,
+ 0x2306,
+ 0x3206,
+ 0x3206,
+ 0x3206,
+ 0x3206,
+ 0x4007,
+ 0x4007,
+ 0x0307,
+ 0x0307, /* 010000 */
+ 0x7208,
+ 0x7208, /* 00 00 */
+ 0x4608, /* 00 */
+ 0x4608, /* 00 00 */
+ 0x6408,
+ 0x6408, /* 00 01 */
+ 0x1708, /* 00 011 */
+ 0x1708,
+ 0x7108, /* 00 100 */
+ 0x7108,
+ 0x0709,
+ 0x7009,
+ 0x3608,
+ 0x3608, /* 00 11 */
+ 0x6308,
+ 0x6308,
+ 0x4508,
+ 0x4508,
+ 0x5408, /* 0 0 */
+ 0x5408, /* 0 000 */
+ 0x4408, /* 0 0 */
+ 0x4408, /* 0 */
+ 0x0609, /* 0 10 */
+ 0x0509, /* 0 11 */
+ 0x2607,
+ 0x2607,
+ 0x2607,
+ 0x2607,
+ 0x6207,
+ 0x6207,
+ 0x6207,
+ 0x6207,
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x1608, /* 0 1010 */
+ 0x1608, /* 0 101 */
+ 0x6008, /* 0 1011 */
+ 0x6008, /* 0 101 */
+ 0x3508,
+ 0x3508, /* 0 110 */
+ 0x5308, /* 0 1101 */
+ 0x5308, /* 0 110 */
+ 0x2508,
+ 0x2508, /* 0 111 */
+ 0x5208, /* 0 1111 */
+ 0x5208, /* 0 111 */
+ 0x770a,
+ 0x670a,
+ 0x7609, /* */
+ 0x7609,
+ 0x5709, /* 0 */
+ 0x5709, /* */
+ 0x7509, /* 1 */
+ 0x7509, /* */
+ 0x6609,
+ 0x6609,
+ 0x4709, /* 0000 01 */
+ 0x4709, /* 0000 0 */
+ 0x7409,
+ 0x7409, /* 0000 1 */
+ 0x6509,
+ 0x6509, /* 0000 1 */
+ 0x5608,
+ 0x5608,
+ 0x5608,
+ 0x5608,
+ 0x3708,
+ 0x3708,
+ 0x3708,
+ 0x3708,
+ 0x7309, /* 000 100 */
+ 0x7309, /* 000 10 */
+ 0x5509,
+ 0x5509, /* 000 10 */
+ 0x2708,
+ 0x2708,
+ 0x2708,
+ 0x2708,
+};
+
+
+
+const uint16 huffTable_13[491] =
+{
+ 0x0001,
+ 0x1104,
+ 0x0104,
+ 0x1003,
+ 0x1003,
+ 0x4107,
+ 0x4107,
+ 0x0408,
+ 0x4008,
+ 0x2308,
+ 0x3208,
+ 0x1307,
+ 0x1307,
+ 0x3107,
+ 0x3107,
+ 0x0307,
+ 0x0307,
+ 0x3007,
+ 0x3007,
+ 0x2207,
+ 0x2207,
+ 0x1206,
+ 0x1206,
+ 0x1206,
+ 0x1206,
+ 0x2106,
+ 0x2106,
+ 0x2106,
+ 0x2106,
+ 0x0206,
+ 0x0206,
+ 0x0206,
+ 0x0206,
+ 0x2006,
+ 0x2006,
+ 0x2006,
+ 0x2006,
+ 0x370a,
+ 0x270a, /* 0 000 */
+ 0x1709, /* 0 00 */
+ 0x1709,
+ 0x7109,
+ 0x7109, /* 0 0 */
+ 0x550a,
+ 0x070a, /* 0 0 11 */
+ 0x700a,
+ 0x360a, /* 0 */
+ 0x630a,
+ 0x450a, /* 0 011 */
+ 0x540a,
+ 0x260a, /* 0 101 */
+ 0x620a,
+ 0x350a, /* 0 111 */
+ 0x8108,
+ 0x8108, /* 0 010 */
+ 0x8108,
+ 0x8108, /* 0 010 */
+ 0x0809,
+ 0x0809, /* 0 0101 */
+ 0x8009,
+ 0x8009, /* 0 0101 */
+ 0x1609,
+ 0x1609, /* 0 0110 */
+ 0x6109,
+ 0x6109, /* 0 0110 */
+ 0x0609,
+ 0x0609, /* 0 0111 */
+ 0x6009,
+ 0x6009, /* 0 0111 */
+ 0x530a,
+ 0x440a, /* 0 100 */
+ 0x2509,
+ 0x2509, /* 0 1000 */
+ 0x5209,
+ 0x5209, /* 0 1 */
+ 0x0509,
+ 0x0509, /* 0 1 */
+ 0x1508,
+ 0x1508, /* 0 101 */
+ 0x1508,
+ 0x1508, /* 0 101 */
+ 0x5108,
+ 0x5108, /* 0 101 */
+ 0x5108,
+ 0x5108, /* 0 101 */
+ 0x3409,
+ 0x3409, /* 0 1100 */
+ 0x4309,
+ 0x4309, /* 0 1100 */
+ 0x5009,
+ 0x5009, /* 0 1101 */
+ 0x2409,
+ 0x2409, /* 0 1101 */
+ 0x4209,
+ 0x4209, /* 0 1110 */
+ 0x3309,
+ 0x3309, /* 0 1110 */
+ 0x1408,
+ 0x1408, /* 0 111 */
+ 0x1408,
+ 0x1408, /* 0 111 */
+ 0x1a0a,
+ 0x1a0a,
+ 0xa10a, /* 00 00 */
+ 0xa10a,
+ 0x0a0b,
+ 0x680b,
+ 0xa00a,
+ 0xa00a,
+ 0x860b,
+ 0x490b,
+ 0x930a,
+ 0x930a,
+ 0x390b,
+ 0x580b,
+ 0x850b,
+ 0x670b,
+ 0x290a,
+ 0x290a,
+ 0x920a,
+ 0x920a,
+ 0x570b,
+ 0x750b,
+ 0x380a,
+ 0x380a,
+ 0x830a,
+ 0x830a,
+ 0x660b,
+ 0x470b,
+ 0x740b,
+ 0x560b,
+ 0x650b,
+ 0x730b,
+ 0x1909,
+ 0x1909,
+ 0x1909,
+ 0x1909,
+ 0x9109,
+ 0x9109,
+ 0x9109,
+ 0x9109,
+ 0x090a, /* 00 10100 */
+ 0x090a,
+ 0x900a, /* 00 10101 */
+ 0x900a,
+ 0x480a, /* 00 10110 */
+ 0x480a,
+ 0x840a, /* 00 10111 */
+ 0x840a,
+ 0x720a, /* 00 11000 */
+ 0x720a,
+ 0x460b, /* 00 11 0 */
+ 0x640b,
+ 0x2809,
+ 0x2809,
+ 0x2809,
+ 0x2809,
+ 0x8209,
+ 0x8209,
+ 0x8209,
+ 0x8209,
+ 0x1809,
+ 0x1809,
+ 0x1809,
+ 0x1809,
+ 0xc10b,
+ 0xc10b, /* 000 0000 */
+ 0x980c,
+ 0x0c0c, /* 000 00 1 */
+ 0xc00b,
+ 0xc00b, /* 000 0 */
+ 0xb40c,
+ 0x6a0c, /* 000 0 11 */
+ 0xa60c,
+ 0x790c, /* 000 */
+ 0x3b0b,
+ 0x3b0b, /* 000 0 */
+ 0xb30b,
+ 0xb30b, /* 000 1 */
+ 0x880c,
+ 0x5a0c, /* 000 111 */
+ 0x2b0b,
+ 0x2b0b, /* 000 0100 */
+ 0xa50c,
+ 0x690c, /* 000 01 1 */
+ 0xa40b,
+ 0xa40b, /* 000 0101 */
+ 0x780c,
+ 0x870c,
+ 0x940b,
+ 0x940b, /* 000 0110 */
+ 0x770c,
+ 0x760c, /* 000 011011 */
+ 0xb20a,
+ 0xb20a, /* 000 011 */
+ 0xb20a,
+ 0xb20a, /* 000 011 */
+ 0x1b0a,
+ 0x1b0a, /* 000 100 */
+ 0x1b0a,
+ 0x1b0a, /* 000 100 */
+ 0xb10a,
+ 0xb10a,
+ 0xb10a, /* 000 100 */
+ 0xb10a, /* 000 100 */
+ 0x0b0b, /* 000 10100 */
+ 0x0b0b, /* 000 1010 */
+ 0xb00b,
+ 0xb00b, /* 000 1010 */
+ 0x960b, /* 000 10110 */
+ 0x960b, /* 000 1011 */
+ 0x4a0b,
+ 0x4a0b, /* 000 1011 */
+ 0x3a0b, /* 000 11000 */
+ 0x3a0b, /* 000 1100 */
+ 0xa30b, /* 000 11 */
+ 0xa30b, /* 000 1100 */
+ 0x590b,
+ 0x590b, /* 000 1101 */
+ 0x950b, /* 000 11011 */
+ 0x950b, /* 000 1101 */
+ 0x2a0a,
+ 0x2a0a,
+ 0x2a0a,
+ 0x2a0a,
+ 0xa20a,
+ 0xa20a,
+ 0xa20a,
+ 0xa20a,
+ 0xf00c,
+ 0xf00c, /* 000 */
+ 0xba0d,
+ 0xe50d, /* 0 1 */
+ 0xe40d,
+ 0x8c0d, /* 01 */
+ 0x6d0d,
+ 0xe30d, /* 11 */
+ 0xe20c, /* 0100 */
+ 0xe20c,
+ 0x2e0d, /* 01010 */
+ 0x0e0d,
+ 0x1e0c, /* 0110 */
+ 0x1e0c,
+ 0xe10c, /* 0111 */
+ 0xe10c,
+ 0xe00d, /* 10000 */
+ 0x5d0d,
+ 0xd50d, /* 1 0 */
+ 0x7c0d,
+ 0xc70d,
+ 0x4d0d,
+ 0x8b0d,
+ 0xb80d,
+ 0xd40d,
+ 0x9a0d,
+ 0xa90d,
+ 0x6c0d,
+ 0xc60c,
+ 0xc60c,
+ 0x3d0c,
+ 0x3d0c, /* 111 */
+ 0xd30d, /* 0000 */
+ 0x7b0d,
+ 0x2d0c,
+ 0x2d0c,
+ 0xd20c,
+ 0xd20c,
+ 0x1d0c,
+ 0x1d0c,
+ 0xb70c,
+ 0xb70c, /* 0000 0 */
+ 0x5c0d,
+ 0xc50d, /* 0000 011 */
+ 0x990d,
+ 0x7a0d,
+ 0xc30c,
+ 0xc30c, /* 0000 1 */
+ 0xa70d,
+ 0x970d,
+ 0x4b0c,
+ 0x4b0c,
+ 0xd10b,
+ 0xd10b,
+ 0xd10b, /* 0000 010 */
+ 0xd10b,
+ 0x0d0c,
+ 0x0d0c,
+ 0xd00c,
+ 0xd00c,
+ 0x8a0c,
+ 0x8a0c,
+ 0xa80c,
+ 0xa80c,
+ 0x4c0c,
+ 0x4c0c,
+ 0xc40c,
+ 0xc40c,
+ 0x6b0c,
+ 0x6b0c, /* 0000 1 */
+ 0xb60c, /* 0000 1 1 */
+ 0xb60c, /* 0000 1 */
+ 0x3c0b,
+ 0x3c0b,
+ 0x3c0b,
+ 0x3c0b,
+ 0x2c0b, /* 0000 1011 */
+ 0x2c0b, /* 0000 101 */
+ 0x2c0b, /* 0000 101 */
+ 0x2c0b, /* 0000 101 */
+ 0xc20b,
+ 0xc20b,
+ 0xc20b,
+ 0xc20b,
+ 0x5b0b, /* 0000 1101 */
+ 0x5b0b,
+ 0x5b0b, /* 0000 110 */
+ 0x5b0b, /* 0000 110 */
+ 0xb50c,
+ 0xb50c,
+ 0x890c,
+ 0x890c, /* 0000 1110 */
+ 0x1c0b,
+ 0x1c0b,
+ 0x1c0b,
+ 0x1c0b,
+ 0x2f0d,
+ 0x2f0d, /* 000 */
+ 0xf20d, /* 0 */
+ 0xf20d, /* 000 */
+ 0x6e0e, /* 00 */
+ 0x9c0e, /* 01 */
+ 0x0f0d, /* 1 */
+ 0x0f0d, /* */
+ 0xc90e,
+ 0x5e0e, /* 01 */
+ 0xab0d, /* 0101 */
+ 0xab0d,
+ 0x7d0e, /* 01100 */
+ 0xd70e,
+ 0x4e0d, /* 0111 */
+ 0x4e0d,
+ 0xc80e,
+ 0xd60e, /* 10 */
+ 0x3e0d,
+ 0x3e0d, /* 100 */
+ 0xb90d,
+ 0xb90d, /* 101 */
+ 0x9b0e,
+ 0xaa0e, /* 10111 */
+ 0x1f0c,
+ 0x1f0c, /* 11 */
+ 0x1f0c, /* 11 */
+ 0x1f0c,
+ 0xf10c, /* 111 */
+ 0xf10c, /* 11 */
+ 0xf10c, /* 11 */
+ 0xf10c, /* 11 */
+ 0xe80e,
+ 0xe80e,
+ 0x5f0e,
+ 0x5f0e,
+ 0x9d0e,
+ 0x9d0e,
+ 0xd90e,
+ 0xd90e, /* 0000000 */
+ 0xf50e,
+ 0xf50e,
+ 0xe70e,
+ 0xe70e,
+ 0xac0e,
+ 0xac0e,
+ 0xbb0e,
+ 0xbb0e,
+ 0x4f0e,
+ 0x4f0e,
+ 0xf40e, /* 0000000 1 */
+ 0xf40e,
+ 0xca0f,
+ 0xe60f,
+ 0xf30e,
+ 0xf30e, /* 0000000 101 */
+ 0x3f0d,
+ 0x3f0d, /* 0000000 11 */
+ 0x3f0d,
+ 0x3f0d, /* 0000000 11 */
+ 0x8d0e,
+ 0x8d0e,
+ 0xd80e, /* 0000000 1111 */
+ 0xd80e,
+ 0x8f0f,
+ 0x8f0f, /* 00000000 000 */
+ 0xf80f, /* 00000000 0 */
+ 0xf80f,
+ 0xcc0f, /* 00000000 0 */
+ 0xcc0f,
+ 0xae10,
+ 0x9e10, /* 00000000 11 */
+ 0x8e0f,
+ 0x8e0f,
+ 0x7f10,
+ 0x7e10,
+ 0xf70e, /* 00000000 011 */
+ 0xf70e,
+ 0xf70e,
+ 0xf70e, /* 00000000 01 */
+ 0xda0e,
+ 0xda0e, /* 00000000 10 */
+ 0xda0e,
+ 0xda0e, /* 00000000 10 */
+ 0xad0f,
+ 0xad0f, /* 00000000 101 */
+ 0xbc0f,
+ 0xbc0f, /* 00000000 101 */
+ 0xcb0f,
+ 0xcb0f, /* 00000000 110 */
+ 0xf60f,
+ 0xf60f, /* 00000000 110 */
+ 0x6f0e,
+ 0x6f0e, /* 00000000 11 */
+ 0x6f0e, /* 00000000 11 */
+ 0x6f0e, /* 00000000 11 */
+ 0xff10,
+ 0xff10,
+ 0xef10,
+ 0xef10, /* 000000000000 */
+ 0xdf10, /* 000000000000 1 */
+ 0xdf10, /* 000000000000 */
+ 0xee10, /* 00000000000 00 */
+ 0xee10, /* 00000000000 0 */
+ 0xcf10, /* 00000000000 01 */
+ 0xcf10,
+ 0xde10, /* 00000000000 10 */
+ 0xde10,
+ 0xbf10, /* 00000000000 11 */
+ 0xbf10, /* 00000000000 1 */
+ 0xfb10,
+ 0xfb10,
+ 0xce10,
+ 0xce10, /* 0000000000 00 */
+ 0xdc10, /* 0000000000 010 */
+ 0xdc10,
+ 0xaf11,
+ 0xe911,
+ 0xec0f, /* 0000000000 10 */
+ 0xec0f, /* 0000000000 1 */
+ 0xec0f, /* 0000000000 1 */
+ 0xec0f, /* 0000000000 1 */
+ 0xdd0f, /* 0000000000 11 */
+ 0xdd0f, /* 0000000000 1 */
+ 0xdd0f, /* 0000000000 1 */
+ 0xdd0f, /* 0000000000 1 */
+ 0xfa10, /* 000000000 0000 */
+ 0xfa10, /* 000000000 000 */
+ 0xcd10, /* 000000000 0 */
+ 0xcd10, /* 000000000 000 */
+ 0xbe0f, /* 000000000 */
+ 0xbe0f,
+ 0xbe0f,
+ 0xbe0f,
+ 0xeb0f,
+ 0xeb0f,
+ 0xeb0f,
+ 0xeb0f, /* 000000000 01 */
+ 0x9f0f, /* 000000000 011 */
+ 0x9f0f, /* 000000000 01 */
+ 0x9f0f,
+ 0x9f0f,
+ 0xf90f, /* 000000000 100 */
+ 0xf90f, /* 000000000 10 */
+ 0xf90f, /* 000000000 10 */
+ 0xf90f, /* 000000000 10 */
+ 0xea0f, /* 000000000 101 */
+ 0xea0f, /* 000000000 10 */
+ 0xea0f, /* 000000000 10 */
+ 0xea0f, /* 000000000 10 */
+ 0xbd0f, /* 000000000 110 */
+ 0xbd0f, /* 000000000 11 */
+ 0xbd0f, /* 000000000 11 */
+ 0xbd0f, /* 000000000 11 */
+ 0xdb0f, /* 000000000 111 */
+ 0xdb0f, /* 000000000 11 */
+ 0xdb0f, /* 000000000 11 */
+ 0xdb0f, /* 000000000 11 */
+ 0xfe13,
+ 0xfc13,
+ 0xfd12,
+ 0xfd12,
+ 0xed11,
+ 0xed11,
+ 0xed11,
+ 0xed11
+
+};
+
+
+
+const uint16 huffTable_15[421] =
+{
+ 0x1103,
+ 0x1103,
+ 0x0104,
+ 0x1004,
+ 0x0003, /* 111 */
+ 0x0003, /* 11 */
+ 0x3407,
+ 0x4307,
+ 0x2407, /* 0101 */
+ 0x4207, /* 0101010 */
+ 0x3307,
+ 0x4106, /* 010110 */
+ 0x4106,
+ 0x1407, /* 0101110 */
+ 0x0407,
+ 0x2306, /* 011000 */
+ 0x2306,
+ 0x3206, /* 011 */
+ 0x3206,
+ 0x4007,
+ 0x0307,
+ 0x1306, /* 011011 */
+ 0x1306, /* 01101 */
+ 0x3106, /* 011100 */
+ 0x3106, /* 01110 */
+ 0x3006, /* 011101 */
+ 0x3006, /* 01110 */
+ 0x2205, /* 01111 */
+ 0x2205, /* 0111 */
+ 0x2205, /* 0111 */
+ 0x2205, /* 0111 */
+ 0x1205, /* 10000 */
+ 0x1205, /* 1000 */
+ 0x1205, /* 1000 */
+ 0x1205, /* 1000 */
+ 0x2105, /* 10 */
+ 0x2105, /* 1000 */
+ 0x2105, /* 1000 */
+ 0x2105, /* 1000 */
+ 0x0205,
+ 0x0205, /* 1 */
+ 0x0205, /* 1 */
+ 0x0205, /* 1 */
+ 0x2005, /* 1 1 */
+ 0x2005, /* 1 */
+ 0x2005, /* 1 */
+ 0x2005, /* 1 */
+ 0x5809,
+ 0x8509,
+ 0x2909, /* */
+ 0x6709, /* 000 */
+ 0x7609, /* 00 0 */
+ 0x9209, /* 00 1 */
+ 0x9108, /* 0 0 */
+ 0x9108, /* 0 */
+ 0x1909, /* 0 10 */
+ 0x9009, /* 0 11 */
+ 0x4809, /* 000 */
+ 0x8409, /* */
+ 0x5709, /* 010 */
+ 0x7509, /* 011 */
+ 0x3809, /* 100 */
+ 0x8309, /* 101 */
+ 0x6609, /* 110 */
+ 0x4709, /* 111 */
+ 0x2808,
+ 0x2808, /* 0100 */
+ 0x8208, /* 01 */
+ 0x8208, /* 0100 */
+ 0x1808, /* 01010 */
+ 0x1808, /* 0101 */
+ 0x8108, /* 01011 */
+ 0x8108, /* 0101 */
+ 0x7409,
+ 0x0809, /* 011 */
+ 0x8009, /* 011010 */
+ 0x5609,
+ 0x6509, /* 011100 */
+ 0x3709,
+ 0x7309, /* 011110 */
+ 0x4609,
+ 0x2708, /* 10000 */
+ 0x2708, /* 1000 */
+ 0x7208, /* 10 */
+ 0x7208, /* 1000 */
+ 0x6408, /* 1 0 */
+ 0x6408, /* 1 */
+ 0x1708, /* 1 1 */
+ 0x1708, /* 1 */
+ 0x5508, /* 10100 */
+ 0x5508,
+ 0x7108, /* 10101 */
+ 0x7108,
+ 0x0709, /* 101100 */
+ 0x7009, /* 101101 */
+ 0x3608, /* 10111 */
+ 0x3608, /* 1011 */
+ 0x6308, /* 11000 */
+ 0x6308, /* 1100 */
+ 0x4508, /* 11 */
+ 0x4508, /* 1100 */
+ 0x5408, /* 11010 */
+ 0x5408, /* 1101 */
+ 0x2608, /* 11011 */
+ 0x2608, /* 1101 */
+ 0x6208, /* 11100 */
+ 0x6208, /* 1110 */
+ 0x1608, /* 11101 */
+ 0x1608, /* 1110 */
+ 0x0609, /* 111100 */
+ 0x6009, /* 111101 */
+ 0x3508, /* 11111 */
+ 0x3508, /* 1111 */
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x6107,
+ 0x5308, /* 0100 0 */
+ 0x5308, /* 0100 */
+ 0x4408, /* 0100 1 */
+ 0x4408, /* 0100 */
+ 0x2507, /* 010 0 */
+ 0x2507, /* 010 */
+ 0x2507, /* 010 */
+ 0x2507, /* 010 */
+ 0x5207, /* 010 1 */
+ 0x5207, /* 010 */
+ 0x5207, /* 010 */
+ 0x5207, /* 010 */
+ 0x1507, /* 01 00 */
+ 0x1507, /* 01 0 */
+ 0x1507, /* 01 0 */
+ 0x1507, /* 01 0 */
+ 0x5107, /* 01 01 */
+ 0x5107, /* 01 0 */
+ 0x5107, /* 01 0 */
+ 0x5107, /* 01 0 */
+ 0x0508, /* 01 100 */
+ 0x0508, /* 01 10 */
+ 0x5008, /* 01 101 */
+ 0x5008, /* 01 10 */
+ 0xc209,
+ 0xc209,
+ 0x2c0a, /* 00 11110 */
+ 0x5b0a,
+ 0xb50a, /* 0 */
+ 0x1c0a, /* 0 000 */
+ 0x890a, /* 0 00 0 */
+ 0x980a,
+ 0xc10a, /* 0 0 00 */
+ 0x4b0a, /* 0 0 01 */
+ 0xb40a, /* 0 0 10 */
+ 0x6a0a, /* 0 0 11 */
+ 0x3b0a, /* 0 000 */
+ 0x790a, /* 0 */
+ 0xb309, /* 0 01 */
+ 0xb309, /* 0 0 */
+ 0x970a, /* 0 100 */
+ 0x880a, /* 0 101 */
+ 0x2b0a, /* 0 110 */
+ 0x5a0a, /* 0 111 */
+ 0xb209, /* 0 01000 */
+ 0xb209, /* 0 0100 */
+ 0xa50a, /* 0 01 0 */
+ 0x1b0a, /* 0 01 1 */
+ 0xb109, /* 0 01010 */
+ 0xb109, /* 0 0101 */
+ 0xb00a, /* 0 010110 */
+ 0x690a, /* 0 010111 */
+ 0x960a, /* 0 011000 */
+ 0x4a0a, /* 0 011 */
+ 0xa40a, /* 0 011010 */
+ 0x780a, /* 0 011011 */
+ 0x870a, /* 0 011100 */
+ 0x3a0a, /* 0 011101 */
+ 0xa309, /* 0 01111 */
+ 0xa309, /* 0 0111 */
+ 0x5909, /* 0 10000 */
+ 0x5909, /* 0 1000 */
+ 0x9509, /* 0 10 */
+ 0x9509, /* 0 1000 */
+ 0x2a09, /* 0 1 0 */
+ 0x2a09, /* 0 1 */
+ 0xa209, /* 0 1 1 */
+ 0xa209, /* 0 1 */
+ 0x1a09, /* 0 10100 */
+ 0x1a09, /* 0 1010 */
+ 0xa109, /* 0 10101 */
+ 0xa109, /* 0 1010 */
+ 0x0a0a, /* 0 101100 */
+ 0xa00a, /* 0 101101 */
+ 0x6809, /* 0 10111 */
+ 0x6809, /* 0 1011 */
+ 0x8609, /* 0 11000 */
+ 0x8609, /* 0 1100 */
+ 0x4909, /* 0 11 */
+ 0x4909, /* 0 1100 */
+ 0x9409, /* 0 11010 */
+ 0x9409, /* 0 1101 */
+ 0x3909, /* 0 11011 */
+ 0x3909, /* 0 1101 */
+ 0x9309, /* 0 11100 */
+ 0x9309, /* 0 1110 */
+ 0x770a, /* 0 111010 */
+ 0x090a, /* 0 111011 */
+ 0x7c0b,
+ 0xc70b, /* 00 000 */
+ 0x4d0b, /* 00 00 0 */
+ 0x8b0b, /* 00 00 1 */
+ 0xd40a, /* 00 0 0 */
+ 0xd40a, /* 00 0 */
+ 0xb80b, /* 00 0 10 */
+ 0x9a0b, /* 00 0 11 */
+ 0xa90b, /* 00 000 */
+ 0x6c0b, /* 00 */
+ 0xc60b, /* 00 010 */
+ 0x3d0b, /* 00 011 */
+ 0xd30a, /* 00 10 */
+ 0xd30a, /* 00 1 */
+ 0xd20a, /* 00 11 */
+ 0xd20a, /* 00 1 */
+ 0x2d0b, /* 00 010000 */
+ 0x0d0b, /* 00 010 */
+ 0x1d0a, /* 00 01 */
+ 0x1d0a, /* 00 0100 */
+ 0x7b0a, /* 00 01010 */
+ 0x7b0a, /* 00 0101 */
+ 0xb70a, /* 00 01011 */
+ 0xb70a, /* 00 0101 */
+ 0xd10a, /* 00 01100 */
+ 0xd10a, /* 00 0110 */
+ 0x5c0b, /* 00 011010 */
+ 0xd00b, /* 00 011011 */
+ 0xc50a, /* 00 01110 */
+ 0xc50a, /* 00 0111 */
+ 0x8a0a, /* 00 01111 */
+ 0x8a0a, /* 00 0111 */
+ 0xa80a, /* 00 10000 */
+ 0xa80a, /* 00 1000 */
+ 0x4c0a, /* 00 10 */
+ 0x4c0a, /* 00 1000 */
+ 0xc40a, /* 00 1 0 */
+ 0xc40a, /* 00 1 */
+ 0x6b0a, /* 00 1 1 */
+ 0x6b0a, /* 00 1 */
+ 0xb60a, /* 00 10100 */
+ 0xb60a, /* 00 1010 */
+ 0x990b, /* 00 101010 */
+ 0x0c0b, /* 00 101011 */
+ 0x3c0a, /* 00 10110 */
+ 0x3c0a, /* 00 1011 */
+ 0xc30a, /* 00 10111 */
+ 0xc30a, /* 00 1011 */
+ 0x7a0a, /* 00 11000 */
+ 0x7a0a, /* 00 1100 */
+ 0xa70a, /* 00 11 */
+ 0xa70a, /* 00 1100 */
+ 0xa60a, /* 00 11010 */
+ 0xa60a, /* 00 1101 */
+ 0xc00b, /* 00 110110 */
+ 0x0b0b, /* 00 110111 */
+ 0xcb0b,
+ 0xcb0b, /* 0000 000 */
+ 0xf60b, /* 0000 0 */
+ 0xf60b, /* 0000 000 */
+ 0x8e0c, /* 0000 00 */
+ 0xe80c, /* 0000 01 */
+ 0x5f0c, /* 0000 10 */
+ 0x9d0c, /* 0000 11 */
+ 0xf50b, /* 0000 0100 */
+ 0xf50b, /* 0000 010 */
+ 0x7e0b, /* 0000 0101 */
+ 0x7e0b, /* 0000 010 */
+ 0xe70b, /* 0000 0110 */
+ 0xe70b, /* 0000 011 */
+ 0xac0b, /* 0000 0111 */
+ 0xac0b, /* 0000 011 */
+ 0xca0b, /* 0000 1000 */
+ 0xca0b, /* 0000 100 */
+ 0xbb0b, /* 0000 1 */
+ 0xbb0b, /* 0000 100 */
+ 0xd90c, /* 0000 10100 */
+ 0x8d0c, /* 0000 10101 */
+ 0x4f0b, /* 0000 1011 */
+ 0x4f0b, /* 0000 101 */
+ 0xf40b, /* 0000 1100 */
+ 0xf40b, /* 0000 110 */
+ 0x3f0b, /* 0000 1101 */
+ 0x3f0b, /* 0000 110 */
+ 0xf30b, /* 0000 1110 */
+ 0xf30b, /* 0000 111 */
+ 0xd80b, /* 0000 1111 */
+ 0xd80b, /* 0000 111 */
+ 0xe60b, /* 000 */
+ 0xe60b, /* 000 0000 */
+ 0x2f0b, /* 000 00 */
+ 0x2f0b, /* 000 0000 */
+ 0xf20b, /* 000 0 0 */
+ 0xf20b, /* 000 0 */
+ 0x6e0c, /* 000 0 10 */
+ 0xf00c, /* 000 0 11 */
+ 0x1f0b, /* 000 00 */
+ 0x1f0b, /* 000 0 */
+ 0xf10b, /* 000 01 */
+ 0xf10b, /* 000 0 */
+ 0x9c0b, /* 000 10 */
+ 0x9c0b, /* 000 1 */
+ 0xc90b, /* 000 11 */
+ 0xc90b, /* 000 1 */
+ 0x5e0b, /* 000 01000 */
+ 0x5e0b, /* 000 0100 */
+ 0xab0b, /* 000 01 */
+ 0xab0b, /* 000 0100 */
+ 0xba0b, /* 000 01010 */
+ 0xba0b, /* 000 0101 */
+ 0xe50b, /* 000 01011 */
+ 0xe50b, /* 000 0101 */
+ 0x7d0b, /* 000 01100 */
+ 0x7d0b, /* 000 0110 */
+ 0xd70b, /* 000 01101 */
+ 0xd70b,
+ 0x4e0b, /* 000 01110 */
+ 0x4e0b,
+ 0xe40b, /* 000 01111 */
+ 0xe40b, /* 000 0111 */
+ 0x8c0b,
+ 0x8c0b, /* 000 1000 */
+ 0xc80b, /* 000 10 */
+ 0xc80b,
+ 0x3e0b, /* 000 1 0 */
+ 0x3e0b, /* 000 1 */
+ 0x6d0b,
+ 0x6d0b, /* 000 1 */
+ 0xd60b, /* 000 10100 */
+ 0xd60b, /* 000 1010 */
+ 0xe30b,
+ 0xe30b, /* 000 1010 */
+ 0x9b0b, /* 000 10110 */
+ 0x9b0b, /* 000 1011 */
+ 0xb90b,
+ 0xb90b, /* 000 1011 */
+ 0x2e0b, /* 000 11000 */
+ 0x2e0b, /* 000 1100 */
+ 0xaa0b,
+ 0xaa0b, /* 000 1100 */
+ 0xe20b,
+ 0xe20b, /* 000 1101 */
+ 0x1e0b,
+ 0x1e0b, /* 000 1101 */
+ 0xe10b,
+ 0xe10b, /* 000 1110 */
+ 0x0e0c,
+ 0xe00c, /* 000 111011 */
+ 0x5d0b,
+ 0x5d0b, /* 000 1111 */
+ 0xd50b,
+ 0xd50b, /* 000 1111 */
+ 0xff0d,
+ 0xef0d,
+ 0xfe0d,
+ 0xdf0d,
+ 0xee0c,
+ 0xee0c,
+ 0xfd0d,
+ 0xcf0d,
+ 0xfc0d,
+ 0xde0d,
+ 0xed0d,
+ 0xbf0d,
+ 0xfb0c,
+ 0xfb0c,
+ 0xce0d,
+ 0xec0d,
+ 0xdd0c, /* 000 */
+ 0xdd0c, /* 00 */
+ 0xaf0c, /* */
+ 0xaf0c, /* 00 */
+ 0xfa0c, /* 010 */
+ 0xfa0c, /* 01 */
+ 0xbe0c, /* 011 */
+ 0xbe0c, /* 01 */
+ 0xeb0c, /* 100 */
+ 0xeb0c, /* 10 */
+ 0xcd0c, /* 101 */
+ 0xcd0c, /* 10 */
+ 0xdc0c, /* 110 */
+ 0xdc0c, /* 11 */
+ 0x9f0c, /* 111 */
+ 0x9f0c, /* 11 */
+ 0xf90c, /* 0000 */
+ 0xf90c, /* 000 */
+ 0xea0c, /* 0 */
+ 0xea0c, /* 000 */
+ 0xbd0c, /* 0 */
+ 0xbd0c, /* */
+ 0xdb0c, /* 1 */
+ 0xdb0c, /* */
+ 0x8f0c, /* 0100 */
+ 0x8f0c, /* 010 */
+ 0xf80c, /* 0101 */
+ 0xf80c, /* 010 */
+ 0xcc0c,
+ 0xcc0c, /* 011 */
+ 0x9e0c, /* 0111 */
+ 0x9e0c, /* 011 */
+ 0xe90c, /* 1000 */
+ 0xe90c, /* 100 */
+ 0x7f0c, /* 1 */
+ 0x7f0c,
+ 0xf70c, /* 1010 */
+ 0xf70c, /* 101 */
+ 0xad0c, /* 1011 */
+ 0xad0c, /* 101 */
+ 0xda0c, /* 1100 */
+ 0xda0c, /* 110 */
+ 0xbc0c,
+ 0xbc0c, /* 110 */
+ 0x6f0c, /* 1110 */
+ 0x6f0c, /* 111 */
+ 0xae0d, /* 11110 */
+ 0x0f0d
+};
+
+const uint16 huffTable_16[465] =
+{
+ 0x0001,
+ 0x1104,
+ 0x0104,
+ 0x1003,
+ 0x1003,
+ 0x2308,
+ 0x3208, /* 11 */
+ 0x1307, /* 0100 */
+ 0x1307, /* 010 */
+ 0x3107,
+ 0x3107,
+ 0x0308,
+ 0x3008,
+ 0x2207, /* 0111 */
+ 0x2207, /* 011 */
+ 0x1206, /* 100 */
+ 0x1206, /* 10 */
+ 0x1206, /* 10 */
+ 0x1206, /* 10 */
+ 0x2106, /* 101 */
+ 0x2106, /* 10 */
+ 0x2106, /* 10 */
+ 0x2106, /* 10 */
+ 0x0206,
+ 0x0206,
+ 0x0206,
+ 0x0206,
+ 0x2006,
+ 0x2006,
+ 0x2006,
+ 0x2006,
+ 0x1709,
+ 0x1709, /* 0 0111 */
+ 0x7109, /* 0 10000 */
+ 0x7109, /* 0 1000 */
+ 0x700a, /* 0 10 0 */
+ 0x360a, /* 0 10 1 */
+ 0x630a, /* 0 1 00 */
+ 0x450a, /* 0 1 01 */
+ 0x540a, /* 0 1 10 */
+ 0x260a, /* 0 1 11 */
+ 0x6209, /* 0 10100 */
+ 0x6209, /* 0 1010 */
+ 0x1609,
+ 0x1609,
+ 0x6109, /* 0 10110 */
+ 0x6109, /* 0 1011 */
+ 0x060a, /* 0 101110 */
+ 0x600a,
+ 0x5309,
+ 0x5309, /* 0 1100 */
+ 0x350a, /* 0 11 0 */
+ 0x440a, /* 0 11 1 */
+ 0x2509, /* 0 11010 */
+ 0x2509, /* 0 1101 */
+ 0x5209, /* 0 11011 */
+ 0x5209, /* 0 1101 */
+ 0x5108,
+ 0x5108,
+ 0x5108,
+ 0x5108,
+ 0x1509,
+ 0x1509, /* 0 1111 */
+ 0x0509, /* 0 11111 */
+ 0x0509, /* 0 1111 */
+ 0x3409, /* */
+ 0x3409, /* */
+ 0x4309, /* 000 */
+ 0x4309, /* */
+ 0x5009, /* 00 0 */
+ 0x5009, /* 00 */
+ 0x2409, /* 00 1 */
+ 0x2409, /* 00 */
+ 0x4209, /* 0 00 */
+ 0x4209, /* 0 0 */
+ 0x3309, /* 0 01 */
+ 0x3309, /* 0 0 */
+ 0x1408, /* 0 1 */
+ 0x1408, /* 0 */
+ 0x1408, /* 0 */
+ 0x1408, /* 0 */
+ 0x4108, /* 00 */
+ 0x4108, /* 0 */
+ 0x4108, /* 0 */
+ 0x4108, /* 0 */
+ 0x0409, /* 010 */
+ 0x0409, /* 01 */
+ 0x4009, /* 011 */
+ 0x4009, /* 01 */
+ 0x1d0b,
+ 0x1d0b, /* 00 10101 */
+ 0xc40c, /* 00 1011000 */
+ 0x6b0c, /* 00 1011 */
+ 0xc30c, /* 00 1011010 */
+ 0xa70c, /* 00 1011011 */
+ 0x2c0b, /* 00 101110 */
+ 0x2c0b, /* 00 10111 */
+ 0xc20c, /* 00 1011110 */
+ 0xb50c, /* 00 1011111 */
+ 0xc10c, /* 00 1100000 */
+ 0x0c0c, /* 00 1100 */
+ 0x4b0c, /* 00 110 0 */
+ 0xb40c, /* 00 110 1 */
+ 0x6a0c, /* 00 11 00 */
+ 0xa60c, /* 00 11 01 */
+ 0xb30b, /* 00 11 1 */
+ 0xb30b, /* 00 11 */
+ 0x5a0c, /* 00 1101000 */
+ 0xa50c, /* 00 1101 */
+ 0x2b0b, /* 00 110101 */
+ 0x2b0b, /* 00 11010 */
+ 0xb20b, /* 00 110110 */
+ 0xb20b, /* 00 11011 */
+ 0x1b0b, /* 00 110111 */
+ 0x1b0b, /* 00 11011 */
+ 0xb10b, /* 00 111000 */
+ 0xb10b, /* 00 11100 */
+ 0x0b0c, /* 00 111 0 */
+ 0xb00c, /* 00 111 1 */
+ 0x690c, /* 00 1110100 */
+ 0x960c, /* 00 1110101 */
+ 0x4a0c, /* 00 1110110 */
+ 0xa40c, /* 00 1110111 */
+ 0x780c, /* 00 1111000 */
+ 0x870c, /* 00 1111 */
+ 0xa30b, /* 00 111101 */
+ 0xa30b, /* 00 11110 */
+ 0x3a0c, /* 00 1111100 */
+ 0x590c, /* 00 1111101 */
+ 0x2a0b, /* 00 111111 */
+ 0x2a0b, /* 00 11111 */
+ 0x950c, /* 0 00000000 */
+ 0x680c, /* 0 */
+ 0xa10b, /* 0 0000 */
+ 0xa10b, /* 0 */
+ 0x860c, /* 0 000 00 */
+ 0x770c, /* 0 000 01 */
+ 0x940b, /* 0 000 1 */
+ 0x940b, /* 0 000 */
+ 0x490c, /* 0 00 000 */
+ 0x570c, /* 0 00 */
+ 0x670b, /* 0 00 01 */
+ 0x670b, /* 0 00 0 */
+ 0xa20a, /* 0 00 1 */
+ 0xa20a, /* 0 00 */
+ 0xa20a, /* 0 00 */
+ 0xa20a, /* 0 00 */
+ 0x1a0a, /* 0 0 00 */
+ 0x1a0a, /* 0 0 0 */
+ 0x1a0a, /* 0 0 0 */
+ 0x1a0a, /* 0 0 0 */
+ 0x0a0b, /* 0 0 010 */
+ 0x0a0b, /* 0 0 01 */
+ 0xa00b, /* 0 0 011 */
+ 0xa00b, /* 0 0 01 */
+ 0x390b, /* 0 0 100 */
+ 0x390b, /* 0 0 10 */
+ 0x930b, /* 0 0 101 */
+ 0x930b, /* 0 0 10 */
+ 0x580b, /* 0 0 110 */
+ 0x580b, /* 0 0 11 */
+ 0x850b, /* 0 0 111 */
+ 0x850b, /* 0 0 11 */
+ 0x290a, /* 0 000 */
+ 0x290a, /* 0 00 */
+ 0x290a, /* 0 00 */
+ 0x290a, /* 0 00 */
+ 0x920a, /* 0 */
+ 0x920a, /* 0 00 */
+ 0x920a, /* 0 00 */
+ 0x920a, /* 0 00 */
+ 0x760b, /* 0 0100 */
+ 0x760b, /* 0 010 */
+ 0x090b, /* 0 0101 */
+ 0x090b, /* 0 010 */
+ 0x190a, /* 0 011 */
+ 0x190a, /* 0 01 */
+ 0x190a, /* 0 01 */
+ 0x190a, /* 0 01 */
+ 0x910a, /* 0 100 */
+ 0x910a, /* 0 10 */
+ 0x910a, /* 0 10 */
+ 0x910a, /* 0 10 */
+ 0x900b, /* 0 1010 */
+ 0x900b, /* 0 101 */
+ 0x480b, /* 0 1011 */
+ 0x480b, /* 0 101 */
+ 0x840b, /* 0 1100 */
+ 0x840b, /* 0 110 */
+ 0x750b, /* 0 1101 */
+ 0x750b, /* 0 110 */
+ 0x380b, /* 0 1110 */
+ 0x380b, /* 0 111 */
+ 0x830b, /* 0 1111 */
+ 0x830b, /* 0 111 */
+ 0x660b, /* 0 0100000 */
+ 0x660b, /* 0 010000 */
+ 0x280b, /* 0 0100 */
+ 0x280b, /* 0 010000 */
+ 0x820a, /* 0 010 */
+ 0x820a, /* 0 01000 */
+ 0x820a, /* 0 01000 */
+ 0x820a, /* 0 01000 */
+ 0x470b, /* 0 01 00 */
+ 0x470b, /* 0 01 0 */
+ 0x740b, /* 0 01 01 */
+ 0x740b, /* 0 01 0 */
+ 0x180a, /* 0 01 1 */
+ 0x180a, /* 0 01 */
+ 0x180a, /* 0 01 */
+ 0x180a, /* 0 01 */
+ 0x810a, /* 0 010100 */
+ 0x810a, /* 0 01010 */
+ 0x810a, /* 0 01010 */
+ 0x810a, /* 0 01010 */
+ 0x800a, /* 0 010101 */
+ 0x800a, /* 0 01010 */
+ 0x800a, /* 0 01010 */
+ 0x800a, /* 0 01010 */
+ 0x080b, /* 0 0101100 */
+ 0x080b, /* 0 010110 */
+ 0x560b, /* 0 0101101 */
+ 0x560b, /* 0 010110 */
+ 0x370a, /* 0 010111 */
+ 0x370a, /* 0 01011 */
+ 0x370a, /* 0 01011 */
+ 0x370a, /* 0 01011 */
+ 0x730a, /* 0 011000 */
+ 0x730a, /* 0 01100 */
+ 0x730a, /* 0 01100 */
+ 0x730a, /* 0 01100 */
+ 0x650b, /* 0 011 0 */
+ 0x650b, /* 0 011 */
+ 0x460b, /* 0 011 1 */
+ 0x460b, /* 0 011 */
+ 0x270a, /* 0 011010 */
+ 0x270a, /* 0 01101 */
+ 0x270a, /* 0 01101 */
+ 0x270a, /* 0 01101 */
+ 0x720a, /* 0 011011 */
+ 0x720a, /* 0 01101 */
+ 0x720a, /* 0 01101 */
+ 0x720a, /* 0 01101 */
+ 0x640b, /* 0 0111000 */
+ 0x640b, /* 0 011100 */
+ 0x550b, /* 0 0111 */
+ 0x550b, /* 0 011100 */
+ 0x070a, /* 0 011101 */
+ 0x070a, /* 0 01110 */
+ 0x070a, /* 0 01110 */
+ 0x070a, /* 0 01110 */
+ 0x9e0d,
+ 0x9e0d, /* 00 0110000 */
+ 0xbc0e, /* 00 01100 0 */
+ 0xcb0e, /* 00 01100 1 */
+ 0x8e0e, /* 00 0110 00 */
+ 0xe80e, /* 00 0110 01 */
+ 0x9d0e, /* 00 0110 10 */
+ 0xe70e, /* 00 0110 11 */
+ 0xbb0e, /* 00 011 000 */
+ 0x8d0e, /* 00 011 */
+ 0xd80e, /* 00 011 010 */
+ 0x6e0e, /* 00 011 011 */
+ 0xe60d, /* 00 011 10 */
+ 0xe60d, /* 00 011 1 */
+ 0x9c0d, /* 00 011 11 */
+ 0x9c0d, /* 00 011 1 */
+ 0xab0e, /* 00 011010000 */
+ 0xba0e, /* 00 011010 */
+ 0xe50e, /* 00 01101 0 */
+ 0xd70e, /* 00 01101 1 */
+ 0x4e0d, /* 00 01101010 */
+ 0x4e0d, /* 00 0110101 */
+ 0xe40e, /* 00 011010110 */
+ 0x8c0e, /* 00 011010111 */
+ 0xc80d, /* 00 01101100 */
+ 0xc80d, /* 00 0110110 */
+ 0x3e0d, /* 00 01101101 */
+ 0x3e0d, /* 00 0110110 */
+ 0x6d0d, /* 00 01101110 */
+ 0x6d0d, /* 00 0110111 */
+ 0xd60e, /* 00 011011110 */
+ 0x9b0e, /* 00 011011111 */
+ 0xb90e, /* 00 011100000 */
+ 0xaa0e, /* 00 011100 */
+ 0xe10d, /* 00 01110 */
+ 0xe10d, /* 00 0111000 */
+ 0xd40d, /* 00 0111 0 */
+ 0xd40d, /* 00 0111 */
+ 0xb80e, /* 00 0111 10 */
+ 0xa90e, /* 00 0111 11 */
+ 0x7b0d, /* 00 01110100 */
+ 0x7b0d, /* 00 0111010 */
+ 0xb70e, /* 00 011101010 */
+ 0xd00e, /* 00 011101011 */
+ 0xe30c, /* 00 0111011 */
+ 0xe30c, /* 00 011101 */
+ 0xe30c, /* 00 011101 */
+ 0xe30c, /* 00 011101 */
+ 0x0e0d, /* 00 01111000 */
+ 0x0e0d, /* 00 0111100 */
+ 0xe00d, /* 00 01111 */
+ 0xe00d, /* 00 0111100 */
+ 0x5d0d, /* 00 01111010 */
+ 0x5d0d, /* 00 0111101 */
+ 0xd50d, /* 00 01111011 */
+ 0xd50d, /* 00 0111101 */
+ 0x7c0d, /* 00 01111100 */
+ 0x7c0d, /* 00 0111110 */
+ 0xc70d, /* 00 01111101 */
+ 0xc70d, /* 00 0111110 */
+ 0x4d0d, /* 00 01111110 */
+ 0x4d0d, /* 00 0111111 */
+ 0x8b0d, /* 00 01111111 */
+ 0x8b0d, /* 00 0111111 */
+ 0x9a0d,
+ 0x6c0d, /* 00 10000 */
+ 0xc60d, /* 00 1000 0 */
+ 0x3d0d, /* 00 1000 1 */
+ 0x5c0d, /* 00 100 00 */
+ 0xc50d, /* 00 100 01 */
+ 0x0d0c, /* 00 100 1 */
+ 0x0d0c, /* 00 100 */
+ 0x8a0d, /* 00 10 000 */
+ 0xa80d, /* 00 10 */
+ 0x990d, /* 00 10 010 */
+ 0x4c0d, /* 00 10 011 */
+ 0xb60d, /* 00 10 100 */
+ 0x7a0d, /* 00 10 101 */
+ 0x3c0c, /* 00 10 11 */
+ 0x3c0c, /* 00 10 1 */
+ 0x5b0d, /* 00 1 0000 */
+ 0x890d, /* 00 1 0 */
+ 0x1c0c, /* 00 1 */
+ 0x1c0c, /* 00 1 00 */
+ 0xc00c, /* 00 1 010 */
+ 0xc00c, /* 00 1 01 */
+ 0x980d, /* 00 1 0110 */
+ 0x790d, /* 00 1 0111 */
+ 0xe20b, /* 00 1 10 */
+ 0xe20b, /* 00 1 1 */
+ 0xe20b, /* 00 1 1 */
+ 0xe20b, /* 00 1 1 */
+ 0x2e0c, /* 00 1 110 */
+ 0x2e0c, /* 00 1 11 */
+ 0x1e0c, /* 00 1 111 */
+ 0x1e0c, /* 00 1 11 */
+ 0xd30c, /* 00 1010000 */
+ 0xd30c, /* 00 101000 */
+ 0x2d0c, /* 00 1010 */
+ 0x2d0c, /* 00 101000 */
+ 0xd20c, /* 00 101 0 */
+ 0xd20c, /* 00 101 */
+ 0xd10c, /* 00 101 1 */
+ 0xd10c, /* 00 101 */
+ 0x3b0c, /* 00 1010100 */
+ 0x3b0c, /* 00 101010 */
+ 0x970d, /* 00 10101010 */
+ 0x880d, /* 00 10101011 */
+ 0xf208,
+ 0xf208, /* 000 1 */
+ 0x2f09, /* 00 0000 */
+ 0x0f09, /* 00 0 */
+ 0x1f08, /* 00 */
+ 0x1f08, /* 00 00 */
+ 0xf108, /* 00 010 */
+ 0xf108, /* 00 01 */
+ 0xce10,
+ 0xce10, /* 000 101100000 */
+ 0xec11, /* 000 1011000 0 */
+ 0xdd11, /* 000 1011000 1 */
+ 0xde0f, /* 000 101100 */
+ 0xde0f, /* 000 10110000 */
+ 0xde0f, /* 000 10110000 */
+ 0xde0f, /* 000 10110000 */
+ 0xe90f, /* 000 10110 0 */
+ 0xe90f, /* 000 10110 */
+ 0xe90f, /* 000 10110 */
+ 0xe90f, /* 000 10110 */
+ 0xea10, /* 000 10110 10 */
+ 0xea10, /* 000 10110 1 */
+ 0xd910, /* 000 10110 11 */
+ 0xd910, /* 000 10110 1 */
+ 0xee0e,
+ 0xee0e, /* 000 1011 */
+ 0xed0f, /* 000 1011 10 */
+ 0xeb0f, /* 000 1011 11 */
+ 0xbe0e, /* 000 10110100 */
+ 0xbe0e, /* 000 1011010 */
+ 0xcd0e, /* 000 10110101 */
+ 0xcd0e, /* 000 1011010 */
+ 0xdc0f, /* 000 101101100 */
+ 0xdb0f, /* 000 101101101 */
+ 0xae0e, /* 000 10110111 */
+ 0xae0e, /* 000 1011011 */
+ 0xcc0e, /* 000 10111000 */
+ 0xcc0e, /* 000 1011100 */
+ 0xad0f, /* 000 10111 0 */
+ 0xda0f, /* 000 10111 1 */
+ 0x7e0f, /* 000 101110100 */
+ 0xac0f, /* 000 101110101 */
+ 0xca0e, /* 000 10111011 */
+ 0xca0e, /* 000 1011101 */
+ 0xc90f, /* 000 101111000 */
+ 0x7d0f, /* 000 101111 */
+ 0x5e0e, /* 000 10111101 */
+ 0x5e0e, /* 000 1011110 */
+ 0xbd0d, /* 000 1011111 */
+ 0xbd0d, /* 000 101111 */
+ 0xbd0d, /* 000 101111 */
+ 0xbd0d, /* 000 101111 */
+ 0xef0b,
+ 0xfe0b, /* 00000000 */
+ 0xdf0b, /* 0000000 0 */
+ 0xfd0b, /* 0000000 1 */
+ 0xcf0b, /* 00 */
+ 0xfc0b, /* 01 */
+ 0xbf0b, /* 10 */
+ 0xfb0b, /* 11 */
+ 0xaf0a, /* 00 */
+ 0xaf0a, /* 0 */
+ 0xfa0b, /* 010 */
+ 0x9f0b, /* 011 */
+ 0xf90b, /* 100 */
+ 0xf80b, /* 101 */
+ 0x8f0a, /* 11 */
+ 0x8f0a, /* 1 */
+ 0x7f0a, /* 0000 000 */
+ 0x7f0a, /* 0000 00 */
+ 0xf70a, /* 0000 */
+ 0xf70a, /* 0000 00 */
+ 0x6f0a, /* 0000 010 */
+ 0x6f0a, /* 0000 01 */
+ 0xf60a, /* 0000 011 */
+ 0xf60a, /* 0000 01 */
+ 0xff08, /* 0000 1 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0xff08, /* 0000 */
+ 0x5f0a, /* 000 0000 */
+ 0x5f0a, /* 000 000 */
+ 0xf50a, /* 000 0 */
+ 0xf50a, /* 000 000 */
+ 0x4f09, /* 000 */
+ 0x4f09, /* 000 00 */
+ 0x4f09, /* 000 00 */
+ 0x4f09, /* 000 00 */
+ 0xf409, /* 000 010 */
+ 0xf409, /* 000 01 */
+ 0xf409, /* 000 01 */
+ 0xf409, /* 000 01 */
+ 0xf309, /* 000 011 */
+ 0xf309, /* 000 01 */
+ 0xf309, /* 000 01 */
+ 0xf309, /* 000 01 */
+ 0xf009, /* 000 100 */
+ 0xf009, /* 000 10 */
+ 0xf009, /* 000 10 */
+ 0xf009, /* 000 10 */
+ 0x3f0a,
+ 0x3f0a
+};
+
+
+
+const uint16 huffTable_24[478] =
+{
+
+ 0x2206, /* 101 */
+ 0x1205, /* 10101 */
+ 0x1205, /* 1010 */
+ 0x2105, /* 10110 */
+ 0x2105, /* 1011 */
+ 0x0206, /* 101110 */
+ 0x2006, /* 101111 */
+ 0x1104,
+ 0x1104,
+ 0x1104,
+ 0x1104,
+ 0x0104,
+ 0x0104,
+ 0x0104,
+ 0x0104,
+ 0x1004,
+ 0x1004,
+ 0x1004,
+ 0x1004,
+ 0x0004,
+ 0x0004,
+ 0x0004,
+ 0x0004,
+ 0x7308,
+ 0x7308,
+ 0x3709,
+ 0x2709,
+ 0x7208,
+ 0x7208,
+ 0x4608, /* 01110000 */
+ 0x4608, /* 0111000 */
+ 0x6408, /* 01110 */
+ 0x6408, /* 0111000 */
+ 0x5508, /* 0111 0 */
+ 0x5508, /* 0111 */
+ 0x7108, /* 0111 1 */
+ 0x7108, /* 0111 */
+ 0x3608, /* 01110100 */
+ 0x3608, /* 0111010 */
+ 0x6308, /* 01110101 */
+ 0x6308, /* 0111010 */
+ 0x4508, /* 01110110 */
+ 0x4508, /* 0111011 */
+ 0x5408, /* 01110111 */
+ 0x5408, /* 0111011 */
+ 0x2608, /* 01111000 */
+ 0x2608, /* 0111100 */
+ 0x6208, /* 01111 */
+ 0x6208, /* 0111100 */
+ 0x1608, /* 01111010 */
+ 0x1608, /* 0111101 */
+ 0x6108, /* 01111011 */
+ 0x6108, /* 0111101 */
+ 0x0609, /* 011111000 */
+ 0x6009, /* 011111 */
+ 0x3508, /* 01111101 */
+ 0x3508, /* 0111110 */
+ 0x5308, /* 01111110 */
+ 0x5308, /* 0111111 */
+ 0x4408, /* 01111111 */
+ 0x4408, /* 0111111 */
+ 0x2508, /* 10000000 */
+ 0x2508, /* 1000000 */
+ 0x5208, /* 10000 */
+ 0x5208, /* 1000000 */
+ 0x1508, /* 1000 0 */
+ 0x1508, /* 1000 */
+ 0x0509, /* 1000 10 */
+ 0x5009, /* 1000 11 */
+ 0x5107, /* 100 0 */
+ 0x5107, /* 100 */
+ 0x5107, /* 100 */
+ 0x5107, /* 100 */
+ 0x3408, /* 100 10 */
+ 0x3408, /* 100 1 */
+ 0x4308, /* 100 11 */
+ 0x4308, /* 100 1 */
+ 0x2407, /* 10 00 */
+ 0x2407, /* 10 0 */
+ 0x2407, /* 10 0 */
+ 0x2407, /* 10 0 */
+ 0x4207, /* 10 01 */
+ 0x4207, /* 10 0 */
+ 0x4207, /* 10 0 */
+ 0x4207, /* 10 0 */
+ 0x3307, /* 10 10 */
+ 0x3307, /* 10 1 */
+ 0x3307, /* 10 1 */
+ 0x3307, /* 10 1 */
+ 0x1407, /* 10 11 */
+ 0x1407, /* 10 1 */
+ 0x1407, /* 10 1 */
+ 0x1407, /* 10 1 */
+ 0x4107, /* 1 000 */
+ 0x4107, /* 1 00 */
+ 0x4107, /* 1 00 */
+ 0x4107, /* 1 00 */
+ 0x0408, /* 1 0 */
+ 0x0408, /* 1 */
+ 0x4008, /* 1 1 */
+ 0x4008, /* 1 */
+ 0x2307, /* 1 010 */
+ 0x2307, /* 1 01 */
+ 0x2307, /* 1 01 */
+ 0x2307, /* 1 01 */
+ 0x3207, /* 1 011 */
+ 0x3207, /* 1 01 */
+ 0x3207, /* 1 01 */
+ 0x3207, /* 1 01 */
+ 0x1306, /* 1 10 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x1306, /* 1 1 */
+ 0x3106, /* 1 11 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x3106, /* 1 1 */
+ 0x0307, /* 1010000 */
+ 0x0307, /* 101000 */
+ 0x0307, /* 101000 */
+ 0x0307, /* 101000 */
+ 0x3007, /* 1010 */
+ 0x3007, /* 101000 */
+ 0x3007, /* 101000 */
+ 0x3007, /* 101000 */
+ 0xb309,
+ 0xb309,
+ 0x8809, /* 010101 */
+ 0x8809, /* 01010100 */
+ 0x2b0a, /* 0101010100 */
+ 0x5a0a, /* 0101010101 */
+ 0xb209, /* 010101011 */
+ 0xb209, /* 01010101 */
+ 0xa50a, /* 0101011000 */
+ 0x1b0a, /* 0101011 */
+ 0xb10a, /* 0101011010 */
+ 0x690a, /* 0101011011 */
+ 0x9609, /* 010101110 */
+ 0x9609, /* 01010111 */
+ 0xa409, /* 010101111 */
+ 0xa409, /* 01010111 */
+ 0x4a0a, /* 0101100000 */
+ 0x780a, /* 0101100 */
+ 0x8709, /* 010110 */
+ 0x8709, /* 01011000 */
+ 0x3a09, /* 01011 0 */
+ 0x3a09, /* 01011 */
+ 0xa309, /* 01011 1 */
+ 0xa309, /* 01011 */
+ 0x5909, /* 010110100 */
+ 0x5909, /* 01011010 */
+ 0x9509, /* 010110101 */
+ 0x9509, /* 01011010 */
+ 0x2a09, /* 010110110 */
+ 0x2a09, /* 01011011 */
+ 0xa209, /* 010110111 */
+ 0xa209, /* 01011011 */
+ 0xa109, /* 010111000 */
+ 0xa109, /* 01011100 */
+ 0x6809, /* 010111 */
+ 0x6809, /* 01011100 */
+ 0x8609, /* 010111010 */
+ 0x8609, /* 01011101 */
+ 0x7709, /* 010111011 */
+ 0x7709, /* 01011101 */
+ 0x4909, /* 010111100 */
+ 0x4909, /* 01011110 */
+ 0x9409, /* 010111101 */
+ 0x9409, /* 01011110 */
+ 0x3909, /* 010111110 */
+ 0x3909, /* 01011111 */
+ 0x9309, /* 010111111 */
+ 0x9309, /* 01011111 */
+ 0x5809, /* 011000000 */
+ 0x5809, /* 01100000 */
+ 0x8509, /* 011000 */
+ 0x8509, /* 01100000 */
+ 0x2909, /* 01100 0 */
+ 0x2909, /* 01100 */
+ 0x6709, /* 01100 1 */
+ 0x6709, /* 01100 */
+ 0x7609, /* 0110 00 */
+ 0x7609, /* 0110 0 */
+ 0x9209, /* 0110 01 */
+ 0x9209, /* 0110 0 */
+ 0x1909, /* 0110 10 */
+ 0x1909, /* 0110 1 */
+ 0x9109, /* 0110 11 */
+ 0x9109, /* 0110 1 */
+ 0x4809, /* 011 000 */
+ 0x4809, /* 011 00 */
+ 0x8409, /* 011 */
+ 0x8409, /* 011 00 */
+ 0x5709, /* 011 010 */
+ 0x5709, /* 011 01 */
+ 0x7509, /* 011 011 */
+ 0x7509, /* 011 01 */
+ 0x3809, /* 011 100 */
+ 0x3809, /* 011 10 */
+ 0x8309, /* 011 101 */
+ 0x8309, /* 011 10 */
+ 0x6609, /* 011 110 */
+ 0x6609, /* 011 11 */
+ 0x2809, /* 011 111 */
+ 0x2809, /* 011 11 */
+ 0x8209, /* 011010000 */
+ 0x8209, /* 01101000 */
+ 0x1809, /* 011010 */
+ 0x1809, /* 01101000 */
+ 0x4709, /* 01101 0 */
+ 0x4709, /* 01101 */
+ 0x7409, /* 01101 1 */
+ 0x7409, /* 01101 */
+ 0x8109, /* 011010100 */
+ 0x8109, /* 01101010 */
+ 0x080a, /* 0110101010 */
+ 0x800a, /* 0110101011 */
+ 0x5609, /* 011010110 */
+ 0x5609, /* 01101011 */
+ 0x6509, /* 011010111 */
+ 0x6509, /* 01101011 */
+ 0x1709, /* 011011000 */
+ 0x1709, /* 01101100 */
+ 0x070a, /* 011011 0 */
+ 0x700a, /* 011011 1 */
+ 0x6e0b,
+ 0x9c0b,
+ 0xc90a, /* 01000 01 */
+ 0xc90a, /* 01000 0 */
+ 0x5e0a, /* 01000 10 */
+ 0x5e0a, /* 01000 1 */
+ 0xba0a, /* 01000 11 */
+ 0xba0a, /* 01000 1 */
+ 0xe50a, /* 0100 000 */
+ 0xe50a, /* 0100 00 */
+ 0xab0b, /* 0100 0 */
+ 0x7d0b, /* 0100 1 */
+ 0xd70a, /* 0100 010 */
+ 0xd70a, /* 0100 01 */
+ 0xe40a, /* 0100 011 */
+ 0xe40a, /* 0100 01 */
+ 0x8c0a, /* 0100 100 */
+ 0x8c0a,
+ 0xc80a,
+ 0xc80a,
+ 0x4e0b, /* 0100 1100 */
+ 0x2e0b, /* 0100 1101 */
+ 0x3e0a, /* 0100 111 */
+ 0x3e0a, /* 0100 11 */
+ 0x6d0a, /* 010 0000 */
+ 0x6d0a, /* 010 000 */
+ 0xd60a, /* 010 0 */
+ 0xd60a, /* 010 000 */
+ 0xe30a, /* 010 0 */
+ 0xe30a, /* 010 */
+ 0x9b0a, /* 010 1 */
+ 0x9b0a, /* 010 */
+ 0xb90a, /* 010 0100 */
+ 0xb90a, /* 010 010 */
+ 0xaa0a, /* 010 0101 */
+ 0xaa0a,
+ 0xe20a,
+ 0xe20a,
+ 0x1e0a,
+ 0x1e0a,
+ 0xe10a,
+ 0xe10a,
+ 0x5d0a,
+ 0x5d0a,
+ 0xd50a,
+ 0xd50a,
+ 0x7c0a,
+ 0x7c0a,
+ 0xc70a,
+ 0xc70a,
+ 0x4d0a,
+ 0x4d0a,
+ 0x8b0a,
+ 0x8b0a,
+ 0xb80a,
+ 0xb80a,
+ 0xd40a,
+ 0xd40a,
+ 0x9a0a,
+ 0x9a0a,
+ 0xa90a, /* 01 0 0 */
+ 0xa90a, /* 01 0 */
+ 0x6c0a, /* 01 0 1 */
+ 0x6c0a, /* 01 0 */
+ 0xc60a, /* 01 00 */
+ 0xc60a, /* 01 0 */
+ 0x3d0a, /* 01 01 */
+ 0x3d0a, /* 01 0 */
+ 0xd30a, /* 01 10 */
+ 0xd30a, /* 01 1 */
+ 0x2d0a, /* 01 11 */
+ 0x2d0a, /* 01 1 */
+ 0xd20a,
+ 0xd20a,
+ 0x1d0a, /* 01 01 */
+ 0x1d0a, /* 01 0100 */
+ 0x7b0a, /* 01 01010 */
+ 0x7b0a, /* 01 0101 */
+ 0xb70a, /* 01 01011 */
+ 0xb70a,
+ 0xd10a,
+ 0xd10a, /* 01 0110 */
+ 0x5c0a, /* 01 01101 */
+ 0x5c0a, /* 01 0110 */
+ 0xc50a, /* 01 01110 */
+ 0xc50a, /* 01 0111 */
+ 0x8a0a, /* 01 01111 */
+ 0x8a0a, /* 01 0111 */
+ 0xa80a, /* 01 10000 */
+ 0xa80a, /* 01 1000 */
+ 0x990a, /* 01 10 */
+ 0x990a, /* 01 1000 */
+ 0x4c0a, /* 01 1 0 */
+ 0x4c0a, /* 01 1 */
+ 0xc40a, /* 01 1 1 */
+ 0xc40a, /* 01 1 */
+ 0x6b0a, /* 01 10100 */
+ 0x6b0a, /* 01 1010 */
+ 0xb60a, /* 01 10101 */
+ 0xb60a, /* 01 1010 */
+ 0xd00b, /* 01 101100 */
+ 0x0c0b, /* 01 101101 */
+ 0x3c0a, /* 01 10111 */
+ 0x3c0a, /* 01 1011 */
+ 0xc30a, /* 01 11000 */
+ 0xc30a, /* 01 1100 */
+ 0x7a0a, /* 01 11 */
+ 0x7a0a, /* 01 1100 */
+ 0xa70a, /* 01 11010 */
+ 0xa70a, /* 01 1101 */
+ 0x2c0a, /* 01 11011 */
+ 0x2c0a, /* 01 1101 */
+ 0xc20a, /* 01 11100 */
+ 0xc20a, /* 01 1110 */
+ 0x5b0a, /* 01 11101 */
+ 0x5b0a, /* 01 1110 */
+ 0xb50a, /* 01 11110 */
+ 0xb50a, /* 01 1111 */
+ 0x1c0a,
+ 0x1c0a,
+ 0x890a,
+ 0x890a,
+ 0x980a,
+ 0x980a,
+ 0xc10a, /* 010100 0 */
+ 0xc10a, /* 010100 */
+ 0x4b0a, /* 010100 1 */
+ 0x4b0a, /* 010100 */
+ 0xc00b, /* 01010 000 */
+ 0x0b0b, /* 01010 */
+ 0x3b0a, /* 01010 01 */
+ 0x3b0a, /* 01010 0 */
+ 0xb00b, /* 01010 100 */
+ 0x0a0b, /* 01010 101 */
+ 0x1a0a, /* 01010 11 */
+ 0x1a0a, /* 01010 1 */
+ 0xb409, /* 0101 00 */
+ 0xb409, /* 0101 0 */
+ 0xb409, /* 0101 0 */
+ 0xb409, /* 0101 0 */
+ 0x6a0a, /* 0101 010 */
+ 0x6a0a, /* 0101 01 */
+ 0xa60a, /* 0101 011 */
+ 0xa60a, /* 0101 01 */
+ 0x790a, /* 0101 100 */
+ 0x790a, /* 0101 10 */
+ 0x970a, /* 0101 101 */
+ 0x970a, /* 0101 10 */
+ 0xa00b, /* 0101 1100 */
+ 0x090b, /* 0101 1101 */
+ 0x900a, /* 0101 111 */
+ 0x900a, /* 0101 11 */
+ 0xca0b,
+ 0xca0b,
+ 0xbb0b,
+ 0xbb0b,
+ 0x8d0b,
+ 0x8d0b, /* 0100000 */
+ 0xd80b, /* 0100000 1 */
+ 0xd80b, /* 0100000 */
+ 0x0e0c, /* 010000 000 */
+ 0xe00c, /* 010000 */
+ 0x0d0b, /* 010000 01 */
+ 0x0d0b, /* 010000 0 */
+ 0xe60a, /* 010000 1 */
+ 0xe60a, /* 010000 */
+ 0xe60a, /* 010000 */
+ 0xe60a, /* 010000 */
+ 0x0f09, /* 011000 401 */
+ 0x0f09, /* 01100 */
+ 0x0f09, /* 01100 */
+ 0x0f09, /* 01100 */
+ 0xee0b, /* 011 00 */
+ 0xde0b, /* 011 01 */
+ 0xed0b, /* 011 10 */
+ 0xce0b, /* 011 11 */
+ 0xec0b, /* 01101000 */
+ 0xdd0b, /* 01101 */
+ 0xbe0b, /* 01101010 */
+ 0xeb0b, /* 01101011 */
+ 0xcd0b, /* 01101100 */
+ 0xdc0b, /* 01101101 */
+ 0xae0b, /* 01101110 */
+ 0xea0b, /* 01101111 */
+ 0xbd0b, /* 01110000 */
+ 0xdb0b, /* 01110 */
+ 0xcc0b, /* 0111 0 */
+ 0x9e0b, /* 0111 1 */
+ 0xe90b, /* 01110100 */
+ 0xad0b, /* 01110101 */
+ 0xda0b, /* 01110110 */
+ 0xbc0b, /* 01110111 */
+ 0xcb0b, /* 01111000 */
+ 0x8e0b,
+ 0xe80b,
+ 0x9d0b,
+ 0xd90b,
+ 0x7e0b,
+ 0xe70b,
+ 0xac0b,
+ 0xff04,
+ 0xef08,
+ 0xfe08,
+ 0xdf08, /* 0000 0 */
+ 0xfd08, /* 0000 1 */
+ 0xcf08, /* 000 00 */
+ 0xfc08, /* 000 01 */
+ 0xbf08, /* 000 10 */
+ 0xfb08, /* 000 11 */
+ 0xfa07, /* 00 00 */
+ 0xfa07, /* 00 0 */
+ 0xaf08, /* 00 010 */
+ 0x9f08, /* 00 011 */
+ 0xf907, /* 00 10 */
+ 0xf907, /* 00 1 */
+ 0xf807, /* 00 11 */
+ 0xf807, /* 00 1 */
+ 0x8f08,
+ 0x7f08, /* 0 0 */
+ 0xf707, /* 0 */
+ 0xf707, /* 0 00 */
+ 0x6f07, /* 0 010 */
+ 0x6f07, /* 0 01 */
+ 0xf607, /* 0 011 */
+ 0xf607, /* 0 01 */
+ 0x5f07,
+ 0x5f07, /* 0 10 */
+ 0xf507, /* 0 101 */
+ 0xf507, /* 0 10 */
+ 0x4f07, /* 0 110 */
+ 0x4f07, /* 0 11 */
+ 0xf407, /* 0 111 */
+ 0xf407, /* 0 11 */
+ 0x3f07,
+ 0x3f07,
+ 0xf307, /* 0 */
+ 0xf307,
+ 0x2f07, /* 0 */
+ 0x2f07, /* */
+ 0xf207, /* 1 */
+ 0xf207, /* */
+ 0xf107,
+ 0xf107,
+ 0x1f08,
+ 0xf008
+
+};
+
+
+const uint16 huffTable_32[33] =
+{
+
+ 0x0b06,
+ 0x0f06,
+ 0x0d06,
+ 0x0e06,
+ 0x0706,
+ 0x0506,
+ 0x0905,
+ 0x0905,
+ 0x0605,
+ 0x0605,
+ 0x0305,
+ 0x0305,
+ 0x0a05,
+ 0x0a05,
+ 0x0c05,
+ 0x0c05,
+ 0x0204,
+ 0x0204,
+ 0x0204,
+ 0x0204,
+ 0x0104,
+ 0x0104,
+ 0x0104,
+ 0x0104,
+ 0x0404,
+ 0x0404,
+ 0x0404,
+ 0x0404,
+ 0x0804,
+ 0x0804,
+ 0x0804,
+ 0x0804,
+ 0x0001
+
+};
+
+
+/*
+ * MM = 512; z = [0:(MM)]; a = z.^(1/3);
+ * Table is in Q27
+ */
+const int32 power_one_third[513] =
+{
+
+ 0x00000000, 0x08000000, 0x0A14517D, 0x0B89BA25,
+ 0x0CB2FF53, 0x0DAE07DE, 0x0E897685, 0x0F4DAEDD,
+ 0x10000000, 0x10A402FD, 0x113C4841, 0x11CAB613,
+ 0x1250BFE2, 0x12CF8890, 0x1347F8AB, 0x13BACD65,
+ 0x1428A2FA, 0x1491FC15, 0x14F74744, 0x1558E2F7,
+ 0x15B72095, 0x161246D7, 0x166A9399, 0x16C03D55,
+ 0x17137449, 0x17646369, 0x17B33124, 0x18000000,
+ 0x184AEF29, 0x18941AD8, 0x18DB9CB7, 0x19218C2E,
+ 0x1965FEA5, 0x19A907C2, 0x19EAB998, 0x1A2B24D0,
+ 0x1A6A58D5, 0x1AA863EE, 0x1AE5535D, 0x1B213377,
+ 0x1B5C0FBD, 0x1B95F2EC, 0x1BCEE70F, 0x1C06F590,
+ 0x1C3E2745, 0x1C74847A, 0x1CAA1501, 0x1CDEE035,
+ 0x1D12ED0B, 0x1D464212, 0x1D78E582, 0x1DAADD3A,
+ 0x1DDC2ECF, 0x1E0CDF8C, 0x1E3CF476, 0x1E6C7257,
+ 0x1E9B5DBA, 0x1EC9BAF6, 0x1EF78E2C, 0x1F24DB4E,
+ 0x1F51A620, 0x1F7DF23C, 0x1FA9C314, 0x1FD51BF2,
+ 0x20000000, 0x202A7244, 0x205475A6, 0x207E0CEE,
+ 0x20A73ACA, 0x20D001CC, 0x20F8646D, 0x2120650E,
+ 0x214805FA, 0x216F4963, 0x2196316C, 0x21BCC020,
+ 0x21E2F77A, 0x2208D961, 0x222E67AD, 0x2253A425,
+ 0x22789082, 0x229D2E6E, 0x22C17F82, 0x22E5854F,
+ 0x23094155, 0x232CB509, 0x234FE1D5, 0x2372C918,
+ 0x23956C26, 0x23B7CC47, 0x23D9EABB, 0x23FBC8B9,
+ 0x241D676E, 0x243EC7FF, 0x245FEB86, 0x2480D319,
+ 0x24A17FC3, 0x24C1F28B, 0x24E22C6C, 0x25022E5F,
+ 0x2521F954, 0x25418E33, 0x2560EDE2, 0x2580193E,
+ 0x259F111F, 0x25BDD657, 0x25DC69B4, 0x25FACBFE,
+ 0x2618FDF8, 0x26370060, 0x2654D3EF, 0x2672795C,
+ 0x268FF156, 0x26AD3C8A, 0x26CA5BA2, 0x26E74F41,
+ 0x27041808, 0x2720B695, 0x273D2B81, 0x27597762,
+ 0x27759ACB, 0x2791964B, 0x27AD6A6F, 0x27C917C0,
+ 0x27E49EC5, 0x28000000, 0x281B3BF3, 0x2836531B,
+ 0x285145F3, 0x286C14F5, 0x2886C096, 0x28A1494B,
+ 0x28BBAF85, 0x28D5F3B3, 0x28F01641, 0x290A179B,
+ 0x2923F82A, 0x293DB854, 0x2957587E, 0x2970D90A,
+ 0x298A3A59, 0x29A37CCA, 0x29BCA0BB, 0x29D5A687,
+ 0x29EE8E87, 0x2A075914, 0x2A200684, 0x2A38972C,
+ 0x2A510B5F, 0x2A696370, 0x2A819FAE, 0x2A99C069,
+ 0x2AB1C5ED, 0x2AC9B088, 0x2AE18085, 0x2AF9362C,
+ 0x2B10D1C6, 0x2B28539B, 0x2B3FBBEF, 0x2B570B09,
+ 0x2B6E412B, 0x2B855E97, 0x2B9C6390, 0x2BB35056,
+ 0x2BCA2527, 0x2BE0E242, 0x2BF787E4, 0x2C0E1649,
+ 0x2C248DAD, 0x2C3AEE4A, 0x2C513859, 0x2C676C13,
+ 0x2C7D89AF, 0x2C939164, 0x2CA98368, 0x2CBF5FF1,
+ 0x2CD52731, 0x2CEAD95E, 0x2D0076A9, 0x2D15FF45,
+ 0x2D2B7363, 0x2D40D332, 0x2D561EE4, 0x2D6B56A7,
+ 0x2D807AAA, 0x2D958B19, 0x2DAA8823, 0x2DBF71F4,
+ 0x2DD448B7, 0x2DE90C98, 0x2DFDBDC0, 0x2E125C5C,
+ 0x2E26E892, 0x2E3B628D, 0x2E4FCA75, 0x2E642070,
+ 0x2E7864A8, 0x2E8C9741, 0x2EA0B862, 0x2EB4C831,
+ 0x2EC8C6D3, 0x2EDCB46C, 0x2EF09121, 0x2F045D14,
+ 0x2F18186A, 0x2F2BC345, 0x2F3F5DC7, 0x2F52E812,
+ 0x2F666247, 0x2F79CC88, 0x2F8D26F4, 0x2FA071AC,
+ 0x2FB3ACD0, 0x2FC6D87F, 0x2FD9F4D7, 0x2FED01F8,
+ 0x30000000, 0x3012EF0C, 0x3025CF39, 0x3038A0A6,
+ 0x304B636D, 0x305E17AD, 0x3070BD81, 0x30835504,
+ 0x3095DE51, 0x30A85985, 0x30BAC6B9, 0x30CD2609,
+ 0x30DF778D, 0x30F1BB60, 0x3103F19C, 0x31161A59,
+ 0x312835B0, 0x313A43BA, 0x314C4490, 0x315E3849,
+ 0x31701EFD, 0x3181F8C4, 0x3193C5B4, 0x31A585E6,
+ 0x31B7396F, 0x31C8E066, 0x31DA7AE1, 0x31EC08F6,
+ 0x31FD8ABC, 0x320F0047, 0x322069AC, 0x3231C702,
+ 0x3243185C, 0x32545DCF, 0x32659770, 0x3276C552,
+ 0x3287E78A, 0x3298FE2C, 0x32AA094A, 0x32BB08F9,
+ 0x32CBFD4A, 0x32DCE652, 0x32EDC423, 0x32FE96D0,
+ 0x330F5E6A, 0x33201B04, 0x3330CCB0, 0x33417380,
+ 0x33520F85, 0x3362A0D0, 0x33732774, 0x3383A380,
+ 0x33941506, 0x33A47C17, 0x33B4D8C4, 0x33C52B1B,
+ 0x33D5732F, 0x33E5B10F, 0x33F5E4CA, 0x34060E71,
+ 0x34162E14, 0x342643C1, 0x34364F88, 0x34465178,
+ 0x345649A1, 0x34663810, 0x34761CD6, 0x3485F800,
+ 0x3495C99D, 0x34A591BB, 0x34B55069, 0x34C505B4,
+ 0x34D4B1AB, 0x34E4545B, 0x34F3EDD2, 0x35037E1D,
+ 0x3513054B, 0x35228367, 0x3531F881, 0x354164A3,
+ 0x3550C7DC, 0x35602239, 0x356F73C5, 0x357EBC8E,
+ 0x358DFCA0, 0x359D3408, 0x35AC62D1, 0x35BB8908,
+ 0x35CAA6B9, 0x35D9BBF0, 0x35E8C8B9, 0x35F7CD20,
+ 0x3606C92F, 0x3615BCF3, 0x3624A878, 0x36338BC8,
+ 0x364266EE, 0x365139F6, 0x366004EC, 0x366EC7D9,
+ 0x367D82C9, 0x368C35C6, 0x369AE0DC, 0x36A98414,
+ 0x36B81F7A, 0x36C6B317, 0x36D53EF7, 0x36E3C323,
+ 0x36F23FA5, 0x3700B488, 0x370F21D5, 0x371D8797,
+ 0x372BE5D7, 0x373A3CA0, 0x37488BF9, 0x3756D3EF,
+ 0x37651489, 0x37734DD1, 0x37817FD1, 0x378FAA92,
+ 0x379DCE1D, 0x37ABEA7C, 0x37B9FFB7, 0x37C80DD7,
+ 0x37D614E6, 0x37E414EC, 0x37F20DF1, 0x38000000,
+ 0x380DEB20, 0x381BCF5A, 0x3829ACB6, 0x3837833D,
+ 0x384552F8, 0x38531BEE, 0x3860DE28, 0x386E99AF,
+ 0x387C4E89, 0x3889FCC0, 0x3897A45B, 0x38A54563,
+ 0x38B2DFDF, 0x38C073D7, 0x38CE0152, 0x38DB885A,
+ 0x38E908F4, 0x38F68329, 0x3903F701, 0x39116483,
+ 0x391ECBB6, 0x392C2CA1, 0x3939874D, 0x3946DBC0,
+ 0x39542A01, 0x39617218, 0x396EB40C, 0x397BEFE4,
+ 0x398925A7, 0x3996555C, 0x39A37F09, 0x39B0A2B7,
+ 0x39BDC06A, 0x39CAD82B, 0x39D7EA01, 0x39E4F5F0,
+ 0x39F1FC01, 0x39FEFC3A, 0x3A0BF6A2, 0x3A18EB3E,
+ 0x3A25DA16, 0x3A32C32F, 0x3A3FA691, 0x3A4C8441,
+ 0x3A595C46, 0x3A662EA6, 0x3A72FB67, 0x3A7FC28F,
+ 0x3A8C8425, 0x3A99402E, 0x3AA5F6B1, 0x3AB2A7B3,
+ 0x3ABF533A, 0x3ACBF94D, 0x3AD899F1, 0x3AE5352C,
+ 0x3AF1CB03, 0x3AFE5B7D, 0x3B0AE6A0, 0x3B176C70,
+ 0x3B23ECF3, 0x3B306830, 0x3B3CDE2C, 0x3B494EEB,
+ 0x3B55BA74, 0x3B6220CC, 0x3B6E81F9, 0x3B7ADE00,
+ 0x3B8734E5, 0x3B9386B0, 0x3B9FD364, 0x3BAC1B07,
+ 0x3BB85D9E, 0x3BC49B2F, 0x3BD0D3BE, 0x3BDD0751,
+ 0x3BE935ED, 0x3BF55F97, 0x3C018453, 0x3C0DA427,
+ 0x3C19BF17, 0x3C25D52A, 0x3C31E662, 0x3C3DF2C6,
+ 0x3C49FA5B, 0x3C55FD24, 0x3C61FB27, 0x3C6DF468,
+ 0x3C79E8ED, 0x3C85D8B9, 0x3C91C3D2, 0x3C9DAA3C,
+ 0x3CA98BFC, 0x3CB56915, 0x3CC1418E, 0x3CCD156A,
+ 0x3CD8E4AE, 0x3CE4AF5E, 0x3CF0757F, 0x3CFC3714,
+ 0x3D07F423, 0x3D13ACB0, 0x3D1F60BF, 0x3D2B1055,
+ 0x3D36BB75, 0x3D426224, 0x3D4E0466, 0x3D59A23F,
+ 0x3D653BB4, 0x3D70D0C8, 0x3D7C6180, 0x3D87EDE0,
+ 0x3D9375EC, 0x3D9EF9A8, 0x3DAA7918, 0x3DB5F43F,
+ 0x3DC16B23, 0x3DCCDDC7, 0x3DD84C2E, 0x3DE3B65D,
+ 0x3DEF1C58, 0x3DFA7E22, 0x3E05DBC0, 0x3E113535,
+ 0x3E1C8A85, 0x3E27DBB3, 0x3E3328C4, 0x3E3E71BB,
+ 0x3E49B69C, 0x3E54F76B, 0x3E60342B, 0x3E6B6CE0,
+ 0x3E76A18D, 0x3E81D237, 0x3E8CFEE0, 0x3E98278D,
+ 0x3EA34C40, 0x3EAE6CFE, 0x3EB989CA, 0x3EC4A2A8,
+ 0x3ECFB79A, 0x3EDAC8A5, 0x3EE5D5CB, 0x3EF0DF10,
+ 0x3EFBE478, 0x3F06E606, 0x3F11E3BE, 0x3F1CDDA2,
+ 0x3F27D3B6, 0x3F32C5FD, 0x3F3DB47B, 0x3F489F32,
+ 0x3F538627, 0x3F5E695C, 0x3F6948D5, 0x3F742494,
+ 0x3F7EFC9D, 0x3F89D0F3, 0x3F94A19A, 0x3F9F6E94,
+ 0x3FAA37E4, 0x3FB4FD8E, 0x3FBFBF94, 0x3FCA7DFB,
+ 0x3FD538C4, 0x3FDFEFF3, 0x3FEAA38A, 0x3FF5538E,
+ 0x40000000
+};
+
+
diff --git a/media/codecs/mp3dec/src/pvmp3_tables.h b/media/codecs/mp3dec/src/pvmp3_tables.h
new file mode 100644
index 0000000..8f8509c
--- /dev/null
+++ b/media/codecs/mp3dec/src/pvmp3_tables.h
@@ -0,0 +1,124 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+ Filename: pvmp3_tables.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+------------------------------------------------------------------------------
+*/
+
+#ifndef PVMP3_TABLES_H
+#define PVMP3_TABLES_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+
+#include "pvmp3_dec_defs.h"
+#include "pv_mp3_huffman.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES AND SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+#define Qfmt_28(a) (int32(double(0x10000000)*(a)))
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; STRUCTURES TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+typedef struct
+{
+ int16 l[23];
+ int16 s[14];
+} mp3_scaleFactorBandIndex;
+
+
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ extern const int32 mp3_s_freq[4][4];
+ extern const int32 inv_sfreq[4];
+ extern const int16 mp3_bitrate[3][15];
+ extern const int32 power_one_third[513];
+
+ extern const mp3_scaleFactorBandIndex mp3_sfBandIndex[9];
+ extern const int32 mp3_shortwindBandWidths[9][13];
+ extern const int32 pqmfSynthWin[(HAN_SIZE/2) + 8];
+
+
+ extern const uint16 huffTable_1[];
+ extern const uint16 huffTable_2[];
+ extern const uint16 huffTable_3[];
+ extern const uint16 huffTable_5[];
+ extern const uint16 huffTable_6[];
+ extern const uint16 huffTable_7[];
+ extern const uint16 huffTable_8[];
+ extern const uint16 huffTable_9[];
+ extern const uint16 huffTable_10[];
+ extern const uint16 huffTable_11[];
+ extern const uint16 huffTable_12[];
+ extern const uint16 huffTable_13[];
+ extern const uint16 huffTable_15[];
+ extern const uint16 huffTable_16[];
+ extern const uint16 huffTable_24[];
+ extern const uint16 huffTable_32[];
+ extern const uint16 huffTable_33[];
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
diff --git a/media/codecs/mp3dec/src/s_huffcodetab.h b/media/codecs/mp3dec/src/s_huffcodetab.h
new file mode 100644
index 0000000..874943d
--- /dev/null
+++ b/media/codecs/mp3dec/src/s_huffcodetab.h
@@ -0,0 +1,98 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: s_huffcodetab.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+
+------------------------------------------------------------------------------
+ REFERENCES
+
+ [1] ISO MPEG Audio Subgroup Software Simulation Group (1996)
+ ISO 13818-3 MPEG-2 Audio Decoder - Lower Sampling Frequency Extension
+
+----------------------------------------------------------------------------*/
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef S_HUFFCODETAB_H
+#define S_HUFFCODETAB_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+#define HUFF_TBL 34
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; STRUCTURES TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+struct huffcodetab
+{
+ uint32 linbits; /*number of linbits */
+ uint16(*pdec_huff_tab)(tmp3Bits *);
+};
+
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/s_mp3bits.h b/media/codecs/mp3dec/src/s_mp3bits.h
new file mode 100644
index 0000000..b905b9a
--- /dev/null
+++ b/media/codecs/mp3dec/src/s_mp3bits.h
@@ -0,0 +1,107 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: s_mp3bits.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines the structure, BITS
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef S_MP3BITS_H
+#define S_MP3BITS_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_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].
+ */
+
+
+typedef struct
+{
+ uint8 *pBuffer;
+ uint32 usedBits;
+ uint32 inputBufferCurrentLength;
+ uint32 offset;
+} tmp3Bits;
+
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+#endif
+
diff --git a/media/codecs/mp3dec/src/s_tmp3dec_chan.h b/media/codecs/mp3dec/src/s_tmp3dec_chan.h
new file mode 100644
index 0000000..6eb8835
--- /dev/null
+++ b/media/codecs/mp3dec/src/s_tmp3dec_chan.h
@@ -0,0 +1,110 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: s_tmp3dec_chan.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines the structure, tmp3dec_chan.
+ This structure contains information per channel that needs to persist
+ between calls
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef S_TMP3DEC_CHAN_H
+#define S_TMP3DEC_CHAN_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "pvmp3_audio_type_defs.h"
+#include "pvmp3_dec_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
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct
+ {
+ int32 used_freq_lines;
+ int32 overlap[SUBBANDS_NUMBER*FILTERBANK_BANDS];
+ int32 work_buf_int32[SUBBANDS_NUMBER*FILTERBANK_BANDS]; /* working buffer */
+ int32 circ_buffer[480 + 576];
+
+ } tmp3dec_chan;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
diff --git a/media/codecs/mp3dec/src/s_tmp3dec_file.h b/media/codecs/mp3dec/src/s_tmp3dec_file.h
new file mode 100644
index 0000000..611e08f
--- /dev/null
+++ b/media/codecs/mp3dec/src/s_tmp3dec_file.h
@@ -0,0 +1,118 @@
+/* ------------------------------------------------------------------
+ * Copyright (C) 1998-2009 PacketVideo
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
+ * express or implied.
+ * See the License for the specific language governing permissions
+ * and limitations under the License.
+ * -------------------------------------------------------------------
+ */
+/*
+------------------------------------------------------------------------------
+ PacketVideo Corp.
+ MP3 Decoder Library
+
+ Filename: s_tmp3dec_file.h
+
+ Date: 09/21/2007
+
+------------------------------------------------------------------------------
+ REVISION HISTORY
+
+ Description:
+
+------------------------------------------------------------------------------
+ INCLUDE DESCRIPTION
+
+ This include file defines the structure, tmp3dec_file.
+ This structure contains information that needs to persist between calls
+
+------------------------------------------------------------------------------
+*/
+
+/*----------------------------------------------------------------------------
+; CONTINUE ONLY IF NOT ALREADY DEFINED
+----------------------------------------------------------------------------*/
+#ifndef S_TMP3DEC_FILE_H
+#define S_TMP3DEC_FILE_H
+
+/*----------------------------------------------------------------------------
+; INCLUDES
+----------------------------------------------------------------------------*/
+#include "s_tmp3dec_chan.h"
+#include "s_mp3bits.h"
+#include "s_huffcodetab.h"
+
+/*----------------------------------------------------------------------------
+; MACROS
+; Define module specific macros here
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; DEFINES
+; Include all pre-processor statements here.
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; EXTERNAL VARIABLES REFERENCES
+; Declare variables used in this module but defined elsewhere
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; SIMPLE TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; ENUMERATED TYPEDEF'S
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; STRUCTURES TYPEDEF'S
+----------------------------------------------------------------------------*/
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+ typedef struct
+ {
+ int32 num_channels;
+ int32 predicted_frame_size;
+ int32 frame_start;
+ int32 Scratch_mem[198];
+ tmp3dec_chan perChan[CHAN];
+ mp3ScaleFactors scaleFactors[CHAN];
+ mp3SideInfo sideInfo;
+ tmp3Bits mainDataStream;
+ uint8 mainDataBuffer[BUFSIZE];
+ tmp3Bits inputStream;
+ huffcodetab ht[HUFF_TBL];
+ } tmp3dec_file;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+/*----------------------------------------------------------------------------
+; GLOBAL FUNCTION DEFINITIONS
+; Function Prototype declaration
+----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+; END
+----------------------------------------------------------------------------*/
+
+#endif
+
+
+
+
diff --git a/media/codecs/mp3dec/test/Android.bp b/media/codecs/mp3dec/test/Android.bp
new file mode 100644
index 0000000..0ff8b12
--- /dev/null
+++ b/media/codecs/mp3dec/test/Android.bp
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+cc_test {
+ name: "Mp3DecoderTest",
+ gtest: true,
+
+ srcs: [
+ "mp3reader.cpp",
+ "Mp3DecoderTest.cpp",
+ ],
+
+ static_libs: [
+ "libstagefright_mp3dec",
+ "libsndfile",
+ "libaudioutils",
+ ],
+
+ shared_libs: [
+ "liblog",
+ ],
+
+ cflags: [
+ "-Werror",
+ "-Wall",
+ ],
+
+ sanitize: {
+ cfi: true,
+ misc_undefined: [
+ "unsigned-integer-overflow",
+ "signed-integer-overflow",
+ ],
+ },
+}
diff --git a/media/codecs/mp3dec/test/AndroidTest.xml b/media/codecs/mp3dec/test/AndroidTest.xml
new file mode 100644
index 0000000..29952eb
--- /dev/null
+++ b/media/codecs/mp3dec/test/AndroidTest.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2020 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.
+-->
+<configuration description="Test module config for Mp3 Decoder unit test">
+ <option name="test-suite-tag" value="Mp3DecoderTest" />
+ <target_preparer class="com.android.tradefed.targetprep.PushFilePreparer">
+ <option name="cleanup" value="true" />
+ <option name="push" value="Mp3DecoderTest->/data/local/tmp/Mp3DecoderTest" />
+ <option name="push-file"
+ key="https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mp3dec/test/Mp3DecoderTest-1.2.zip?unzip=true"
+ value="/data/local/tmp/Mp3DecoderTestRes/" />
+ </target_preparer>
+
+ <test class="com.android.tradefed.testtype.GTest" >
+ <option name="native-test-device-path" value="/data/local/tmp" />
+ <option name="module-name" value="Mp3DecoderTest" />
+ <option name="native-test-flag" value="-P /data/local/tmp/Mp3DecoderTestRes/" />
+ </test>
+</configuration>
diff --git a/media/codecs/mp3dec/test/Mp3DecoderTest.cpp b/media/codecs/mp3dec/test/Mp3DecoderTest.cpp
new file mode 100644
index 0000000..91326a8
--- /dev/null
+++ b/media/codecs/mp3dec/test/Mp3DecoderTest.cpp
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 2019 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 "Mp3DecoderTest"
+
+#include <utils/Log.h>
+
+#include <audio_utils/sndfile.h>
+#include <stdio.h>
+
+#include "mp3reader.h"
+#include "pvmp3decoder_api.h"
+
+#include "Mp3DecoderTestEnvironment.h"
+
+#define OUTPUT_FILE "/data/local/tmp/mp3Decode.out"
+
+constexpr int32_t kInputBufferSize = 1024 * 10;
+constexpr int32_t kOutputBufferSize = 4608 * 2;
+constexpr int32_t kMaxCount = 10;
+constexpr int32_t kNumFrameReset = 150;
+
+static Mp3DecoderTestEnvironment *gEnv = nullptr;
+
+class Mp3DecoderTest : public ::testing::TestWithParam<string> {
+ public:
+ Mp3DecoderTest() : mConfig(nullptr) {}
+
+ ~Mp3DecoderTest() {
+ if (mConfig) {
+ delete mConfig;
+ mConfig = nullptr;
+ }
+ }
+
+ virtual void SetUp() override {
+ mConfig = new tPVMP3DecoderExternal{};
+ ASSERT_NE(mConfig, nullptr) << "Failed to initialize config. No Memory available";
+ mConfig->equalizerType = flat;
+ mConfig->crcEnabled = false;
+ }
+
+ tPVMP3DecoderExternal *mConfig;
+ Mp3Reader mMp3Reader;
+
+ ERROR_CODE DecodeFrames(void *decoderbuf, SNDFILE *outFileHandle, SF_INFO sfInfo,
+ int32_t frameCount = INT32_MAX);
+ SNDFILE *openOutputFile(SF_INFO *sfInfo);
+};
+
+ERROR_CODE Mp3DecoderTest::DecodeFrames(void *decoderBuf, SNDFILE *outFileHandle, SF_INFO sfInfo,
+ int32_t frameCount) {
+ uint8_t inputBuf[kInputBufferSize];
+ int16_t outputBuf[kOutputBufferSize];
+ uint32_t bytesRead;
+ ERROR_CODE decoderErr;
+ while (frameCount > 0) {
+ bool success = mMp3Reader.getFrame(inputBuf, &bytesRead);
+ if (!success) {
+ break;
+ }
+ mConfig->inputBufferCurrentLength = bytesRead;
+ mConfig->inputBufferMaxLength = 0;
+ mConfig->inputBufferUsedLength = 0;
+ mConfig->pInputBuffer = inputBuf;
+ mConfig->pOutputBuffer = outputBuf;
+ mConfig->outputFrameSize = kOutputBufferSize / sizeof(int16_t);
+ decoderErr = pvmp3_framedecoder(mConfig, decoderBuf);
+ if (decoderErr != NO_DECODING_ERROR) break;
+ sf_writef_short(outFileHandle, outputBuf, mConfig->outputFrameSize / sfInfo.channels);
+ frameCount--;
+ }
+ return decoderErr;
+}
+
+SNDFILE *Mp3DecoderTest::openOutputFile(SF_INFO *sfInfo) {
+ memset(sfInfo, 0, sizeof(SF_INFO));
+ sfInfo->channels = mMp3Reader.getNumChannels();
+ sfInfo->format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+ sfInfo->samplerate = mMp3Reader.getSampleRate();
+ SNDFILE *outFileHandle = sf_open(OUTPUT_FILE, SFM_WRITE, sfInfo);
+ return outFileHandle;
+}
+
+TEST_F(Mp3DecoderTest, MultiCreateMp3DecoderTest) {
+ size_t memRequirements = pvmp3_decoderMemRequirements();
+ ASSERT_NE(memRequirements, 0) << "Failed to get the memory requirement size";
+ void *decoderBuf = malloc(memRequirements);
+ ASSERT_NE(decoderBuf, nullptr)
+ << "Failed to allocate decoder memory of size " << memRequirements;
+ for (int count = 0; count < kMaxCount; count++) {
+ pvmp3_InitDecoder(mConfig, decoderBuf);
+ ALOGV("Decoder created successfully");
+ }
+ if (decoderBuf) {
+ free(decoderBuf);
+ decoderBuf = nullptr;
+ }
+}
+
+TEST_P(Mp3DecoderTest, DecodeTest) {
+ size_t memRequirements = pvmp3_decoderMemRequirements();
+ ASSERT_NE(memRequirements, 0) << "Failed to get the memory requirement size";
+ void *decoderBuf = malloc(memRequirements);
+ ASSERT_NE(decoderBuf, nullptr)
+ << "Failed to allocate decoder memory of size " << memRequirements;
+
+ pvmp3_InitDecoder(mConfig, decoderBuf);
+ ALOGV("Decoder created successfully");
+ string inputFile = gEnv->getRes() + GetParam();
+ bool status = mMp3Reader.init(inputFile.c_str());
+ ASSERT_TRUE(status) << "Unable to initialize the mp3Reader";
+
+ // Open the output file.
+ SF_INFO sfInfo;
+ SNDFILE *outFileHandle = openOutputFile(&sfInfo);
+ ASSERT_NE(outFileHandle, nullptr) << "Error opening output file for writing decoded output";
+
+ ERROR_CODE decoderErr = DecodeFrames(decoderBuf, outFileHandle, sfInfo);
+ ASSERT_EQ(decoderErr, NO_DECODING_ERROR) << "Failed to decode the frames";
+ ASSERT_EQ(sfInfo.channels, mConfig->num_channels) << "Number of channels does not match";
+ ASSERT_EQ(sfInfo.samplerate, mConfig->samplingRate) << "Sample rate does not match";
+
+ mMp3Reader.close();
+ sf_close(outFileHandle);
+ if (decoderBuf) {
+ free(decoderBuf);
+ decoderBuf = nullptr;
+ }
+}
+
+TEST_P(Mp3DecoderTest, ResetDecoderTest) {
+ size_t memRequirements = pvmp3_decoderMemRequirements();
+ ASSERT_NE(memRequirements, 0) << "Failed to get the memory requirement size";
+ void *decoderBuf = malloc(memRequirements);
+ ASSERT_NE(decoderBuf, nullptr)
+ << "Failed to allocate decoder memory of size " << memRequirements;
+
+ pvmp3_InitDecoder(mConfig, decoderBuf);
+ ALOGV("Decoder created successfully.");
+ string inputFile = gEnv->getRes() + GetParam();
+ bool status = mMp3Reader.init(inputFile.c_str());
+ ASSERT_TRUE(status) << "Unable to initialize the mp3Reader";
+
+ // Open the output file.
+ SF_INFO sfInfo;
+ SNDFILE *outFileHandle = openOutputFile(&sfInfo);
+ ASSERT_NE(outFileHandle, nullptr) << "Error opening output file for writing decoded output";
+
+ ERROR_CODE decoderErr;
+ decoderErr = DecodeFrames(decoderBuf, outFileHandle, sfInfo, kNumFrameReset);
+ ASSERT_EQ(decoderErr, NO_DECODING_ERROR) << "Failed to decode the frames";
+ ASSERT_EQ(sfInfo.channels, mConfig->num_channels) << "Number of channels does not match";
+ ASSERT_EQ(sfInfo.samplerate, mConfig->samplingRate) << "Sample rate does not match";
+
+ pvmp3_resetDecoder(decoderBuf);
+ // Decode the same file.
+ decoderErr = DecodeFrames(decoderBuf, outFileHandle, sfInfo);
+ ASSERT_EQ(decoderErr, NO_DECODING_ERROR) << "Failed to decode the frames";
+ ASSERT_EQ(sfInfo.channels, mConfig->num_channels) << "Number of channels does not match";
+ ASSERT_EQ(sfInfo.samplerate, mConfig->samplingRate) << "Sample rate does not match";
+
+ mMp3Reader.close();
+ sf_close(outFileHandle);
+ if (decoderBuf) {
+ free(decoderBuf);
+ decoderBuf = nullptr;
+ }
+}
+
+INSTANTIATE_TEST_SUITE_P(Mp3DecoderTestAll, Mp3DecoderTest,
+ ::testing::Values(("bbb_44100hz_2ch_128kbps_mp3_30sec.mp3"),
+ ("bbb_44100hz_2ch_128kbps_mp3_5mins.mp3"),
+ ("bug_136053885.mp3"),
+ ("bbb_2ch_44kHz_lame_crc.mp3"),
+ ("bbb_mp3_stereo_192kbps_48000hz.mp3")));
+
+int main(int argc, char **argv) {
+ gEnv = new Mp3DecoderTestEnvironment();
+ ::testing::AddGlobalTestEnvironment(gEnv);
+ ::testing::InitGoogleTest(&argc, argv);
+ int status = gEnv->initFromOptions(argc, argv);
+ if (status == 0) {
+ status = RUN_ALL_TESTS();
+ ALOGV("Test result = %d\n", status);
+ }
+ return status;
+}
diff --git a/media/codecs/mp3dec/test/Mp3DecoderTestEnvironment.h b/media/codecs/mp3dec/test/Mp3DecoderTestEnvironment.h
new file mode 100644
index 0000000..a54b34c
--- /dev/null
+++ b/media/codecs/mp3dec/test/Mp3DecoderTestEnvironment.h
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2019 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 __MP3DECODER_TEST_ENVIRONMENT_H__
+#define __MP3DECODER_TEST_ENVIRONMENT_H__
+
+#include <gtest/gtest.h>
+
+#include <getopt.h>
+
+using namespace std;
+
+class Mp3DecoderTestEnvironment : public ::testing::Environment {
+ public:
+ Mp3DecoderTestEnvironment() : res("/data/local/tmp/") {}
+
+ // Parses the command line arguments
+ int initFromOptions(int argc, char **argv);
+
+ void setRes(const char *_res) { res = _res; }
+
+ const string getRes() const { return res; }
+
+ private:
+ string res;
+};
+
+int Mp3DecoderTestEnvironment::initFromOptions(int argc, char **argv) {
+ static struct option options[] = {{"res", required_argument, 0, 'P'}, {0, 0, 0, 0}};
+
+ while (true) {
+ int index = 0;
+ int c = getopt_long(argc, argv, "P:", options, &index);
+ if (c == -1) {
+ break;
+ }
+
+ switch (c) {
+ case 'P':
+ setRes(optarg);
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (optind < argc) {
+ fprintf(stderr,
+ "unrecognized option: %s\n\n"
+ "usage: %s <gtest options> <test options>\n\n"
+ "test options are:\n\n"
+ "-P, --path: Resource files directory location\n",
+ argv[optind ?: 1], argv[0]);
+ return 2;
+ }
+ return 0;
+}
+
+#endif // __MP3DECODER_TEST_ENVIRONMENT_H__
diff --git a/media/codecs/mp3dec/test/README.md b/media/codecs/mp3dec/test/README.md
new file mode 100644
index 0000000..f59fec7
--- /dev/null
+++ b/media/codecs/mp3dec/test/README.md
@@ -0,0 +1,39 @@
+## Media Testing ##
+---
+#### Mp3Decoder :
+The Mp3Decoder Test Suite validates the mp3decoder available in libstagefright.
+
+Run the following steps to build the test suite:
+```
+m Mp3DecoderTest
+```
+
+The 32-bit binaries will be created in the following path : ${OUT}/data/nativetest/
+
+The 64-bit binaries will be created in the following path : ${OUT}/data/nativetest64/
+
+To test 64-bit binary push binaries from nativetest64.
+```
+adb push ${OUT}/data/nativetest64/Mp3DecoderTest/Mp3DecoderTest /data/local/tmp/
+```
+
+To test 32-bit binary push binaries from nativetest.
+```
+adb push ${OUT}/data/nativetest/Mp3DecoderTest/Mp3DecoderTest /data/local/tmp/
+```
+
+The resource file for the tests is taken from [here](https://storage.googleapis.com/android_media/frameworks/av/media/libstagefright/mp3dec/test/Mp3DecoderTest.zip). Download, unzip and push these files into device for testing.
+
+```
+adb push Mp3DecoderTestRes/. /data/local/tmp/
+```
+
+usage: Mp3DecoderTest -P \<path_to_folder\>
+```
+adb shell /data/local/tmp/Mp3DecoderTest -P /data/local/tmp/Mp3DecoderTestRes/
+```
+Alternatively, the test can also be run using atest command.
+
+```
+atest Mp3DecoderTest -- --enable-module-dynamic-download=true
+```
diff --git a/media/codecs/mp3dec/test/mp3dec_test.cpp b/media/codecs/mp3dec/test/mp3dec_test.cpp
new file mode 100644
index 0000000..26d62f3
--- /dev/null
+++ b/media/codecs/mp3dec/test/mp3dec_test.cpp
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+
+#include "pvmp3decoder_api.h"
+#include "mp3reader.h"
+#include <audio_utils/sndfile.h>
+
+using namespace std;
+
+enum {
+ kInputBufferSize = 10 * 1024,
+ kOutputBufferSize = 4608 * 2,
+};
+
+int main(int argc, const char **argv) {
+
+ if (argc != 3) {
+ fprintf(stderr, "Usage %s <input file> <output file>\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+
+ // Initialize the config.
+ tPVMP3DecoderExternal config;
+ config.equalizerType = flat;
+ config.crcEnabled = false;
+
+ // Allocate the decoder memory.
+ uint32_t memRequirements = pvmp3_decoderMemRequirements();
+ void *decoderBuf = malloc(memRequirements);
+ assert(decoderBuf != NULL);
+
+ // Initialize the decoder.
+ pvmp3_InitDecoder(&config, decoderBuf);
+
+ // Open the input file.
+ Mp3Reader mp3Reader;
+ bool success = mp3Reader.init(argv[1]);
+ if (!success) {
+ fprintf(stderr, "Encountered error reading %s\n", argv[1]);
+ free(decoderBuf);
+ return EXIT_FAILURE;
+ }
+
+ // Open the output file.
+ SF_INFO sfInfo;
+ memset(&sfInfo, 0, sizeof(SF_INFO));
+ sfInfo.channels = mp3Reader.getNumChannels();
+ sfInfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+ sfInfo.samplerate = mp3Reader.getSampleRate();
+ SNDFILE *handle = sf_open(argv[2], SFM_WRITE, &sfInfo);
+ if (handle == NULL) {
+ fprintf(stderr, "Encountered error writing %s\n", argv[2]);
+ mp3Reader.close();
+ free(decoderBuf);
+ return EXIT_FAILURE;
+ }
+
+ // Allocate input buffer.
+ uint8_t *inputBuf = static_cast<uint8_t*>(malloc(kInputBufferSize));
+ assert(inputBuf != NULL);
+
+ // Allocate output buffer.
+ int16_t *outputBuf = static_cast<int16_t*>(malloc(kOutputBufferSize));
+ assert(outputBuf != NULL);
+
+ // Decode loop.
+ int retVal = EXIT_SUCCESS;
+ while (1) {
+ // Read input from the file.
+ uint32_t bytesRead;
+ bool success = mp3Reader.getFrame(inputBuf, &bytesRead);
+ if (!success) break;
+
+ // Set the input config.
+ config.inputBufferCurrentLength = bytesRead;
+ config.inputBufferMaxLength = 0;
+ config.inputBufferUsedLength = 0;
+ config.pInputBuffer = inputBuf;
+ config.pOutputBuffer = outputBuf;
+ config.outputFrameSize = kOutputBufferSize / sizeof(int16_t);
+
+ ERROR_CODE decoderErr;
+ decoderErr = pvmp3_framedecoder(&config, decoderBuf);
+ if (decoderErr != NO_DECODING_ERROR) {
+ fprintf(stderr, "Decoder encountered error\n");
+ retVal = EXIT_FAILURE;
+ break;
+ }
+ sf_writef_short(handle, outputBuf,
+ config.outputFrameSize / sfInfo.channels);
+ }
+
+ // Close input reader and output writer.
+ mp3Reader.close();
+ sf_close(handle);
+
+ // Free allocated memory.
+ free(inputBuf);
+ free(outputBuf);
+ free(decoderBuf);
+
+ return retVal;
+}
diff --git a/media/codecs/mp3dec/test/mp3reader.cpp b/media/codecs/mp3dec/test/mp3reader.cpp
new file mode 100644
index 0000000..b3138ec
--- /dev/null
+++ b/media/codecs/mp3dec/test/mp3reader.cpp
@@ -0,0 +1,425 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <stdint.h>
+#include "mp3reader.h"
+
+static uint32_t U32_AT(const uint8_t *ptr) {
+ return ptr[0] << 24 | ptr[1] << 16 | ptr[2] << 8 | ptr[3];
+}
+
+static bool parseHeader(
+ uint32_t header, size_t *frame_size,
+ uint32_t *out_sampling_rate = NULL, uint32_t *out_channels = NULL ,
+ uint32_t *out_bitrate = NULL, uint32_t *out_num_samples = NULL) {
+ *frame_size = 0;
+
+ if (out_sampling_rate) {
+ *out_sampling_rate = 0;
+ }
+
+ if (out_channels) {
+ *out_channels = 0;
+ }
+
+ if (out_bitrate) {
+ *out_bitrate = 0;
+ }
+
+ if (out_num_samples) {
+ *out_num_samples = 1152;
+ }
+
+ if ((header & 0xffe00000) != 0xffe00000) {
+ return false;
+ }
+
+ unsigned version = (header >> 19) & 3;
+
+ if (version == 0x01) {
+ return false;
+ }
+
+ unsigned layer = (header >> 17) & 3;
+
+ if (layer == 0x00) {
+ return false;
+ }
+
+ unsigned bitrate_index = (header >> 12) & 0x0f;
+
+ if (bitrate_index == 0 || bitrate_index == 0x0f) {
+ // Disallow "free" bitrate.
+ return false;
+ }
+
+ unsigned sampling_rate_index = (header >> 10) & 3;
+
+ if (sampling_rate_index == 3) {
+ return false;
+ }
+
+ static const int kSamplingRateV1[] = { 44100, 48000, 32000 };
+ int sampling_rate = kSamplingRateV1[sampling_rate_index];
+ if (version == 2 /* V2 */) {
+ sampling_rate /= 2;
+ } else if (version == 0 /* V2.5 */) {
+ sampling_rate /= 4;
+ }
+
+ unsigned padding = (header >> 9) & 1;
+
+ if (layer == 3) {
+ // layer I
+
+ static const int kBitrateV1[] = {
+ 32, 64, 96, 128, 160, 192, 224, 256,
+ 288, 320, 352, 384, 416, 448
+ };
+
+ static const int kBitrateV2[] = {
+ 32, 48, 56, 64, 80, 96, 112, 128,
+ 144, 160, 176, 192, 224, 256
+ };
+
+ int bitrate =
+ (version == 3 /* V1 */)
+ ? kBitrateV1[bitrate_index - 1]
+ : kBitrateV2[bitrate_index - 1];
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+
+ *frame_size = (12000 * bitrate / sampling_rate + padding) * 4;
+
+ if (out_num_samples) {
+ *out_num_samples = 384;
+ }
+ } else {
+ // layer II or III
+
+ static const int kBitrateV1L2[] = {
+ 32, 48, 56, 64, 80, 96, 112, 128,
+ 160, 192, 224, 256, 320, 384
+ };
+
+ static const int kBitrateV1L3[] = {
+ 32, 40, 48, 56, 64, 80, 96, 112,
+ 128, 160, 192, 224, 256, 320
+ };
+
+ static const int kBitrateV2[] = {
+ 8, 16, 24, 32, 40, 48, 56, 64,
+ 80, 96, 112, 128, 144, 160
+ };
+
+ int bitrate;
+ if (version == 3 /* V1 */) {
+ bitrate = (layer == 2 /* L2 */)
+ ? kBitrateV1L2[bitrate_index - 1]
+ : kBitrateV1L3[bitrate_index - 1];
+
+ if (out_num_samples) {
+ *out_num_samples = 1152;
+ }
+ } else {
+ // V2 (or 2.5)
+
+ bitrate = kBitrateV2[bitrate_index - 1];
+ if (out_num_samples) {
+ *out_num_samples = (layer == 1 /* L3 */) ? 576 : 1152;
+ }
+ }
+
+ if (out_bitrate) {
+ *out_bitrate = bitrate;
+ }
+
+ if (version == 3 /* V1 */) {
+ *frame_size = 144000 * bitrate / sampling_rate + padding;
+ } else {
+ // V2 or V2.5
+ size_t tmp = (layer == 1 /* L3 */) ? 72000 : 144000;
+ *frame_size = tmp * bitrate / sampling_rate + padding;
+ }
+ }
+
+ if (out_sampling_rate) {
+ *out_sampling_rate = sampling_rate;
+ }
+
+ if (out_channels) {
+ int channel_mode = (header >> 6) & 3;
+
+ *out_channels = (channel_mode == 3) ? 1 : 2;
+ }
+
+ return true;
+}
+
+// Mask to extract the version, layer, sampling rate parts of the MP3 header,
+// which should be same for all MP3 frames.
+static const uint32_t kMask = 0xfffe0c00;
+
+static ssize_t sourceReadAt(FILE *fp, off64_t offset, void *data, size_t size) {
+ int retVal = fseek(fp, offset, SEEK_SET);
+ if (retVal != EXIT_SUCCESS) {
+ return 0;
+ } else {
+ return fread(data, 1, size, fp);
+ }
+}
+
+// Resync to next valid MP3 frame in the file.
+static bool resync(
+ FILE *fp, uint32_t match_header,
+ off64_t *inout_pos, uint32_t *out_header) {
+
+ if (*inout_pos == 0) {
+ // Skip an optional ID3 header if syncing at the very beginning
+ // of the datasource.
+
+ for (;;) {
+ uint8_t id3header[10];
+ int retVal = sourceReadAt(fp, *inout_pos, id3header,
+ sizeof(id3header));
+ if (retVal < (ssize_t)sizeof(id3header)) {
+ // If we can't even read these 10 bytes, we might as well bail
+ // out, even if there _were_ 10 bytes of valid mp3 audio data...
+ return false;
+ }
+
+ if (memcmp("ID3", id3header, 3)) {
+ break;
+ }
+
+ // Skip the ID3v2 header.
+
+ size_t len =
+ ((id3header[6] & 0x7f) << 21)
+ | ((id3header[7] & 0x7f) << 14)
+ | ((id3header[8] & 0x7f) << 7)
+ | (id3header[9] & 0x7f);
+
+ len += 10;
+
+ *inout_pos += len;
+ }
+
+ }
+
+ off64_t pos = *inout_pos;
+ bool valid = false;
+
+ const int32_t kMaxReadBytes = 1024;
+ const int32_t kMaxBytesChecked = 128 * 1024;
+ uint8_t buf[kMaxReadBytes];
+ ssize_t bytesToRead = kMaxReadBytes;
+ ssize_t totalBytesRead = 0;
+ ssize_t remainingBytes = 0;
+ bool reachEOS = false;
+ uint8_t *tmp = buf;
+
+ do {
+ if (pos >= *inout_pos + kMaxBytesChecked) {
+ // Don't scan forever.
+ break;
+ }
+
+ if (remainingBytes < 4) {
+ if (reachEOS) {
+ break;
+ } else {
+ memcpy(buf, tmp, remainingBytes);
+ bytesToRead = kMaxReadBytes - remainingBytes;
+
+ /*
+ * The next read position should start from the end of
+ * the last buffer, and thus should include the remaining
+ * bytes in the buffer.
+ */
+ totalBytesRead = sourceReadAt(fp, pos + remainingBytes,
+ buf + remainingBytes, bytesToRead);
+
+ if (totalBytesRead <= 0) {
+ break;
+ }
+ reachEOS = (totalBytesRead != bytesToRead);
+ remainingBytes += totalBytesRead;
+ tmp = buf;
+ continue;
+ }
+ }
+
+ uint32_t header = U32_AT(tmp);
+
+ if (match_header != 0 && (header & kMask) != (match_header & kMask)) {
+ ++pos;
+ ++tmp;
+ --remainingBytes;
+ continue;
+ }
+
+ size_t frame_size;
+ uint32_t sample_rate, num_channels, bitrate;
+ if (!parseHeader(
+ header, &frame_size,
+ &sample_rate, &num_channels, &bitrate)) {
+ ++pos;
+ ++tmp;
+ --remainingBytes;
+ continue;
+ }
+
+ // We found what looks like a valid frame,
+ // now find its successors.
+
+ off64_t test_pos = pos + frame_size;
+
+ valid = true;
+ const int FRAME_MATCH_REQUIRED = 3;
+ for (int j = 0; j < FRAME_MATCH_REQUIRED; ++j) {
+ uint8_t tmp[4];
+ ssize_t retval = sourceReadAt(fp, test_pos, tmp, sizeof(tmp));
+ if (retval < (ssize_t)sizeof(tmp)) {
+ valid = false;
+ break;
+ }
+
+ uint32_t test_header = U32_AT(tmp);
+
+ if ((test_header & kMask) != (header & kMask)) {
+ valid = false;
+ break;
+ }
+
+ size_t test_frame_size;
+ if (!parseHeader(test_header, &test_frame_size)) {
+ valid = false;
+ break;
+ }
+
+ test_pos += test_frame_size;
+ }
+
+ if (valid) {
+ *inout_pos = pos;
+
+ if (out_header != NULL) {
+ *out_header = header;
+ }
+ }
+
+ ++pos;
+ ++tmp;
+ --remainingBytes;
+ } while (!valid);
+
+ return valid;
+}
+
+Mp3Reader::Mp3Reader() : mFp(NULL) {
+}
+
+// Initialize the MP3 reader.
+bool Mp3Reader::init(const char *file) {
+
+ // Open the file.
+ mFp = fopen(file, "rb");
+ if (mFp == NULL) return false;
+
+ // Sync to the first valid frame.
+ off64_t pos = 0;
+ uint32_t header;
+ bool success = resync(mFp, 0 /*match_header*/, &pos, &header);
+ if (success == false) return false;
+
+ mCurrentPos = pos;
+ mFixedHeader = header;
+
+ size_t frame_size;
+ return parseHeader(header, &frame_size, &mSampleRate,
+ &mNumChannels, &mBitrate);
+}
+
+// Get the next valid MP3 frame.
+bool Mp3Reader::getFrame(void *buffer, uint32_t *size) {
+
+ size_t frame_size;
+ uint32_t bitrate;
+ uint32_t num_samples;
+ uint32_t sample_rate;
+ for (;;) {
+ ssize_t n = sourceReadAt(mFp, mCurrentPos, buffer, 4);
+ if (n < 4) {
+ return false;
+ }
+
+ uint32_t header = U32_AT((const uint8_t *)buffer);
+
+ if ((header & kMask) == (mFixedHeader & kMask)
+ && parseHeader(
+ header, &frame_size, &sample_rate, NULL /*out_channels*/,
+ &bitrate, &num_samples)) {
+ break;
+ }
+
+ // Lost sync.
+ off64_t pos = mCurrentPos;
+ if (!resync(mFp, mFixedHeader, &pos, NULL /*out_header*/)) {
+ // Unable to resync. Signalling end of stream.
+ return false;
+ }
+
+ mCurrentPos = pos;
+
+ // Try again with the new position.
+ }
+ ssize_t n = sourceReadAt(mFp, mCurrentPos, buffer, frame_size);
+ if (n < (ssize_t)frame_size) {
+ return false;
+ }
+
+ *size = frame_size;
+ mCurrentPos += frame_size;
+ return true;
+}
+
+// Close the MP3 reader.
+void Mp3Reader::close() {
+ assert(mFp != NULL);
+ fclose(mFp);
+}
+
+Mp3Reader::~Mp3Reader() {
+}
diff --git a/media/codecs/mp3dec/test/mp3reader.h b/media/codecs/mp3dec/test/mp3reader.h
new file mode 100644
index 0000000..871f664
--- /dev/null
+++ b/media/codecs/mp3dec/test/mp3reader.h
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifndef MP3READER_H_
+#define MP3READER_H_
+
+class Mp3Reader {
+public:
+ Mp3Reader();
+ bool init(const char *file);
+ bool getFrame(void *buffer, uint32_t *size);
+ uint32_t getSampleRate() { return mSampleRate;}
+ uint32_t getNumChannels() { return mNumChannels;}
+ void close();
+ ~Mp3Reader();
+private:
+ FILE *mFp;
+ uint32_t mFixedHeader;
+ off64_t mCurrentPos;
+ uint32_t mSampleRate;
+ uint32_t mNumChannels;
+ uint32_t mBitrate;
+};
+
+
+#endif /* MP3READER_H_ */